From a7eb2ed6bc54679bad7f1eed470f1487327e23d5 Mon Sep 17 00:00:00 2001 From: Jeongnim Kim Date: Fri, 15 Feb 2013 18:14:31 +0000 Subject: [PATCH] Add MPC check to avoid processing density. git-svn-id: https://subversion.assembla.com/svn/qmcdev/trunk@5711 e5b18d87-469d-4833-9cc0-8cdfa06e9491 --- .../EinsplineSetBuilderESHDF.fft.cpp | 184 +++++++++--------- 1 file changed, 96 insertions(+), 88 deletions(-) diff --git a/src/QMCWaveFunctions/EinsplineSetBuilderESHDF.fft.cpp b/src/QMCWaveFunctions/EinsplineSetBuilderESHDF.fft.cpp index 8d0ff6c68..b55c03f7b 100644 --- a/src/QMCWaveFunctions/EinsplineSetBuilderESHDF.fft.cpp +++ b/src/QMCWaveFunctions/EinsplineSetBuilderESHDF.fft.cpp @@ -24,6 +24,7 @@ #include "OhmmsData/HDFStringAttrib.h" #include "ParticleIO/ESHDFParticleParser.h" #include "ParticleBase/RandomSeqGenerator.h" +#include "qmc_common.h" namespace qmcplusplus { @@ -188,107 +189,114 @@ namespace qmcplusplus { // app_log() << buff; } - ////////////////////////////////////////////////////////// - // Only if it is bulk: If the density has not been set in TargetPtcl, and // - // the density is available, read it in and save it // - // in TargetPtcl. // - ////////////////////////////////////////////////////////// - if(TargetPtcl.Lattice.SuperCellEnum == SUPERCELL_BULK) + if(qmc_common::use_density) { - // FIXME: add support for more than one spin density - if (!TargetPtcl.Density_G.size()) - { - HDFAttribIO > > - h_reduced_gvecs(TargetPtcl.DensityReducedGvecs); - HDFAttribIO > - h_density_r (TargetPtcl.Density_r); - TinyVector mesh; - h_reduced_gvecs.read (H5FileID, "/electrons/density/gvectors"); - - int numG = TargetPtcl.DensityReducedGvecs.size(); - // Convert primitive G-vectors to supercell G-vectors - // Also, flip sign since ESHDF format uses opposite sign convention -#pragma omp parallel for - for (int iG=0; iG < numG; iG++) - TargetPtcl.DensityReducedGvecs[iG] = - -1 * dot(TileMatrix, TargetPtcl.DensityReducedGvecs[iG]); - app_log() << " Read " << numG << " density G-vectors.\n"; - - for (int ispin=0; ispin density_G; - HDFAttribIO > h_density_G (density_G); - h_density_G.read (H5FileID, density_g_path.str().c_str()); - if (!density_G.size()) { - app_error() << " Density reduced G-vectors defined, but not the" - << " density.\n"; - abort(); - } - else { - if (ispin == 0) - TargetPtcl.Density_G = density_G; - else - for (int iG=0; iG > > - h_reduced_gvecs(TargetPtcl.VHXCReducedGvecs); - TinyVector mesh; - h_reduced_gvecs.read (H5FileID, "/electrons/VHXC/gvectors"); - - int numG = TargetPtcl.VHXCReducedGvecs.size(); - // Convert primitive G-vectors to supercell G-vectors - // Also, flip sign since ESHDF format uses opposite sign convention -#pragma omp parallel for - for (int iG=0; iG < numG; iG++) - TargetPtcl.VHXCReducedGvecs[iG] = - -1 * dot(TileMatrix, TargetPtcl.VHXCReducedGvecs[iG]); - - app_log() << " Read " << numG << " VHXC G-vectors.\n"; - - for (int ispin=0; ispin > > + h_reduced_gvecs(TargetPtcl.DensityReducedGvecs); HDFAttribIO > - h_VHXC_r (TargetPtcl.VHXC_r[ispin]); + h_density_r (TargetPtcl.Density_r); + TinyVector mesh; + h_reduced_gvecs.read (H5FileID, "/electrons/density/gvectors"); - ostringstream VHXC_r_path, VHXC_g_path; - VHXC_r_path << "/electrons/VHXC/spin_" << ispin << "/VHXC_r"; - VHXC_g_path << "/electrons/VHXC/spin_" << ispin << "/VHXC_g"; - h_VHXC_r.read (H5FileID, VHXC_r_path.str().c_str()); + int numG = TargetPtcl.DensityReducedGvecs.size(); + // Convert primitive G-vectors to supercell G-vectors + // Also, flip sign since ESHDF format uses opposite sign convention +#pragma omp parallel for + for (int iG=0; iG < numG; iG++) + TargetPtcl.DensityReducedGvecs[iG] = + -1 * dot(TileMatrix, TargetPtcl.DensityReducedGvecs[iG]); + app_log() << " Read " << numG << " density G-vectors.\n"; - if (TargetPtcl.VHXCReducedGvecs.size()) { - app_log() << " EinsplineSetBuilder found VHXC in the HDF5 file.\n"; - vector VHXC_G; - HDFAttribIO > h_VHXC_G (VHXC_G); - h_VHXC_G.read (H5FileID, VHXC_g_path.str().c_str()); - if (!VHXC_G.size()) { - app_error() << " VHXC reduced G-vectors defined, but not the" - << " VHXC.\n"; - abort(); + for (int ispin=0; ispin density_G; + HDFAttribIO > h_density_G (density_G); + h_density_G.read (H5FileID, density_g_path.str().c_str()); + if (!density_G.size()) { + app_error() << " Density reduced G-vectors defined, but not the" + << " density.\n"; + abort(); + } + else { + if (ispin == 0) + TargetPtcl.Density_G = density_G; + else + for (int iG=0; iG > > + h_reduced_gvecs(TargetPtcl.VHXCReducedGvecs); + TinyVector mesh; + h_reduced_gvecs.read (H5FileID, "/electrons/VHXC/gvectors"); + + int numG = TargetPtcl.VHXCReducedGvecs.size(); + // Convert primitive G-vectors to supercell G-vectors + // Also, flip sign since ESHDF format uses opposite sign convention +#pragma omp parallel for + for (int iG=0; iG < numG; iG++) + TargetPtcl.VHXCReducedGvecs[iG] = + -1 * dot(TileMatrix, TargetPtcl.VHXCReducedGvecs[iG]); + + app_log() << " Read " << numG << " VHXC G-vectors.\n"; + + for (int ispin=0; ispin > + h_VHXC_r (TargetPtcl.VHXC_r[ispin]); + + ostringstream VHXC_r_path, VHXC_g_path; + VHXC_r_path << "/electrons/VHXC/spin_" << ispin << "/VHXC_r"; + VHXC_g_path << "/electrons/VHXC/spin_" << ispin << "/VHXC_g"; + h_VHXC_r.read (H5FileID, VHXC_r_path.str().c_str()); + + if (TargetPtcl.VHXCReducedGvecs.size()) { + app_log() << " EinsplineSetBuilder found VHXC in the HDF5 file.\n"; + vector VHXC_G; + HDFAttribIO > h_VHXC_G (VHXC_G); + h_VHXC_G.read (H5FileID, VHXC_g_path.str().c_str()); + if (!VHXC_G.size()) { + app_error() << " VHXC reduced G-vectors defined, but not the" + << " VHXC.\n"; + abort(); + } + else + TargetPtcl.VHXC_G[ispin] = VHXC_G; } - else - TargetPtcl.VHXC_G[ispin] = VHXC_G; } } } } + else + { + app_log() << " Skip initialization of the density" << endl; + } HaveLocalizedOrbs = false; return true; }