Skip to content

Commit 91ebbf5

Browse files
authored
Merge pull request brucefan1983#1353 from brucefan1983/d3_MN
D3 MN
2 parents da61b81 + 887633f commit 91ebbf5

3 files changed

Lines changed: 67 additions & 15 deletions

File tree

4.24 KB
Binary file not shown.

tools/Miscellaneous/for_coding/for_perioidc_table/nep.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ heat transport, Phys. Rev. B. 104, 104309 (2021).
4040
namespace
4141
{
4242
const int MAX_NEURON = 120; // maximum number of neurons in the hidden layer
43-
const int MN = 2000; // maximum number of neighbors for one atom
43+
const int MN = 4000; // maximum number of neighbors for one atom
4444
const int NUM_OF_ABC = 80; // 3 + 5 + 7 + 9 + 11 + 13 + 15 + 17 for L_max = 8
4545
const int MAX_NUM_N = 17; // basis_size_radial+1 = 16+1
4646
const int MAX_DIM = 103;
@@ -2375,6 +2375,10 @@ void find_neighbor_list_large_box(
23752375
}
23762376
}
23772377
}
2378+
if (count_radial > MN) {
2379+
printf("count_radial > %d.\n", MN);
2380+
exit(1);
2381+
}
23782382
g_NN_radial[n1] = count_radial;
23792383
g_NN_angular[n1] = count_angular;
23802384
}
@@ -2461,6 +2465,10 @@ void find_neighbor_list_small_box(
24612465
}
24622466
}
24632467
}
2468+
if (count_radial > MN) {
2469+
printf("count_radial > %d.\n", MN);
2470+
exit(1);
2471+
}
24642472
g_NN_radial[n1] = count_radial;
24652473
g_NN_angular[n1] = count_angular;
24662474
}

tools/Miscellaneous/for_coding/for_perioidc_table/nep_data_toolkit.cpp

Lines changed: 58 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,33 @@ 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)
500+
{
501+
constexpr int num_metals = 8;
502+
std::string metals[num_metals] = {"Co", "Cr", "Fe", "Mn", "Mo", "Ni", "V", "W"};
503+
for (int nc = 0; nc < structures.size(); ++nc) {
504+
bool has_given_metal = false;
505+
bool has_F_or_O = false;
506+
507+
for (int n = 0; n < structures[nc].num_atom; ++n) {
508+
for (int k = 0; k < num_metals; ++k) {
509+
if (structures[nc].atom_symbol[n] == metals[k]) {
510+
has_given_metal = true;
511+
break;
512+
}
513+
}
514+
if (structures[nc].atom_symbol[n] == "F" || structures[nc].atom_symbol[n] == "O") {
515+
has_F_or_O = true;
516+
break;
517+
}
518+
}
519+
520+
if (has_given_metal && has_F_or_O) {
521+
structures[nc].energy_weight = 0;
522+
}
523+
}
524+
}
525+
499526
static void set_box_to_1000(std::vector<Structure>& structures)
500527
{
501528
for (int nc = 0; nc < structures.size(); ++nc) {
@@ -615,6 +642,9 @@ static void add_d3(std::vector<Structure>& structures, const std::string& functi
615642
std::vector<std::string> atom_symbols = get_atom_symbols("nep.txt");
616643
for (int nc = 0; nc < structures.size(); ++nc) {
617644
calculate_one_structure(nep3, atom_symbols, structures[nc], functional, 12, 6);
645+
if ((nc+1) % 10000 == 0) {
646+
printf("%d stuctures finished.\n", nc+1);
647+
}
618648
}
619649
}
620650

@@ -853,7 +883,7 @@ static void split_with_sid(const std::vector<Structure>& structures)
853883
{
854884
std::ofstream output_ch("../ch/train.xyz");
855885
std::ofstream output_unep1("../unep1/train.xyz");
856-
std::ofstream output_hydrate("../hydrate/train.xyz");
886+
std::ofstream output_omat2("../omat2/train.xyz");
857887
std::ofstream output_chonps("../chonps/train.xyz");
858888
std::ofstream output_spice("../spice/train.xyz");
859889
std::ofstream output_water("../water/train.xyz");
@@ -863,10 +893,10 @@ static void split_with_sid(const std::vector<Structure>& structures)
863893
std::ofstream output_ani1xnr("../ani1xnr/train.xyz");
864894
std::ofstream output_sse_vasp("../sse_vasp/train.xyz");
865895
std::ofstream output_sse_abacus("../sse_abacus/train.xyz");
866-
std::ofstream output_cspbx("../cspbx/train.xyz");
896+
std::ofstream output_omol25("../omol25/train.xyz");
867897
int num_ch = 0;
868898
int num_unep1 = 0;
869-
int num_hydrate = 0;
899+
int num_omat2 = 0;
870900
int num_chonps = 0;
871901
int num_spice = 0;
872902
int num_omat = 0;
@@ -876,17 +906,17 @@ static void split_with_sid(const std::vector<Structure>& structures)
876906
int num_ani1xnr = 0;
877907
int num_sse_vasp = 0;
878908
int num_sse_abacus = 0;
879-
int num_cspbx = 0;
909+
int num_omol25 = 0;
880910
for (int nc = 0; nc < structures.size(); ++nc) {
881911
if (structures[nc].sid == "ch") {
882912
write_one_structure(output_ch, structures[nc]);
883913
num_ch++;
884914
} else if (structures[nc].sid == "unep1") {
885915
write_one_structure(output_unep1, structures[nc]);
886916
num_unep1++;
887-
} else if (structures[nc].sid == "hydrate") {
888-
write_one_structure(output_hydrate, structures[nc]);
889-
num_hydrate++;
917+
} else if (structures[nc].sid == "omat2") {
918+
write_one_structure(output_omat2, structures[nc]);
919+
num_omat2++;
890920
} else if (structures[nc].sid == "chonps") {
891921
write_one_structure(output_chonps, structures[nc]);
892922
num_chonps++;
@@ -914,14 +944,14 @@ static void split_with_sid(const std::vector<Structure>& structures)
914944
} else if (structures[nc].sid == "omat") {
915945
write_one_structure(output_omat, structures[nc]);
916946
num_omat++;
917-
} else if (structures[nc].sid == "cspbx") {
918-
write_one_structure(output_cspbx, structures[nc]);
919-
num_cspbx++;
947+
} else if (structures[nc].sid == "omol25") {
948+
write_one_structure(output_omol25, structures[nc]);
949+
num_omol25++;
920950
}
921951
}
922952
output_ch.close();
923953
output_unep1.close();
924-
output_hydrate.close();
954+
output_omat2.close();
925955
output_chonps.close();
926956
output_spice.close();
927957
output_omat.close();
@@ -931,10 +961,10 @@ static void split_with_sid(const std::vector<Structure>& structures)
931961
output_ani1xnr.close();
932962
output_sse_abacus.close();
933963
output_sse_vasp.close();
934-
output_cspbx.close();
964+
output_omol25.close();
935965
std::cout << "Number of structures written into ch.xyz = " << num_ch << std::endl;
936966
std::cout << "Number of structures written into unep1.xyz = " << num_unep1 << std::endl;
937-
std::cout << "Number of structures written into hydrate.xyz = " << num_hydrate << std::endl;
967+
std::cout << "Number of structures written into omat2.xyz = " << num_omat2 << std::endl;
938968
std::cout << "Number of structures written into chonps.xyz = " << num_chonps << std::endl;
939969
std::cout << "Number of structures written into spice.xyz = " << num_spice << std::endl;
940970
std::cout << "Number of structures written into water.xyz = " << num_water << std::endl;
@@ -944,7 +974,7 @@ static void split_with_sid(const std::vector<Structure>& structures)
944974
std::cout << "Number of structures written into ani1xnr.xyz = " << num_ani1xnr << std::endl;
945975
std::cout << "Number of structures written into sse_abacus.xyz = " << num_sse_abacus << std::endl;
946976
std::cout << "Number of structures written into sse_vasp.xyz = " << num_sse_vasp << std::endl;
947-
std::cout << "Number of structures written into cspbx.xyz = " << num_cspbx << std::endl;
977+
std::cout << "Number of structures written into omol25.xyz = " << num_omol25 << std::endl;
948978
}
949979

950980
static void fps(std::vector<Structure>& structures, double distance_square_min, int dim)
@@ -1195,6 +1225,7 @@ int main(int argc, char* argv[])
11951225
std::cout << "13: get valid structures\n";
11961226
std::cout << "14: calculate MAEs and RMSEs\n";
11971227
std::cout << "15: split according to neighbor counts\n";
1228+
std::cout << "16: set energy_weight to zero for +U systems\n";
11981229
std::cout << "====================================================\n";
11991230

12001231
std::cout << "Please choose a number based on your purpose: ";
@@ -1403,6 +1434,19 @@ int main(int argc, char* argv[])
14031434
std::cout << "Number of structures read from "
14041435
<< input_filename + " = " << structures_input.size() << std::endl;
14051436
split_according_to_neighbor_counts(structures_input, radial_threshold, angular_threshold);
1437+
} else if (option == 16) {
1438+
std::cout << "Please enter the input xyz filename: ";
1439+
std::string input_filename;
1440+
std::cin >> input_filename;
1441+
std::cout << "Please enter the output xyz filename: ";
1442+
std::string output_filename;
1443+
std::cin >> output_filename;
1444+
std::vector<Structure> structures_input;
1445+
read(input_filename, structures_input);
1446+
std::cout << "Number of structures read from "
1447+
<< input_filename + " = " << structures_input.size() << std::endl;
1448+
set_energy_weight_to_zero_if_has_U(structures_input);
1449+
write(output_filename, structures_input);
14061450
} else {
14071451
std::cout << "This is an invalid option.";
14081452
exit(1);

0 commit comments

Comments
 (0)