Base Submodel#
- class pybamm.BaseSubModel(param, domain=None, name='Unnamed submodel', external=False, options=None, phase=None)[source]#
The base class for all submodels. All submodels inherit from this class and must only provide public methods which overwrite those in this base class. Any methods added to a submodel that do not overwrite those in this bass class are made private with the prefix ‘_’, providing a consistent public interface for all submodels.
- Parameters:
param (parameter class) – The model parameter symbols
domain (str) – The domain of the model either ‘Negative’ or ‘Positive’
name (str) – A string giving the name of the submodel
external (bool, optional) – Whether the variables defined by the submodel will be provided externally by the users. Default is ‘False’.
options (dict) – A dictionary of options to be passed to the model. See
pybamm.BaseBatteryModel
phase (str, optional) – Phase of the particle (default is None).
- param#
The model parameter symbols.
- Type:
parameter class
- domain#
The domain of the submodel, could be either ‘Negative’, ‘Positive’, ‘Separator’, or None.
- Type:
- external#
A boolean flag indicating whether the variables defined by the submodel will be provided externally by the user. Set to False by default.
- Type:
- options#
A dictionary or an instance of pybamm.BatteryModelOptions that stores configuration options for the submodel.
- Type:
- phase_name#
A string representing the phase of the submodel, which could be “primary”, “secondary”, or an empty string if there is only one phase.
- Type:
- phase#
The current phase of the submodel, which could be “primary”, “secondary”, or None.
- Type:
str or None
- boundary_conditions#
A dictionary mapping variables to their respective boundary conditions.
- Type:
- variables#
A dictionary mapping variable names (strings) to expressions or objects that represent the useful variables for the submodel.
- Type:
Extends:
pybamm.models.base_model.BaseModel
- add_events_from(variables)[source]#
A method to set events related to the state of submodel variable. Note: this method modifies the state of self.events. Unless overwritten by a submodel, the default behaviour of ‘pass’ is used as implemented in
pybamm.BaseSubModel
.- Parameters:
variables (dict) – The variables in the whole model.
- property domain_Domain#
Returns a tuple containing the current domain and its capitalized form.
- get_coupled_variables(variables)[source]#
A public method that creates and returns the variables in a submodel which require variables in other submodels to be set first. For example, the exchange current density requires the concentration in the electrolyte to be created before it can be created. If a variable can be created independent of other submodels then it should be created in ‘get_fundamental_variables’ instead of this method.
- get_fundamental_variables()[source]#
A public method that creates and returns the variables in a submodel which can be created independent of other submodels. For example, the electrolyte concentration variables can be created independent of whether any other variables have been defined in the model. As a rule, if a variable can be created without variables from other submodels, then it should be placed in this method.
- Returns:
The variables created by the submodel which are independent of variables in other submodels.
- Return type:
- get_parameter_info(by_submodel=False)[source]#
Extracts the parameter information and returns it as a dictionary. To get a list of all parameter-like objects without extra information, use
model.parameters
.
- set_algebraic(variables)[source]#
A method to set the differential equations which do not contain a time derivative. Note: this method modifies the state of self.algebraic. Unless overwritten by a submodel, the default behaviour of ‘pass’ is used as implemented in
pybamm.BaseSubModel
.- Parameters:
variables (dict) – The variables in the whole model.
- set_boundary_conditions(variables)[source]#
A method to set the boundary conditions for the submodel. Note: this method modifies the state of self.boundary_conditions. Unless overwritten by a submodel, the default behaviour of ‘pass’ is used as implemented in
pybamm.BaseSubModel
.- Parameters:
variables (dict) – The variables in the whole model.
- set_initial_conditions(variables)[source]#
A method to set the initial conditions for the submodel. Note: this method modifies the state of self.initial_conditions. Unless overwritten by a submodel, the default behaviour of ‘pass’ is used as implemented in
pybamm.BaseSubModel
.- Parameters:
variables (dict) – The variables in the whole model.
- set_rhs(variables)[source]#
A method to set the right hand side of the differential equations which contain a time derivative. Note: this method modifies the state of self.rhs. Unless overwritten by a submodel, the default behaviour of ‘pass’ is used as implemented in
pybamm.BaseSubModel
.- Parameters:
variables (dict) – The variables in the whole model.