Skip to content

Commit

Permalink
Bug fix in the scaling of the operator in the rational approximation
Browse files Browse the repository at this point in the history
  • Loading branch information
sbacchio committed Sep 4, 2017
1 parent 5f01c73 commit fd0ca8c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 23 deletions.
48 changes: 27 additions & 21 deletions monomial/ndrat_monomial.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void nd_set_global_parameter(monomial * const mnl) {
boundary(g_kappa);
phmc_cheb_evmin = mnl->EVMin;
phmc_invmaxev = mnl->EVMaxInv;
phmc_cheb_evmax = 1.;
phmc_cheb_evmax = mnl->EVMax;
phmc_Cpol = 1.;
// used for preconditioning in cloverdetrat
g_mu3 = 0.;
Expand Down Expand Up @@ -325,30 +325,36 @@ double ndrat_acc(const int id, hamiltonian_field_t * const hf) {

int init_ndrat_monomial(const int id) {
monomial * mnl = &monomial_list[id];

mnl->EVMin = mnl->StildeMin / mnl->StildeMax;
mnl->EVMax = 1.;
mnl->EVMaxInv = 1./(sqrt(mnl->StildeMax));
int scale = 0;

if(mnl->type == RAT || mnl->type == CLOVERRAT ||
mnl->type == RATCOR || mnl->type == CLOVERRATCOR) {
init_rational(&mnl->rat, 1);

if(init_chi_spinor_field(VOLUMEPLUSRAND/2, (mnl->rat.np+2)/2) != 0) {
fprintf(stderr, "Not enough memory for Chi fields! Aborting...\n");
exit(0);
}
}
else {
init_rational(&mnl->rat, 0);
mnl->type == RATCOR || mnl->type == CLOVERRATCOR)
scale = 1;

if(scale) {

This comment has been minimized.

Copy link
@kostrzewa

kostrzewa Nov 7, 2018

Member

Are you sure this was necessary? We tested "det" vs. "rat" and got consistent results. Does this change retain this consistency?

// When scale = 1
// the rational approximation is done for the standard operator
// which have eigenvalues between EVMin and EVMax. Indeed the
// parameters of the rational approximation are scaled. Thus
// additional scaling of the operator (EVMaxInv) is not required.
mnl->EVMin = mnl->StildeMin;
mnl->EVMax = mnl->StildeMax;
mnl->EVMaxInv = 1.;
} else {
// When scale = 0
// the rational approximation is done for the normalized operator
// which have eigenvalues between EVMin/EVMax and 1. Thus the
// operator need to be scaled by EVMaxInv=1/EVMax.
mnl->EVMin = mnl->StildeMin / mnl->StildeMax;
mnl->EVMax = 1.;
mnl->EVMaxInv = 1./(sqrt(mnl->StildeMax));

if(init_chi_spinor_field(VOLUMEPLUSRAND/2, (mnl->rat.np+1)) != 0) {
fprintf(stderr, "Not enough memory for Chi fields! Aborting...\n");
exit(0);
}
mnl->EVMaxInv = 1./sqrt(mnl->StildeMax);
}

init_rational(&mnl->rat, scale);

if(init_chi_spinor_field(VOLUMEPLUSRAND/2, (mnl->rat.np+2)/2) != 0) {
fprintf(stderr, "Not enough memory for Chi fields! Aborting...\n");
exit(0);
}

return(0);
Expand Down
4 changes: 2 additions & 2 deletions phmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,15 @@ void phmc_compute_ev(const int trajectory_counter,
mnl->name, trajectory_counter, temp2);
}
if(g_proc_id == 0) {
if(temp2 > 1.) {
if(temp2 > mnl->EVMax) {
fprintf(stderr, "\nWarning: largest eigenvalue for monomial %s larger than upper bound!\n\n", mnl->name);
}
if(temp < mnl->EVMin) {
fprintf(stderr, "\nWarning: smallest eigenvalue for monomial %s smaller than lower bound!\n\n", mnl->name);
}
countfile = fopen(phmcfilename, "a");
fprintf(countfile, "%.8d %1.5e %1.5e %1.5e %1.5e\n",
trajectory_counter, temp, temp2, mnl->EVMin, 1.);
trajectory_counter, temp, temp2, mnl->EVMin, mnl->EVMax);
fclose(countfile);
}
etime = gettime();
Expand Down

0 comments on commit fd0ca8c

Please sign in to comment.