anderkve / FYS3150

https://anderkve.github.io/FYS3150
26 stars 14 forks source link

Time dependency #62

Closed Norahelgeland closed 1 year ago

Norahelgeland commented 1 year ago

Hello :)

We are wondering if we should use eq. 15 and 17 in our Euler and Runge Kutta functions. When we update the velocity and the position for the next time step we do not use eq. 15 and 17 seeing that we already have calculated the position in the last iteration. Is this wrong? We were also wondering how it is possible to make the total force time dependent seeing that it only depends on the position.

anderkve commented 1 year ago

Hi @Norahelgeland!

We are wondering if we should use eq. 15 and 17 in our Euler and Runge Kutta functions.

No, indeed you shouldn't (and you can't) use these equations directly in the numerical solvers. There's a short note about this below the final set of differential equations, eqs. 18--20. For a bit more detail: In the lectures we've discussed Forward Euler and RK4 as methods for solving first-order differential equations. The equations we encounter here in Eqs. 13--15 and in Eqs. 18--20 are second-order differential equations. So the first step in using either FE or RK4 to solve these equations is to formulate the problem in terms of coupled, first-order differential equations:

$$ \frac{d \mathbf{r}}{dt} = \mathbf{v} $$

$$ \frac{d \mathbf{v}}{dt} = \mathbf{a} = \frac{\mathbf{F}}{m} $$

So all the physics-specific details in the second-order differential equations in the project description will effectively be contained in the function(s) you use to compute the total force $\mathbf{F}$ acting on a particle at position $\mathbf{r}$ with velocity $\mathbf{v}$ at time $t$.

We were also wondering how it is possible to make the total force time dependent seeing that it only depends on the position.

In problem 9 the external force will get an explicit time dependence, see Eq. 21. This means that you at this point probably want to modify some of the function declarations relative to those suggested in the code snippet at the bottom, so that e.g. the function for the external force takes the specific time $t$ as one of the input arguments. (There's a comment hinting at this below the code snippet.)

Hope that helps! :)