char mut(const char *ntp) { uint32_t dice = xs128(); int trpl = triplet_ind(ntp); if (dice < pm[trpl][0]) return nuc(0); if (dice < pm[trpl][1]) return nuc(1); if (dice < pm[trpl][2]) return nuc(2); return nuc(3); }
int autoefficiency(TH1 *hist,const char *name) { gSystem->Load("libNucleus"); TNucleus nuc(name); TGraph *graph; graph = autoefficiency(hist,&nuc); return 1; }
int main() { Nucleation nuc(5,10,50,1.,1.,2.5,0,10); Harmonic pe(nuc); TransferMatrixFunctions TM(pe); std::cout << TM.T(0,1) << std::endl; std::cout << TM.T_hat(0,1) << std::endl; return 0; }
void DoFit(TH2 *hist) { TChannel::DeleteAllChannels(); TChannel::ReadCalFile("GrifCal.cal"); printf("made %i channels.\n",TChannel::GetNumberOfChannels()); TNucleus nuc("152eu"); for(int x = 1; x <= 64; ++x) { printf(" x = %i\n",x); TH1 *p = GetProjectionY(hist,x); if(p->GetEntries() < 100) continue; TGraph* graph = autogain(p,&nuc); TChannel *chan = TChannel::GetChannelByNumber(x); if(!chan) continue; chan->DestroyCalibrations(); chan->AddENGCoefficient(graph->GetFunction("pol1")->GetParameter(0)); chan->AddENGCoefficient(graph->GetFunction("pol1")->GetParameter(1)); chan->SetIntegration(125); } TChannel::WriteCalFile("NewGrifCal.cal"); }
int main() { Nucleation nuc(5,10,50,1.,1.,2.5,0,10); Harmonic test(nuc); T t_matrix(test); T00 t00_matrix(test); T11 t11_matrix(test); //t_matrix.OutputDataMatrix("t_matrix.data"); //t00_matrix.OutputDataMatrix("t00_matrix.data"); //t11_matrix.OutputDataMatrix("t11_matrix.data"); t_matrix.ComputeEigensystem(); t00_matrix.ComputeEigensystem(); t11_matrix.ComputeEigensystem(); std::cout << "MAX EVAL (T Matrix) : " << t_matrix.OrderEigenSystemMax() << std::endl; std::cout << "MAX EVAL (T00 Matrix) : " << t00_matrix.OrderEigenSystemMax() << std::endl; std::cout << "MAX EVAL (T11 Matrix) : " << t11_matrix.OrderEigenSystemMax() << std::endl; return 0; }
int autogain(TH1 *hist,const char *name) { TNucleus nuc(name); autogain(hist,&nuc); return 1; }
//-------------------------------------------------------------------------- // //-------------------------------------------------------------------------- void AlgWspect::run() { #ifdef TIMING_ALG_W_SPECT int quark_b, quark_e; int meson_b, meson_m, meson_e, meson_bmp, meson_mmp, meson_emp; int nucleon_b, nucleon_m, nucleon_e; int total_b = clock(); int total_e; #endif CgArg cg = *cg_arg_p; char *fname = "run()"; VRB.Func(d_class_name,fname); // printf("in AlgWspect::run \n"); WspectOutput * output = (WspectOutput *)common_arg->results; // Set the Lattice pointer //------------------------------------------------------------------------ Lattice& lat = AlgLattice(); int src_slice = d_arg_p->aots_start; int src_slice_step = d_arg_p->aots_step; int src_slice_end = src_slice + src_slice_step * d_arg_p->aots_num; VRB.Result(d_class_name,fname,"%d %d %d \n",src_slice,src_slice_step, src_slice_end); for ( ; src_slice < src_slice_end; src_slice += src_slice_step) { // Calculate quark propagator //---------------------------------------------------------------------- // Ping: certainly more work here to be done about the desired // combinations of non-degenerate quarks. // Presumably, more arguments will have to be passed in. // One way: for three flavors, [100] means use only q1 // to caculate spectrum. // Also some care needed to get the scope (CTOR and DTOR) // of each quark propagator right. // const WspectQuark & q2 = q; // const WspectQuark & q3 = q; // Xiaodong & Thomas: // Modified to calculate also extended mesons // q1 is the usual propagator(no source operator), which can be // used to pass propagation direction and src_slice infomation // to spectrum class // there is a problem here --> check ! VRB.Result(d_class_name,fname,"prop_dir = %d , src_slice = %d \n",d_arg_p->prop_dir, src_slice); WspectHyperRectangle hyperRect(d_arg_p->prop_dir, src_slice); #ifdef TIMING_ALG_W_SPECT quark_b = clock(); #endif VRB.Result(d_class_name,fname,"created quark q1 \n"); // create local quark propagator WspectQuark q1(lat, output->cg, output->pbp, output->mid_point, output->a0_p, d_arg_p[0], cg,hyperRect); VRB.Result(d_class_name,fname,"finished quark q1 \n"); #ifdef TIMING_ALG_W_SPECT quark_e = clock(); #endif //Note: for ExtendedMesons, do only zero momentum projection WspectMomenta mom(hyperRect, q1.SourceCenter2(), d_arg_p->num_mom - 1); // mom.dumpData(); // Calculate LOCAL meson CORRELATOR // added control by Thomas and Xiaodong //---------------------------------------------------------------------- { #ifdef TIMING_ALG_W_SPECT meson_b = clock(); #endif if(d_arg_p->normal_mesons_on) { WspectMesons mes(q1, q1, hyperRect, mom); #if 0 q1.dumpData("qprop.dat"); #endif #ifdef TIMING_ALG_W_SPECT meson_m = clock(); #endif //write data to files mes.print(output); } #ifdef TIMING_ALG_W_SPECT meson_e = clock(); #endif } //end of normal mesons // Calculate <\Delta J^5 \bar q1 \gamma^5 q1> with middle point sink // changed //---------------------------------------------------------------------- if (lat.Fclass() == F_CLASS_DWF && output->mid_point) { #ifdef TIMING_ALG_W_SPECT meson_bmp = clock(); #endif WspectMesons mes(q1.Data_SP1(), q1.Data_SP2(), hyperRect, mom); #ifdef TIMING_ALG_W_SPECT meson_mmp = clock(); #endif mes.print_mp(output->mid_point); #ifdef TIMING_ALG_W_SPECT meson_emp = clock(); #endif } // Calculate nucleon and delta's //---------------------------------------------------------------------- if (d_arg_p->baryons_on) { { #ifdef TIMING_ALG_W_SPECT nucleon_b = clock(); #endif WspectBaryon nuc(q1, q1, q1, hyperRect, WspectBaryon::NUCLEON_CONSTI, WspectBaryon::NUCLEON_DIRAC); #ifdef TIMING_ALG_W_SPECT nucleon_m = clock(); #endif nuc.print(output->nucleon, output->fold); #ifdef TIMING_ALG_W_SPECT nucleon_e = clock(); #endif } { WspectBaryon nucPrime(q1, q1, q1, hyperRect, WspectBaryon::NUCLEON_CONSTI, WspectBaryon::UnitUnit); nucPrime.print(output->nucleon_prime, output->fold); } { WspectBaryon deltaX(q1, q1, q1, hyperRect, WspectBaryon::DELTA_CONSTI, WspectBaryon::DELTAX_DIRAC); deltaX.print(output->delta_x, output->fold); } { WspectBaryon deltaY(q1, q1, q1, hyperRect, WspectBaryon::DELTA_CONSTI, WspectBaryon::DELTAY_DIRAC); deltaY.print(output->delta_y, output->fold); } { WspectBaryon deltaZ(q1, q1, q1, hyperRect, WspectBaryon::DELTA_CONSTI, WspectBaryon::DELTAZ_DIRAC); deltaZ.print(output->delta_z, output->fold); } { WspectBaryon deltaT(q1, q1, q1, hyperRect, WspectBaryon::DELTA_CONSTI, WspectBaryon::DELTAT_DIRAC); deltaT.print(output->delta_t, output->fold); } } //end if(baryons_on) // Increment the counter d_counter += d_count_step; } // end of for(sc_slice,..) #ifdef TIMING_ALG_W_SPECT total_e = clock(); printf("Total: %d = [%d - %d]\n", total_e - total_b, total_e, total_b); printf("Quark: %d = [%d - %d]\n", quark_e - quark_b, quark_e, quark_b); printf("Meson: \t%d = [%d - %d] = \n\tcalc %d = [%d - %d] + \n\tprint %d = [%d - %d]\n", meson_e - meson_b, meson_e, meson_b, meson_m - meson_b, meson_m, meson_b, meson_e - meson_m, meson_e, meson_m); printf("Nucleon:\t%d = [%d - %d] = \n\tcalc %d = [%d - %d] + \n\tprint %d = [%d - %d]\n", nucleon_e - nucleon_b, nucleon_e, nucleon_b, nucleon_m - nucleon_b, nucleon_m, nucleon_b, nucleon_e - nucleon_m, nucleon_e, nucleon_m); #endif VRB.FuncEnd(d_class_name,fname); }
void BaderGrid::construct_bader(const arma::mat & P, double otoler) { // Amount of radial shells on the atoms std::vector<size_t> nrad(basp->get_Nnuc()); Timer t; size_t nd=0, ng=0; // Form radial shells std::vector<angshell_t> grids; for(size_t iat=0;iat<basp->get_Nnuc();iat++) { angshell_t sh; sh.atind=iat; sh.cen=basp->get_nuclear_coords(iat); sh.tol=otoler*PRUNETHR; // Compute necessary number of radial points for atom size_t nr=std::max(20,(int) round(-5*(3*log10(otoler)+8-element_row[basp->get_Z(iat)]))); // Get Chebyshev nodes and weights for radial part std::vector<double> rad, wrad; radial_chebyshev_jac(nr,rad,wrad); nr=rad.size(); // Sanity check nrad[iat]=nr; // Loop over radii for(size_t irad=0;irad<nr;irad++) { sh.R=rad[irad]; sh.w=wrad[irad]; grids.push_back(sh); } } // List of grid points std::vector<gridpoint_t> points; // Initialize list of maxima maxima.clear(); reggrid.clear(); for(size_t i=0;i<basp->get_Nnuc();i++) { nucleus_t nuc(basp->get_nucleus(i)); if(!nuc.bsse) { // Add to list maxima.push_back(nuc.r); std::vector<gridpoint_t> ghlp; reggrid.push_back(ghlp); } } Nnuc=maxima.size(); // Block inside classification? std::vector<bool> block(maxima.size(),false); // Index of last treated atom size_t oldatom=-1; for(size_t ig=0;ig<grids.size();ig++) { // Construct the shell wrk.set_grid(grids[ig]); grids[ig]=wrk.construct_becke(otoler/nrad[grids[ig].atind]); // Form the grid again wrk.form_grid(); // Extract the points on the shell std::vector<gridpoint_t> shellpoints(wrk.get_grid()); if(!shellpoints.size()) continue; // Are we inside an established trust radius, or are we close enough to a real nucleus? bool inside=false; if(grids[ig].R<=TRUSTRAD && !(basp->get_nucleus(grids[ig].atind).bsse)) inside=true; else if(!block[grids[ig].atind] && oldatom==grids[ig].atind) { // Compute projection of density gradient of points on shell arma::vec proj(shellpoints.size()); coords_t nuccoord(basp->get_nuclear_coords(grids[ig].atind)); #ifdef _OPENMP #pragma omp parallel for #endif for(size_t ip=0;ip<shellpoints.size();ip++) { // Compute density gradient double d; arma::vec g; compute_density_gradient(P,*basp,shellpoints[ip].r,d,g); // Vector pointing to nucleus coords_t dRc=nuccoord-shellpoints[ip].r; arma::vec dR(3); dR(0)=dRc.x; dR(1)=dRc.y; dR(2)=dRc.z; // Compute dot product with gradient proj(ip)=arma::norm_dot(dR,g); } // Increment amount of gradient evaluations ng+=shellpoints.size(); // Check if all points are inside const double cthcrit=cos(M_PI/4.0); inside=(arma::min(proj) >= cthcrit); } // If we are not inside, we need to run a point by point classification. if(!inside) { Timer tc; // Reset the trust atom oldatom=-1; // and the current atom block[grids[ig].atind]=true; // Loop over points #ifdef _OPENMP #pragma omp parallel for schedule(dynamic) #endif for(size_t ip=0;ip<shellpoints.size();ip++) { if(compute_density(P,*basp,shellpoints[ip].r)<=SMALLDENSITY) { // Zero density - skip point continue; } // Track the density to its maximum coords_t r=track_to_maximum(*basp,P,shellpoints[ip].r,nd,ng); #ifdef _OPENMP #pragma omp critical #endif { // Now that we have the maximum, check if it is on the list of known maxima bool found=false; for(size_t im=0;im<maxima.size();im++) if(norm(r-maxima[im])<=SAMEMAXIMUM) { found=true; reggrid[im].push_back(shellpoints[ip]); break; } // Maximum was not found, add it to the list if(!found) { maxima.push_back(r); std::vector<gridpoint_t> ghlp; ghlp.push_back(shellpoints[ip]); reggrid.push_back(ghlp); } } } // Continue with the next radial shell continue; } else { // If we are here, then all points belong to this nuclear maximum oldatom=grids[ig].atind; reggrid[ grids[ig].atind ].insert(reggrid[ grids[ig].atind ].end(), shellpoints.begin(), shellpoints.end()); } } if(verbose) { printf("Bader grid constructed in %s, taking %i density and %i gradient evaluations.\n",t.elapsed().c_str(),(int) nd, (int) ng); print_maxima(); // Amount of integration points arma::uvec np(basp->get_Nnuc()); np.zeros(); // Amount of function values arma::uvec nf(basp->get_Nnuc()); nf.zeros(); for(size_t i=0;i<grids.size();i++) { np(grids[i].atind)+=grids[i].np; nf(grids[i].atind)+=grids[i].nfunc; } printf("Composition of atomic integration grid:\n %7s %7s %10s\n","atom","Npoints","Nfuncs"); for(size_t i=0;i<basp->get_Nnuc();i++) printf(" %4i %-2s %7i %10i\n",(int) i+1, basp->get_symbol(i).c_str(), (int) np(i), (int) nf(i)); printf("\nAmount of grid points in the regions:\n %7s %7s\n","region","Npoints"); for(size_t i=0;i<reggrid.size();i++) printf(" %4i %7i\n",(int) i+1, (int) reggrid[i].size()); fflush(stdout); } }
void BaderGrid::construct_voronoi(double otoler) { // Amount of radial shells on the atoms std::vector<size_t> nrad(basp->get_Nnuc()); Timer t; // Form radial shells std::vector<angshell_t> grids; for(size_t iat=0;iat<basp->get_Nnuc();iat++) { angshell_t sh; sh.atind=iat; sh.cen=basp->get_nuclear_coords(iat); sh.tol=otoler*PRUNETHR; // Compute necessary number of radial points for atom size_t nr=std::max(20,(int) round(-5*(3*log10(otoler)+8-element_row[basp->get_Z(iat)]))); // Get Chebyshev nodes and weights for radial part std::vector<double> rad, wrad; radial_chebyshev_jac(nr,rad,wrad); nr=rad.size(); // Sanity check nrad[iat]=nr; // Loop over radii for(size_t irad=0;irad<nr;irad++) { sh.R=rad[irad]; sh.w=wrad[irad]; grids.push_back(sh); } } // List of grid points std::vector<gridpoint_t> points; // Initialize list of maxima maxima.clear(); reggrid.clear(); for(size_t i=0;i<basp->get_Nnuc();i++) { nucleus_t nuc(basp->get_nucleus(i)); if(!nuc.bsse) { // Add to list maxima.push_back(nuc.r); std::vector<gridpoint_t> ghlp; reggrid.push_back(ghlp); } } Nnuc=maxima.size(); for(size_t ig=0;ig<grids.size();ig++) { // Construct the shell wrk.set_grid(grids[ig]); grids[ig]=wrk.construct_becke(otoler/nrad[grids[ig].atind]); // Form the grid again wrk.form_grid(); // Extract the points on the shell std::vector<gridpoint_t> shellpoints(wrk.get_grid()); // Loop over the points on the shell for(size_t ip=0;ip<shellpoints.size();ip++) { // Compute distances to atoms arma::vec dist(maxima.size()); for(size_t ia=0;ia<maxima.size();ia++) dist(ia)=normsq(shellpoints[ip].r-maxima[ia]); // Region is arma::uword idx; dist.min(idx); // Assign point to atom reggrid[idx].push_back(shellpoints[ip]); } } if(verbose) { printf("Voronoi grid constructed in %s.\n",t.elapsed().c_str()); // Amount of integration points arma::uvec np(basp->get_Nnuc()); np.zeros(); // Amount of function values arma::uvec nf(basp->get_Nnuc()); nf.zeros(); for(size_t i=0;i<grids.size();i++) { np(grids[i].atind)+=grids[i].np; nf(grids[i].atind)+=grids[i].nfunc; } printf("Composition of atomic integration grid:\n %7s %7s %10s\n","atom","Npoints","Nfuncs"); for(size_t i=0;i<basp->get_Nnuc();i++) printf(" %4i %-2s %7i %10i\n",(int) i+1, basp->get_symbol(i).c_str(), (int) np(i), (int) nf(i)); printf("\nAmount of grid points in the atomic regions:\n %7s %7s\n","region","Npoints"); for(size_t i=0;i<reggrid.size();i++) printf(" %4i %7i\n",(int) i+1, (int) reggrid[i].size()); fflush(stdout); } }