odesplit

버전 1.2.0.0 (8 KB) 작성자: Richard Crozier
Splits evaluation of a system of differential equations into chunks to avoid out of memory errors
다운로드 수: 235
업데이트 날짜: 2012/1/24

라이선스 보기

Occasionally I have had to solve large systems of differential equations which result in matlab running out of memory during evaluation. Odesplit breaks up the simulation period into a series of chunks to ease this problem. At each split point in the evaluation a function specified by the user is called with the current set of results to do whatever is necessary with the ouput. The next section is then evaluated using the final value of the previous section as the new starting point.

This behaviour differs from matlab's odextend as it allows you operate only on small sections of the solution, whereas odeextend always returns the full solution from the original start time to the specified final time. With odesplit, you could also choose to extract only particular solution components of interest, but which depend on the full solution, saving more resources.

Example:

Create the ode function described in Example 1 of the documentation for
ode45 (doc ode45)

function dy = rigid(t,y)
dy = zeros(3,1); % a column vector
dy(1) = y(2) * y(3);
dy(2) = -y(1) * y(3);
dy(3) = -0.51 * y(1) * y(2);

Create a function to be called at each split point

function results = rigidspfcn(results, sol)
if nargin == 0
results.iters = 0;
else
save(['rigidodesave_', int2str(results.iters), '.mat'], 'sol');
results.iters = results.iters + 1;
end

Set the options etc. and call odesplit, splitting the computation into
three blocks

odeoptions = odeset('RelTol',1e-4,'AbsTol',[1e-4 1e-4 1e-5]);

odefcn = @ode45;
odeevfcn = @rigid;
tspan = [0, 30];
y0 = [0 1 1];
spfcn = @rigidspfcn;

[results, tspan] = odesplit(odefcn, odeevfcn, tspan, ...
y0, odeoptions, spfcn, 'Blocks', 3)

In this case, odesplit evaluate the ode and saves the results of each section to disk. However, we could have done anything we wished with this section of data, such as appending solution components of interest to 'results'. The 'results' variable is maintained throughout the calculation in odesplit and returned at the end.

If you ask it to, odesplit will also look out for an out-of-memory error and restart the calculation with a greater number of split points.

인용 양식

Richard Crozier (2024). odesplit (https://www.mathworks.com/matlabcentral/fileexchange/31265-odesplit), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2008b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Ordinary Differential Equations에 대해 자세히 알아보기
태그 태그 추가

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.2.0.0

Changed summary description.

1.1.0.0

Added more detail to description to make clear benefits over odextend

1.0.0.0