The term initial condition has two meanings:
For time-dependent problems, the initial condition
is the solution u at the initial time, and also
the initial time-derivative if the
is nonzero. Set the initial condition in the model using
For nonlinear stationary problems, the initial condition
is a guess or approximation of the solution u at
the initial iteration of the nonlinear solver. Set the initial condition
in the model using
If you do not specify the initial condition for a stationary
solvepde uses the zero function for
the initial iteration.
For a system of N equations, you can give constant initial conditions as either a scalar or as a vector with N components. For example, if the initial condition is u = 15 for all components, use the following command.
If N = 3, and the initial condition is 15 for the first equation, 0 for the second equation, and –3 for the third equation, use the following commands.
u0 = [15,0,-3]; setInitialConditions(model,u0);
m coefficient is nonzero, give an
initial condition for the time derivative as well. Set this initial
derivative in the same form as the first initial condition. For example,
if the initial derivative of the solution is
use the following commands.
u0 = [15,0,-3]; ut0 = [4,3,0]; setInitialConditions(model,u0,ut0);
If your initial conditions are not constant, set them by writing a function of the form.
function u0 = initfun(location)
location as a structure with fields
location.y, and, for 3-D problems,
initfun must return a matrix
u0 of size N-by-
N is the number of equations in your PDE and
length(location.x). The fields in
location are row
For example, suppose you have a 2-D problem with N = 2 equations:
This problem has
m = 1,
f = .
m is nonzero, give both an initial value
of u and an initial value of the derivative of u.
Write the following function files. Save them to a location on your MATLAB® path.
function uinit = u0fun(location) M = length(location.x); uinit = zeros(2,M); uinit(1,:) = 4 + location.x.^2 + location.y.^2;
function utinit = ut0fun(location) M = length(location.x); utinit = zeros(2,M); utinit(2,:) = sin(location.x.*location.y);
Pass the initial conditions to your PDE model:
u0 = @u0fun; ut0 = @ut0fun; setInitialConditions(model,u0,ut0);
You can use results of previous analysis as nodal initial conditions
for your current model. The geometry and mesh of the model you used
to obtain the results and the current model must be the same. For
example, solve a time-dependent PDE problem for times from
a time step
results = solvepde(model,t0:tstep:t1);
If later you need to solve this PDE problem for times from
you can use
results to set initial conditions.
If you do not explicitly specify the time step,
to the last solution time,
results for a particular solution
time instead of the last one, specify the solution time index as a
third parameter of
example, to use the solution at time
t0 + 10*tstep,
11 as the third parameter.