Defining mass matrix for solving transport equation

Deepa Maheshvare (view profile)

on 7 Jan 2019
Latest activity Commented on by Torsten

Torsten (view profile)

on 8 Jan 2019
I want to solve the following 1-D pde which is discretized in spacial direction to solve using ode15s.
Dc/Dt = D*D^c/Dx^2 - v*Dc/Dx.
With initial condition,
c(x,0) = Co
Boundary conditions ,
Dirichlet boundary condition at left boundary,
c(0,t) = cl;
Neumann boundary condition at right boundary,
dc/dx = 0;
I'm not very clear about defining the mass matrix for the input options in the call to ode15s
options = odeset('Mass',M,'RelTol',1e-4,'AbsTol',[1e-6 1e-10 1e-6]);
[t,y] = ode15s(@fun,tspan,y0,options);
I'm trying to solve the above system as a index-1 DAE. The first row and second row of the mass matrix will contain one's in the diagonal entries.
I am not sure how the left boundary condition has to be specified in the mass matrix.
Could someone explain?

Torsten

Torsten (view profile)

on 8 Jan 2019
Sorry, I have not yet worked with the option of "Jacobian Pattern". Thus I had to start at the same knowledge level as you do.
Deepa Maheshvare

Deepa Maheshvare (view profile)

on 8 Jan 2019
No problem. Thanks a lot for your support.
There is an example available here.
In the file named 'ex12ode(t,y,flag)' in the examples provided in the above link,
the Jacobian Pattern matrix and the mas matrix are defined.From what I understand , the diagonal entries corresponding to the algebraic equations are zero .I suppose, for my case, since the algebraic equation of left boundary is written as dc(1)/dt = 0 there is no algebraic equation. Thus the mass matrix is identity matrix, as you already mentioned. (Hope it is right to understand that the mass matrix doesn't include the algebraic equation corresponding to the initial condition.)
However,I couldn't understand how Jacpat function is defined in 'ex12ode(t,y,flag)'.
Hope someone could help me with this.
Any help will be much appreciated.
Torsten

Torsten (view profile)

on 8 Jan 2019
function S = Jacpat(N)
% Define the sparsity structure of the Jacobian by indicating which
% variables appear in which equations. This is done by inspection of
% the function 'f' above for evaluating the equations.
S = sparse(N,N);
for i = 2:(N-1)
S(i,i-1) = 1; % c(i-1)
S(i,i) = 1; % c(i)
S(i,i+1) = 1; % c(i+1)
end
S(N,N-1) = 1; % c(N-1)
S(N,N) = 1; % c(N)