question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Casadi solver doesn't work with external variables

See original GitHub issue

Summary 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:10

github_iconTop GitHub Comments

1reaction
TomTrantercommented, Jan 17, 2020

Fine by me . I approved the PR

0reactions
tinosulzercommented, Jan 17, 2020

Let’s merge this in now, and I’ll work on other issues as part of #784

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found