mirror of
https://github.com/TREX-CoE/qmckl.git
synced 2025-04-30 04:15:00 +02:00
Fixed some tests in Jastrow-single
This commit is contained in:
parent
12de50d2cf
commit
ac5d5535e6
@ -2298,7 +2298,7 @@ qmckl_exit_code qmckl_get_jastrow_champ_ee_distance_rescaled(qmckl_context conte
|
||||
if (distance_rescaled == NULL) {
|
||||
return qmckl_failwith( context,
|
||||
QMCKL_INVALID_ARG_2,
|
||||
"qmckl_provide_jastrow_champ_factor_ee_gl",
|
||||
"qmckl_get_jastrow_champ_ee_distance_rescaled",
|
||||
"Null pointer");
|
||||
}
|
||||
|
||||
@ -2307,7 +2307,7 @@ qmckl_exit_code qmckl_get_jastrow_champ_ee_distance_rescaled(qmckl_context conte
|
||||
if (size_max < sze) {
|
||||
return qmckl_failwith( context,
|
||||
QMCKL_INVALID_ARG_2,
|
||||
"qmckl_provide_jastrow_champ_factor_ee_gl",
|
||||
"qmckl_get_jastrow_champ_ee_distance_rescaled",
|
||||
"Array too small. Expected elec_num*elec_num*walk_num.");
|
||||
}
|
||||
memcpy(distance_rescaled, ctx->jastrow_champ.ee_distance_rescaled, sze * sizeof(double));
|
||||
@ -7215,7 +7215,7 @@ assert(qmckl_electron_provided(context));
|
||||
{
|
||||
|
||||
double een_rescaled_e[walk_num][(cord_num + 1)][elec_num][elec_num];
|
||||
rc = qmckl_get_jastrow_champ_een_distance_rescaled_e(context, &(een_rescaled_e[0][0][0][0]),elec_num*elec_num*(cord_num+1)*walk_num);
|
||||
rc = qmckl_get_jastrow_champ_een_rescaled_e(context, &(een_rescaled_e[0][0][0][0]),elec_num*elec_num*(cord_num+1)*walk_num);
|
||||
|
||||
<<test_ee()>>
|
||||
}
|
||||
@ -7791,7 +7791,7 @@ assert(qmckl_electron_provided(context));
|
||||
{
|
||||
/* Finite difference test fails and I can't understand why... */
|
||||
|
||||
printf("een_distance_rescaled_e_gl\n");
|
||||
printf("een_rescaled_e_gl\n");
|
||||
|
||||
double fd[walk_num][cord_num+1][elec_num][4][elec_num];
|
||||
|
||||
@ -7873,10 +7873,10 @@ assert(qmckl_electron_provided(context));
|
||||
}
|
||||
|
||||
|
||||
double een_distance_rescaled_e_gl[walk_num][cord_num+1][elec_num][4][elec_num];
|
||||
double een_rescaled_e_gl[walk_num][cord_num+1][elec_num][4][elec_num];
|
||||
rc = qmckl_check(context,
|
||||
qmckl_get_jastrow_champ_een_rescaled_e_gl(context,
|
||||
&(een_distance_rescaled_e_gl[0][0][0][0][0]),
|
||||
&(een_rescaled_e_gl[0][0][0][0][0]),
|
||||
walk_num*(cord_num+1)*elec_num*4*elec_num)
|
||||
);
|
||||
|
||||
@ -7888,23 +7888,23 @@ assert(qmckl_electron_provided(context));
|
||||
for (int i = 0; i < elec_num; i++) {
|
||||
for (int j = 0; j < elec_num; j++) {
|
||||
for (int k = 0; k < 3; k++){
|
||||
if (fabs(fd[nw][c][i][k][j] - een_distance_rescaled_e_gl[nw][c][i][k][j]) > 1.e-10) {
|
||||
if (fabs(fd[nw][c][i][k][j] - een_rescaled_e_gl[nw][c][i][k][j]) > 1.e-10) {
|
||||
printf("%2d %2d %2d %2d %2d\t", nw, c, i, k, j);
|
||||
printf("%.10e\t", fd[nw][c][i][k][j]);
|
||||
printf("%.10e\n", een_distance_rescaled_e_gl[nw][c][i][k][j]);
|
||||
printf("%.10e\n", een_rescaled_e_gl[nw][c][i][k][j]);
|
||||
fflush(stdout);
|
||||
}
|
||||
assert(fabs(fd[nw][c][i][k][j] - een_distance_rescaled_e_gl[nw][c][i][k][j]) < 1.e-8);
|
||||
assert(fabs(fd[nw][c][i][k][j] - een_rescaled_e_gl[nw][c][i][k][j]) < 1.e-8);
|
||||
}
|
||||
int k=3;
|
||||
if (i != j) {
|
||||
if (fabs(fd[nw][c][i][k][j] - een_distance_rescaled_e_gl[nw][c][i][k][j]) > 1.e-8) {
|
||||
if (fabs(fd[nw][c][i][k][j] - een_rescaled_e_gl[nw][c][i][k][j]) > 1.e-8) {
|
||||
printf("%2d %2d %2d %2d %2d\t", nw, c, i, k, j);
|
||||
printf("%.10e\t", fd[nw][c][i][k][j]);
|
||||
printf("%.10e\n", een_distance_rescaled_e_gl[nw][c][i][k][j]);
|
||||
printf("%.10e\n", een_rescaled_e_gl[nw][c][i][k][j]);
|
||||
fflush(stdout);
|
||||
}
|
||||
assert(fabs(fd[nw][c][i][k][j] - een_distance_rescaled_e_gl[nw][c][i][k][j]) < 1.e-6);
|
||||
assert(fabs(fd[nw][c][i][k][j] - een_rescaled_e_gl[nw][c][i][k][j]) < 1.e-6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -324,6 +324,8 @@ double coords[walk_num][elec_num][3];
|
||||
- [walk_num][3] if ~transp~ is ~'N'~
|
||||
- [3][walk_num] if ~transp~ is ~'T'~
|
||||
|
||||
Internally, the coordinates are stored in 'N' format as opposed to elec_coord.
|
||||
|
||||
#+begin_src c :comments org :tangle (eval h_func)
|
||||
qmckl_exit_code qmckl_set_single_point (qmckl_context context,
|
||||
const char transp,
|
||||
@ -408,7 +410,7 @@ qmckl_set_single_point (qmckl_context context,
|
||||
|
||||
ctx->single_point.num = num;
|
||||
|
||||
if (transp == 'T') {
|
||||
if (transp == 'N') {
|
||||
double *a = ctx->single_point.coord.data;
|
||||
for (int64_t i=0 ; i<3*walk_num ; ++i) {
|
||||
a[i] = coord[i];
|
||||
@ -590,15 +592,17 @@ qmckl_exit_code qmckl_provide_single_ee_distance(qmckl_context context)
|
||||
:END:
|
||||
|
||||
#+NAME: qmckl_single_ee_distance_args
|
||||
|----------------------+---------------------------------+--------+-----------------------------|
|
||||
| Variable | Type | In/Out | Description |
|
||||
|----------------------+---------------------------------+--------+-----------------------------|
|
||||
| ~context~ | ~qmckl_context~ | in | Global state |
|
||||
| ~num~ | ~int64_t~ | in | Number of electrons |
|
||||
| ~num~ | ~int64_t~ | in | Number of electrons |
|
||||
| ~elec_num~ | ~int64_t~ | in | Number of electrons |
|
||||
| ~walk_num~ | ~int64_t~ | in | Number of walkers |
|
||||
| ~coord~ | ~double[3][walk_num][elec_num]~ | in | Electron coordinates |
|
||||
| ~single_coord~ | ~double[walk_num][3]~ | in | Single electron coordinates |
|
||||
| ~single_ee_distance~ | ~double[walk_num][elec_num]~ | out | Electron-electron distances |
|
||||
|----------------------+---------------------------------+--------+-----------------------------|
|
||||
|
||||
#+begin_src f90 :comments org :tangle (eval f) :noweb yes
|
||||
integer(qmckl_exit_code) function qmckl_compute_single_ee_distance(context, &
|
||||
@ -610,7 +614,7 @@ integer(qmckl_exit_code) function qmckl_compute_single_ee_distance(context, &
|
||||
integer(qmckl_context), intent(in) :: context
|
||||
integer (c_int64_t) , intent(in) , value :: elec_num, num_in
|
||||
integer (c_int64_t) , intent(in) , value :: walk_num
|
||||
real (c_double ) , intent(in) :: coord(elec_num,3,walk_num)
|
||||
real (c_double ) , intent(in) :: coord(elec_num,walk_num,3)
|
||||
real (c_double ) , intent(in) :: single_coord(3,walk_num)
|
||||
real (c_double ) , intent(out) :: single_ee_distance(elec_num,walk_num)
|
||||
|
||||
@ -637,10 +641,10 @@ integer(qmckl_exit_code) function qmckl_compute_single_ee_distance(context, &
|
||||
endif
|
||||
|
||||
do k=1,walk_num
|
||||
info = qmckl_distance(context, 'N', 'T', 1_8, elec_num, &
|
||||
info = qmckl_distance(context, 'T', 'N', elec_num, 1_8, &
|
||||
coord(1,k,1), elec_num*walk_num, &
|
||||
single_coord(1,k), 3_8, &
|
||||
coord(1,1,k), elec_num, &
|
||||
single_ee_distance(1,k), 1_8)
|
||||
single_ee_distance(1,k), elec_num)
|
||||
if (info /= QMCKL_SUCCESS) then
|
||||
exit
|
||||
endif
|
||||
@ -682,6 +686,7 @@ double ee_distance[walk_num][elec_num][elec_num];
|
||||
rc = qmckl_check(context,
|
||||
qmckl_get_electron_ee_distance(context, &ee_distance[0][0][0], walk_num*elec_num*elec_num)
|
||||
);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
rc = qmckl_check(context,
|
||||
qmckl_get_electron_coord(context, 'N', &coords[0][0][0], walk_num*elec_num*3)
|
||||
@ -858,6 +863,7 @@ qmckl_exit_code qmckl_provide_een_rescaled_single_e(qmckl_context context)
|
||||
:END:
|
||||
|
||||
#+NAME: qmckl_factor_een_rescaled_single_e_args
|
||||
|-------------------------+----------------------------------------------------+--------+-------------------------------------------------------------|
|
||||
| Variable | Type | In/Out | Description |
|
||||
|-------------------------+----------------------------------------------------+--------+-------------------------------------------------------------|
|
||||
| ~context~ | ~qmckl_context~ | in | Global state |
|
||||
@ -869,6 +875,7 @@ qmckl_exit_code qmckl_provide_een_rescaled_single_e(qmckl_context context)
|
||||
| ~single_ee_distance~ | ~double[walk_num][elec_num]~ | in | Single electron-electron distances for each walker |
|
||||
| ~een_rescaled_e~ | ~double[walk_num][0:cord_num][elec_num][elec_num]~ | in | Rescaled electron-electron distances for each walker |
|
||||
| ~een_rescaled_single_e~ | ~double[walk_num][0:cord_num][elec_num]~ | out | Single electron-electron rescaled distances for each walker |
|
||||
|-------------------------+----------------------------------------------------+--------+-------------------------------------------------------------|
|
||||
|
||||
#+begin_src f90 :comments org :tangle (eval f) :noweb yes
|
||||
integer function qmckl_compute_een_rescaled_single_e_doc( &
|
||||
@ -1201,14 +1208,16 @@ qmckl_exit_code qmckl_provide_single_en_distance(qmckl_context context)
|
||||
:END:
|
||||
|
||||
#+NAME: qmckl_single_en_distance_args
|
||||
|----------------------+-----------------------+--------+----------------------------|
|
||||
| Variable | Type | In/Out | Description |
|
||||
|----------------------+-----------------------+--------+----------------------------|
|
||||
| ~context~ | ~qmckl_context~ | in | Global state |
|
||||
| ~nucl_num~ | ~int64_t~ | in | Number of nuclei |
|
||||
| ~walk_num~ | ~int64_t~ | in | Number of walkers |
|
||||
| ~elec_coord~ | ~double[3]~ | in | Electron coordinates |
|
||||
| ~elec_coord~ | ~double[3][walk_num]~ | in | Electron coordinates |
|
||||
| ~nucl_coord~ | ~double[3][nucl_num]~ | in | Nuclear coordinates |
|
||||
| ~single_en_distance~ | ~double[nucl_num]~ | out | Electron-nucleus distances |
|
||||
|----------------------+-----------------------+--------+----------------------------|
|
||||
|
||||
#+begin_src f90 :comments org :tangle (eval f) :noweb yes
|
||||
integer function qmckl_compute_single_en_distance(context, nucl_num, walk_num, &
|
||||
@ -1218,9 +1227,9 @@ integer function qmckl_compute_single_en_distance(context, nucl_num, walk_num,
|
||||
implicit none
|
||||
integer(qmckl_context), intent(in) :: context
|
||||
integer (c_int64_t) , intent(in) , value :: nucl_num, walk_num
|
||||
real (c_double ) , intent(in) :: elec_coord(3)
|
||||
real (c_double ) , intent(in) :: elec_coord(3,walk_num)
|
||||
real (c_double ) , intent(in) :: nucl_coord(nucl_num,3)
|
||||
real (c_double ) , intent(out) :: single_en_distance(nucl_num)
|
||||
real (c_double ) , intent(out) :: single_en_distance(nucl_num, walk_num)
|
||||
|
||||
integer*8 :: k
|
||||
|
||||
@ -1236,9 +1245,9 @@ integer function qmckl_compute_single_en_distance(context, nucl_num, walk_num,
|
||||
return
|
||||
endif
|
||||
|
||||
info = qmckl_distance(context, 'T', 'T', nucl_num, 1_8, &
|
||||
info = qmckl_distance(context, 'T', 'N', nucl_num, walk_num, &
|
||||
nucl_coord, nucl_num, &
|
||||
elec_coord, walk_num, &
|
||||
elec_coord, 3_8, &
|
||||
single_en_distance, nucl_num)
|
||||
|
||||
end function qmckl_compute_single_en_distance
|
||||
@ -1261,23 +1270,33 @@ qmckl_exit_code qmckl_compute_single_en_distance (
|
||||
/* Check if Jastrow is properly initialized */
|
||||
assert(qmckl_jastrow_champ_provided(context));
|
||||
|
||||
rc = qmckl_set_electron_coord(context, 'N', walk_num, elec_coord, walk_num*elec_num*3);
|
||||
rc = qmckl_check(context,
|
||||
qmckl_set_electron_coord(context, 'N', walk_num, elec_coord, walk_num*elec_num*3)
|
||||
);
|
||||
assert(rc == QMCKL_SUCCESS);
|
||||
|
||||
double en_distance[walk_num][elec_num][nucl_num];
|
||||
rc = qmckl_get_electron_en_distance(context,
|
||||
&en_distance[0][0][0],
|
||||
walk_num*elec_num*nucl_num);
|
||||
rc = qmckl_check(context,
|
||||
qmckl_get_electron_en_distance(context,
|
||||
&en_distance[0][0][0],
|
||||
walk_num*elec_num*nucl_num)
|
||||
);
|
||||
|
||||
rc = qmckl_get_electron_coord(context, 'N', &coords[0][0][0], walk_num*elec_num*3);
|
||||
rc = qmckl_check(context,
|
||||
qmckl_get_electron_coord(context, 'N', &coords[0][0][0], walk_num*elec_num*3)
|
||||
);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
rc = qmckl_set_single_point(context, 'N', 2, new_coords, 3*walk_num);
|
||||
rc = qmckl_check(context,
|
||||
qmckl_set_single_point(context, 'N', 2, new_coords, 3*walk_num)
|
||||
);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
double single_en_distance[walk_num][nucl_num];
|
||||
rc = qmckl_get_single_electron_en_distance(context,
|
||||
&(single_en_distance[0][0]), nucl_num);
|
||||
rc = qmckl_check(context,
|
||||
qmckl_get_single_electron_en_distance(context,
|
||||
&(single_en_distance[0][0]), nucl_num*walk_num)
|
||||
);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
coords[0][2][0] = new_coords[0];
|
||||
@ -1287,11 +1306,15 @@ coords[1][2][0] = new_coords[3];
|
||||
coords[1][2][1] = new_coords[4];
|
||||
coords[1][2][2] = new_coords[5];
|
||||
|
||||
rc = qmckl_set_electron_coord(context, 'N', walk_num, &coords[0][0][0], walk_num*elec_num*3);
|
||||
rc = qmckl_check(context,
|
||||
qmckl_set_electron_coord(context, 'N', walk_num, &coords[0][0][0], walk_num*elec_num*3)
|
||||
);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
rc = qmckl_get_electron_en_distance(context,
|
||||
&en_distance[0][0][0], walk_num*elec_num*nucl_num);
|
||||
rc = qmckl_check(context,
|
||||
qmckl_get_electron_en_distance(context,
|
||||
&en_distance[0][0][0], walk_num*elec_num*nucl_num)
|
||||
);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
for (int nw = 0 ; nw < walk_num ; nw++) {
|
||||
@ -2493,18 +2516,26 @@ rc = qmckl_set_electron_coord(context, 'N', walk_num, elec_coord, walk_num*elec_
|
||||
assert(rc == QMCKL_SUCCESS);
|
||||
|
||||
double ee_rescaled[walk_num][elec_num][elec_num];
|
||||
rc = qmckl_get_jastrow_champ_ee_distance_rescaled(context,
|
||||
&ee_rescaled[0][0][0], walk_num*elec_num*elec_num);
|
||||
rc = qmckl_check(context,
|
||||
qmckl_get_jastrow_champ_ee_distance_rescaled(context,
|
||||
&ee_rescaled[0][0][0], walk_num*elec_num*elec_num)
|
||||
);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
rc = qmckl_get_electron_coord(context, 'N', &coords[0][0][0], walk_num*elec_num*3);
|
||||
rc = qmckl_check(context,
|
||||
qmckl_get_electron_coord(context, 'N', &coords[0][0][0], walk_num*elec_num*3)
|
||||
);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
rc = qmckl_set_single_point(context, 'N', 2, new_coords, 3*walk_num);
|
||||
rc = qmckl_check(context,
|
||||
qmckl_set_single_point(context, 'N', 2, new_coords, 3*walk_num)
|
||||
);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
double single_ee_rescaled[walk_num][elec_num];
|
||||
rc = qmckl_get_ee_rescaled_single(context, &single_ee_rescaled[0][0], walk_num*elec_num);
|
||||
rc = qmckl_check(context,
|
||||
qmckl_get_ee_rescaled_single(context, &single_ee_rescaled[0][0], walk_num*elec_num)
|
||||
);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
coords[0][2][0] = new_coords[0];
|
||||
@ -2514,11 +2545,15 @@ coords[1][2][0] = new_coords[3];
|
||||
coords[1][2][1] = new_coords[4];
|
||||
coords[1][2][2] = new_coords[5];
|
||||
|
||||
rc = qmckl_set_electron_coord(context, 'N', walk_num, &coords[0][0][0], walk_num*elec_num*3);
|
||||
rc = qmckl_check(context,
|
||||
qmckl_set_electron_coord(context, 'N', walk_num, &coords[0][0][0], walk_num*elec_num*3)
|
||||
);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
rc = qmckl_get_jastrow_champ_ee_distance_rescaled(context,
|
||||
&ee_rescaled[0][0][0], walk_num*elec_num*elec_num);
|
||||
rc = qmckl_check(context,
|
||||
qmckl_get_jastrow_champ_ee_distance_rescaled(context,
|
||||
&ee_rescaled[0][0][0], walk_num*elec_num*elec_num)
|
||||
);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
|
||||
@ -2772,18 +2807,26 @@ rc = qmckl_set_electron_coord(context, 'N', walk_num, elec_coord, walk_num*elec_
|
||||
assert(rc == QMCKL_SUCCESS);
|
||||
|
||||
double en_rescaled[walk_num][nucl_num][elec_num];
|
||||
rc = qmckl_get_jastrow_champ_ee_distance_rescaled(context,
|
||||
&en_rescaled[0][0][0], walk_num*nucl_num*elec_num);
|
||||
rc = qmckl_check(context,
|
||||
qmckl_get_jastrow_champ_en_distance_rescaled(context,
|
||||
&en_rescaled[0][0][0], walk_num*nucl_num*elec_num)
|
||||
);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
rc = qmckl_get_electron_coord(context, 'N', &coords[0][0][0], walk_num*elec_num*3);
|
||||
rc = qmckl_check(context,
|
||||
qmckl_get_electron_coord(context, 'N', &coords[0][0][0], walk_num*elec_num*3)
|
||||
);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
rc = qmckl_set_single_point(context, 'N', 2, new_coords, 3*walk_num);
|
||||
rc = qmckl_check(context,
|
||||
qmckl_set_single_point(context, 'N', 2, new_coords, 3*walk_num)
|
||||
);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
double single_en_rescaled[walk_num][nucl_num];
|
||||
rc = qmckl_get_en_rescaled_single(context, &single_en_rescaled[0][0], walk_num*nucl_num);
|
||||
rc = qmckl_check(context,
|
||||
qmckl_get_en_rescaled_single(context, &single_en_rescaled[0][0], walk_num*nucl_num)
|
||||
);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
coords[0][2][0] = new_coords[0];
|
||||
@ -2793,11 +2836,15 @@ coords[1][2][0] = new_coords[3];
|
||||
coords[1][2][1] = new_coords[4];
|
||||
coords[1][2][2] = new_coords[5];
|
||||
|
||||
rc = qmckl_set_electron_coord(context, 'N', walk_num, &coords[0][0][0], walk_num*elec_num*3);
|
||||
rc = qmckl_check(context,
|
||||
qmckl_set_electron_coord(context, 'N', walk_num, &coords[0][0][0], walk_num*elec_num*3)
|
||||
);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
rc = qmckl_get_jastrow_champ_ee_distance_rescaled(context,
|
||||
&en_rescaled[0][0][0], walk_num*nucl_num*elec_num);
|
||||
rc = qmckl_check(context,
|
||||
qmckl_get_jastrow_champ_en_distance_rescaled(context,
|
||||
&en_rescaled[0][0][0], walk_num*nucl_num*elec_num)
|
||||
);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user