//------------------------------------------------------------------ AlgEig::AlgEig(Lattice& latt, CommonArg *c_arg, EigArg *arg) : Alg(latt, c_arg) { cname = "AlgEig"; char *fname = "AlgEig(L&,CommonArg*,EigArg*)"; VRB.Func(cname,fname); // Initialize the argument pointer //---------------------------------------------------------------- if(arg == 0) ERR.Pointer(cname,fname, "arg"); alg_eig_arg = arg; Ncb = NumChkb(alg_eig_arg->RitzMatOper); // Set the node size of the full (non-checkerboarded) fermion field // NOTE: at this point we must know on what lattice size the operator // will act. //---------------------------------------------------------------- int f_size = GJP.VolNodeSites() * latt.FsiteSize() * Ncb / 2; VRB.Flow(cname,fname,"f_size=%d\n",0); // int f_size = GJP.VolNodeSites() * Ncb / 2; // exit(1); //VRB.Flow(cname,fname,"Doing Ritz"); int N_eig = alg_eig_arg->N_eig; // Allocate memory for the eigenvectors and eigenvalues //---------------------------------------------------------------- eigenv = (Vector **) smalloc (cname,fname, "eigenv", N_eig * sizeof(Vector *)); for(int n = 0; n < N_eig; ++n) { eigenv[n] = (Vector *) smalloc(cname,fname, "eigenv[n]", (f_size)* sizeof(Float)); } lambda = (Float *) smalloc(cname,fname, "lambda", 2*N_eig * sizeof(Float)); chirality = (Float *) smalloc(cname,fname,"chirality", N_eig * sizeof(Float)); valid_eig = (int *) smalloc(cname,fname,"valid_eig",N_eig * sizeof(int)); // Print out input parameters //---------------------------------------------------------------- VRB.Input(cname,fname, "N_eig = %d\n",int(N_eig)); VRB.Input(cname,fname, "MaxCG = %d\n",alg_eig_arg->MaxCG); VRB.Input(cname,fname, "Mass_init = %g\n",IFloat(alg_eig_arg->Mass_init)); VRB.Input(cname,fname, "Mass_final = %g\n",IFloat(alg_eig_arg->Mass_final)); VRB.Input(cname,fname, "Mass_step = %g\n",IFloat(alg_eig_arg->Mass_step)); // Calculate n_masses if necessary VRB.Flow(cname,fname,"alg_eig_arg->pattern_kind=%d\n",alg_eig_arg->pattern_kind); switch( alg_eig_arg->pattern_kind ) { case ARRAY: n_masses = alg_eig_arg->Mass.Mass_len; break; case LOG: n_masses = (int) ((log(alg_eig_arg->Mass_final - alg_eig_arg->Mass_init) / log(alg_eig_arg->Mass_step)) + 1.000001); break; case LIN: n_masses = (int) (fabs((alg_eig_arg->Mass_final - alg_eig_arg->Mass_init)/alg_eig_arg->Mass_step) + 1.000001); break; default: ERR.General(cname, fname, "alg_eig_arg->pattern_kind = %d is unrecognized\n", alg_eig_arg->pattern_kind); break; } VRB.FuncEnd(cname,fname); }
CPS_START_NAMESPACE /*!\file \brief Methods of the AlgPbp class. $Id: alg_pbp.C,v 1.14 2012-07-06 20:22:08 chulwoo Exp $ */ //-------------------------------------------------------------------- // CVS keywords // // $Author: chulwoo $ // $Date: 2012-07-06 20:22:08 $ // $Header: /home/chulwoo/CPS/repo/CVS/cps_only/cps_pp/src/alg/alg_pbp/alg_pbp.C,v 1.14 2012-07-06 20:22:08 chulwoo Exp $ // $Id: alg_pbp.C,v 1.14 2012-07-06 20:22:08 chulwoo Exp $ // $Name: not supported by cvs2svn $ // $Locker: $ // $RCSfile: alg_pbp.C,v $ // $Revision: 1.14 $ // $Source: /home/chulwoo/CPS/repo/CVS/cps_only/cps_pp/src/alg/alg_pbp/alg_pbp.C,v $ // $State: Exp $ // //-------------------------------------------------------------------- //------------------------------------------------------------------ // // alg_pbp.C // // AlgPbp is derived from Alg and is relevant to the // stochastic measurement of PsiBar Psi using the // Conjugate Gradient algorithm. The type of fermion is // determined by the argument to the constructor. // // PsiBarPsi is normalized so that for large values of the // PbpArg.mass PsiBarPsi = 1 / mass for any fermion type. // This normalization results to the following small mass // behavior for a trivial background gauge field with periodic // boundary conditions: // Staggered = 16 / ( Volume * mass ) // Wilson = 1 / ( Volume * mass ) // Dwf = 1 / ( Volume * mass ) // //------------------------------------------------------------------ CPS_END_NAMESPACE #include <util/qcdio.h> #include <alg/alg_pbp.h> #include <util/lattice.h> #include <util/gjp.h> #include <util/smalloc.h> #include <util/vector.h> #include <util/verbose.h> #include <util/error.h> CPS_START_NAMESPACE #define POINT #undef POINT #define Z2 #undef Z2 //------------------------------------------------------------------ /*! \param latt The lattice on which to compute the condensate. \param c_arg The common argument structure for all algorithms. \param arg The algorithm parameters. */ //------------------------------------------------------------------ AlgPbp::AlgPbp(Lattice& latt, CommonArg *c_arg, PbpArg *arg) : Alg(latt, c_arg) { cname = "AlgPbp"; char *fname = "AlgPbp(L&,CommonArg*,PbpArg*)"; VRB.Func(cname,fname); // Initialize the argument pointer //---------------------------------------------------------------- if(arg == 0) ERR.Pointer(cname,fname, "arg"); alg_pbp_arg = arg; // Set the node size of the full (non-checkerboarded) fermion field //---------------------------------------------------------------- f_size = GJP.VolNodeSites() * latt.FsiteSize(); // Allocate memory for the source. //---------------------------------------------------------------- src = (Vector *) smalloc(f_size * sizeof(Float)); if(src == 0) ERR.Pointer(cname,fname, "src"); VRB.Smalloc(cname,fname, "src", src, f_size * sizeof(Float)); // Allocate memory for the solution //---------------------------------------------------------------- sol = (Vector *) smalloc(f_size * sizeof(Float)); if(sol == 0) ERR.Pointer(cname,fname, "sol"); VRB.Smalloc(cname,fname, "sol", sol, f_size * sizeof(Float)); }
CPS_START_NAMESPACE //------------------------------------------------------------------ /*! \param latt The lattice on which the HMC algorithm runs. \param c_arg The common argument structure for all algorithms. \param arg The algorithm parameters. */ //------------------------------------------------------------------ AlgHmcQPQ::AlgHmcQPQ(Lattice& latt, CommonArg *c_arg, HmdArg *arg) : AlgHmd(latt, c_arg, arg) { int i, j; cname = "AlgHmcQPQ"; char *fname = "AlgHmcQPQ(L&,CommonArg*,HmdArg*)"; VRB.Func(cname,fname); int n_masses; // Initialize the number of dynamical fermion masses //---------------------------------------------------------------- n_frm_masses = hmd_arg->n_frm_masses; if(n_frm_masses > MAX_HMD_MASSES) { ERR.General(cname,fname, "hmd_arg->n_frm_masses = %d is larger than MAX_HMD_MASSES = %d\n", n_frm_masses, MAX_HMD_MASSES); } // Initialize the number of dynamical boson masses //---------------------------------------------------------------- n_bsn_masses = hmd_arg->n_bsn_masses; if(n_bsn_masses > MAX_HMD_MASSES) { ERR.General(cname,fname, "hmd_arg->n_bsn_masses = %d is larger than MAX_HMD_MASSES = %d\n", n_bsn_masses, MAX_HMD_MASSES); } // Calculate the fermion field size. //---------------------------------------------------------------- f_size = GJP.VolNodeSites() * latt.FsiteSize() / (latt.FchkbEvl()+1); // Allocate memory for the fermion CG arguments. //---------------------------------------------------------------- if(n_frm_masses != 0) { frm_cg_arg = (CgArg **) smalloc(n_frm_masses * sizeof(int)); if(frm_cg_arg == 0) ERR.Pointer(cname,fname, "frm_cg_arg"); VRB.Smalloc(cname,fname, "frm_cg_arg",frm_cg_arg, n_frm_masses * sizeof(int)); for(i=0; i<n_frm_masses; i++) { frm_cg_arg[i] = (CgArg *) smalloc(sizeof(CgArg)); if(frm_cg_arg[i] == 0) ERR.Pointer(cname,fname, "frm_cg_arg[i]"); VRB.Smalloc(cname,fname, "frm_cg_arg[i]", frm_cg_arg[i], sizeof(CgArg)); } } // Initialize the fermion CG arguments //---------------------------------------------------------------- //??? Complete this for(i=0; i<n_frm_masses; i++) { frm_cg_arg[i]->mass = hmd_arg->frm_mass[i]; frm_cg_arg[i]->max_num_iter = hmd_arg->max_num_iter[i]; frm_cg_arg[i]->stop_rsd = hmd_arg->stop_rsd[i]; } // Allocate memory for the boson CG arguments. //---------------------------------------------------------------- if(n_bsn_masses != 0) { bsn_cg_arg = (CgArg **) smalloc(n_bsn_masses * sizeof(int)); if(bsn_cg_arg == 0) ERR.Pointer(cname,fname, "bsn_cg_arg"); VRB.Smalloc(cname,fname, "bsn_cg_arg",bsn_cg_arg, n_bsn_masses * sizeof(int)); for(i=0; i<n_bsn_masses; i++) { bsn_cg_arg[i] = (CgArg *) smalloc(sizeof(CgArg)); if(bsn_cg_arg[i] == 0) ERR.Pointer(cname,fname, "bsn_cg_arg[i]"); VRB.Smalloc(cname,fname, "bsn_cg_arg[i]", bsn_cg_arg[i], sizeof(CgArg)); } } // Initialize the boson CG arguments //---------------------------------------------------------------- //??? Complete this for(i=0; i<n_bsn_masses; i++) { bsn_cg_arg[i]->mass = hmd_arg->bsn_mass[i]; bsn_cg_arg[i]->max_num_iter = hmd_arg->max_num_iter[i]; bsn_cg_arg[i]->stop_rsd = hmd_arg->stop_rsd[i]; } // Allocate memory for the phi pseudo fermion field. //---------------------------------------------------------------- if(n_frm_masses != 0) { phi = (Vector **) smalloc(n_frm_masses * sizeof(int)); if(phi == 0) ERR.Pointer(cname,fname, "phi"); VRB.Smalloc(cname,fname, "phi",phi, n_frm_masses * sizeof(int)); for(i=0; i<n_frm_masses; i++) { phi[i] = (Vector *) smalloc(f_size * sizeof(Float)); if(phi[i] == 0) ERR.Pointer(cname,fname, "phi[i]"); VRB.Smalloc(cname,fname, "phi[i]", phi[i], f_size * sizeof(Float)); } } // Allocate memory for the chronological inverter. //---------------------------------------------------------------- if(n_frm_masses != 0) { cg_sol = (Vector ***) smalloc(n_frm_masses * sizeof(Vector**)); if(cg_sol == 0) ERR.Pointer(cname,fname, "cg_sol_prev"); VRB.Smalloc(cname,fname, "cg_sol", cg_sol, n_frm_masses * sizeof(Vector**)); if (hmd_arg->chrono > 0) { vm = (Vector ***) smalloc(n_frm_masses * sizeof(Vector**)); if(vm == 0) ERR.Pointer(cname,fname, "vm"); VRB.Smalloc(cname,fname, "vm", vm, n_frm_masses * sizeof(Vector**)); cg_sol_prev = (Vector **) smalloc(hmd_arg->chrono * sizeof(Vector*)); if(cg_sol_prev == 0) ERR.Pointer(cname,fname, "cg_sol_prev"); VRB.Smalloc(cname,fname, "cg_sol_prev", cg_sol_prev, hmd_arg->chrono * sizeof(Vector**)); for(i=0; i<n_frm_masses; i++) { cg_sol[i] = (Vector **) smalloc(hmd_arg->chrono * sizeof(Vector*)); if(cg_sol[i] == 0) ERR.Pointer(cname,fname, "cg_sol[i]"); VRB.Smalloc(cname,fname, "cg_sol[i]", cg_sol[i], hmd_arg->chrono * sizeof(Vector*)); vm[i] = (Vector **) smalloc(hmd_arg->chrono * sizeof(Vector*)); if(vm[i] == 0) ERR.Pointer(cname,fname, "vm[i]"); VRB.Smalloc(cname,fname, "vm[i]", vm[i], hmd_arg->chrono * sizeof(Vector*)); for(j=0; j<hmd_arg->chrono; j++) { cg_sol[i][j] = (Vector *) smalloc(f_size * sizeof(Float)); if(cg_sol[i][j] == 0) ERR.Pointer(cname,fname, "cg_sol[i][j]"); VRB.Smalloc(cname,fname, "cg_sol[i][j]", cg_sol[i][j], f_size * sizeof(Float)); vm[i][j] = (Vector *) smalloc(f_size * sizeof(Float)); if(vm[i][j] == 0) ERR.Pointer(cname,fname, "vm[i][j]"); VRB.Smalloc(cname,fname, "vm[i][j]", vm[i][j], f_size * sizeof(Float)); } } } else if (hmd_arg->chrono == 0) { for(i=0; i<n_frm_masses; i++) { cg_sol[i] = (Vector **) smalloc(sizeof(Vector*)); if(cg_sol[i] == 0) ERR.Pointer(cname,fname, "cg_sol[i]"); VRB.Smalloc(cname,fname, "cg_sol[i]", cg_sol[i], sizeof(Vector*)); cg_sol[i][0] = (Vector *) smalloc(f_size * sizeof(Float)); if(cg_sol[i][0] == 0) ERR.Pointer(cname,fname, "cg_sol[i][0]"); VRB.Smalloc(cname,fname, "cg_sol[i][0]", cg_sol[i][0], f_size * sizeof(Float)); } } } // Allocate memory for the boson field bsn. //---------------------------------------------------------------- if(n_bsn_masses != 0) { bsn = (Vector **) smalloc(n_bsn_masses * sizeof(int)); if(bsn == 0) ERR.Pointer(cname,fname, "bsn"); VRB.Smalloc(cname,fname, "bsn",bsn, n_bsn_masses * sizeof(int)); for(i=0; i<n_bsn_masses; i++) { bsn[i] = (Vector *) smalloc(f_size * sizeof(Float)); if(bsn[i] == 0) ERR.Pointer(cname,fname, "bsn[i]"); VRB.Smalloc(cname,fname, "bsn[i]", bsn[i], f_size * sizeof(Float)); } } // Allocate memory for the initial gauge field. //---------------------------------------------------------------- gauge_field_init = (Matrix *) smalloc(g_size * sizeof(Float)); if(gauge_field_init == 0) ERR.Pointer(cname,fname, "gauge_field_init"); VRB.Smalloc(cname,fname, "gauge_field_init",gauge_field_init, g_size * sizeof(Float)); // Allocate memory for 2 general purpose fermion/boson field // arrays (frm1,frm2). //---------------------------------------------------------------- n_masses = n_frm_masses; if(n_bsn_masses > n_frm_masses) n_masses = n_bsn_masses; if(n_masses != 0) { frm1 = (Vector **) smalloc(n_masses * sizeof(int)); if(frm1 == 0) ERR.Pointer(cname,fname, "frm1"); VRB.Smalloc(cname,fname, "frm1",frm1, n_masses * sizeof(int)); frm2 = (Vector **) smalloc(n_masses * sizeof(int)); if(frm2 == 0) ERR.Pointer(cname,fname, "frm2"); VRB.Smalloc(cname,fname, "frm2",frm2, n_masses * sizeof(int)); for(i=0; i<n_masses; i++) { frm1[i] = (Vector *) smalloc(f_size * sizeof(Float)); if(frm1[i] == 0) ERR.Pointer(cname,fname, "frm1[i]"); VRB.Smalloc(cname,fname, "frm1[i]", frm1[i], f_size * sizeof(Float)); frm2[i] = (Vector *) smalloc(f_size * sizeof(Float)); if(frm2[i] == 0) ERR.Pointer(cname,fname, "frm2[i]"); VRB.Smalloc(cname,fname, "frm2[i]", frm2[i], f_size * sizeof(Float)); } } }
CPS_START_NAMESPACE /*!\file \brief Methods of the AlgDens class. $Id: alg_dens.C,v 1.8 2008-02-14 20:45:44 chulwoo Exp $ */ //-------------------------------------------------------------------- // CVS keywords // // $Author: chulwoo $ // $Date: 2008-02-14 20:45:44 $ // $Header: /home/chulwoo/CPS/repo/CVS/cps_only/cps_pp/src/alg/alg_dens/alg_dens.C,v 1.8 2008-02-14 20:45:44 chulwoo Exp $ // $Id: alg_dens.C,v 1.8 2008-02-14 20:45:44 chulwoo Exp $ // $Name: not supported by cvs2svn $ // $Locker: $ // $RCSfile: alg_dens.C,v $ // $Revision: 1.8 $ // $Source: /home/chulwoo/CPS/repo/CVS/cps_only/cps_pp/src/alg/alg_dens/alg_dens.C,v $ // $State: Exp $ // //-------------------------------------------------------------------- //------------------------------------------------------------------ // // alg_dens.C // // AlgDens is derived from Alg and is relevant to the // stochastic measurement of derivatives of the partition function // with respect to the chemical potential using the // Conjugate Gradient algorithm. The type of fermion is // determined by the argument to the constructor. // //------------------------------------------------------------------ CPS_END_NAMESPACE #include <util/qcdio.h> #include <alg/alg_dens.h> #include <util/lattice.h> #include <util/gjp.h> #include <util/smalloc.h> #include <util/vector.h> #include <util/verbose.h> #include <util/error.h> CPS_START_NAMESPACE #define POINT #undef POINT #define Z2 #undef Z2 //------------------------------------------------------------------ /*! \param latt The lattice on which to compute the condensate. \param c_arg The common argument structure for all algorithms. \param arg The algorithm parameters. */ //------------------------------------------------------------------ AlgDens::AlgDens(Lattice& latt, CommonArg *c_arg, DensArg *arg) : Alg(latt, c_arg) { cname = "AlgDens"; char *fname = "AlgDens(L&,CommonArg*,DensArg*)"; VRB.Func(cname,fname); // Initialize the argument pointer //---------------------------------------------------------------- if(arg == 0) ERR.Pointer(cname,fname, "arg"); alg_dens_arg = arg; // Set the node size of the full (non-checkerboarded) fermion field //---------------------------------------------------------------- f_size = GJP.VolNodeSites() * latt.FsiteSize(); // Allocate memory for the source. //---------------------------------------------------------------- src = (Vector *) smalloc(f_size * sizeof(Float)); if(src == 0) ERR.Pointer(cname,fname, "src"); VRB.Smalloc(cname,fname, "src", src, f_size * sizeof(Float)); srcM = (Vector *) smalloc(f_size * sizeof(Float)); if(srcM == 0) ERR.Pointer(cname,fname, "srcM"); VRB.Smalloc(cname,fname, "srcM", srcM, f_size * sizeof(Float)); // Allocate memory for the solutions //---------------------------------------------------------------- save = (Vector *) smalloc(f_size * (alg_dens_arg->max_save) * sizeof(Float)); if(save == 0) ERR.Pointer(cname,fname, "save"); VRB.Smalloc(cname,fname, "save", save, f_size * (alg_dens_arg->max_save) * sizeof(Float)); sol = (Vector *) smalloc(f_size * sizeof(Float)); if(sol == 0) ERR.Pointer(cname,fname, "sol"); VRB.Smalloc(cname,fname, "sol", sol, f_size * sizeof(Float)); solM = (Vector *) smalloc(f_size * sizeof(Float)); if(solM == 0) ERR.Pointer(cname,fname, "solM"); VRB.Smalloc(cname,fname, "solM", solM, f_size * sizeof(Float)); //map_table = (int *) smalloc( (alg_dens_arg->max_save) * sizeof(int)); //if(map_table == 0) // ERR.Pointer(cname,fname, "map_table"); //VRB.Smalloc(cname,fname, "map_table", map_table, (alg_dens_arg->max_save) * sizeof(int)); //save_table = (int *) smalloc( (alg_dens_arg->n_obs) * sizeof(int)); //if(save_table == 0) // ERR.Pointer(cname,fname, "save_table"); //VRB.Smalloc(cname,fname, "save_table", save_table, (alg_dens_arg->n_obs) * sizeof(int)); //load_table = (int *) smalloc( (alg_dens_arg->n_obs) * sizeof(int)); //if(load_table == 0) // ERR.Pointer(cname,fname, "load_table"); //VRB.Smalloc(cname,fname, "load_table", load_table, (alg_dens_arg->n_obs) * sizeof(int)); //refresh_table = (int *) smalloc( (alg_dens_arg->n_obs) * sizeof(int)); //if(refresh_table == 0) // ERR.Pointer(cname,fname, "refresh_table"); //VRB.Smalloc(cname,fname, "refresh_table", refresh_table, (alg_dens_arg->n_obs) * sizeof(int)); //a_coor_table = (int *) smalloc( (alg_dens_arg->n_obs) * sizeof(int)); //if(a_coor_table == 0) // ERR.Pointer(cname,fname, "a_coor_table"); //VRB.Smalloc(cname,fname, "a_coor_table", a_coor_table, (alg_dens_arg->n_obs) * sizeof(int)); //b_coor_table = (int *) smalloc( (alg_dens_arg->n_obs) * sizeof(int)); //if(b_coor_table == 0) // ERR.Pointer(cname,fname, "b_coor_table"); //VRB.Smalloc(cname,fname, "b_coor_table", b_coor_table, (alg_dens_arg->n_obs) * sizeof(int)); }