From 24471d248a68554d45c53ecff2ba661473ffa6e8 Mon Sep 17 00:00:00 2001 From: Valentin Sulzer Date: Wed, 21 Sep 2022 13:38:19 -0400 Subject: [PATCH 1/4] specify input parameter order when exporting casadi objects --- examples/basic_16p2s.py | 2 +- liionpack/solver_utils.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/basic_16p2s.py b/examples/basic_16p2s.py index de25cb9c..6acb4590 100644 --- a/examples/basic_16p2s.py +++ b/examples/basic_16p2s.py @@ -43,7 +43,7 @@ initial_soc=0.5, inputs=inputs, nproc=os.cpu_count(), - manager='casadi') + manager='ray') # Plot the pack and individual cell results lp.plot_pack(output) diff --git a/liionpack/solver_utils.py b/liionpack/solver_utils.py index d9474965..8b62d46e 100644 --- a/liionpack/solver_utils.py +++ b/liionpack/solver_utils.py @@ -319,7 +319,9 @@ def _create_casadi_objects(inputs, sim, dt, Nspm, nproc, variable_names, mapped) integrator = integrator.map(Nspm, "thread", nproc) # Variables function for parallel evaluation - casadi_objs = sim.built_model.export_casadi_objects(variable_names=variable_names) + casadi_objs = sim.built_model.export_casadi_objects( + variable_names=variable_names, input_parameter_order=inputs[0].keys() + ) variables = casadi_objs["variables"] t, x, z, p = ( casadi_objs["t"], From aaee48d4ced5d491a92fbae186a0ff0b504f6027 Mon Sep 17 00:00:00 2001 From: Valentin Sulzer Date: Wed, 21 Sep 2022 13:39:53 -0400 Subject: [PATCH 2/4] revert to casadi in example --- examples/basic_16p2s.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/basic_16p2s.py b/examples/basic_16p2s.py index 6acb4590..de25cb9c 100644 --- a/examples/basic_16p2s.py +++ b/examples/basic_16p2s.py @@ -43,7 +43,7 @@ initial_soc=0.5, inputs=inputs, nproc=os.cpu_count(), - manager='ray') + manager='casadi') # Plot the pack and individual cell results lp.plot_pack(output) From 3ca10596c407cd66bfb53fbb030ed33de00139ab Mon Sep 17 00:00:00 2001 From: Valentin Sulzer Date: Wed, 21 Sep 2022 14:10:22 -0400 Subject: [PATCH 3/4] add order in other call --- liionpack/solver_utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/liionpack/solver_utils.py b/liionpack/solver_utils.py index 8b62d46e..3bc0bc7d 100644 --- a/liionpack/solver_utils.py +++ b/liionpack/solver_utils.py @@ -339,7 +339,9 @@ def _create_casadi_objects(inputs, sim, dt, Nspm, nproc, variable_names, mapped) event_vars = [v for v in all_vars if "Event" in v] if len(event_vars) > 0: # Variables function for parallel evaluation - casadi_objs = sim.built_model.export_casadi_objects(variable_names=event_vars) + casadi_objs = sim.built_model.export_casadi_objects( + variable_names=variable_names, input_parameter_order=inputs[0].keys() + ) events = casadi_objs["variables"] t, x, z, p = ( casadi_objs["t"], From e262a958d06acd8b087934bbeddc6bd7d0a1caed Mon Sep 17 00:00:00 2001 From: Valentin Sulzer Date: Wed, 21 Sep 2022 15:12:52 -0400 Subject: [PATCH 4/4] #170 flake8 --- liionpack/solver_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/liionpack/solver_utils.py b/liionpack/solver_utils.py index 3bc0bc7d..693c1fc8 100644 --- a/liionpack/solver_utils.py +++ b/liionpack/solver_utils.py @@ -340,8 +340,8 @@ def _create_casadi_objects(inputs, sim, dt, Nspm, nproc, variable_names, mapped) if len(event_vars) > 0: # Variables function for parallel evaluation casadi_objs = sim.built_model.export_casadi_objects( - variable_names=variable_names, input_parameter_order=inputs[0].keys() - ) + variable_names=variable_names, input_parameter_order=inputs[0].keys() + ) events = casadi_objs["variables"] t, x, z, p = ( casadi_objs["t"],