Ode15s and function containing system of odes

Hi i have 3 transient pdes(descritized in 2d space using method of lines) represnted as 3 matrix (uep,Ro,c_o) and i want to solve them simultaneously by ode15s.

    Function dC=fun(t,C)
     %system of odes
    end 

Solver is :

    [t,C]=ode15s(@fun,tspan,initialvalues)

I have 2 questions : 1. does ode15s call fun(t,C) in each time step? 2.i want to update my 3 matrices in each time step using C A)Is C the answer of pdes in each time step? B)Is C passed over ot fun(t,C) as a vector or more percisely what is the dimensions of C in each step ? (or Does it's size change as solution goes forward in time?)

I'm asking these questions cause i need to update my matrices each step using the answer of pdes in previous step so i wanted to write something like this:

    uep(2:10,1:19)=reshape(C(1:171),[9 19])

And so on.

Thanks in advance

2 commentaires

Can you show the mathematical equations for the system of ODEs you're trying to solve?

Connectez-vous pour commenter.

 Réponse acceptée

Torsten
Torsten le 7 Nov 2022
Modifié(e) : Torsten le 8 Nov 2022

0 votes

I suggest you start with a simpler example at the beginning than your complicated system of 3 transient PDEs 2D in space. Something like
du/dt = D*d^2u/dx^2 - v*du/dx
Concerning your questions:
1)
ode15s calls fun(t,C) as often as it needs to call in order to solve the ordinary differential equations within a specified error tolerance from tstart to tend. Thus the time step is not the vector "tspan" you hand over to ode15s, but the time steps are chosen internally by ode15s. "tspan" is only the vector of times when outputs are created.
2A)
C is the vector of solution variables. In fiunction "fun", it is not the case that (t,C) is already the solution vector C at time t. In the function "fun", you have to evaluate f(t,C) if your system of ODEs is given by M*dC/dt = f(t,C).
2B)
C is a column vector of the same length as the vector C0 of initial values you have passed to ode15s when you called the integrator. The length of C remains the same during integration.

3 commentaires

Tara Behmanesh
Tara Behmanesh le 8 Nov 2022
Modifié(e) : Tara Behmanesh le 8 Nov 2022
Thanks I'll try it .and do you possibly know a source for numerically solved pdes?(to solve pde and check if i'm getting right answer)
Torsten
Torsten le 8 Nov 2022
For 1d : Maybe examples solved by MATLAB's "pdepe".
For 2d : Maybe examples solved by the PDE toolbox.
Thanks

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by