Tutorial
The edumud package can be used to build up a colloidal system with an (ionic) electrolyte and particles. The characteristics of the colloid are read from a configuration file in *.yaml format.
Using edumud always starts with the import of the necessary physical constants and Python objects. The main objects are Elektrolyte, Particle and Colloid. Also, the load_config function is imported.
from edumud.constants import *
from edumud.electrolytes import Electrolyte
from edumud.particles import Particle
from edumud import Colloid
from edumud.file_utils import load_config
Next, a configuration can be read from file. As an example load the file ‘cegm.yaml’.
from pathlib import Path
DATADIR = Path(__file__).parent
CONFIG = "cegm.yaml"
el = Electrolyte(str(DATADIR / CONFIG))
el.calc_kappa()
param = load_config(str(DATADIR / CONFIG))
part = Particle.from_dict(param["particles"][0])
The structure of the configuration file closely follows the structure of the Elektrolyte object:
- Elektrolyte
concentration in mM
- ions
chemical name e.g. “K”, “Cl”, “PO4”
diffusion constant D
ionic charge z (with sign)
stoechiometry
As an example the configuration for a 5 mM KCl solution is given:
electrolyte:
-
conc: 5.0
ions:
-
name: K
D: 2.0e-9
z: 1
nu: 1
-
name: Cl
D: 3.0e-9
z: -1
nu: 1
The Elektrolyte object contains a list of {concentration, ions} dictionaries for each dissolved salt. Usually there will be one salt in the Elektrolyte but the *.yaml format allows for an extension with multiple dissolved salts.
In a similar way, particle species can be added to the colloid. The configuration yields a list of Particle objects. consisting of:
radius
relative zeta potential in units of .. math:: /kT
relative electrical permittivity epsilon
Hamaker constant from DLVO theory
phi zero
mass fraction
particles:
-
radius: 250.0e-9
rel_zeta: 4.0
eps: 2.0
Hamaker: 5.0e-21
phi_zero: 1
fraction: 0.01
Once the elektrolyte and particles are configured, they can be merged into a Colloid system.
zeta_zero = BOLTZ_T / (el.z_plus * E_CHARGE)
print(f"zeta_zero: {1000 * zeta_zero} mV")
psi_zero = 0.5 * zeta_zero