Skip to content

Instantly share code, notes, and snippets.

@jimpea
Created November 8, 2023 15:35
Show Gist options
  • Save jimpea/5725748e77c4c5b395b020cce2ece33a to your computer and use it in GitHub Desktop.
Save jimpea/5725748e77c4c5b395b020cce2ece33a to your computer and use it in GitHub Desktop.
excel lambda functions
// Dispersion force Models
// See <https://arxiv.org/pdf/1910.05746.pdf>
// In these expressions, the unit of length is /sigma, the interparticle
// distance where the potential changes sign and the unit of energy is
// /epsilon, the well depth.
//
/* Lennard-Jones Potential
Inputs:
rs: separation
sigma: interparticle distance where the potential changes sign
epsilon: well depth
Return:
The potential
*/
LJ = LAMBDA(rs, sigma_, epsilon_,
4 * epsilon_ * ((sigma_ / rs) ^ 12 - (sigma_ / rs) ^ 6)
);
/* Coefficient that ensures the depth of the attractive well is -epsilon
Inputs:
rs: separation
sigma: interparticle distance where the potential changes sign
epsilon: well depth
*/
alpha = LAMBDA(rc_, sigma_,
2 * (rc_ / sigma_) ^ 2 *
(3 / (2 * ((rc_ / sigma_) ^ 2 - 1))) ^ 3
);
rmin = LAMBDA(rc_, sigma_,
rc_ * (3 / (1 + 2 * (rc_ / sigma_) ^ 2)) ^ 0.5
);
/* Alternative to LJ potential
Inputs:
rs_: separation
sigma_: interparticle distance where the potential changes sign
epsilon_: well depth
rc_: Cut off
Return:
Modified potential with cutoff at rc_
*/
phi = LAMBDA(rs_, sigma_, epsilon_, rc_,
LET(
alpha_, alpha(rc_, sigma_),
return_, epsilon_ * alpha_ *
((sigma_ / rs_) ^ 2 - 1) *
((rc_ / rs_) ^ 2 - 1) ^ 2,
IF(rs_ <= rc_, return_, 0)
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment