diff --git a/examples/PinnedH2O/job.ref b/examples/PinnedH2O/job.ref index 32024e6f..c716b724 100644 --- a/examples/PinnedH2O/job.ref +++ b/examples/PinnedH2O/job.ref @@ -1,14 +1,14 @@ #!/bin/tcsh #SBATCH -N 1 -#SBATCH -t 1:00:00 -#SBATCH -p pdebug +#SBATCH -t 3:00:00 +#SBATCH -p pbatch date setenv OMP_NUM_THREADS 1 #setenv KMP_DETERMINISTIC_REDUCTION 1 -set ncpus = 8 +set ncpus = 1 set case = 2 set maindir = /p/lustre2/cheung26/mgmol diff --git a/examples/PinnedH2O/job.rom_3DOF b/examples/PinnedH2O/job.rom_3DOF index 0e38688b..fdbb1a55 100644 --- a/examples/PinnedH2O/job.rom_3DOF +++ b/examples/PinnedH2O/job.rom_3DOF @@ -1,14 +1,14 @@ #!/bin/tcsh #SBATCH -N 1 -#SBATCH -t 1:00:00 -#SBATCH -p pdebug +#SBATCH -t 2:00:00 +#SBATCH -p pbatch date setenv OMP_NUM_THREADS 1 #setenv KMP_DETERMINISTIC_REDUCTION 1 -set ncpus = 8 +set ncpus = 1 set case = 2 set maindir = /p/lustre2/cheung26/mgmol diff --git a/examples/PinnedH2O/mgmol_rom_3DOF_test2.cfg b/examples/PinnedH2O/mgmol_rom_3DOF_test2.cfg index 24273c40..bb2912d9 100644 --- a/examples/PinnedH2O/mgmol_rom_3DOF_test2.cfg +++ b/examples/PinnedH2O/mgmol_rom_3DOF_test2.cfg @@ -38,7 +38,7 @@ output_level=4 [ROM] stage=online_pinned_H2O_3dof [ROM.offline] -basis_file=/usr/workspace/nlrom/MGmol/PinnedH2O_3DOF/data_8/PinnedH2O_3DOF_orbitals_basis_2_2 +basis_file=/usr/workspace/nlrom/MGmol/PinnedH2O_3DOF/data_1/PinnedH2O_3DOF_orbitals_basis_2_2 [ROM.basis] compare_md=false number_of_orbital_basis=34 diff --git a/src/Control.cc b/src/Control.cc index 980c1abe..b7d23203 100644 --- a/src/Control.cc +++ b/src/Control.cc @@ -112,7 +112,6 @@ Control::Control() out_restart_file_type = -1; spread_radius = -1.; iprint_residual = -1; - override_restart = -1; dot_product_type = -1; spread_penalty_damping_ = -1; spread_penalty_alpha_ = -1; @@ -386,7 +385,7 @@ void Control::sync(void) short_buffer[47] = out_restart_file_naming_strategy; short_buffer[48] = enforceVmass0; short_buffer[49] = dm_inner_steps; - short_buffer[50] = override_restart; + short_buffer[50] = -1; short_buffer[51] = fgmres_kim; short_buffer[52] = fgmres_maxits; short_buffer[53] = ilu_type; @@ -599,41 +598,41 @@ void Control::sync(void) out_restart_file_naming_strategy = short_buffer[47]; enforceVmass0 = short_buffer[48]; dm_inner_steps = short_buffer[49]; - override_restart = short_buffer[50]; - fgmres_kim = short_buffer[51]; - fgmres_maxits = short_buffer[52]; - ilu_type = short_buffer[53]; - ilu_lof = short_buffer[54]; - ilu_maxfil = short_buffer[55]; - coloring_algo_ = short_buffer[56]; - diel_flag_ = short_buffer[57]; - poisson_pc_nu1 = short_buffer[58]; - poisson_pc_nu2 = short_buffer[59]; - poisson_pc_nlev = short_buffer[60]; - system_charge_ = short_buffer[61]; - md_print_freq = short_buffer[62]; - use_kernel_functions = short_buffer[63]; - ngpts_[0] = short_buffer[64]; - ngpts_[1] = short_buffer[65]; - ngpts_[2] = short_buffer[66]; - computeCondGram_ = short_buffer[67]; - lrs_extrapolation = short_buffer[68]; - parallel_transport = (bool)short_buffer[69]; - with_spin_ = (bool)short_buffer[70]; - conv_criterion_ = short_buffer[71]; - load_balancing_max_iterations = short_buffer[72]; - load_balancing_modulo = short_buffer[73]; - write_clusters = short_buffer[74]; - DM_solver_ = short_buffer[75]; - dm_algo_ = short_buffer[80]; - dm_approx_order = short_buffer[81]; - dm_approx_ndigits = short_buffer[82]; - dm_approx_power_maxits = short_buffer[83]; - spread_penalty_type_ = short_buffer[84]; - dm_use_old_ = short_buffer[85]; - max_electronic_steps_tight_ = short_buffer[86]; - hartree_reset_ = short_buffer[88]; - MD_last_step_ = short_buffer[89]; + //... = short_buffer[50]; + fgmres_kim = short_buffer[51]; + fgmres_maxits = short_buffer[52]; + ilu_type = short_buffer[53]; + ilu_lof = short_buffer[54]; + ilu_maxfil = short_buffer[55]; + coloring_algo_ = short_buffer[56]; + diel_flag_ = short_buffer[57]; + poisson_pc_nu1 = short_buffer[58]; + poisson_pc_nu2 = short_buffer[59]; + poisson_pc_nlev = short_buffer[60]; + system_charge_ = short_buffer[61]; + md_print_freq = short_buffer[62]; + use_kernel_functions = short_buffer[63]; + ngpts_[0] = short_buffer[64]; + ngpts_[1] = short_buffer[65]; + ngpts_[2] = short_buffer[66]; + computeCondGram_ = short_buffer[67]; + lrs_extrapolation = short_buffer[68]; + parallel_transport = (bool)short_buffer[69]; + with_spin_ = (bool)short_buffer[70]; + conv_criterion_ = short_buffer[71]; + load_balancing_max_iterations = short_buffer[72]; + load_balancing_modulo = short_buffer[73]; + write_clusters = short_buffer[74]; + DM_solver_ = short_buffer[75]; + dm_algo_ = short_buffer[80]; + dm_approx_order = short_buffer[81]; + dm_approx_ndigits = short_buffer[82]; + dm_approx_power_maxits = short_buffer[83]; + spread_penalty_type_ = short_buffer[84]; + dm_use_old_ = short_buffer[85]; + max_electronic_steps_tight_ = short_buffer[86]; + hartree_reset_ = short_buffer[88]; + MD_last_step_ = short_buffer[89]; poisson_lap_type_ = static_cast(short_buffer[90]); numst = int_buffer[0]; @@ -1787,7 +1786,6 @@ void Control::setOptions(const boost::program_options::variables_map& vm) // options not available in configure file lr_updates_type = 0; precond_factor_computed = false; - override_restart = 0; mix_pot = 1.; project_out_psd = 0; multipole_order = 1; diff --git a/src/Control.h b/src/Control.h index 77932fb3..7e27d1b8 100644 --- a/src/Control.h +++ b/src/Control.h @@ -562,7 +562,6 @@ class Control short out_restart_file_naming_strategy; short restart_file_type; short out_restart_file_type; - short override_restart; short verbose; diff --git a/src/DensityMatrix.cc b/src/DensityMatrix.cc index 83d715d5..7be19aab 100644 --- a/src/DensityMatrix.cc +++ b/src/DensityMatrix.cc @@ -22,12 +22,6 @@ const double factor_kernel4dot = 10.; -#define MGMOL_DENSITYMATRIX_FAIL(X) \ - { \ - std::cerr << "DensityMatrix failure:" << std::endl; \ - std::cerr << "Error Message: " << X << std::endl; \ - } - #define MGMOL_DENSITYMATRIX_FAIL(X) \ { \ std::cerr << "DensityMatrix failure:" << std::endl; \ diff --git a/src/MGmol.cc b/src/MGmol.cc index ac022d91..5c590819 100644 --- a/src/MGmol.cc +++ b/src/MGmol.cc @@ -45,6 +45,7 @@ #include "MGmol.h" #include "MLWFTransform.h" #include "MPIdata.h" +#include "MVPSolver.h" #include "MasksSet.h" #include "Mesh.h" #include "OrbitalsPreconditioning.h" @@ -901,6 +902,9 @@ void MGmol::printTimers() AndersonMix::update_tm().print(os_); proj_matrices_->printTimers(os_); ShortSightedInverse::printTimers(os_); + if (std::is_same::value) + MVPSolver>::printTimers(os_); VariableSizeMatrixInterface::printTimers(os_); DataDistribution::printTimers(os_); PackedCommunicationBuffer::printTimers(os_); diff --git a/src/MGmol.h b/src/MGmol.h index c7777a62..a561e900 100644 --- a/src/MGmol.h +++ b/src/MGmol.h @@ -229,7 +229,6 @@ class MGmol : public MGmolInterface void printEigAndOcc(); - int readCoordinates(std::ifstream* tfile, const bool cell_relative); int readCoordinates(const std::string& filename, const bool cell_relative); double computeConstraintResidual(OrbitalsType& orbitals, const OrbitalsType& hphi, OrbitalsType& res, const bool print_residual, diff --git a/src/MVPSolver.cc b/src/MVPSolver.cc index 4f9165a5..699a01f3 100644 --- a/src/MVPSolver.cc +++ b/src/MVPSolver.cc @@ -398,12 +398,8 @@ int MVPSolver::solve(OrbitalsType& orbitals) template void MVPSolver::printTimers(std::ostream& os) { - if (onpe0) - { - os << std::setprecision(2) << std::fixed << std::endl; - solve_tm_.print(os); - target_tm_.print(os); - } + solve_tm_.print(os); + target_tm_.print(os); } template class MVPSolver class ProjectedMatrices; @@ -67,7 +66,7 @@ class MVPSolver ~MVPSolver(); int solve(OrbitalsType& orbitals); - void printTimers(std::ostream& os); + static void printTimers(std::ostream& os); }; #endif diff --git a/src/main.cc b/src/main.cc index 3c6830a0..621b72de 100644 --- a/src/main.cc +++ b/src/main.cc @@ -58,7 +58,7 @@ int main(int argc, char** argv) /* * read runtime parameters */ - std::string input_filename(""); + std::string coords_filename(""); std::string lrs_filename; std::string constraints_filename(""); @@ -70,7 +70,7 @@ int main(int argc, char** argv) // read from PE0 only if (MPIdata::onpe0) { - read_config(argc, argv, vm, input_filename, lrs_filename, + read_config(argc, argv, vm, coords_filename, lrs_filename, constraints_filename, total_spin, with_spin); } @@ -89,7 +89,7 @@ int main(int argc, char** argv) int ret = ct.checkOptions(); if (ret < 0) return ret; - mmpi.bcastGlobal(input_filename); + mmpi.bcastGlobal(coords_filename); mmpi.bcastGlobal(lrs_filename); // Enter main scope @@ -97,10 +97,10 @@ int main(int argc, char** argv) MGmolInterface* mgmol; if (ct.isLocMode()) mgmol = new MGmol(global_comm, *MPIdata::sout, - input_filename, lrs_filename, constraints_filename); + coords_filename, lrs_filename, constraints_filename); else mgmol = new MGmol(global_comm, *MPIdata::sout, - input_filename, lrs_filename, constraints_filename); + coords_filename, lrs_filename, constraints_filename); mgmol->setup(); diff --git a/src/md.cc b/src/md.cc index ac5aa8c1..16e0c6e7 100644 --- a/src/md.cc +++ b/src/md.cc @@ -340,7 +340,7 @@ void MGmol::md(OrbitalsType** orbitals, Ions& ions) constraints_->printConstraints(os_); - if (ct.restart_info > 0 && !ct.override_restart) + if (ct.restart_info > 0) { if (onpe0) os_ << "Use restart file to initialize MD..." << std::endl; stepper->init(*h5f_file_); @@ -406,9 +406,13 @@ void MGmol::md(OrbitalsType** orbitals, Ions& ions) h5f_file_.reset(); } - bool ROM_MVP = (ct.getROMOptions().rom_stage == ROMStage::ONLINE_PINNED_H2O_3DOF); #ifdef MGMOL_HAS_LIBROM + bool ROM_MVP = (ct.getROMOptions().rom_stage == ROMStage::ONLINE_PINNED_H2O_3DOF); + DensityMatrix>* dm = nullptr; + dist_matrix::DistMatrix* previous_dm = nullptr; // ROM - initialize orbitals and density matrix + // assume ct.Mehrstellen() nor ct.short_sighted nor use_replicated_matrix + // so that Line 267 of MGmol.cc is activated if (ROM_MVP) { if (onpe0) os_ << "Setup ROM MVP solver..." << std::endl; @@ -422,6 +426,11 @@ void MGmol::md(OrbitalsType** orbitals, Ions& ions) = getProjectedMatrices(); projmatrices->setDMuniform(ct.getNelSpin()); projmatrices->printDM(os_); + + std::shared_ptr>> projmatrices_downcast = + std::dynamic_pointer_cast>>(projmatrices); + dm = &(projmatrices_downcast->getDM()); + previous_dm = new dist_matrix::DistMatrix(dm->getMatrix()); } #endif @@ -487,6 +496,9 @@ void MGmol::md(OrbitalsType** orbitals, Ions& ions) if (ROM_MVP) { md_updateDMandEnergy_tm.start(); + dist_matrix::DistMatrix tmp(dm->getMatrix()); + dm->linearExtrapolate(*previous_dm); + *previous_dm = tmp; updateDMandEnergy(**orbitals, *ROM_ions, eks); md_updateDMandEnergy_tm.stop(); } diff --git a/src/readInput.cc b/src/readInput.cc index 79fbecf1..bd6a7dd1 100644 --- a/src/readInput.cc +++ b/src/readInput.cc @@ -164,7 +164,7 @@ int MGmol::readLRsFromInput(std::ifstream* tfile) template int MGmol::readCoordinates( - std::ifstream* tfile, const bool cell_relative) + const std::string& coords_filename, const bool cell_relative) { Control& ct = *(Control::instance()); if (ct.verbose > 0) printWithTimeStamp("Read atomic coordinates...", os_); @@ -177,71 +177,26 @@ int MGmol::readCoordinates( const std::vector& sp(ct.getSpecies()); ions_.reset(new Ions(lattice, sp)); - if (ct.restart_info > 0 - && ct.override_restart == 0) // read restart ionic positions + if (ct.restart_info > 0 && coords_filename.empty()) { - if (ct.restart_info > 0) - { - if (onpe0 && ct.verbose > 0) - { - os_ << "Initialize ionic positions from restart file " - << ct.restart_file << std::endl; - } - ions_->initFromRestartFile(*h5f_file_); - } - } - else - { - // Coordinates and species type for each ion. - int info = ions_->readAtoms(tfile, cell_relative); - - return info; - } - - const int num_ions = ions_->getNumIons(); - if (onpe0) os_ << num_ions << " ions in simulation" << std::endl; - - return 0; -} - -template -int MGmol::readCoordinates( - const std::string& filename, const bool cell_relative) -{ - Control& ct = *(Control::instance()); - if (ct.verbose > 0) printWithTimeStamp("Read atomic coordinates...", os_); - Mesh* mymesh = Mesh::instance(); - const pb::Grid& mygrid = mymesh->grid(); - - const double lattice[3] = { mygrid.ll(0), mygrid.ll(1), mygrid.ll(2) }; - - // setup ions - const std::vector& sp(ct.getSpecies()); - ions_.reset(new Ions(lattice, sp)); - - if (ct.restart_info > 0 - && ct.override_restart == 0) // read restart ionic positions - { - if (ct.restart_info > 0) + // read restart atomic positions + if (onpe0 && ct.verbose > 0) { - if (onpe0 && ct.verbose > 0) - { - os_ << "Initialize ionic positions from restart file " - << ct.restart_file << std::endl; - } - ions_->initFromRestartFile(*h5f_file_); + os_ << "Initialize atomic positions from restart file " + << ct.restart_file << std::endl; } + ions_->initFromRestartFile(*h5f_file_); } else { // Coordinates and species type for each ion. - int info = ions_->readAtoms(filename, cell_relative); + int info = ions_->readAtoms(coords_filename, cell_relative); return info; } const int num_ions = ions_->getNumIons(); - if (onpe0) os_ << num_ions << " ions in simulation" << std::endl; + if (onpe0) os_ << num_ions << " atoms in simulation" << std::endl; return 0; } diff --git a/src/read_config.cc b/src/read_config.cc index 9dbd56d3..aefb59ae 100644 --- a/src/read_config.cc +++ b/src/read_config.cc @@ -20,7 +20,7 @@ namespace po = boost::program_options; int read_config(int argc, char** argv, po::variables_map& vm, - std::string& input_file, std::string& lrs_filename, + std::string& coords_filename, std::string& lrs_filename, std::string& constraints_filename, float& total_spin, bool& with_spin) { // use configure file if it can be found @@ -36,9 +36,9 @@ int read_config(int argc, char** argv, po::variables_map& vm, "help,h", "produce help message")("check", "check input")( "config,c", po::value(&config_file)->default_value("mgmol.cfg"), - "name of a file of a configuration.")("atomicCoordinates,i", - po::value>(), - "coordinates filename")("LRsFilename,l", + "name of configuration file")("atomicCoordinates,i", + po::value(&coords_filename), + "atomic coordinates filename")("LRsFilename,l", po::value(&lrs_filename), "LRs filename"); // Declare a group of options (with default when appropriate) that @@ -150,9 +150,8 @@ int read_config(int argc, char** argv, po::variables_map& vm, "Tolerance on forces for Geometry optimization")( "GeomOpt.max_steps", po::value()->default_value(1), "max. number of Geometry optimization steps")("GeomOpt.dt", - po::value(), "Delta t for trial pseudo-time steps")( - "atomicCoordinates", po::value>(), - "coordinates filename")("Thermostat.type", + po::value(), + "Delta t for trial pseudo-time steps")("Thermostat.type", po::value()->default_value("Langevin"), "Thermostat type")("Thermostat.temperature", po::value()->default_value(-1.), "Thermostat temperature")( @@ -384,9 +383,9 @@ int read_config(int argc, char** argv, po::variables_map& vm, } if (vm.count("atomicCoordinates")) { - input_file + coords_filename = vm["atomicCoordinates"].as>()[0]; - std::cout << "Input files is: " << input_file << "\n"; + std::cout << "Coordinates files is: " << coords_filename << "\n"; } else { diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 38cdc4c1..72e603b6 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -467,6 +467,15 @@ add_test(NAME testSiH4 ${CMAKE_CURRENT_SOURCE_DIR}/SiH4/mgmol.cfg ${CMAKE_CURRENT_SOURCE_DIR}/SiH4/sih4.xyz ${CMAKE_CURRENT_SOURCE_DIR}/../potentials) +add_test(NAME testOverrideCoords + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OverrideCoords/test.py + ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 4 ${MPIEXEC_PREFLAGS} + ${CMAKE_CURRENT_BINARY_DIR}/../src/mgmol-opt + ${CMAKE_CURRENT_SOURCE_DIR}/OverrideCoords/mgmol.cfg + ${CMAKE_CURRENT_SOURCE_DIR}/OverrideCoords/restart.cfg + ${CMAKE_CURRENT_SOURCE_DIR}/OverrideCoords/sih4.xyz + ${CMAKE_CURRENT_SOURCE_DIR}/OverrideCoords/shifted.xyz + ${CMAKE_CURRENT_SOURCE_DIR}/../potentials) add_test(NAME testCl2 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Cl2_ONCVPSP_LDA/test.py ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 4 ${MPIEXEC_PREFLAGS} diff --git a/tests/LBFGS/test.py b/tests/LBFGS/test.py index 324fd129..7150b3ce 100755 --- a/tests/LBFGS/test.py +++ b/tests/LBFGS/test.py @@ -56,7 +56,7 @@ os.remove('wave.out') os.symlink(restart_file, 'wave.out') -command = "{} {} -c {} -i {} -l {}".format(mpicmd,exe,inp2,coords,lrs) +command = "{} {} -c {} -l {}".format(mpicmd,exe,inp2,lrs) print(command) output = subprocess.check_output(command,shell=True) diff --git a/tests/MD_D72/test.py b/tests/MD_D72/test.py index 3f98b2bd..22773b6b 100755 --- a/tests/MD_D72/test.py +++ b/tests/MD_D72/test.py @@ -54,7 +54,7 @@ os.remove('wave.out') os.symlink(restart_file, 'wave.out') -command = "{} {} -c {} -i {}".format(mpicmd,exe,inp2,coords) +command = "{} {} -c {}".format(mpicmd,exe,inp2) output2 = subprocess.check_output(command,shell=True) #remove created files diff --git a/tests/MD_MVP/test.py b/tests/MD_MVP/test.py index 47b5462d..c767031e 100755 --- a/tests/MD_MVP/test.py +++ b/tests/MD_MVP/test.py @@ -51,7 +51,7 @@ os.rename(restart_file, 'snapshotMVP') #run MGmol - command = "{} {} -c {} -i {}".format(mpicmd,exe,inp2,coords) + command = "{} {} -c {}".format(mpicmd,exe,inp2) output2 = subprocess.check_output(command,shell=True) #remove used restart files diff --git a/tests/OverrideCoords/mgmol.cfg b/tests/OverrideCoords/mgmol.cfg new file mode 100644 index 00000000..fad77b2d --- /dev/null +++ b/tests/OverrideCoords/mgmol.cfg @@ -0,0 +1,27 @@ +verbosity=2 +xcFunctional=LDA +[Mesh] +nx=40 +ny=40 +nz=40 +[Domain] +ox=-6.75 +oy=-6.75 +oz=-6.75 +lx=13.5 +ly=13.5 +lz=13.5 +[Potentials] +pseudopotential=pseudo.Si +pseudopotential=pseudo.H +[Run] +type=QUENCH +[Quench] +max_steps=45 +atol=1.e-9 +num_lin_iterations=2 +[Orbitals] +initial_type=Gaussian +initial_width=2. +[Restart] +output_level=3 diff --git a/tests/OverrideCoords/restart.cfg b/tests/OverrideCoords/restart.cfg new file mode 100644 index 00000000..0715e6b1 --- /dev/null +++ b/tests/OverrideCoords/restart.cfg @@ -0,0 +1,24 @@ +verbosity=2 +xcFunctional=LDA +[Mesh] +nx=40 +ny=40 +nz=40 +[Domain] +ox=-6.75 +oy=-6.75 +oz=-6.75 +lx=13.5 +ly=13.5 +lz=13.5 +[Potentials] +pseudopotential=pseudo.Si +pseudopotential=pseudo.H +[Run] +type=QUENCH +[Quench] +max_steps=25 +atol=1.e-8 +[Restart] +input_level=3 +input_filename=wave.out diff --git a/tests/OverrideCoords/shifted.xyz b/tests/OverrideCoords/shifted.xyz new file mode 100644 index 00000000..089658f8 --- /dev/null +++ b/tests/OverrideCoords/shifted.xyz @@ -0,0 +1,8 @@ +5 +SiH4 molecule (coordinates in Angstrom) +Si 0.0 0.0 0.0 +H 0.885 0.885 0.935 +H -0.885 -0.885 0.885 +H -0.885 0.885 -0.885 +H 0.885 -0.885 -0.885 + diff --git a/tests/OverrideCoords/sih4.xyz b/tests/OverrideCoords/sih4.xyz new file mode 100644 index 00000000..b3f921e3 --- /dev/null +++ b/tests/OverrideCoords/sih4.xyz @@ -0,0 +1,8 @@ +5 +SiH4 molecule (coordinates in Angstrom) +Si 0.0 0.0 0.0 +H 0.885 0.885 0.885 +H -0.885 -0.885 0.885 +H -0.885 0.885 -0.885 +H 0.885 -0.885 -0.885 + diff --git a/tests/OverrideCoords/test.py b/tests/OverrideCoords/test.py new file mode 100755 index 00000000..2de3fd4f --- /dev/null +++ b/tests/OverrideCoords/test.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python +import sys +import os +import subprocess +import string +import shutil + +print("Test Override coordinates...") + +nargs=len(sys.argv) + +mpicmd = sys.argv[1]+" "+sys.argv[2]+" "+sys.argv[3] +for i in range(4,nargs-6): + mpicmd = mpicmd + " "+sys.argv[i] +print("MPI run command: {}".format(mpicmd)) + +exe = sys.argv[nargs-6] +inp1 = sys.argv[nargs-5] +inp2 = sys.argv[nargs-4] +coords1 = sys.argv[nargs-3] +coords2 = sys.argv[nargs-2] +print("coordinates file: %s"%coords1) + +#create links to potentials files +dst1 = 'pseudo.Si' +dst2 = 'pseudo.H' +src1 = sys.argv[nargs-1] + '/' + dst1 +src2 = sys.argv[nargs-1] + '/' + dst2 + +if not os.path.exists(dst1): + print("Create link to %s"%dst1) + os.symlink(src1, dst1) +if not os.path.exists(dst2): + print("Create link to %s"%dst2) + os.symlink(src2, dst2) + +#run quench +command = "{} {} -c {} -i {}".format(mpicmd,exe,inp1,coords1) +print("Run command: {}".format(command)) +output1 = subprocess.check_output(command,shell=True) +lines=output1.split(b'\n') + +#analyse output of quench +for line in lines: + if line.count(b'%%'): + print(line) + +#run quench with shifted coordinates +command = "ls -ld snapshot* | awk '{ print $9 }' | tail -n1" +print(command) +restart_file = subprocess.check_output(command,shell=True) +restart_file=str(restart_file[:-1],'utf-8') +print(restart_file) + +try: + os.symlink(restart_file, 'wave.out') +except FileExistsError: + os.remove('wave.out') + os.symlink(restart_file, 'wave.out') + +command = "{} {} -c {} -i {}".format(mpicmd,exe,inp2,coords2) +print(command) +output2 = subprocess.check_output(command,shell=True) + +#remove created files +shutil.rmtree(restart_file) +os.remove('wave.out') + +#analyse mgmol standard output +lines=output2.split(b'\n') + +flag = 0 +for line in lines: + if line.count(b'%%'): + print(line) + if line.count(b'achieved'): + flag=1 + +if flag==0: + print("second run did not converge...") + sys.exit(1) + +sys.exit(0) diff --git a/tests/PinnedH2O_3DOF/job.offline b/tests/PinnedH2O_3DOF/job.offline index 5b4224f0..13393c88 100644 --- a/tests/PinnedH2O_3DOF/job.offline +++ b/tests/PinnedH2O_3DOF/job.offline @@ -16,15 +16,8 @@ setenv LD_LIBRARY_PATH ${maindir}/build_quartz/libROM/build/lib:$LD_LIBRARY_PATH set exe = mgmol-opt -cp $maindir/install_quartz/bin/$exe . - set cfg_offline = mgmol_offline.cfg -ln -s -f $maindir/potentials/pseudo.O_ONCV_PBE_SG15 . -ln -s -f $maindir/potentials/pseudo.H_ONCV_PBE_SG15 . - -source $maindir/scripts/modules.quartz - set bondlength_min = 0.95 set bondlength_max = 1.05 set bondlength_num_increments = 10 @@ -32,6 +25,16 @@ set bondangle_min = -5.0 set bondangle_max = 5.0 set bondangle_num_increments = 10 +cp $maindir/install_quartz/bin/$exe . + +ln -s -f $maindir/potentials/pseudo.O_ONCV_PBE_SG15 . +ln -s -f $maindir/potentials/pseudo.H_ONCV_PBE_SG15 . + +source $maindir/scripts/modules.quartz + +mkdir data +cd data + foreach i (`seq 0 $bondlength_num_increments`) set bondlength_one = `echo "scale=2; $bondlength_min + $i * ($bondlength_max - $bondlength_min) / ($bondlength_num_increments)" | bc` set bondlength_one = `printf "%.2f" $bondlength_one` @@ -56,4 +59,6 @@ foreach i (`seq 0 $bondlength_num_increments`) end end +cd .. + date diff --git a/tests/RhoVhRestart/test.py b/tests/RhoVhRestart/test.py index a34b962f..0d14383e 100755 --- a/tests/RhoVhRestart/test.py +++ b/tests/RhoVhRestart/test.py @@ -53,7 +53,7 @@ sys.exit(1) #run MD -command = "{} {} -c {} -i {}".format(mpicmd,mgmol_exe,input2,coords) +command = "{} {} -c {}".format(mpicmd,mgmol_exe,input2) print("Run command: {}".format(command)) output = subprocess.check_output(command,shell=True) lines=output.split(b'\n') @@ -68,7 +68,7 @@ sys.exit(1) #run test -command = "{} {} -c {} -i {}".format(mpicmd,test_exe,input3,coords) +command = "{} {} -c {}".format(mpicmd,test_exe,input3) print("Run command: {}".format(command)) output = subprocess.check_output(command,shell=True) lines=output.split(b'\n') diff --git a/tests/testSetGhostValues.cc b/tests/testSetGhostValues.cc index c3680087..90aafde0 100644 --- a/tests/testSetGhostValues.cc +++ b/tests/testSetGhostValues.cc @@ -12,6 +12,8 @@ #include "catch.hpp" +#include + TEST_CASE("Set ghost values", "[set ghosts") { const double origin[3] = { 0., 0., 0. }; diff --git a/tests/testTradeGhostValues.cc b/tests/testTradeGhostValues.cc index 069b9374..8294aaec 100644 --- a/tests/testTradeGhostValues.cc +++ b/tests/testTradeGhostValues.cc @@ -13,6 +13,8 @@ #include "catch.hpp" +#include + // function of periodicity nx, ny, nz double cos3(const int i, const int j, const int k, const int nx, const int ny, const int nz)