Hi group,
Two very elementary questions that I have trouble answering myself:
1. If I want to define a 1D mesh that extends into the negative domain, how
do I do so?
2. When I try to simulate a simple moving pulse with no diffusion nor
source term but only a rudimentary convection term (see below), I could not
get the moving wave I expected. Instead, the original distribution appears
to diffuse on its own. Is this an artifice of setting the initial condition
as a probability density function? If so, is there a way around it?
from matplotlib import pylab
> from fipy import *
> from fipy import numerix
> # pylab config
> fig = pylab.figure(figsize=(5, 5))
> ax = pylab.subplot((111))
> # mesh config
> l = 50.
> nx = 100.
> dx = l / nx
> mesh = Grid1D(nx = nx, dx = dx)
>
> # stochasticity
> x = mesh.getCellCenters()[0]
> distr = 1/numerix.sqrt(1*numerix.pi) * numerix.exp(-((x - 12) ** 2) / 2)
> # variable config
> phi = CellVariable(name='$\phi$', mesh=mesh, value=distr)
>
> # viewer config
> viewer = MatplotlibViewer(vars=(phi),
> limits={'ymin': 0., 'ymax': 1.5},
> title="$\phi$",
> axes=ax)
>
> # pde config
> convCoeff = (-40.,)
>
> eq = TransientTerm() == ConvectionTerm(coeff=convCoeff)
> # temporal config
> timeStepDuration = 0.1 * dx ** 2 / (2 * 30) *3
> steps = 500
> # solve for transient solution
> for steps in range(steps):
> eq.solve(var=phi, dt=timeStepDuration)
> print phi[-3]
> viewer.plot()
Thanks!
Yun
--
Graduate Group of Ecology Doctoral Candidate
Department of Environmental Science and Policy
Center for Population Biology
University of California, Davis
_______________________________________________
fipy mailing list
[email protected]
http://www.ctcms.nist.gov/fipy
[ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]