Skip to content

Commit

Permalink
Add postprocessing script
Browse files Browse the repository at this point in the history
  • Loading branch information
siuwuncheung committed Aug 20, 2024
1 parent 8526678 commit 0f9fd0f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/PinnedH2O/job.basis
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ echo "Snapshot files: $snapshot_files"

set basis_file = "PinnedH2O_orbitals_basis"

srun -n $ncpus $exe -f $basis_file $snapshot_files > basis_${increment_md_steps}_${num_md_steps}_Pineed_H2O.out
srun -n $ncpus $exe -f $basis_file $snapshot_files > basis_${increment_md_steps}_${num_md_steps}_Pinned_H2O.out

date
27 changes: 27 additions & 0 deletions examples/PinnedH2O/postprocess_PinnedH2O.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import subprocess
import re

print("\\begin{tabular}{|c||c|c|c|c|c|c|c|}")
print("\\hline")
print("$k$ & $\\varepsilon = 10^{-1}$ & $\\varepsilon = 10^{-2}$ & $\\varepsilon = 10^{-3}$ & $\\varepsilon = 10^{-4}$ & $\\varepsilon = 10^{-5}$ & Snapshots \\\\")
print("\\hline")

pattern = r"For energy fraction: \d+\.\d+, take first (\d+) of \d+ basis vectors"
for t in range(10):
k = 50*(t+1)
snapshots = 4*k
grep_command = f"grep 'take first' basis_1_{k}_Pinned_H2O.out"
result = subprocess.run(grep_command, shell=True, capture_output=True, text=True)
matches = re.findall(pattern, result.stdout)
energy_fractions = {
"0.9": matches[0],
"0.99": matches[1],
"0.999": matches[2],
"0.9999": matches[3],
"0.99999": matches[4],
}
line = f"{k} & {energy_fractions['0.9']} & {energy_fractions['0.99']} & {energy_fractions['0.999']} & {energy_fractions['0.9999']} & {energy_fractions['0.99999']} & {snapshots} \\\\"
print(line)

print("\\hline")
print("\\end{tabular}")

0 comments on commit 0f9fd0f

Please sign in to comment.