Easy distinction between PyBOP parameters and PyBaMM parameters #396
Description
Feature description
Okay slightly strange one here, but bare with me... It would be useful if it were possible to take the parameters proposed by PyBOP, and post-process them into the parameter set that PyBaMM sees. So, PyBOP optimises over a set of parameters, a post-processor does something to them, and the results are fed into a PyBaMM model.
There's ways around this already, eg. use a custom / standalone model, or subclassing a PyBOP model and overriding the simulate
function to postprocess the parameters before they go off to PyBaMM. Neither of these are particularly convenient though, so it would be good to have the structure in PyBOP to natively handle this sort of parameter processing.
Motivation
Three cases where I've found myself trying to do this, all in the context of fitting Thevenin models:
- Functional parameters: idea would be for PyBOP to optimise over a set of 'dummy parameters', eg.
r0_at_soc_1
,r0_at_soc_0d9
, ..., and have a postprocessor build these into apybamm.Interpolant
from the pairs(SOC=1, R0=r0_at_soc_1)
,(SOC=0.9, R0=r0_at_soc_0d9)
, etc. This is useful for fitting linear interpolation flavoured functional parameters, since PyBOP can't optimise over apybamm.Interpolant
and the PyBaMM model doesn't natively take series resistance R0s as a list of scalars. Instead, the post-processor can act as a layer between PyBOP and PyBaMM, to close this gap. - Least squares regression of ECMs: consider fitting a 1-RC model with a fixed time-constant, using the
GaussianLogLikelihood
method. PyBOP can be used to identify the RC resistance$R$ , but to build a complete PyBaMM model, we also need to set the RC capacitance as$C=\tau/R$ . This again needs some sort of intermediate step between the parameter PyBOP suggests (in this case,$R$ ), and the parameters PyBaMM sees (here,$R$ and$C$ ). - Unsure how useful this will be in practice, but it would be interesting to see if fitting
$1/R$ is more numerically stable than fitting$R$ directly. For a constrained optimisation where timescale$R*C \leq \tau_{max}$ , the search space for parameter$R$ can be particularly small (think the small strip close to the$y$ axis of a$y=1/x$ curve). In that case, optimising over conductance$1/R$ will have a much larger search space, and could therefore alleviate some of the difficulties the optimisers can face. Again this needs a post-processor / translation layer between the$1/R$ that PyBOP sees, and the$R$ that gets fed into the PyBaMM model.
Possible implementation
Something like an optional callback function in the optimiser class. Takes a dict of named PyBOP parameters, and outputs a dict of named PyBaMM parameters.
Additional context
No response
Metadata
Assignees
Labels
Type
Projects
Status
Done