pybamm-team / PyBaMM

Fast and flexible physics-based battery models in Python
https://www.pybamm.org/
BSD 3-Clause "New" or "Revised" License
1.06k stars 526 forks source link

[Bug]: TypeError in Example Notebook: Simulation.__init__() got an unexpected keyword argument 'discretisation_kwargs' #4281

Closed opqrst-chen closed 2 weeks ago

opqrst-chen commented 1 month ago

PyBaMM Version

24.1

Python Version

3.12.4

Describe the bug

I encountered a TypeError when running the example notebook located at PyBaMM/docs/source/examples/notebooks/models/loss_of_active_materials.ipynb.

The error occurs with the following code:

sim = pybamm.Simulation(
    model,
    experiment=experiment,
    parameter_values=param,
    discretisation_kwargs={"remove_independent_variables_from_rhs": True},
)

The error message is as follows:

{
    "name": "TypeError",
    "message": "Simulation.__init__() got an unexpected keyword argument 'discretisation_kwargs'",
    "stack": "---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[10], line 23
     14 param.update({\"Positive electrode LAM constant proportional term [s-1]\": 1e-4 / 3600})
     15 experiment = pybamm.Experiment(
     16     [
     17         \"Discharge at 1C until 3 V\",
   (...)
     21     ]
     22 )
---> 23 sim = pybamm.Simulation(
     24     model,
     25     experiment=experiment,
     26     parameter_values=param,
     27     discretisation_kwargs={\"remove_independent_variables_from_rhs\": True},
     28 )
     29 solution = sim.solve(calc_esoh=False)

TypeError: Simulation.__init__() got an unexpected keyword argument 'discretisation_kwargs'"
}

Steps to Reproduce

  1. Open the example notebook at PyBaMM/docs/source/examples/notebooks/models/loss_of_active_materials.ipynb.
  2. Execute the code in the cell.
  3. Observe the error message when running the following code:
    sim = pybamm.Simulation(
    model,
    experiment=experiment,
    parameter_values=param,
    discretisation_kwargs={"remove_independent_variables_from_rhs": True},
    )

Relevant log output

No response

agriyakhetarpal commented 1 month ago

Hi, @opqrst-chen – since you're running PyBaMM version 24.1, could you please try out the notebook from the v24.1 branch: https://github.com/pybamm-team/PyBaMM/blob/v24.1/docs/source/examples/notebooks/models/loss_of_active_materials.ipynb? The discretisation_kwargs argument does not exist in v24.1, but exists in the unreleased develop branch, which might explain your error. FYI, PyBaMM's pre-releases for v24.5 are available as well, where the notebook from the develop branch should work. The pre-releases, shall you wish to install them, can be installed with this command: pip install --pre pybamm

github-actions[bot] commented 2 weeks ago

It looks like there hasn't been a reply in 30 days, so I'm closing this issue.