Next: Initial Conditions
Up: Project Lagrangian
Previous: The Difference Equations
Use periodic boundary conditions to allow simulation of an infinite
wave train. Note, though, the presence of
and
in
(2.9.1). If
runs from
to
then
and
will be needed. This is best done by creating ``ghost'' cells at the
end of the arrays. In C(++) this can be done by a declaration such
as
double x[N+1], u[N+1], P[N+2];
and, after each loop in which
or
are updated, by setting
and
, where
is the equilibrium length
of the grid. Note that this requires you to leave a couple of empty
array elements, but for large
this is not significant.