Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions source/source_lcao/module_deepks/deepks_basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ void DeePKS_domain::load_model(const std::string& model_file, torch::jit::script
ModuleBase::TITLE("DeePKS_domain", "load_model");
ModuleBase::timer::tick("DeePKS_domain", "load_model");

// check whether file exists
std::ifstream ifs(model_file.c_str());
if (!ifs)
{
ModuleBase::timer::tick("DeePKS_domain", "load_model");
ModuleBase::WARNING_QUIT("DeePKS_domain::load_model", "No model file named " + model_file + ", please check!");
return;
}
ifs.close();
try
{
model = torch::jit::load(model_file);
Expand Down
5 changes: 5 additions & 0 deletions source/source_lcao/module_deepks/deepks_vdrpre.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ void DeePKS_domain::cal_vdr_precalc(const int nlocal,
int iRx = DeePKS_domain::mapping_R(dR.x);
int iRy = DeePKS_domain::mapping_R(dR.y);
int iRz = DeePKS_domain::mapping_R(dR.z);
// Make sure the index is in range we need to save
if (iRx >= R_size || iRy >= R_size || iRz >= R_size)
{
return; // to next loop
}

for (int iw1 = 0; iw1 < nw1_tot; ++iw1)
{
Expand Down
20 changes: 10 additions & 10 deletions source/source_lcao/module_deepks/test/LCAO_deepks_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ void test_deepks<T>::check_vdrpre()
std::vector<torch::Tensor> gevdm;
torch::Tensor vdrpre;
DeePKS_domain::cal_gevdm(ucell.nat, this->ld.inlmax, this->ld.inl2l, this->ld.pdm, gevdm);
// normally use hR to get R_size, here use phialpha[0] only for test case
int R_size = DeePKS_domain::get_R_size<double>(*(this->ld.phialpha[0]));
// normally use hR to get R_size, here use 3 instead for Bravo lattice R in [-1,0,1]
int R_size = 3;
DeePKS_domain::cal_vdr_precalc(PARAM.sys.nlocal,
this->ld.lmaxd,
this->ld.inlmax,
Expand All @@ -317,8 +317,8 @@ void test_deepks<T>::check_vdrpre()
ParaO,
Test_Deepks::GridD,
vdrpre);
// vdrpre is large, we only check the main element in Bravo lattice vector (0, 0, 0)
torch::Tensor vdrpre_sliced = vdrpre.slice(0, 0, 1, 1).slice(1, 0, 1, 1).slice(2, 0, 1, 1);
// vdrpre is large, we only check the main element in Bravo lattice vector (0, 0, 0) and (1, 0, 0)
torch::Tensor vdrpre_sliced = vdrpre.slice(0, 0, 2, 1).slice(1, 0, 1, 1).slice(2, 0, 1, 1);
DeePKS_domain::check_tensor<double>(vdrpre_sliced, "vdr_precalc.dat", 0); // 0 for rank
this->compare_with_ref("vdr_precalc.dat", "vdrpre_ref.dat");
}
Expand Down Expand Up @@ -462,8 +462,8 @@ void test_deepks<T>::compare_with_ref(const std::string f1, const std::string f2
file2 >> word2;
if ((word1[0] - '0' >= 0 && word1[0] - '0' < 10) || word1[0] == '-')
{
double num1 = std::stof(word1);
double num2 = std::stof(word2);
double num1 = std::stod(word1);
double num2 = std::stod(word2);
if (std::abs(num1 - num2) > test_thr)
{
this->failed_check += 1;
Expand All @@ -476,10 +476,10 @@ void test_deepks<T>::compare_with_ref(const std::string f1, const std::string f2
{
std::string word1_str = word1.substr(1, word1.size() - 2);
std::string word2_str = word2.substr(1, word2.size() - 2);
double word1_real = std::stof(word1_str.substr(0, word1_str.find(',')));
double word1_imag = std::stof(word1_str.substr(word1_str.find(',') + 1));
double word2_real = std::stof(word2_str.substr(0, word2_str.find(',')));
double word2_imag = std::stof(word2_str.substr(word2_str.find(',') + 1));
double word1_real = std::stod(word1_str.substr(0, word1_str.find(',')));
double word1_imag = std::stod(word1_str.substr(word1_str.find(',') + 1));
double word2_real = std::stod(word2_str.substr(0, word2_str.find(',')));
double word2_imag = std::stod(word2_str.substr(word2_str.find(',') + 1));
if (std::abs(word1_real - word2_real) > test_thr || std::abs(word1_imag - word2_imag) > test_thr)
{
this->failed_check += 1;
Expand Down
2 changes: 1 addition & 1 deletion tests/09_DeePKS/100_NO_GO_deepks_UT/E_delta_bands_ref.dat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-0.007602894356
-0.08058091803
2 changes: 1 addition & 1 deletion tests/09_DeePKS/100_NO_GO_deepks_UT/E_delta_ref.dat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-0.1377737748
-0.3135463017
10 changes: 5 additions & 5 deletions tests/09_DeePKS/100_NO_GO_deepks_UT/F_delta_ref.dat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-0.0003706779237 8.336190151e-06 0.001631126762
9.708686281e-05 1.690692748e-05 -0.005582105144
-0.003585987888 2.035424355e-05 0.001126977947
0.001908170566 0.00362839126 0.001398407512
0.001951408382 -0.003673988622 0.001425592923
-0.001966690223 0.0003863484866 -0.0002775679931
0.0001490387822 0.0001336996716 -0.010866736
-0.009536649342 -0.0001507865891 0.002944084409
0.005665599528 0.00917496669 0.003914146719
0.005688701256 -0.009544228259 0.004286072869
101 changes: 20 additions & 81 deletions tests/09_DeePKS/100_NO_GO_deepks_UT/descriptor_ref.dat
Original file line number Diff line number Diff line change
@@ -1,85 +1,24 @@
C atom_index 1 n_descriptor 117
1.324860831 0.5600247713 0.08683995213 0.002391330993 0.0002024558499 0.001941592692 0.0009357014709 0.001285464024
0.0003747383084 0.0003981271759 3.380417477e-05 6.431403684e-05 2.556932909e-06 0.8695818932 0.916560116 0.9348722622
0.5671462004 0.5827725011 0.6038780645 0.2225610471 0.2375338231 0.2689329217 0.05107183751 0.0550662635
0.06725417066 0.0274640254 0.02763567155 0.03036736102 0.009236827855 0.009784456469 0.01047491505 0.007756248553
0.008939652399 0.009556260509 0.00269143549 0.002988436311 0.0030097818 0.002698641498 0.00275369074 0.002809538324
0.0004430358294 0.000473965429 0.0005461798262 0.0006207625589 0.0006252586984 0.0006801435171 4.150871189e-05 4.330816918e-05
4.667738734e-05 0.0001557875346 0.0001718841495 0.0001850356996 -1.183981499e-19 6.063545581e-07 0.04038715139 0.05269214728
0.06114420692 1.292616484e-18 5.575625058e-07 0.04171422912 0.04594499957 0.04814794243 -7.089220973e-20 1.765877947e-07
0.0123284183 0.01390481134 0.01663859359 -3.852003475e-20 3.615081622e-09 0.0001736888643 0.0005485798217 0.002063123394
-2.168214613e-20 4.401821355e-10 1.690595317e-05 7.715571121e-05 0.0001213088347 -5.227637072e-20 2.690574911e-09 0.0001582957773
0.0003014056198 0.0003098393785 -2.578746165e-21 2.002926017e-11 1.091401345e-06 9.842946442e-06 2.886364082e-05 -1.467890701e-21
3.781819455e-11 2.738852614e-07 1.682185927e-06 3.057534856e-05 -6.145488072e-21 4.629796289e-11 4.595018067e-06 2.141227898e-05
2.536254421e-05 -8.938399573e-23 3.772623386e-12 2.778571396e-08 4.457119135e-07 3.033763681e-06 -1.039006993e-21 5.051850135e-11
2.864461584e-06 4.258478683e-06 6.253775845e-06 1.263644019e-21 3.715492028e-11 2.13443985e-06 6.156461998e-06 6.427224849e-06
8.615639474e-23 2.171014683e-11 1.415717567e-06 1.797491267e-06 2.149757784e-06
C atom_index 1 n_descriptor 18
1.056940269 0.1266618616 0.8734002808 0.902430529 0.970664598 0.007596404359 0.008745980544 0.01021958025
-7.027367648e-18 2.237266295e-07 0.01497960358 0.01708725446 0.02300553405 5.14127977e-19 5.904406668e-08 0.004380552522
0.004727727944 0.005122035518

H atom_index 1 n_descriptor 117
1.098605102 0.7495795634 0.3252209747 0.06672575817 0.005898566349 0.000519189802 0.0002552736779 0.0003234603839
0.0002335484133 0.0004497605392 0.0001012210655 8.786165673e-05 3.539866253e-05 0.5905397681 0.598461126 0.8795152914
0.1044141671 0.1114081517 0.1266379876 0.009515278265 0.009902643111 0.06160116406 4.612177997e-05 9.115920963e-05
0.05014362463 0.0002442240299 0.0002958040607 0.004301186338 0.0003868073526 0.0004226864861 0.0005105677415 1.449869113e-05
1.580735669e-05 0.001406025591 0.0001296467764 0.0001356599856 0.0001724887798 0.0001272755945 0.0001385483305 0.0004430266012
4.65141336e-05 5.300624993e-05 0.0001647060554 2.272102161e-05 5.384463551e-05 5.551241557e-05 4.849594913e-05 4.997326859e-05
0.0001351349529 3.923290381e-05 4.204567163e-05 6.184414284e-05 -7.325504269e-14 4.743830918e-08 0.3119131633 0.4891762159
0.5011445533 -4.583638385e-15 5.374932893e-08 0.08730883866 0.1769972762 0.186367201 -2.371984657e-16 1.693664909e-06
0.004676598456 0.03183582515 0.03379273604 -2.400925284e-15 1.919260555e-07 0.001195586854 0.001365496543 0.01930914966
-6.043462235e-17 6.483234972e-08 0.000982477601 0.001206386856 0.00839954464 -1.255767316e-18 4.504838611e-08 0.0001187273216
0.0001537274649 0.003235584061 -1.067876998e-16 9.335912398e-08 3.936269894e-06 3.957751825e-06 0.0001799379967 -4.812116629e-17
1.130748427e-10 6.236657691e-05 0.0002721719788 0.0002786798993 -3.910423899e-18 1.098368929e-09 6.058274681e-05 7.539783521e-05
0.0004622823936 -1.412067608e-18 1.508439812e-09 1.417642678e-05 2.631797473e-05 3.28595603e-05 -1.314050125e-17 1.6384074e-11
1.969568504e-05 5.901670367e-05 5.913736007e-05 -6.071600775e-18 2.700911728e-11 3.929750348e-05 4.006934305e-05 5.969216787e-05
-3.278345683e-18 2.297319961e-12 8.799274201e-06 3.001252069e-05 3.388745239e-05
H atom_index 1 n_descriptor 18
1.400632299 0.04117702106 0.1027305888 0.1041966275 0.1294135661 0.01642938298 0.02242890128 0.02280997959
-5.263808249e-16 2.234016552e-07 0.015913677 0.07687398759 0.07817548593 -4.778097868e-16 4.735625439e-10 0.003893476503
0.01697098872 0.01735324613

H atom_index 2 n_descriptor 117
1.066059296 0.7453159715 0.2272757978 0.02268097303 0.00210041428 0.0006983231607 0.0009453295944 0.001533508085
0.0004715005968 0.0002363166266 7.650629389e-05 7.034243271e-05 3.474045631e-05 0.4707547845 0.4852871597 0.8459050647
0.0425861505 0.04975191971 0.1333461159 0.0009068345858 0.0009986348456 0.08651615735 0.0009734263907 0.001277773457
0.02389125178 9.440348353e-05 0.0001230076263 0.002068445798 0.0002898134263 0.000405323856 0.0009215389789 0.0001136309834
0.0001336591021 0.001354683766 5.971564529e-05 6.357551643e-05 0.0003786453155 4.784147073e-05 0.0001139331031 0.0001214582535
7.640800882e-05 9.309400337e-05 0.0002991784943 4.485703977e-05 5.470324742e-05 0.0001456595214 4.57071795e-05 5.133796737e-05
6.113873751e-05 4.230789719e-05 4.610390344e-05 0.0001052539477 -9.942399523e-15 1.635602839e-07 0.4166274084 0.5201712957
0.5458105194 -2.881672179e-17 8.251041194e-07 0.05825466592 0.1171892841 0.1341075864 -4.887469832e-16 2.717085945e-06
0.01015981041 0.01176405702 0.02713831111 -2.638235092e-17 1.345076142e-07 0.0002893168385 0.0005239157678 0.03049069728
-5.221577314e-17 1.410609052e-07 9.404937335e-05 0.0001948845312 0.001713559167 -7.268488418e-18 2.881045976e-10 9.810194935e-05
0.0004344160694 0.0006252264378 -3.39040841e-19 4.644683891e-10 4.306033514e-05 4.674548199e-05 0.001581342823 -7.409489793e-19
3.055740839e-09 6.97100551e-05 7.978386841e-05 0.0001000042475 -3.283402357e-18 5.219274745e-09 2.136057469e-05 0.0001516153737
0.0001798260934 -1.376225085e-18 6.24846001e-09 6.160379901e-05 8.814700702e-05 0.0002389709743 -7.25718242e-19 1.921027202e-11
2.698746144e-05 4.690575194e-05 5.34539035e-05 -1.023580241e-18 3.513446915e-10 3.104686508e-05 5.335830712e-05 5.651805483e-05
-8.762999951e-19 1.312018938e-09 4.196691081e-05 5.130099515e-05 6.00940637e-05
H atom_index 2 n_descriptor 18
1.181670195 0.04550076051 0.04232612155 0.04377413388 0.1245819176 0.01174657886 0.01215933419 0.02044853859
7.197982145e-16 9.606563449e-09 0.03052951885 0.0335141051 0.03505048493 3.93594073e-16 2.191861746e-09 0.004314213193
0.0101011116 0.0105768787

H atom_index 3 n_descriptor 117
1.072875794 0.7492115734 0.2520946 0.03085946079 0.002353586074 0.0004022672543 0.0005672046673 0.001282863354
0.000496264943 0.0003186440715 7.841854164e-05 5.784777788e-05 3.522718558e-05 0.495726934 0.513259289 0.8554494483
0.05270001399 0.06314503126 0.1284387793 0.002010572212 0.002245774641 0.08459686849 0.0006781104219 0.001043545509
0.0321046318 7.477142908e-05 0.0001198309287 0.0008740942697 0.000314370922 0.0004766160339 0.0006031258316 8.621238219e-05
0.0001035671389 0.001839325965 6.135074924e-05 6.792331266e-05 0.0002019288118 3.748894875e-05 0.0001227724732 0.0001358936561
6.614301922e-05 8.667688695e-05 0.0003637961651 4.325828215e-05 5.320922396e-05 9.256091574e-05 4.717813107e-05 5.26975738e-05
6.512425766e-05 4.036925952e-05 4.582077217e-05 0.0001115153413 -4.205279615e-14 2.318992809e-07 0.3946701482 0.5114627326
0.5430379672 -1.530603065e-15 1.321771425e-06 0.06358728311 0.1289176481 0.1518655472 -2.813829039e-15 5.329534275e-06
0.01423222587 0.01686477908 0.01947627673 -2.237125186e-15 1.789596519e-06 7.945394706e-05 0.0002056196701 0.03075041389
-7.171536746e-17 3.570102327e-08 0.000128020796 0.0003106019487 0.00349602538 -4.14699737e-17 5.72335645e-07 0.0001428120485
0.0004176966772 0.0006499234709 -1.095915408e-19 3.240749442e-10 1.447820741e-05 2.195383392e-05 0.001351212072 -1.065894228e-17
1.654236155e-09 9.240769839e-05 0.000111777506 0.0001497317319 -2.119091765e-17 1.747308723e-08 9.276902073e-05 0.0001425894753
0.0001793036357 -5.935703804e-18 4.431695181e-09 4.29546023e-05 7.150592423e-05 0.0001874481269 -4.41374928e-18 1.117382431e-09
1.218200499e-05 4.835160026e-05 5.541954064e-05 -4.95657466e-18 6.770259067e-10 4.529460622e-05 5.182849641e-05 5.54090552e-05
-4.59078958e-18 1.28291777e-09 3.529558353e-05 4.647622419e-05 5.018985314e-05

H atom_index 4 n_descriptor 117
1.076905759 0.7505672105 0.2654735826 0.03602771298 0.002602551235 0.0003282954594 0.0004230428263 0.001104631382
0.000484227278 0.0003667222204 7.970678348e-05 5.526037756e-05 3.597855097e-05 0.5093264096 0.5295797518 0.8603779172
0.05978648191 0.07011888455 0.1267264325 0.002799184517 0.00320095235 0.08227264164 0.0005340127392 0.0008612190756
0.03636668558 7.341019579e-05 0.0001326467689 0.0007106140273 0.0002726371094 0.0004284535045 0.000531731561 7.25178725e-05
8.169619072e-05 0.00199688686 6.526238644e-05 7.214393049e-05 0.0001522542184 5.168144081e-05 0.0001273129985 0.0001438518239
6.099455487e-05 8.211188965e-05 0.0003724476668 4.329148742e-05 5.2767521e-05 6.939157346e-05 4.797154716e-05 5.365169042e-05
7.187699257e-05 3.916720294e-05 4.558041043e-05 0.0001095943866 -5.333407762e-14 4.884262051e-07 0.381812448 0.5064834489
0.5400106478 -5.167787288e-15 9.055336292e-07 0.0673416006 0.1362313965 0.1599758942 -2.88206e-15 6.863623229e-06
0.0154092469 0.01667488876 0.02016716968 -8.95122582e-15 2.61519226e-06 0.0001008043504 0.000122793475 0.02994082585
-2.320235995e-18 4.284069415e-09 0.0001755709327 0.0004102819955 0.004612884769 -3.990181075e-17 5.16398016e-07 0.0003206919486
0.0004590677531 0.0006049351942 -5.061440383e-18 1.603035762e-09 5.661183523e-06 1.284970954e-05 0.001120873834 -1.306564849e-17
2.826054946e-09 0.0001133291171 0.0001310638632 0.0001793411122 -2.139171125e-17 2.417480231e-08 0.0001201588268 0.0001716169249
0.0001768421225 -5.145551842e-18 3.09719065e-09 3.627318582e-05 6.258724207e-05 0.0001430005699 -5.616122447e-18 1.758833697e-09
8.498437259e-06 5.075844714e-05 5.56219579e-05 -5.638988892e-18 1.008359145e-09 5.013459407e-05 5.306528676e-05 5.506585846e-05
-4.655884534e-18 1.326652709e-09 3.17974234e-05 4.146664705e-05 4.554097626e-05
H atom_index 3 n_descriptor 18
1.236604132 0.04560187401 0.05263608364 0.05494823354 0.1308693603 0.01393374205 0.01453588332 0.01879213875
-5.446263208e-16 1.187865741e-07 0.02895598367 0.04150173332 0.04376939009 -1.586846631e-16 2.888713946e-08 0.003184943987
0.0118208337 0.01253806203

H atom_index 4 n_descriptor 18
1.26662277 0.04521520737 0.05931915163 0.06187700248 0.1329947817 0.01527065544 0.01573939534 0.01794575804
-1.230035378e-15 1.136899733e-07 0.02742236223 0.04651814046 0.04908940065 -4.340124768e-16 2.520267511e-08 0.002668663015
0.01279224077 0.01358768798
Loading
Loading