-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_usage.py
More file actions
45 lines (35 loc) · 2.01 KB
/
Copy pathexample_usage.py
File metadata and controls
45 lines (35 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from pathlib import Path
import argparse
from pdf_gr_conversion import convert_file_gr_to_small_gr
from pdf_coordination import analyze_file_first_shell
def main():
parser = argparse.ArgumentParser(description="Convert G(r) to g(r) and integrate first shell.")
parser.add_argument("--input", required=True, help="Input G(r) file, e.g. data/std_Si.gr")
parser.add_argument("--rho0", type=float, required=True, help="Number density in atoms/Å^3")
parser.add_argument("--output-g", default=None, help="Output g(r) file")
parser.add_argument("--output-plot", default=None, help="Output integration plot")
parser.add_argument("--output-data", default=None, help="Output txt file for the full integration plot data")
parser.add_argument("--output-region-data", default=None, help="Output txt file for integration-region-only data")
args = parser.parse_args()
input_file = Path(args.input)
output_g = Path(args.output_g) if args.output_g else input_file.with_name(input_file.stem + "_small_g.dat")
output_plot = Path(args.output_plot) if args.output_plot else input_file.with_name(input_file.stem + "_first_shell.png")
output_data = Path(args.output_data) if args.output_data else input_file.with_name(input_file.stem + "_first_shell_data.txt")
output_region_data = Path(args.output_region_data) if args.output_region_data else input_file.with_name(input_file.stem + "_first_shell_region.txt")
convert_file_gr_to_small_gr(input_file=input_file, output_file=output_g, rho0=args.rho0)
result = analyze_file_first_shell(
input_file=output_g,
rho0=args.rho0,
plot_file=output_plot,
data_file=output_data,
region_data_file=output_region_data,
)
print("First-shell analysis result:")
for k, v in result.items():
print(f"{k}: {v}")
print(f"Saved g(r): {output_g}")
print(f"Saved plot: {output_plot}")
print(f"Saved plot data: {output_data}")
print(f"Saved region data: {output_region_data}")
if __name__ == "__main__":
main()