|
4 | 4 | import matplotlib.pyplot as plt |
5 | 5 | from scipy.interpolate import interp1d |
6 | 6 |
|
| 7 | +input_file = None |
| 8 | +output_file = None |
| 9 | +output_png = None |
| 10 | + |
7 | 11 | current_dir = os.getcwd() |
8 | 12 |
|
9 | 13 | if os.path.exists(os.path.join(current_dir, "ElecStaticPot.cube")): |
|
15 | 19 | dir_path = os.path.join(current_dir, dir_name) |
16 | 20 |
|
17 | 21 | if os.path.isdir(dir_path) and dir_name.startswith("OUT."): |
18 | | - input_file = os.path.join(dir_path, "ElecStaticPot.cube") |
19 | | - output_file = os.path.join(dir_path, "ElecStaticPot_AVE") |
20 | | - output_png = os.path.join(dir_path, "ElecStaticPot-vs-Z.png") |
21 | | - if os.path.exists(input_file): |
| 22 | + candidate_file = os.path.join(dir_path, "ElecStaticPot.cube") |
| 23 | + if os.path.exists(candidate_file): |
| 24 | + input_file = candidate_file |
| 25 | + output_file = os.path.join(dir_path, "ElecStaticPot_AVE") |
| 26 | + output_png = os.path.join(dir_path, "ElecStaticPot-vs-Z.png") |
22 | 27 | print(f"Processeding: {input_file}") |
23 | 28 | break |
24 | | - else: |
25 | | - print(f"File does not exist: {input_file}") |
26 | | - sys.exit() |
27 | | - |
| 29 | + |
| 30 | +if input_file is None: |
| 31 | + print("Error: 'ElecStaticPot.cube' was not found in the current directory or any 'OUT.*' subdirectories.", file=sys.stderr) |
| 32 | + print("Please check if ABACUS has completed successfully with 'out_pot' enabled (e.g., set to 2).", file=sys.stderr) |
| 33 | + sys.exit(1) |
| 34 | + |
| 35 | + |
28 | 36 | with open(input_file, 'r') as inpt: |
29 | 37 | temp = inpt.readlines() |
30 | 38 |
|
|
0 commit comments