| 10 | } |
| 11 | |
| 12 | void MBTR::getK1(py::array_t<double> &descriptor, const vector<int> &Z, const string &geomFunc, const string &weightFunc, const map<string, double> ¶meters, double min, double max, double sigma, int n) |
| 13 | { |
| 14 | // Create mutable and unchecked version |
| 15 | auto descriptor_mu = descriptor.mutable_unchecked<1>(); |
| 16 | |
| 17 | int nAtoms = Z.size(); |
| 18 | double dx = (max-min)/(n-1); |
| 19 | double sigmasqrt2 = sigma*sqrt(2.0); |
| 20 | double start = min-dx/2; |
| 21 | |
| 22 | for (int i = 0; i < nAtoms; ++i) { |
| 23 | // Only consider atoms within the original cell |
| 24 | if (i >= this->interactionLimit) { |
| 25 | continue; |
| 26 | } |
| 27 | |
| 28 | // Calculate geometry value |
| 29 | double geom; |
| 30 | if (geomFunc == "atomic_number") { |
| 31 | geom = k1GeomAtomicNumber(i, Z); |
| 32 | } else { |
| 33 | throw invalid_argument("Invalid geometry function."); |
| 34 | } |
| 35 | |
| 36 | // Calculate weight value |
| 37 | double weight; |
| 38 | if (weightFunc == "unity") { |
| 39 | weight = k1WeightUnity(i); |
| 40 | } else { |
| 41 | throw invalid_argument("Invalid weighting function."); |
| 42 | } |
| 43 | |
| 44 | // Calculate gaussian |
| 45 | vector<double> gauss = gaussian(geom, weight, start, dx, sigmasqrt2, n); |
| 46 | |
| 47 | // Get the index of the present elements in the final vector |
| 48 | int i_elem = Z[i]; |
| 49 | int i_index = this->atomicNumberToIndexMap.at(i_elem); |
| 50 | int begin = i_index * n; |
| 51 | int end = (i_index + 1) * n; |
| 52 | |
| 53 | for (int index = 0; index < n; ++index) { |
| 54 | descriptor_mu[begin+index] += gauss[index]; |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | void MBTR::getK2(py::array_t<double> &descriptor, py::array_t<double> &derivatives, bool return_descriptor, bool return_derivatives, const vector<int> &Z, const vector<vector<double>> &positions, const vector<vector<double>> &distances, const vector<vector<int>> &neighbours, const string &geomFunc, const string &weightFunc, const map<string, double> ¶meters, double min, double max, double sigma, int n) |
| 60 | { |
nothing calls this directly
no outgoing calls
no test coverage detected