Skip to content

Commit 8388340

Browse files
authored
Merge pull request brucefan1983#1334 from brucefan1983/tool-neighbor
my tool
2 parents 3f221bd + 58342ff commit 8388340

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

128 Bytes
Binary file not shown.

tools/Miscellaneous/for_coding/for_perioidc_table/nep_data_toolkit.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,35 @@ static void split_into_accurate_and_inaccurate(
702702
std::cout << "Number of structures written into inaccurate.xyz = " << num2 << std::endl;
703703
}
704704

705+
static void split_according_to_neighbor_counts(
706+
const std::vector<Structure>& structures,
707+
int radial_threshold,
708+
int angular_threshold)
709+
{
710+
std::ifstream input_neighbor("neighbor.txt");
711+
std::ofstream output_small("neighbor_counts_small.xyz");
712+
std::ofstream output_large("neighbor_counts_large.xyz");
713+
int num1 = 0;
714+
int num2 = 0;
715+
for (int nc = 0; nc < structures.size(); ++nc) {
716+
int count_radial;
717+
int count_angular;
718+
input_neighbor >> count_radial >> count_angular;
719+
if (count_radial > radial_threshold || count_angular > angular_threshold) {
720+
write_one_structure(output_large, structures[nc]);
721+
num1++;
722+
} else{
723+
write_one_structure(output_small, structures[nc]);
724+
num2++;
725+
}
726+
}
727+
input_neighbor.close();
728+
output_small.close();
729+
output_large.close();
730+
std::cout << "Number of structures written into neighbor_counts_large.xyz = " << num1 << std::endl;
731+
std::cout << "Number of structures written into neighbor_counts_small.xyz = " << num2 << std::endl;
732+
}
733+
705734
static void calculate_mae_and_rmse_one(
706735
const std::string& filename,
707736
const std::string& units,
@@ -1165,6 +1194,7 @@ int main(int argc, char* argv[])
11651194
std::cout << "12: change box to 1000\n";
11661195
std::cout << "13: get valid structures\n";
11671196
std::cout << "14: calculate MAEs and RMSEs\n";
1197+
std::cout << "15: split according to neighbor counts\n";
11681198
std::cout << "====================================================\n";
11691199

11701200
std::cout << "Please choose a number based on your purpose: ";
@@ -1358,6 +1388,21 @@ int main(int argc, char* argv[])
13581388
get_valid_structures(structures_input, energy_threshold, force_threshold, stress_threshold);
13591389
} else if (option == 14) {
13601390
calculate_mae_and_rmse();
1391+
} else if (option == 15) {
1392+
std::cout << "Please enter the input xyz filename: ";
1393+
std::string input_filename;
1394+
std::cin >> input_filename;
1395+
std::cout << "Please enter the radial neighbor count threshold: ";
1396+
int radial_threshold;
1397+
std::cin >> radial_threshold;
1398+
std::cout << "Please enter the angular neighbor count threshold: ";
1399+
int angular_threshold;
1400+
std::cin >> angular_threshold;
1401+
std::vector<Structure> structures_input;
1402+
read(input_filename, structures_input);
1403+
std::cout << "Number of structures read from "
1404+
<< input_filename + " = " << structures_input.size() << std::endl;
1405+
split_according_to_neighbor_counts(structures_input, radial_threshold, angular_threshold);
13611406
} else {
13621407
std::cout << "This is an invalid option.";
13631408
exit(1);

0 commit comments

Comments
 (0)