python - store old values FiPy -
i'm trying solve differential equations using fipy in python , newbie, still have problems. following: define cell variable, solve equation variable , update it. want store values after each time iteration. here example:
a = cellvariable(mesh,name='a', value=0., hasold=true) # eq equation involving 'a' # define array store values of 'a' after solving 'eq' a_tt = [] t in range(10): eq.sweep(dt=0.01) a.updateold() a_tt.append(a)
i realize mistake - values in 'a_tt' updated every time update 'a', have @ end array same elements. shoud alternatively avoid this?
i think a_tt.append(a.copy())
might work.
otherwise, method used in sweeps part of http://www.ctcms.nist.gov/fipy/examples/diffusion/generated/examples.diffusion.mesh1d.html should work. like:
a_tt.append(cellvariable(mesh=m, value=a.value))
Comments
Post a Comment