added update_position method #8

Open
eceku wants to merge 1 commit from eceku/2025-plovdiv-scientific-patterns:scientific into main

View file

@ -17,7 +17,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 4,
"metadata": { "metadata": {
"ExecuteTime": { "ExecuteTime": {
"end_time": "2018-07-27T15:05:51.531289Z", "end_time": "2018-07-27T15:05:51.531289Z",
@ -35,7 +35,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 7,
"metadata": { "metadata": {
"pycharm": { "pycharm": {
"name": "#%%\n" "name": "#%%\n"
@ -59,13 +59,16 @@
" def momentum(self):\n", " def momentum(self):\n",
" return self.mass * self.velocity\n", " return self.mass * self.velocity\n",
"\n", "\n",
" def update_position(self, position, dt):\n",
" return position + self.velocity * dt\n",
"\n",
"particle = Particle(mass=2.1, velocity=0.8)\n", "particle = Particle(mass=2.1, velocity=0.8)\n",
"print(particle.momentum())" "print(particle.momentum())"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 5,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -84,10 +87,23 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 8,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
"source": [] {
"data": {
"text/plain": [
"8.28"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"particle.update_position(position = position, dt = 0.1)"
]
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -118,7 +134,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.10.11" "version": "3.13.6"
}, },
"toc": { "toc": {
"nav_menu": { "nav_menu": {
@ -142,5 +158,5 @@
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 2 "nbformat_minor": 4
} }