pybamm.
Discretisation
(mesh=None, spatial_methods=None)[source]¶The discretisation class, with methods to process a model and replace Spatial Operators with Matrices and Variables with StateVectors
Parameters: |
|
---|
check_model
(model)[source]¶Perform some basic checks to make sure the discretised model makes sense.
check_tab_conditions
(symbol, bcs)[source]¶Check any boundary conditions applied on “negative tab”, “positive tab” and “no tab”. For 1D current collector meshes, these conditions are converted into boundary conditions on “left” (tab at z=0) or “right” (tab at z=l_z) depending on the tab location stored in the mesh. For 2D current collector meshes, the boundary conditions can be applied on the tabs directly.
Parameters: |
|
---|---|
Returns: | The dictionary of boundary conditions, with the keys changed to “left” and “right” where necessary. |
Return type: |
check_variables
(model)[source]¶Check variables in variable list against rhs Be lenient with size check if the variable in model.variables is broadcasted, or a concatenation, or an outer product (if broadcasted, variable is a multiplication with a vector of ones)
create_mass_matrix
(model)[source]¶Creates mass matrix of the discretised model. Note that the model is assumed to be of the form M*y_dot = f(t,y), where M is the (possibly singular) mass matrix.
Parameters: | model (pybamm.BaseModel ) – Discretised model. Must have attributes rhs, initial_conditions and
boundary_conditions (all dicts of {variable: equation}) |
---|---|
Returns: | The mass matrix |
Return type: | pybamm.Matrix |
process_boundary_conditions
(model)[source]¶Discretise model boundary_conditions, also converting keys to ids
Parameters: | model (pybamm.BaseModel ) – Model to dicretise. Must have attributes rhs, initial_conditions and
boundary_conditions (all dicts of {variable: equation}) |
---|---|
Returns: | Dictionary of processed boundary conditions |
Return type: | dict |
process_dict
(var_eqn_dict)[source]¶Discretise a dictionary of {variable: equation}, broadcasting if necessary (can be model.rhs, model.initial_conditions or model.variables).
Parameters: | var_eqn_dict (dict) – Equations ({variable: equation} dict) to dicretise (can be model.rhs, model.initial_conditions or model.variables) |
---|---|
Returns: | new_var_eqn_dict – Discretised equations |
Return type: | dict |
process_initial_conditions
(model)[source]¶Discretise model initial_conditions.
Parameters: | model (pybamm.BaseModel ) – Model to dicretise. Must have attributes rhs, initial_conditions and
boundary_conditions (all dicts of {variable: equation}) |
---|---|
Returns: | Tuple of processed_initial_conditions (dict of initial conditions) and concatenated_initial_conditions (numpy array of concatenated initial conditions) |
Return type: | tuple |
process_model
(model, inplace=True)[source]¶Discretise a model. Currently inplace, could be changed to return a new model.
Parameters: |
|
---|---|
Returns: | model_disc – The discretised model. Note that if |
Return type: | |
Raises: |
|
process_rhs_and_algebraic
(model)[source]¶Discretise model equations - differential (‘rhs’) and algebraic.
Parameters: | model (pybamm.BaseModel ) – Model to dicretise. Must have attributes rhs, initial_conditions and
boundary_conditions (all dicts of {variable: equation}) |
---|---|
Returns: | Tuple of processed_rhs (dict of processed differential equations), processed_concatenated_rhs, processed_algebraic (dict of processed algebraic equations) and processed_concatenated_algebraic |
Return type: | tuple |
process_symbol
(symbol)[source]¶Discretise operators in model equations. If a symbol has already been discretised, the stored value is returned.
Parameters: | symbol (pybamm.expression_tree.symbol.Symbol ) – Symbol to discretise |
---|---|
Returns: | Discretised symbol |
Return type: | pybamm.expression_tree.symbol.Symbol |