Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Is it possible to break up ODEs and then piece back together

Subject: Is it possible to break up ODEs and then piece back together

From: Keane Gonzalez

Date: 2 Apr, 2011 18:56:04

Message: 1 of 4

  I've got some basic Lorenz & Rossler chaos equations that I'm using ode45 (maybe some others) to solve. I'd like to run various cases with differing time steps, but I'm running into memory issues on my wimpy machine. As an example, solving a simple Lorenz for a time period of 0 to 20s is no problem and I get reasonable results from this, albeit at a lesser resolution (0.1 time step).
  The problem is if I try to go to a time period much longer than 200s at the same time step or smaller. I initially tried to split up the longer time period into sections, then run ode45 on each part and then piece the results back together. The basic method I used was:
1. select a large time period, say 0 to 2000s
2. select a time step, such as 0.01s
3. select an initial set of points, x0,y0,z0
4. Depending on the size of the run period, split it up into sections. For this example, I would run from 0 to 1000s for one ode, then 1000+ time step to 2000s for the next.
5. For the second half, the last x,y, z value output from the first ode was used as the input x0,y0, and z0.
6. The results are put together
  At first glance, this looked okay, but to check it out, I split up a run up to 1000s using this method and then ran a regular ode45run over 1000s to compare results. The results differed by more than I expected to see. Is splitting up ODE runs like this mathematically "wrong" or is there something else needed to make such a method sufficiently close to running a large ode45 run on a separate machine with more memory?
  I realize there are other methods to use, but I was just hoping to see if I could stick with ode45 for the time being (or one of the other canned ode systems built-in).
 

Thanks,


Keane Gonzalez

Subject: Is it possible to break up ODEs and then piece back together

From: Roger Stafford

Date: 2 Apr, 2011 20:03:04

Message: 2 of 4

"Keane Gonzalez" <keane_gonzalez@hotmail.com> wrote in message <in7rg4$7gp$1@fred.mathworks.com>...
> I've got some basic Lorenz & Rossler chaos equations that I'm using ode45 (maybe some others) to solve. I'd like to run various cases with differing time steps, but I'm running into memory issues on my wimpy machine. As an example, solving a simple Lorenz for a time period of 0 to 20s is no problem and I get reasonable results from this, albeit at a lesser resolution (0.1 time step).
> The problem is if I try to go to a time period much longer than 200s at the same time step or smaller. I initially tried to split up the longer time period into sections, then run ode45 on each part and then piece the results back together. The basic method I used was:
> 1. select a large time period, say 0 to 2000s
> 2. select a time step, such as 0.01s
> 3. select an initial set of points, x0,y0,z0
> 4. Depending on the size of the run period, split it up into sections. For this example, I would run from 0 to 1000s for one ode, then 1000+ time step to 2000s for the next.
> 5. For the second half, the last x,y, z value output from the first ode was used as the input x0,y0, and z0.
> 6. The results are put together
> At first glance, this looked okay, but to check it out, I split up a run up to 1000s using this method and then ran a regular ode45run over 1000s to compare results. The results differed by more than I expected to see. Is splitting up ODE runs like this mathematically "wrong" or is there something else needed to make such a method sufficiently close to running a large ode45 run on a separate machine with more memory?
> I realize there are other methods to use, but I was just hoping to see if I could stick with ode45 for the time being (or one of the other canned ode systems built-in).
>
> Thanks,
> Keane Gonzalez
- - - - - - - - - - -
  If you haven't already done so, I would suggest you use 'odeset' to set the 'RelTol' and 'AbsTol' values to the accuracy you desire. Note that the default value for 'RelTol' is only 1e-3 which may not be accurate enough for your purposes.

  Of course with more accuracy the runs will take longer and perhaps use more memory. (Sounds like "catch-22" doesn't it?) Breaking up the runs into separate segments as you have done sounds valid to me provided the accuracy is set high enough, though a lot of extra work on your part.

Roger Stafford

Subject: Is it possible to break up ODEs and then piece back together

From: Keane Gonzalez

Date: 2 Apr, 2011 22:17:04

Message: 3 of 4

"Roger Stafford" wrote in message <in7vdo$5f7$1@fred.mathworks.com>...

> - - - - - - - - - - -
> If you haven't already done so, I would suggest you use 'odeset' to set the 'RelTol' and 'AbsTol' values to the accuracy you desire. Note that the default value for 'RelTol' is only 1e-3 which may not be accurate enough for your purposes.
>
> Of course with more accuracy the runs will take longer and perhaps use more memory. (Sounds like "catch-22" doesn't it?) Breaking up the runs into separate segments as you have done sounds valid to me provided the accuracy is set high enough, though a lot of extra work on your part.
>
> Roger Stafford

Roger,
  That's good information. I'll mess around with those options and see if things move closer to what I expect.

Thanks,

Keane Gonzalez

Subject: Is it possible to break up ODEs and then piece back together

From: Roger Stafford

Date: 2 Apr, 2011 23:22:05

Message: 4 of 4

"Keane Gonzalez" <keane_gonzalez@hotmail.com> wrote in message <in8790$1v6$1@fred.mathworks.com>...
> Roger,
> That's good information. I'll mess around with those options and see if things move closer to what I expect.
>
> Thanks,
> Keane Gonzalez
- - - - - - - - - -
  I had one further thought about your memory problems. The time steps you specify and those used internally are entirely different quantities. You could get away with using large time steps to save memory without sacrificing accuracy. It would just mean that the output is more widely-spaced in time.

  The documentation reads: "Specifying tspan with more than two elements does not affect the internal time steps that the solver uses to traverse the interval from tspan(1) to tspan(end)" and "Specifying tspan with more than two elements has little effect on the efficiency of computation, but for large systems, affects memory management."

Roger Stafford

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us