Electrical Potential
ElectricalPotential manages the electrode configuration of an electrochemical simulation. It declares how many electrodes are present in the domain, pairs each with its counter-electrode, and reads the integer elementary-charge valence
with ElectricProperties uses to build the space charge density consumed by the Poisson solver described on the Electrics overview.
Key Classes and Concepts
ElectricalPotential : public OPObject: holds the electrode list, the per-componentElementarCharges[q]and derivedMolarCharge[q].Electrode: one electrode entry with an index, a charge, an interface volume, a 3-vector position, and a counter-electrode index.
Usage
Input
Defined in the @ElectricalPotential block. Electrodes are numbered 1-based in the input; inside the code they are stored zero-based (the reader subtracts 1).
@ElectricalPotential
$Nelectrodes Number of electrodes in the domain : 2
$CntElectr1 Counter-electrode index for electrode 1 : 2
$CntElectr2 Counter-electrode index for electrode 2 : 1
# Elementary charge valence of each component (zero-based) {#elementary-charge-valence-of-each-component-zero-based}
$Z0 Valence of component 0 : 1
$Z1 Valence of component 1 : -1| Token | Variable | Type | Required |
|---|---|---|---|
$Nelectrodes | Nelectrodes | int | yes |
$CntElectr<i> | electrodes[i-1].counterElectrode | int (1-based on input) | yes, one per electrode |
$Z<q> | ElementarCharges[q] | int | yes, one per component |
Output
No dedicated output file. The derived MolarCharge[q] array is forwarded to ElectricProperties::CalculateChargeDensity during the solve, whose result ends up in the VTK output written through the Electrics overview solver pipeline.
Example
#include "ElectricalPotential.h"
#include "Electrics/ElectricProperties.h"
ElectricalPotential EPot(OPSettings, InputFile);
ElectricProperties ElecP(OPSettings, InputFile);
for(RTC.tStep = RTC.tStart; RTC.tStep <= RTC.nSteps; RTC.IncrementTimeStep())
{
// ElecP uses ElementarCharges published by EPot
ElecP.CalculateChargeDensity(Cx);
ElecP.SetBoundaryConditions(BC);
// ... solver step ...
}Dependencies
- Composition — component list.
- ElectricProperties — consumer of the per-component molar-charge array.
- Electrics (overview) — the spectral solver.
PhysicalConstants::Faraday— the Faraday constant used in theconversion.