예제 #1
0
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void LapH::OperatorsForMesons::build_vdaggerv(const std::string& filename) {

  clock_t t2 = clock();
  const size_t dim_row = 3*Lx*Ly*Lz;
  const size_t id_unity = operator_lookuptable.index_of_unity;

  // resizing each matrix in vdaggerv
  // TODO: check if it is better to use for_each and resize instead of std::fill
  std::fill(vdaggerv.origin(), vdaggerv.origin() + vdaggerv.num_elements(), 
            Eigen::MatrixXcd::Zero(nb_ev, nb_ev));

#pragma omp parallel
{
  Eigen::VectorXcd mom = Eigen::VectorXcd::Zero(dim_row);
  LapH::EigenVector V_t(1, dim_row, nb_ev);// each thread needs its own copy
  #pragma omp for schedule(dynamic)
  for(size_t t = 0; t < Lt; ++t){

    // creating full filename for eigenvectors and reading them in
    char inter_name[200];
    sprintf(inter_name, "%s%03d", filename.c_str(), (int) t);
    //avoid reading eigenvectors for now, since no displacement or momentum is
    //used
    //V_t.read_eigen_vector(inter_name, 0, 0); // reading eigenvectors

    // VdaggerV is independent of the gamma structure and momenta connected by
    // sign flip are related by adjoining VdaggerV. Thus the expensive 
    // calculation must only be performed for a subset of quantum numbers given
    // in op_VdaggerV.
    for(const auto& op : operator_lookuptable.vdaggerv_lookup){
      // For zero momentum and displacement VdaggerV is the unit matrix, thus
      // the calculation is not performed
      if(op.id != id_unity){
        // momentum vector contains exp(-i p x). Divisor 3 for colour index. 
        // All three colours on same lattice site get the same momentum.
        for(size_t x = 0; x < dim_row; ++x) {
          mom(x) = momentum[op.id][x/3];
        }
        vdaggerv[op.id][t] = V_t[0].adjoint() * mom.asDiagonal() * V_t[0];
      }
      else // zero momentum
        vdaggerv[op.id][t] = Eigen::MatrixXcd::Identity(nb_ev, nb_ev);
    }
  } // loop over time
}// pragma omp parallel ends here

  t2 = clock() - t2;
  std::cout << std::setprecision(1) << "\t\t\tSUCCESS - " << std::fixed 
    << ((float) t2)/CLOCKS_PER_SEC << " seconds" << std::endl;
  is_vdaggerv_set = true;

}
예제 #2
0
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void LapH::OperatorsForMesons::build_vdaggerv(const std::string& filename,
                                              const int config) {

  clock_t t2 = clock();
  const size_t dim_row = 3*Lx*Ly*Lz;
  const int id_unity = operator_lookuptable.index_of_unity;

  // prepare full path for writing
  char dummy_path[200];
  sprintf(dummy_path, "/%s/cnfg%04d/", path_vdaggerv.c_str(), config);
  const std::string full_path(dummy_path);
  // check if directory exists
  if(handling_vdaggerv == "write" && access(full_path.c_str(), 0 ) != 0) {
    std::cout << "\tdirectory " << full_path.c_str() 
              << " does not exist and will be created";
    boost::filesystem::path dir(full_path.c_str());
    if(!boost::filesystem::create_directories(dir))
      std::cout << "\tSuccess" << std::endl;
    else
      std::cout << "\tFailure" << std::endl;
  }

  // resizing each matrix in vdaggerv
  // TODO: check if it is better to use for_each and resize instead of std::fill
  std::fill(vdaggerv.origin(), vdaggerv.origin() + vdaggerv.num_elements(), 
            Eigen::MatrixXcd::Zero(nb_ev, nb_ev));


#pragma omp parallel
{
  Eigen::VectorXcd mom = Eigen::VectorXcd::Zero(dim_row);
  LapH::EigenVector V_t(1, dim_row, nb_ev);// each thread needs its own copy
  #pragma omp for schedule(dynamic)
  for(size_t t = 0; t < Lt; ++t){

    // creating full filename for eigenvectors and reading them in
    if(!(operator_lookuptable.vdaggerv_lookup.size() == 1 &&
       operator_lookuptable.vdaggerv_lookup[0].id == id_unity)){
      char inter_name[200];
      sprintf(inter_name, "%s%03d", filename.c_str(), (int) t);
      V_t.read_eigen_vector(inter_name, 0, 0); // reading eigenvectors
    }

    // VdaggerV is independent of the gamma structure and momenta connected by
    // sign flip are related by adjoining VdaggerV. Thus the expensive 
    // calculation must only be performed for a subset of quantum numbers given
    // in op_VdaggerV.
    for(const auto& op : operator_lookuptable.vdaggerv_lookup){
      // For zero momentum and displacement VdaggerV is the unit matrix, thus
      // the calculation is not performed
      if(op.id != id_unity){
        // momentum vector contains exp(-i p x). Divisor 3 for colour index. 
        // All three colours on same lattice site get the same momentum.
        for(size_t x = 0; x < dim_row; ++x) {
          mom(x) = momentum[op.id][x/3];
        }
        vdaggerv[op.id][t] = V_t[0].adjoint() * mom.asDiagonal() * V_t[0];
        // writing vdaggerv to disk
        if(handling_vdaggerv == "write"){
          char dummy2[200];
          sprintf(dummy2, "operators.%04d.p_", config);
          std::string dummy = std::string(dummy2) + 
                              std::to_string(op.momentum[0]) + 
                              std::to_string(op.momentum[1]) + 
                              std::to_string(op.momentum[2]);
          char outfile[200];
          sprintf(outfile, "%s_.t_%03d", dummy.c_str(), (int) t);
          write_vdaggerv(full_path, std::string(outfile), vdaggerv[op.id][t]);
        }
      }
      else // zero momentum
        vdaggerv[op.id][t] = Eigen::MatrixXcd::Identity(nb_ev, nb_ev);
    }
  } // loop over time
}// pragma omp parallel ends here

  t2 = clock() - t2;
  std::cout << std::setprecision(1) << "\t\t\tSUCCESS - " << std::fixed 
    << ((float) t2)/CLOCKS_PER_SEC << " seconds" << std::endl;
  is_vdaggerv_set = true;

}