Commit c55315a9 authored by Jan Oliver Oelerich's avatar Jan Oliver Oelerich

Improved slice potential calculation even more

parent d72c044d
......@@ -70,7 +70,7 @@ void Slice::calculateTransmissionFunction(const shared_ptr<FPConfManager> &fpman
_transmission_function.init(samples_x, samples_y, complex<float>(1.0, 0.0));
for(auto &a: _atoms) {
auto & pot_cache = sf.getPotential(a->getElement());
// now add up all the potentials
double dx = fpman->dx(a->getId());
......@@ -111,7 +111,7 @@ void Slice::calculateTransmissionFunction(const shared_ptr<FPConfManager> &fpman
dist_y = current_y * scale_y - (a->getY() + dy);
distance = sqrt(pow(dist_x, 2) + pow(dist_y, 2));
vz[x][y] += sf.getPotential(distance, a->getElement());
vz[x][y] += pot_cache[sf.getIndex(distance)];
}
}
}
......
......@@ -104,7 +104,14 @@ namespace stemsalabim { namespace atomic {
return grating_atompot / length_atompot;
}
double getPotential(double distance, const std::shared_ptr<Element> &element) {
int getIndex(double distance) const {
if(distance > _cutoff)
return -1;
return (int)round(fabs(distance) * _grating);
}
double getPotential(double distance, const std::shared_ptr<Element> &element) const {
if(distance > _cutoff)
return 0.0;
......@@ -112,6 +119,10 @@ namespace stemsalabim { namespace atomic {
return _cache.at(element->symbol())[index];
}
const std::vector<double> & getPotential(const std::shared_ptr<Element> &element)const {
return _cache.at(element->symbol());
}
void initPotential(const std::shared_ptr<Element> &element) {
std::unique_lock<std::mutex> lck(_cache_mtx);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment