Skip to content

Commit

Permalink
Adding short description for examples
Browse files Browse the repository at this point in the history
  • Loading branch information
tlroy committed Apr 17, 2024
1 parent 5a94ff3 commit d3dd3f5
Show file tree
Hide file tree
Showing 20 changed files with 223 additions and 69 deletions.
5 changes: 5 additions & 0 deletions examples/BMCSL.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
@author: Nitish Govindarajan
Simple example for the BMCSL model for finite size ion effects
Code to reproduce Figure 1 from doi:10.1016/j.jcis.2007.08.006
Biesheuvel, P.M. and Van Soestbergen, M., 2007. Counterion volume effects in
mixed electrical double layers. Journal of Colloid and Interface Science,
316(2), pp.490-499.
"""

# Import required libraries
Expand Down
3 changes: 2 additions & 1 deletion examples/bicarb.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
class CarbonateSolver(EchemSolver):
def __init__(self):
"""
Bicarbonate example reproduced from:
Flow past an electrode with bicarbonate bulk reactions and linear CO2 electrolysis
Example reproduced from:
Lin, T.Y., Baker, S.E., Duoss, E.B. and Beck, V.A., 2021. Analysis of
the Reactive CO2 Surface Flux in Electrocatalytic Aqueous Flow
Reactors. Industrial & Engineering Chemistry Research, 60(31),
Expand Down
27 changes: 13 additions & 14 deletions examples/bicarb_Ag_Cu_tandem_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@
comm = MPI.COMM_WORLD
rank = comm.Get_rank()

##Description:
#This example case runs a tandem electrode system, with an Ag catalyst placed
#in front of a Cu catalyst, at a Peclet number of 1E3.
#The advection/diffusion/migration/electroneutrality equations are solved
#for the bulk electrolyte, and a Tafel description is applied for the surface
#catalyst reactions.
"""
This example case runs a tandem electrode system, with an Ag catalyst placed
in front of a Cu catalyst, at a Peclet number of 1E3.
The advection/diffusion/migration/electroneutrality equations are solved
for the bulk electrolyte, and a Tafel description is applied for the surface
catalyst reactions.
#Assumed products of Cu catalyst are C2H4, C2H6O, and H2.
#Assumed products of Ag catalysis are CO and H2.
Assumed products of Cu catalyst are C2H4, C2H6O, and H2.
Assumed products of Ag catalysis are CO and H2.
--------------------------------------------------------------------------
list of references
##--------------------------------------------------------------------------
#list of references
"""
Bicarbonate flow reactor setup given in:
Lin, T.Y., Baker, S.E., Duoss, E.B. and Beck, V.A., 2021. Analysis of
the Reactive CO2 Surface Flux in Electrocatalytic Aqueous Flow
Expand Down Expand Up @@ -53,10 +53,9 @@
Microkinetics with Continuum Transport Models to Understand Electrochemical
CO2 Reduction in Flow Reactors. PRX Energy, 2(3), pp.033010.
--------------------------------------------------------------------------
end of list of references
"""
##--------------------------------------------------------------------------
#end of list of references



#---------------------------------------------------------------------------
Expand Down
14 changes: 14 additions & 0 deletions examples/bortels_threeion.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@
parser.add_argument("--family", type=str, default='DG')
args, _ = parser.parse_known_args()

"""
2D Flow-plate reactor with electroneutral Nernst-Planck. Using a custom gmsh
mesh with refinement close to the electrodes. GMSH is used to get the mesh file
from the .geo file as follows:
gmsh -2 bortels_structuredquad.geo
Three ion case taken from:
Bortels, L., Deconinck, J. and Van Den Bossche, B., 1996. The multi-dimensional
upwinding method as a new simulation tool for the analysis of multi-ion
electrolytes controlled by diffusion, convection and migration. Part 1. Steady
state analysis of a parallel plane flow channel. Journal of Electroanalytical
Chemistry, 404(1), pp.15-26.
"""

class BortelsSolver(EchemSolver):
def __init__(self):
Expand Down
20 changes: 19 additions & 1 deletion examples/bortels_threeion_extruded_3D_nondim.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@

set_log_level(DEBUG)

"""
3D Flow-plate reactor with electroneutral Nernst-Planck. Using a custom gmsh
mesh with refinement close to the electrodes. The mesh is then extruded in the
z-direction. Custom block preconditioners are used. The file submitter.pl can
be adapted to launch slurm jobs using perl.
Three ion case adapted from the 2D case in:
Bortels, L., Deconinck, J. and Van Den Bossche, B., 1996. The multi-dimensional
upwinding method as a new simulation tool for the analysis of multi-ion
electrolytes controlled by diffusion, convection and migration. Part 1. Steady
state analysis of a parallel plane flow channel. Journal of Electroanalytical
Chemistry, 404(1), pp.15-26.
Nondimensionalization and preconditioning from:
Roy, T., Andrej, J. and Beck, V.A., 2023. A scalable DG solver for the
electroneutral Nernst-Planck equations. Journal of Computational Physics, 475,
p.111859.
"""

parser = argparse.ArgumentParser()
parser.add_argument('-ref_levels', type=int, default=0)
Expand Down Expand Up @@ -55,6 +73,7 @@ def coarsen_form(self, form, args):
class BortelsSolver(EchemSolver):
def __init__(self):
# Create an initial coarse mesh
# Note: will need to use "gmsh -2 mesh_name.geo" command to convert to .msh format
if args.mesh == 'structured':
plane_mesh = Mesh('bortels_structuredquad_nondim_coarse1664.msh')
layers = 8
Expand Down Expand Up @@ -197,7 +216,6 @@ def set_velocity(self):

# Custom solver parameters


class CoarsenPenaltyPMGPC(P1PC):
def coarsen_form(self, form, replace_dict):
k = 1
Expand Down
19 changes: 19 additions & 0 deletions examples/bortels_threeion_nondim.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
from firedrake import *
from echemflow import EchemSolver

"""
2D Flow-plate reactor with electroneutral Nernst-Planck. Using a custom gmsh
mesh with refinement close to the electrodes. GMSH is used to get the mesh file
from the .geo file as follows:
gmsh -2 bortels_structuredquad_nondim.geo
Three ion case taken from:
Bortels, L., Deconinck, J. and Van Den Bossche, B., 1996. The multi-dimensional
upwinding method as a new simulation tool for the analysis of multi-ion
electrolytes controlled by diffusion, convection and migration. Part 1. Steady
state analysis of a parallel plane flow channel. Journal of Electroanalytical
Chemistry, 404(1), pp.15-26.
Nondimensionalization from:
Roy, T., Andrej, J. and Beck, V.A., 2023. A scalable DG solver for the
electroneutral Nernst-Planck equations. Journal of Computational Physics, 475,
p.111859.
"""

class BortelsSolver(EchemSolver):
def __init__(self):
Expand Down
14 changes: 14 additions & 0 deletions examples/bortels_twoion.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@
parser.add_argument("--family", type=str, default='DG')
args, _ = parser.parse_known_args()

"""
2D Flow-plate reactor with electroneutral Nernst-Planck. Using a custom GMSH
mesh with refinement close to the electrodes. GMSH is used to get the mesh file
from the .geo file as follows:
gmsh -2 bortels_structuredquad.geo
Two ion case taken from:
Bortels, L., Deconinck, J. and Van Den Bossche, B., 1996. The multi-dimensional
upwinding method as a new simulation tool for the analysis of multi-ion
electrolytes controlled by diffusion, convection and migration. Part 1. Steady
state analysis of a parallel plane flow channel. Journal of Electroanalytical
Chemistry, 404(1), pp.15-26.
"""

class BortelsSolver(EchemSolver):
def __init__(self):
Expand Down
19 changes: 19 additions & 0 deletions examples/bortels_twoion_nondim.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
from firedrake import *
from echemfem import EchemSolver

"""
2D Flow-plate reactor with electroneutral Nernst-Planck. Using a custom gmsh
mesh with refinement close to the electrodes. GMSH is used to get the mesh file
from the .geo file as follows:
gmsh -2 bortels_structuredquad_nondim.geo
Two ion case taken from:
Bortels, L., Deconinck, J. and Van Den Bossche, B., 1996. The multi-dimensional
upwinding method as a new simulation tool for the analysis of multi-ion
electrolytes controlled by diffusion, convection and migration. Part 1. Steady
state analysis of a parallel plane flow channel. Journal of Electroanalytical
Chemistry, 404(1), pp.15-26.
Nondimensionalization from:
Roy, T., Andrej, J. and Beck, V.A., 2023. A scalable DG solver for the
electroneutral Nernst-Planck equations. Journal of Computational Physics, 475,
p.111859.
"""

class BortelsSolver(EchemSolver):
def __init__(self):
Expand Down
31 changes: 19 additions & 12 deletions examples/carbonate.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
from firedrake import *
from echemfem import EchemSolver, IntervalBoundaryLayerMesh

"""
A 1D example of diffusion-reaction for CO2 electrolysis with bicarbonate bulk
reactions. The bulk reactions and charge-transfer reactions are implemented by
hand.
Steady-state version of example from
Gupta, N., Gattrell, M. and MacDougall, B., 2006. Calculation for the
cathode surface concentrations in the electrochemical reduction of CO2 in
KHCO3 solutions. Journal of applied electrochemistry, 36(2), pp.161-172.
Using the bicarbonate bulk reactions from
Schulz, K.G., Riebesell, U., Rost, B., Thoms, S. and Zeebe, R.E., 2006.
Determination of the rate constants for the carbon dioxide to bicarbonate
inter-conversion in pH-buffered seawater systems. Marine chemistry,
100(1-2), pp.53-65.
"""

class CarbonateSolver(EchemSolver):
"""
Steady-state version of example from
Gupta, N., Gattrell, M. and MacDougall, B., 2006. Calculation for the
cathode surface concentrations in the electrochemical reduction of CO2 in
KHCO3 solutions. Journal of applied electrochemistry, 36(2), pp.161-172.
but using the bicarbonate bulk reactions from
Schulz, K.G., Riebesell, U., Rost, B., Thoms, S. and Zeebe, R.E., 2006.
Determination of the rate constants for the carbon dioxide to bicarbonate
inter-conversion in pH-buffered seawater systems. Marine chemistry,
100(1-2), pp.53-65.
"""

def __init__(self):

delta = 0.0001
Expand Down Expand Up @@ -115,6 +119,9 @@ def set_boundary_markers(self):
solver = CarbonateSolver()
solver.setup_solver()
solver.solve()

### Plotting

C_CO2, C_OH, C_H, C_CO3, C_HCO3 = solver.u.subfunctions
# OH boundary layer
x = solver.mesh.coordinates
Expand Down
31 changes: 19 additions & 12 deletions examples/carbonate_homog_params.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
from firedrake import *
from echemfem import EchemSolver, IntervalBoundaryLayerMesh

"""
A 1D example of diffusion-reaction for CO2 electrolysis with bicarbonate bulk
reactions. The charge-transfer reactions are implemented by hand but the bulk
reactions are implemented using the homog_params interface.
Steady-state version of example from
Gupta, N., Gattrell, M. and MacDougall, B., 2006. Calculation for the
cathode surface concentrations in the electrochemical reduction of CO2 in
KHCO3 solutions. Journal of applied electrochemistry, 36(2), pp.161-172.
Using the bicarbonate bulk reactions from
Schulz, K.G., Riebesell, U., Rost, B., Thoms, S. and Zeebe, R.E., 2006.
Determination of the rate constants for the carbon dioxide to bicarbonate
inter-conversion in pH-buffered seawater systems. Marine chemistry,
100(1-2), pp.53-65.
"""

class CarbonateSolver(EchemSolver):
"""
Steady-state version of example from
Gupta, N., Gattrell, M. and MacDougall, B., 2006. Calculation for the
cathode surface concentrations in the electrochemical reduction of CO2 in
KHCO3 solutions. Journal of applied electrochemistry, 36(2), pp.161-172.
but using the bicarbonate bulk reactions from
Schulz, K.G., Riebesell, U., Rost, B., Thoms, S. and Zeebe, R.E., 2006.
Determination of the rate constants for the carbon dioxide to bicarbonate
inter-conversion in pH-buffered seawater systems. Marine chemistry,
100(1-2), pp.53-65.
"""

def __init__(self):

delta = 0.0001
Expand Down Expand Up @@ -142,6 +146,9 @@ def set_boundary_markers(self):
solver = CarbonateSolver()
solver.setup_solver()
solver.solve()

### Plotting

C_CO2, C_OH, C_H, C_CO3, C_HCO3 = solver.u.subfunctions
# OH boundary layer
x = solver.mesh.coordinates
Expand Down
8 changes: 7 additions & 1 deletion examples/catalyst_layer_Cu.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
import csv
import pdb
"""
Model fromn
1D model for the CO2 electrolysis in a copper catalyst layer of a gas diffusion
electrode (GDE). The model uses electroneutral Nernst-Planck in a porous
medium.
Corral D, Lee DU, Ehlinger VM, Nitopi S, Acosta JE, Wang L, King AJ, Feaster JT,
Lin YR, Weber AZ, Baker SE. Bridging knowledge gaps in liquid-and vapor-fed CO2
electrolysis through active electrode area. Chem Catalysis. 2022 Oct 12.
Expand Down Expand Up @@ -240,6 +243,9 @@ def set_boundary_markers(self):
solver.U_app.assign(Vs)
print("V = %d mV" % (Vs * 1000))
solver.solve()

## Plotting

cCO2, cOH, cH, cCO3, cHCO3, phi2, phi1 = solver.u.subfunctions
cK = Function(solver.V).assign(2 * cCO3 + cOH + cHCO3 - cH)

Expand Down
10 changes: 9 additions & 1 deletion examples/catalyst_layer_Cu_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
import numpy as np
import csv
"""
Model fromn
1D model for the CO2 electrolysis in a copper catalyst layer of a gas diffusion
electrode (GDE). The model uses electroneutral Nernst-Planck in a porous
medium. This version of the code does not eliminate a species by substituting
the electroneutrality equation, but rather explicitly solves for
electroneutrality.
Corral D, Lee DU, Ehlinger VM, Nitopi S, Acosta JE, Wang L, King AJ, Feaster JT,
Lin YR, Weber AZ, Baker SE. Bridging knowledge gaps in liquid-and vapor-fed CO2
electrolysis through active electrode area. Chem Catalysis. 2022 Oct 12.
Expand Down Expand Up @@ -240,6 +245,9 @@ def set_boundary_markers(self):
solver.U_app.assign(Vs)
print("V = %d mV" % (Vs * 1000))
solver.solve()

## Plotting

cCO2, cOH, cH, cCO3, cHCO3, cK, phi2, phi1 = solver.u.subfunctions

x_ = Function(V).interpolate(solver.mesh.coordinates[0]).vector().dat.data
Expand Down
8 changes: 5 additions & 3 deletions examples/cylindrical_pore.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
from echemfem import EchemSolver
import numpy as np
"""
Model from
A symmetric cylindrical pore model for CO2 electrolysis using electroneutral
Nernst-Planck and simplified bicarbonate bulk reactions.
Elucidating Mass Transport Regimes in Gas Diffusion Electrodes for CO2 Electroreduction
Thomas Moore, Xiaoxing Xia, Sarah E. Baker, Eric B. Duoss, and Victor A. Beck
ACS Energy Letters 2021 6 (10), 3600-3606
Expand Down Expand Up @@ -170,18 +172,18 @@ def set_boundary_markers(self):
solver.save_solutions = False
solver.solve()

## Plotting

# getting active region
_, Z = SpatialCoordinate(solver.mesh)
active = conditional(le(Z, 5e-6), 1., 0.)


def get_boundary_dofs(V, i):
u = Function(V)
bc = DirichletBC(V, active, i)
bc.apply(u)
return np.where(u.vector()[:] == 1)


dofs = get_boundary_dofs(solver.V, 2)
Z_cat = Function(solver.V).interpolate(Z).dat.data[dofs]

Expand Down
6 changes: 6 additions & 0 deletions examples/gupta.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

class GuptaSolver(EchemSolver):
"""
A 1D example of diffusion-reaction for CO2 electrolysis with bicarbonate bulk
reactions.
Steady-state version of example from
Gupta, N., Gattrell, M. and MacDougall, B., 2006. Calculation for the
cathode surface concentrations in the electrochemical reduction of CO2 in
Expand Down Expand Up @@ -94,6 +97,9 @@ def set_boundary_markers(self):
solver = GuptaSolver()
solver.setup_solver()
solver.solve()

## Plotting

C_CO2, C_HCO3, C_CO3, C_OH = solver.u.subfunctions
# OH boundary layer
x = solver.mesh.coordinates
Expand Down
Loading

0 comments on commit d3dd3f5

Please sign in to comment.