-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build an iterative phonon flow #306
base: main
Are you sure you want to change the base?
Changes from 33 commits
6a3a342
fc9e7a5
25a95b4
4ca1d1c
55562d5
e5787c7
4f3d6c4
52deaa2
6ba11e0
855dccc
fcf0cda
1958654
3c0d6a8
f85baa3
8b54a5c
af16c12
5e09a4f
7094b93
1bd5d49
295478e
f7ad583
e17fc92
75de5db
829e674
e2bc0eb
bad024c
00e20cd
c80a5ed
9444190
d98727e
215c0de
1944eed
ec68520
d2a1485
834e175
8c5aa8a
13b1229
6eb620f
bdf0c8b
c59f853
453c75d
624f762
21f8ca2
43f95d6
36af259
a8e065b
6705f1b
71c59d9
82cd1e5
512cad7
1163b83
301a378
e562ce3
74da25a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -183,8 +183,10 @@ def make( | |
jobs.append(mlip_fit_job) | ||
|
||
return Flow(jobs=jobs, output=mlip_fit_job.output, name=self.name) | ||
# this will only run if train.extxyz and test.extxyz files are present in the database_dir | ||
|
||
# this will only run if train.extxyz and test.extxyz files are present in the database_dir | ||
# TODO: shouldn't this be the exception rather then the default run?! | ||
# TODO: I assume we always want to use data from before? | ||
if isinstance(self.database_dir, str): | ||
self.database_dir = Path(self.database_dir) | ||
|
||
|
@@ -300,6 +302,33 @@ def make( | |
logging.info( | ||
f"File {file_name} has been copied to {destination_file_path}" | ||
) | ||
if len(self.pre_xyz_files) == 2: | ||
# join to one file and then split again afterwards | ||
# otherwise, split percentage will not be true | ||
destination_file_path = os.path.join( | ||
current_working_directory, "vasp_ref.extxyz" | ||
) | ||
for file_name in self.pre_xyz_files: | ||
# TODO: if it makes sense to remove isolated atoms from other files as well | ||
atoms_list = ase.io.read( | ||
os.path.join(self.pre_database_dir, file_name), index=":" | ||
) | ||
new_atoms_list = [ | ||
atoms | ||
for atoms in atoms_list | ||
if atoms.info["config_type"] != "IsolatedAtom" | ||
] | ||
|
||
ase.io.write(destination_file_path, new_atoms_list, append=True) | ||
|
||
logging.info( | ||
f"File {self.pre_xyz_files[0]} has been copied to {destination_file_path}" | ||
) | ||
Comment on lines
+316
to
+326
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this a good universal solution? maybe, i can reduce it to just one set of isolatedAtom energies to avoid failures |
||
|
||
elif len(self.pre_xyz_files) > 2: | ||
raise ValueError( | ||
"Please provide a train and a test extxyz file (two files in total) for the pre_xyz_files." | ||
) | ||
|
||
vaspoutput_2_extended_xyz( | ||
path_to_vasp_static_calcs=list_of_vasp_calc_dirs, | ||
|
@@ -310,28 +339,13 @@ def make( | |
atom_wise_regularization=self.atom_wise_regularization, | ||
) | ||
|
||
# TODO: remove too many isolated atoms | ||
write_after_distillation_data_split( | ||
self.distillation, self.force_max, self.split_ratio | ||
) | ||
|
||
# Merging database | ||
if self.pre_database_dir and os.path.exists(self.pre_database_dir): | ||
if len(self.pre_xyz_files) == 2: | ||
files_new = ["train.extxyz", "test.extxyz"] | ||
for file_name, file_new in zip(self.pre_xyz_files, files_new): | ||
with ( | ||
open( | ||
os.path.join(self.pre_database_dir, file_name) | ||
) as pre_xyz_file, | ||
open(file_new, "a") as xyz_file, | ||
): | ||
xyz_file.write(pre_xyz_file.read()) | ||
logging.info(f"File {file_name} has been copied to {file_new}") | ||
|
||
elif len(self.pre_xyz_files) > 2: | ||
raise ValueError( | ||
"Please provide a train and a test extxyz file (two files in total) for the pre_xyz_files." | ||
) | ||
Comment on lines
-318
to
-334
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. did not keep the split ratio constant |
||
# TODO: does a merge happen here? | ||
if self.regularization: | ||
base_dir = os.getcwd() | ||
folder_name = os.path.join(base_dir, "without_regularization") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add warning that default scale factor range is used