Skip to content

Commit

Permalink
add some output
Browse files Browse the repository at this point in the history
  • Loading branch information
jcosborn committed Jun 12, 2024
1 parent aab7a7c commit cca9f02
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/examples/harmonic.nim
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ var
globalRng: MRG32k3a # global RNG
globalRng.seed(seed, 987654321)

echo "ntraj: ", ntraj
echo "nsteps: ", nsteps
echo "tau: ", tau

proc refreshMomentum(p: auto) =
threads:
p.gaussian rng
Expand Down Expand Up @@ -70,6 +74,7 @@ proc printObservables(x: auto) =
threads:
x := 0

var ds2 = 0.0
for traj in 1..ntraj:
refreshMomentum(p)
threads:
Expand All @@ -79,6 +84,7 @@ for traj in 1..ntraj:
evolve(p, x)
let s1 = action(p, x)
let ds = s1 - s0
ds2 += ds*ds
let pacc = exp(-ds)
let r = globalRng.uniform
if r <= pacc: # accept
Expand All @@ -93,4 +99,5 @@ for traj in 1..ntraj:
printObservables(x)

echo "Acceptance ratio: ", nAccept/ntraj
echo "ds2: ", ds2/ntraj
qexFinalize()

0 comments on commit cca9f02

Please sign in to comment.