From a4220aee18a6ac9d39c5b5ea9466e74a806cbd98 Mon Sep 17 00:00:00 2001 From: Evgeny Blokhin Date: Sat, 11 Jan 2025 16:06:08 +0100 Subject: [PATCH] Extend examples --- examples/submit_any_engine_input.py | 36 +++++++++++++++++ examples/submit_fullprof_input.py | 61 +++++++++++++++++++++++++++++ examples/submit_topas_input.py | 22 ++++++++--- 3 files changed, 113 insertions(+), 6 deletions(-) create mode 100644 examples/submit_any_engine_input.py create mode 100644 examples/submit_fullprof_input.py diff --git a/examples/submit_any_engine_input.py b/examples/submit_any_engine_input.py new file mode 100644 index 0000000..07ef718 --- /dev/null +++ b/examples/submit_any_engine_input.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 + +import os +import argparse + +from yascheduler import Yascheduler + + +parser = argparse.ArgumentParser() +parser.add_argument("-f", dest="file", action="store", type=str, required=True) +parser.add_argument("-e", dest="engine", action="store", type=str, required=True) +parser.add_argument("-l", dest="localrepo", action="store", type=bool, required=False, default=False) +args = parser.parse_args() + +input_data = {} +yac = Yascheduler() +assert args.engine in yac.config.engines + +target = os.path.abspath(args.file) +work_folder = os.path.dirname(target) +with open(target, encoding="utf-8") as f: + MAIN_INPUT = f.read() + +if args.localrepo: + input_data["local_folder"] = None + print("**To save calc in a local repo**") +else: + input_data["local_folder"] = work_folder + print("**To save calc in an input folder**") + +input_data[yac.config.engines[args.engine].input_files[0]] = MAIN_INPUT +for inp in yac.config.engines[args.engine].input_files[1:]: + input_data[inp] = "" + +result = yac.queue_submit_task("test calc", input_data, args.engine) +print(result) diff --git a/examples/submit_fullprof_input.py b/examples/submit_fullprof_input.py new file mode 100644 index 0000000..8f7cc5f --- /dev/null +++ b/examples/submit_fullprof_input.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python3 +"""Submit FP task""" + +from yascheduler import Yascheduler + +LABEL = "Al2O3 XRPD pattern" + +PATTERN_REQUEST = """COMM Corindon Al2O3 +! Files => DAT-file: corindon, PCR-file: corindonx +!Job Npr Nph Nba Nex Nsc Nor Dum Iwg Ilo Ias Res Ste Nre Cry Uni Cor Opt Aut + 2 5 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 +! +!Ipr Ppl Ioc Mat Pcr Ls1 Ls2 Ls3 NLI Prf Ins Rpa Sym Hkl Fou Sho Ana + 0 0 1 0 1 0 0 0 0 2 0 0 0 0 0 0 1 +! +! lambda1 Lambda2 Ratio Bkpos Wdt Cthm muR AsyLim Rpolarz ->Patt# 1 +1.540596 1.540596 0.50 65.00 20.00 0.7998 0.00 40.00 0.0000 +! +!NCY Eps R_at R_an R_pr R_gl Thmin Step Thmax PSD Sent0 + 1 0.01 0.65 0.65 0.35 0.65 10.0000 0.100000 175.0000 0.000 0.000 +! + 0 !Number of refined parameters +! +! Zero Code SyCos Code SySin Code Lambda Code MORE ->Patt# 1 +-0.090 21.00 0.0000 0.00 0.0000 0.00 0.0000 0.0000 0 +! Background coefficients/codes for Pattern# 1 +21.00 -5.66 -9.36 8.30 37.04 -24.55 + 51.00 61.00 71.00 81.00 31.00 41.00 +!------------------------------------------------------------------------------- +! Data for PHASE number: 1 +!------------------------------------------------------------------------------- +Al2O3 +! +!Nat Dis Ang Pr1 Pr2 Pr3 Jbt Irf Isy Str Furth ATZ Nvk Npr More + 2 0 0 0.0 0.0 1.0 0 0 0 0 0 611.760 0 5 0 +! +R -3 c <--Space group symbol +!Atom Typ X Y Z Biso Occ In Fin N_t Spc /Codes +AL AL+3 0.00000 0.00000 0.35218 0.4000 0.33333 0 0 0 0 + 0.00 0. 00 171.00 191.00 0.00 +O O-2 0.30610 0.00000 0.25000 0.5000 0.50000 0 0 0 0 + 181.00 0.00 0.00 201.00 0.00 +!-------> Profile Parameters for Pattern # 1 +! Scale Shape1 Bov Str1 Str2 Str3 Strain-Model +0.28556E-02 0.5000 0.00000 0.00000 0.00000 0.00000 0 + 11.00000 161.000 0.000 0.000 0.000 0.000 +! U V W X Y GauSiz LorSiz Size-Model + 0.005865 0.025089 0.018587 0.000000 0.000000 0.000000 0.000000 0 + 141.000 151.000 131.000 0.000 0.000 0.000 0.000 +! a b c alpha beta gamma #Cell Info + 4.75758 4.75758 12.9876 90.000 90.000 120.000 + 111.000 111.000 121.000 0.000 0.000 111.000 +! Pref1 Pref2 Asy1 Asy2 Asy3 Asy4 + 0.00000 0.00000 0.023 0.061 0.00000 0.00000 + 0.00 0.00 91.00 101.00 0.00 0.00 +""" + +yac = Yascheduler() +result = yac.queue_submit_task(LABEL, {"calc.pcr": PATTERN_REQUEST}, "fullprof") +print(LABEL) +print(result) diff --git a/examples/submit_topas_input.py b/examples/submit_topas_input.py index d6a5789..af4942f 100644 --- a/examples/submit_topas_input.py +++ b/examples/submit_topas_input.py @@ -3,13 +3,21 @@ from yascheduler import Yascheduler -LABEL = "SrTiO3 XRPD pattern" +LABEL = "SrTiO3 XRPD dI" PATTERN_REQUEST = """ -iters 0 -yobs_eqn !x = 0; min 10 max 175 del 0.1 - -Out_X_Ycalc( calc.xy ) +macro Out_Dif(file) +{ + out file phase_out file load out_record out_fmt out_eqn + { + " %11.5f" = D_spacing; + " %11.5f\n" = I_after_scale_pks; + } +} + +iters 1 +yobs_eqn = 0; min 0 max 80 del 0.01 +LP_Factor(0) lam ymin_on_ymax 0.0001 @@ -24,10 +32,12 @@ site O x 0.00000 y 0.00000 z 2.00000 occ O 1 beq 1 site Sr x 2.00000 y 2.00000 z 2.00000 occ Sr 1 beq 1 site Ti x 0.00000 y 0.00000 z 0.00000 occ Ti 1 beq 1 + +Out_Dif( calc.xy ) """ yac = Yascheduler() -result = yac.queue_submit_task(LABEL, {"calc.inp": PATTERN_REQUEST, "structure.inc": "", "input.xy: ""}, "topas") +result = yac.queue_submit_task(LABEL, {"calc.inp": PATTERN_REQUEST, "structure.inc": ""}, "topas") print(LABEL) print(result)