From fc2445d158ebff47baa02594e4ddd95249a6b268 Mon Sep 17 00:00:00 2001 From: Yifan Li Date: Tue, 12 May 2026 16:42:13 -0400 Subject: [PATCH 1/2] fix: add TI anchor metadata to result.json --- dpti/ti.py | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/dpti/ti.py b/dpti/ti.py index 11114e5..fe4dc0c 100755 --- a/dpti/ti.py +++ b/dpti/ti.py @@ -457,6 +457,7 @@ def post_tasks( scheme="simpson", shift=0.0, output_dir=None, + hti_path=None, ): equi_conf = get_task_file_abspath(iter_name, jdata["equi_conf"]) if natoms is None: @@ -695,7 +696,7 @@ def post_tasks( return info -def post_tasks_mbar(iter_name, jdata, Eo, natoms=None, output_dir=None): +def post_tasks_mbar(iter_name, jdata, Eo, natoms=None, output_dir=None, hti_path=None): equi_conf = jdata["equi_conf"] if natoms is None: natoms = get_natoms(equi_conf) @@ -845,8 +846,18 @@ def post_tasks_mbar(iter_name, jdata, Eo, natoms=None, output_dir=None): ), } info = {"start_point_info": info0, "end_point_info": info1, "data": data} - with open(os.path.join(output_dir, "result"), "w") as f: - f.write(result) + if hti_path is not None: + info["hti_path"] = os.path.abspath(hti_path) + hti_result_json = os.path.join(hti_path, "result.json") + hti_input_json = os.path.join(hti_path, "in.json") + if os.path.isfile(hti_result_json) and os.path.isfile(hti_input_json): + jdata_hti = json.load(open(hti_result_json)) + jdata_hti_in = json.load(open(hti_input_json)) + t0, p0 = _get_hti_anchor_tp(jdata_hti, jdata_hti_in) + if t0 is not None: + info["T0"] = t0 + if p0 is not None: + info["p0"] = p0 with open(os.path.join(output_dir, "result.json"), "w") as f: f.write(json.dumps(info)) return info @@ -928,7 +939,16 @@ def refine_task(from_task, to_task, err): fp.write(from_task_list[back_map[ii]]) -def compute_task(job, inte_method, Eo, Eo_err, To, scheme="simpson", output_dir=None): +def compute_task( + job, + inte_method, + Eo, + Eo_err, + To, + scheme="simpson", + output_dir=None, + hti_path=None, +): # job = args.JOB with open(os.path.join(job, "ti_settings.json")) as f: jdata = json.load(f) @@ -941,9 +961,10 @@ def compute_task(job, inte_method, Eo, Eo_err, To, scheme="simpson", output_dir= To=To, scheme=scheme, output_dir=output_dir, + hti_path=hti_path, ) elif inte_method == "mbar": - info = post_tasks_mbar(job, jdata, Eo, output_dir=output_dir) + info = post_tasks_mbar(job, jdata, Eo, output_dir=output_dir, hti_path=hti_path) else: raise RuntimeError("unknow integration method") return info @@ -1175,6 +1196,7 @@ def handle_compute(args): To=args.To, scheme=args.scheme, output_dir=output_dir, + hti_path=hti_dir, ) # job = args.JOB # jdata = json.load(open(os.path.join(job, 'in.json'), 'r')) From 0063b28a382db0620d12ada44124b0c1152c7eb9 Mon Sep 17 00:00:00 2001 From: Yifan Li Date: Tue, 12 May 2026 16:43:19 -0400 Subject: [PATCH 2/2] fix: sync complete TI output handling changes --- dpti/ti.py | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/dpti/ti.py b/dpti/ti.py index fe4dc0c..11114e5 100755 --- a/dpti/ti.py +++ b/dpti/ti.py @@ -457,7 +457,6 @@ def post_tasks( scheme="simpson", shift=0.0, output_dir=None, - hti_path=None, ): equi_conf = get_task_file_abspath(iter_name, jdata["equi_conf"]) if natoms is None: @@ -696,7 +695,7 @@ def post_tasks( return info -def post_tasks_mbar(iter_name, jdata, Eo, natoms=None, output_dir=None, hti_path=None): +def post_tasks_mbar(iter_name, jdata, Eo, natoms=None, output_dir=None): equi_conf = jdata["equi_conf"] if natoms is None: natoms = get_natoms(equi_conf) @@ -846,18 +845,8 @@ def post_tasks_mbar(iter_name, jdata, Eo, natoms=None, output_dir=None, hti_path ), } info = {"start_point_info": info0, "end_point_info": info1, "data": data} - if hti_path is not None: - info["hti_path"] = os.path.abspath(hti_path) - hti_result_json = os.path.join(hti_path, "result.json") - hti_input_json = os.path.join(hti_path, "in.json") - if os.path.isfile(hti_result_json) and os.path.isfile(hti_input_json): - jdata_hti = json.load(open(hti_result_json)) - jdata_hti_in = json.load(open(hti_input_json)) - t0, p0 = _get_hti_anchor_tp(jdata_hti, jdata_hti_in) - if t0 is not None: - info["T0"] = t0 - if p0 is not None: - info["p0"] = p0 + with open(os.path.join(output_dir, "result"), "w") as f: + f.write(result) with open(os.path.join(output_dir, "result.json"), "w") as f: f.write(json.dumps(info)) return info @@ -939,16 +928,7 @@ def refine_task(from_task, to_task, err): fp.write(from_task_list[back_map[ii]]) -def compute_task( - job, - inte_method, - Eo, - Eo_err, - To, - scheme="simpson", - output_dir=None, - hti_path=None, -): +def compute_task(job, inte_method, Eo, Eo_err, To, scheme="simpson", output_dir=None): # job = args.JOB with open(os.path.join(job, "ti_settings.json")) as f: jdata = json.load(f) @@ -961,10 +941,9 @@ def compute_task( To=To, scheme=scheme, output_dir=output_dir, - hti_path=hti_path, ) elif inte_method == "mbar": - info = post_tasks_mbar(job, jdata, Eo, output_dir=output_dir, hti_path=hti_path) + info = post_tasks_mbar(job, jdata, Eo, output_dir=output_dir) else: raise RuntimeError("unknow integration method") return info @@ -1196,7 +1175,6 @@ def handle_compute(args): To=args.To, scheme=args.scheme, output_dir=output_dir, - hti_path=hti_dir, ) # job = args.JOB # jdata = json.load(open(os.path.join(job, 'in.json'), 'r'))