Casadi solver doesn't work with external variables
See original GitHub issueSummary ODE solver allows you to specify external variables - it would be good if Casadi solver did to
At the very least there should be some error messages saying it’s not implemented yet. If you try to run it you get runtime errors
RuntimeError: …/casadi/core/function_internal.hpp:1247: Input 1 (i1) has mismatching shape. Got 80-by-1. Allowed dimensions, in general, are:
- The input dimension N-by-M (here 81-by-1)
- A scalar, i.e. 1-by-1
- M-by-N if N=1 or M=1 (i.e. a transposed vector)
- N-by-M1 if K*M1=M for some K (argument repeated horizontally)
- N-by-P*M, indicating evaluation with multiple arguments (P must be a multiple of 1 for consistency with previous inputs)
This was produced with the following script
import pybamm
import numpy as np
model_options = {
"thermal": "x-lumped",
"external submodels": ["thermal"],
}
model = pybamm.lithium_ion.SPMe(model_options)
solver = pybamm.CasadiSolver()
sim = pybamm.Simulation(model, solver=solver)
t_eval = np.linspace(0, 0.01, 3)
T_av = 0.0
for i in np.arange(1, len(t_eval) - 1):
dt = t_eval[i + 1] - t_eval[i]
external_variables = {"X-averaged cell temperature": T_av}
T_av += 1.0
sim.step(dt, external_variables=external_variables)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:10
Top Results From Across the Web
Docs - CasADi
Unlike integrator objects, NLP solver functions are currently not differentiable functions in CasADi. There are several NLP solvers interfaced with CasADi. The ...
Read more >Solving Problems in Parallel · Issue #1942 · casadi ... - GitHub
I believe that refers to nlp and/or solver variables that are arguments to the function to be executed in parallel.
Read more >User Documentation for CasADi v3.2.3
Unlike integrator objects, NLP solver functions are currently not differentiable functions in CasADi. There are several NLP solvers interfaced ...
Read more >Issues after installing CasADi with SNOPT - Google Groups
I have the environment variable $SNOPT set to the root SNOPT directory. Both SNOPT/IPOPT are found (reported by cmake). I also amended LD_LIBRARY_PATH...
Read more >Source code for pybamm.solvers.casadi_solver
CasADi Solver class # import casadi import pybamm import numpy as np import ... Any external variables or input parameters to pass to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Fine by me . I approved the PR
Let’s merge this in now, and I’ll work on other issues as part of #784