pybamm-team / PyBaMM

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

Make `calc_esoh` a model attribute #4619

Open rtimms opened 4 days ago

rtimms commented 4 days ago

Currently the Simulation class uses the following logic to decide if it should calculate the state of health in a simulation

    def _get_esoh_solver(self, calc_esoh):
        if (
            calc_esoh is False
            or isinstance(self._model, pybamm.lead_acid.BaseModel)
            or isinstance(self._model, pybamm.equivalent_circuit.Thevenin)
            or self._model.options["working electrode"] != "both"
        ):
            return None

        return pybamm.lithium_ion.ElectrodeSOHSolver(
            self._parameter_values, self._model.param, options=self._model.options
        )

It would be nice if cacl_esoh was a model attribute (True by default) so that when writing custom models you don't have to pass calc_esoh=False to the solver every time.

valentinsulzer commented 2 days ago

I think the whole "this is how you calculate summary variables" logic should be in the model instead of the solver