summaryrefslogtreecommitdiff
path: root/ep_run/t2fix_freezer.py
blob: d5d090f6ec86565cef6d468013bd1f5d404a7c16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import time, os, re, shutil
os.chdir("/home/yurenh2/ept/ep_run")
LOG, CK = "runs/ep_t2fix.log", "runs/ep_t2fix.pt"
os.makedirs("runs/t2fix_traj", exist_ok=True)
last_mt=0; t0=time.time()
while time.time()-t0 < 24*3600:
    time.sleep(30)
    try: ls=[l for l in open(LOG) if l.startswith("step")]
    except Exception: continue
    if not ls: continue
    m=re.search(r"step\s+(\d+)/.*res=([\d.eE+-]+)", ls[-1])
    if not m: continue
    step=int(m.group(1)); res=float(m.group(2))
    try: mt=os.path.getmtime(CK)
    except Exception: continue
    if mt!=last_mt and os.path.getsize(CK)>1e6:
        last_mt=mt
        try: shutil.copy2(CK, f"runs/t2fix_traj/s{step}.pt"); print(f"froze s{step} res={res:.2e}",flush=True)
        except Exception: pass
    if res>0.25: print(f"ep_t2fix DIVERGED step {step}",flush=True); break
print("t2fix freezer done")