On Nov 11, 2008, at 8:52 AM, Thomas Cool wrote:

I'm trying to use the matplotlib vector viewer for fipy but i'm having
problems: could anyone take a look and tell me what's wrong?



Other than

   import fipy.viewers.matplotlibViewer.matplotlibVectorViewer

I don't see any attempt to use the vector viewer.

   viewer = fipy.viewers.make(vars = var,

doesn't care what imports you've done. It looks at the supplied vars and tries to create appropriate Viewers for them. Since var is scalar:

P = 1.0
E = 0.0

var = CellVariable(name = "phase field",
                  mesh = mesh,
                  value = 2.0*P*random.random(nx * ny) - P)

fipy.viewers.make() will return a scalar Viewer.

You *could* try to replace

   viewer = fipy.viewers.make(vars = var,
                              limits = {'datamin': -1.0e0,
'datamax': 1.0e-0}
                              )

with

viewer = fipy .viewers .matplotlibViewer.matplotlibVectorViewer.MatplotlibVectorViewer(vars = var,
                              limits = {'datamin': -1.0e0,
'datamax': 1.0e-0}
                              )


but this won't work because var is scalar. On the other hand,

   viewer = fipy.viewers.make(vars = var.getGrad(),
                              limits = {'datamin': -1.0e0,
'datamax': 1.0e-0}
                              )


should work (although I don't know that datamin and datamax are interpreted usefully for a vector viewer (and even if they were, they'd probably refer to magnitude, so -1.0e0 wouldn't be a good value)).

There's no reason for the line:

   import fipy.viewers.matplotlibViewer.matplotlibVectorViewer

as you've already locked in matplotlib:

os.environ["FIPY_VIEWER"]="matplotlib"

and viewers.make() will take care of giving you a vector Viewer when that's appropriate.


Reply via email to