Skip to content

Commit

Permalink
deploy: 0497f91
Browse files Browse the repository at this point in the history
  • Loading branch information
xavierr committed Dec 20, 2024
1 parent 5a06619 commit c4fb307
Show file tree
Hide file tree
Showing 105 changed files with 5,009 additions and 1,790 deletions.
Binary file modified _images/runBatteryP2D_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed _images/runElectrolyser_02.png
Binary file not shown.
Binary file modified _images/runGasSupply_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/runGasSupply_02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/runGasSupply_03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/runGasSupply_04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/runGasSupply_05.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/runGasSupply_06.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/runGasSupply_07.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/runGasSupply_08.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/runGasSupply_09.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/runProtonicCell_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/runProtonicCell_02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/runProtonicCell_03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/runProtonicCell_04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/runProtonicCell_05.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/runProtonicCell_06.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/runProtonicCell_07.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/runProtonicCell_08.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/runProtonicCell_09.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/runProtonicCell_10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/runProtonicCell_11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/runProtonicCell_12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/runProtonicCell_13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/runProtonicMembrane_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _images/runProtonicMembrane_02.png
Binary file modified _images/runProtonicMembrane_03.png
Binary file modified _images/runProtonicMembrane_04.png
Binary file modified _images/runProtonicMembrane_05.png
Binary file modified _images/runProtonicMembrane_06.png
Binary file modified _images/runProtonicMembrane_07.png
3 changes: 1 addition & 2 deletions _sources/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
advancedtopics
juliabridge
Electrolyser simulation <publishedExamples/runElectrolyser>
Protonic Membrane <publishedExamples/runProtonicMembrane>
Gas Supply <publishedExamples/runGasSupply>
protonicmembrane
app
Computational Graph <computationalGraph/graphdoc>
seealso
Expand Down
30 changes: 30 additions & 0 deletions _sources/protonicmembrane.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
=================
Protonic Membrane
=================

.. toctree::
:hidden:

Protonic Membrane <publishedExamples/runProtonicMembrane>
Gas Supply <publishedExamples/runGasSupply>
Full Cell <publishedExamples/runProtonicCell>

We consider the model of a mixed proton and electron conducting membrane, as described in :cite:`V_llestad_2019` from 2019.

.. grid:: 1

.. grid-item-card::
:padding: 2

:ref:`Protonic Membrane <runProtonicMembrane>`

.. grid-item-card::
:padding: 2

:ref:`Gas Supply Layer <runGasSupply>`

.. grid-item-card::
:padding: 2

:ref:`Full Cell <runProtonicCell>`

40 changes: 14 additions & 26 deletions _sources/publishedExamples/battMoTutorial.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ BattMo uses functionality from :mod:`MRST <MRSTBattMo>`. This functionality is c
Specifying the physical model
=============================
In this tutorial we will simulate a lithium-ion battery consisting of a negative electrode, a positive electrode and an electrolyte. BattMo comes with some pre-defined models which can be loaded from JSON files. Here we will load the basic lithium-ion model JSON file which comes with Battmo. We use :battmo:`parseBattmoJson` to parse the file, see :todo:`add link to doc`
In this tutorial we will simulate a lithium-ion battery consisting of a negative electrode, a positive electrode and an electrolyte. BattMo comes with some pre-defined models which can be loaded from JSON files. Here we will load the basic lithium-ion model JSON file which comes with Battmo. We use :battmo:`parseBattmoJson` to parse the file.

.. code-block:: matlab
Expand Down Expand Up @@ -75,22 +75,22 @@ Now we can set the diffusion model type for the active material (am) in the posi
jsonstruct.(pe).(am).diffusionModelType = 'full';
jsonstruct.(ne).(am).diffusionModelType = 'full';
To see which other types of diffusion model are available one can view :battmo:`ActiveMaterialInputParams`. When running a simulation, BattMo requires that all model parameters are stored in an instance of :battmo:`BatteryInputParams`. This class is used to initialize the simulation and is accessed by various parts of the simulator during the simulation. This class is instantiated using the jsonstruct we just created:
To see which other types of diffusion model are available one can view :battmo:`ActiveMaterialInputParams`. When running a simulation, BattMo requires that all model parameters are stored in an instance of :battmo:`BatteryInputParams`. This class is used to initialize the simulation and is accessed by various parts of the simulator during the simulation. This class is instantiated using the jsonstruct we just created:

.. code-block:: matlab
paramobj = BatteryInputParams(jsonstruct);
inputparams = BatteryInputParams(jsonstruct);
It is also possible to update the properties of this paramobj in a similar way to updating the jsonstruct. Here we set the discretisation level for the diffusion model. Other input parameters for the full diffusion model can be found here: :battmo:`FullSolidDiffusionModelInputParams`.
It is also possible to update the properties of this inputparams in a similar way to updating the jsonstruct. Here we set the discretisation level for the diffusion model. Other input parameters for the full diffusion model can be found here: :battmo:`FullSolidDiffusionModelInputParams`.

.. code-block:: matlab
paramobj.(ne).(co).(am).(sd).N = 5;
paramobj.(pe).(co).(am).(sd).N = 5;
inputparams.(ne).(co).(am).(sd).N = 5;
inputparams.(pe).(co).(am).(sd).N = 5;
% We can also change how the battery is operated, for example setting
% the cut off voltage.
paramobj.(ctrl).lowerCutoffVoltage = 2.5;
inputparams.(ctrl).lowerCutoffVoltage = 2.5;
Setting up the geometry
Expand All @@ -101,21 +101,21 @@ Here, we setup the 1D computational grid that will be used for the simulation. T
gen = BatteryGeneratorP2D();
Now, we update the paramobj with the properties of the grid. This function will update relevent parameters in the paramobj object and make sure we have all the required parameters for the model geometry chosen.
Now, we update the inputparams with the properties of the grid. This function will update relevent parameters in the inputparams object and make sure we have all the required parameters for the model geometry chosen.

.. code-block:: matlab
paramobj = gen.updateBatteryInputParams(paramobj);
inputparams = gen.updateBatteryInputParams(inputparams);
Initialising the battery model object
=====================================
The battery model is initialized by sending paramobj to the Battery class constructor. see :battmo:`Battery`.
The battery model is initialized by sending inputparams to the Battery class constructor. see :battmo:`Battery`.
In BattMo a battery model is actually a collection of submodels: Electrolyte, Negative Electrode, Positive Electrode, Thermal Model and Control Model. The battery class contains all of these submodels and various other parameters necessary to run the simulation.

.. code-block:: matlab
model = Battery(paramobj);
model = Battery(inputparams);
Plotting the OCP curves against state of charge
Expand Down Expand Up @@ -158,22 +158,11 @@ We can inspect the model object to find out which parameters are being used. For
Controlling the simulation
==========================
The control model specifies how the battery is operated, i.e., how the simulation is controlled.
In the first instance we use CCDischarge control policy. We set the total time scaled by the CRate in the model. The CRate has been set by the json file. We can access it here:
The input parameters for the control have been given as part of the json structure :battmofile:`ParameterData/BatteryCellParameters/LithiumIonBatteryCell/lithium_ion_battery_nmc_graphite.json`. The total simulation time is setup for us, computed from the DRate value. We use the method :code:`setupScheduleStep` in :battmo:`ControlModel` to setup the :code:`step` structure.

.. code-block:: matlab
CRate = model.Control.CRate;
total = 1.1*hour/CRate;
We want to break this total time into 100 timesteps. To begin with we will use equal values for each timestep.
We create a structure containing the length of each step in seconds ('val') and also which control to use for each step ('control').
In this case we use control 1 for all steps. This means that the functions used to setup the control values are the same at each step.

.. code-block:: matlab
n = 100;
dt = total/n;
step = struct('val', dt*ones(n, 1), 'control', ones(n, 1));
step = model.Control.setupScheduleStep();
We create a control structure containing the source function and and a stopping criteria. The control parameters have been given in the json file :battmofile:`ParameterData/BatteryCellParameters/LithiumIonBatteryCell/lithium_ion_battery_nmc_graphite.json`
The :code:`setupScheduleControl` method contains the code to setup the control structure that is used in the schedule structure setup below.
Expand Down Expand Up @@ -201,7 +190,7 @@ To run simulation we need to know the starting point which we will run it from,
Running the simulation
======================
Once we have the initial state, the model and the schedule, we can call the simulateScheduleAD function which will actually run the simulation.
The outputs from the simulation are: - sols: which provides the current and voltage of the battery at each timestep. - states: which contains the values of the primary variables in the model at each timestep. - reports: which contains technical information about the steps used in the numerical solvers.
The outputs from the simulation are: - sols: which provides the current and voltage of the battery at each timestep. - states: which contains the values of the primary variables in the model at each timestep. - reports: which contains technical information about the steps used in the numerical solvers.

.. code-block:: matlab
Expand All @@ -227,7 +216,6 @@ To get the results we use the matlab cellfun function to extract the values Cont
subplot(1,2,2)
plot(time/hour, I)
ylim([0, 0.02])
xlabel('time / h')
ylabel('Cell Current / A')
Expand Down
56 changes: 20 additions & 36 deletions _sources/publishedExamples/battMoTutorial_source.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Source code for battMoTutorial
% negative electrode, a positive electrode and an electrolyte. *BattMo*
% comes with some pre-defined models which can be loaded from JSON files.
% Here we will load the basic lithium-ion model JSON file which comes with
% Battmo. We use :battmo:`parseBattmoJson` to parse the file, see :todo:`add link to doc`
% Battmo. We use :battmo:`parseBattmoJson` to parse the file.
fname = fullfile('ParameterData','BatteryCellParameters',...
'LithiumIonBatteryCell','lithium_ion_battery_nmc_graphite.json');
Expand Down Expand Up @@ -86,21 +86,21 @@ Source code for battMoTutorial
% various parts of the simulator during the simulation. This class is
% instantiated using the jsonstruct we just created:
paramobj = BatteryInputParams(jsonstruct);
inputparams = BatteryInputParams(jsonstruct);
%%
% It is also possible to update the properties of this paramobj in a
% It is also possible to update the properties of this inputparams in a
% similar way to updating the jsonstruct. Here we set the discretisation
% level for the diffusion model. Other input parameters for the full diffusion
% model can be found here:
% :battmo:`FullSolidDiffusionModelInputParams`.
paramobj.(ne).(co).(am).(sd).N = 5;
paramobj.(pe).(co).(am).(sd).N = 5;
inputparams.(ne).(co).(am).(sd).N = 5;
inputparams.(pe).(co).(am).(sd).N = 5;
% We can also change how the battery is operated, for example setting
% the cut off voltage.
paramobj.(ctrl).lowerCutoffVoltage = 2.5;
inputparams.(ctrl).lowerCutoffVoltage = 2.5;
%% Setting up the geometry
% Here, we setup the 1D computational grid that will be used for the
Expand All @@ -111,22 +111,22 @@ Source code for battMoTutorial
gen = BatteryGeneratorP2D();
%%
% Now, we update the paramobj with the properties of the grid. This function
% will update relevent parameters in the paramobj object and make sure we have
% Now, we update the inputparams with the properties of the grid. This function
% will update relevent parameters in the inputparams object and make sure we have
% all the required parameters for the model geometry chosen.
paramobj = gen.updateBatteryInputParams(paramobj);
inputparams = gen.updateBatteryInputParams(inputparams);
%% Initialising the battery model object
% The battery model is initialized by sending paramobj to the Battery class
% The battery model is initialized by sending inputparams to the Battery class
% constructor. see :battmo:`Battery`.
%
% In BattMo a battery model is actually a collection of submodels:
% Electrolyte, Negative Electrode, Positive Electrode, Thermal Model and Control
% Model. The battery class contains all of these submodels and various other
% parameters necessary to run the simulation.
model = Battery(paramobj);
model = Battery(inputparams);
%% Plotting the OCP curves against state of charge
% We can inspect the model object to find out which parameters are being
Expand Down Expand Up @@ -162,36 +162,22 @@ Source code for battMoTutorial
legend(eldes, 'location', 'nw')
%% Controlling the simulation
% The control model specifies how the battery is operated, i.e., how
% the simulation is controlled.
% The control model specifies how the battery is operated, i.e., how the simulation is controlled.
%
% In the first instance we use CCDischarge control policy.
% We set the total time scaled by the CRate in the model.
% The CRate has been set by the json file. We can access it here:
% The input parameters for the control have been given as part of the json structure
% :battmofile:`ParameterData/BatteryCellParameters/LithiumIonBatteryCell/lithium_ion_battery_nmc_graphite.json`. The
% total simulation time is setup for us, computed from the DRate value. We use the method :code:`setupScheduleStep` in
% :battmo:`ControlModel` to setup the :code:`step` structure.
CRate = model.Control.CRate;
total = 1.1*hour/CRate;
%%
% We want to break this total time into 100 timesteps. To begin with we
% will use equal values for each timestep.
%
% We create a structure containing the length of each step in seconds
% ('val') and also which control to use for each step ('control').
%
% In this case we use control 1 for all steps. This means that the functions
% used to setup the control values are the same at each step.
n = 100;
dt = total/n;
step = struct('val', dt*ones(n, 1), 'control', ones(n, 1));
step = model.Control.setupScheduleStep();
%%
% We create a control structure containing the source function and
% and a stopping criteria. The control parameters have been given in the json file
% :battmofile:`ParameterData/BatteryCellParameters/LithiumIonBatteryCell/lithium_ion_battery_nmc_graphite.json`
%
% The :code:`setupScheduleControl` method contains the code to setup the control structure that is used in the schedule structure setup below.
% The :code:`setupScheduleControl` method contains the code to setup the control structure that is used in the schedule
% structure setup below.
control = model.Control.setupScheduleControl();
Expand All @@ -212,7 +198,6 @@ Source code for battMoTutorial
initstate = model.setupInitialState();
%% Running the simulation
% Once we have the initial state, the model and the schedule, we can call
% the simulateScheduleAD function which will actually run the simulation.
Expand Down Expand Up @@ -246,13 +231,12 @@ Source code for battMoTutorial
subplot(1,2,2)
plot(time/hour, I)
ylim([0, 0.02])
xlabel('time / h')
ylabel('Cell Current / A')
%{
Copyright 2021-2023 SINTEF Industry, Sustainable Energy Technology
Copyright 2021-2024 SINTEF Industry, Sustainable Energy Technology
and SINTEF Digital, Mathematics & Cybernetics.
This file is part of The Battery Modeling Toolbox BattMo
Expand Down
Loading

0 comments on commit c4fb307

Please sign in to comment.