MCPcopy Create free account
hub / github.com/SINGROUP/dscribe / getK2Local

Method getK2Local

dscribe/ext/mbtr.cpp:584–668  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

582}
583
584vector<map<string, vector<double>>> MBTR::getK2Local(const vector<int> &indices, const vector<int> &Z, const vector<vector<double> > &distances, const vector<vector<int> > &neighbours, const string &geomFunc, const string &weightFunc, const map<string, double> &parameters, double min, double max, double sigma, int n)
585{
586 // Initialize some variables outside the loop
587 int nPos = indices.size();
588 vector<map<string, vector<double> > > k2Maps(nPos);
589 double dx = (max-min)/(n-1);
590 double sigmasqrt2 = sigma*sqrt(2.0);
591 double start = min-dx/2;
592
593 // We loop over the specified indices
594 for (int i = 0; i < nPos; ++i) {
595 int iTrue = indices[i];
596 map<string, vector<double> > k2Map;
597
598 // For each atom we loop only over the neighbours
599 const vector<int> &i_neighbours = neighbours[i];
600 for (const int &j : i_neighbours) {
601
602 // Self-distances are not considered
603 if (iTrue == j) {
604 continue;
605 }
606
607 // Calculate geometry value
608 double geom;
609 if (geomFunc == "inverse_distance") {
610 geom = k2GeomInverseDistance(i, j, distances);
611 } else if (geomFunc == "distance") {
612 geom = k2GeomDistance(i, j, distances);
613 } else {
614 throw invalid_argument("Invalid geometry function.");
615 }
616
617 // Calculate weight value
618 double weight;
619 if (weightFunc == "exp") {
620 double scale = parameters.at("scale");
621 double threshold = parameters.at("threshold");
622 weight = k2WeightExponential(i, j, distances, scale);
623 if (weight < threshold) {
624 continue;
625 }
626 } else if (weightFunc == "unity") {
627 weight = k2WeightUnity(i, j, distances);
628 } else {
629 throw invalid_argument("Invalid weighting function.");
630 }
631
632 // Calculate gaussian
633 vector<double> gauss = gaussian(geom, weight, start, dx, sigmasqrt2, n);
634
635 // Get the index of the present elements in the final vector
636 int i_elem = 0;
637 int j_elem = Z[j];
638 int i_index = this->atomicNumberToIndexMap.at(i_elem);
639 int j_index = this->atomicNumberToIndexMap.at(j_elem);
640
641 // Save information in the part where j_index >= i_index

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected