Commit 0156e9e0 authored by Jan Oliver Oelerich's avatar Jan Oliver Oelerich

Added slice coords to output file, added frozen_phonon.enabled and changed 0...

Added slice coords to output file, added frozen_phonon.enabled and changed 0 distance potential calculation
parent 8ce7c691
......@@ -73,7 +73,6 @@ namespace stemsalabim {
std::normal_distribution<double> distribution(0.0, 1.0);
auto rgen = p.getRandomGenerator();
size_t cnt = 0;
_displacements.resize(_total_configurations);
for(size_t j = 0; j < _total_configurations; j++) {
......@@ -81,13 +80,19 @@ namespace stemsalabim {
_displacements[j].resize(_crystal->numberOfAtoms());
for(size_t i = 0; i < _crystal->numberOfAtoms(); i++) {
std::get<0>(_displacements[j][i]) = sqrt(_crystal->getAtoms()[i]->getMSD()) * distribution(rgen);
std::get<1>(_displacements[j][i]) = sqrt(_crystal->getAtoms()[i]->getMSD()) * distribution(rgen);
if(fixed_slicing) {
std::get<2>(_displacements[j][i]) = 0;
cnt++;
if(p.fpEnabled()) {
std::get<0>(_displacements[j][i]) = sqrt(_crystal->getAtoms()[i]->getMSD()) * distribution(rgen);
std::get<1>(_displacements[j][i]) = sqrt(_crystal->getAtoms()[i]->getMSD()) * distribution(rgen);
if(fixed_slicing) {
std::get<2>(_displacements[j][i]) = 0;
} else {
std::get<2>(_displacements[j][i]) = sqrt(_crystal->getAtoms()[i]->getMSD()) * distribution(rgen);
}
} else {
std::get<2>(_displacements[j][i]) = sqrt(_crystal->getAtoms()[i]->getMSD()) * distribution(rgen);
std::get<0>(_displacements[j][i]) = 0.0;
std::get<1>(_displacements[j][i]) = 0.0;
std::get<2>(_displacements[j][i]) = 0.0;
}
}
}
......
......@@ -129,6 +129,8 @@ void GridManager::generateGrids() {
_adf_store_slice[slice->id()] = false;
_cbed_store_slice[slice->id()] = false;
_slice_coords.push_back(slice->z());
if(snum == nslices || (p.adfSaveEveryNSlices() > 0 && snum % every_nslices_adf == 0)) {
_adf_slice_coords.push_back(slice->z());
_adf_store_slice[slice->id()] = true;
......
......@@ -248,6 +248,14 @@ namespace stemsalabim {
return _cbed_slice_coords;
}
/*!
* Get the z coordinates of the Slice objects
* @return vector of z coordinates of the slices
*/
const std::vector<float> sliceCoords() const {
return _slice_coords;
}
/*!
* Return all ScanPoint objects for all the pixels that are calculated by the simulation.
* @return vector of ScanPoints
......@@ -610,6 +618,7 @@ namespace stemsalabim {
std::vector<double> _detector_grid;
std::vector<double> _adf_slice_coords;
std::vector<double> _cbed_slice_coords;
std::vector<float> _slice_coords;
std::vector<double> _defoci;
std::vector<double> _defocus_weights;
std::vector<ScanPoint> _scan_points;
......
......@@ -72,6 +72,7 @@ void IO::initNCFile(const shared_ptr<GridManager> &gridman, const shared_ptr<ato
auto radiusVar = g.defineVar<float>("radius", vd({frameDim, atomDim}));
auto MSDVar = g.defineVar<float>("msd", vd({frameDim, atomDim}));
auto sliceVar = g.defineVar<int>("slice", vd({frameDim, atomDim}));
auto sliceCoordsVar = g.defineVar<float>("slice_coordinates", vd({slicesDim}));
auto elementVar = g.defineVar<short>("element", vd({frameDim, atomDim}));
auto systemLengthsVar = g.defineVar<float>("system_lengths", vd({cellSpatialDim}));
auto systemAnglesVar = g.defineVar<float>("system_angles", vd({cellSpatialDim}));
......@@ -868,6 +869,11 @@ void IO::writeGrids(const shared_ptr<GridManager> &gridman) {
g.var("defocus_weights").put(vs({0}), vs({gridman->defocusWeights().size()}), gridman->defocusWeights());
}
{
auto g = f.group("AMBER");
g.var("slice_coordinates").put(vs({0}), vs({gridman->slices().size()}), gridman->sliceCoords());
}
} catch(NcException &e) {
output::error("%s\n", e.what());
}
......
......@@ -93,6 +93,7 @@ void Params::readParamsFromString(const string &prms) {
if(!cliParamGiven("num-configurations"))
_cfg.lookupValue("frozen_phonon.number_configurations", _number_configurations);
_cfg.lookupValue("frozen_phonon.fixed_slicing", _fixed_slicing);
_cfg.lookupValue("frozen_phonon.enabled", _fp_enabled);
// CBED stuff
if(_cfg.exists("cbed")) {
......
......@@ -277,6 +277,15 @@ namespace stemsalabim {
return _number_configurations;
}
/*!
* Return whether frozen phonon should be enabled
* @return true if enabled.
*/
bool fpEnabled() const {
return _fp_enabled;
}
/*!
* Get the (generated) random seed of this simulation.
* @return random seed
......@@ -570,6 +579,7 @@ namespace stemsalabim {
double _slice_thickness{0.2715};
unsigned int _number_configurations{1};
bool _fp_enabled{true};
bool _fixed_slicing{true};
std::string _crystal_file{""};
......
......@@ -126,7 +126,7 @@ namespace stemsalabim { namespace atomic {
double factor = pi / (2 * _cutoff * 0.15);
double tapering_radius = 0.85 * _cutoff;
v[0] = feKirklandReal(1.0 / _grating, element);
v[0] = feKirklandReal(0.0018, element);
for(unsigned int i = 1; i < cache_len; ++i) {
double distance = i / _grating;
v[i] = feKirklandReal(distance, element);
......
......@@ -429,6 +429,29 @@ namespace stemsalabim {
}
}
inline bool checkFFTEfficient(int n) {
if(n==1)
return true;
else {
if(n % 2 == 0)
return checkFFTEfficient(n / 2);
if(n % 3 == 0)
return checkFFTEfficient(n / 3);
if(n % 5 == 0)
return checkFFTEfficient(n / 5);
if(n % 7 == 0)
return checkFFTEfficient(n / 7);
}
return false;
}
inline int getFFTEfficientSize(int N) {
while(!checkFFTEfficient(N)) {
N++;
}
return N;
}
}
#endif // ALGORITHMS_HPP_
\ No newline at end of file
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