Initial conditions has two meanings:
the initial condition
u0 is the solution u at
the initial time. You must specify the initial condition for these
solvers. Pass the initial condition in the first argument or arguments.
u = parabolic(u0,... or u = hyperbolic(u0,ut0,...
hyperbolic solver, you must also
ut0, which is the value of the derivative
of u with respect to time at the initial time.
the same form as
For nonlinear elliptic problems, the initial condition
a guess or approximation of the solution u at the
initial iteration of the
solver. You pass
u0 in the
u = pdenonlin(b,p,e,t,c,a,f,'U0',u0)
If you do not specify initial conditions,
the zero function for the initial iteration.
You can specify initial conditions as a constant by passing a scalar or string vector.
For scalar problems or systems of equations, give
a scalar as the initial condition. For example, set
an initial condition of 5 in every component.
For systems of N equations, give
a string vector initial condition with N rows.
For example, if there are N = 3 equations, you
can give initial conditions
You can specify text expressions for the initial conditions.
The initial conditions are functions of x and y alone,
and, for 3-D problems, z. The text expressions
represent vectors at nodal points, so use
./ for division, and
For example, if you have an initial condition
then you can use this expression for the initial condition.
For a system of N > 1 equations, use a text array with one row for each component, such as
char('x.^2 + 5*cos(x.*y)',... 'tanh(x.*y)./(1+z.^2)')
u0 as a column vector of values at the
mesh nodes. The nodes are either
p data from
See Mesh Data.
Tip For reliability, the initial conditions and boundary conditions should be consistent.
The size of the column vector
on the number of equations, N, and on the number
of nodes in the mesh,
For scalar u, specify a column vector of
Np. The value of
k corresponds to the node
For a system of N equations, specify a column
vector of N*
Np elements contain
the values of component 1, where the value of element
p(k). The next
contain the values of component 2, etc. It can be convenient to first
represent the initial conditions
u0 as an
where the first column contains entries for component 1, the second
column contains entries for component 2, etc. The final representation
of the initial conditions is
For example, suppose you have a function
calculates the value of the initial condition
a row vector of length N for a 2-D problem. Suppose
p is the usual mesh node data (see Mesh Data). Compute the initial conditions
for all mesh nodes
% Assume N and p exist; N = 1 for a scalar problem np = size(p,2); % Number of mesh points u0 = zeros(np,N); % Allocate initial matrix for k = 1:np x = p(1,k); y = p(2,k); u0(k,:) = myfun(x,y); % Fill in row k end u0 = u0(:); % Convert to column form
u0 as the initial condition.