From 8050f33253ef9626ed2e4f95a3d2ad0580d422b7 Mon Sep 17 00:00:00 2001 From: Xavier Raynaud Date: Wed, 18 Dec 2024 17:59:38 +0100 Subject: [PATCH] update in runProtonicMembrane doc --- .../publishedExamples/runProtonicMembrane.png | Bin 3113 -> 3113 bytes .../publishedExamples/runProtonicMembrane.rst | 23 +++++++--------- .../runProtonicMembranePreamble.rst | 25 ++++++++++-------- .../runProtonicMembrane_01.png | Bin 15091 -> 15091 bytes .../runProtonicMembrane_02.png | Bin 14828 -> 14828 bytes .../runProtonicMembrane_03.png | Bin 15400 -> 15400 bytes .../runProtonicMembrane_04.png | Bin 15252 -> 15252 bytes .../runProtonicMembrane_05.png | Bin 15586 -> 15586 bytes .../runProtonicMembrane_06.png | Bin 14023 -> 14023 bytes .../runProtonicMembrane_07.png | Bin 20147 -> 20147 bytes .../runProtonicMembrane_source.rst | 19 +++++++------ .../examples/runProtonicMembrane.m | 18 ++++++------- 12 files changed, 41 insertions(+), 44 deletions(-) diff --git a/Documentation/publishedExamples/runProtonicMembrane.png b/Documentation/publishedExamples/runProtonicMembrane.png index 2ced7374cbda4cd4c7ad68763cf88f430ed69761..176ae2009b38c55b560aa748e65a467efcfb89f0 100644 GIT binary patch delta 18 ZcmZ1}u~K4!F1vu0V$D$<-i;<-xdAu-1`z-N delta 18 acmZ1}u~K4!E<1;Tm0Z>T#T!k&asvQ62L{*x diff --git a/Documentation/publishedExamples/runProtonicMembrane.rst b/Documentation/publishedExamples/runProtonicMembrane.rst index 81d88e84..14e57fa8 100644 --- a/Documentation/publishedExamples/runProtonicMembrane.rst +++ b/Documentation/publishedExamples/runProtonicMembrane.rst @@ -11,7 +11,7 @@ Protonic Membrane model Load and parse input from given json files ========================================== -The source of the json files can be seen in :battmofile:`protonicMembrane` and :battmofile:`1d-PM-geometry.json` +The source of the json files can be seen in :battmofile:`protonicMembrane.json` and :battmofile:`1d-PM-geometry.json` .. code-block:: matlab @@ -31,8 +31,11 @@ We setup the input parameter structure which will we be used to instantiate the .. code-block:: matlab inputparams = ProtonicMembraneCellInputParams(jsonstruct); - - % We setup the grid, which is done by calling the function :battmo:`setupProtonicMembraneCellGrid` + +We setup the grid, which is done by calling the function :battmo:`setupProtonicMembraneCellGrid` + +.. code-block:: matlab + [inputparams, gen] = setupProtonicMembraneCellGrid(inputparams, jsonstruct); @@ -62,19 +65,13 @@ We setup the initial state using a default setup included in the model Schedule ======== -We setup the schedule, which means the timesteps and also the control we want to use. In this case we use current control and the current equal to zero (see here :battmofile:`here`). -We compute the steady-state solution so that the time stepping here is more an artifact to reach the steady-state solution. In particular, it governs the pace at which we increase the non-linearity (not detailed here). +We setup the schedule, which means the timesteps and also the control we want to use. In this case we use current control and the current equal to zero (see :battmofile:`here`). +We compute the steady-state solution and the time stepping here does not correspond to time values but should be seen as step-wise increase of the effect of the non-linearity (in particular in the expression of the conductivity which includes highly nonlineaer effect with the exponential terms. We do not detail here the method). .. code-block:: matlab schedule = model.Control.setupSchedule(inputparams.jsonstruct); -We change the default tolerance - -.. code-block:: matlab - - model.nonlinearTolerance = 1e-8; - Simulation ========== @@ -87,7 +84,7 @@ We run the simulation Plotting ======== -We setup som shortcuts for convenience +We setup som shortcuts for convenience and introduce plotting options .. code-block:: matlab @@ -105,7 +102,7 @@ We recover the position of the mesh cell of the discretization grid. This is use xc = model.(elyte).grid.cells.centroids(:, 1); -We consider the solution obtained at the last time step, which corresponds to the solution at steady-state. +We consider the solution obtained at the last time step, which corresponds to the solution at steady-state. The second line adds to the state variable all the variables that are derived from our primary unknowns. .. code-block:: matlab diff --git a/Documentation/publishedExamples/runProtonicMembranePreamble.rst b/Documentation/publishedExamples/runProtonicMembranePreamble.rst index cc6581d6..8211f74a 100644 --- a/Documentation/publishedExamples/runProtonicMembranePreamble.rst +++ b/Documentation/publishedExamples/runProtonicMembranePreamble.rst @@ -6,7 +6,9 @@ We consider the model of a mixed proton and electron conducting membrane, as des Governing equations ------------------- -We have three components given by the proton (:math:`H^+`), the :math:`p` and :math:`n` type. We want to find expressions for the fluxes for each of the components +In the membrane, we have three components or *species* given by the proton (:math:`H^+`), and the :math:`p` and :math:`n` +type charge carriers. We need expressions for the fluxes for each of those. The governing equations will then be given +by charge and mass conservation equations. We denote by :math:`\phi` the electrostatic potential. For each of the components :math:`\alpha=\{H^+, p, n\}`, we introduce the electrochemical potential denoted :math:`\bar\mu_\alpha` and the chemical potential denoted @@ -14,13 +16,13 @@ introduce the electrochemical potential denoted :math:`\bar\mu_\alpha` and the c .. math:: - \bar\mu_\alpha = \mu_\alpha + z_\alpha F \phi + \bar\mu_\alpha = \mu_\alpha + z_\alpha F \phi. The fluxes are governed by the gradient of the electrochemical potential. We have .. math:: - j_{\alpha} = -k_\alpha\nabla\bar\mu_\alpha + j_{\alpha} = -k_\alpha\nabla\bar\mu_\alpha, for some coefficient :math:`k_\alpha` which is not necessarily a constant. @@ -43,18 +45,17 @@ For the :math:`p` and :math:`n` type conductivities, we use the empirical relat \sigma_p(E) = \sigma_p^0\exp\left(\frac{F(E - E_{\text{ref},p})}{RT}\right)\quad\text{ and }\quad\sigma_n(E) = \sigma_n^0\exp\left(\frac{-F(E - E_{\text{ref},n})}{RT}\right). -Here :math:`E_{\text{ref},p}` and :math:`E_{\text{ref},n}` are two reference potentials (see below). +Here :math:`E_{\text{ref},p}` and :math:`E_{\text{ref},n}` are two reference potentials. We consider the steady state. We could introduce later charge and mass capacitors. The unknowns are the functions :math:`\phi(x)` and :math:`E(x)` in the electrolyte. The governing equations are given by the mass conservation for the proton and the charge conservation. -The mass conservation for $H^+$ is given by +The **mass conservation equation** for :math:`H^+` is given by .. math:: \nabla\cdot j_{H^+} = 0. -The current density is given by :math:`i = F (j_{H^+} + j_p - j_n)` and the \textbf{charge -conservation equation} is +The total current density is given by :math:`i = F (j_{H^+} + j_p - j_n)` and the **charge conservation equation** is .. math:: @@ -72,7 +73,8 @@ We can rewrite :math:`i_{\text{el}}` as i_{\text{el}} = - (\sigma_p(E) + \sigma_n(E))\nabla ( E + \phi ). -The governing equations for :math:`\phi(x)` and :math:`\pi(x)` are therefore the differential equations +We finally obtain the governing equations for :math:`\phi(x)` and :math:`\pi(x)` as the following system of differential +equations .. math:: @@ -91,7 +93,7 @@ We define the over-potential :math:`\eta` as \eta_\text{elde} = \pi_\text{elde} - \phi_\text{elde} - \text{OCP}_\text{elde} where :math:`\text{OCP}_\text{elde}` is the open-circuit potential for the given electrode. The value of the -$\text{OCP}$ at each electrode depend on the composition at the electrode (see :cite:`V_llestad_2019` for the expressions). +OCP at each electrode depend on the composition at the electrode (see :cite:`V_llestad_2019` for the expressions). At the anode, we imposte that the proton current is given through the following Buttler-Volmer type expression @@ -99,9 +101,10 @@ At the anode, we imposte that the proton current is given through the following i_{H^+, \text{an}} = -i_0\frac{e^{-\beta\frac{ z F \eta_{\text{an}}}{RT}} - e^{( 1- \beta)\frac{ z F \eta_{\text{an}}}{RT}}}{ 1+ \frac{i_0}{i_{l,c}}e^{-\beta\frac{ z F \eta_{\text{an}}}{RT}} - \frac{i_0}{i_{l,a}}e^{( 1- \beta)\frac{ z F \eta_{\text{an}}}{RT}}} -Here, :math:`i_{l,c}` and :math:`i_{l,a}` are given constants. The value of the reference current density $i_0$ is also constant +Here, :math:`i_{l,c}` and :math:`i_{l,a}` are given constants. The value of the reference current density :math:`i_0` is +also constant. -The total current is given by :math:`i_{\text{an}} = I` for some constant current $I$. +The total current is given by :math:`i_{\text{an}} = I` for some constant current :math:`I`. At the cathode, we impose that the electrostatic potential is equal to zero and a relation between the :math:`H^+` current and the over-potential that takes a linear form, diff --git a/Documentation/publishedExamples/runProtonicMembrane_01.png b/Documentation/publishedExamples/runProtonicMembrane_01.png index 2e128394cf423544ddb07a43dbc4b7a1cce9c9d0..1a2f4c9e03e4d44f3c1df52d7da583d437711272 100644 GIT binary patch delta 18 Zcmexd`nhz1F1vua%tU6nz>OyRtpG_y2H5}r delta 18 Zcmexd`nhz1E<1;wbX(8`rHv;0tpH7&2aW&$ diff --git a/Documentation/publishedExamples/runProtonicMembrane_02.png b/Documentation/publishedExamples/runProtonicMembrane_02.png index 16c8c44077c8332a6e1ce1b6521876a0338670b7..c8471434f581a4eef101c936bff5d359ca467596 100644 GIT binary patch delta 18 ZcmaD;{HAzOw5ECEOe2EPCR delta 18 ZcmaD;{HAz@ya<;~P!BSOWk>fCpRv delta 18 ZcmZ2cv7%yvE<1;wjD(qM<3^J&)&M@=27dqm diff --git a/Documentation/publishedExamples/runProtonicMembrane_04.png b/Documentation/publishedExamples/runProtonicMembrane_04.png index 18907a14a80e293744056ab543d947b51a08d578..23bd8e93232996e0ddc5ddfb57078d1a4781acfb 100644 GIT binary patch delta 18 ZcmbPIKBatuF1vua>@ya<;~Py9tN}rg2A%)_ delta 18 ZcmbPIKBatuE<1;wjD(qM<3^JNYXCa$1;GFS diff --git a/Documentation/publishedExamples/runProtonicMembrane_05.png b/Documentation/publishedExamples/runProtonicMembrane_05.png index 08dee5df1fb3a0027a5b5fafeed89ec362f53311..a63825a60b91a0f174925e061f39ee607a90a959 100644 GIT binary patch delta 18 acmaD<`KWS&F1vu0{N5#o%Ql*T#T!i~n*jhx3I~S( diff --git a/Documentation/publishedExamples/runProtonicMembrane_07.png b/Documentation/publishedExamples/runProtonicMembrane_07.png index 1a83cfec6563a9e595a0a478e1e3161ed2ffb50b..d55e81abffbb202820c470be7716a72348507785 100644 GIT binary patch delta 20 ccmdlymvQr4#tFLY0#=GOM|F5Nn$-IN08L#6{r~^~ delta 20 ccmdlymvQr4#tFLY90pc$RsR=nG^zIk08nKI#Q*>R diff --git a/Documentation/publishedExamples/runProtonicMembrane_source.rst b/Documentation/publishedExamples/runProtonicMembrane_source.rst index 2ef8f01b..6d0da8ce 100644 --- a/Documentation/publishedExamples/runProtonicMembrane_source.rst +++ b/Documentation/publishedExamples/runProtonicMembrane_source.rst @@ -11,7 +11,7 @@ Source code for runProtonicMembrane %% Protonic Membrane model %% Load and parse input from given json files - % The source of the json files can be seen in :battmofile:`protonicMembrane` and + % The source of the json files can be seen in :battmofile:`protonicMembrane.json` and % :battmofile:`1d-PM-geometry.json` filename = fullfile(battmoDir(), 'ProtonicMembrane', 'jsonfiles', 'protonicMembrane.json'); @@ -27,6 +27,7 @@ Source code for runProtonicMembrane inputparams = ProtonicMembraneCellInputParams(jsonstruct); + %% % We setup the grid, which is done by calling the function :battmo:`setupProtonicMembraneCellGrid` [inputparams, gen] = setupProtonicMembraneCellGrid(inputparams, jsonstruct); @@ -44,17 +45,14 @@ Source code for runProtonicMembrane %% Schedule % We setup the schedule, which means the timesteps and also the control we want to use. In this case we use current - % control and the current equal to zero (see here :battmofile:`here`). + % control and the current equal to zero (see :battmofile:`here`). % - % We compute the steady-state solution so that the time stepping here is more an artifact to reach the steady-state - % solution. In particular, it governs the pace at which we increase the non-linearity (not detailed here). + % We compute the steady-state solution and the time stepping here does not correspond to time values but should be seen + % as step-wise increase of the effect of the non-linearity (in particular in the expression of the conductivity which + % includes highly nonlineaer effect with the exponential terms. We do not detail here the method). schedule = model.Control.setupSchedule(inputparams.jsonstruct); - %% - % We change the default tolerance - model.nonlinearTolerance = 1e-8; - %% Simulation % We run the simulation @@ -64,7 +62,7 @@ Source code for runProtonicMembrane % %% - % We setup som shortcuts for convenience + % We setup som shortcuts for convenience and introduce plotting options an = 'Anode'; ct = 'Cathode'; elyte = 'Electrolyte'; @@ -79,7 +77,8 @@ Source code for runProtonicMembrane xc = model.(elyte).grid.cells.centroids(:, 1); %% - % We consider the solution obtained at the last time step, which corresponds to the solution at steady-state. + % We consider the solution obtained at the last time step, which corresponds to the solution at steady-state. The second + % line adds to the state variable all the variables that are derived from our primary unknowns. state = states{end}; state = model.addVariables(state, schedule.control); diff --git a/ProtonicMembrane/examples/runProtonicMembrane.m b/ProtonicMembrane/examples/runProtonicMembrane.m index 136a05c0..b0f2f3de 100644 --- a/ProtonicMembrane/examples/runProtonicMembrane.m +++ b/ProtonicMembrane/examples/runProtonicMembrane.m @@ -1,7 +1,7 @@ %% Protonic Membrane model %% Load and parse input from given json files -% The source of the json files can be seen in :battmofile:`protonicMembrane` and +% The source of the json files can be seen in :battmofile:`protonicMembrane.json` and % :battmofile:`1d-PM-geometry.json` filename = fullfile(battmoDir(), 'ProtonicMembrane', 'jsonfiles', 'protonicMembrane.json'); @@ -35,17 +35,14 @@ %% Schedule % We setup the schedule, which means the timesteps and also the control we want to use. In this case we use current -% control and the current equal to zero (see here :battmofile:`here`). +% control and the current equal to zero (see :battmofile:`here`). % -% We compute the steady-state solution so that the time stepping here is more an artifact to reach the steady-state -% solution. In particular, it governs the pace at which we increase the non-linearity (not detailed here). +% We compute the steady-state solution and the time stepping here does not correspond to time values but should be seen +% as step-wise increase of the effect of the non-linearity (in particular in the expression of the conductivity which +% includes highly nonlineaer effect with the exponential terms. We do not detail here the method). schedule = model.Control.setupSchedule(inputparams.jsonstruct); -%% -% We change the default tolerance -model.nonlinearTolerance = 1e-8; - %% Simulation % We run the simulation @@ -55,7 +52,7 @@ % %% -% We setup som shortcuts for convenience +% We setup som shortcuts for convenience and introduce plotting options an = 'Anode'; ct = 'Cathode'; elyte = 'Electrolyte'; @@ -70,7 +67,8 @@ xc = model.(elyte).grid.cells.centroids(:, 1); %% -% We consider the solution obtained at the last time step, which corresponds to the solution at steady-state. +% We consider the solution obtained at the last time step, which corresponds to the solution at steady-state. The second +% line adds to the state variable all the variables that are derived from our primary unknowns. state = states{end}; state = model.addVariables(state, schedule.control);