Skip to content

Commit

Permalink
Merge pull request etmc#185 from kostrzewa/oriented_plaquettes
Browse files Browse the repository at this point in the history
add function to measure oriented plaquettes
  • Loading branch information
urbach committed Dec 11, 2012
2 parents 0437e50 + 2aee76d commit 1d420db
Show file tree
Hide file tree
Showing 8 changed files with 232 additions and 12 deletions.
7 changes: 5 additions & 2 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ COMPILE = ${CC} ${DEFS} ${INCLUDES} -o $@ ${CFLAGS}
SMODULES =

MODULES = read_input gamma hybrid_update measure_gauge_action start \
measure_oriented_plaquettes \
expo get_staples update_backward_gauge \
measure_rectangles get_rectangle_staples \
test/check_geometry test/check_xchange \
Expand Down Expand Up @@ -87,9 +88,11 @@ ${top_srcdir}/git_hash.h:

include ${top_srcdir}/Makefile.global

ifneq (,$(findstring lex,${LEX}))
${top_srcdir}/read_input.c: ${top_srcdir}/read_input.l
@${LEX} -Ptmlqcd -i -t ${top_srcdir}/read_input.l > ${top_srcdir}/read_input.c
ifneq (,$(findstring lex,${LEX}))
${LEX} -Ptmlqcd -i -t ${top_srcdir}/read_input.l > ${top_srcdir}/read_input.c
else
$(error Unable to find (f)lex, read_input.c not built. Please install (f)lex!)
endif

libhmc.a: ${addsuffix .o, ${MODULES} ${SMODULES}} Makefile
Expand Down
26 changes: 26 additions & 0 deletions fatal_error.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,36 @@
/***********************************************************************
*
* Copyright (C) 2012 Carsten Urbach
*
* This file is part of tmLQCD.
*
* tmLQCD is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* tmLQCD is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with tmLQCD. If not, see <http://www.gnu.org/licenses/>.
***********************************************************************/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <stdio.h>
#include <global.h>

#ifdef MPI
#include <mpi.h>
#endif

#include "fatal_error.h"

void fatal_error(char const *error, char const *function)
{
if (error != NULL)
Expand Down
29 changes: 29 additions & 0 deletions fatal_error.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/***********************************************************************
*
* Copyright (C) 2012 Carsten Urbach
*
* This file is part of tmLQCD.
*
* tmLQCD is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* tmLQCD is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with tmLQCD. If not, see <http://www.gnu.org/licenses/>.
***********************************************************************/

#ifndef _FATAL_ERROR_H
#define _FATAL_ERROR_H

/* Function to cleanly exit the program with an error messages. The two parameters
are strings describing the error and identifying the originating function respectively */

void fatal_error(char const *error, char const *function);

#endif
109 changes: 109 additions & 0 deletions measure_oriented_plaquettes.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/***********************************************************************
*
* Copyright (C) 2001 Martin Hasenbusch, 2012 Bartosz Kostrzewa
*
* This file is part of tmLQCD.
*
* tmLQCD is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* tmLQCD is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with tmLQCD. If not, see <http://www.gnu.org/licenses/>.
*
************************************************************************/

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifdef OMP
# include <omp.h>
#endif

#include <string.h>
#include <stdio.h>

#include "su3.h"
#include "geometry_eo.h"
#include "global.h"
#include "measure_oriented_plaquettes.h"
#include "fatal_error.h"


void measure_oriented_plaquettes(const su3 ** const gf, double *plaq) {
#ifdef MPI
double ALIGN mplaq[6];
#endif

int ix,ix1,ix2,mu1,mu2,plane;
su3 ALIGN pr1,pr2;
const su3 *v,*w;
double ALIGN pl;
double ALIGN ks[6] = {0.0,0.0,0.0,0.0,0.0,0.0};
double ALIGN kc[6] = {0.0,0.0,0.0,0.0,0.0,0.0};
double ALIGN tr[6],ts[6],tt[6];

for (ix=0;ix<VOLUME;ix++){
plane = 0;
for (mu1=0;mu1<3;mu1++){
ix1=g_iup[ix][mu1];
for (mu2=mu1+1;mu2<4;mu2++){
ix2=g_iup[ix][mu2];
v=&gf[ix][mu1];
w=&gf[ix1][mu2];
_su3_times_su3(pr1,*v,*w);
v=&gf[ix][mu2];
w=&gf[ix2][mu1];
_su3_times_su3(pr2,*v,*w);
_trace_su3_times_su3d(pl,pr1,pr2);
tr[plane]=pl+kc[plane];
ts[plane]=tr[plane]+ks[plane];
tt[plane]=ts[plane]-ks[plane];
ks[plane]=ts[plane];
kc[plane]=tr[plane]-tt[plane];
++plane;
}
}
}

for(int j = 0; j < 6; ++j) {
kc[j]=(kc[j]+ks[j])/3.0;
plaq[j] = kc[j]/(g_nproc*VOLUME);
}

#ifdef MPI
MPI_Allreduce(plaq, mplaq, 6, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
for(int j = 0; j < 6; j++)
plaq[j] = mplaq[j];
#endif
return;
}

void oriented_plaquettes_measurement(const int traj, const int id, const int ieo) {
double plaq[6];
measure_oriented_plaquettes((const su3** const)g_gauge_field,plaq);

if( g_proc_id == 0 ) {
FILE *outfile;
char filename[] = "oriented_plaquettes.data";
outfile = fopen(filename,"a");

if( outfile == NULL ) {
char error_message[200];
snprintf(error_message,200,"Couldn't open %s for appending during measurement %d!",filename, id);
fatal_error(error_message,"oriented_plaquettes_measurement");
}

fprintf(outfile, "%.8d %14.12lf %14.12lf %14.12lf %14.12lf %14.12lf %14.12lf\n",traj,plaq[0],plaq[1],plaq[2],plaq[3],plaq[4],plaq[5]);
fclose(outfile);
}

return;
}

39 changes: 39 additions & 0 deletions measure_oriented_plaquettes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/***********************************************************************
*
* Copyright (C) 2001 Martin Hasenbusch, 2012 Bartosz Kostrzewa
*
* This file is part of tmLQCD.
*
* tmLQCD is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* tmLQCD is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with tmLQCD. If not, see <http://www.gnu.org/licenses/>.
***********************************************************************/

#ifndef _MEASURE_ORIENTED_PLAQUETTES_H
#define _MEASURE_ORIENTED_PLAQUETTES_H

#include "su3.h"

/* measures the lattice average of plaquettes oriented in the 6
hyperplanes TX, TY, TZ, XY, XZ, YZ and stores them in this
order in the plaq array (of 6 elements)
the caller must provide the memory for plaq */

void measure_oriented_plaquettes(const su3 ** const gf, double *plaq);

/* implements the online measurement function for the oriented
plaquettes, writes (in append mode) into "oriented_plaquettes.data" */

void oriented_plaquettes_measurement(const int traj, const int id, const int ieo);

#endif
8 changes: 7 additions & 1 deletion measurements.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,20 @@
#include "pion_norm.h"
#include "online_measurement.h"
#include "polyakov_loop.h"
#include "measure_oriented_plaquettes.h"
#include "measurements.h"

measurement measurement_list[max_no_measurements];
int no_measurements = 0;

int add_measurement(const int type) {
int add_measurement(const enum MEAS_TYPE meas_type) {

if(no_measurements == max_no_measurements) {
fprintf(stderr, "maximal number of measurementss %d exceeded!\n", max_no_measurements);
exit(-1);
}
measurement_list[no_measurements].measurefunc = &dummy_meas;
measurement_list[no_measurements].type = meas_type;
measurement_list[no_measurements].initialised = 1;
no_measurements++;
return(no_measurements);
Expand All @@ -66,6 +68,10 @@ int init_measurements(){
if(measurement_list[i].type == POLYAKOV) {
measurement_list[i].measurefunc = &polyakov_loop_measurement;
}

if(measurement_list[i].type == ORIENTED_PLAQUETTES) {
measurement_list[i].measurefunc = oriented_plaquettes_measurement;
}

measurement_list[i].id = i;
}
Expand Down
16 changes: 9 additions & 7 deletions measurements.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@

#define max_no_measurements 20


/* Give the measurements a unambiguous number*/
#define ONLINE 0
#define PIONNORM 1
#define POLYAKOV 2
/* Give the measurement types an unambiguous ID*/
enum MEAS_TYPE {
ONLINE,
PIONNORM,
POLYAKOV,
ORIENTED_PLAQUETTES
};

typedef struct {
int type;
enum MEAS_TYPE type;
int initialised;
int id;

Expand Down Expand Up @@ -61,7 +63,7 @@ extern measurement measurement_list[max_no_measurements];
extern int no_measurements;

/* add a new measurement to the list of measurements */
int add_measurement(const int type);
int add_measurement(const enum MEAS_TYPE);
/* initialise all measurements in the list */
int init_measurements();
/* free space again */
Expand Down
10 changes: 8 additions & 2 deletions read_input.l
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ inline void rmQuotes(char *str){
%x ONLINEMEAS
%x PIONNORMMEAS
%x PLOOP
%x ORIENTEDPLAQUETTESMEAS
%x REWEIGH
%x REWSAMPLES
Expand Down Expand Up @@ -1299,6 +1300,10 @@ inline void rmQuotes(char *str){
else if(strcmp(yytext, "POLYAKOVLOOP")==0) {
meas->type = POLYAKOV;
strcpy((*meas).name, "POLYAKOV");
}
else if(strcmp(yytext, "ORIENTEDPLAQUETTES")==0) {
meas->type = ORIENTED_PLAQUETTES;
strcpy(meas->name, "ORIENTEDPLAQUETTES");
}
else {
fprintf(stderr, "Unknown measurement type %s in line %d\n", yytext, line_of_file);
Expand All @@ -1319,9 +1324,10 @@ inline void rmQuotes(char *str){
if(meas->type == ONLINE) BEGIN(ONLINEMEAS);
else if(meas->type == PIONNORM) BEGIN(PIONNORMMEAS);
else if(meas->type == POLYAKOV) BEGIN(PLOOP);
else if(meas->type == ORIENTED_PLAQUETTES) BEGIN(ORIENTEDPLAQUETTESMEAS);
}

<ONLINEMEAS,PIONNORMMEAS,PLOOP>{
<ONLINEMEAS,PIONNORMMEAS,PLOOP,ORIENTEDPLAQUETTESMEAS>{
^EndMeasurement{SPC}* {
if(myverbose) printf("Measurement with id %d parsed in line %d\n\n", meas->id, line_of_file);
BEGIN(0);
Expand Down Expand Up @@ -1840,7 +1846,7 @@ inline void rmQuotes(char *str){
}


<INITMONOMIAL,DETMONOMIAL,CLDETMONOMIAL,CLDETRATMONOMIAL,NDPOLYMONOMIAL,CLPOLYMONOMIAL,GAUGEMONOMIAL,INTEGRATOR,INITINTEGRATOR,INITMEASUREMENT,PIONNORMMEAS,ONLINEMEAS,INITOPERATOR,TMOP,DBTMOP,OVERLAPOP,WILSONOP,CLOVEROP,DBCLOVEROP,POLYMONOMIAL,PLOOP,INITGPU,GPU>\n {
<INITMONOMIAL,DETMONOMIAL,CLDETMONOMIAL,CLDETRATMONOMIAL,NDPOLYMONOMIAL,CLPOLYMONOMIAL,GAUGEMONOMIAL,INTEGRATOR,INITINTEGRATOR,INITMEASUREMENT,PIONNORMMEAS,ONLINEMEAS,ORIENTEDPLAQUETTESMEAS,INITOPERATOR,TMOP,DBTMOP,OVERLAPOP,WILSONOP,CLOVEROP,DBCLOVEROP,POLYMONOMIAL,PLOOP,INITGPU,GPU>\n {
line_of_file++;
}
<*>\n {
Expand Down

0 comments on commit 1d420db

Please sign in to comment.