diff --git a/src/QMCDrivers/WFOpt/QMCCostFunctionBase.cpp b/src/QMCDrivers/WFOpt/QMCCostFunctionBase.cpp index 9f47967f21..6026bd3973 100644 --- a/src/QMCDrivers/WFOpt/QMCCostFunctionBase.cpp +++ b/src/QMCDrivers/WFOpt/QMCCostFunctionBase.cpp @@ -414,7 +414,7 @@ bool QMCCostFunctionBase::put(xmlNodePtr q) if (obj.isOptimized()) obj.checkInVariablesExclusive(OptVariablesForPsi); OptVariablesForPsi.resetIndex(); - app_log() << "Totally " << OptVariablesForPsi.size() << " parameters being optimzied." << std::endl; + app_log() << " Selected " << OptVariablesForPsi.size() << " variational parameters." << std::endl; //synchronize OptVariables and OptVariablesForPsi OptVariables = OptVariablesForPsi; @@ -482,6 +482,8 @@ bool QMCCostFunctionBase::put(xmlNodePtr q) { APP_ABORT("QMCCostFunctionBase::put No valid optimizable variables are found."); } + else + app_log() << " Totally " << NumOptimizables << " parameters being optimized after applying constraints." << std::endl; // app_log() << " " << std::endl; // OptVariables.print(app_log()); // app_log() << "" << std::endl; diff --git a/src/QMCWaveFunctions/Fermion/MultiSlaterDetTableMethod.cpp b/src/QMCWaveFunctions/Fermion/MultiSlaterDetTableMethod.cpp index cb3f1cc940..e090c496c9 100644 --- a/src/QMCWaveFunctions/Fermion/MultiSlaterDetTableMethod.cpp +++ b/src/QMCWaveFunctions/Fermion/MultiSlaterDetTableMethod.cpp @@ -35,7 +35,7 @@ MultiSlaterDetTableMethod::MultiSlaterDetTableMethod(ParticleSet& targetPtcl, CI_Optimizable(false), use_pre_computing_(use_pre_computing) { - Dets = std::move(dets); + Dets = std::move(dets); C_otherDs.resize(Dets.size()); int NP = targetPtcl.getTotalNum(); myG.resize(NP); @@ -735,7 +735,10 @@ void MultiSlaterDetTableMethod::extractOptimizableObjectRefs(UniqueOptObjRefs& o void MultiSlaterDetTableMethod::checkInVariablesExclusive(opt_variables_type& active) { if (CI_Optimizable && myVars->size()) + { + myVars->setIndexDefault(); active.insertFrom(*myVars); + } } void MultiSlaterDetTableMethod::checkInVariables(opt_variables_type& active) diff --git a/src/QMCWaveFunctions/Jastrow/BsplineFunctor.h b/src/QMCWaveFunctions/Jastrow/BsplineFunctor.h index 76da6b7f0f..8dacfb64cf 100644 --- a/src/QMCWaveFunctions/Jastrow/BsplineFunctor.h +++ b/src/QMCWaveFunctions/Jastrow/BsplineFunctor.h @@ -682,6 +682,7 @@ struct BsplineFunctor : public OptimizableFunctorBase { if (notOpt) return; + myVars.setIndexDefault(); active.insertFrom(myVars); } diff --git a/src/QMCWaveFunctions/Jastrow/PolynomialFunctor3D.h b/src/QMCWaveFunctions/Jastrow/PolynomialFunctor3D.h index 4b4b4bcc72..cb3acc928e 100644 --- a/src/QMCWaveFunctions/Jastrow/PolynomialFunctor3D.h +++ b/src/QMCWaveFunctions/Jastrow/PolynomialFunctor3D.h @@ -990,9 +990,21 @@ struct PolynomialFunctor3D : public OptimizableFunctorBase reset_gamma(); } - void checkInVariables(opt_variables_type& active) override { active.insertFrom(myVars); } + void checkInVariables(opt_variables_type& active) override + { + if (notOpt) + return; + + myVars.setIndexDefault(); + active.insertFrom(myVars); + } - void checkOutVariables(const opt_variables_type& active) override { myVars.getIndex(active); } + void checkOutVariables(const opt_variables_type& active) override + { + if (notOpt) + return; + myVars.getIndex(active); + } void print(std::ostream& os) { diff --git a/src/QMCWaveFunctions/VariableSet.cpp b/src/QMCWaveFunctions/VariableSet.cpp index 7170eefbf9..50757fa9fe 100644 --- a/src/QMCWaveFunctions/VariableSet.cpp +++ b/src/QMCWaveFunctions/VariableSet.cpp @@ -173,10 +173,10 @@ void VariableSet::getIndex(const VariableSet& selected) } } -void VariableSet::setDefaults(bool optimize_all) +void VariableSet::setIndexDefault() { for (int i = 0; i < Index.size(); ++i) - Index[i] = optimize_all ? i : -1; + Index[i] = i; } void VariableSet::print(std::ostream& os, int leftPadSpaces, bool printHeader) const diff --git a/src/QMCWaveFunctions/VariableSet.h b/src/QMCWaveFunctions/VariableSet.h index 5a6cb770b0..f9c9f674d6 100644 --- a/src/QMCWaveFunctions/VariableSet.h +++ b/src/QMCWaveFunctions/VariableSet.h @@ -46,11 +46,11 @@ struct VariableSet using value_type = qmcplusplus::QMCTraits::ValueType; using real_type = qmcplusplus::QMCTraits::RealType; - using pair_type = std::pair; - using index_pair_type = std::pair; - using iterator = std::vector::iterator; - using const_iterator = std::vector::const_iterator; - using size_type = std::vector::size_type; + using pair_type = std::pair; + using index_pair_type = std::pair; + using iterator = std::vector::iterator; + using const_iterator = std::vector::const_iterator; + using size_type = std::vector::size_type; ///number of active variables int num_active_vars; @@ -327,10 +327,9 @@ struct VariableSet */ void getIndex(const VariableSet& selected); - /** set default Indices - * @param optimize_all if true, all the variables are active + /** set default Indices, namely all the variables are active */ - void setDefaults(bool optimize_all); + void setIndexDefault(); void print(std::ostream& os, int leftPadSpaces = 0, bool printHeader = false) const; diff --git a/tests/molecules/H4_ae/CMakeLists.txt b/tests/molecules/H4_ae/CMakeLists.txt index 90c096ea87..fc9905ed6e 100644 --- a/tests/molecules/H4_ae/CMakeLists.txt +++ b/tests/molecules/H4_ae/CMakeLists.txt @@ -289,6 +289,19 @@ if(NOT QMC_CUDA) H4_OPT_SCALARS # OPT step 5 ) + list(APPEND H4_OPT_SCALARS_ONLY_JAS "totenergy" "-2.066504 0.0009") # total energy + qmc_run_and_check( + short-H4-opt-OneShiftOnly-onlyjas + "${qmcpack_SOURCE_DIR}/tests/molecules/H4_ae" + H4-OneShiftOnly + optm-OneShiftOnly-onlyjas.xml + 1 + 16 + ${SUCCESS_STATUS_MP} + 5 + H4_OPT_SCALARS_ONLY_JAS # OPT step 5 + ) + list(APPEND H4_OPT_SCALARS_ONLY_MSD "totenergy" "-2.138635 0.0009") # total energy qmc_run_and_check( short-H4-opt-OneShiftOnly-onlymsd @@ -302,17 +315,16 @@ if(NOT QMC_CUDA) H4_OPT_SCALARS_ONLY_MSD # OPT step 5 ) - list(APPEND H4_OPT_SCALARS_ONLY_JAS "totenergy" "-2.066504 0.0009") # total energy qmc_run_and_check( - short-H4-opt-OneShiftOnly-onlyjas + short-H4-optbatch-OneShiftOnly-multistep "${qmcpack_SOURCE_DIR}/tests/molecules/H4_ae" H4-OneShiftOnly - optm-OneShiftOnly-onlyjas.xml + optm-OneShiftOnly-multistep.xml 1 16 ${SUCCESS_STATUS_MP} - 5 - H4_OPT_SCALARS_ONLY_JAS # OPT step 5 + 11 + H4_OPT_SCALARS_ONLY_MSD # OPT step 011 ) else() message(VERBOSE diff --git a/tests/molecules/H4_ae/H4.wfs_j123.xml b/tests/molecules/H4_ae/H4.wfs_j123.xml new file mode 100644 index 0000000000..df4d2d1692 --- /dev/null +++ b/tests/molecules/H4_ae/H4.wfs_j123.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + 5.04668000000000e-01 4.50114000000000e-01 3.58423000000000e-01 1.26449000000000e-01 + -2.40452000000000e-01 -3.20413000000000e-01 4.66777000000000e-01 7.03549000000000e-01 + 8.80080000000000e-02 -5.04842000000000e-01 8.07522000000000e-01 -7.19301000000000e-01 + 1.03323500000000e+00 -8.77213000000000e-01 -3.90492000000000e-01 2.12318000000000e-01 + + + + + + 5.04668000000000e-01 4.50114000000000e-01 3.58423000000000e-01 1.26449000000000e-01 + -2.40452000000000e-01 -3.20413000000000e-01 4.66777000000000e-01 7.03549000000000e-01 + 8.80080000000000e-02 -5.04842000000000e-01 8.07522000000000e-01 -7.19301000000000e-01 + 1.03323500000000e+00 -8.77213000000000e-01 -3.90492000000000e-01 2.12318000000000e-01 + + + + + + + + + + + + + + + + 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 + + + 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 + + + + + 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 + + + + + + + + + + + + diff --git a/tests/molecules/H4_ae/optm-OneShiftOnly-multistep.xml b/tests/molecules/H4_ae/optm-OneShiftOnly-multistep.xml new file mode 100644 index 0000000000..8b748256be --- /dev/null +++ b/tests/molecules/H4_ae/optm-OneShiftOnly-multistep.xml @@ -0,0 +1,92 @@ + + + + batch + + + + + + + + + + + + + + 16 + 128 + 5 + 128 + 5 + 0.5 + yes + 262144 + 1.00 + 0.00 + 0.00 + + OneShiftOnly + uu ud + + + + + + 16 + 128 + 5 + 128 + 5 + 0.5 + yes + 262144 + 1.00 + 0.00 + 0.00 + + OneShiftOnly + uu ud eH + + + + + + 16 + 128 + 5 + 128 + 5 + 0.5 + yes + 262144 + 1.00 + 0.00 + 0.00 + + OneShiftOnly + uu ud eH CI + + + + + + 16 + 128 + 5 + 128 + 5 + 0.5 + yes + 262144 + 1.00 + 0.00 + 0.00 + + OneShiftOnly + uu ud eH uuH udH + + + +