| Crates.io | coulomb |
| lib.rs | coulomb |
| version | 0.2.1 |
| created_at | 2024-11-25 15:59:31.538753+00 |
| updated_at | 2025-06-03 12:48:12.712007+00 |
| description | Library for electrolytes and electrostatic interactions |
| homepage | |
| repository | https://github.com/mlund/coulomb |
| max_upload_size | |
| id | 1460449 |
| size | 286,885 |
Coulomb A Library for Electrolyte Solutions and Electrostatic Interactions
Coulomb is a library for working with electrolyte solutions and calculating electrostatic interactions in and between molecules and particles. The main purpose is to offer support for molecular simulation software.
trait.uom.
To enable, use the uom feature flag.This is largely a Rust rewrite and extension of the CoulombGalore C++ library.
Simple polynomial models are provided to obtain the relative permittivity or a Medium as a function
of temperature.
For working with the ionic strength, Salt of arbitrary valency can be given and the
required stoichiometry is automatically worked out.
use coulomb::{Medium, Salt};
let molarity = 0.1;
let medium = Medium::salt_water(298.15, Salt::CalciumChloride, molarity);
assert_eq!(medium.permittivity()?, 78.35565171480539);
assert_eq!(medium.ionic_strength()?, 0.3); // mol/l
assert_eq!(medium.debye_length()?, 5.548902662386284); // angstrom
All pairwise schemes support calculation of potential, energy, field, force from or between multipolar particles, up to second order (ion-ion, ion-dipole, dipole-dipole; ion-quadrupole). Most scheme can be evaluated with or without a Debye-Hรผckel screening length.
use coulomb::pairwise::*;
let scheme = Plain::default(); // Vanilla Coulomb scheme, ๐ฎ(๐)=1
let z = 1.0; // point charge, ๐ง
let r = Vector3::new(3.0, 5.0, 0.0); // distance vector, ๐
let ion_pot = scheme.ion_potential(z, r.norm()); // potential |๐| away from charge
assert_eq!(ion_pot, z / r.norm());
let mu = Vector3::new(0.2, 3.0, -1.0); // point dipole, ๐
let dipole_pot = scheme.dipole_potential(&mu, &r); // potential ๐ away from dipole
let energy = scheme.ion_dipole_energy(z, &mu, &r); // interaction energy assuming ๐ = ๐(๐) - ๐(๐ง)
The image below is generated by examples/potential.rs and shows the calculated
electric potential on a plane containing a monopole and a dipole.

Experimental support for static unit analysis can be activated with the uom feature.
use coulomb::{units::*, pairwise::{Plain, MultipoleEnergySI}};
let z1 = ElectricCharge::new::<elementary_charge>(1.0);
let z2 = ElectricCharge::new::<elementary_charge>(2.0);
let r = Length::new::<nanometer>(2.3);
let energy = Plain::without_cutoff().ion_ion_energy(z1, z2, r);
assert_eq!(energy.get::<kilojoule_per_mole>(), 362.4403242896922);