Skip to content

Commit b072a6f

Browse files
authored
Merge pull request #17 from daschaich/rescale
Rescale
2 parents ea7e91a + 7896678 commit b072a6f

File tree

8 files changed

+55
-13
lines changed

8 files changed

+55
-13
lines changed

4d_Q16/susy/Make_template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,13 @@ susy_eig::
144144

145145
susy_cheb::
146146
${MAKE} -f ${MAKEFILE} target "MYTARGET= $@" \
147-
"DEFINES = ${DEFINES} -DPHI_ALGORITHM -DCHEB " \
147+
"DEFINES = ${DEFINES} -DPHI_ALGORITHM -DCHEB -DRESCALE " \
148148
"LAPACK = -llapack -lblas " \
149149
"EXTRA_OBJECTS = control_cheb.o chebyshev.o z2source.o "
150150

151151
susy_mode::
152152
${MAKE} -f ${MAKEFILE} target "MYTARGET= $@" \
153-
"DEFINES = ${DEFINES} -DPHI_ALGORITHM -DMODE " \
153+
"DEFINES = ${DEFINES} -DPHI_ALGORITHM -DMODE -DRESCALE " \
154154
"LAPACK = -llapack -lblas " \
155155
"EXTRA_OBJECTS = control_mode.o modenumber.o mode_coeffs.o z2source.o "
156156

4d_Q16/susy/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Eigenvalue measurements (susy_eig) require PRIMME (https://github.com/primme/pri
3030
-DEIG switches on the PRIMME eigenvalue calculation
3131
-DCHEB switches on Chebyshev spectral density computations
3232
-DMODE switches on stochastic eigenmode number computations
33+
-DRESCALE switches to more symmetric fermion operator
3334
-DPL_CORR switches on the Polyakov loop correlator calculation (NOT CURRENTLY IN USE)
3435
-DPUREGAUGE switches off the fermions (FOR TESTING)
3536

4d_Q16/susy/congrad_multi.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ int congrad_multi(Twist_Fermion *src, Twist_Fermion **psim,
4040
double *beta_im1 = malloc(sizeof *beta_im1 * Norder);
4141
double *alpha = malloc(sizeof *alpha * Norder);
4242
double rsqj;
43-
complex ctmp;
4443
Twist_Fermion **pm = malloc(sizeof(Twist_Fermion*) * Norder);
4544
for (i = 1; i < Norder; i++) // !!!
4645
pm[i] = malloc(sizeof(Twist_Fermion) * sites_on_node);
@@ -86,10 +85,8 @@ int congrad_multi(Twist_Fermion *src, Twist_Fermion **psim,
8685

8786
// beta_i[0] = -(r, r) / (pm, Mpm)
8887
cd = 0;
89-
FORALLSITES(i, s) {
90-
ctmp = TF_dot(&(pm0[i]), &(mpm[i]));
91-
cd += ctmp.real;
92-
}
88+
FORALLSITES(i, s)
89+
TF_rdot_sum(&(pm0[i]), &(mpm[i]), &cd);
9390
g_doublesum(&cd);
9491

9592
beta_i[0] = -rsq / cd;
@@ -155,7 +152,7 @@ int congrad_multi(Twist_Fermion *src, Twist_Fermion **psim,
155152
floatvark[j] = (Real)alpha[j];
156153
}
157154
FORALLSITES(i, s) {
158-
scalar_mult_TF(&(rm[i]),floatvar, &(mpm[i]));
155+
scalar_mult_TF(&(rm[i]), floatvar, &(mpm[i]));
159156
scalar_mult_add_TF(&(mpm[i]), &(pm0[i]), floatvar2, &(pm0[i]));
160157
for (j = 1; j < Norder; j++) {
161158
if (converged[j] == 0) {
@@ -215,7 +212,7 @@ int congrad_multi(Twist_Fermion *src, Twist_Fermion **psim,
215212
source_norm = 0; // Re-using for convenience
216213
FORALLSITES(i, s) { // Add shift.psi and subtract src
217214
scalar_mult_sum_TF(&(psim[j][i]), shift[j], &(mpm[i]));
218-
scalar_mult_sum_TF(&(src[i]), -1.0, &(mpm[i]));
215+
dif_TF(&(src[i]), &(mpm[i]));
219216
source_norm += (double)magsq_TF(&(mpm[i]));
220217
}
221218
g_doublesum(&source_norm);

4d_Q16/susy/control_cheb.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "susy_includes.h"
1111

1212
#ifndef CHEB
13-
#error "Don't use control_mode unless compiling with -DMODE!"
13+
#error "Don't use control_cheb unless compiling with -DCHEB!"
1414
#endif
1515
#ifdef MODE
1616
#error "-DCHEB and -DMODE will clobber each other!"
@@ -93,7 +93,6 @@ int main(int argc, char *argv[]) {
9393
node0_printf("RUNNING COMPLETED\n");
9494
dtime += dclock();
9595
node0_printf("\nTime = %.4g seconds\n", dtime);
96-
node0_printf("total_iters = %d\n", total_iters);
9796
fflush(stdout);
9897

9998
normal_exit(0); // Needed by at least some clusters

4d_Q16/susy/defines.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#define SV // Site/vector terms in action
2828
#define VP // Vector/plaquette terms in action
2929
#define QCLOSED // Q-closed terms in action
30+
//#define RESCALE // Rescale for more symmetric fermion operator
3031
//#define DIMREDUCE // Consider dimensionally reduced systems
3132
//#define DEBUG_CHECK // Print lambdas, offsets, etc.
3233

4d_Q16/susy/setup.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ void make_fields() {
124124
node0_printf("Single-trace scalar potential\n");
125125
#else
126126
node0_printf("Double-trace scalar potential\n");
127+
#endif
128+
#ifdef RESCALE
129+
node0_printf("Rescaled fermion operator\n");
127130
#endif
128131
Real size = (Real)(2.0 * sizeof(complex));
129132
FIELD_ALLOC(tr_eta, complex);

4d_Q16/susy/update_h.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ double gauge_force(Real eps) {
268268
// All called by assemble_fermion_force below
269269
// First Q-closed piece: chi_ab D_c chi_de epsilon_{abcde}
270270
// Note factor of -1/2
271+
#ifdef QCLOSED
271272
void F1Q(matrix *plaq_sol[NPLAQ], matrix *plaq_psol[NPLAQ]) {
272273
register int i, opp_a, opp_b;
273274
register site *s;
@@ -359,13 +360,15 @@ void F1Q(matrix *plaq_sol[NPLAQ], matrix *plaq_psol[NPLAQ]) {
359360
flip = (flip + 1) % 2;
360361
}
361362
}
363+
#endif
362364
// -----------------------------------------------------------------
363365

364366

365367

366368
// -----------------------------------------------------------------
367369
// Second Q-closed piece
368370
// Note factor of -1/2
371+
#ifdef QCLOSED
369372
void F2Q(matrix *plaq_sol[NPLAQ], matrix *plaq_psol[NPLAQ]) {
370373
register int i, opp_a, opp_b;
371374
register site *s;
@@ -457,6 +460,7 @@ void F2Q(matrix *plaq_sol[NPLAQ], matrix *plaq_psol[NPLAQ]) {
457460
flip = (flip + 1) % 2;
458461
}
459462
}
463+
#endif
460464
// -----------------------------------------------------------------
461465

462466

@@ -469,6 +473,7 @@ void F2Q(matrix *plaq_sol[NPLAQ], matrix *plaq_psol[NPLAQ]) {
469473
// Assume compute_plaqdet() has already been run
470474
// Appropriate adjoints set up in assemble_fermion_force
471475
// A bit more code reuse may be possible
476+
#ifdef SV
472477
void detF(matrix *eta, matrix *psi[NUMLINK], int sign) {
473478
register int i;
474479
register site *s;
@@ -644,6 +649,7 @@ void detF(matrix *eta, matrix *psi[NUMLINK], int sign) {
644649
free(inv_term);
645650
free(adj_term);
646651
}
652+
#endif
647653
// -----------------------------------------------------------------
648654

649655

@@ -686,6 +692,13 @@ void assemble_fermion_force(Twist_Fermion *sol, Twist_Fermion *psol) {
686692
mat_copy(&(sol[i].Fplaq[mu]), &(plaq_src[mu][i]));
687693
adjoint(&(psol[i].Fplaq[mu]), &(plaq_dest[mu][i]));
688694
}
695+
696+
// Optionally rescale to make fermion operator more symmetric
697+
// psol[i].Fsite already rescaled in fermion_op
698+
// !!!TODO: Not yet conserving...
699+
#ifdef RESCALE
700+
scalar_mult_matrix(&(site_src[i]), 2.0, &(site_src[i]));
701+
#endif
689702
}
690703

691704
#ifdef SV
@@ -730,6 +743,11 @@ void assemble_fermion_force(Twist_Fermion *sol, Twist_Fermion *psol) {
730743
}
731744
cleanup_gather(mtag[mu]);
732745
}
746+
#else
747+
FORALLDIR(mu) { // Zero force collectors
748+
FORALLSITES(i, s)
749+
clear_mat(&(s->f_U[mu]));
750+
}
733751
#endif
734752
#ifdef VP
735753
// Now calculate DU on chi_{munu} D_mu(U) psi_nu
@@ -875,6 +893,7 @@ void assemble_fermion_force(Twist_Fermion *sol, Twist_Fermion *psol) {
875893
}
876894
#endif
877895

896+
#ifdef SV
878897
// Plaquette determinant contributions if G is non-zero
879898
if (doG) {
880899
// First connect link_src with site_dest[DIMF - 1]^dag (LtoS)
@@ -883,6 +902,7 @@ void assemble_fermion_force(Twist_Fermion *sol, Twist_Fermion *psol) {
883902
// Second connect site_src[DIMF - 1] with link_dest^dag (StoL)
884903
detF(site_src, link_dest, MINUS);
885904
}
905+
#endif
886906

887907
#ifdef QCLOSED
888908
if (NUMLINK != 5) {

4d_Q16/susy/utilities.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -772,13 +772,25 @@ void fermion_op(Twist_Fermion *src, Twist_Fermion *dest, int sign) {
772772
node0_printf("Error: incorrect sign in fermion_op: %d\n", sign);
773773
terminate(1);
774774
}
775-
FORALLSITES(i, s)
775+
FORALLSITES(i, s) {
776+
// Optionally rescale to make fermion operator more symmetric
777+
#ifdef RESCALE
778+
scalar_mult_matrix(&(site_src[i]), 2.0, &(site_src[i]));
779+
#endif
776780
tr_eta[i] = trace(&(site_src[i]));
781+
}
777782

778783
// Assemble separate routines for each term in the fermion operator
779784
#ifdef VP
780785
Dplus(link_src, plaq_dest); // Overwrites plaq_dest
781786
Dminus(plaq_src, link_dest); // Overwrites link_dest
787+
#else
788+
FORALLSITES(i, s) { // Zero link_dest and plaq_dest
789+
FORALLDIR(mu)
790+
clear_mat(&(link_dest[mu][i]));
791+
for (mu = 0; mu < NPLAQ; mu++)
792+
clear_mat(&(plaq_dest[mu][i]));
793+
}
782794
#endif
783795

784796
#ifdef SV
@@ -794,13 +806,22 @@ void fermion_op(Twist_Fermion *src, Twist_Fermion *dest, int sign) {
794806
// Link-to-site plaquette determinant contribution if G is non-zero
795807
if (doG)
796808
detLtoS(link_src, site_dest); // Adds to site_dest
809+
#else
810+
FORALLSITES(i, s) // Zero site_dest
811+
clear_mat(&(site_dest[i]));
797812
#endif
798813

799814
#ifdef QCLOSED
800815
DbminusPtoP(plaq_src, plaq_dest); // Adds to plaq_dest
801816
DbplusPtoP(plaq_src, plaq_dest); // Adds to plaq_dest
802817
#endif
803818

819+
// Optionally rescale to make fermion operator more symmetric
820+
#ifdef RESCALE
821+
FORALLSITES(i, s)
822+
scalar_mult_matrix(&(site_dest[i]), 2.0, &(site_dest[i]));
823+
#endif
824+
804825
// Copy local plaquette, link and site fermions into dest TwistFermion
805826
if (sign == 1) {
806827
FORALLSITES(i, s) {
@@ -835,7 +856,7 @@ void DSq(Twist_Fermion *src, Twist_Fermion *dest) {
835856

836857
fermion_op(src, tempTF, PLUS);
837858
fermion_op(tempTF, dest, MINUS);
838-
if (fmass > IMAG_TOL) {
859+
if (fmass > IMAG_TOL) { // Assume fmass non-negative
839860
Real fmass2 = fmass * fmass;
840861
FORALLSITES(i, s)
841862
scalar_mult_sum_TF(&(src[i]), fmass2, &(dest[i]));

0 commit comments

Comments
 (0)