This commit is contained in:
commit
568474d52f
1591 files changed
+528213
No files matched your search
@@ -0,0 +1,59 @@
|
||||
function Pow(x: real, n: nat): real
|
||||
{
|
||||
if n == 0 then 1.0 else x * Pow(x, n - 1)
|
||||
}
|
||||
|
||||
function LJ(r: real, epsilon: real, sigma: real): real
|
||||
requires r > 0.0
|
||||
{
|
||||
4.0 * epsilon * (Pow(sigma / r, 12) - Pow(sigma / r, 6))
|
||||
}
|
||||
|
||||
lemma PowAdd(x: real, a: nat, b: nat)
|
||||
ensures Pow(x, a + b) == Pow(x, a) * Pow(x, b)
|
||||
{
|
||||
if a > 0 {
|
||||
PowAdd(x, a - 1, b);
|
||||
assert Pow(x, a + b) == x * Pow(x, a - 1 + b);
|
||||
}
|
||||
}
|
||||
|
||||
lemma Pow2(x: real)
|
||||
ensures Pow(x, 2) == x * x
|
||||
{
|
||||
assert Pow(x, 1) == x;
|
||||
}
|
||||
|
||||
lemma Pow6(s: real)
|
||||
ensures Pow(s, 6) == (s * s) * (s * s) * (s * s)
|
||||
{
|
||||
Pow2(s);
|
||||
PowAdd(s, 2, 2);
|
||||
PowAdd(s, 4, 2);
|
||||
}
|
||||
|
||||
lemma Pow12(s: real)
|
||||
ensures Pow(s, 12) == Pow(s, 6) * Pow(s, 6)
|
||||
{
|
||||
PowAdd(s, 6, 6);
|
||||
}
|
||||
|
||||
method LennardJones(r: real, epsilon: real, sigma: real) returns (v: real)
|
||||
requires r > 0.0
|
||||
ensures v == LJ(r, epsilon, sigma)
|
||||
{
|
||||
var s := sigma / r;
|
||||
var s2 := s * s;
|
||||
var s6 := s2 * s2 * s2;
|
||||
Pow6(s);
|
||||
Pow12(s);
|
||||
v := 4.0 * epsilon * (s6 * s6 - s6);
|
||||
}
|
||||
|
||||
// The potential crosses zero at R = Sigma.
|
||||
lemma ZeroAtSigma(epsilon: real, sigma: real)
|
||||
requires sigma > 0.0
|
||||
ensures LJ(sigma, epsilon, sigma) == 0.0
|
||||
{
|
||||
assert sigma / sigma == 1.0;
|
||||
}
|
||||
Reference in new issue
Block a user