Hi all,
In plotting a very simple 2D diffusion process (see attached file), I
noticed that I am incapable of visualizing the solution at a smaller region
than the predefined domain size. For instance, in a 12x12 landscape,
diffusion looks the same as when I fixed the plot window to be 0.5x0.5.
Locking *datamin *and *datamax *inside *MatplotlibViewer *also doesn't seem
to help. Any suggestion? My eventual goal is to be able to simultaneously
see different parts of the domains in separate subplots.
Thanks!
Yun
--
Ph.D
University of California, Davis
from fipy import *
from fipy import numerix
from matplotlib.mlab import bivariate_normal
from matplotlib import pyplot as plt
L = 12
nx = 200.
ny = nx
dx = L/nx
dy = L/ny
mesh = Grid2D(nx=nx, ny=ny, dx=dx, dy=dy) + [[-L/2]]
x, y = mesh.getCellCenters()
X, Y = mesh.faceCenters
z = bivariate_normal(x, y, 1., 1., 0., 0.)
phi = CellVariable(name = "solution variable",
mesh = mesh,
value = z)
D = 1.
eq = TransientTerm() == DiffusionTerm(coeff=D)
# reflective boundary conditions
valueTopLeft = 0
valueBottomRight = 0
facesTopLeft = ((mesh.facesLeft & (Y > 0))
| (mesh.facesTop & (X < 0)))
facesBottomRight = ((mesh.facesRight & (Y < 0))
| (mesh.facesBottom & (X > 0)))
phi.faceGrad.constrain(((0,),(0,)), where=facesTopLeft)
phi.faceGrad.constrain(((0,),(0,)), where=facesBottomRight)
# plotting
width = L/2. #0.5
if __name__ == '__main__':
viewer = MatplotlibViewer(vars=phi,
limits={'xmin': -width, 'xmax': width, 'ymin': -width, 'ymax': width})
# datamin=0., datamax=.15)
viewer.plot()
timeStepDuration = 10 * 0.9 * dx**2 / (2 * D)
steps = 10
for step in range(steps):
eq.solve(var=phi,
dt=timeStepDuration)
print 'cell volume: ', phi.getCellVolumeAverage() * mesh.getCellVolumes().sum()
if __name__ == '__main__':
viewer.plot()
_______________________________________________
fipy mailing list
[email protected]
http://www.ctcms.nist.gov/fipy
[ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]