23 Jun 18:36
Diffusion equation with a moving point source
From: Tony S Yu <tonyyu@...>
Subject: Diffusion equation with a moving point source
Newsgroups: gmane.comp.python.fipy
Date: 2008-06-23 16:38:56 GMT
Subject: Diffusion equation with a moving point source
Newsgroups: gmane.comp.python.fipy
Date: 2008-06-23 16:38:56 GMT
Hi,
I'm trying to solve the diffusion equation with a moving point source.
In otherwords,
\partial\phi/\partial t = \nabla^2 \phi + \delta(x_s(t))
To represent the delta function on a discrete grid, I need to
initialize a zero array and set certain points on the grid (given by
position x_s) to non-zero values. Unfortunately, x_s is a function of
time, but indexing an array with a Variable object doesn't retain lazy
evaluation. Here's a toy example:
#############
from fipy import *
mesh = Grid1D(nx=10)
phi = CellVariable(mesh=mesh, value=0)
delta = CellVariable(mesh=mesh, value=0)
time = Variable(value=0)
x_s = time
x, = mesh.getCellCenters()
delta.setValue(1, where=(x > x_s) * (x < x_s + 1))
eq = TransientTerm() == ImplicitDiffusionTerm(coeff=1.) + delta
BCs = (FixedValue(faces=mesh.getFacesLeft(), value=0.),
FixedValue(faces=mesh.getFacesRight(), value=0.))
for t in range(0, 10):
(Continue reading)
RSS Feed