Using ODE's in space and time

4 views (last 30 days)
Michael Horn
Michael Horn on 28 Jan 2015
Commented: Torsten on 30 Jan 2015
Hi,
I made a bit of a time investment to get a system of equations into an ODE format in a seperate function file. These equations are dependent on time, but I wish to define a 1D geometry. say X=0:dx:10. I created the function file so that for every time point I solve all of my X's. In my X domain I give a step for a defined time perios over a defined distance and then leave it to work itself out. The problem I am running into now is that MatLab is wanting the output to be a column vector. Currently I have it set up such that I get a 2D matrix out. Each row is a differential equation and each column is a specific place in space. This is not an acceptable output for an ODE solver it seems.
I previously went around this problem before by setting up a Euler integration approach but I am running into the limits of MatLab memory constraints and need the variable step sizes that an ODE solver gives me. I have also looked into PDEPE and am not sure that this is the solution. I am still trying to see all of the option in the toolbox but I could use a helping hand.
Thanks,
Ryne

Answers (1)

Torsten
Torsten on 29 Jan 2015
Use reshape to transform your 2d-matrix to a column vector:
reshape(A,[neq*nx,1])
where neq is the number of differential equations and nx is the number of grid points in x direction.
Best wishes
Torsten.
  3 Comments
Michael Horn
Michael Horn on 29 Jan 2015
So this got my program to run through my ODE function file without anymore errors. The problem now is I am getting, what I believe, to be garbage on the other end. My question moves to what exactly the ODE solver does behind the scene from the end of my file (Output) back up to begining of my file (Input, initial conditions). I know there is some sort of error check, depending on the type of ODE being used, that alters the initial conditions. Does placing my 2D data into a 1D column effect this error checking? I believe that it would but I'm not entirely sure. Thoughts?
Torsten
Torsten on 30 Jan 2015
Don't care about what the integrator does in the background.
You have to take care that you supply correct initial conditions and time derivatives for the variables.
The replacement of the 2D data to an 1D column has no effect on how the solver tackles your problem.
Best wishes
Torsten.

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!