Offline Estimators (m.estimators.offline)#

Tools which estimate parameters of battery health and performance after-the-fact.

class moirae.estimators.offline.OfflineEstimator#

Bases: object

Base class for tools which estimate battery health parameters given many measurements of the battery performance over time.

Create the class by passing a fully-configured Loss() then perform the estimation using the estimate() function.

estimate() tuple[GeneralContainer, HealthVariable, Any]#

Compute an estimate for the initial state and ASOH.

Returns:

  • Estimate for the initial state

  • Estimate for the ASOH parameters

  • Diagnostic unique to the type of estimator

loss: BaseLoss#

Function being minimized

Scipy Estimators (m.e.offline.scipy)#

Estimate the state of health using SciPy optimizers

class moirae.estimators.offline.scipy.ScipyDifferentialEvolution(objective: BaseLoss, bounds: Bounds | list[tuple[float, float]], **kwargs)#

Bases: OfflineEstimator

Estimate using SciPy’s differential_evolution function.

Parameters:
  • objective – Objective function to be optimized

  • bounds – Bounds for variables. There are two ways to specify the bounds: instance of scipy Bounds class, or (min, max) pairs for each element in x, defining the finite lower and upper bounds for the optimizing argument of func.

  • kwargs – Passed to the minimize function. Refer to the documentation for differential_evolution

estimate() tuple[GeneralContainer, HealthVariable, OptimizeResult]#

Compute an estimate for the initial state and ASOH.

Returns:

  • Estimate for the initial state

  • Estimate for the ASOH parameters

  • Diagnostic unique to the type of estimator

class moirae.estimators.offline.scipy.ScipyMinimizer(objective: BaseLoss, **kwargs)#

Bases: OfflineEstimator

Estimate using SciPy’s minimize function.

Parameters:
  • objective – Objective function to be optimized

  • kwargs – Passed to the minimize function. Refer to the documentation of minimize

estimate() tuple[GeneralContainer, HealthVariable, OptimizeResult]#

Compute an estimate for the initial state and ASOH.

Returns:

  • Estimate for the initial state

  • Estimate for the ASOH parameters

  • Diagnostic unique to the type of estimator

Loss Functions (m.e.offline.loss)#

Interfaces that evaluate the fitness of a set of battery state parameters provided as a NumPy array.

class moirae.estimators.offline.loss.AdditiveLoss(losses: list[tuple[float, BaseLoss]])#

Bases: BaseLoss

Loss function which combines multiple loss functions

Supply a list of loss functions and weights for each.

Parameters:
  • losses – List of loss functions, defined as pairs of (weight, loss) values

  • cell_model – Model that describes battery physics

  • asoh – Initial guesses for ASOH parameter values

  • transient_state – Initial guesses for transient state

  • observations – Observations of battery performance

class moirae.estimators.offline.loss.BaseLoss(cell_model: CellModel, asoh: HealthVariable, transient_state: GeneralContainer, observations: BatteryDataset)#

Bases: object

Base class for objective functions which evaluate the ability of a set of battery health parameters to explain the observed performance data.

All Loss classes should follow the convention that better sets of parameters yield values which are less than worse parameters. There are no constraints on whether the values need to be positive or negative.

Parameters:
  • cell_model – Model that describes battery physics

  • asoh – Initial guesses for ASOH parameter values

  • transient_state – Initial guesses for transient state

  • observations – Observations of battery performance

asoh: HealthVariable#

Initial guess for battery health

cell_model: CellModel#

Cell model used to compute

get_x0() ndarray#

Generate an initial guess

Returns:

A 1D vector used as a starting point for class to this class

property num_states: int#

Number of output variables which correspond to transient states

observations: BatteryDataset#

Observed data for the battery performance

state: GeneralContainer#

Initial guess for battery transient state

x_to_state(x: ndarray, inplace: bool = True) tuple[GeneralContainer, HealthVariable]#

Copy batch of parameters into ASOH and state classes

Parameters:
  • x – Batch of parameters

  • inplace – Whether to edit the copies of ASOH and state held by the loss function, or return a copy

class moirae.estimators.offline.loss.MeanSquaredLoss(cell_model: CellModel, asoh: HealthVariable, transient_state: GeneralContainer, observations: BatteryDataset)#

Bases: BaseLoss

Score the fitness of a set of health parameters by the mean squared error between observed and predicted terminal voltage.

Parameters:
  • cell_model – Model that describes battery physics

  • asoh – Initial guesses for ASOH parameter values

  • transient_state – Initial guesses for transient state

  • observations – Observations of battery performance

class moirae.estimators.offline.loss.PriorLoss(transient_priors: dict[str, rv_continuous], asoh_priors: dict[str, rv_continuous], cell_model: CellModel, asoh: HealthVariable, transient_state: GeneralContainer, observations: BatteryDataset)#

Bases: BaseLoss

Compute the negative log-probability of parameter values from a prior distribution

Supply priors as a scipy rv_continuous distribution that defines the logpdf() method.

For example, setting priors for the hysteresis parameter of an ECM and no priors for the ASOH parameters.

from scipy.stats import norm

hy_dist = norm(loc=0, scale=0.1)
prior_loss = PriorLoss(
    transient_priors={'hyst': hy_dist},
    asoh_priors={},
    cell_model=ecm_model,
    asoh=init_asoh,
    transient_state=int_state,
    observations=timeseries_dataset
)
Parameters:
  • cell_model – Model that describes battery physics

  • asoh – Initial guesses for ASOH parameter values

  • transient_state – Initial guesses for transient state

  • observations – Observations of battery performance