How to apply deval function to a numerical solution of ODE in parallel?

1 visualización (últimos 30 días)
Dear collegues,
I have a numerical solution of differential equation in the form of structure (e.g. output of ode45 procedure), which was obtained by integration over a large time interval. This solution has a huge size.
I have a certain partition of this large time interval on equal time spans and I am trying to evaluate the solution over these small time spans in parallel using deval function. During my experiments I faced the following problems: since the size of the solution structure is too big, it takes a lot of time to copy it to workers, and, more importantly, it is not possible to specify a sufficient number of Workers, because of the lack of RAM.
I was trying to use parallel.pool.Constant to copy the instance of solution to all workers once, but this does not solve the Out of memory issue.
% Numerical integration of ODE solution
tEnd = 1e5; initPoint = [1, 1, 1];
solNonLinOde = ode45(nonLinOde, [0, tEnd], initPoint, options);
% Partition of [0, tEnd] in to small pieces (time spans)
tStepOde = 1e-2; tStep = 1e-1;
tSpan = 0 : tStepOde : tEnd; tSpanOde = 0 : tStepOde : tStep;
numSpanOde = size(tSpanOde, 2); nChunks = fix(tEnd / tStep);
tempMat = ones(numSpanOde, nChunks) .* (0 : nChunks-1);
tSpanChunks = repmat(tSpanOde, 1, nChunks) + tempMat(:)' .* tStep;
dimChunks = diff(fix(linspace(0, size(tSpanChunks, 2), nChunks+1)));
tSpanCell = mat2cell(tSpanChunks', dimChunks, 1);
% Evaluation the solution over small time spans in parallel
poolobj = parpoolparpool('local');
nonLinOdeTrajChunkCell = cell(1, nChunks);
solNonLinOdeDistr = parallel.pool.Constant(solNonLinOde);
parfor iChunk = 1 : nChunks
nonLinOdeTrajChunkCell{iChunk} = deval(solNonLinOdeDistr.Value, tSpanCell{iChunk});
% ...
end
delete(poolobj);
Could you please help me and advice how to solve this task in a more efficient way?
P.S. Maybe it is reasonable to split the huge solution structure in to small structures in accrodance with the time spans (since one actually does not need to have this huge solution structure to interpolate the points over a small time span). Unfortunatly, I don't know how to split the solution structure.
P.P.S. I know, that there is a possibilty to evaluate the solution over the time span within the solver procedure, i.e.
solNonLinOde2 = ode45(nonLinOde, 0 : tStepOde : tEnd, initPoint, options);
Problem here is that solNonLinOde2 and solNonLinOde will be different, and will define different trajectories (it is possible to observe it on the example of any ODE which generates a chaotic system).

Respuestas (0)

Categorías

Más información sobre Parallel Computing Fundamentals en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by