diff --git a/cmake_modules/FindSCALAPACK.cmake b/cmake_modules/FindSCALAPACK.cmake index dde12c26..74e58e7d 100644 --- a/cmake_modules/FindSCALAPACK.cmake +++ b/cmake_modules/FindSCALAPACK.cmake @@ -7,7 +7,7 @@ if(DEFINED ENV{SCALAPACK_ROOT}) endif(DEFINED ENV{SCALAPACK_ROOT}) if(SCALAPACK_ROOT) - set(_SCALAPACK_SEARCH_DIR ${SCALAPACK_ROOT}) + set(_SCALAPACK_SEARCH_DIR ${SCALAPACK_ROOT} ${SCALAPACK_ROOT}/lib/intel64) list(APPEND _SCALAPACK_SEARCHES ${_SCALAPACK_SEARCH_DIR}) endif(SCALAPACK_ROOT) @@ -29,13 +29,28 @@ if(NOT SCALAPACK_LIBRARY) endforeach() endif() -unset(SCALAPACK_NAMES) - mark_as_advanced(SCALAPACK_LIBRARY SCALAPACK_INCLUDE_DIR) include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(SCALAPACK REQUIRED_VARS SCALAPACK_LIBRARY) +# Search for some default library paths +if (NOT SCALAPACK_FOUND) + find_library(SCALAPACK_LIBRARY + NAMES ${SCALAPACK_NAMES} + PATHS /usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib + /opt/local/lib /opt/sw/lib /sw/lib + ENV LD_LIBRARY_PATH + ENV DYLD_FALLBACK_LIBRARY_PATH + ENV DYLD_LIBRARY_PATH + ENV SCALAPACKDIR + ENV BLACSDIR) + + FIND_PACKAGE_HANDLE_STANDARD_ARGS(SCALAPACK REQUIRED_VARS SCALAPACK_LIBRARY) +endif() + +unset(SCALAPACK_NAMES) + if(SCALAPACK_FOUND) # Only Intel's scalapack requires an include directory if(SCALAPACK_INCLUDE_DIR) diff --git a/examples/Carbyne/carbyne.cfg b/examples/Carbyne/carbyne.cfg new file mode 100644 index 00000000..d153e6f6 --- /dev/null +++ b/examples/Carbyne/carbyne.cfg @@ -0,0 +1,26 @@ +verbosity=2 +xcFunctional=PBE +FDtype=4th +[Mesh] +nx= 96 +ny= 96 +nz= 192 +[Domain] +ox= -10. +oy= -10. +oz= -20. +lx= 20. +ly= 20. +lz= 40. +[Potentials] +pseudopotential=pseudo.H_ONCV_PBE_SG15 +pseudopotential=pseudo.C_ONCV_PBE_SG15 +[Run] +type=QUENCH +[Quench] +max_steps=200 +atol=1.e-8 +[Orbitals] +initial_type=Fourier +[Restart] +output_level=3 diff --git a/examples/Carbyne/carbyne.in b/examples/Carbyne/carbyne.in new file mode 100644 index 00000000..9f4e975a --- /dev/null +++ b/examples/Carbyne/carbyne.in @@ -0,0 +1,14 @@ +H00 1 -0.0000 -0.0000 15.2674 +C01 2 -0.0000 0.0000 13.2519 +C02 2 -0.0000 0.0000 10.9495 +C03 2 -0.0000 -0.0000 8.4221 +C04 2 0.0000 0.0000 6.0897 +C05 2 -0.0000 0.0000 3.5892 +C06 2 -0.0000 -0.0000 1.2470 +C07 2 0.0000 -0.0000 -1.2469 +C08 2 0.0000 -0.0000 -3.5891 +C09 2 -0.0000 -0.0000 -6.0897 +C10 2 -0.0000 0.0000 -8.4221 +C11 2 0.0000 -0.0000 -10.9495 +C12 2 0.0000 0.0000 -13.2520 +H13 1 0.0000 0.0000 -15.2675 diff --git a/src/MGmol.cc b/src/MGmol.cc index b43c70e3..0af62ebc 100644 --- a/src/MGmol.cc +++ b/src/MGmol.cc @@ -106,7 +106,7 @@ extern Timer ions_setupInteractingIons_tm; extern Timer ions_setup_tm; extern Timer updateCenters_tm; -#include "Signal.h" +#include "mgmol_Signal.h" std::set Signal::recv_; template diff --git a/src/MGmol.h b/src/MGmol.h index 23b507c4..e63e7069 100644 --- a/src/MGmol.h +++ b/src/MGmol.h @@ -102,7 +102,7 @@ class MGmol : public MGmolInterface double total_energy_; ConstraintSet* constraints_; - OrbitalsExtrapolation* orbitals_extrapol_; + OrbitalsExtrapolation* orbitals_extrapol_ = nullptr; float md_time_; int md_iteration_; @@ -301,6 +301,8 @@ class MGmol : public MGmolInterface { forces_->force(orbitals, ions); } + + OrbitalsType* loadOrbitalFromRestartFile(const std::string filename); }; // Instantiate static variables here to avoid clang warnings template diff --git a/src/OrbitalsExtrapolation.h b/src/OrbitalsExtrapolation.h index 9f2348f7..47c1a21b 100644 --- a/src/OrbitalsExtrapolation.h +++ b/src/OrbitalsExtrapolation.h @@ -44,7 +44,7 @@ class OrbitalsExtrapolation virtual short getNumOrbitalExtrapolations() { return 0; } protected: - OrbitalsType* orbitals_minus1_; + OrbitalsType* orbitals_minus1_ = nullptr; }; #endif diff --git a/src/md.cc b/src/md.cc index 1adab46b..ec288839 100644 --- a/src/md.cc +++ b/src/md.cc @@ -31,7 +31,7 @@ #include "ProjectedMatricesMehrstellen.h" #include "ProjectedMatricesSparse.h" #include "Rho.h" -#include "Signal.h" +#include "mgmol_Signal.h" #include "SpreadsAndCenters.h" #include "tools.h" @@ -674,5 +674,89 @@ void MGmol::md(OrbitalsType** orbitals, Ions& ions) delete orbitals_extrapol_; } +template +OrbitalsType* MGmol::loadOrbitalFromRestartFile(const std::string filename) +{ + MGmol_MPI& mmpi(*(MGmol_MPI::instance())); + Control& ct = *(Control::instance()); + Mesh* mymesh = Mesh::instance(); + const pb::PEenv& myPEenv = mymesh->peenv(); + + /* For now, we only consider double-precision hdf5 I/O. */ + assert(ct.restart_info > 3); + assert((ct.AtomsDynamic() == AtomsDynamicType::MD) || (ct.AtomsDynamic() == AtomsDynamicType::Quench)); + + HDFrestart h5file(filename, myPEenv, ct.out_restart_file_type); + int ierr; + + OrbitalsType *restart_orbitals = nullptr; + + /* This corresponds to MGmol::initial */ + { + // Copy from current orbital, instead of constructing brand-new one + restart_orbitals = new OrbitalsType("ForLoading", *current_orbitals_, false); + + /* This corresponds to MGmol::read_restart_data */ + { + ierr = restart_orbitals->read_func_hdf5(h5file); + } // read_restart_data + } // initial() + + /* This corresponds to MGmol::md */ + { + int flag_extrapolated_data = 0; + if (onpe0) + { + flag_extrapolated_data + = h5file.dset_exists("ExtrapolatedFunction0000"); + if (flag_extrapolated_data == 0) + flag_extrapolated_data + = h5file.dset_exists("ExtrapolatedFunction0"); + } + MPI_Bcast(&flag_extrapolated_data, 1, MPI_INT, 0, comm_); + + /* + If extrapolated function exists, + then function is set as previous orbitals, + while the extrapolated function is set as the current orbitals. + This is how the restart file is saved via dumprestartFile. + */ + if (flag_extrapolated_data) + { + orbitals_extrapol_ = OrbitalsExtrapolationFactory::create( + ct.WFExtrapolation()); + + if (onpe0) os_ << "Create new orbitals_minus1..." << std::endl; + + orbitals_extrapol_->setupPreviousOrbitals(&restart_orbitals, + proj_matrices_, lrs_, local_cluster_, currentMasks_, + corrMasks_, h5file); + } + + /* main workflow delete h5f_file_ here, meaning the loading is over. */ + } // md() + + ierr = h5file.close(); + mmpi.allreduce(&ierr, 1, MPI_MIN); + if (ierr < 0) + { + if (onpe0) + (*MPIdata::serr) + << "loadRestartFile: cannot close file..." << std::endl; + return nullptr; + } + + /* + In returning restart_orbitals, + we hope that the wavefunctions in restart_orbitals are all set. + At least the following functions should return proper data loaded from the file: + + restart_orbitals->getLocNumpt() + restart_orbitals->chromatic_number() + restart_orbitals->getPsi(idx) (for int idx) + */ + return restart_orbitals; +} + template class MGmol; template class MGmol; diff --git a/src/tools/Timeout.h b/src/tools/Timeout.h index 18940a78..25751b2a 100644 --- a/src/tools/Timeout.h +++ b/src/tools/Timeout.h @@ -17,7 +17,7 @@ #include #include "MPIdata.h" -#include "Signal.h" +#include "mgmol_Signal.h" #if PCS #include diff --git a/src/tools/Signal.h b/src/tools/mgmol_Signal.h similarity index 98% rename from src/tools/Signal.h rename to src/tools/mgmol_Signal.h index 8e8d0a21..33c47b3e 100644 --- a/src/tools/Signal.h +++ b/src/tools/mgmol_Signal.h @@ -15,7 +15,7 @@ // access the flag set, reset flags, or interrogate flags. // The Signal class can be used in an application by declaring // -// #include "Signal.h" +// #include "mgmol_Signal.h" // set Signal::recv_; // // A signal can be registered using, e.g.