Skip to content

Commit

Permalink
Add postprocessing scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
siuwuncheung committed Nov 14, 2024
1 parent 65939c5 commit 03e59eb
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
28 changes: 28 additions & 0 deletions examples/PinnedH2O/get_ROM_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import subprocess
import re

pattern = r"For energy fraction: \d+\.\d+, take first (\d+) of \d+ basis vectors"

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")

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}")
31 changes: 31 additions & 0 deletions examples/PinnedH2O_3DOF/get_ROM_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import subprocess
import re

bondlength_num_increments = (2, 5, 10)
bondangle_num_increments = (2, 5, 10)

pattern = r"For energy fraction: \d+\.\d+, take first (\d+) of \d+ basis vectors"

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

for _, N_L in enumerate(bondlength_num_increments):
for _, N_theta in enumerate(bondangle_num_increments):
snapshots = 2*(N_L+1)*(N_L+2)*(N_theta+1)
grep_command = f"grep 'take first' basis_{N_L}_{N_theta}_PinnedH2O_3DOF.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"{N_L} & {N_theta} & {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 03e59eb

Please sign in to comment.