mirror of
https://github.com/TREX-CoE/qmckl.git
synced 2025-01-08 20:33:40 +01:00
Added proper tests for ee and en rescaled distances. #17
This commit is contained in:
parent
45670c83d6
commit
fc8cb4a5a8
@ -787,7 +787,7 @@ for (int64_t i=0 ; i<3*elec_num ; ++i) {
|
||||
the dependencies are more recent than the date of the data to
|
||||
compute. If it is the case, then the data is recomputed and the
|
||||
current date is stored.
|
||||
|
||||
|
||||
** Electron-electron distances
|
||||
|
||||
*** Get
|
||||
@ -1019,6 +1019,15 @@ assert(fabs(ee_distance[elec_num*elec_num+1]-6.5517646321055665) < 1.e-12);
|
||||
|
||||
** Electron-electron rescaled distances
|
||||
|
||||
~ee_distance_rescaled~ stores the matrix of the rescaled distances between all
|
||||
pairs of electrons:
|
||||
|
||||
\[
|
||||
C_{ij} = \left( 1 - \exp{-\kappa C_{ij}}\right)/\kappa
|
||||
\]
|
||||
|
||||
where \(C_{ij}\) is the matrix of electron-electron distances.
|
||||
|
||||
*** Get
|
||||
|
||||
#+begin_src c :comments org :tangle (eval h_func) :noweb yes
|
||||
@ -1203,53 +1212,54 @@ qmckl_exit_code qmckl_compute_ee_distance_rescaled (
|
||||
#+begin_src python :results output :exports none
|
||||
import numpy as np
|
||||
|
||||
kappa = 1.0
|
||||
|
||||
elec_1_w1 = np.array( [ -2.26995253563, -5.15737533569, -2.22940072417 ])
|
||||
elec_2_w1 = np.array( [ 3.51983380318, -1.08717381954, -1.19617708027 ])
|
||||
elec_1_w2 = np.array( [ -2.34410619736, -3.20016115904, -1.53496759012 ])
|
||||
elec_2_w2 = np.array( [ 3.17996025085, -1.40260577202, 1.49473607540 ])
|
||||
|
||||
print ( "[0][0][0] : ", np.linalg.norm(elec_1_w1-elec_1_w1) )
|
||||
print ( "[0][1][0] : ", np.linalg.norm(elec_1_w1-elec_2_w1) )
|
||||
print ( "[1][0][0] : ", np.linalg.norm(elec_2_w1-elec_1_w1) )
|
||||
print ( "[0][0][1] : ", np.linalg.norm(elec_1_w2-elec_1_w2) )
|
||||
print ( "[0][1][1] : ", np.linalg.norm(elec_1_w2-elec_2_w2) )
|
||||
print ( "[1][0][1] : ", np.linalg.norm(elec_2_w2-elec_1_w2) )
|
||||
print ( "[0][0][0] : ", (1.0 - np.exp(-kappa * np.linalg.norm(elec_1_w1-elec_1_w1)) )/kappa )
|
||||
print ( "[0][1][0] : ", (1.0 - np.exp(-kappa * np.linalg.norm(elec_1_w1-elec_2_w1)) )/kappa )
|
||||
print ( "[1][0][0] : ", (1.0 - np.exp(-kappa * np.linalg.norm(elec_2_w1-elec_1_w1)) )/kappa )
|
||||
print ( "[0][0][1] : ", (1.0 - np.exp(-kappa * np.linalg.norm(elec_1_w2-elec_1_w2)) )/kappa )
|
||||
print ( "[0][1][1] : ", (1.0 - np.exp(-kappa * np.linalg.norm(elec_1_w2-elec_2_w2)) )/kappa )
|
||||
print ( "[1][0][1] : ", (1.0 - np.exp(-kappa * np.linalg.norm(elec_2_w2-elec_1_w2)) )/kappa )
|
||||
#+end_src
|
||||
|
||||
#+RESULTS:
|
||||
: [0][0][0] : 0.0
|
||||
: [0][1][0] : 7.152322512964209
|
||||
: [1][0][0] : 7.152322512964209
|
||||
: [0][1][0] : 0.9992169566605263
|
||||
: [1][0][0] : 0.9992169566605263
|
||||
: [0][0][1] : 0.0
|
||||
: [0][1][1] : 6.5517646321055665
|
||||
: [1][0][1] : 6.5517646321055665
|
||||
: [0][1][1] : 0.9985724058042633
|
||||
: [1][0][1] : 0.9985724058042633
|
||||
|
||||
#+begin_src c :tangle (eval c_test)
|
||||
assert(qmckl_electron_provided(context));
|
||||
|
||||
|
||||
double ee_distance_rescaled[walk_num * elec_num * elec_num];
|
||||
rc = qmckl_get_electron_ee_distance_rescaled(context, ee_distance);
|
||||
rc = qmckl_get_electron_ee_distance_rescaled(context, ee_distance_rescaled);
|
||||
|
||||
// TODO: Get exact values
|
||||
//// (e1,e2,w)
|
||||
//// (0,0,0) == 0.
|
||||
//assert(ee_distance[0] == 0.);
|
||||
//
|
||||
//// (1,0,0) == (0,1,0)
|
||||
//assert(ee_distance[1] == ee_distance[elec_num]);
|
||||
//
|
||||
//// value of (1,0,0)
|
||||
//assert(fabs(ee_distance[1]-7.152322512964209) < 1.e-12);
|
||||
//
|
||||
//// (0,0,1) == 0.
|
||||
//assert(ee_distance[elec_num*elec_num] == 0.);
|
||||
//
|
||||
//// (1,0,1) == (0,1,1)
|
||||
//assert(ee_distance[elec_num*elec_num+1] == ee_distance[elec_num*elec_num+elec_num]);
|
||||
//
|
||||
//// value of (1,0,1)
|
||||
//assert(fabs(ee_distance[elec_num*elec_num+1]-6.5517646321055665) < 1.e-12);
|
||||
// (e1,e2,w)
|
||||
// (0,0,0) == 0.
|
||||
assert(ee_distance_rescaled[0] == 0.);
|
||||
|
||||
// (1,0,0) == (0,1,0)
|
||||
assert(ee_distance_rescaled[1] == ee_distance_rescaled[elec_num]);
|
||||
|
||||
// value of (1,0,0)
|
||||
assert(fabs(ee_distance_rescaled[1]-0.9992169566605263) < 1.e-12);
|
||||
|
||||
// (0,0,1) == 0.
|
||||
assert(ee_distance_rescaled[elec_num*elec_num] == 0.);
|
||||
|
||||
// (1,0,1) == (0,1,1)
|
||||
assert(ee_distance_rescaled[elec_num*elec_num+1] == ee_distance_rescaled[elec_num*elec_num+elec_num]);
|
||||
|
||||
// value of (1,0,1)
|
||||
assert(fabs(ee_distance_rescaled[elec_num*elec_num+1]-0.9985724058042633) < 1.e-12);
|
||||
|
||||
#+end_src
|
||||
|
||||
@ -1957,6 +1967,8 @@ qmckl_exit_code qmckl_compute_en_distance_rescaled (
|
||||
#+begin_src python :results output :exports none
|
||||
import numpy as np
|
||||
|
||||
kappa = 1.0
|
||||
|
||||
elec_1_w1 = np.array( [ -2.26995253563, -5.15737533569, -2.22940072417 ])
|
||||
elec_2_w1 = np.array( [ 3.51983380318, -1.08717381954, -1.19617708027 ])
|
||||
elec_1_w2 = np.array( [ -2.34410619736, -3.20016115904, -1.53496759012 ])
|
||||
@ -1964,21 +1976,22 @@ elec_2_w2 = np.array( [ 3.17996025085, -1.40260577202, 1.49473607540 ])
|
||||
nucl_1 = np.array( [ 1.096243353458458e+00, 8.907054016973815e-01, 7.777092280258892e-01 ] )
|
||||
nucl_2 = np.array( [ 1.168459237342663e+00, 1.125660720053393e+00, 2.833370314829343e+00 ] )
|
||||
|
||||
print ( "[0][0][0] : ", np.linalg.norm(elec_1_w1-nucl_1) )
|
||||
print ( "[0][1][0] : ", np.linalg.norm(elec_1_w1-nucl_2) )
|
||||
print ( "[0][0][1] : ", np.linalg.norm(elec_2_w1-nucl_1) )
|
||||
print ( "[1][0][0] : ", np.linalg.norm(elec_1_w2-nucl_1) )
|
||||
print ( "[1][1][0] : ", np.linalg.norm(elec_1_w2-nucl_2) )
|
||||
print ( "[1][0][1] : ", np.linalg.norm(elec_2_w2-nucl_1) )
|
||||
print ( "[0][0][0] : ", (1.0 - np.exp(-kappa * np.linalg.norm(elec_1_w1-nucl_1)) )/kappa )
|
||||
print ( "[0][1][0] : ", (1.0 - np.exp(-kappa * np.linalg.norm(elec_1_w1-nucl_2)) )/kappa )
|
||||
print ( "[0][0][1] : ", (1.0 - np.exp(-kappa * np.linalg.norm(elec_2_w1-nucl_1)) )/kappa )
|
||||
print ( "[1][0][0] : ", (1.0 - np.exp(-kappa * np.linalg.norm(elec_1_w2-nucl_1)) )/kappa )
|
||||
print ( "[1][1][0] : ", (1.0 - np.exp(-kappa * np.linalg.norm(elec_1_w2-nucl_2)) )/kappa )
|
||||
print ( "[1][0][1] : ", (1.0 - np.exp(-kappa * np.linalg.norm(elec_2_w2-nucl_1)) )/kappa )
|
||||
|
||||
#+end_src
|
||||
|
||||
#+RESULTS:
|
||||
: [0][0][0] : 7.546738741619978
|
||||
: [0][1][0] : 8.77102435246984
|
||||
: [0][0][1] : 3.698922010513608
|
||||
: [1][0][0] : 5.824059436060509
|
||||
: [1][1][0] : 7.080482110317645
|
||||
: [1][0][1] : 3.1804527583077356
|
||||
: [0][0][0] : 0.9994721712909764
|
||||
: [0][1][0] : 0.9998448354439821
|
||||
: [0][0][1] : 0.9752498074577688
|
||||
: [1][0][0] : 0.9970444172399963
|
||||
: [1][1][0] : 0.9991586325813303
|
||||
: [1][0][1] : 0.9584331688679852
|
||||
|
||||
#+begin_src c :tangle (eval c_test)
|
||||
|
||||
@ -2000,28 +2013,27 @@ assert(qmckl_nucleus_provided(context));
|
||||
|
||||
double en_distance_rescaled[walk_num][nucl_num][elec_num];
|
||||
|
||||
rc = qmckl_get_electron_en_distance_rescaled(context, &(en_distance[0][0][0]));
|
||||
rc = qmckl_get_electron_en_distance_rescaled(context, &(en_distance_rescaled[0][0][0]));
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
// TODO: check exact values
|
||||
//// (e,n,w) in Fortran notation
|
||||
//// (1,1,1)
|
||||
//assert(fabs(en_distance[0][0][0] - 7.546738741619978) < 1.e-12);
|
||||
//
|
||||
//// (1,2,1)
|
||||
//assert(fabs(en_distance[0][1][0] - 8.77102435246984) < 1.e-12);
|
||||
//
|
||||
//// (2,1,1)
|
||||
//assert(fabs(en_distance[0][0][1] - 3.698922010513608) < 1.e-12);
|
||||
//
|
||||
//// (1,1,2)
|
||||
//assert(fabs(en_distance[1][0][0] - 5.824059436060509) < 1.e-12);
|
||||
//
|
||||
//// (1,2,2)
|
||||
//assert(fabs(en_distance[1][1][0] - 7.080482110317645) < 1.e-12);
|
||||
//
|
||||
//// (2,1,2)
|
||||
//assert(fabs(en_distance[1][0][1] - 3.1804527583077356) < 1.e-12);
|
||||
// (e,n,w) in Fortran notation
|
||||
// (1,1,1)
|
||||
assert(fabs(en_distance_rescaled[0][0][0] - 0.9994721712909764) < 1.e-12);
|
||||
|
||||
// (1,2,1)
|
||||
assert(fabs(en_distance_rescaled[0][1][0] - 0.9998448354439821) < 1.e-12);
|
||||
|
||||
// (2,1,1)
|
||||
assert(fabs(en_distance_rescaled[0][0][1] - 0.9752498074577688) < 1.e-12);
|
||||
|
||||
// (1,1,2)
|
||||
assert(fabs(en_distance_rescaled[1][0][0] - 0.9970444172399963) < 1.e-12);
|
||||
|
||||
// (1,2,2)
|
||||
assert(fabs(en_distance_rescaled[1][1][0] - 0.9991586325813303) < 1.e-12);
|
||||
|
||||
// (2,1,2)
|
||||
assert(fabs(en_distance_rescaled[1][0][1] - 0.9584331688679852) < 1.e-12);
|
||||
|
||||
#+end_src
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user