Dynamic analysis III
This notebook demonstrates how to use custom experiments with the Breathe Simulate API. Custom experiments allow you to define complex cycling protocols using either text-based commands or control arrays for precise current or power control.
You can use custom experiments in several ways:
- Text-based commands: Simple string commands for basic cycling
- List-based commands: More structured approach using lists
- Current control arrays: Define precise current vs. time profiles
- Power control arrays: Define precise power vs. time profiles
- Mixed approaches: Combine arrays with text commands
In [1]:
Copied!
from breathe_simulate import api_interface as api
from breathe_simulate import enable_notebook_plotly
enable_notebook_plotly()
from breathe_simulate import api_interface as api
from breathe_simulate import enable_notebook_plotly
enable_notebook_plotly()
In [2]:
Copied!
# Set up common simulation parameters
base_battery = "Molicel P45B"
designs = []
initialSoC = 0.5
initialTemperature_degC = 25.0
ambientTemperature_degC = 25.0
heatTransferCoefficient = 20.0
# Set up common simulation parameters
base_battery = "Molicel P45B"
designs = []
initialSoC = 0.5
initialTemperature_degC = 25.0
ambientTemperature_degC = 25.0
heatTransferCoefficient = 20.0
Method 1: Text-based Custom Experiments¶
The simplest way to define a custom experiment is using a text string with newline-separated commands. Each line represents a step in the experiment.
In [3]:
Copied!
# Example 1: Simple text-based experiment
cycler_text = {
"cycle_type": "CUSTOM",
"control_parameters": {
"experiment_text": "Charge at 4.5 A until 4.2 V\nRest for 60 s\nDischarge at 4.5 A until 2.5 V",
"period": "1s",
},
}
result1 = api.run_sim(
base_battery=base_battery,
cycler=cycler_text,
designs=designs,
initialSoC=initialSoC,
initialTemperature_degC=initialTemperature_degC,
ambientTemperature_degC=ambientTemperature_degC,
heatTransferCoefficient=heatTransferCoefficient,
)
# Example 1: Simple text-based experiment
cycler_text = {
"cycle_type": "CUSTOM",
"control_parameters": {
"experiment_text": "Charge at 4.5 A until 4.2 V\nRest for 60 s\nDischarge at 4.5 A until 2.5 V",
"period": "1s",
},
}
result1 = api.run_sim(
base_battery=base_battery,
cycler=cycler_text,
designs=designs,
initialSoC=initialSoC,
initialTemperature_degC=initialTemperature_degC,
ambientTemperature_degC=ambientTemperature_degC,
heatTransferCoefficient=heatTransferCoefficient,
)
In [4]:
Copied!
result1.plot_voltage_response()
result1.plot_voltage_response()