Skip to content

Commit

Permalink
Replaced old suNg copy functions
Browse files Browse the repository at this point in the history
  • Loading branch information
sofiemartins committed Apr 30, 2024
1 parent e59fca3 commit fb5fddb
Show file tree
Hide file tree
Showing 18 changed files with 64 additions and 121 deletions.
4 changes: 2 additions & 2 deletions GaugeFix/gaugefix_measure.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ int main(int argc, char *argv[]) {
double p1 = calc_plaq(u_gauge);
lprintf("TEST", 0, "u_gauge plaq %1.6f\n", p1);

suNg_field_copy(fixed_gauge, u_gauge);
copy_suNg_field(fixed_gauge, u_gauge);

double p2 = calc_plaq(fixed_gauge);
lprintf("TEST", 0, "fixed_gauge plaq %1.6f\n", p2);
Expand All @@ -186,7 +186,7 @@ int main(int argc, char *argv[]) {
p2 = calc_plaq(fixed_gauge);
lprintf("TEST", 0, "fixed_gauge plaq %1.6f\n", p2);

suNg_field_copy(u_gauge, fixed_gauge); //u_gauge = fixed_gauge
copy_suNg_field(u_gauge, fixed_gauge); //u_gauge = fixed_gauge
represent_gauge_field(); //u_gauge_f = represented fixed_gauge

if (list == NULL) { break; }
Expand Down
1 change: 0 additions & 1 deletion Include/Inverters/scalarfield_operations.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
extern "C" {
#endif

void scalar_field_copy(scalar_field *s1, scalar_field *s2);
void flip_scalar_field(scalar_field *s);
void set_scalar_field(scalar_field *s, double c);
void gaussian_scalar_field(scalar_field *s);
Expand Down
17 changes: 0 additions & 17 deletions Include/Update/copy_gfield.h

This file was deleted.

1 change: 0 additions & 1 deletion Include/update.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "Update/avr_plaquette.h"
#include "Update/cabmar.h"
#include "Update/clover_tools.h"
#include "Update/copy_gfield.h"
#include "Update/dirac.h"
#include "Update/field_update.h"
#include "Update/find_spec_limits.h"
Expand Down
10 changes: 0 additions & 10 deletions LibHR/Inverters/scalarfield_operations.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@
#include "libhr_core.h"
#include "random.h"

void scalar_field_copy(scalar_field *s1, scalar_field *s2) {
error(s1 == NULL, 1, "scalar_field_copy [scalarfield_operations.c]", "Attempt to access unallocated memory space");
error(s2 == NULL, 1, "scalar_field_copy [scalarfield_operations.c]", "Attempt to access unallocated memory space");

_MASTER_FOR(&glattice, ix) {
double c = *_FIELD_AT(s2, ix);
*_FIELD_AT(s1, ix) = c;
}
}

//s=-s
void flip_scalar_field(scalar_field *s) {
error(s == NULL, 1, "flip_scalar_field [scalarfield_operations.c]", "Attempt to access unallocated memory space");
Expand Down
5 changes: 2 additions & 3 deletions LibHR/Observables/loop_tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "io.h"
#include "utils.h"
#include "memory.h"
#include "Update/copy_gfield.h"
#include "Update/representation.h"
#include "Update/avr_plaquette.h"
#include "inverters.h"
Expand Down Expand Up @@ -300,7 +299,7 @@ void measure_loops(double *m, int nhits, int conf_num, double precision, int sou
}
if (source_type == 1) {
u_gauge_old = alloc_suNg_field(&glattice);
suNg_field_copy(u_gauge_old, u_gauge);
copy_suNg_field(u_gauge_old, u_gauge);
zero_spinor_field(prop);
//Fix the Gauge
double act = gaugefix(0, //= 0, 1, 2, 3 for Coulomb guage else Landau
Expand Down Expand Up @@ -394,7 +393,7 @@ void measure_loops(double *m, int nhits, int conf_num, double precision, int sou
} /* volume source + spin + color + eo dilution */
}
if (u_gauge_old != NULL) {
suNg_field_copy(u_gauge, u_gauge_old);
copy_suNg_field(u_gauge, u_gauge_old);
represent_gauge_field();
free_suNg_field(u_gauge_old);
}
Expand Down
30 changes: 15 additions & 15 deletions LibHR/Observables/meson_measurements.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ void measure_spectrum_pt_fixedbc(int tau, int dt, int nm, double *m, int n_mom,
zero_spinor_field(prop + i);
}
char label[100];
suNf_field_copy(u_gauge_old, u_gauge_f);
copy_suNf_field(u_gauge_old, u_gauge_f);
init_propagator_eo(nm, m, precision);
fix_T_bc(tau - dt); // Apply fixed boundaryconditions by zeroing links at time slice tau to direction 0.
lprintf("MAIN", 0, "Point Source at (%d,0,0,0) \n", tau);
Expand All @@ -227,7 +227,7 @@ void measure_spectrum_pt_fixedbc(int tau, int dt, int nm, double *m, int n_mom,
}
sprintf(label, "DIRICHLET_POINT dt=%d", dt);
print_mesons(meson_correlators, 1., conf_num, nm, m, GLB_T, n_mom, label);
suNf_field_copy(u_gauge_f, u_gauge_old);
copy_suNf_field(u_gauge_f, u_gauge_old);
free_spinor_field(source);
free_spinor_field(prop);
free_suNf_field(u_gauge_old);
Expand All @@ -253,7 +253,7 @@ void measure_diquark_semwall_background(int nm, double *m, int nhits, int conf_n

int tau, k;
suNg_field *u_gauge_old = alloc_suNg_field(&glattice);
suNg_field_copy(u_gauge_old, u_gauge);
copy_suNg_field(u_gauge_old, u_gauge);

error(nm != 1, 1, "measure_diquark_semwall_background", "nm cannot be different from 1 !\n");

Expand All @@ -266,15 +266,15 @@ void measure_diquark_semwall_background(int nm, double *m, int nhits, int conf_n
represent_gauge_field();
calc_propagator_eo(prop_u, source, 4); // 4 for spin dilution
// apply background and calculate second prop
suNg_field_copy(u_gauge, u_gauge_old);
copy_suNg_field(u_gauge, u_gauge_old);

apply_background_field_zdir(u_gauge, -Q, n);
represent_gauge_field();
calc_propagator_eo(prop_d, source, 4); // 4 for spin dilution

measure_diquarks(meson_correlators, prop_u, prop_d, source, nm, tau);

suNg_field_copy(u_gauge, u_gauge_old);
copy_suNg_field(u_gauge, u_gauge_old);
represent_gauge_field();
}
print_mesons(meson_correlators, nhits * GLB_VOL3 / 2., conf_num, nm, m, GLB_T, 1, "DEFAULT_DIQUARK_SEMWALL_BACKGROUND");
Expand Down Expand Up @@ -396,14 +396,14 @@ void measure_spectrum_semwall_fixedbc(int dt, int nm, double *m, int nhits, int
}

char label[100];
suNf_field_copy(u_gauge_old, u_gauge_f);
copy_suNf_field(u_gauge_old, u_gauge_f);
init_propagator_eo(nm, m, precision);
for (k = 0; k < nhits; ++k) {
tau = create_diluted_source_equal_eo(source);
fix_T_bc(tau - dt);
calc_propagator_eo(prop, source, 4); // 4 for spin dilution
measure_mesons(meson_correlators, prop, source, nm, tau);
suNf_field_copy(u_gauge_f, u_gauge_old);
copy_suNf_field(u_gauge_f, u_gauge_old);
}
sprintf(label, "DIRICHLET_SEMWALL dt=%d", dt);
print_mesons(meson_correlators, nhits * GLB_VOL3 / 2., conf_num, nm, m, GLB_T, 1, label);
Expand All @@ -426,7 +426,7 @@ void measure_spectrum_gfwall(int nm, double *m, int conf_num, double precision,
}
int tau, k;
tau = 0;
suNg_field_copy(u_gauge_old, u_gauge);
copy_suNg_field(u_gauge_old, u_gauge);
// Fix the Gauge
double act = gaugefix(0, //= 0, 1, 2, 3 for Coulomb guage else Landau
1.8, // overrelax
Expand All @@ -448,7 +448,7 @@ void measure_spectrum_gfwall(int nm, double *m, int conf_num, double precision,
}
print_mesons(meson_correlators, GLB_VOL3, conf_num, nm, m, GLB_T, 1, "DEFAULT_GFWALL");

suNg_field_copy(u_gauge, u_gauge_old);
copy_suNg_field(u_gauge, u_gauge_old);
represent_gauge_field();

free_propagator_eo();
Expand All @@ -468,7 +468,7 @@ void measure_spectrum_gfwall_fixedbc(int dt, int nm, double *m, int conf_num, do
}
int tau, k;
tau = 0;
suNg_field_copy(u_gauge_old, u_gauge);
copy_suNg_field(u_gauge_old, u_gauge);

// Fix the Gauge
double act = gaugefix(0, //= 0, 1, 2, 3 for Coulomb guage else Landau
Expand All @@ -493,7 +493,7 @@ void measure_spectrum_gfwall_fixedbc(int dt, int nm, double *m, int conf_num, do
}
print_mesons(meson_correlators, GLB_VOL3, conf_num, nm, m, GLB_T, 1, "DIRICHLET_GFWALL");

suNg_field_copy(u_gauge, u_gauge_old);
copy_suNg_field(u_gauge, u_gauge_old);
represent_gauge_field();

free_propagator_eo();
Expand Down Expand Up @@ -549,7 +549,7 @@ void measure_spectrum_discon_gfwall(int nm, double *m, int conf_num, double prec
int tau, k;
tau = 0;

suNg_field_copy(u_gauge_old, u_gauge);
copy_suNg_field(u_gauge_old, u_gauge);
// Fix the Gauge
double act = gaugefix(0, //= 0, 1, 2, 3 for Coulomb guage else Landau
1.8, // overrelax
Expand All @@ -574,7 +574,7 @@ void measure_spectrum_discon_gfwall(int nm, double *m, int conf_num, double prec
}
print_mesons(discon_correlators, GLB_T, conf_num, nm, m, GLB_T, 1, "DISCON_GFWALL");

suNg_field_copy(u_gauge, u_gauge_old);
copy_suNg_field(u_gauge, u_gauge_old);
represent_gauge_field();

free_propagator_eo();
Expand Down Expand Up @@ -659,7 +659,7 @@ void measure_formfactor_fixed(int ti, int tf, int dt, int nm, double *m, int n_m
int k;
char label[100];
suNf_field *u_gauge_old = alloc_suNf_field(&glattice);
suNf_field_copy(u_gauge_old, u_gauge_f); // Save the gaugefield
copy_suNf_field(u_gauge_old, u_gauge_f); // Save the gaugefield

double p = avr_plaquette();
lprintf("MESON_MEASUREMENTS", 0, "<P> = %g\n", p);
Expand Down Expand Up @@ -694,7 +694,7 @@ void measure_formfactor_fixed(int ti, int tf, int dt, int nm, double *m, int n_m

sprintf(label, "DIRICHLET_FF_POINT dt=%d", dt);
print_formfactor(conf_num, nm, m, n_mom, label, tf - ti);
suNf_field_copy(u_gauge_f, u_gauge_old); // Restore the gaugefield
copy_suNf_field(u_gauge_f, u_gauge_old); // Restore the gaugefield

free_spinor_field(source);
free_spinor_field(source_seq);
Expand Down
30 changes: 0 additions & 30 deletions LibHR/Update/copy_gfield.c

This file was deleted.

45 changes: 25 additions & 20 deletions LibHR/Update/update_mt.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,21 @@ void init_ghmc(ghmc_par *par) {

/* allocate space for the backup copy of suNg_field */
if (u_gauge_old == NULL) { u_gauge_old = alloc_suNg_field(&glattice); }
suNg_field_copy(u_gauge_old, u_gauge);
copy_suNg_field(u_gauge_old, u_gauge);
printf("plaq gauge: %0.15e\n", avr_plaquette(u_gauge_old));

/* allocate space for the backup copy of the scalar field */
if (u_scalar != NULL) {
if (u_scalar_old == NULL) { u_scalar_old = alloc_suNg_scalar_field(&glattice); }
suNg_scalar_field_copy(u_scalar_old, u_scalar);
copy_suNg_scalar_field(u_scalar_old, u_scalar);
}

/* allocate space for backup copy of four fermion fields */
if (four_fermion_active) {
if (ff_sigma_old == NULL) { ff_sigma_old = alloc_scalar_field(1, &glattice); }
if (ff_pi_old == NULL) { ff_pi_old = alloc_scalar_field(1, &glattice); }
scalar_field_copy(ff_sigma_old, ff_sigma);
scalar_field_copy(ff_pi_old, ff_pi);
copy_scalar_field(ff_sigma_old, ff_sigma);
copy_scalar_field(ff_pi_old, ff_pi);
}

/* allocate momenta */
Expand Down Expand Up @@ -184,11 +185,11 @@ int update_ghmc() {
lprintf("HMC", 10, "[DeltaS = %1.8e][exp(-DS) = %1.8e]\n", deltaH, exp(-deltaH));

if (deltaH < 0) {
suNg_field_copy(u_gauge_old, u_gauge);
if (u_scalar != NULL) { suNg_scalar_field_copy(u_scalar_old, u_scalar); }
copy_suNg_field(u_gauge_old, u_gauge);
if (u_scalar != NULL) { copy_suNg_scalar_field(u_scalar_old, u_scalar); }
if (four_fermion_active) {
scalar_field_copy(ff_sigma_old, ff_sigma);
scalar_field_copy(ff_pi_old, ff_pi);
copy_scalar_field(ff_sigma_old, ff_sigma);
copy_scalar_field(ff_pi_old, ff_pi);
}
} else {
double r;
Expand All @@ -204,19 +205,23 @@ int update_ghmc() {
bcast(&r, 1);

if (r > 0) {
suNg_field_copy(u_gauge_old, u_gauge);
if (u_scalar != NULL) { suNg_scalar_field_copy(u_scalar_old, u_scalar); }
copy_suNg_field(u_gauge_old, u_gauge);
if (u_scalar != NULL) { copy_suNg_scalar_field(u_scalar_old, u_scalar); }
if (four_fermion_active) {
scalar_field_copy(ff_sigma_old, ff_sigma);
scalar_field_copy(ff_pi_old, ff_pi);
copy_scalar_field(ff_sigma_old, ff_sigma);
copy_scalar_field(ff_pi_old, ff_pi);
}
} else {
lprintf("HMC", 10, "Configuration rejected.\n");
suNg_field_copy(u_gauge, u_gauge_old);
if (u_scalar != NULL) { suNg_scalar_field_copy(u_scalar, u_scalar_old); }
start_sendrecv_suNg_field(u_gauge);
printf("plaq old: %0.15e\n", avr_plaquette(u_gauge_old));
copy_suNg_field(u_gauge, u_gauge_old);
start_sendrecv_suNg_field(u_gauge);
printf("plaq after copy: %0.15e\n", avr_plaquette());
if (u_scalar != NULL) { copy_suNg_scalar_field(u_scalar, u_scalar_old); }
if (four_fermion_active) {
scalar_field_copy(ff_sigma, ff_sigma_old);
scalar_field_copy(ff_pi, ff_pi_old);
copy_scalar_field(ff_sigma, ff_sigma_old);
copy_scalar_field(ff_pi, ff_pi_old);
}
start_sendrecv_suNg_field(
u_gauge); /* this may not be needed if we always guarantee that we copy also the buffers */
Expand Down Expand Up @@ -306,11 +311,11 @@ int reverse_update_ghmc() {
global_sum(&deltaH, 1);
lprintf("HMC", 10, "[DeltaS = %1.8e][exp(-DS) = %1.8e]\n", deltaH, exp(-deltaH));

suNg_field_copy(u_gauge_old, u_gauge);
if (u_scalar != NULL) { suNg_scalar_field_copy(u_scalar_old, u_scalar); }
copy_suNg_field(u_gauge_old, u_gauge);
if (u_scalar != NULL) { copy_suNg_scalar_field(u_scalar_old, u_scalar); }
if (four_fermion_active) {
scalar_field_copy(ff_sigma_old, ff_sigma);
scalar_field_copy(ff_pi_old, ff_pi);
copy_scalar_field(ff_sigma_old, ff_sigma);
copy_scalar_field(ff_pi_old, ff_pi);
}

lprintf("HMC", 10, "Configuration accepted.\n");
Expand Down
8 changes: 4 additions & 4 deletions LibHR/Utils/background_field.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void apply_background_field_zdir(suNg_field *V, double Q, int n) {

Vtest_old = alloc_suNg_field(&glattice);
Vtest_new = alloc_suNg_field(&glattice);
suNg_field_copy(Vtest_old, V);
copy_suNg_field(Vtest_old, V);

start_sendrecv_suNg_field(Vtest_old);
complete_sendrecv_suNg_field(Vtest_old);
Expand Down Expand Up @@ -69,7 +69,7 @@ void apply_background_field_zdir(suNg_field *V, double Q, int n) {
diff_re = 0.;
diff_im = 0.;

suNg_field_copy(Vtest_new, V);
copy_suNg_field(Vtest_new, V);
complete_sendrecv_suNg_field(Vtest_new);

for (c[0] = 0; c[0] < T; c[0]++) {
Expand All @@ -89,7 +89,7 @@ void apply_background_field_zdir(suNg_field *V, double Q, int n) {
_complex_div(tmp2, tmp, phase);

// restore old gauge field
suNg_field_copy(V, Vtest_old);
copy_suNg_field(V, Vtest_old);

start_sendrecv_suNg_field(V);
complete_sendrecv_suNg_field(V);
Expand All @@ -101,7 +101,7 @@ void apply_background_field_zdir(suNg_field *V, double Q, int n) {
diff_im += fabs(cimag(tmp2 - tmp));

// restore new gauge field
suNg_field_copy(V, Vtest_new);
copy_suNg_field(V, Vtest_new);

start_sendrecv_suNg_field(V);
complete_sendrecv_suNg_field(V);
Expand Down
Loading

0 comments on commit fb5fddb

Please sign in to comment.