High level interface
Input types
BattMo.AbstractInput Type
AbstractInput
Abstract type for all parameter sets that can be given as an input to BattMo.
For any structure of this type, it is possible to access and set the values of the object using the same syntax as a standard Julia dictionary.
sourceBattMo.CyclingProtocol Type
Parameter set type that represents the cycling protocol related parameters
sourceBattMo.SimulationSettings Type
Parameter set type that represents the simulation related settings
sourceBattMo.BattMoFormattedInput Type
abstract type BattMoFormattedInput <: AbstractInput
Abstract type representing input parameters formatted for BattMo. This type is used exclusively in the backend as an input to the simulation. Subtypes of BattMoFormattedInput
contain parameter dictionaries structured for BattMo compatibility.
BattMo.InputParams Type
struct InputParams <: BattMoFormattedInput
Represents a validated and backend-formatted set of input parameters for a BattMo simulation.
Fields
data ::Dict{String, Any}
: A dictionary storing the input parameters for BattMo.
BattMo.MatlabInputParams Type
struct MatlabInputParams <: BattMoFormattedInput
Represents input parameters derived from MATLAB-generated files, formatted for BattMo compatibility.
Fields
data ::Dict{String, Any}
: A dictionary storing MATLAB-extracted input parameters.
Read input
BattMo.load_cell_parameters Function
load_cell_parameters(; from_file_path::String = nothing, from_default_set::String = nothing, from_model_template::BatteryModelSetup = nothing)
Reads and loads cell parameters either from a JSON file, a default set, or a model template.
Arguments
from_file_path ::String
: (Optional) Path to the JSON file containing cell parameters.from_default_set ::String
: (Optional) The name of the default set to load cell parameters from.from_model_template ::BatteryModelSetup
: (Optional) ABatteryModelSetup
instance used to load an empty set of cell parameters required for the concerning model.
Returns
An instance of CellParameters
.
Errors
Throws an ArgumentError
if none of the arguments are provided.
BattMo.load_cycling_protocol Function
load_cycling_protocol(; from_file_path::String = nothing, from_default_set::String = nothing)
Reads and loads cycling protocol either from a JSON file or a default set.
Arguments
from_file_path ::String
: (Optional) Path to the JSON file containing cycling protocol.from_default_set ::String
: (Optional) The name of the default set to load cycling protocol from.
Returns
An instance of CyclingProtocol
.
Errors
Throws an ArgumentError
if neither from_file_path
nor from_default_set
is provided.
BattMo.load_model_settings Function
load_model_settings(; from_file_path::String = nothing, from_default_set::String = nothing)
Reads and loads model settings either from a JSON file or a default set.
Arguments
from_file_path ::String
: (Optional) Path to the JSON file containing model settings.from_default_set ::String
: (Optional) The name of the default set to load model settings from.
Returns
An instance of ModelSettings
.
Errors
Throws an ArgumentError
if neither from_file_path
nor from_default_set
is provided.
BattMo.load_simulation_settings Function
load_simulation_settings(; from_file_path::String = nothing, from_default_set::String = nothing, from_model_template::BatteryModelSetup = nothing)
Reads and loads simulation settings either from a JSON file, a default set, or a model template.
Arguments
from_file_path ::String
: (Optional) Path to the JSON file containing simulation settings.from_default_set ::String
: (Optional) The name of the default set to load simulation settings from.from_model_template ::BatteryModelSetup
: (Optional) ABatteryModelSetup
instance used to load an empty set of simulation settings required for the concerning model.
Returns
An instance of SimulationSettings
.
Errors
Throws an ArgumentError
if none of the arguments are provided.
BattMo.load_battmo_formatted_input Function
load_battmo_formatted_input(filepath::String)
Reads and parses a JSON file into an InputParams
instance.
Arguments
filepath ::String
: Path to the JSON file.
Returns
An instance of InputParams
.
BattMo.load_matlab_battmo_input Function
load_matlab_battmo_input(inputFileName::String)
Reads the input from a MATLAB output file which contains a description of the model and returns an MatlabInputParams
that can be sent to the simulator.
Arguments
inputFileName ::String
: Path to the MATLAB file.
Returns
An instance of MatlabInputParams
that can be sent to the simulator via run_battery
.
Battery model types
BattMo.BatteryModelSetup Type
abstract type BatteryModelSetup
Abstract type representing a battery model. All battery models should inherit from this type.
sourceBattMo.LithiumIonBattery Type
struct LithiumIonBattery <: BatteryModelSetup
Represents a lithium-ion battery model based on the Doyle-Fuller-Newman approach.
Fields
name ::String
: A descriptive name for the model.model_settings ::ModelSettings
: Settings specific to the model.
Constructor
LithiumIonBattery(; model_settings = get_default_model_settings(LithiumIonBattery))
Creates an instance of LithiumIonBattery
with the specified or default model settings. The model name is automatically generated based on the model geometry.
Forward simulation
BattMo.Simulation Type
struct Simulation <: SolvingProblem
Represents a battery simulation problem to be solved.
Fields
function_to_solve ::Function
: The function responsible for running the simulation.model ::BatteryModelSetup
: The battery model being simulated.cell_parameters ::CellParameters
: The cell parameters for the simulation.cycling_protocol ::CyclingProtocol
: The cycling protocol used.simulation_settings ::SimulationSettings
: The simulation settings applied.is_valid ::Bool
: A flag indicating if the simulation is valid.
Constructor
Simulation(model::BatteryModelSetup, cell_parameters::CellParameters, cycling_protocol::CyclingProtocol; simulation_settings::SimulationSettings = get_default_simulation_settings(model))
Creates an instance of Simulation
, initializing it with the given parameters and defaulting simulation settings if not provided.
BattMo.solve Function
solve(problem::Simulation; hook=nothing, kwargs...)
Solves a given Simulation
problem by running the associated simulation function.
Arguments
problem ::Simulation
: The simulation problem instance.hook
(optional) : A user-defined function or callback to modify the solving process.kwargs...
: Additional keyword arguments passed to the solver.
Returns
The output of the simulation if the problem is valid.
Throws
Throws an error if the Simulation
object is not valid, prompting the user to check warnings during instantiation.
BattMo.run_battery Function
run_battery(model::BatteryModelSetup, cell_parameters::CellParameters,
cycling_protocol::CyclingProtocol, simulation_settings::SimulationSettings;
hook=nothing, kwargs...)
Runs a battery simulation using the provided model, cell parameters, cycling protocol, and simulation settings.
Arguments
model ::BatteryModelSetup
: The battery model to be used.cell_parameters ::CellParameters
: The cell parameter set.cycling_protocol ::CyclingProtocol
: The cycling protocol parameter set.simulation_settings ::SimulationSettings
: The simulation settings parameter set.hook
(optional) : A user-defined function or callback to modify the process.kwargs...
: Additional keyword arguments.
Returns
The output of the battery simulation after executing run_battery
with formatted input.
run_battery(inputparams::AbstractInputParams; hook = nothing)
Simulate a battery for a given input. The input is expected to be an instance of AbstractInputParams. Such input can be prepared from a json file using the function load_battmo_formatted_input
.