Skip to content

Adding Electrochemistry

Matthew Hockley edited this page Jan 12, 2021 · 5 revisions

Electrochemistry (EC) is the study of electricity and chemical change. EC has many applications namely electrolysis, a reaction driven by an electric input, or chemical reaction producing an electric output such as a battery. The equations governing the EC in BERNAISE is an adaption of the advection-diffusion-reaction equations with an electric field condition, more information is available in Asger Bolet's, Gaute Linga's and Joachim Mathiesen's paper and FEniCS Advection-Diffusion-Reaction Equations Demo. In microfluidics, the transport and controlled mixing (H-channel diffusion - TBA) is useful in a variety of applications. Additionally, understanding the movement of chemical micro-droplets suspensions can be useful in active separation applications (TBA).

The EC models often are limited to the time step where assumptions are made for the diffusion. Too large a time step, the assumption will be unrealistic and lead to an unstable system. The EC chemicals are defined as solutes which have the format name, which phase (1 if no phase field), diffusion in phase 1 (m2/s), diffusion in phase 2 (m2/s), solubility energy in phase 1 (N/A) and solubility energy in phase 1 (N/A).

solutes = [["c_p", 1, 1e-5, 1e-3, 4., 1.]]

problem()

As mentioned above, a solutes variable needs to be created to define the chemical species in the system. See above for more information. As mentioned in Creating a CFD problem, the most important function is problem(). This function contains a dictionary called parameters which needs the following amended or added...

Parameter Description
enable_EC Enable Electrochemistry study
V_left or V_right Define electric field variables to apply to boundaries. See create_bcs().
solutes = solutes Store the solutes array in the parameter dictionary
c_init Initial concentration of solute(s).

initialize()

initialize() function allows for assignment of a pre-defined assumption for the problems. Read more in initialize() main. In EC problems, initial placement of chemicals in the system can be define by position and phase similar to solutes in problem(). Often the placement is defined by an expression such as initial_c in the flow_spiral2D_EC(TBC) example.

        ### Initialize electrochemistry
        # initial_c(xMin, xOffSet, yMin, yOffSet, c_init, function_space):
        if enable_EC:
            c_init_expr = initial_c(
                Hmin, 3*scale_factor, Hymin, 0.25*scale_factor, concentration_init,
                field_to_subspace[solutes[0][0]].collapse())
            w_init_field[solutes[0][0]] = df.interpolate(c_init_expr,
                 field_to_subspace[solutes[0][0]].collapse())

create_bcs()

Boundaries follow a similar definition as in 'create_bcs()' main where enable_EC adds expression for EC inlet/starting concentration and boundary specific constants such as charged or electric field surfaces. The flow_spiral2D_EC(TBC) example defines c_init at the spiral inlet. By default, no electric field V or concentration of solutes [solutes[0][0]] are defined in boundaries.

    ## Define EC boudnaries
    if enable_EC:
        ## Concentration - Constant at inlet
        bcs["inlet"][solutes[0][0]] = Fixed(concentration_init) 
        ## Parameters "V" for electric field (if defined) 
        # bcs["inlet"]["V"] = Fixed(0.0) V = is electric field
        # bcs["outletL"]["V"] = Fixed(0.0) # No electric field
        # bcs["outletR"]["V"] = Fixed(0.0) # No electric field
        # bcs["wall"]["V"] = Fixed(0.0) # No electric field

initial_c

The function initial_c defines the initial concentration of solutes in the system. This expression typically defines solutes are the inlet of the system and is a assumption. This aids in the system reaching a steady state solution.

Parameter Description
xMin Minimum co-ordinate of face. Also known as Hmin.
xOffSet Length of boundary face. Also known as H.
yMin Second minimum co-ordinate of face. Also known as HminZ.
yOffSet Second length of boundary face. Also known as Hz.
c_init Initial concentration of solute(s).
function_space Function space to apply expression. Legacy code, now completed in initialize()

The initial_c expression in the flow_spiral2D_EC(TBC) example defines a 3 mm by 0.5 mm rectangle at the inlet of the spiral. Any co-ordinate values within the rectangle are assigned the c_init value and all other values are assigned 0 concentration for solute(s).

c_init_expr = df.Expression(('((x[0] > (xMin-xOffSet) && x[0] < xMin) &&'
        '((x[1] > (yMin-yOffSet)) && (x[1] < (yMin+yOffSet)))) ? A : 0'),
        xMin=df.Constant(xMin), xOffSet=df.Constant(xOffSet),
        yMin=df.Constant(yMin), yOffSet=df.Constant(yOffSet),
        A=df.Constant(c_init), degree=2)

    return c_init_expr