pybop.pybamm.utils#
Classes#
A shortcut for creating the PyBaMM solver recommended for optimisation. |
|
Helper class to replace all instances of one or more symbols in an expression tree |
Module Contents#
- class pybop.pybamm.utils.RecommendedSolver(output_variables: list[str] | None = None)[source]#
Bases:
pybamm.IDAKLUSolverA shortcut for creating the PyBaMM solver recommended for optimisation.
- class pybop.pybamm.utils.SymbolReplacer(symbol_replacement_map: dict[pybamm.Symbol, pybamm.Symbol], processed_symbols: dict[pybamm.Symbol, pybamm.Symbol] | None = None, process_initial_conditions: bool = True)[source]#
Helper class to replace all instances of one or more symbols in an expression tree with another symbol, as defined by the dictionary symbol_replacement_map Originally developed by pybamm: pybamm-team/pybamm
- Parameters:
symbol_replacement_map (dict {
pybamm.Symbol->pybamm.Symbol}) – Map of which symbols should be replaced by which.processed_symbols (dict {
pybamm.Symbol->pybamm.Symbol}, optional) – cached replaced symbolsprocess_initial_conditions (bool, optional) – Whether to process initial conditions, default is True
- process_boundary_conditions(model)[source]#
Process boundary conditions for a PybaMM model class Boundary conditions are dictionaries {“left”: left bc, “right”: right bc} in general, but may be imposed on the tabs (or not on the tab) for a small number of variables, e.g. {“negative tab”: neg. tab bc, “positive tab”: pos. tab bc “no tab”: no tab bc}.
- process_model(unprocessed_model, inplace=True)[source]#
Replace all instances of a symbol in a PyBaMM model class.
- Parameters:
unprocessed_model (
pybamm.BaseModel) – Model class to assign parameter values toinplace (bool, optional) – If True, replace the parameters in the model in place. Otherwise, return a new model with parameter values set (default: True).
- process_symbol(symbol)[source]#
This function recurses down the tree, replacing any symbols in self._symbol_replacement_map.keys() with their corresponding value
- Parameters:
symbol (
pybamm.Symbol) – The symbol to replace- Returns:
Symbol with all replacements performed
- Return type:
pybamm.Symbol
- _process_initial_conditions = True#
- _processed_symbols#
- _symbol_replacement_map#