Discussion:
ODE15s / DAE error message
(too old to reply)
Daniel
2010-10-04 14:26:05 UTC
Permalink
Hi there,

I'm trying to solve a DAE system of the following form:

M=diag([1 1 1 1 1 1 0 0 0 0]);
options=odeset('Mass',M);
[t,sol]=ode15s(@fun,tspan,x0,options)

function d_dt=fun(t,x)
c1=... some expression
c2=...
c3=...
c4=...
c5=...
c6=...
res7=c7+c8
res8=c1*c7
res9=parameter/(c1+c2+c3)*c7
res10=parameter/(c1+c2+c3)*c8

d_dt=[c1 c2 c3 c4 c5 c6 res7 res8 res9 res10 ]

I get the error message:

###################################################################
??? Error using ==> mtimes
Inner matrix dimensions must agree.

Error in ==> daeic12 at 62
F = UM' * f;

Error in ==> ode15s at 395
[y,yp,f0,dfdy,nFE,nPD,Jfac] = daeic12(odeFcn,odeArgs,t,ICtype,Mt,y,yp0,f0,...
###################################################################

So question 1:
What is this error about???

question 2:
What does the option 'Vectorized', 'On' mean and could it help in this case?

Thanks for your help in advance!
Steven_Lord
2010-10-04 17:32:26 UTC
Permalink
Post by Daniel
Hi there,
M=diag([1 1 1 1 1 1 0 0 0 0]);
options=odeset('Mass',M);
function d_dt=fun(t,x)
c1=... some expression
c2=...
c3=...
c4=...
c5=...
c6=...
res7=c7+c8
res8=c1*c7
res9=parameter/(c1+c2+c3)*c7
res10=parameter/(c1+c2+c3)*c8
d_dt=[c1 c2 c3 c4 c5 c6 res7 res8 res9 res10 ]
The ODE solvers expect your function to return a _column_ vector of values,
not a _row_ vector.

http://www.mathworks.com/help/techdoc/ref/ode23.html

"Function f = odefun(t,y), for a scalar t and a column vector y, must return
a column vector f corresponding to f(t, y)."

*snip*
Post by Daniel
So question 1: What is this error about???
Well, you haven't included your full code, but I suspect the different
orientations is the cause of this particular error.
Post by Daniel
What does the option 'Vectorized', 'On' mean and could it help in this case?
The various options available for use with the ODE solvers are described
here:

http://www.mathworks.com/help/techdoc/ref/odeset.html#f92-1023074

I don't think using that option would necessarily resolve that particular
error.
--
Steve Lord
***@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com
Daniel
2010-10-04 18:35:22 UTC
Permalink
Post by Steven_Lord
Post by Daniel
d_dt=[c1 c2 c3 c4 c5 c6 res7 res8 res9 res10 ]
The ODE solvers expect your function to return a _column_ vector of values,
not a _row_ vector.
http://www.mathworks.com/help/techdoc/ref/ode23.html
"Function f = odefun(t,y), for a scalar t and a column vector y, must return
a column vector f corresponding to f(t, y)."
Sorry, just a typing error. The d_dt vector is a column vector, I checked that.
So any further ideas what might cause this error?
(Shall I give the full code?)
Torsten Hennig
2010-10-05 06:31:46 UTC
Permalink
Post by Daniel
Hi there,
I'm trying to solve a DAE system of the following
M=diag([1 1 1 1 1 1 0 0 0 0]);
options=odeset('Mass',M);
Did you initialize x0 ?
Post by Daniel
function d_dt=fun(t,x)
c1=... some expression
c2=...
c3=...
c4=...
c5=...
c6=...
res7=c7+c8
res8=c1*c7
res9=parameter/(c1+c2+c3)*c7
res10=parameter/(c1+c2+c3)*c8
d_dt=[c1 c2 c3 c4 c5 c6 res7 res8 res9 res10 ]
######################################################
#############
??? Error using ==> mtimes
Inner matrix dimensions must agree.
Error in ==> daeic12 at 62
F = UM' * f;
Error in ==> ode15s at 395
[y,yp,f0,dfdy,nFE,nPD,Jfac] =
c] = daeic12(odeFcn,odeArgs,t,ICtype,Mt,y,yp0,f0,...
######################################################
#############
What is this error about???
What does the option 'Vectorized', 'On' mean and
could it help in this case?
Thanks for your help in advance!
Best wishes
Torsten.
Daniel
2010-10-05 06:57:06 UTC
Permalink
Post by Torsten Hennig
Did you initialize x0 ?
Yes I did!

As I understand from the help, 'Vectorize', 'On' is applicable for this problem.
Unfortunately this results in another (quiet similar) error message:

#####################################################################
??? Error using ==> minus
Matrix dimensions must agree.

Error in ==> odenumjac at 148
Fdiff = Fdel - Fvalue(:,ones(1,ny));

Error in ==> daeic12 at 38
[DfDy,Joptions.fac,nF] = odenumjac(fun, {t0,y,args{:}}, f, Joptions);

Error in ==> ode15s at 395
[y,yp,f0,dfdy,nFE,nPD,Jfac] = daeic12(odeFcn,odeArgs,t,ICtype,Mt,y,yp0,f0,...
###################################################################
Daniel
2010-10-05 12:03:06 UTC
Permalink
update:

The description for daeic12 says:
' DAEIC12 attempts to find a set of consistent initial conditions for
equations of the form M(t)*y' = f(t,y) '

So what does this mean exactly?
I guess it has something to do with the initials I set...but why consistent? I only can take the initials which are physical meaningful ...
Torsten Hennig
2010-10-05 12:38:42 UTC
Permalink
Post by Daniel
' DAEIC12 attempts to find a set of consistent
initial conditions for
equations of the form M(t)*y' = f(t,y) '
So what does this mean exactly?
I guess it has something to do with the initials I
set...but why consistent? I only can take the
initials which are physical meaningful ...
You have four algebraic equations in your DAE-system
(namely the last 4).
If you don't supply starting values for x1,...,x10
such that f7(t=0,x1,...,x10), f8(t=0,x1,...,x10),
f9(t=0,x1,...,x10), f10(t=0,x1,...,x10) are identically
zero, DAEIC12 attempts to adjust your x7,...,x10 such
that this is the case.
But this has nothing to do with the error message you
receive, I would guess.

Best wishes
Torsten.
Daniel
2010-10-05 12:52:04 UTC
Permalink
Post by Torsten Hennig
Post by Daniel
' DAEIC12 attempts to find a set of consistent
initial conditions for
equations of the form M(t)*y' = f(t,y) '
So what does this mean exactly?
I guess it has something to do with the initials I
set...but why consistent? I only can take the
initials which are physical meaningful ...
You have four algebraic equations in your DAE-system
(namely the last 4).
If you don't supply starting values for x1,...,x10
such that f7(t=0,x1,...,x10), f8(t=0,x1,...,x10),
f9(t=0,x1,...,x10), f10(t=0,x1,...,x10) are identically
zero, DAEIC12 attempts to adjust your x7,...,x10 such
that this is the case.
But this has nothing to do with the error message you
receive, I would guess.
Best wishes
Torsten.
But the iteration does not start because of this error. The value of the t variable stays zero allthough the function is called about 100 times. Then the ode returns this error message caused by the inconsistency in the DAE initial conditions...as far as I understand this. But why do I need to choose the 'right' initial guesses?
Torsten Hennig
2010-10-05 13:24:24 UTC
Permalink
in message
athforum.org>...
Post by Torsten Hennig
Post by Daniel
' DAEIC12 attempts to find a set of consistent
initial conditions for
equations of the form M(t)*y' = f(t,y) '
So what does this mean exactly?
I guess it has something to do with the initials
I
Post by Torsten Hennig
Post by Daniel
set...but why consistent? I only can take the
initials which are physical meaningful ...
You have four algebraic equations in your
DAE-system
Post by Torsten Hennig
(namely the last 4).
If you don't supply starting values for x1,...,x10
such that f7(t=0,x1,...,x10), f8(t=0,x1,...,x10),
f9(t=0,x1,...,x10), f10(t=0,x1,...,x10) are
identically
Post by Torsten Hennig
zero, DAEIC12 attempts to adjust your x7,...,x10
such
Post by Torsten Hennig
that this is the case.
But this has nothing to do with the error message
you
Post by Torsten Hennig
receive, I would guess.
Best wishes
Torsten.
But the iteration does not start because of this
error. The value of the t variable stays zero
allthough the function is called about 100 times.
Then the ode returns this error message caused by the
inconsistency in the DAE initial conditions...as far
as I understand this.
The error messages you posted so far said something
about 'matrix dimensions that do not agree', but nothing
about 'an inconsistency in the DAE initial conditions'.
But why do I need to choose the
'right' initial guesses?
If you have an algebraic equation like y(7) - 500 = 0
in your system, you want y(7) = 500 for all times t.
If at time t = 0, you provide y(7) = 2000,
you provide a _wrong_ initial value.
The solver tries to adjust it to y(7) = 500,
but if your initial guess is too far away form the correct value, the solver may fail.

This is different from differential variables
where there is no 'correct' initial condition, but you
can start from where you like.

Best wishes
Torsten.
Daniel
2010-10-06 13:35:28 UTC
Permalink
Post by Torsten Hennig
in message
athforum.org>...
If you have an algebraic equation like y(7) - 500 = 0
in your system, you want y(7) = 500 for all times t.
If at time t = 0, you provide y(7) = 2000,
you provide a _wrong_ initial value.
The solver tries to adjust it to y(7) = 500,
but if your initial guess is too far away form the correct value, the solver may fail.
This is different from differential variables
where there is no 'correct' initial condition, but you
can start from where you like.
Best wishes
Torsten.
OK. Thank you Torsten!!!

But what if y (as you introduced it above) is a vector so that I get something like y(1:5)-500=0 ? Is this a case for 'Vectorized', 'On' now?
I arrive at this case for my DAE system from a discretization with the finite volume method. Its kind of difficult to get the initial values for this then...because I know y(1) and maybe y(5), but not the values in between.
Daniel
2010-10-06 14:48:23 UTC
Permalink
Post by Daniel
Post by Torsten Hennig
in message
athforum.org>...
If you have an algebraic equation like y(7) - 500 = 0
in your system, you want y(7) = 500 for all times t.
If at time t = 0, you provide y(7) = 2000,
you provide a _wrong_ initial value.
The solver tries to adjust it to y(7) = 500,
but if your initial guess is too far away form the correct value, the solver may fail.
This is different from differential variables
where there is no 'correct' initial condition, but you
can start from where you like.
Best wishes
Torsten.
OK. Thank you Torsten!!!
But what if y (as you introduced it above) is a vector so that I get something like y(1:5)-500=0 ? Is this a case for 'Vectorized', 'On' now?
I arrive at this case for my DAE system from a discretization with the finite volume method. Its kind of difficult to get the initial values for this then...because I know y(1) and maybe y(5), but not the values in between.
edit: y(1:5)-500*=0
* - can also be a vector e.g. z(1:5)
Daniel
2010-10-11 15:07:08 UTC
Permalink
Post by Daniel
Post by Daniel
Post by Torsten Hennig
in message
athforum.org>...
If you have an algebraic equation like y(7) - 500 = 0
in your system, you want y(7) = 500 for all times t.
If at time t = 0, you provide y(7) = 2000,
you provide a _wrong_ initial value.
The solver tries to adjust it to y(7) = 500,
but if your initial guess is too far away form the correct value, the solver may fail.
This is different from differential variables
where there is no 'correct' initial condition, but you
can start from where you like.
Best wishes
Torsten.
OK. Thank you Torsten!!!
But what if y (as you introduced it above) is a vector so that I get something like y(1:5)-500=0 ? Is this a case for 'Vectorized', 'On' now?
I arrive at this case for my DAE system from a discretization with the finite volume method. Its kind of difficult to get the initial values for this then...because I know y(1) and maybe y(5), but not the values in between.
edit: y(1:5)-500*=0
* - can also be a vector e.g. z(1:5)
Found the error which was causing the error messages above: the Mass-Matrix must a Matrix. Stupid mistake but very simple to solve...

But another error occurred now:
'??? Error using ==> daeic12 at 167 Need a better guess y0 for consistent initial conditions.'

Again the question: what shall I do if I do not know all initial conditions? Is there a way to tell the ode solver? Or is there a way to set the conditions physically senseless but at least consistent?
Torsten Hennig
2010-10-12 06:30:25 UTC
Permalink
Post by Daniel
Found the error which was causing the error messages
above: the Mass-Matrix must a Matrix. Stupid mistake
but very simple to solve...
'??? Error using ==> daeic12 at 167 Need a better
guess y0 for consistent initial conditions.'
Again the question: what shall I do if I do not know
all initial conditions? Is there a way to tell the
ode solver? Or is there a way to set the conditions
physically senseless but at least consistent?
You have to start from a physically senseful solution
because it is this solution which is the basis
for the following time integration.

You have two possibilities to calculate this solution:
- by hand
- by using MATLAB's fsolve before calling the
DAE-integrator.

Best wishes
Torsten.
Daniel
2010-10-12 13:19:03 UTC
Permalink
Post by Daniel
Post by Daniel
M=diag([1 1 1 1 1 1 0 0 0 0]);
options=odeset('Mass',M);
function d_dt=fun(t,x)
c1=... some expression
c2=...
c3=...
c4=...
c5=...
c6=...
res7=c7+c8
res8=c1*c7
res9=parameter/(c1+c2+c3)*c7
res10=parameter/(c1+c2+c3)*c8
d_dt=[c1 c2 c3 c4 c5 c6 res7 res8 res9 res10 ]
Post by Daniel
Found the error which was causing the error messages
above: the Mass-Matrix must a Matrix. Stupid mistake
but very simple to solve...
'??? Error using ==> daeic12 at 167 Need a better
guess y0 for consistent initial conditions.'
Again the question: what shall I do if I do not know
all initial conditions? Is there a way to tell the
ode solver? Or is there a way to set the conditions
physically senseless but at least consistent?
You have to start from a physically senseful solution
because it is this solution which is the basis
for the following time integration.
- by hand
- by using MATLAB's fsolve before calling the
DAE-integrator.
Best wishes
Torsten.
OK! Thank you Torsten.

But I have another question! (seems to be a very complicated system that's why that may questions)

I'm referring to the source code above:
For a special region (e.g. x<x1=10m) some of the algebraic terms are not (physically meaningful) present anymore. Is it sufficient to tell Matlab with res8=0 that the equation is not to be considered anymore? I think repeatedly calling the function fun(t,x) with separate values of x is not the solution, isn't it?
Torsten Hennig
2010-10-13 06:40:28 UTC
Permalink
Post by Daniel
Post by Daniel
M=diag([1 1 1 1 1 1 0 0 0 0]);
options=odeset('Mass',M);
function d_dt=fun(t,x)
c1=... some expression
c2=...
c3=...
c4=...
c5=...
c6=...
res7=c7+c8
res8=c1*c7
res9=parameter/(c1+c2+c3)*c7
res10=parameter/(c1+c2+c3)*c8
d_dt=[c1 c2 c3 c4 c5 c6 res7 res8 res9 res10 ]
in message
athforum.org>...
Post by Daniel
Post by Daniel
Found the error which was causing the error
messages
Post by Daniel
Post by Daniel
above: the Mass-Matrix must a Matrix. Stupid
mistake
Post by Daniel
Post by Daniel
but very simple to solve...
'??? Error using ==> daeic12 at 167 Need a better
guess y0 for consistent initial conditions.'
Again the question: what shall I do if I do not
know
Post by Daniel
Post by Daniel
all initial conditions? Is there a way to tell
the
Post by Daniel
Post by Daniel
ode solver? Or is there a way to set the
conditions
Post by Daniel
Post by Daniel
physically senseless but at least consistent?
You have to start from a physically senseful
solution
Post by Daniel
because it is this solution which is the basis
for the following time integration.
You have two possibilities to calculate this
- by hand
- by using MATLAB's fsolve before calling the
DAE-integrator.
Best wishes
Torsten.
OK! Thank you Torsten.
But I have another question! (seems to be a very
complicated system that's why that may questions)
For a special region (e.g. x<x1=10m) some of the
algebraic terms are not (physically meaningful)
present anymore.
The variables corresponding to some algebraic equations
are no longer needed just from the beginning of the
computation or at some stage during the computation ?
Is it sufficient to tell Matlab with
res8=0 that the equation is not to be considered
anymore? I think repeatedly calling the function
fun(t,x) with separate values of x is not the
solution, isn't it?
Telling MATLAB res8 = 0 is not a good idea because
the Jacobian matrix will become singular.
Set res8 to a simple algebraic equation that includes
the variable to be determined by the 8th algebraic
equation, e.g. res8 = x(8). Then x(8)=0 for all times t.

Best wishes
Torsten.
Daniel
2010-10-13 07:52:04 UTC
Permalink
Post by Torsten Hennig
in message
athforum.org>...
The variables corresponding to some algebraic equations
are no longer needed just from the beginning of the
computation or at some stage during the computation ?
Again, thank you very much for your help here Torsten!!! I really appreciate it.


Maybe I need to explain the problem a little bit more in specific:

I need to solve a PDE/ODE system for a battery electrode and a battery separator in 1D like shown below:

n= 1 n=6 n=10
|x=0|---------------------------------------------------------------------- |x=x1|-------------------------|x=x2|
< porous electrode > <separator>
solid and solved species only solved species

The porous electrode is filled with solid metal particles and liquid electrolyte solution in between these particles. There are two solid species and 4 solved ones in solution.
Therefore I get 6 species PDEs like
dc/dt =reaction + diffusion + convection + migration = function(c(x), dc/dx, d²c/dx², phi_sol(x)).
The migration is only valid for charged species in solution and is coupled with the 'drag-force' in dependence of the solution potential at the current position x, phi_sol(x).
The potential is calculated with 4 extra first order ODEs in space with the help of the current and potential in solid and solution phase. They are not time dependent.

The DAE system arises because I do a finite volume discretization for the PDE, let's say for n=10 elements...so about n=6 for the electrode and n=4 for the separator. In total there would be a set of 10*10=100 equations.
But I get 6*6=36 ODEs in time for the species and 4*6=24 algebraic equations in the electrode. Consequently, in the separator this is reduced by 2*4=8 ODEs (since the solid components are not present anymore) and 2*4=8 algebraic equations (since the current and potential in the solid metal phase are missing). In total I only need 84 equations. Clear?

So that's why I asked if res8(from x1 to x2)=0 would do?
I also thought of calling separate functions for electrode and separator. But then the time in both functions is different and I would need the boundary values at x=x1 at the exact same time. Right?

Or do you have any other idea how to solve the PDE/ODE system without discretization in Matlab?
Torsten Hennig
2010-10-13 09:05:59 UTC
Permalink
Post by Daniel
Post by Torsten Hennig
in message
athforum.org>...
The variables corresponding to some algebraic
equations
Post by Torsten Hennig
are no longer needed just from the beginning of the
computation or at some stage during the computation
?
Again, thank you very much for your help here
Torsten!!! I really appreciate it.
Maybe I need to explain the problem a little bit more
I need to solve a PDE/ODE system for a battery
electrode and a battery separator in 1D like shown
n= 1
n=6
n=6
n=6
n=6
n=6
n=6
n=6
n=6
n=6
n=6
n=6 n=10
|x=0|-------------------------------------------------
---------------------
|x=x1|-------------------------|x=x2|
< porous electrode
< porous electrode >
rous electrode >
<separator>
solid and solved
solid and solved species
solved species
only solved
only solved species
The porous electrode is filled with solid metal
particles and liquid electrolyte solution in between
these particles. There are two solid species and 4
solved ones in solution.
Therefore I get 6 species PDEs like
dc/dt =reaction + diffusion + convection + migration
= function(c(x), dc/dx, d²c/dx², phi_sol(x)).
The migration is only valid for charged species in
solution and is coupled with the 'drag-force' in
dependence of the solution potential at the current
position x, phi_sol(x).
The potential is calculated with 4 extra first order
ODEs in space with the help of the current and
potential in solid and solution phase. They are not
time dependent.
The DAE system arises because I do a finite volume
discretization for the PDE, let's say for n=10
elements...so about n=6 for the electrode and n=4 for
the separator. In total there would be a set of
10*10=100 equations.
But I get 6*6=36 ODEs in time for the species and
4*6=24 algebraic equations in the electrode.
Consequently, in the separator this is reduced by
2*4=8 ODEs (since the solid components are not
present anymore) and 2*4=8 algebraic equations (since
the current and potential in the solid metal phase
are missing). In total I only need 84 equations.
Clear?
So that's why I asked if res8(from x1 to x2)=0 would
do?
I also thought of calling separate functions for
electrode and separator. But then the time in both
functions is different and I would need the boundary
values at x=x1 at the exact same time. Right?
Or do you have any other idea how to solve the
PDE/ODE system without discretization in Matlab?
I don't understand why you make life so difficult.
For each node j in the electrode, define a
solution vector
(y_1^(j),...,y_6^(j),y_7^(j),...,y_10^(j))
and for each node j in the seperator, define a
solution vector
(y_1^(j),...,y_6^(j)).
For your above choice of the nuumber of elements,
glue the solution vectors together to an y-vector
of the form
y = (y_1^(1),...,y_10^(1),y_1^(2),...,y_10^(2),
..,y_1^(6),...,y_10^(6),y_1^(7),...,y_6^(7),...,
y_1^(10),...,y_6^(10))
with 60 + 24 = 84 components and call ODE15s
with this vector.
In the function routine, you can write the full
y-vector in local vectors which reflect the underlying
problem (e.g. it is convenient to define subvectors
(y_1^(1),y_1^(2),...,y_1^(10)),
(y_2^(1),y_2^(2),...,y_2^(10)),
..
(y_6^(1),y_6^(2),...,y_6^(10)),
(y_7^(1),y_7^(2),...,y_7^(6)),
..
(y_10^(1),y_10^(2),...,y_10^(6))
for teh different solution variables, I think.)

Best wishes
Torsten.
Daniel
2010-10-14 09:05:06 UTC
Permalink
Post by Torsten Hennig
I don't understand why you make life so difficult.
For each node j in the electrode, define a
solution vector
(y_1^(j),...,y_6^(j),y_7^(j),...,y_10^(j))
and for each node j in the seperator, define a
solution vector
(y_1^(j),...,y_6^(j)).
For your above choice of the nuumber of elements,
glue the solution vectors together to an y-vector
of the form
y = (y_1^(1),...,y_10^(1),y_1^(2),...,y_10^(2),
..,y_1^(6),...,y_10^(6),y_1^(7),...,y_6^(7),...,
y_1^(10),...,y_6^(10))
with 60 + 24 = 84 components and call ODE15s
with this vector.
In the function routine, you can write the full
y-vector in local vectors which reflect the underlying
problem (e.g. it is convenient to define subvectors
(y_1^(1),y_1^(2),...,y_1^(10)),
(y_2^(1),y_2^(2),...,y_2^(10)),
..
(y_6^(1),y_6^(2),...,y_6^(10)),
(y_7^(1),y_7^(2),...,y_7^(6)),
..
(y_10^(1),y_10^(2),...,y_10^(6))
for teh different solution variables, I think.)
Best wishes
Torsten.
Thanks! Tried that.
But now the DAE index appears to be greater than 1:
??? Error using ==> daeic12 at 77
This DAE appears to be of index greater than 1.
Don't know why exactly because all algebraic states can be described by the algebraic equations...

So again the question can Matlab solve the original PDE/ODE system without discretization?
Torsten Hennig
2010-10-14 09:47:34 UTC
Permalink
in message
mathforum.org>...
Post by Torsten Hennig
I don't understand why you make life so difficult.
For each node j in the electrode, define a
solution vector
(y_1^(j),...,y_6^(j),y_7^(j),...,y_10^(j))
and for each node j in the seperator, define a
solution vector
(y_1^(j),...,y_6^(j)).
For your above choice of the nuumber of elements,
glue the solution vectors together to an y-vector
of the form
y = (y_1^(1),...,y_10^(1),y_1^(2),...,y_10^(2),
..,y_1^(6),...,y_10^(6),y_1^(7),...,y_6^(7),...,
y_1^(10),...,y_6^(10))
with 60 + 24 = 84 components and call ODE15s
with this vector.
In the function routine, you can write the full
y-vector in local vectors which reflect the
underlying
Post by Torsten Hennig
problem (e.g. it is convenient to define subvectors
(y_1^(1),y_1^(2),...,y_1^(10)),
(y_2^(1),y_2^(2),...,y_2^(10)),
..
(y_6^(1),y_6^(2),...,y_6^(10)),
(y_7^(1),y_7^(2),...,y_7^(6)),
..
(y_10^(1),y_10^(2),...,y_10^(6))
for teh different solution variables, I think.)
Best wishes
Torsten.
Thanks! Tried that.
??? Error using ==> daeic12 at 77
This DAE appears to be of index greater than 1.
Don't know why exactly because all algebraic states
can be described by the algebraic equations...
The reason for this error message usually is a
programming error or inconsistent initial values
for the algebraic variables.
You can check this by calculating the residuals
of the algebraic equations after the first call of
ODE15s to your function routine - they should be very
small if the initial values are consistent.
So again the question can Matlab solve the original
PDE/ODE system without discretization?
You may have a look at MATLAB's pdepe, but I think
a mixture of PDEs and ODEs with different domains
on which they are valid requires more flexibility
than pdepe can offer.

Best wishes
Torsten.
d***@mst.edu
2018-03-20 05:23:00 UTC
Permalink
Post by Daniel
Post by Torsten Hennig
I don't understand why you make life so difficult.
For each node j in the electrode, define a
solution vector
(y_1^(j),...,y_6^(j),y_7^(j),...,y_10^(j))
and for each node j in the seperator, define a
solution vector
(y_1^(j),...,y_6^(j)).
For your above choice of the nuumber of elements,
glue the solution vectors together to an y-vector
of the form
y = (y_1^(1),...,y_10^(1),y_1^(2),...,y_10^(2),
..,y_1^(6),...,y_10^(6),y_1^(7),...,y_6^(7),...,
y_1^(10),...,y_6^(10))
with 60 + 24 = 84 components and call ODE15s
with this vector.
In the function routine, you can write the full
y-vector in local vectors which reflect the underlying
problem (e.g. it is convenient to define subvectors
(y_1^(1),y_1^(2),...,y_1^(10)),
(y_2^(1),y_2^(2),...,y_2^(10)),
..
(y_6^(1),y_6^(2),...,y_6^(10)),
(y_7^(1),y_7^(2),...,y_7^(6)),
..
(y_10^(1),y_10^(2),...,y_10^(6))
for teh different solution variables, I think.)
Best wishes
Torsten.
Thanks! Tried that.
??? Error using ==> daeic12 at 77
This DAE appears to be of index greater than 1.
Don't know why exactly because all algebraic states can be described by the algebraic equations...
So again the question can Matlab solve the original PDE/ODE system without discretization?
Hello Daniel,
I by chance came across this thread on index error associated with modelling lithium ion battery cell using ode15s in MATLAB. If it will not be too much of a ask, how did you eventually solve this problem because I am presently having this same problem with my battery model using spectral methods.

Regards,
Damola M. Ajiboye.
Patrick
2022-07-03 20:44:20 UTC
Permalink
Post by d***@mst.edu
Post by Daniel
Post by Torsten Hennig
I don't understand why you make life so difficult.
For each node j in the electrode, define a
solution vector
(y_1^(j),...,y_6^(j),y_7^(j),...,y_10^(j))
and for each node j in the seperator, define a
solution vector
(y_1^(j),...,y_6^(j)).
For your above choice of the nuumber of elements,
glue the solution vectors together to an y-vector
of the form
y = (y_1^(1),...,y_10^(1),y_1^(2),...,y_10^(2),
..,y_1^(6),...,y_10^(6),y_1^(7),...,y_6^(7),...,
y_1^(10),...,y_6^(10))
with 60 + 24 = 84 components and call ODE15s
with this vector.
In the function routine, you can write the full
y-vector in local vectors which reflect the underlying
problem (e.g. it is convenient to define subvectors
(y_1^(1),y_1^(2),...,y_1^(10)),
(y_2^(1),y_2^(2),...,y_2^(10)),
..
(y_6^(1),y_6^(2),...,y_6^(10)),
(y_7^(1),y_7^(2),...,y_7^(6)),
..
(y_10^(1),y_10^(2),...,y_10^(6))
for teh different solution variables, I think.)
Best wishes
Torsten.
Thanks! Tried that.
??? Error using ==> daeic12 at 77
This DAE appears to be of index greater than 1.
Don't know why exactly because all algebraic states can be described by the algebraic equations...
So again the question can Matlab solve the original PDE/ODE system without discretization?
Hello Daniel,
I by chance came across this thread on index error associated with modelling lithium ion battery cell using ode15s in MATLAB. If it will not be too much of a ask, how did you eventually solve this problem because I am presently having this same problem with my battery model using spectral methods.
Regards,
Damola M. Ajiboye.
Same problem, also modeling Li-Ion batteries. Any news?

Loading...