SeaWolf-AI commited on
Commit
6577534
·
verified ·
1 Parent(s): fbbaf0f

honest per-material rebuild: N(E_F)xA_d(delta) verified + published pipeline + CC-BY-NC

Browse files
Files changed (1) hide show
  1. pipeline/solve_batch.py +50 -0
pipeline/solve_batch.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """Run the precise 6x6 doped-Hubbard solver once per UNIQUE filling present in df_batch,
3
+ then assign the material-specific d-wave amplitude A_d(delta) to every material.
4
+
5
+ verified_score = N(E_F) * A_d(delta_material) (a physical, per-material quantity: it varies
6
+ with doping via the d-wave dome). Cheap: only the distinct fillings are solved.
7
+ """
8
+ import os, sys, json, glob, subprocess, time
9
+
10
+ SOLVER = "/data/ginipick/hubbard_doped/pair_corr.py"
11
+ CVD = os.environ.get("CUDA_VISIBLE_DEVICES", "3")
12
+ OPT = int(os.environ.get("OSC_OPT", "200"))
13
+
14
+
15
+ def solve(nup, ndn):
16
+ out = f"/tmp/Abatch_{nup}_{ndn}.json"
17
+ env = dict(os.environ, CUDA_VISIBLE_DEVICES=CVD)
18
+ subprocess.run([sys.executable, "-u", SOLVER, "--size", "6x6", "--nup", str(nup),
19
+ "--ndn", str(ndn), "--opt", str(OPT), "--meas", "20", "--Bmeas", "384",
20
+ "--dwave", "0.15", "--out", out],
21
+ env=env, cwd=os.path.dirname(SOLVER), timeout=900, check=False)
22
+ d = json.load(open(out))
23
+ pds = {k: v for k, v in d.items() if k.startswith("Pd_") and not k.endswith("err")}
24
+ if not pds:
25
+ return None
26
+ best = max(pds, key=lambda k: sum(int(c) for c in k.split("_")[1]))
27
+ return float(pds[best])
28
+
29
+
30
+ def main():
31
+ rows = [json.load(open(f)) for f in glob.glob("df_batch/*.json")]
32
+ uniq = sorted(set((r["solver_nup"], r["solver_ndn"]) for r in rows))
33
+ print(f"{len(rows)} materials, {len(uniq)} unique fillings to solve", flush=True)
34
+ A = {}
35
+ for nup, ndn in uniq:
36
+ t0 = time.time()
37
+ a = solve(nup, ndn)
38
+ A[(nup, ndn)] = a
39
+ print(f" Ne={nup+ndn} delta={1-(nup+ndn)/36.0:+.3f} A_d={a} ({time.time()-t0:.0f}s)", flush=True)
40
+ os.makedirs("solved", exist_ok=True)
41
+ for r in rows:
42
+ a = A.get((r["solver_nup"], r["solver_ndn"]))
43
+ r["A_dwave"] = round(a, 5) if a is not None else None
44
+ json.dump(r, open("solved/" + r["material_id"] + ".json", "w"), indent=1)
45
+ json.dump({f"{k[0]+k[1]}": v for k, v in A.items()}, open("solved/A_by_Ne.json", "w"), indent=1)
46
+ print("done -> solved/", flush=True)
47
+
48
+
49
+ if __name__ == "__main__":
50
+ main()