Using Sundials cvode solver
29 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi All,
I'm currently using ode15s to solve a set of stiff differential equations.
[t, species] = ode15s(@(t,s) factory(t,s), tspan , species0, options);
I would like to try solving the same set of odes using the CVODE solver in Sundials.
I checked some examples which show how to specify the solver type and use Sundials.
configsetObj = getconfigset(modelObj);
configsetObj.SolverType = 'sundials';
configsetObj.MaximumWallClock = 30;
configsetObj.MaximumNumberOfLogs = 100;
configsetObj.StopTime = 10;
[time, states] = sbiosimulate(modelObj);
plot(time,states)
I would like to know how modelObj should be defined.
5 comentarios
Star Strider
el 12 de Oct. de 2023
I had to look that up. I found SUNDIALS Solvers as the only relevant documentation. I get the impression that these are stand-alone routines, however I have not explored the LLNL documentation for the software.
Respuestas (3)
Aditya
el 27 de Oct. de 2023
Hi Deepa,
I understand that you want to solve set of stiff differential equations using the CVODE solver in Sundials and need help defining the “modelObj” for it.
To convert your ODE model to SimBiology, you can follow a direct approach by converting each differential equation into a rate rule. You can find an example of that here:
In addition, I recommend checking out the following resources to understand how to define a model object according to your specific needs.
- https://www.mathworks.com/help/simbio/ref/modelobject.html#bqu195b-7
- https://www.mathworks.com/help/simbio/gs/construct-a-simple-model.html
Hope this helps!
0 comentarios
Mike Croucher
el 17 de Abr. de 2024
As of MATLAB R2024a, SUNDIALS is shipped with and supported directly in MATLAB. See my blog post for details
1 comentario
Neil
el 4 de Ag. de 2025
YOU FORGET TO MENTION WHICH VERSION OF SUNDIALS IS USED. ALSO COULD BE HELPFULL TO KNOW IF IT IS THE SAME WRAPPER THAT USES SIMBIOLOGY. THANKS
Mohamed Elshami
el 7 de En. de 2025
you need to redefine your problem instead of traditional method. In this definition you set the ode solver to your problem directly.
ode15s(@(t,s) factory(t,s), tspan , species0, options)
Starting from 2024 versions new solvers of sundials were added which are (cvodenonstiff, cvodestiff, and idas), to use any of them you should follow the updated new method to define ode functions, according your problem you need to rewrite it as follows:
d = ode(ODEFcn = @(t,s)[factory(t,s)]);
d.Solver = "cvodesStiff"; % or "cvodesNonstiff" , "idas" (all are sundials solvers)
d.InitialValue = species0;
d.InitialTime = 0;
d.RelativeTolerance = 1e-6;
d.AbsoluteTolerance = 1e-6;
d.SolverOptions.MaxStep = 1e-2;
StartTime = 0;
StopTime = 10;
Y = solve(d,StartTime,StopTime);
note that
- d: is an arbitrary object name just to further deal with the object handles (InitialValue, InitialTime,... etc).
- for the full list of handles of the ode object just type the object given name (d) in the command line then enter.
0 comentarios
Ver también
Categorías
Más información sobre Scan Parameter Ranges en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!