## FCSys.Chemistry.Electrochemistry

Models associated with electrochemical reactions

### Information

Extends from Modelica.Icons.Package (Icon for standard packages).

### Package Content

Name | Description
--- | ---
DoubleLayer | Electrolytic double layer
ElectronTransfer | Electron transfer

## FCSys.Chemistry.Electrochemistry.DoubleLayer

Electrolytic double layer

### Information

The capacitance (C) is calculated from the surface area (A), length of the gap (L), and the permittivity (ε) assuming that the charges are uniformly distributed over (infinite) parallel planes.

If `setVelocity` is `true`, then the material exits with the velocity of the `inert` connector. Typically, that connector should be connected to the stationary solid, in which case heat will be generated if material arrives with a nonzero velocity. That heat is rejected to the same connector.

Extends from FCSys.Icons.Names.Top2.

### Parameters

Type | Name | Default | Description
--- | --- | --- | ---
Integer | n_trans |  | Number of components of translational momentum
Area | A | 10*U.m^2 | Surface area [L2]
Length | L | 1e-10*U.m | Length of the gap [L]
Permittivity | epsilon | U.epsilon_0 | Permittivity of the dielectric [N2.T2/(L3.M)]
replaceable package Data | Characteristics.'e-'.Graphite | Material properties
Assumptions
Boolean | setVelocity | true | Material exits at the velocity of the `inert` connector
Boolean | inclVolume | true | Include the `amagat` connector to occupy volume

### Connectors

Type | Name | Description
--- | --- | ---
replaceable package Data | Material properties
Chemical | negative | Chemical connector on the 1st side
Chemical | positive | Chemical connector on the 2nd side
Inert | inert | Translational and thermal interface with the substrate
Amagat | amagat | Connector for additivity of volume

### Modelica definition

    model DoubleLayer "Electrolytic double layer"
      extends FCSys.Icons.Names.Top2;

      parameter Integer n_trans(min=1,max=3)
        "Number of components of translational momentum";
      parameter Q.Area A=10*U.m^2 "Surface area";
      parameter Q.Length L=1e-10*U.m "Length of the gap";
      parameter Q.Permittivity epsilon=U.epsilon_0 "Permittivity of the dielectric";

      final parameter Q.Capacitance C=epsilon*A/L "Capacitance";
      replaceable package Data = Characteristics.'e-'.Graphite constrainedby
        Characteristics.BaseClasses.Characteristic "Material properties";

      parameter Boolean setVelocity=true
        "Material exits at the velocity of the inert connector";
      parameter Boolean inclVolume=true
        "Include the amagat connector to occupy volume";

      // Aliases
      Q.Potential w(
        stateSelect=StateSelect.always,
        start=0,
        fixed=true) "Electrical potential";
      Q.Current I "Material current";

      output Q.Amount Z(stateSelect=StateSelect.never) = C*w if environment.analysis
        "Amount of charge shifted in the positive direction";

      Connectors.Chemical negative(final n_trans=n_trans)
        "Chemical connector on the 1st side";
      Connectors.Chemical positive(final n_trans=n_trans)
        "Chemical connector on the 2nd side";
      Connectors.Inert inert(final n_trans=n_trans)
        "Translational and thermal interface with the substrate";

      Connectors.Amagat amagat(final V=-A*L) if inclVolume
        "Connector for additivity of volume";

    protected
      outer Conditions.Environment environment "Environmental conditions";

    equation
      // Aliases
      Data.z*w = positive.g - negative.g;
      I = positive.Ndot;

      // Streams
      if setVelocity then
        negative.phi = inert.phi;
        positive.phi = inert.phi;
      else
        negative.phi = inStream(positive.phi);
        positive.phi = inStream(negative.phi);
      end if;
      negative.sT = inStream(positive.sT);
      positive.sT = inStream(negative.sT);

      // Conservation
      0 = negative.Ndot + positive.Ndot "Material (no storage)";
      zeros(n_trans) = Data.m*(actualStream(negative.phi) - actualStream(positive.phi))
        *I + inert.mPhidot "Translational momentum (no storage)";
      der(C*w)/U.s = Data.z*I
        "Electrical energy (reversible; simplified using material conservation and divided by potential)";
      0 = inert.Qdot + (actualStream(negative.phi)*actualStream(negative.phi) -
        actualStream(positive.phi)*actualStream(positive.phi))*I*Data.m/2 + inert.phi
        *inert.mPhidot "Mechanical and thermal energy (no storage)";

    end DoubleLayer;

## FCSys.Chemistry.Electrochemistry.ElectronTransfer

Electron transfer

### Information

`fromI` may help to eliminate nonlinear systems of equations if the double layer capacitance is not included.

Extends from FCSys.Icons.Names.Top2.

### Parameters

Type | Name | Default | Description
--- | --- | --- | ---
Integer | n_trans |  | Number of components of translational momentum
Integer | z | -1 | Charge number
Current | I0 | U.A | Exchange current @ 300 K [N/T]
Chemical parameters
Potential | E_A | 0 | Activation energy [L2.M/(N.T2)]
NumberAbsolute | alpha | 0.5 | Charge transfer coefficient [1]
Advanced
Boolean | fromI | true | Invert the Butler-Volmer equation, if α=½

### Connectors

Type | Name | Description
--- | --- | ---
Chemical | negative | Chemical connector on the 1st side
Chemical | positive | Chemical connector on the 2nd side
Inert | inert | Translational and thermal interface with the substrate

### Modelica definition

    model ElectronTransfer "Electron transfer"
      import Modelica.Math.asinh;
      extends FCSys.Icons.Names.Top2;

      parameter Integer n_trans(min=1,max=3)
        "Number of components of translational momentum";

      parameter Integer z=-1 "Charge number";
      parameter Q.Potential E_A=0 "Activation energy";
      parameter Q.NumberAbsolute alpha(max=1) = 0.5 "Charge transfer coefficient";
      parameter Q.Current I0=U.A "Exchange current @ 300 K";
      parameter Boolean fromI=true
        "Invert the Butler-Volmer equation, if α=½";

      Connectors.Chemical negative(final n_trans=n_trans)
        "Chemical connector on the 1st side";
      Connectors.Chemical positive(final n_trans=n_trans)
        "Chemical connector on the 2nd side";

      // Aliases
      Q.TemperatureAbsolute T(start=300*U.K) "Reaction rate";
      Q.Current I(start=0) "Reaction rate";
      Q.Potential Deltag(start=0) "Potential difference";

      Connectors.Inert inert(final n_trans=n_trans)
        "Translational and thermal interface with the substrate";

    equation
      // Aliases
      I = positive.Ndot;
      Deltag = positive.g - negative.g;
      T = inert.T;

      // Streams
      negative.phi = inStream(positive.phi);
      positive.phi = inStream(negative.phi);
      negative.sT = inStream(positive.sT);
      positive.sT = inStream(negative.sT);

      // Reaction rate
      if abs(alpha - 0.5) < Modelica.Constants.eps and fromI then
        Deltag = 2*T*asinh(0.5*exp(E_A*(1/T - 1/(300*U.K)))*I/I0);
      else
        I*exp(E_A*(1/T - 1/(300*U.K))) = I0*(exp((1 - alpha)*Deltag/T) - exp(-alpha*
          Deltag/T));
      end if;

      // Conservation (without storage)
      0 = negative.Ndot + positive.Ndot "Material";
      zeros(n_trans) = inert.mPhidot "Translational momentum";
      0 = Deltag*I + inert.Qdot "Energy";
      // Note:  Energy and momentum cancel among the stream terms.

    end ElectronTransfer;