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

Remove python-idaklu #4326

Merged
merged 11 commits into from
Aug 27, 2024
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
- Fixed memory issue that caused failure when `output variables` were specified with (`IDAKLUSolver`). ([#4379](https://github.com/pybamm-team/PyBaMM/issues/4379))
- Fixed bug where IDAKLU solver failed when `output variables` were specified and an event triggered. ([#4300](https://github.com/pybamm-team/PyBaMM/pull/4300))

## Breaking changes

- Removed legacy python-IDAKLU solver. ([#4326](https://github.com/pybamm-team/PyBaMM/pull/4326))

# [v24.5](https://github.com/pybamm-team/PyBaMM/tree/v24.5) - 2024-07-26

## Features
Expand Down
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ pybind11_add_module(idaklu
src/pybamm/solvers/c_solvers/idaklu/IdakluJax.hpp
src/pybamm/solvers/c_solvers/idaklu/common.hpp
src/pybamm/solvers/c_solvers/idaklu/common.cpp
src/pybamm/solvers/c_solvers/idaklu/python.hpp
src/pybamm/solvers/c_solvers/idaklu/python.cpp
src/pybamm/solvers/c_solvers/idaklu/Solution.cpp
src/pybamm/solvers/c_solvers/idaklu/Solution.hpp
src/pybamm/solvers/c_solvers/idaklu/Options.hpp
Expand Down
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,6 @@ def compile_KLU():
"src/pybamm/solvers/c_solvers/idaklu/IdakluJax.hpp",
"src/pybamm/solvers/c_solvers/idaklu/common.hpp",
"src/pybamm/solvers/c_solvers/idaklu/common.cpp",
"src/pybamm/solvers/c_solvers/idaklu/python.hpp",
"src/pybamm/solvers/c_solvers/idaklu/python.cpp",
"src/pybamm/solvers/c_solvers/idaklu/Solution.cpp",
"src/pybamm/solvers/c_solvers/idaklu/Solution.hpp",
"src/pybamm/solvers/c_solvers/idaklu/Options.hpp",
Expand Down
1 change: 1 addition & 0 deletions src/pybamm/models/base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class BaseModel:
calling `evaluate(t, y)` on the given expression treeself.
- "casadi": convert into CasADi expression tree, which then uses CasADi's \
algorithm to calculate the Jacobian.
- "jax": convert into JAX expression tree
pipliggins marked this conversation as resolved.
Show resolved Hide resolved
Default is "casadi".
"""
Expand Down
23 changes: 5 additions & 18 deletions src/pybamm/solvers/base_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1514,26 +1514,13 @@ def report(string):
elif model.convert_to_format != "casadi":
y = vars_for_processing["y"]
jacobian = vars_for_processing["jacobian"]
# Process with pybamm functions, converting
# to python evaluator

if model.calculate_sensitivities:
report(
f"Calculating sensitivities for {name} with respect "
f"to parameters {model.calculate_sensitivities}"
raise pybamm.SolverError( # pragma: no cover
"Sensitivies are no longer supported for the python "
"evaluator. Please use `convert_to_format = 'casadi'`, or `jax` "
"to calculate sensitivities."
)
jacp_dict = {
p: symbol.diff(pybamm.InputParameter(p))
for p in model.calculate_sensitivities
}

report(f"Converting sensitivities for {name} to python")
jacp_dict = {
p: pybamm.EvaluatorPython(jacp) for p, jacp in jacp_dict.items()
}

# jacp should be a function that returns a dict of sensitivities
def jacp(*args, **kwargs):
return {k: v(*args, **kwargs) for k, v in jacp_dict.items()}

else:
jacp = None
Expand Down
23 changes: 0 additions & 23 deletions src/pybamm/solvers/c_solvers/idaklu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "idaklu/idaklu_solver.hpp"
#include "idaklu/IdakluJax.hpp"
#include "idaklu/common.hpp"
#include "idaklu/python.hpp"
#include "idaklu/Expressions/Casadi/CasadiFunctions.hpp"

#ifdef IREE_ENABLE
Expand All @@ -34,28 +33,6 @@ PYBIND11_MODULE(idaklu, m)

py::bind_vector<std::vector<np_array>>(m, "VectorNdArray");

m.def("solve_python", &solve_python,
"The solve function for python evaluators",
py::arg("t"),
py::arg("y0"),
py::arg("yp0"),
py::arg("res"),
py::arg("jac"),
py::arg("sens"),
py::arg("get_jac_data"),
py::arg("get_jac_row_vals"),
py::arg("get_jac_col_ptr"),
py::arg("nnz"),
py::arg("events"),
py::arg("number_of_events"),
py::arg("use_jacobian"),
py::arg("rhs_alg_id"),
py::arg("atol"),
py::arg("rtol"),
py::arg("inputs"),
py::arg("number_of_sensitivity_parameters"),
py::return_value_policy::take_ownership);

py::class_<IDAKLUSolver>(m, "IDAKLUSolver")
.def("solve", &IDAKLUSolver::solve,
"perform a solve",
Expand Down
Loading
Loading