7
7
import shutil
8
8
from pathlib import Path
9
9
10
- import numpy as np
10
+ from ase . constraints import voigt_6_to_full_3x3_stress
11
11
from ase .io import read , write
12
12
from atomate2 .utils .path import strip_hostname
13
13
@@ -62,16 +62,16 @@ def gap_hyperparameter_constructor(
62
62
gap fit input parameter string.
63
63
"""
64
64
# convert gap_parameter_dict to representation compatible with gap
65
- if atoms_energies and atoms_symbols is not None :
66
- e0 = ":" .join (
67
- [
68
- f"{ iso_atom } :{ iso_energy } "
69
- for iso_atom , iso_energy in zip (atoms_symbols , atoms_energies )
70
- ]
71
- )
65
+ # if atoms_energies and atoms_symbols is not None:
66
+ # e0 = ":".join(
67
+ # [
68
+ # f"{iso_atom}:{iso_energy}"
69
+ # for iso_atom, iso_energy in zip(atoms_symbols, atoms_energies)
70
+ # ]
71
+ # )
72
72
73
- # Update the isolated atom energy argument
74
- gap_parameter_dict ["general" ].update ({"e0" : e0 })
73
+ # Update the isolated atom energy argument
74
+ # gap_parameter_dict["general"].update({"e0": e0})
75
75
76
76
general = [f"{ key } ={ value } " for key , value in gap_parameter_dict ["general" ].items ()]
77
77
@@ -136,7 +136,11 @@ def get_list_of_vasp_calc_dirs(flow_output):
136
136
return list_of_vasp_calc_dirs
137
137
138
138
139
- def outcar_2_extended_xyz (path_to_vasp_static_calcs : list , xyz_file : str | None = None ):
139
+ def outcar_2_extended_xyz (
140
+ path_to_vasp_static_calcs : list ,
141
+ config_types : list [str ] | None = None ,
142
+ xyz_file : str | None = None ,
143
+ ):
140
144
"""
141
145
Parse all VASP OUTCARs and generates a trainGAP.xyz.
142
146
@@ -149,16 +153,27 @@ def outcar_2_extended_xyz(path_to_vasp_static_calcs: list, xyz_file: str | None
149
153
List of VASP static calculation directories.
150
154
xyz_file: str or None
151
155
a possibly already existing xyz file.
156
+ config_types: list[str] or None
157
+ list of config_types.
152
158
"""
153
- for path in path_to_vasp_static_calcs :
159
+ if config_types is None :
160
+ config_types = ["bulk" ] * len (path_to_vasp_static_calcs )
161
+
162
+ for path , config_type in zip (path_to_vasp_static_calcs , config_types ):
154
163
# strip hostname if it exists in the path
155
- path_without_hostname = Path (strip_hostname (path )).joinpath ("OUTCAR .gz" )
164
+ path_without_hostname = Path (strip_hostname (path )).joinpath ("vasprun.xml .gz" )
156
165
# read the outcar
157
166
file = read (path_without_hostname , index = ":" )
158
167
for i in file :
159
- xx , yy , zz , yz , xz , xy = - i . calc . results [ "stress" ] * i .get_volume ()
160
- i .info ["virial " ] = np . array ([( xx , xy , xz ), ( xy , yy , yz ), ( xz , yz , zz )] )
168
+ virial_list = - voigt_6_to_full_3x3_stress ( i . get_stress ()) * i .get_volume ()
169
+ i .info ["REF_virial " ] = " " . join ( map ( str , virial_list . flatten ()) )
161
170
del i .calc .results ["stress" ]
171
+ i .arrays ["REF_forces" ] = i .calc .results ["forces" ]
172
+ del i .calc .results ["forces" ]
173
+ i .info ["REF_energy" ] = i .calc .results ["free_energy" ]
174
+ del i .calc .results ["energy" ]
175
+ del i .calc .results ["free_energy" ]
176
+ i .info ["config_type" ] = config_type
162
177
i .pbc = True
163
178
if xyz_file is not None :
164
179
shutil .copy2 (xyz_file , os .getcwd ())
0 commit comments