On Oct 8, 2007, at 10:20 AM, R. Edwin Garcia wrote:
I am trying to program a time-dependent diffusion-like equation
that looks something like this:
\frac{\partial \phi}{\partial t} = \nabla \cdot M \nabla \phi + A*
\sin (\omega t)
where $\phi$ is the spatially distributed variable, $M$ is the
mobility, $A$ and $\omega$ are constants, and t is time.
I looked around, but I couldn't find an example: Would you have a
suggestion on how to add a source term that has an explicit
(sinusoidal) time-dependence?
We don't have a time-dependent source, but we do show a time-
dependent boundary condition in Example 7.1. Same basic idea:
t = Variable()
eq = TransientTerm() == DiffusionTerm(coeff=M) + A * sin(omega * t)
dt=.1
while t() < totalTime:
t.setValue(t()+dt)
eq.solve(var=phi, dt=dt, boundaryConditions=BCs)