mirror of
https://github.com/TREX-CoE/qmckl.git
synced 2024-11-19 20:42:50 +01:00
Avoid duplicate storage of constant parameters in nucleus and electron
This commit is contained in:
parent
06e6221d33
commit
6ba83ee33f
@ -361,16 +361,16 @@ qmckl_exit_code qmckl_init_ao_basis(qmckl_context context) {
|
||||
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
|
||||
return qmckl_failwith( context,
|
||||
QMCKL_NULL_CONTEXT,
|
||||
"qmckl_get_ao_*",
|
||||
"qmckl_set_ao_*",
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
qmckl_context_struct* const ctx = (qmckl_context_struct*) context;
|
||||
|
||||
if (!(ctx->ao_basis.uninitialized & mask)) {
|
||||
return qmckl_failwith( context,
|
||||
QMCKL_ALREADY_SET,
|
||||
"qmckl_get_ao_*",
|
||||
"qmckl_set_ao_*",
|
||||
NULL);
|
||||
}
|
||||
#+end_src
|
||||
@ -4168,20 +4168,10 @@ print ( "[1][4][26] : %25.15e"% lf(a,x,y))
|
||||
|
||||
#+begin_src c :tangle (eval c_test) :exports none
|
||||
{
|
||||
#define walk_num 1 // chbrclf_walk_num
|
||||
#define elec_num chbrclf_elec_num
|
||||
#define shell_num chbrclf_shell_num
|
||||
|
||||
int64_t elec_up_num = chbrclf_elec_up_num;
|
||||
int64_t elec_dn_num = chbrclf_elec_dn_num;
|
||||
double* elec_coord = &(chbrclf_elec_coord[0][0][0]);
|
||||
|
||||
rc = qmckl_set_electron_num (context, elec_up_num, elec_dn_num);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
rc = qmckl_set_electron_walk_num (context, walk_num);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
assert(qmckl_electron_provided(context));
|
||||
|
||||
rc = qmckl_set_electron_coord (context, 'N', elec_coord, walk_num*elec_num*3);
|
||||
@ -6141,21 +6131,11 @@ print ( "[26][1][224] : %25.15e"%(df(a,x,y,1)* (x[2] - y[2]) * (x[2] - y[2])) )
|
||||
|
||||
#+begin_src c :tangle (eval c_test) :exports none
|
||||
{
|
||||
#define walk_num 1 // chbrclf_walk_num
|
||||
#define elec_num chbrclf_elec_num
|
||||
#define shell_num chbrclf_shell_num
|
||||
#define ao_num chbrclf_ao_num
|
||||
|
||||
int64_t elec_up_num = chbrclf_elec_up_num;
|
||||
int64_t elec_dn_num = chbrclf_elec_dn_num;
|
||||
double* elec_coord = &(chbrclf_elec_coord[0][0][0]);
|
||||
|
||||
rc = qmckl_set_electron_num (context, elec_up_num, elec_dn_num);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
rc = qmckl_set_electron_walk_num (context, walk_num);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
assert(qmckl_electron_provided(context));
|
||||
|
||||
rc = qmckl_set_electron_coord (context, 'N', elec_coord, walk_num*elec_num*3);
|
||||
@ -7137,21 +7117,11 @@ print ( "[26][1][224] : %25.15e"%(df(a,x,y,1)* (x[2] - y[2]) * (x[2] - y[2])) )
|
||||
|
||||
#+begin_src c :tangle (eval c_test) :exports none
|
||||
{
|
||||
#define walk_num 1 // chbrclf_walk_num
|
||||
#define elec_num chbrclf_elec_num
|
||||
#define shell_num chbrclf_shell_num
|
||||
#define ao_num chbrclf_ao_num
|
||||
|
||||
int64_t elec_up_num = chbrclf_elec_up_num;
|
||||
int64_t elec_dn_num = chbrclf_elec_dn_num;
|
||||
double* elec_coord = &(chbrclf_elec_coord[0][0][0]);
|
||||
|
||||
rc = qmckl_set_electron_num (context, elec_up_num, elec_dn_num);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
rc = qmckl_set_electron_walk_num (context, walk_num);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
assert(qmckl_electron_provided(context));
|
||||
|
||||
rc = qmckl_set_electron_coord (context, 'N', elec_coord, walk_num*elec_num*3);
|
||||
|
@ -490,6 +490,13 @@ if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
|
||||
}
|
||||
|
||||
qmckl_context_struct* const ctx = (qmckl_context_struct*) context;
|
||||
|
||||
if (mask != 0 && !(ctx->electron.uninitialized & mask)) {
|
||||
return qmckl_failwith( context,
|
||||
QMCKL_ALREADY_SET,
|
||||
"qmckl_set_electron_*",
|
||||
NULL);
|
||||
}
|
||||
#+end_src
|
||||
|
||||
#+NAME:post2
|
||||
@ -544,6 +551,8 @@ qmckl_exit_code
|
||||
qmckl_set_electron_num(qmckl_context context,
|
||||
const int64_t up_num,
|
||||
const int64_t down_num) {
|
||||
int32_t mask = 1 << 0;
|
||||
|
||||
<<pre2>>
|
||||
|
||||
if (up_num <= 0) {
|
||||
@ -560,8 +569,6 @@ qmckl_set_electron_num(qmckl_context context,
|
||||
"down_num < 0");
|
||||
}
|
||||
|
||||
int32_t mask = 1 << 0;
|
||||
|
||||
ctx->electron.up_num = up_num;
|
||||
ctx->electron.down_num = down_num;
|
||||
ctx->electron.num = up_num + down_num;
|
||||
@ -576,6 +583,8 @@ qmckl_set_electron_num(qmckl_context context,
|
||||
qmckl_exit_code
|
||||
qmckl_set_electron_walk_num(qmckl_context context, const int64_t walk_num) {
|
||||
|
||||
int32_t mask = 1 << 1;
|
||||
|
||||
<<pre2>>
|
||||
|
||||
if (walk_num <= 0) {
|
||||
@ -585,7 +594,6 @@ qmckl_set_electron_walk_num(qmckl_context context, const int64_t walk_num) {
|
||||
"walk_num <= 0");
|
||||
}
|
||||
|
||||
int32_t mask = 1 << 1;
|
||||
ctx->electron.walk_num = walk_num;
|
||||
|
||||
<<post2>>
|
||||
@ -598,6 +606,9 @@ qmckl_set_electron_walk_num(qmckl_context context, const int64_t walk_num) {
|
||||
qmckl_exit_code
|
||||
qmckl_set_electron_rescale_factor_ee(qmckl_context context,
|
||||
const double rescale_factor_kappa_ee) {
|
||||
|
||||
int32_t mask = 0; // can be changed
|
||||
|
||||
<<pre2>>
|
||||
|
||||
if (rescale_factor_kappa_ee <= 0.0) {
|
||||
@ -615,6 +626,9 @@ qmckl_set_electron_rescale_factor_ee(qmckl_context context,
|
||||
qmckl_exit_code
|
||||
qmckl_set_electron_rescale_factor_en(qmckl_context context,
|
||||
const double rescale_factor_kappa_en) {
|
||||
|
||||
int32_t mask = 0; // can be changed
|
||||
|
||||
<<pre2>>
|
||||
|
||||
if (rescale_factor_kappa_en <= 0.0) {
|
||||
@ -675,6 +689,8 @@ qmckl_set_electron_coord(qmckl_context context,
|
||||
const int64_t size_max)
|
||||
{
|
||||
|
||||
int32_t mask = 0; // coord can be changed
|
||||
|
||||
<<pre2>>
|
||||
|
||||
if (transp != 'N' && transp != 'T') {
|
||||
@ -2318,16 +2334,6 @@ print ( "[1][0][1] : ", (1.0 - np.exp(-kappa * np.linalg.norm(elec_2_w2-nucl_1))
|
||||
#+begin_src c :tangle (eval c_test)
|
||||
|
||||
assert(qmckl_electron_provided(context));
|
||||
|
||||
rc = qmckl_set_nucleus_num (context, nucl_num);
|
||||
assert(rc == QMCKL_SUCCESS);
|
||||
|
||||
rc = qmckl_set_nucleus_charge (context, charge, nucl_num);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
rc = qmckl_set_nucleus_coord (context, 'T', nucl_coord, 3*nucl_num);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
assert(qmckl_nucleus_provided(context));
|
||||
|
||||
double en_distance_rescaled[walk_num][nucl_num][elec_num];
|
||||
@ -2586,18 +2592,9 @@ import numpy as np
|
||||
|
||||
assert(qmckl_electron_provided(context));
|
||||
|
||||
rc = qmckl_set_nucleus_num (context, nucl_num);
|
||||
assert(rc == QMCKL_SUCCESS);
|
||||
|
||||
rc = qmckl_set_nucleus_rescale_factor (context, nucl_rescale_factor_kappa);
|
||||
assert(rc == QMCKL_SUCCESS);
|
||||
|
||||
rc = qmckl_set_nucleus_charge (context, charge, nucl_num);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
rc = qmckl_set_nucleus_coord (context, 'T', nucl_coord, 3*nucl_num);
|
||||
assert (rc == QMCKL_SUCCESS);
|
||||
|
||||
assert(qmckl_nucleus_provided(context));
|
||||
|
||||
double en_distance_rescaled_deriv_e[walk_num][4][nucl_num][elec_num];
|
||||
|
@ -422,10 +422,20 @@ bool qmckl_nucleus_provided(const qmckl_context context) {
|
||||
#+NAME:pre2
|
||||
#+begin_src c :exports none
|
||||
if (qmckl_context_check(context) == QMCKL_NULL_CONTEXT) {
|
||||
return QMCKL_NULL_CONTEXT;
|
||||
}
|
||||
return qmckl_failwith( context,
|
||||
QMCKL_NULL_CONTEXT,
|
||||
"qmckl_set_nucleus_*",
|
||||
NULL);
|
||||
}
|
||||
|
||||
qmckl_context_struct* const ctx = (qmckl_context_struct*) context;
|
||||
|
||||
if (mask != 0 && !(ctx->nucleus.uninitialized & mask)) {
|
||||
return qmckl_failwith( context,
|
||||
QMCKL_ALREADY_SET,
|
||||
"qmckl_set_nucleus_*",
|
||||
NULL);
|
||||
}
|
||||
#+end_src
|
||||
|
||||
#+NAME:post2
|
||||
@ -452,6 +462,8 @@ qmckl_exit_code
|
||||
qmckl_set_nucleus_num(qmckl_context context,
|
||||
const int64_t num)
|
||||
{
|
||||
int32_t mask = 1 << 0;
|
||||
|
||||
<<pre2>>
|
||||
|
||||
if (num <= 0) {
|
||||
@ -461,8 +473,6 @@ qmckl_set_nucleus_num(qmckl_context context,
|
||||
"num <= 0");
|
||||
}
|
||||
|
||||
int32_t mask = 1 << 0;
|
||||
|
||||
ctx->nucleus.num = num;
|
||||
|
||||
<<post2>>
|
||||
@ -498,6 +508,8 @@ qmckl_set_nucleus_charge(qmckl_context context,
|
||||
const double* charge,
|
||||
const int64_t size_max)
|
||||
{
|
||||
int32_t mask = 1 << 1;
|
||||
|
||||
<<pre2>>
|
||||
|
||||
if (charge == NULL) {
|
||||
@ -510,8 +522,6 @@ qmckl_set_nucleus_charge(qmckl_context context,
|
||||
int64_t num;
|
||||
qmckl_exit_code rc;
|
||||
|
||||
int32_t mask = 1 << 1;
|
||||
|
||||
rc = qmckl_get_nucleus_num(context, &num);
|
||||
if (rc != QMCKL_SUCCESS) return rc;
|
||||
|
||||
@ -569,12 +579,12 @@ qmckl_set_nucleus_coord(qmckl_context context,
|
||||
const double* coord,
|
||||
const int64_t size_max)
|
||||
{
|
||||
int32_t mask = 1 << 2;
|
||||
|
||||
<<pre2>>
|
||||
|
||||
qmckl_exit_code rc;
|
||||
|
||||
int32_t mask = 1 << 2;
|
||||
|
||||
const int64_t nucl_num = (int64_t) ctx->nucleus.num;
|
||||
|
||||
if (ctx->nucleus.coord.data != NULL) {
|
||||
@ -641,6 +651,8 @@ qmckl_exit_code
|
||||
qmckl_set_nucleus_rescale_factor(qmckl_context context,
|
||||
const double rescale_factor_kappa)
|
||||
{
|
||||
int32_t mask = 0; // Can be updated
|
||||
|
||||
<<pre2>>
|
||||
|
||||
if (rescale_factor_kappa <= 0.0) {
|
||||
|
Loading…
Reference in New Issue
Block a user