1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Resample/Swig/MultiLayerFuncs.cpp
//! @brief Global functions related to MultiLayers.
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#include "Resample/Swig/MultiLayerFuncs.h"
#include "Resample/Option/SimulationOptions.h"
#include "Resample/Processed/ReSample.h"
#include "Resample/Slice/ProfileHelper.h"
namespace {
ProfileHelper helper(const Sample& sample)
{
SimulationOptions options;
options.setUseAvgMaterials(true);
const ReSample resample = ReSample::make(sample, options);
return {resample.averageSlices()};
}
} // namespace
std::vector<double> swigAPI::generateZValues(int n_points, double z_min, double z_max)
{
std::vector<double> result;
if (n_points < 1)
return result;
double step = n_points > 1 ? (z_max - z_min) / (n_points - 1) : 0.0;
for (int i = 0; i < n_points; ++i)
result.push_back(z_min + i * step);
return result;
}
std::vector<complex_t> swigAPI::materialProfileSLD(const Sample& sample, int n_points, double z_min,
double z_max)
{
std::vector<double> z_values = generateZValues(n_points, z_min, z_max);
return ::helper(sample).calculateSLDProfile(z_values);
}
std::vector<double> swigAPI::magnetizationProfile(const Sample& sample, std::string xyz,
int n_points, double z_min, double z_max)
{
std::vector<double> z_values = generateZValues(n_points, z_min, z_max);
return ::helper(sample).calculateMagnetizationProfile(z_values, xyz);
}
std::pair<double, double> swigAPI::defaultMaterialProfileLimits(const Sample& sample)
{
SimulationOptions options;
options.setUseAvgMaterials(true);
const ReSample resample = ReSample::make(sample, options);
ProfileHelper helper(resample.averageSlices());
return helper.defaultLimits();
}
|