diff --git a/pybamm/solvers/c_solvers/idaklu.cpp b/pybamm/solvers/c_solvers/idaklu.cpp index 720dcd3be2..2e5fccfb8e 100644 --- a/pybamm/solvers/c_solvers/idaklu.cpp +++ b/pybamm/solvers/c_solvers/idaklu.cpp @@ -59,7 +59,7 @@ PYBIND11_MODULE(idaklu, m) //py::bind_vector>(m, "VectorFunction"); //py::implicitly_convertible>(); - + m.def("create_casadi_solver", &create_casadi_solver, "Create a casadi idaklu solver object", py::arg("number_of_states"), diff --git a/pybamm/solvers/c_solvers/idaklu/CasadiSolver.cpp b/pybamm/solvers/c_solvers/idaklu/CasadiSolver.cpp index f45e667d68..3967449b1f 100644 --- a/pybamm/solvers/c_solvers/idaklu/CasadiSolver.cpp +++ b/pybamm/solvers/c_solvers/idaklu/CasadiSolver.cpp @@ -4,6 +4,6 @@ /* * This is an abstract base class for the Idaklu solver */ - + CasadiSolver::CasadiSolver() {} CasadiSolver::~CasadiSolver() {} diff --git a/pybamm/solvers/c_solvers/idaklu/CasadiSolverOpenMP.cpp b/pybamm/solvers/c_solvers/idaklu/CasadiSolverOpenMP.cpp index e3e7117896..ac695051ce 100644 --- a/pybamm/solvers/c_solvers/idaklu/CasadiSolverOpenMP.cpp +++ b/pybamm/solvers/c_solvers/idaklu/CasadiSolverOpenMP.cpp @@ -10,7 +10,7 @@ * are intended to be overriden to support alternative solver * approaches, as needed. */ - + /* Skeleton workflow: https://sundials.readthedocs.io/en/latest/ida/Usage/index.html 1. (N/A) Initialize parallel or multi-threaded environment @@ -135,7 +135,7 @@ void CasadiSolverOpenMP::Initialize() { N_VConst(RCONST(0.0), yyS[is]); N_VConst(RCONST(0.0), ypS[is]); } - + // create Matrix objects SetMatrix(); @@ -210,7 +210,7 @@ CasadiSolverOpenMP::~CasadiSolverOpenMP() N_VDestroy(yy); N_VDestroy(yp); N_VDestroy(id); - + if (number_of_parameters > 0) { N_VDestroyVectorArray(yyS, number_of_parameters); @@ -367,7 +367,7 @@ Solution CasadiSolverOpenMP::solve( realtype *yS_return = new realtype[number_of_parameters * number_of_timesteps * length_of_return_vector]; - + res = new realtype[max_res_size]; res_dvar_dy = new realtype[max_res_dvar_dy]; res_dvar_dp = new realtype[max_res_dvar_dp]; diff --git a/pybamm/solvers/c_solvers/idaklu/casadi_functions.cpp b/pybamm/solvers/c_solvers/idaklu/casadi_functions.cpp index 829e983b42..6c5f882b7b 100644 --- a/pybamm/solvers/c_solvers/idaklu/casadi_functions.cpp +++ b/pybamm/solvers/c_solvers/idaklu/casadi_functions.cpp @@ -70,7 +70,7 @@ CasadiFunctions::CasadiFunctions( for (auto& var : dvar_dp_fcns) { this->dvar_dp_fcns.push_back(CasadiFunction(*var)); } - + // copy across numpy array values const int n_row_vals = jac_times_cjmass_rowvals_arg.request().size; auto p_jac_times_cjmass_rowvals = jac_times_cjmass_rowvals_arg.unchecked<1>(); diff --git a/pybamm/solvers/c_solvers/idaklu/casadi_functions.hpp b/pybamm/solvers/c_solvers/idaklu/casadi_functions.hpp index 1feac1f359..848a365842 100644 --- a/pybamm/solvers/c_solvers/idaklu/casadi_functions.hpp +++ b/pybamm/solvers/c_solvers/idaklu/casadi_functions.hpp @@ -14,7 +14,7 @@ void csc_csr(realtype f[], T1 c[], T1 r[], realtype nf[], T2 nc[], T2 nr[], int int rr[N]; for (int i=0; i var_casadi_fcns; std::vector dvar_dy_fcns; std::vector dvar_dp_fcns; - + std::vector jac_times_cjmass_rowvals; std::vector jac_times_cjmass_colptrs; std::vector inputs; - + Options options; - + realtype *get_tmp_state_vector(); realtype *get_tmp_sparse_jacobian_data(); diff --git a/pybamm/solvers/c_solvers/idaklu/casadi_solver.cpp b/pybamm/solvers/c_solvers/idaklu/casadi_solver.cpp index 7040d1398f..c1c06c0fed 100644 --- a/pybamm/solvers/c_solvers/idaklu/casadi_solver.cpp +++ b/pybamm/solvers/c_solvers/idaklu/casadi_solver.cpp @@ -29,7 +29,7 @@ CasadiSolver *create_casadi_solver( const std::vector dvar_dy_fcns, const std::vector dvar_dp_fcns, py::dict options -) { +) { auto options_cpp = Options(options); auto functions = std::make_unique( rhs_alg, @@ -54,7 +54,7 @@ CasadiSolver *create_casadi_solver( ); CasadiSolver *casadiSolver = nullptr; - + // Instantiate solver class if (options_cpp.linear_solver == "SUNLinSol_Dense") { diff --git a/pybamm/solvers/c_solvers/idaklu/casadi_solver.hpp b/pybamm/solvers/c_solvers/idaklu/casadi_solver.hpp index 023810d2a5..84e57ed050 100644 --- a/pybamm/solvers/c_solvers/idaklu/casadi_solver.hpp +++ b/pybamm/solvers/c_solvers/idaklu/casadi_solver.hpp @@ -10,9 +10,9 @@ CasadiSolver *create_casadi_solver( const Function &jac_times_cjmass, const np_array_int &jac_times_cjmass_colptrs, const np_array_int &jac_times_cjmass_rowvals, - const int jac_times_cjmass_nnz, + const int jac_times_cjmass_nnz, const int jac_bandwidth_lower, - const int jac_bandwidth_upper, + const int jac_bandwidth_upper, const Function &jac_action, const Function &mass_action, const Function &sens, diff --git a/pybamm/solvers/c_solvers/idaklu/casadi_sundials_functions.cpp b/pybamm/solvers/c_solvers/idaklu/casadi_sundials_functions.cpp index e39d0fce56..0c98ad9d26 100644 --- a/pybamm/solvers/c_solvers/idaklu/casadi_sundials_functions.cpp +++ b/pybamm/solvers/c_solvers/idaklu/casadi_sundials_functions.cpp @@ -222,7 +222,7 @@ int jacobian_casadi(realtype tt, realtype cj, N_Vector yy, N_Vector yp, realtype newjac[SUNSparseMatrix_NNZ(JJ)]; sunindextype *jac_ptrs = SUNSparseMatrix_IndexPointers(JJ); sunindextype *jac_vals = SUNSparseMatrix_IndexValues(JJ); - + // args are t, y, cj, put result in jacobian data matrix p_python_functions->jac_times_cjmass.m_arg[0] = &tt; p_python_functions->jac_times_cjmass.m_arg[1] = NV_DATA(yy); diff --git a/pybamm/solvers/c_solvers/idaklu/sundials_legacy_wrapper.hpp b/pybamm/solvers/c_solvers/idaklu/sundials_legacy_wrapper.hpp index 19bc92dcdf..f4855b1bc4 100644 --- a/pybamm/solvers/c_solvers/idaklu/sundials_legacy_wrapper.hpp +++ b/pybamm/solvers/c_solvers/idaklu/sundials_legacy_wrapper.hpp @@ -26,12 +26,12 @@ { return N_VNew_Serial(vec_length); } - + N_Vector N_VNew_OpenMP(sunindextype vec_length, SUNContext sunctx) { return N_VNew_OpenMP(vec_length); } - + N_Vector N_VNew_Cuda(sunindextype vec_length, SUNContext sunctx) { return N_VNew_Cuda(vec_length);