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

Simulation with explicit experiment and irreversibe plating fails #1700

Closed
DavidMStraub opened this issue Sep 30, 2021 · 3 comments · Fixed by #1707
Closed

Simulation with explicit experiment and irreversibe plating fails #1700

DavidMStraub opened this issue Sep 30, 2021 · 3 comments · Fixed by #1707
Assignees

Comments

@DavidMStraub
Copy link
Contributor

  • PyBaMM version: Current develop
  • Python version: 3.8.5

Describe the bug

Error:

RuntimeError: .../casadi/core/function_internal.hpp:1257: Input 1 (i1) has mismatching shape. Got 141-by-1. Allowed dimensions, in general, are:
 - The input dimension N-by-M (here 122-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)

To Reproduce
Steps to reproduce the behaviour:

import pybamm

options = {"lithium plating": "irreversible"}
model = pybamm.lithium_ion.SPMe(options=options)

experiment = pybamm.Experiment(
    [
        "Discharge with 1 C for 30 minutes",
        "Rest for 30 minutes",
    ]
)

solver = pybamm.CasadiSolver("fast with events")

parameter_values = model.default_parameter_values.copy()
parameter_values.update(
    {
        "Lithium metal partial molar volume [m3.mol-1]": 1.30e-5,
        "Exchange-current density for plating [A.m-2]": 0.001,
        "Initial plated lithium concentration [mol.m-3]": 0,
        "Typical plated lithium concentration [mol.m-3]": 1000,
    },
    check_already_exists=False
)

sim = pybamm.Simulation(model, experiment=experiment, solver=solver, parameter_values=parameter_values)
sim.solve()

Expected behaviour

No error

Additional context

@brosaplanella
Copy link
Sponsor Member

The issue is with the x-averaging of the plating model. I will open a separate issue, but for the moment you can replace the line where you define the model by

model = pybamm.lithium_ion.SPMe(build=False)
model.submodels["negative lithium plating"] = pybamm.lithium_plating.IrreversiblePlating(model.param, "Negative", False)
model.build_model()

@DavidMStraub
Copy link
Contributor Author

Thanks! Fix worked (I had to remove the "Negative" from IrreversiblePlating).

@valentinsulzer
Copy link
Member

It should still work with the x-averaged form, there is just a bug in how multiple steps are set up. I thought I had fixed it but don't know where that branch went

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants