v1.4.0) — Scientific & Mathematical MethodsLicense: GNU General Public License v3.0 or later (GPL-3.0-or-later).
This document specifies the physical force field, stochastic integrator, replica-exchange thermostatting, cryptographic validation, and Markov State Model (MSM) kinetic analysis algorithms implemented in BeoFold (crates/fold-physics, crates/fold-storage, and crates/fold-msm).
BeoFold uses standard biomolecular MD internal units (Å, ps, amu, kcal/mol, elementary charge e, Kelvin K):
KCAL_TO_AMU_A2_PS2 = 418.4 ([kcal / (mol * Å)] / amu -> Å / ps^2)k_B = 0.001987204259 kcal / (mol * K) (Boltzmann constant)k_e = 1 / (4 * pi * eps_0) = 332.063713 (kcal * Å) / (mol * e^2) (Coulomb constant)fold-physics)Total potential energy V_total(r) decomposes into bonded and non-bonded terms (C^1 smooth up to r_c = 12.0 Å):
V_total(r) = V_bond + V_angle + V_torsion + V_LJ + V_elec_GB + V_EEF1
Following AMBER ff14SB conventions, non-bonded pair policies are:
1-2 (covalently bonded) and 1-3 (valence angle) pairs: Excluded (0.0).1-4 dihedral terminal pairs: Scaled14 (0.5 * V_LJ, (1 / 1.2) * V_elec_GB; EEF1 omitted).r < r_c: Full (1.0).Bonded potential terms (forcefield.rs, evaluated in double precision f64):
V_bond(r) = 0.5 * k_b * (r - r_0)^2
V_angle(theta) = 0.5 * k_theta * (theta - theta_0)^2
V_torsion(phi) = 0.5 * V_n * (1 + cos(n * phi - gamma))
Cartesian forces for dihedrals use the singularity-free Blondel & Karplus (1996) formulation, avoiding division by sin(phi) near planar configurations (0 or pi), with elevated n = 2, gamma = pi, V_2 = 5.0 kcal/mol barriers preserving peptide-bond (C-N) planarity.
For atom pair (i, j) with Lorentz-Berthelot combining rules sigma_ij = 0.5 * (sigma_i + sigma_j) and eps_ij = lj_scale * sqrt(eps_i * eps_j):
u_LJ(r) = 4 * eps_ij * [ (sigma_ij / r)^12 - (sigma_ij / r)^6 ]
u_LJ_shifted(r) = u_LJ(r) - u_LJ(r_c) - (r - r_c) * (du_LJ / dr)|_{r = r_c}
Both potential energy and radial force vanish continuously at r = r_c = 12.0 Å.
gb_radius_ang)Implicit-solvent electrostatic screening combines interior solute polarization (eps_in = 1.0) and bulk aqueous screening (eps_out = 78.5) via the Still et al. (1990) effective interaction distance f_GB(r) parameterized by each atom's effective Born radius R_i = max(gb_radius_ang[i], 0.5 Å):
a = R_i * R_j
h(r) = a * exp( -r^2 / (4 * a) )
f_GB(r) = sqrt( r^2 + h(r) )
To eliminate f32 catastrophic cancellation at long range inside the WGSL GPU kernel (nonbonded.wgsl) while matching CPU f64 evaluation (forcefield.rs), the pairwise factor g(r) = 1/(eps_in * r) - (1/eps_in - 1/eps_out)/f_GB(r) is evaluated in exact algebraic form:
g(r) = 1 / (eps_out * f_GB) + (1 / eps_in) * h(r) / [ r * f_GB * (f_GB + r) ]
dg/dr = -(1 / eps_out) * [ r * (1 - 0.25 * exp(-r^2 / (4*a))) / f_GB^3 ]
-(1 / eps_in) * [ h(r)*(f_GB^2 + f_GB*r + r^2) / (r^2 * f_GB^3 * (f_GB + r))
+ r * exp(-r^2 / (4*a)) / (4 * f_GB^3) ]
The pairwise interaction U_elec(r) = elec_scale * k_e * q_i * q_j * g(r) is C^1 force-shifted at r_c = 12.0 Å consistently on both CPU (rayon Morton grid) and GPU (wgpu 64-thread tiled WGSL compute shader).
Non-backbone sidechain heavy atoms carry a signed solvation weight s_i = eef1_solvation_weight(atom):
s_i > 0): TRP (+1.15), PHE/ILE/LEU (+1.00), MET/VAL (+0.90), TYR (+0.85), CYS (+0.80), PRO (+0.60), ALA (+0.55), and apolar PDB C/S atoms (+0.85 / +0.45).s_i < 0): SER/THR (-0.55), ASN/GLN/HIS (-0.75), LYS/ARG (-1.10), ASP/GLU (-1.15), and charged (|q| >= 0.25) or polar (N/O) PDB sidechain atoms (-1.05 / -0.65).For full non-bonded sidechain pairs with mean weight s_avg = 0.5 * (s_i + s_j):
s_avg > 0): Attractive negative Gaussian well centered at r_contact = sigma_ij + 1.4 Å (width = 1.85 Å, well = 0.28 * sqrt(eps_i * eps_j) * s_avg), driving hydrophobic core collapse:text
u_g(r) = -well * exp( -((r - r_contact) / 1.85)^2 )s_avg < 0): Monotonically repulsive desolvation penalty (width = 2.20 Å, penalty = 0.28 * max(sqrt(eps_i * eps_j), 0.28) * (-s_avg)), penalizing loss of hydration shell contacts when r > sigma_ij (and C^1-flat for r <= sigma_ij):text
u_g(r) = +penalty * exp( -(max(r - sigma_ij, 0) / 2.20)^2 )Both branches are C^1 force-shifted at r_c = 12.0 Å identically on CPU and WGSL GPU (GpuAtomParams.gb_radius_ang, GpuAtomParams.solv_weight).
Atomic SASA (Å^2) is computed via Shrake-Rupley quadrature with N = 32 deterministic Fibonacci sphere points per atom and water probe radius r_probe = 1.40 Å (R_eff = gb_radius_ang + 1.40 Å), accelerated by the 3D Morton spatial grid.
Trajectories advance via Leimkuhler-Matthews BAOAB splitting (dt = 1.5–2.0 fs), which yields second-order weak accuracy and exact configurational sampling:
B (dt/2): v <- v + (dt / 2) * (KCAL_TO_AMU_A2_PS2 / m) * F(x)
A (dt/2): x <- x + (dt / 2) * v
O (dt) : v <- c1 * v + c2 * sqrt(KCAL_TO_AMU_A2_PS2 * k_B * T / m) * G_n
A (dt/2): x <- x + (dt / 2) * v
F <- -grad V_total(x)
B (dt/2): v <- v + (dt / 2) * (KCAL_TO_AMU_A2_PS2 / m) * F(x)
where c1 = exp(-gamma * dt), c2 = sqrt(1 - c1^2), and G_n ~ N(0, I_3) is drawn deterministically from checkpointed counter-based ChaCha8Rng. Setting gamma = 0.0 ps^-1 selects pure symplectic velocity-Verlet (NVE) for energy conservation verification.
Numerical Safety Guards:
mass_amu <= 0.0 or non-finite mass remain immobilized (v = [0, 0, 0]) without division by zero.T <= 0.0 or non-finite T safely clamp thermal noise amplitude to 0.0 (zero NaN propagation).Adjacent temperature rungs (T_1, V_1) and (T_2, V_2) undergo asynchronous Metropolis exchange trials with acceptance probability:
beta_k = 1 / (k_B * T_k)
P_accept = min( 1.0, exp( (beta_1 - beta_2) * (V_1 - V_2) ) )
T_1 <= 0, T_2 <= 0, or any temperature/potential is non-finite (NaN/Inf), metropolis_swap_probability returns 0.0 without panicking.T_old to T_new, its atomic velocities are canonically rescaled:v_new = v_old * sqrt(T_new / T_old)
K_new = K_old * (T_new / T_old)
This rescaling is applied identically in:
mremd::rescale_velocities_sugita_okamoto & try_mremd_swap_checkpoints (fold-physics),FoldStore::acquire_next_lease_filtered (fold-storage) when a swapped Gen G+1 work unit is leased,integrator::run_generation_chunk_with_gpu (fold-physics) whenever thermostatted integration transitions between temperatures (guaranteeing bit-exact replay in Gate 3A canary spot-checks), andWorkerSimState (fold-gui) during live interactive MREMD folding.fold-msm)All algorithms in crates/fold-msm compile under #![forbid(unsafe_code)]:
compute_ca_rmsd): Translates centroids to the origin and solves Horn's (1987) 4x4 symmetric quaternion key matrix K via 25 cyclic Jacobi sweeps:text
RMSD = sqrt( max(0, (G_0 - 2 * lambda_max(K)) / N_CA) )cluster_conformations_kmedoids): Deterministic Maximin Regular-Space seeding anchored at the global lowest-energy frame followed by Partitioning Around Medoids (PAM) refinement so every microstate center is a sterically valid conformation.estimate_reversible_msm): Counts sequential (Run, Clone) transitions at integer lag tau, restricts to cold MREMD rungs (T <= T_ref + 25 K when ergodic, with automatic fallback), extracts the largest Tarjan (1972) Strongly Connected Component (SCC), and optimizes the Prinz-Noé-Pande (2011) reversible maximum-likelihood transition matrix T_ij satisfying exact detailed balance pi_i * T_ij = pi_j * T_ji.S_ij = x_ij / sqrt(X_i * X_j) and computes all real eigenvalues 1 = lambda_1 >= lambda_2 >= ... via pure-Rust Cyclic Jacobi eigendecomposition (t_k = -lag_ps / ln(lambda_k)).TPT) Dirichlet linear system (I - T_II) q_I^+ = T_{I,F} for forward folding committors p_fold in [0, 1].ISA) + crispness maximization I(A) (chi = Psi * A, chi_{i,a} >= 0, sum_a chi_{i,a} = 1) to coarse-grain microstates into M metastable PCCA+ macrostates.compute_2d_pmf_grid, extract_pmf_iso_contours):40x40 2D Gaussian KDE on (RMSD_best, R_g) where each frame in active microstate i carries statistical weight pi_i / count(i).N_eff = (sum w)^2 / sum(w^2) and robust spread min(sigma, IQR / 1.34):text
h_d = 0.96 * N_eff^(-1/6) * min(sigma_d, IQR_d / 1.34)
W(x, y) = -k_B * T_ref * ln( P_eq(x, y) / P_max )1, 2, 3 kcal/mol via Marching Squares with saddle-point disambiguation for both SVG reports and the interactive GUI canvas.