usnistgov / fipy

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

Question about the example mesh1D.py #948

Closed CalebDmArcher closed 11 months ago

CalebDmArcher commented 11 months ago

I have some questions in examples/diffusion/mesh1D.py about using sweep() in the case that 'diffusivity is not only non-uniform'. Hope someone can help me.

The example uses a while loop (while res > 1e-6:) to solve the steady-state solution; the example also sets a sweeping number per step and runs for a certain number of steps for the transient-state solution. I was trying to use the while loop in the transient state for each step and turns out it does not work. I noticed that if I use the while loop in the transient state, the solution will always stay at the solution of the first step and will not update anymore.

To better show my confusion, I wrote a code for comparison in the attachment.

In this code, phi[0] stores the values that are calculated by using the while loop. And phi[1] stores the values that are calculated by setting the sweeping value of 5 per step. I used a total step number of 1000 which is a relatively large number. (I can see that the plot of phi[1] is indeed identical to the plot of the steady-state result in the example which shows the consistency between the steady-state result and transient-state result.)

I am very confused as to why the while loop does not work for the transient-state case. I thought the while loop only makes the results more accurate. Can anyone point out where I got it wrong?

comparison.zip