Skip to content

Commit d4645ce

Browse files
authored
Merge pull request brucefan1983#1356 from brucefan1983/removeU
simply remove +U structures
2 parents 442dbbf + 7d3be60 commit d4645ce

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed
0 Bytes
Binary file not shown.

tools/Miscellaneous/for_coding/for_perioidc_table/nep_data_toolkit.cpp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -496,10 +496,16 @@ static void set_energy_weight_to_zero(std::vector<Structure>& structures)
496496
}
497497
}
498498

499-
static void set_energy_weight_to_zero_if_has_U(std::vector<Structure>& structures)
499+
static void get_valid_structures_without_U(const std::vector<Structure>& structures)
500500
{
501+
std::ofstream output_valid("valid.xyz");
502+
std::ofstream output_invalid("invalid.xyz");
503+
int num1 = 0;
504+
int num2 = 0;
505+
501506
constexpr int num_metals = 8;
502507
std::string metals[num_metals] = {"Co", "Cr", "Fe", "Mn", "Mo", "Ni", "V", "W"};
508+
503509
for (int nc = 0; nc < structures.size(); ++nc) {
504510
bool has_given_metal = false;
505511
bool has_F_or_O = false;
@@ -518,9 +524,17 @@ static void set_energy_weight_to_zero_if_has_U(std::vector<Structure>& structure
518524
}
519525

520526
if (has_given_metal && has_F_or_O) {
521-
structures[nc].energy_weight = 0;
527+
write_one_structure(output_invalid, structures[nc]);
528+
num1++;
529+
} else{
530+
write_one_structure(output_valid, structures[nc]);
531+
num2++;
522532
}
523533
}
534+
output_valid.close();
535+
output_invalid.close();
536+
std::cout << "Number of structures written into valid.xyz = " << num2 << std::endl;
537+
std::cout << "Number of structures written into invalid.xyz = " << num1 << std::endl;
524538
}
525539

526540
static void set_box_to_1000(std::vector<Structure>& structures)
@@ -1225,7 +1239,7 @@ int main(int argc, char* argv[])
12251239
std::cout << "13: get valid structures\n";
12261240
std::cout << "14: calculate MAEs and RMSEs\n";
12271241
std::cout << "15: split according to neighbor counts\n";
1228-
std::cout << "16: set energy_weight to zero for +U systems\n";
1242+
std::cout << "16: get valid structures without U\n";
12291243
std::cout << "====================================================\n";
12301244

12311245
std::cout << "Please choose a number based on your purpose: ";
@@ -1438,15 +1452,11 @@ int main(int argc, char* argv[])
14381452
std::cout << "Please enter the input xyz filename: ";
14391453
std::string input_filename;
14401454
std::cin >> input_filename;
1441-
std::cout << "Please enter the output xyz filename: ";
1442-
std::string output_filename;
1443-
std::cin >> output_filename;
14441455
std::vector<Structure> structures_input;
14451456
read(input_filename, structures_input);
14461457
std::cout << "Number of structures read from "
14471458
<< input_filename + " = " << structures_input.size() << std::endl;
1448-
set_energy_weight_to_zero_if_has_U(structures_input);
1449-
write(output_filename, structures_input);
1459+
get_valid_structures_without_U(structures_input);
14501460
} else {
14511461
std::cout << "This is an invalid option.";
14521462
exit(1);

0 commit comments

Comments
 (0)