Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dt_min option for IDAKLUSolver #4736

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Features

- Added a `dt_min` option to the (`IDAKLUSolver`). ([#4736](https://github.com/pybamm-team/PyBaMM/pull/4736))
- Enabled using SEI models with particle size distributions. ([#4693](https://github.com/pybamm-team/PyBaMM/pull/4693))
- Added symbolic mesh which allows for using InputParameters for geometric parameters ([#4665](https://github.com/pybamm-team/PyBaMM/pull/4665))
- Enhanced the `search` method to accept multiple search terms in the form of a string or a list. ([#4650](https://github.com/pybamm-team/PyBaMM/pull/4650))
Expand Down
3 changes: 3 additions & 0 deletions src/pybamm/solvers/c_solvers/idaklu/IDAKLUSolverOpenMP.inl
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ void IDAKLUSolverOpenMP<ExprSet>::SetSolverOptions() {
// Initial step size
CheckErrors(IDASetInitStep(ida_mem, solver_opts.dt_init));

// Minimum absolute step size
CheckErrors(IDASetMinStep(ida_mem, solver_opts.dt_min));

// Maximum absolute step size
CheckErrors(IDASetMaxStep(ida_mem, solver_opts.dt_max));

Expand Down
1 change: 1 addition & 0 deletions src/pybamm/solvers/c_solvers/idaklu/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ SolverOptions::SolverOptions(py::dict &py_opts)
max_order_bdf(py_opts["max_order_bdf"].cast<int>()),
max_num_steps(py_opts["max_num_steps"].cast<int>()),
dt_init(RCONST(py_opts["dt_init"].cast<double>())),
dt_min(RCONST(py_opts["dt_min"].cast<double>())),
dt_max(RCONST(py_opts["dt_max"].cast<double>())),
max_error_test_failures(py_opts["max_error_test_failures"].cast<int>()),
max_nonlinear_iterations(py_opts["max_nonlinear_iterations"].cast<int>()),
Expand Down
1 change: 1 addition & 0 deletions src/pybamm/solvers/c_solvers/idaklu/Options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct SolverOptions {
int max_order_bdf;
int max_num_steps;
double dt_init;
double dt_min;
double dt_max;
int max_error_test_failures;
int max_nonlinear_iterations;
Expand Down
4 changes: 4 additions & 0 deletions src/pybamm/solvers/idaklu_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ class IDAKLUSolver(pybamm.BaseSolver):
"max_num_steps": 100000,
# Initial step size. The solver default is used if this is left at 0.0
"dt_init": 0.0,
# Minimum absolute step size. The solver default is used if this is
# left at 0.0
"dt_min": 0.0,
# Maximum absolute step size. The solver default is used if this is
# left at 0.0
"dt_max": 0.0,
Expand Down Expand Up @@ -200,6 +203,7 @@ def __init__(
"max_order_bdf": 5,
"max_num_steps": 100000,
"dt_init": 0.0,
"dt_min": 0.0,
"dt_max": 0.0,
"max_error_test_failures": 10,
"max_nonlinear_iterations": 40,
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_solvers/test_idaklu_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@ def test_solver_options(self):
"max_order_bdf": 4,
"max_num_steps": 490,
"dt_init": 0.01,
"dt_min": 1e-6,
"dt_max": 1000.9,
"max_error_test_failures": 11,
"max_nonlinear_iterations": 5,
Expand Down
Loading