cideMOD.main
This module is the core of cideMOD. Contain the class for handling battery cell simulations
Classes
|
Class for handling battery cell simulations. |
- class cideMOD.main.Problem(cell: CellParser, model_options: BaseModelOptions)[source]
Bases:
objectClass for handling battery cell simulations.
- Parameters:
cell (CellParser) – Parser of the cell dictionary.
model_options (ModelOptions) – Model options already configured by the user.
- add_global_variables(name: str | List[str])[source]
This method add the requested variable to the list of requested global variables to be compute throughout the simulation.
- name: Union[str, List[str]]
Name/s of the requested global variable/s. It should be provided by the active models.
- add_internal_variables(name: str | List[str])[source]
This method add the requested variable to the list of requested internal variables to be compute throughout the simulation.
- name: Union[str, List[str]]
Name/s of the requested global variable/s. It should be provided by the active models.
- get_avg(variable, domain: ufl.Measure | str, integral_type='x')[source]
Get the average of the variable over the given subdomain or surface
- Parameters:
variable (Union[ufl.Integral, ufl.Operator, dolfinx.Function]) – Expression of the variable to be averaged
domain (Union[Measure, str]) – Measure or tag of the domain to integrate over
integral_type (str) – Integral type. Only used if domain is a string. Available options: ‘x’, ‘s’ and ‘S’
- Returns:
Averaged variable over the given subdomain or surface
- Return type:
float
- get_global_variable(name: str)[source]
Get the values of a global variable over the timesteps
- Parameters:
name (str) – Name of the global variable
- Returns:
List of values
- Return type:
list
- reset(new_parameters: dict | None = None, triggers: List[Trigger] | None = None, save_path: str | None = None, save_config=True, prefix='results_')[source]
This method resets the problem in order to be ready for running another simulation with the same initial conditions, and maybe using different parameters.
- Parameters:
new_parameters (Dict[str, float], optional) – Dictionary containing the cell parameters to be updated.
triggers (List[Triggers]) – List containing the triggers that should be reset.
save_path (str, optional) – Path to the new results folder.
save_config – Whether to save the parameter and simulation options to the results folder. Defaults to True.
Notes
This method is used to avoid the generation of multiple Problem objects when running multiple simulations, for example when performing optimizations.
- set_boundary_condition(bc)[source]
This method set the given boundary condition.
- Parameters:
bc (BaseBoundaryCondition) – Object that contain the required information to set the new boundary condition.
- set_cell_state(**kwargs)[source]
This method set the current state of the cell.
- Parameters:
kwargs (dict) – Dictionary containing the parameters that describe the cell state. To know more type
cideMOD.info( 'set_cell_state', model_options=model_options)()
- setup()[source]
Set-up the Problem object: - Build the FEM function spaces - Build the cell properties - Set-up internal state variables - Set-up Warehouse object - Build the variational formulation
- solve(t_f=3600, store_delay=1, min_step=0.01, triggers: List[Trigger] = [], adaptive: bool = False, **kwargs)[source]
- solve(t_f=3600, store_delay=1, initial_step=None, max_step=3600, min_step=0.01, triggers: List[Trigger] = [], adaptive: bool = True, time_adaptive_tol=0.01, **kwargs)
Perform a simulation step. For more complex inputs it is recommended to use several calls to this method.
- Parameters:
t_f (float, optional) – The maximum duration of the simulation. Defaults to 3600.
store_delay (int, optional) – The delay to apply between consecutive saves of the internal variables, in number of timesteps. Defaults to 1.
initial_step (float, optional) – Initial timestep length. If not given, the timestep chose is the minimum. Default to None.
max_step (float, optional) – Maximum timestep length for adaptive solver in seconds. Default to 3600.
min_step (float, optional) – Minimum timestep length for adaptive solver in seconds. Default to 0.01.
triggers (list, optional) – List of Triggers to check during runtime. Default to [].
adaptive (bool, optional) – Whether to use adaptive timestepping or not. Default to True.
time_adaptive_tol (Union[float,int]) – Tolerance of the time-adaptive scheme. Defaults to 1e-2.
kwargs (dict) – Control variables of the problem. Could be constant or a time-dependent expression. To know the required control variables type problem.print_control_variables_info().
- Returns:
The status of the simulation. If there is an error, the Exception object is returned. Otherwise return 0.
- Return type:
Union[int, Exception]
- update_dynamic_parameters(dynamic_parameters)[source]
This method updates the values of the dynamic parameters of the cell and the components it has.
- Parameters:
dynamic_parameters (dict) – Dictionary containing the dynamic parameter names and values to be updated.
Notes
To update a dynamic parameter of the cell:
>>> problem.update_dynamic_parameters({'area': 0.1})
or
>>> problem.update_dynamic_parameters({'cell.area': 0.1})
To update a dynamic parameter of a cell component:
>>> problem.update_dynamic_parameters({'anode.thickness': 1e-4})