pythonodefipy

Chosen dt in sweep in FiPy package changes time domain of solution?


I am currently trying to solve a large PDE system with 18 PDEs and ODEs (which is why I use FiPy and not odeint from scipy). One of the equations is quite simple: dROS/dt = 0.06 which I implemented as follows:

eqn_ROS = ( TransientTerm(var=ROS) == 0.06 )

The desired time range is from o to 3650, so I solve this way, using sweep (I write the update only for one equation here):

for t in range(3650): 
    ROS.updateOld()
    res = 1e10 
    while res > 0.1:
        res = eqn_ROS.sweep(var=ROS, dt=1e-5)

As I expect to get a plot of ROS = 0.06t, when I plot this graph of ROS vs t (after yielding the right values from tsv files created with TSVviewr), t axis is indeed from 0 to 3650, however, the ROS values are much smaller than expected and do not match the wanted value, which is 36500.06.

I must add that I have tried solving this equation alone with the same sweep dt and yet the values are wrong.

Could this problem occur because of the dt I chose for the sweep? or maybe something else I completely misunderstood?

Thanks in advance!


Solution

  • [Answered on GitHub. Please ask in one location or the other, but not both]

    You are taking 3650 steps of size 1e-5, for a total duration of 3.65e-2, so I would expect ROS to be 0.00219 at the end, which is what happens.

    This equation is linear in ROS, so there's no need to sweep it.