# electrolyte-ion-content

Definition of electrolyte: An aqueous solution containing dissolved ions that result from the dissociation of salts.

The pH value of this solution is related to the concentration of H3O+ and OH`-` ions.

There are two ways how the electrolyte influences the calculations:
- oxide/electrolyte interface states:```             \$interface-states```
- Poisson-Boltzmann equation in electrolyte region:``` \$electrolyte```
```                                       \$electrolyte-ion-content```

The electrostatic potential distribution in the electrolyte can be finally obtained by solving the nonlinear Poisson-Boltzmann equation with appropriate boundary conditions.

The Poisson-Boltzmann model describes the equilibrium of electro-diffusion processes of ions in a solution. There is an exponential relationship between the distribution of the charge density and the potential.

Note: The material name of the electrolyte region must be identical to '`Electrolyte`':
`  \$material`
`   material_name = Electrolyte`

If the electrolyte is present at grid point` i`, then call``` SUBROUTINE calculate_class_dens_ion ```to calculate the ion density (Poisson-Boltzmann equation).
```- FUNCTION density - FUNCTION deriv_density```

### Electrolyte:

1D:
Note: The electrolyte region should be placed at the boundary of the one-dimensional device, i.e. the device should basically look like this along z-direction:
metal (=contact) - semiconductor heterostructure - oxide - electrolyte - metal (contact=electrode inside the electrolyte)

2D:
Then solve the current in the device for direction perpendicular to z direction, i.e. along x and y:
metal (=contact) - semiconductor heterostructure - (here flows the current, so we need two additional contacts in a 2D simulation) - oxide - electrolyte - metal (contact=electrode inside the electrolyte)

```!----------------------------------------------------! \$electrolyte-ion-content                   optional  !  ion-number                  integer       required  !  ion-name                    character     optional  !  ion-valency                 double        required  !  ion-concentration           double        required  !  ion-region                  double_array  required  ! \$end_electrolyte-ion-content               optional  ! !----------------------------------------------------!```

## Syntax

```ion-number        = 1                   = 2 ```Numbering must be unique. All ion numbers numbers together must form a dense set `1`,` 2`,` 3`, ...,` maxnumber`.

```ion-name          = Na+   ! ```cation`+`   of``` NaCl                   = Cl-   ! ```anion`-`    of``` NaCl                   = Ca2+  ! ```cation`2+ `of` CaCl2`
```                  = Cl-   ! ```anion`-`    of` CaCl2`
(optional)

```ion-valency       =  1d0                   = -2d0 ```should be an integer, e.g.` ...,-2,-1,0`,`1````,2,... ```This is the charge of the ion.
(Can be set zero if one wants to deactivate it.)

```ion-concentration = 1.0d-3         ! [M]=[mol/l] ```ion concentration of this` ion-number `in the electrolyte in units of` [M] = [mole/liter] = 1d-3 [mol/cm³]`

```ion-region        = 100d0  2000d0  ! [nm] ```refers to region where the electrolyte has to be applied to, e.g. from 100 nm to 2000 nm in 1D (`xmin xmax`)
` - `1D simulation:` xmin xmax`
` - `2D simulation:``` xmin xmax  ymin ymax  - ```3D simulation:` xmin xmax  ymin ymax  zmin zmax`

1D Example:
```  !---------------------------------------------------------------------------!  ! The electrolyte (NaCl, Hepes) contains four types of ions:  !   1) 100 mM singly charged cations (Na^+)  !   2) 100 mM singly charged anions  (Cl^-)  !   3)  10 mM doubly charged cations (Hepes solution ^2+)  !   4)  20 mM singly charged anions  (Hepes solution ^-)  !---------------------------------------------------------------------------!  \$electrolyte-ion-content   ion-number        = 1   ion-name          = Na+            ! Na+   ion-valency       = 1d0            ! ```charge of the ion:``` Na+   ion-concentration = 0.100d0        ! ```Input in units of:``` [M] = [mol/l] = 1d-3 [mol/cm³]   ion-region        = 1543d0  9999d0 ! ```refers to region where the electrolyte has to be applied to```   ion-number        = 2   ion-name          = Cl-            ! Cl-   ion-valency       = -1d0           ! ```charge of the ion:``` Cl-   ion-concentration = 0.100d0        ! ```Input in units of:``` [M] = [mol/l] = 1d-3 [mol/cm³]   ion-region        = 1543d0  9999d0 ! ```refers to region where the electrolyte has to be applied to```   ion-number        = 3              ! ``` HEPES buffer```   ion-name          = Hepes2+        ! Hepes2+   ion-valency       = 2d0            ! ```charge of the ion:``` Hepes2+   ion-concentration = 0.010d0        ! ```Input in units of:``` [M] = [mol/l] = 1d-3 [mol/cm³]   ion-region        = 1543d0  9999d0 ! ```refers to region where the electrolyte has to be applied to```   ion-number        = 4              ! ``` HEPES buffer```   ion-name          = Hepes-         ! Hepes-   ion-valency       = -1d0           ! ```charge of the ion:``` Hepes-   ion-concentration = 0.020d0        ! ```Input in units of:``` [M] = [mol/l] = 1d-3 [mol/cm³]   ion-region        = 1543d0  9999d0 ! ```refers to region where the electrolyte has to be applied to```  \$end_electrolyte-ion-content  !---------------------------------------------------------------------------!```

Buffer solutions

Note: Instead of specifying the buffer ions explicitly under keyword``` \$electrolyte-ion-content ```it is much more convenient (and userfriendly) to use the specifer``` buffer-name = HEPES ```(or any other buffer name) in keyword``` \$electrolyte```.
By doing so, the concentration of the various buffer ions is calculated automatically, taking into account the pH value, the pKa value, the number of relevant ions, the ionic strength and the temperature dependence in a self-consistent manner.
The material parameters for the various buffer solutions can be found in the database under this keyword:``` \$buffer-solutions```.

Limitations:
- Currently the ion-region must extend over the whole electrolyte region.
- Only one electrolyte region is possible
- Even if no ions are present in the electrolyte (apart from H3O+, OH`-`, anion`-`, cation+), at least one ion species has to be specified. But you can specify` ion-concentration = 0d0 ` in this case.
- Note that the overall charge in the electrolyte should be zero, i.e. the electrolyte should be neutral (electroneutrality requirement).
Bascially, the salts that are put into the electrolyte are neutral. So the sum over all dissociated ions of the salts should also be neutral.
It could be that the user forgets some of these dissociated ions, specifies the valency incorrectly or specifies the concentration incorrectly.
Luckily, these cases will be checked inside the code.

## pH value

Note: The ion concentrations of H3O+ and OH`-` (and their corresponding anion`-` and cation+ counterparts) must not be specified here.
- corresponding anion`-`: conjugate base (Example: HCl + H2O <==> H3O+ + Cl`-`   :      Cl`-` is the conjugate base)
- corresponding cation`+`: conjugate acid
They are inserted automatically inside the code.
nextnano³ automatically generates the following entries internally for the specified pH values:
(`i `is the total number of ions specified in the input file)

pH = 7 (neutral) ([H3O+] = [OH`-`] = 1 * 10-7 M):
```  ion-number        = (i+1)             ! ``` H3O+```   ion-name          = H3O+              ! ```H3O+```   ion-valency       = 1d0               ! ```charge of H3O+:``` ^1+   ion-concentration = 1.0d-7            ! ```Input in units of:``` [M] = [mol/l] = 1d-3 [mol/cm³]   ion-region        = (same as 1st ion) ! ```refers to region where the electrolyte has to be applied to```   ion-number        = (i+2)             ! ``` OH`-````   ion-name          = OH-               ! ```OH`-````   ion-valency       = -1d0              ! ```charge of OH`-`:``` ^1-   ion-concentration = 1.0d-7            ! ```Input in units of:``` [M] = [mol/l] = 1d-3 [mol/cm³]   ion-region        = (same as 1st ion) ! ```refers to region where the electrolyte has to be applied to
```   ion-number        = (i+3)             ! ``` anion`-`` `(corresponding to H3O+)```   ion-name          = anion-            ! ```anion`-`` `(corresponding to H3O+)```   ion-valency       = -1d0              ! ```charge of anion`-`:``` ^1-   ion-concentration = 0d0               ! ``` No conjugate base present for pH = 7 (neutral, i.e. pure water)```   ion-region        = (same as 1st ion) ! ```refers to region where the electrolyte has to be applied to
```   ion-number        = (i+4)             ! ``` cation+` `(corresponding to OH`-`)```   ion-name          = cation+           ! ```cation+` `(corresponding to OH`-`)```   ion-valency       = +1d0              ! ```charge of cation+:``` ^1+   ion-concentration = 0d0               ! ``` No conjugate acid present for pH = 7 (neutral, i.e. pure water)```   ion-region        = (same as 1st ion) ! ```refers to region where the electrolyte has to be applied to

pH = 0 (acid) ([H3O+] = 1 M; [OH`-`] = 1 * 10-14 M):
```  ion-number        = (i+1)             ! ``` H3O+```   ion-valency       = 1d0               ! ``` charge of H3O+:``` ^1+   ion-concentration = 1.0d0             ! ```Input in units of:``` [M] = [mol/l] = 1d-3 [mol/cm³]   ...   ion-number        = (i+2)             ! ``` OH`-````   ion-valency       = -1d0              ! ``` charge of OH`-`:``` ^1-   ion-concentration = 1.0d-14           ! ```Input in units of:``` [M] = [mol/l] = 1d-3 [mol/cm³]   ...   ion-number        = (i+3)             ! ``` anion`-`` `(corresponding to H3O+)```   ion-valency       = -1d0              ! ``` charge of anion`-`:``` ^1-   ion-concentration = ~1d0              ! ``` = 10-pH - 10-pOH = 10-0 - 10-14 = 1```   ...   ion-number        = (i+4)             ! ``` cation+` `(corresponding to OH`-`)```   ion-valency       = +1d0              ! ``` charge of cation+:``` ^1+   ion-concentration = 0d0               ! ``` No conjugate acid present for pH < 7 (i.e. acid)```   ...```

pH = 14 (base) ([H3O+] =  1 * 10-14 M; [OH`-`] = 1 M):
```  ion-number        = (i+1)             ! ``` H3O+```   ion-valency       = 1d0               ! ``` charge of H3O+:``` ^1+   ion-concentration = 1.0d-14           ! ```Input in units of:``` [M] = [mol/l] = 1d-3 [mol/cm³]   ...   ion-number        = (i+2)             ! ``` OH`-````   ion-valency       = -1d0              ! ``` charge of OH`-`:``` ^1-   ion-concentration = 1.0d0             ! ```Input in units of:``` [M] = [mol/l] = 1d-3 [mol/cm³]   ...   ion-number        = (i+3)             ! ``` anion`-`` `(corresponding to H3O+)```   ion-valency       = -1d0              ! ``` charge of anion`-`:``` ^1-   ion-concentration = 0d0               ! ``` No conjugate base present for pH > 7 (i.e. base)```   ...   ion-number        = (i+4)             ! ```cation+` `(corresponding to OH`-`)```   ion-valency       = +1d0              ! ``` charge of cation+:``` ^1+   ion-concentration = ~1d0              ! ``` = 10-pOH - 10-pH = 10-0 - 10-14 = 1```   ...```

The pH value has to be specified in keyword``` \$interface-states ```by the specifier``` pH-value ```for the` state-type = electrolyte`.

## Extremal pH values

At extremal pH values, the following ions are present:

pH = 0:  1 mol/l H3O+, ~1 mol/l anion`- ` (conjugate base)` ` (negligible: 1*10-14 mol/l OH`-`; 0 mol/l cation+)

pH = 14: 1 mol/l OH`-`, ~1 mol/l cation+` `(conjugate acid)`  ` (negligible: 1*10-14 mol/l H3O+; 0 mol/l anion`-`)

This means that these ions will dominate over all other specified ion species unless they occur in a comparable concentration.

If the density of surface sites is zero (`\$interface-states`,``` state-type = electrolyte```,``` interface-density = 0d0```) and if no other ions are specified then the results for very extreme pH values should be identical:
Result( pH=0 ) = Result( pH=14 )` => `Strong acid and strong base should lead to identical results
because nextnano³ does not distinguish between H3O+ and cation+. It also does not distinguish between OH`-` and anion`-`.

More information on electrolyte:``` \$electrolyte```
More information on electrolyte interface charges (site-binding model):``` \$interface-states```