# Solver performances depending on parameters

**URL:** <https://discourse.julialang.org/t/solver-performances-depending-on-parameters/129223>\
**Category:** General Usage\
**Tags:** differentialequation\
**Created:** [May 21, 2025, 2:57pm UTC](https://discourse.julialang.org/t/solver-performances-depending-on-parameters/129223 "2025-05-21T14:57:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![diffeqslvr](https://avatars.discourse-cdn.com/v4/letter/d/f475e1/32.png) [@diffeqslvr](https://discourse.julialang.org/u/diffeqslvr)\
**Post date:** [May 21, 2025, 2:57pm UTC](https://discourse.julialang.org/t/solver-performances-depending-on-parameters/129223/1 "2025-05-21T14:57:52Z")

</div>

I am solving a set of differential equations, see eqs C3a-C3e from [https://journals.aps.org/prresearch/pdf/10.1103/PhysRevResearch.5.013091](https://journals.aps.org/prresearch/pdf/10.1103/PhysRevResearch.5.013091).

 ![Screenshot 2025-05-22 at 11.12.27](https://global.discourse-cdn.com/julialang/original/3X/f/0/f00f129776d15a0a51c338c97fa7407dd4e664d9.png)

I separated the equations into real and imaginary parts and propagate them using different solvers. In the beginning, I set the algorithm to `nothing` and chose `alg_hints = :stiff` (which corresponds to choosing the solver automatically). But then, I found out that this does not work for some cases, and I went to try some of the solvers proposed for stiff problems here [ODE Solvers · DifferentialEquations.jl](https://docs.sciml.ai/DiffEqDocs/stable/solvers/ode_solve/). I found that Kvaerno5 and KenCarp4 seemed more reliable, but also lead to some strange features in the dynamics in some cases.

For example, I consider a system of 3x3 particles with an interaction for direct neighbors of J\_ij + i Gamma\_ij ~ 23 + i and perform a second-order approximation (i.e., I only consider equations C3a - C3c and approximate three-particle terms). This corresponds to a system of 117 equations, and the dynamics of the central atom’s population look like what is shown on the screenshot below. Here, I would say that the automatic solver choice works the best (KenCarp4 and Kvaerno lie on top of each other).

 ![Screenshot 2025-05-22 at 10.52.52](https://global.discourse-cdn.com/julialang/original/3X/5/4/54dd36028c1de72e531401c9f6a5cbff539292c0.png)

Another example is when I consider 3x1 particles with an interaction for direct neighbors of J\_ij + i Gamma\_ij ~ 3000 + i and perform a third-order approximation (i.e., I do not approximate third-order terms but evolve them according to C3d-C3e). This corresponds to a system of 19 equations.

 ![Screenshot 2025-05-22 at 10.57.02](https://global.discourse-cdn.com/julialang/original/3X/b/0/b0b9f49f7802894a45f1c9fcfc598afba136a6cc.png)

I know that these two examples are very different in terms of parameters and number of equations. Still, I would like to get an understanding of when to choose which solver - trying all of them for each parameter set seems extensive.  
Optimally, I would like to find one reliable solver that works for all situations. Or should I lower my expectations?

Note: When I call the solve function, I use  
sol = solve(  
prob,  
alg,  
alg\_hints = :stiff,  
dtmax = 0.01,  
maxiters = Int(1e10),  
saveat = 0.001,  
)

Maybe some other parameter is not set correctly?

---

<div class="post-metadata">

**Author:** ![diffeqslvr](https://avatars.discourse-cdn.com/v4/letter/d/f475e1/32.png) [@diffeqslvr](https://discourse.julialang.org/u/diffeqslvr)\
**Post date:** [May 22, 2025, 9:27am UTC](https://discourse.julialang.org/t/solver-performances-depending-on-parameters/129223/2 "2025-05-22T09:27:40Z")

</div>

Edit:  
I found that, indeed, choosing  
sol = solve(  
prob,  
alg,  
alg\_hints = :stiff,  
dtmax = 0.01,  
maxiters = Int(1e10),  
saveat = 0.01,  
reltol = 1e-9,  
abstol = 1e-9  
)

fixes the problems with the automatic solver choice. I don’t understand why setting abstol/reltol has such a dramatic impact on the automatic solver but not on KenCarp4/Kvaerno5. I will check if I find different issues now.

---

<div class="post-metadata">

**Author:** ![diffeqslvr](https://avatars.discourse-cdn.com/v4/letter/d/f475e1/32.png) [@diffeqslvr](https://discourse.julialang.org/u/diffeqslvr)\
**Post date:** [May 22, 2025, 4:26pm UTC](https://discourse.julialang.org/t/solver-performances-depending-on-parameters/129223/3 "2025-05-22T16:26:54Z")

</div>

I have found out that the optimal approach is to use the automatic solver selection and play with abstol and reltol when the dynamics look strange. I am unsure if I understand why this is the case, or if that’s expected, but I will make a different post for that.
