From 40b996207e6c37b2f0919f53e3e32b626a513477 Mon Sep 17 00:00:00 2001 From: mkirsz <s1351949@sms.ed.ac.uk> Date: Wed, 18 Dec 2024 12:25:52 +0000 Subject: [PATCH] rename aed --- include/tadah/mlip/analytics/statistics.h | 2 +- include/tadah/mlip/descriptors_calc.hpp | 10 +++++----- include/tadah/mlip/models/basis.h | 4 ++-- include/tadah/mlip/models/m_blr.h | 12 ++++++------ include/tadah/mlip/models/m_krr.h | 12 ++++++------ include/tadah/mlip/models/m_tadah_base.h | 6 +++--- include/tadah/mlip/output/output.h | 2 +- include/tadah/mlip/st_descriptors.h | 4 ++-- src/dm_bf_linear.cpp | 2 +- src/dm_bf_polynomial2.cpp | 10 +++++----- src/dm_kern_base.cpp | 8 ++++---- src/dm_kern_linear.cpp | 6 +++--- src/m_tadah_base.cpp | 12 ++++++------ src/st_descriptors.cpp | 4 ++-- 14 files changed, 47 insertions(+), 47 deletions(-) diff --git a/include/tadah/mlip/analytics/statistics.h b/include/tadah/mlip/analytics/statistics.h index 0d86664..4bd75bf 100644 --- a/include/tadah/mlip/analytics/statistics.h +++ b/include/tadah/mlip/analytics/statistics.h @@ -5,7 +5,7 @@ /** Some basis statistical tools */ class Statistics { - using vec = aed_type2; + using vec = aed_type; public: /** Residual sum of squares. */ static double res_sum_sq(const vec &obs, const vec &pred); diff --git a/include/tadah/mlip/descriptors_calc.hpp b/include/tadah/mlip/descriptors_calc.hpp index 10eb0bf..01ae99d 100644 --- a/include/tadah/mlip/descriptors_calc.hpp +++ b/include/tadah/mlip/descriptors_calc.hpp @@ -216,7 +216,7 @@ void DescriptorsCalc<D2,D3,DM,C2,C3,CM>::calc(const Structure &st, StDescriptors // zero all aeds and set bias for (size_t i=0; i<st.natoms(); ++i) { - aed_type2 &aed = st_d.get_aed(i); + aed_type &aed = st_d.get_aed(i); aed.set_zero(); aed(0)=static_cast<double>(bias); // set bias } @@ -226,7 +226,7 @@ void DescriptorsCalc<D2,D3,DM,C2,C3,CM>::calc(const Structure &st, StDescriptors // can be calculated if (initmb) { for (size_t i=0; i<st.natoms(); ++i) { - aed_type2 &aed = st_d.get_aed(i); + aed_type &aed = st_d.get_aed(i); rho_type& rhoi = st_d.get_rho(i); dm.calc_aed(rhoi,aed); } @@ -238,7 +238,7 @@ void DescriptorsCalc<D2,D3,DM,C2,C3,CM>::calc(const Structure &st, StDescriptors Vec3d delij; for (size_t i=0; i<st.natoms(); ++i) { const Atom &a1 = st(i); - aed_type2 &aed = st_d.get_aed(i); + aed_type &aed = st_d.get_aed(i); for (size_t jj=0; jj<st.nn_size(i); ++jj) { const Vec3d &a2pos = st.nn_pos(i,jj); @@ -356,7 +356,7 @@ void DescriptorsCalc<D2,D3,DM,C2,C3,CM>::calc_dimer(const Structure &st, StDescr // zero all aeds+rho and set bias for (size_t i=0; i<4; ++i) { - aed_type2 &aed = st_d.get_aed(i); + aed_type &aed = st_d.get_aed(i); aed.set_zero(); aed(0)=static_cast<double>(bias); // set bias } @@ -401,7 +401,7 @@ void DescriptorsCalc<D2,D3,DM,C2,C3,CM>::calc_dimer(const Structure &st, StDescr // calculate many-body aed if (initmb) { for (size_t i=0; i<4; ++i) { - aed_type2 &aed = st_d.get_aed(i); + aed_type &aed = st_d.get_aed(i); rho_type& rhoi = st_d.get_rho(i); dm.calc_aed(rhoi,aed); } diff --git a/include/tadah/mlip/models/basis.h b/include/tadah/mlip/models/basis.h index 80f2bbe..f00caf0 100644 --- a/include/tadah/mlip/models/basis.h +++ b/include/tadah/mlip/models/basis.h @@ -56,7 +56,7 @@ larger than the amount of available AEDs\n"); for (size_t i=1; i<s; ++i) { size_t st = std::get<0>(indices[i]); size_t a = std::get<1>(indices[i]); - const aed_type2 &aed = st_desc_db(st).get_aed(a); + const aed_type &aed = st_desc_db(st).get_aed(a); for (size_t j=0; j<aed.size(); ++j) { b(j,i)=aed[j]; } @@ -97,7 +97,7 @@ larger than the amount of available AEDs\n"); const size_t st = indices[i]; T(i)=stdb(st).energy/st_desc_db(st).naed(); for( size_t a=0; a<st_desc_db(st).naed(); a++ ) { - const aed_type2 &aed = st_desc_db(st).get_aed(a); + const aed_type &aed = st_desc_db(st).get_aed(a); for (size_t j=0; j<aed.size(); ++j) { b(j,i)+=aed[j]/st_desc_db(st).naed(); } diff --git a/include/tadah/mlip/models/m_blr.h b/include/tadah/mlip/models/m_blr.h index d687282..943a7fe 100644 --- a/include/tadah/mlip/models/m_blr.h +++ b/include/tadah/mlip/models/m_blr.h @@ -76,15 +76,15 @@ public: norm = Normaliser(c); } - double epredict(const aed_type2 &aed) const{ + double epredict(const aed_type &aed) const{ return bf.epredict(weights,aed); }; - double fpredict(const fd_type &fdij, const aed_type2 &aedi, const size_t k) const{ + double fpredict(const fd_type &fdij, const aed_type &aedi, const size_t k) const{ return bf.fpredict(weights,fdij,aedi,k); } - force_type fpredict(const fd_type &fdij, const aed_type2 &aedi) const{ + force_type fpredict(const fd_type &fdij, const aed_type &aedi) const{ return bf.fpredict(weights,fdij,aedi); } @@ -167,7 +167,7 @@ public: return c; } StructureDB predict(Config config_pred, StructureDB &stdb, DC_Base &dc, - aed_type2 &predicted_error) { + aed_type &predicted_error) { LinearRegressor::read_sigma(config_pred,Sigma); DesignMatrix<BF> dm(bf,config_pred); @@ -178,7 +178,7 @@ public: double pmean = sqrt(predicted_error.mean()); // compute energy, forces and stresses - aed_type2 Tpred = T_dgemv(dm.Phi, weights); + aed_type Tpred = T_dgemv(dm.Phi, weights); // Construct StructureDB object with predicted values StructureDB stdb_; @@ -218,7 +218,7 @@ Hint: check different predict() methods."); //std::cout << Phi.row(0) << std::endl; // compute energy, forces and stresses - aed_type2 Tpred = T_dgemv(Phi, weights); + aed_type Tpred = T_dgemv(Phi, weights); double eweightglob=config.template get<double>("EWEIGHT"); double fweightglob=config.template get<double>("FWEIGHT"); diff --git a/include/tadah/mlip/models/m_krr.h b/include/tadah/mlip/models/m_krr.h index 610c1fc..92aee1d 100644 --- a/include/tadah/mlip/models/m_krr.h +++ b/include/tadah/mlip/models/m_krr.h @@ -79,15 +79,15 @@ public: norm = Normaliser(c); } - double epredict(const aed_type2 &aed) const { + double epredict(const aed_type &aed) const { return kernel.epredict(weights,aed); }; - double fpredict(const fd_type &fdij, const aed_type2 &aedi, const size_t k) const { + double fpredict(const fd_type &fdij, const aed_type &aedi, const size_t k) const { return kernel.fpredict(weights,fdij,aedi,k); } - force_type fpredict(const fd_type &fdij, const aed_type2 &aedi) const { + force_type fpredict(const fd_type &fdij, const aed_type &aedi) const { return kernel.fpredict(weights,fdij,aedi); } @@ -237,7 +237,7 @@ public: return c; } StructureDB predict(Config config_pred, StructureDB &stdb, DC_Base &dc, - aed_type2 &predicted_error) { + aed_type &predicted_error) { LinearRegressor::read_sigma(config_pred,Sigma); DesignMatrix<K> dm(kernel,config_pred); @@ -249,7 +249,7 @@ public: double pmean = sqrt(predicted_error.mean()); // compute energy, forces and stresses - aed_type2 Tpred = T_dgemv(dm.Phi, weights); + aed_type Tpred = T_dgemv(dm.Phi, weights); // Construct StructureDB object with predicted values StructureDB stdb_; @@ -288,7 +288,7 @@ Hint: check different predict() methods."); phi_type &Phi = desmat.Phi; // compute energy, forces and stresses - aed_type2 Tpred = T_dgemv(Phi, weights); + aed_type Tpred = T_dgemv(Phi, weights); double eweightglob=config.template get<double>("EWEIGHT"); double fweightglob=config.template get<double>("FWEIGHT"); diff --git a/include/tadah/mlip/models/m_tadah_base.h b/include/tadah/mlip/models/m_tadah_base.h index c98e4e6..d719829 100644 --- a/include/tadah/mlip/models/m_tadah_base.h +++ b/include/tadah/mlip/models/m_tadah_base.h @@ -29,11 +29,11 @@ public: double epredict(const StDescriptors &std); ///** \brief Predict force between a pair of atoms in a k-direction. */ - //virtual double fpredict(const fd_type &fdij, const aed_type2 &aedi, size_t k)=0; + //virtual double fpredict(const fd_type &fdij, const aed_type &aedi, size_t k)=0; ///** \brief Predict force between a pair of atoms. */ //virtual force_type fpredict(const fd_type &fdij, - // const aed_type2 &aedi)=0; + // const aed_type &aedi)=0; /** \brief Predict total force on an atom a. */ virtual void fpredict(const size_t a, force_type &v, @@ -96,7 +96,7 @@ public: virtual void train(StDescriptorsDB &, const StructureDB &) {}; virtual StructureDB predict(Config config_pred, StructureDB &stdb, DC_Base &dc, - aed_type2 &predicted_error)=0; + aed_type &predicted_error)=0; virtual StructureDB predict(StructureDB &stdb)=0; diff --git a/include/tadah/mlip/output/output.h b/include/tadah/mlip/output/output.h index 0f0a7a3..1a08850 100644 --- a/include/tadah/mlip/output/output.h +++ b/include/tadah/mlip/output/output.h @@ -45,7 +45,7 @@ class Output { out_unc.close(); } - void print_predict_all(StructureDB &stdb, StructureDB &stpred, aed_type2 & predicted_error) { + void print_predict_all(StructureDB &stdb, StructureDB &stpred, aed_type & predicted_error) { std::ofstream out_error("error.pred"); std::ofstream out_energy("energy.pred"); std::ofstream out_force("forces.pred"); diff --git a/include/tadah/mlip/st_descriptors.h b/include/tadah/mlip/st_descriptors.h index 56618d5..f5cf2ad 100644 --- a/include/tadah/mlip/st_descriptors.h +++ b/include/tadah/mlip/st_descriptors.h @@ -69,8 +69,8 @@ struct StDescriptors { rhos_type rhos; - aed_type2 & get_aed(const size_t i); - const aed_type2 &get_aed(const size_t i) const; + aed_type & get_aed(const size_t i); + const aed_type &get_aed(const size_t i) const; rho_type& get_rho(const size_t i); size_t naed() const; diff --git a/src/dm_bf_linear.cpp b/src/dm_bf_linear.cpp index 3aea01b..4f5dac2 100644 --- a/src/dm_bf_linear.cpp +++ b/src/dm_bf_linear.cpp @@ -18,7 +18,7 @@ void DM_BF_Linear::calc_phi_energy_row(phi_type &Phi, size_t &row, const double fac, const Structure &, const StDescriptors &st_d) { for (size_t i=0; i<st_d.naed(); ++i) { - const aed_type2 &aed = st_d.get_aed(i); + const aed_type &aed = st_d.get_aed(i); for (size_t j=0; j<aed.size(); ++j) { Phi(row,j)+=aed[j]*fac; } diff --git a/src/dm_bf_polynomial2.cpp b/src/dm_bf_polynomial2.cpp index 9c48624..c7fb188 100644 --- a/src/dm_bf_polynomial2.cpp +++ b/src/dm_bf_polynomial2.cpp @@ -23,7 +23,7 @@ void DM_BF_Polynomial2::calc_phi_energy_row(phi_type &Phi, const StDescriptors &st_d) { for (size_t a=0; a<st_d.naed();++a) { - const aed_type2& aed = st_d.get_aed(a); + const aed_type& aed = st_d.get_aed(a); size_t b=0; for (size_t i=0; i<st_d.dim(); ++i) { for (size_t ii=i; ii<st_d.dim(); ++ii) { @@ -40,13 +40,13 @@ void DM_BF_Polynomial2::calc_phi_force_rows(phi_type &Phi, const StDescriptors &st_d) { for (size_t a=0; a<st.natoms(); ++a) { - const aed_type2& aedi = st_d.get_aed(a); + const aed_type& aedi = st_d.get_aed(a); for (size_t jj=0; jj<st_d.fd[a].size(); ++jj) { const size_t j=st.near_neigh_idx[a][jj]; size_t aa = st.get_nn_iindex(a,j,jj); const fd_type &fdji = st_d.fd[j][aa]; const fd_type &fdij = st_d.fd[a][jj]; - const aed_type2& aedj = st_d.get_aed(j); + const aed_type& aedj = st_d.get_aed(j); for (size_t k=0; k<3; ++k) { size_t b=0; @@ -72,14 +72,14 @@ void DM_BF_Polynomial2::calc_phi_stress_rows(phi_type &Phi, double V_inv = 1/st.get_volume(); for (size_t a=0; a<st.natoms(); ++a) { const Vec3d &ri = st(a).position; - const aed_type2& aedi = st_d.get_aed(a); + const aed_type& aedi = st_d.get_aed(a); for (size_t jj=0; jj<st_d.fd[a].size(); ++jj) { const size_t j=st.near_neigh_idx[a][jj]; size_t aa = st.get_nn_iindex(a,j,jj); const fd_type &fdji = st_d.fd[j][aa]; const fd_type &fdij = st_d.fd[a][jj]; const Vec3d &rj = st.nn_pos(a,jj); - const aed_type2& aedj = st_d.get_aed(j); + const aed_type& aedj = st_d.get_aed(j); size_t mn=0; for (size_t x=0; x<3; ++x) { for (size_t y=x; y<3; ++y) { diff --git a/src/dm_kern_base.cpp b/src/dm_kern_base.cpp index 9e569e0..f78c71e 100644 --- a/src/dm_kern_base.cpp +++ b/src/dm_kern_base.cpp @@ -27,13 +27,13 @@ void DM_Kern_Base::calc_phi_energy_row(phi_type &Phi, size_t &row, const double void DM_Kern_Base::calc_phi_force_rows(phi_type &Phi, size_t &row, const double fac, const Structure &st, const StDescriptors &st_d) { for (size_t i=0; i<st.natoms(); ++i) { - const aed_type2& aedi = st_d.get_aed(i); + const aed_type& aedi = st_d.get_aed(i); for (size_t jj=0; jj<st_d.fd[i].size(); ++jj) { size_t j=st.near_neigh_idx[i][jj]; size_t ii = st.get_nn_iindex(i,j,jj); const fd_type &fdji = st_d.fd[j][ii]; const fd_type &fdij = st_d.fd[i][jj]; - const aed_type2& aedj = st_d.get_aed(j); + const aed_type& aedj = st_d.get_aed(j); for (size_t b=0; b<basis.cols(); ++b) { for (size_t k=0; k<3; ++k) { Phi(row+k,b) -= fac*((*this).prime(basis.col(b), aedi,fdij(k)) - @@ -50,13 +50,13 @@ void DM_Kern_Base::calc_phi_stress_rows(phi_type &Phi, size_t &row, const doubl double V_inv = 1/st.get_volume(); for (size_t i=0; i<st.natoms(); ++i) { const Vec3d &ri = st(i).position; - const aed_type2& aedi = st_d.get_aed(i); + const aed_type& aedi = st_d.get_aed(i); for (size_t jj=0; jj<st_d.fd[i].size(); ++jj) { size_t j=st.near_neigh_idx[i][jj]; size_t ii = st.get_nn_iindex(i,j,jj); const fd_type &fdji = st_d.fd[j][ii]; const fd_type &fdij = st_d.fd[i][jj]; - const aed_type2& aedj = st_d.get_aed(j); + const aed_type& aedj = st_d.get_aed(j); const Vec3d &rj = st.nn_pos(i,jj); size_t mn=0; for (size_t x=0; x<3; ++x) { diff --git a/src/dm_kern_linear.cpp b/src/dm_kern_linear.cpp index df6126a..84c484b 100644 --- a/src/dm_kern_linear.cpp +++ b/src/dm_kern_linear.cpp @@ -19,7 +19,7 @@ void DM_Kern_Linear::calc_phi_energy_row(phi_type &Phi, size_t &row, const double fac, const Structure &, const StDescriptors &st_d) { for (size_t a=0; a<st_d.naed();++a) { - const aed_type2 &aed = st_d.get_aed(a); // TODO + const aed_type &aed = st_d.get_aed(a); // TODO for (size_t j=0; j<aed.size(); ++j) { Phi(row,j)+=aed[j]*fac; } @@ -34,7 +34,7 @@ void DM_Kern_Linear::calc_phi_force_rows(phi_type &Phi, size_t &row, const size_t j=st.near_neigh_idx[a][jj]; const size_t aa = st.get_nn_iindex(a,j,jj); for (size_t k=0; k<3; ++k) { - aed_type2 temp = (st_d.fd[a][jj](k)- + aed_type temp = (st_d.fd[a][jj](k)- st_d.fd[j][aa](k))*fac; for (size_t d=0; d<temp.size(); ++d) { Phi(row+k,d) -= temp[d]; @@ -60,7 +60,7 @@ void DM_Kern_Linear::calc_phi_stress_rows(phi_type &Phi, size_t &row, size_t mn=0; for (size_t x=0; x<3; ++x) { for (size_t y=x; y<3; ++y) { - aed_type2 temp = V_inv*(fdij(y)-fdji(y))*0.5*fac[mn]*(ri(x)-rj(x)); + aed_type temp = V_inv*(fdij(y)-fdji(y))*0.5*fac[mn]*(ri(x)-rj(x)); for (size_t d=0; d<temp.size(); ++d) { Phi(row+mn,d) += temp[d]; } diff --git a/src/m_tadah_base.cpp b/src/m_tadah_base.cpp index ca18ccb..2efa8f1 100644 --- a/src/m_tadah_base.cpp +++ b/src/m_tadah_base.cpp @@ -9,8 +9,8 @@ fpredict(const size_t a, force_type &v, const size_t aa = st.get_nn_iindex(a,j,jj); const fd_type &fdji = std.fd[j][aa]; const fd_type &fdij = std.fd[a][jj]; - const aed_type2 &aedi = std.get_aed(a); - const aed_type2 &aedj = std.get_aed(j); + const aed_type &aedi = std.get_aed(a); + const aed_type &aedj = std.get_aed(j); v += fpredict(fdij,aedi); v -= fpredict(fdji,aedj); } @@ -111,14 +111,14 @@ spredict(const size_t a, stress_type &s, { double V_inv = 1/st.get_volume(); const Vec3d &ri = st.atoms[a].position; - const aed_type2 &aedi = std.get_aed(a); + const aed_type &aedi = std.get_aed(a); for (size_t jj=0; jj<st.nn_size(a); ++jj) { size_t j=st.near_neigh_idx[a][jj]; const size_t aa = st.get_nn_iindex(a,j,jj); const Vec3d &rj = st.nn_pos(a,jj); const fd_type &fdij = std.fd[a][jj]; const fd_type &fdji = std.fd[j][aa]; - const aed_type2 &aedj = std.get_aed(j); + const aed_type &aedj = std.get_aed(j); const force_type fij = fpredict(fdij,aedi); const force_type fji = fpredict(fdji,aedj); @@ -142,14 +142,14 @@ stress_force_predict(const StDescriptors &std, Structure &st_) for (size_t a=0; a<st_.natoms(); ++a) { force_type v; const Vec3d &ri = st_.atoms[a].position; - const aed_type2 &aedi = std.get_aed(a); + const aed_type &aedi = std.get_aed(a); for (size_t jj=0; jj<st_.nn_size(a); ++jj) { size_t j=st_.near_neigh_idx[a][jj]; const size_t aa = st_.get_nn_iindex(a,j,jj); const Vec3d &rj = st_.nn_pos(a,jj); const fd_type &fdij = std.fd[a][jj]; const fd_type &fdji = std.fd[j][aa]; - const aed_type2 &aedj = std.get_aed(j); + const aed_type &aedj = std.get_aed(j); const force_type fij = fpredict(fdij,aedi); const force_type fji = fpredict(fdji,aedj); diff --git a/src/st_descriptors.cpp b/src/st_descriptors.cpp index e7a2840..a0407e8 100644 --- a/src/st_descriptors.cpp +++ b/src/st_descriptors.cpp @@ -31,11 +31,11 @@ StDescriptors::StDescriptors(const Structure &s, const Config &c): } StDescriptors::StDescriptors() {} -aed_type2 & StDescriptors::get_aed(const size_t i) { +aed_type & StDescriptors::get_aed(const size_t i) { return aeds.col(i); } -const aed_type2 &StDescriptors::get_aed(const size_t i) const { +const aed_type &StDescriptors::get_aed(const size_t i) const { return aeds.col(i); } rho_type& StDescriptors::get_rho(const size_t i) { -- GitLab