From 4fa5f6007a60d7a58db91746522997e480b20c85 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Tue, 12 Sep 2023 21:28:41 -0400 Subject: [PATCH] support dimension of aparam to be nall Signed-off-by: Jinzhe Zeng --- deepmd/descriptor/se_a_mask.py | 4 +- deepmd/entrypoints/freeze.py | 1 + deepmd/model/pairwise_dprc.py | 1 + source/api_c/include/c_api_internal.h | 2 + source/api_c/include/deepmd.hpp | 8 +- source/api_c/src/c_api.cc | 11 ++- source/api_cc/include/DeepPot.h | 21 +++++ source/api_cc/include/common.h | 9 ++ source/api_cc/src/DeepPot.cc | 119 ++++++++++++++++---------- source/api_cc/src/common.cc | 21 +++-- 10 files changed, 142 insertions(+), 55 deletions(-) diff --git a/deepmd/descriptor/se_a_mask.py b/deepmd/descriptor/se_a_mask.py index cdec33e292..1b53700c1f 100644 --- a/deepmd/descriptor/se_a_mask.py +++ b/deepmd/descriptor/se_a_mask.py @@ -301,10 +301,12 @@ def build( dstd = self.dstd """ - ``aparam'' shape is [nframes, natoms] + ``aparam'' shape is [nframes, nall] aparam[:, :] is the real/virtual sign for each atom. """ aparam = input_dict["aparam"] + with tf.variable_scope("fitting_attr" + suffix, reuse=reuse): + t_aparam_nall = tf.constant(True, name="aparam_nall", dtype=tf.bool) self.mask = tf.cast(aparam, tf.int32) self.mask = tf.reshape(self.mask, [-1, natoms[1]]) diff --git a/deepmd/entrypoints/freeze.py b/deepmd/entrypoints/freeze.py index c39dd4ad61..11e0d55645 100755 --- a/deepmd/entrypoints/freeze.py +++ b/deepmd/entrypoints/freeze.py @@ -224,6 +224,7 @@ def _make_node_names( "spin_attr/ntypes_spin", "fitting_attr/dfparam", "fitting_attr/daparam", + "fitting_attr/aparam_nall", ] elif model_type == "dos": nodes += [ diff --git a/deepmd/model/pairwise_dprc.py b/deepmd/model/pairwise_dprc.py index bf158434b0..cd5fb63002 100644 --- a/deepmd/model/pairwise_dprc.py +++ b/deepmd/model/pairwise_dprc.py @@ -125,6 +125,7 @@ def build( with tf.variable_scope("fitting_attr" + suffix, reuse=reuse): t_dfparam = tf.constant(0, name="dfparam", dtype=tf.int32) t_daparam = tf.constant(1, name="daparam", dtype=tf.int32) + t_aparam_nall = tf.constant(True, name="aparam_nall", dtype=tf.bool) with tf.variable_scope("descrpt_attr" + suffix, reuse=reuse): t_ntypes = tf.constant(self.ntypes, name="ntypes", dtype=tf.int32) t_rcut = tf.constant( diff --git a/source/api_c/include/c_api_internal.h b/source/api_c/include/c_api_internal.h index 44bce2c696..85e1d2f421 100644 --- a/source/api_c/include/c_api_internal.h +++ b/source/api_c/include/c_api_internal.h @@ -41,6 +41,7 @@ struct DP_DeepPot { std::string exception; int dfparam; int daparam; + bool aparam_nall; }; struct DP_DeepPotModelDevi { @@ -51,6 +52,7 @@ struct DP_DeepPotModelDevi { std::string exception; int dfparam; int daparam; + bool aparam_nall; }; struct DP_DeepTensor { diff --git a/source/api_c/include/deepmd.hpp b/source/api_c/include/deepmd.hpp index 532e01e805..8cfe9cf431 100644 --- a/source/api_c/include/deepmd.hpp +++ b/source/api_c/include/deepmd.hpp @@ -1051,7 +1051,9 @@ class DeepPot { } if (aparam.size() != daparam * nloc && - aparam.size() != nframes * daparam * nloc) { + aparam.size() != nframes * daparam * nloc && + aparam.size() != daparam * nall && + aparam.size() != nframes * daparam * nall) { throw deepmd::hpp::deepmd_exception( "the dim of atom parameter provided is not consistent with what the " "model uses"); @@ -1460,7 +1462,9 @@ class DeepPotModelDevi { } if (aparam.size() != daparam * nloc && - aparam.size() != nframes * daparam * nloc) { + aparam.size() != nframes * daparam * nloc && + aparam.size() != daparam * nall && + aparam.size() != nframes * daparam * nall) { throw deepmd::hpp::deepmd_exception( "the dim of atom parameter provided is not consistent with what the " "model uses"); diff --git a/source/api_c/src/c_api.cc b/source/api_c/src/c_api.cc index 1e2ee47b8b..b30f97186a 100644 --- a/source/api_c/src/c_api.cc +++ b/source/api_c/src/c_api.cc @@ -29,6 +29,7 @@ DP_DeepPot::DP_DeepPot() {} DP_DeepPot::DP_DeepPot(deepmd::DeepPot& dp) : dp(dp) { dfparam = dp.dim_fparam(); daparam = dp.dim_aparam(); + aparam_nall = dp.is_aparam_all(); } DP_DeepPot* DP_NewDeepPot(const char* c_model) { @@ -65,6 +66,7 @@ DP_DeepPotModelDevi::DP_DeepPotModelDevi(deepmd::DeepPotModelDevi& dp) : dp(dp) { dfparam = dp.dim_fparam(); daparam = dp.dim_aparam(); + aparam_nall = dp.is_aparam_all(); } DP_DeepPotModelDevi* DP_NewDeepPotModelDevi(const char** c_models, @@ -249,7 +251,10 @@ inline void DP_DeepPotComputeNList_variant(DP_DeepPot* dp, } std::vector aparam_; if (aparam) { - aparam_.assign(aparam, aparam + nframes * (natoms - nghost) * dp->daparam); + aparam_.assign(aparam, + aparam + nframes * + (dp->aparam_all ? natoms : (natoms - nghost)) * + dp->daparam); } std::vector e; std::vector f, v, ae, av; @@ -433,7 +438,9 @@ void DP_DeepPotModelDeviComputeNList_variant(DP_DeepPotModelDevi* dp, } std::vector aparam_; if (aparam) { - aparam_.assign(aparam, aparam + (natoms - nghost) * dp->daparam); + aparam_.assign( + aparam, + aparam + (dp->aparam_all ? natoms : (natoms - nghost)) * dp->daparam); } // different from DeepPot std::vector e; diff --git a/source/api_cc/include/DeepPot.h b/source/api_cc/include/DeepPot.h index 4db012ea4f..7c4a0afe10 100644 --- a/source/api_cc/include/DeepPot.h +++ b/source/api_cc/include/DeepPot.h @@ -291,6 +291,16 @@ class DeepPot { **/ void get_type_map(std::string& type_map); + /** + * @brief Get whether the atom dimension of aparam is nall instead of fparam. + * @param[out] aparam_nall whether the atom dimension of aparam is nall + *instead of fparam. + **/ + bool is_aparam_nall() const { + assert(inited); + return aparam_nall; + }; + private: tensorflow::Session* session; int num_intra_nthreads, num_inter_nthreads; @@ -309,6 +319,7 @@ class DeepPot { int ntypes_spin; int dfparam; int daparam; + bool aparam_nall; /** * @brief Validate the size of frame and atomic parameters. * @param[in] nframes The number of frames. @@ -572,6 +583,15 @@ class DeepPotModelDevi { void compute_relative_std_f(std::vector& std, const std::vector& avg, const VALUETYPE eps); + /** + * @brief Get whether the atom dimension of aparam is nall instead of fparam. + * @param[out] aparam_nall whether the atom dimension of aparam is nall + *instead of fparam. + **/ + bool is_aparam_nall() const { + assert(inited); + return aparam_nall; + }; private: unsigned numb_models; @@ -592,6 +612,7 @@ class DeepPotModelDevi { int ntypes_spin; int dfparam; int daparam; + bool aparam_nall; template void validate_fparam_aparam(const int& nloc, const std::vector& fparam, diff --git a/source/api_cc/include/common.h b/source/api_cc/include/common.h index 2bcb3cc77f..c4db90687f 100644 --- a/source/api_cc/include/common.h +++ b/source/api_cc/include/common.h @@ -227,6 +227,8 @@ int session_get_dtype(tensorflow::Session* session, * @param[in] fparam_ Frame parameters. * @param[in] aparam_ Atom parameters. * @param[in] atommap Atom map. + * @param[in] aparam_nall Whether the atomic dimesion of atomic parameters is + * nall. * @param[in] scope The scope of the tensors. */ template @@ -240,6 +242,7 @@ int session_input_tensors( const std::vector& fparam_, const std::vector& aparam_, const deepmd::AtomMap& atommap, + const bool aparam_nall = false, const std::string scope = ""); /** @@ -254,6 +257,8 @@ int session_input_tensors( * @param[in] atommap Atom map. * @param[in] nghost Number of ghost atoms. * @param[in] ago Update the internal neighbour list if ago is 0. + * @param[in] aparam_nall Whether the atomic dimesion of atomic parameters is + * nall. * @param[in] scope The scope of the tensors. */ template @@ -269,6 +274,7 @@ int session_input_tensors( const deepmd::AtomMap& atommap, const int nghost, const int ago, + const bool aparam_nall = false, const std::string scope = ""); /** @@ -284,6 +290,8 @@ int session_input_tensors( * @param[in] atommap Atom map. * @param[in] nghost Number of ghost atoms. * @param[in] ago Update the internal neighbour list if ago is 0. + * @param[in] aparam_nall Whether the atomic dimesion of atomic parameters is + * nall. * @param[in] scope The scope of the tensors. */ template @@ -298,6 +306,7 @@ int session_input_tensors_mixed_type( const std::vector& fparam_, const std::vector& aparam_, const deepmd::AtomMap& atommap, + const bool aparam_nall = false, const std::string scope = ""); /** diff --git a/source/api_cc/src/DeepPot.cc b/source/api_cc/src/DeepPot.cc index e20989eb9d..98674efcb3 100644 --- a/source/api_cc/src/DeepPot.cc +++ b/source/api_cc/src/DeepPot.cc @@ -479,6 +479,15 @@ void DeepPot::init(const std::string& model, if (daparam < 0) { daparam = 0; } + if (daparam > 0) { + try { + aparam_nall = get_scalar("fitting_attr/aparam_nall"); + } catch (deepmd::deepmd_exception) { + aparam_nall = false; + } + } else { + aparam_nall = false; + } model_type = get_scalar("model_attr/model_type"); inited = true; @@ -571,23 +580,25 @@ void DeepPot::compute(ENERGYVTYPE& dener, assert(nloc == atommap.get_type().size()); std::vector fparam; std::vector aparam; - validate_fparam_aparam(nframes, nloc, fparam_, aparam_); + validate_fparam_aparam(nframes, (aparam_nall ? nall : nloc), fparam_, + aparam_); tile_fparam_aparam(fparam, nframes, dfparam, fparam_); - tile_fparam_aparam(aparam, nframes, nloc * daparam, aparam_); + tile_fparam_aparam(aparam, nframes, (aparam_nall ? nall : nloc) * daparam, + aparam_); std::vector> input_tensors; if (dtype == tensorflow::DT_DOUBLE) { - int ret = - session_input_tensors(input_tensors, dcoord_, ntypes, datype_, - dbox, cell_size, fparam, aparam, atommap); + int ret = session_input_tensors(input_tensors, dcoord_, ntypes, + datype_, dbox, cell_size, fparam, + aparam, atommap, aparam_nall); assert(ret == nloc); run_model(dener, dforce_, dvirial, session, input_tensors, atommap, nframes); } else { - int ret = - session_input_tensors(input_tensors, dcoord_, ntypes, datype_, - dbox, cell_size, fparam, aparam, atommap); + int ret = session_input_tensors(input_tensors, dcoord_, ntypes, + datype_, dbox, cell_size, fparam, + aparam, atommap, aparam_nall); assert(ret == nloc); run_model(dener, dforce_, dvirial, session, input_tensors, atommap, nframes); @@ -650,9 +661,12 @@ void DeepPot::compute(ENERGYVTYPE& dener, int nframes = dcoord_.size() / nall / 3; std::vector fparam; std::vector aparam_; - validate_fparam_aparam(nframes, nall - nghost, fparam_, aparam__); + validate_fparam_aparam(nframes, (aparam_nall ? nall : (nall - nghost)), + fparam_, aparam__); tile_fparam_aparam(fparam, nframes, dfparam, fparam_); - tile_fparam_aparam(aparam_, nframes, (nall - nghost) * daparam, aparam__); + tile_fparam_aparam(aparam_, nframes, + (aparam_nall ? nall : (nall - nghost)) * daparam, + aparam__); // select real atoms std::vector dcoord, dforce, aparam; @@ -752,16 +766,16 @@ void DeepPot::compute_inner(ENERGYVTYPE& dener, nlist_data.make_inlist(nlist); } if (dtype == tensorflow::DT_DOUBLE) { - int ret = session_input_tensors(input_tensors, dcoord_, ntypes, - datype_, dbox, nlist, fparam, - aparam, atommap, nghost, ago); + int ret = session_input_tensors( + input_tensors, dcoord_, ntypes, datype_, dbox, nlist, fparam, aparam, + atommap, nghost, ago, aparam_nall); assert(nloc == ret); run_model(dener, dforce_, dvirial, session, input_tensors, atommap, nframes, nghost); } else { int ret = session_input_tensors(input_tensors, dcoord_, ntypes, datype_, dbox, nlist, fparam, aparam, - atommap, nghost, ago); + atommap, nghost, ago, aparam_nall); assert(nloc == ret); run_model(dener, dforce_, dvirial, session, input_tensors, atommap, nframes, nghost); @@ -832,22 +846,24 @@ void DeepPot::compute(ENERGYVTYPE& dener, int nloc = datype_.size(); std::vector fparam; std::vector aparam; - validate_fparam_aparam(nframes, nloc, fparam_, aparam_); + validate_fparam_aparam(nframes, (aparam_nall ? nall : nloc), fparam_, + aparam_); tile_fparam_aparam(fparam, nframes, dfparam, fparam_); - tile_fparam_aparam(aparam, nframes, nloc * daparam, aparam_); + tile_fparam_aparam(aparam, nframes, (aparam_nall ? nall : nloc) * daparam, + aparam_); std::vector> input_tensors; if (dtype == tensorflow::DT_DOUBLE) { - int nloc = - session_input_tensors(input_tensors, dcoord_, ntypes, datype_, - dbox, cell_size, fparam, aparam, atommap); + int nloc = session_input_tensors(input_tensors, dcoord_, ntypes, + datype_, dbox, cell_size, fparam, + aparam, atommap, aparam_nall); run_model(dener, dforce_, dvirial, datom_energy_, datom_virial_, session, input_tensors, atommap, nframes); } else { - int nloc = - session_input_tensors(input_tensors, dcoord_, ntypes, datype_, - dbox, cell_size, fparam, aparam, atommap); + int nloc = session_input_tensors(input_tensors, dcoord_, ntypes, + datype_, dbox, cell_size, fparam, + aparam, atommap, aparam_nall); run_model(dener, dforce_, dvirial, datom_energy_, datom_virial_, session, input_tensors, atommap, nframes); } @@ -920,9 +936,11 @@ void DeepPot::compute(ENERGYVTYPE& dener, int nloc = nall - nghost; std::vector fparam; std::vector aparam_; - validate_fparam_aparam(nframes, nloc, fparam_, aparam__); + validate_fparam_aparam(nframes, (aparam_nall ? nall : nloc), fparam_, + aparam__); tile_fparam_aparam(fparam, nframes, dfparam, fparam_); - tile_fparam_aparam(aparam_, nframes, nloc * daparam, aparam__); + tile_fparam_aparam(aparam_, nframes, (aparam_nall ? nall : nloc) * daparam, + aparam__); std::vector> input_tensors; // select real atoms std::vector dcoord, dforce, aparam, datom_energy, datom_virial; @@ -943,16 +961,16 @@ void DeepPot::compute(ENERGYVTYPE& dener, } if (dtype == tensorflow::DT_DOUBLE) { - int ret = session_input_tensors(input_tensors, dcoord, ntypes, - datype, dbox, nlist, fparam, aparam, - atommap, nghost_real, ago); + int ret = session_input_tensors( + input_tensors, dcoord, ntypes, datype, dbox, nlist, fparam, aparam, + atommap, nghost_real, ago, aparam_nall); assert(nloc_real == ret); run_model(dener, dforce, dvirial, datom_energy, datom_virial, session, input_tensors, atommap, nframes, nghost_real); } else { - int ret = session_input_tensors(input_tensors, dcoord, ntypes, - datype, dbox, nlist, fparam, aparam, - atommap, nghost_real, ago); + int ret = session_input_tensors( + input_tensors, dcoord, ntypes, datype, dbox, nlist, fparam, aparam, + atommap, nghost_real, ago, aparam_nall); assert(nloc_real == ret); run_model(dener, dforce, dvirial, datom_energy, datom_virial, session, input_tensors, atommap, nframes, nghost_real); @@ -1046,23 +1064,25 @@ void DeepPot::compute_mixed_type(ENERGYVTYPE& dener, atommap = deepmd::AtomMap(datype_.begin(), datype_.begin() + nloc); std::vector fparam; std::vector aparam; - validate_fparam_aparam(nframes, nloc, fparam_, aparam_); + validate_fparam_aparam(nframes, (aparam_nall ? nall : nloc), fparam_, + aparam_); tile_fparam_aparam(fparam, nframes, dfparam, fparam_); - tile_fparam_aparam(aparam, nframes, nloc * daparam, aparam_); + tile_fparam_aparam(aparam, nframes, (aparam_nall ? nall : nloc) * daparam, + aparam_); std::vector> input_tensors; if (dtype == tensorflow::DT_DOUBLE) { int ret = session_input_tensors_mixed_type( input_tensors, nframes, dcoord_, ntypes, datype_, dbox, cell_size, - fparam, aparam, atommap); + fparam, aparam, atommap, aparam_nall); assert(ret == nloc); run_model(dener, dforce_, dvirial, session, input_tensors, atommap, nframes); } else { int ret = session_input_tensors_mixed_type( input_tensors, nframes, dcoord_, ntypes, datype_, dbox, cell_size, - fparam, aparam, atommap); + fparam, aparam, atommap, aparam_nall); assert(ret == nloc); run_model(dener, dforce_, dvirial, session, input_tensors, atommap, nframes); @@ -1130,22 +1150,24 @@ void DeepPot::compute_mixed_type(ENERGYVTYPE& dener, atommap = deepmd::AtomMap(datype_.begin(), datype_.begin() + nloc); std::vector fparam; std::vector aparam; - validate_fparam_aparam(nframes, nloc, fparam_, aparam_); + validate_fparam_aparam(nframes, (aparam_nall ? nall : nloc), fparam_, + aparam_); tile_fparam_aparam(fparam, nframes, dfparam, fparam_); - tile_fparam_aparam(aparam, nframes, nloc * daparam, aparam_); + tile_fparam_aparam(aparam, nframes, (aparam_nall ? nall : nloc) * daparam, + aparam_); std::vector> input_tensors; if (dtype == tensorflow::DT_DOUBLE) { int nloc = session_input_tensors_mixed_type( input_tensors, nframes, dcoord_, ntypes, datype_, dbox, cell_size, - fparam, aparam, atommap); + fparam, aparam, atommap, aparam_nall); run_model(dener, dforce_, dvirial, datom_energy_, datom_virial_, session, input_tensors, atommap, nframes); } else { int nloc = session_input_tensors_mixed_type( input_tensors, nframes, dcoord_, ntypes, datype_, dbox, cell_size, - fparam, aparam, atommap); + fparam, aparam, atommap, aparam_nall); run_model(dener, dforce_, dvirial, datom_energy_, datom_virial_, session, input_tensors, atommap, nframes); } @@ -1307,6 +1329,15 @@ void DeepPotModelDevi::init(const std::vector& models, if (daparam < 0) { daparam = 0; } + if (daparam > 0) { + try { + aparam_nall = get_scalar("fitting_attr/aparam_nall"); + } catch (deepmd::deepmd_exception) { + aparam_nall = false; + } + } else { + aparam_nall = false; + } model_type = get_scalar("model_attr/model_type"); // rcut = get_rcut(); // cell_size = rcut; @@ -1425,7 +1456,7 @@ void DeepPotModelDevi::compute(std::vector& all_energy, int nall = dcoord_.size() / 3; int nframes = 1; int nloc = nall - nghost; - validate_fparam_aparam(nloc, fparam, aparam_); + validate_fparam_aparam((aparam_nall ? nall : nloc), fparam, aparam_); std::vector> input_tensors; // select real atoms @@ -1450,11 +1481,11 @@ void DeepPotModelDevi::compute(std::vector& all_energy, if (dtype == tensorflow::DT_DOUBLE) { ret = session_input_tensors(input_tensors, dcoord, ntypes, datype, dbox, nlist, fparam, aparam, atommap, - nghost_real, ago); + nghost_real, ago, aparam_nall); } else { ret = session_input_tensors(input_tensors, dcoord, ntypes, datype, dbox, nlist, fparam, aparam, atommap, - nghost_real, ago); + nghost_real, ago, aparam_nall); } all_energy.resize(numb_models); all_force.resize(numb_models); @@ -1523,7 +1554,7 @@ void DeepPotModelDevi::compute( int nframes = 1; int nall = dcoord_.size() / 3; int nloc = nall - nghost; - validate_fparam_aparam(nloc, fparam, aparam_); + validate_fparam_aparam((aparam_nall ? nall : nloc), fparam, aparam_); std::vector> input_tensors; // select real atoms @@ -1548,11 +1579,11 @@ void DeepPotModelDevi::compute( if (dtype == tensorflow::DT_DOUBLE) { ret = session_input_tensors(input_tensors, dcoord, ntypes, datype, dbox, nlist, fparam, aparam, atommap, - nghost_real, ago); + nghost_real, ago, aparam_nall); } else { ret = session_input_tensors(input_tensors, dcoord, ntypes, datype, dbox, nlist, fparam, aparam, atommap, - nghost_real, ago); + nghost_real, ago, aparam_nall); } all_energy.resize(numb_models); diff --git a/source/api_cc/src/common.cc b/source/api_cc/src/common.cc index 43412c4c43..5175c9f317 100644 --- a/source/api_cc/src/common.cc +++ b/source/api_cc/src/common.cc @@ -374,6 +374,7 @@ int deepmd::session_input_tensors( const std::vector& fparam_, const std::vector& aparam__, const deepmd::AtomMap& atommap, + const bool aparam_nall, const std::string scope) { int nframes = dcoord_.size() / 3 / datype_.size(); int nall = datype_.size(); @@ -440,8 +441,10 @@ int deepmd::session_input_tensors( std::vector dcoord(dcoord_); atommap.forward(dcoord.begin(), dcoord_.begin(), 3, nframes, nall); std::vector aparam_(aparam__); - atommap.forward(aparam_.begin(), aparam__.begin(), - aparam__.size() / nframes / nloc, nframes, nloc); + atommap.forward( + aparam_.begin(), aparam__.begin(), + aparam__.size() / nframes / (aparam_nall ? nall : nloc), nframes, + (aparam_nall ? nall : nloc)); for (int ii = 0; ii < nframes; ++ii) { for (int jj = 0; jj < nall * 3; ++jj) { @@ -511,6 +514,7 @@ int deepmd::session_input_tensors( const deepmd::AtomMap& atommap, const int nghost, const int ago, + const bool aparam_nall, const std::string scope) { int nframes = dcoord_.size() / 3 / datype_.size(); int nall = datype_.size(); @@ -573,8 +577,10 @@ int deepmd::session_input_tensors( std::vector dcoord(dcoord_); atommap.forward(dcoord.begin(), dcoord_.begin(), 3, nframes, nall); std::vector aparam_(aparam__); - atommap.forward(aparam_.begin(), aparam__.begin(), - aparam__.size() / nframes / nloc, nframes, nloc); + atommap.forward( + aparam_.begin(), aparam__.begin(), + aparam__.size() / nframes / (aparam_nall ? nall : nloc), nframes, + (aparam_nall ? nall : nloc)); for (int ii = 0; ii < nframes; ++ii) { for (int jj = 0; jj < nall * 3; ++jj) { @@ -645,6 +651,7 @@ int deepmd::session_input_tensors_mixed_type( const std::vector& fparam_, const std::vector& aparam__, const deepmd::AtomMap& atommap, + const bool aparam_nall, const std::string scope) { int nall = datype_.size() / nframes; int nloc = nall; @@ -706,8 +713,10 @@ int deepmd::session_input_tensors_mixed_type( std::vector dcoord(dcoord_); atommap.forward(dcoord.begin(), dcoord_.begin(), 3, nframes, nall); std::vector aparam_(aparam__); - atommap.forward(aparam_.begin(), aparam__.begin(), - aparam__.size() / nframes / nloc, nframes, nloc); + atommap.forward( + aparam_.begin(), aparam__.begin(), + aparam__.size() / nframes / (aparam_nall ? nall : nloc), nframes, + (aparam_nall ? nall : nloc)); for (int ii = 0; ii < nframes; ++ii) { for (int jj = 0; jj < nall * 3; ++jj) {