// LennardJones: the Lennard-Jones pair potential at distance R, // V(R) = 4 Epsilon ((Sigma / R)^12 - (Sigma / R)^6). Epsilon is the depth of // the well, reached at R = 2^(1/6) Sigma, and V is 0 at R = Sigma. The powers // are built by multiplication from (Sigma / R)^2, as simulation codes do, // which is faster than ^ and rounds a little differently. FUNCTION LennardJones(R : FLOAT, Epsilon : FLOAT, Sigma : FLOAT) RETURNS FLOAT REQUIRE R > 0.0 DECLARE S2 : FLOAT <- (Sigma / R) * (Sigma / R) DECLARE S6 : FLOAT <- S2 * S2 * S2 RETURN 4.0 * Epsilon * (S6 * S6 - S6) ENDFUNCTION