usnistgov / fipy

FiPy is a Finite Volume PDE solver written in Python
http://pages.nist.gov/fipy/en/latest
Other
506 stars 148 forks source link

Does the dt in sweep changes the total time span of the solution? #837

Closed Yifath7 closed 2 years ago

Yifath7 commented 2 years ago

Hi, I am currently trying to solve a large PDE system with 18 PDEs and ODEs. 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!

guyer commented 2 years ago

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.