cideMOD.models.model_handler
Classes
|
Container abstracting a list of BaseCellModel. |
|
Container abstracting a list of BaseCellModel. |
- class cideMOD.models.model_handler.CellModelList(model_list, instances=True)[source]
Bases:
ParsedListContainer abstracting a list of BaseCellModel. This class sorts by hierarchy the given list of models
- class cideMOD.models.model_handler.ModelHandler(options)[source]
Bases:
CellModelListContainer abstracting a list of BaseCellModel. Enable to access the models attributes via a single call. It builds a bridge between models and cideMOD classes.
- build_cell_components(cell) None[source]
This method iterates over the active models to build the components of the cell that fit our model type.
- Parameters:
cell (CellParser) – Parser of the cell dictionary.
- build_dimensional_analysis(DA: DimensionalAnalysis, cell: CellParser)[source]
This method computes the dimensionless numbers that arise from the dimensional analysis.
- Parameters:
DA (DimensionalAnalysis) – Object where the dimensional analysis is performed.
cell (CellParser) – Parser of the cell dictionary.
- build_weak_formulation(solvers_info: dict, var: ProblemVariables, cell: BatteryCell, mesher: BaseMesher, DT: TimeScheme, W: BlockFunctionSpace, problem)[source]
This method iterates over the active models to build the weak formulation of the problem.
- Parameters:
solvers_info (dict) – Dictionary containing solvers information
var (ProblemVariables) – Object that store the preprocessed problem variables.
cell (BatteryCell) – Object where cell parameters are preprocessed and stored.
mesher (BaseMesher) – Object that store the mesh information.
DT (TimeScheme) – Object that provide the temporal derivatives with the specified scheme.
W (BlockFunctionSpace) – Object that store the function space of each state variable.
problem (Problem) – Object that handles the battery cell simulation.
- Returns:
Object containing the integral forms of each equation, as well as the dirichlet boundary conditions, that corresponds to each state variable.
- Return type:
- build_weak_formulation_stationary(solvers_info: dict, var: ProblemVariables, cell: BatteryCell, mesher: BaseMesher, W: BlockFunctionSpace, problem)[source]
This method iterates over the active models to build the weak formulation of the stationary problem.
- Parameters:
solvers_info (dict) – Dictionary containing solvers information
var (ProblemVariables) – Object that store the preprocessed problem variables.
cell (BatteryCell) – Object where cell parameters are preprocessed and stored.
mesher (BaseMesher) – Object that store the mesh information.
W (BlockFunctionSpace) – Object that store the function space of each state variable.
problem (Problem) – Object that handles the battery cell simulation.
- Returns:
Object containing the integral forms of each equation, as well as the dirichlet boundary conditions, that corresponds to each state variable.
- Return type:
- build_weak_formulation_transitory(solvers_info, var: ProblemVariables, cell: BatteryCell, mesher: BaseMesher, W: BlockFunctionSpace, problem)[source]
This method iterates over the active models to build the weak formulation of the transitory problem.
- Parameters:
solvers_info (dict) – Dictionary containing solvers information
var (ProblemVariables) – Object that store the preprocessed problem variables.
cell (BatteryCell) – Object where cell parameters are preprocessed and stored.
mesher (BaseMesher) – Object that store the mesh information.
W (BlockFunctionSpace) – Object that store the function space of each state variable.
problem (Problem) – Object that handles the battery cell simulation.
- Returns:
Object containing the integral forms of each equation, as well as the dirichlet boundary conditions, that corresponds to each state variable.
- Return type:
- compute_cell_properties(cell: BatteryCell)[source]
This method iterates over the active models to compute the general cell properties.
- Parameters:
cell (BatteryCell) – Object where cell parameters are preprocessed and stored.
Notes
This method is called once the cell parameters has been preprocessed.
- compute_reference_cell_properties(cell: CellParser) None[source]
This method iterates over the active models to compute the general reference cell properties.
- Parameters:
cell (CellParser) – Parser of the cell dictionary.
Notes
This method is called once the cell parameters has been parsed.
- explicit_update(problem) None[source]
This method iterates over the active models to update the active explicit models once the implicit timestep is performed.
- Parameters:
problem (Problem) – Object that handles the battery cell simulation.
- get_cell_state(problem) OrderedDict[source]
This method iterates over the active models to get the current state of the cell.
- Parameters:
problem (Problem) – Object that handles the battery cell simulation.
kwargs (dict) – Dictionary containing the parameters that describe the cell state. To know more type
cideMOD.info( 'get_cell_state', model_options=model_options)()
- get_outputs_info(warehouse: Warehouse) None[source]
This method iterates over the active models to return a dictionary containing the information of both the global and internal variables that can be outputed by the models.
- Parameters:
warehouse (Warehouse) – Object that postprocess, store and write the outputs.
- get_solvers_info(problem) dict[source]
This method iterates over the active models to get the solvers information.
- Parameters:
problem (Problem) – Object that handles the battery cell simulation.
- Returns:
Returns a dictionary containing solvers information
- Return type:
dict
- initial_guess(f: BlockFunction, var: ProblemVariables, cell: BatteryCell, problem)[source]
This method iterates over the active models to initialize the state variables based on the initial conditions and assuming that the simulation begins after a stationary state.
- Parameters:
f (BlockFunction) – Block function that contain the state variables to be initialized.
var (ProblemVariables) – Object that store the preprocessed problem variables.
cell (BatteryCell) – Object where cell parameters are preprocessed and stored.
problem (Problem) – Object that handles the battery cell simulation.
- parse_cell_structure(cell) None[source]
This method iterates over the active models to parse the cell structure.
- Parameters:
cell (CellParser) – Parser of the cell dictionary.
- parse_component_parameters(component) None[source]
This method iterates over the active models to parse the parameters of the given component.
- Parameters:
component (BaseComponentParser) – Object that parses the component parameters.
- prepare_outputs(warehouse: Warehouse, var: ProblemVariables, cell: BatteryCell, mesher: BaseMesher, DA: DimensionalAnalysis, problem) None[source]
This method iterates over the active models to compute the expression of the requested internal variables to be ready for being evaluated and stored.
- Parameters:
warehouse (Warehouse) – Object that postprocess, store and write the outputs.
var (ProblemVariables) – Object containing the problem variables.
cell (BatteryCell) – Object where cell parameters are preprocessed and stored.
mesher (BaseMesher) – Object that store the mesh information.
DA (DimensionalAnalysis) – Object where the dimensional analysis is performed.
problem (Problem) – Object that handles the battery cell simulation.
- reset(problem, new_parameters=None, deep_reset=False) None[source]
This method iterates over the active models to reset the problem variables in order to be ready for running another simulation with the same initial conditions, and maybe using different parameters.
- Parameters:
problem (Problem) – Object that handles the battery cell simulation.
new_parameters (Dict[str, float], optional) – Dictionary containing the cell parameters that have already been updated.
deep_reset (bool, optional) – Whether or not a deep reset will be performed. It means that the Problem setup stage will be run again as the mesh has been changed. Default to False.
- scale_variable(name: str, value)[source]
This method scales the given variable.
- Parameters:
name (str) – Name of the variable to be scaled.
value (Any) – Value to be scaled.
- Returns:
Scaled value of the variable.
- Return type:
Any
Examples
>>> models.scale_variable('c_e', 1000) 0
- scale_variables(variables: dict)[source]
This method scales the given variables.
- Parameters:
variables (Dict[str, Any]) – Dictionary containing the names and the values of the variables to be scaled.
- Returns:
Dictionary containing the scaled variables.
- Return type:
dict
Examples
>>> variables = {'c_e': 1000, 'c_s_a': 28700} >>> models.scale_variables(variables) {'c_e': 0, 'c_s_a': 1}
- set_cell_state(problem, **kwargs) None[source]
This method iterates over the active models to set the current state of the cell.
- Parameters:
problem (Problem) – Object that handles the battery cell simulation.
kwargs (dict) – Dictionary containing the parameters that describe the cell state. To know more type
cideMOD.info( 'set_cell_state', model_options=model_options)()
- set_component_parameters(component, problem)[source]
This method iterates over the active models to preprocess the component parameters.
- Parameters:
component (BaseCellComponent) – Object where component parameters are preprocessed and stored.
problem (Problem) – Object that handles the battery cell simulation.
- set_dependent_variables(var: ProblemVariables, cell: BatteryCell, DT: TimeScheme, problem) None[source]
This method iterates over the active models to set the dependent variables.
- Parameters:
var (ProblemVariables) – Object that store the preprocessed problem variables.
cell (BatteryCell) – Object where cell parameters are preprocessed and stored.
DT (TimeScheme) – Object that provide the temporal derivatives with the specified scheme.
problem (Problem) – Object that handles the battery cell simulation.
- set_problem_variables(var: ProblemVariables, DT: TimeScheme, problem) None[source]
This method iterates over the active models to set the problem variables.
- Parameters:
var (ProblemVariables) – Object that store the preprocessed problem variables.
DT (TimeScheme) – Object that provide the temporal derivatives with the specified scheme.
problem (Problem) – Object that handles the battery cell simulation.
- set_state_variables(mesher, V, V_vec, problem) list[source]
This method iterates over the active models to set the state variables.
- Parameters:
mesher (BaseMesher) – Object that contains the mesh information.
V (dolfinx.fem.FunctionSpace) – Common FunctionSpace to be used for each model.
V_vec (dolfinx.fem.VectorFunctionSpace) – Common VectorFunctionSpace to be used for each model.
problem (Problem) – Object that handles the battery cell simulation.
- Returns:
Returns a list of tuples, each one containing the name, the subdomain and the function space of the state variable.
- Return type:
List(Tuple(str, numpy.ndarray, dolfinx.fem.FunctionSpace))
- setup(problem)[source]
This method iterates over the active models to setup the models if needed.
- Parameters:
problem (Problem) – Object that handles the battery cell simulation.
- unscale_variable(name: str, value)[source]
This method unscales the given variable.
- Parameters:
name (str) – Name of the variable to be unscaled.
value (Any) – Value to be unscaled.
- Returns:
Unscaled value of the variable.
- Return type:
Any
Examples
>>> models.unscale_variable('c_e', 0) 1000
- unscale_variables(variables: dict)[source]
This method unscales the given variables.
- Parameters:
variables (Dict[str, Any]) – Dictionary containing the names and the values of the variables to be unscaled.
- Returns:
Dictionary containing the unscaled variables.
- Return type:
dict
Examples
>>> variables = {'c_e': 0, 'c_s_a': 1} >>> models.unscale_variables(variables) {'c_e': 1000, 'c_s_a': 28700}
- update_control_variables(var: ProblemVariables, problem, **kwargs) None[source]
This method iterates over the active models to update the control variables of the problem.
- Parameters:
var (ProblemVariables) – Object that store the preprocessed problem variables.
problem (Problem) – Object that handles the battery cell simulation.
kwargs (dict) – Dictionary containing the control variables.
- update_reference_values(updated_values: dict, cell: CellParser, problem=None) None[source]
This method iterates over the active models to update the reference cell properties.
- Parameters:
updated_values (Dict[str, float]) – Dictionary containing the cell parameters that have already been updated.
cell (CellParser) – Parser of the cell dictionary.
problem (Problem, optional) – Object that handles the battery cell simulation.
Notes
This method is called each time a set of dynamic parameters have been updated. If problem is not given, then it is assumed that it have not been already defined.