Dear all,

we are currently using the fipy.Viewer class to visualise a scalar field as a 
function of time (as was demonstrated in the diffusion example provided by 
fipy); example code attached below.

In addition, I would like to mark a particular x,y position on that plot which 
changes from iteration to iteration.

If I was not using fipy, I could use matplotlib to update for every iteration a 
plot of using

>>> plot( [x], [y], 'o') 

to plot a circle at position (x,y), say.


I couldn't make this work together with fipy -- presumably because fipy wraps 
up some matplotlib functionality to make things more convenient.

Can anybody give some general advice on what approach is likely to deliver what 
I need here? (I hope I have described the problem clearly enough). If there was 
an example related to this that I haven't found, please point me to that and 
this may answer my question.


Thanks in advance, and thank you for providing fipy and the user support.

Best wishes,

Hans






import fipy 
 
Ly = 20 
Lx = Ly 
nx = 20 
ny = nx 
dx = 1. 
dy = dx 
 
mesh = fipy.Grid2D(dx=dx, dy=dy, nx=nx, ny=ny) 
 
phi = fipy.CellVariable(name = "solution variable", 
                        mesh = mesh, 
                        value = 0.0) 
 
#Basic equation 
D = 1 
eq = fipy.TransientTerm() == fipy.DiffusionTerm(coeff=D)  
 
#boundary conditions 
phi_outside = 0.1 
x, y = mesh.getFaceCenters() 
facesTopLeft = ((mesh.getFacesLeft() & (y > Ly / 2)) 
                | (mesh.getFacesTop() & (x < Lx / 2))) 
facesBottomRight = ((mesh.getFacesRight() & (y < Ly / 2)) 
                    | (mesh.getFacesBottom() & (x > Lx / 2))) 
 
BCs = (fipy.FixedValue(faces=facesTopLeft, value=phi_outside), 
       fipy.FixedValue(faces=facesBottomRight, value=-phi_outside)) 
 
viewer = fipy.Viewer(vars=phi, datamin=-phi_outside*1., datamax=phi_outside*1) 
 
viewer.plot() 
 
#and solve the equation by repeatedly looping in time: 
 
explicit_max_timeStepDuration = 0.9 * dx*dy / (2 * D) 
timeStepDuration = 10 * explicit_max_timeStepDuration 
 
steps = 100 
 
for step in range(steps): 
    eq.solve(var=phi, 
             boundaryConditions=BCs, 
             dt=timeStepDuration) 
 
    viewer.plot() 




Reply via email to