Skip to content
Snippets Groups Projects
Commit c1fdab74 authored by Mikhail Svechnikov's avatar Mikhail Svechnikov Committed by Mikhail Svechnikov
Browse files

add ConversionUtil

parent f28038d2
No related branches found
No related tags found
1 merge request!2178Do a coordinates conversion for loaded specular data (#811)
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Base/Util/ConversionUtil.cpp
//! @brief Implements namespace Conversion.
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2023
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#include "Base/Util/ConversionUtil.h"
#include "Base/Util/Assert.h"
#include <cmath>
#include <numbers>
double Conversion::Refl::qz2alpha(double lambda, double qz)
{
return std::asin(qz * lambda / 4.0 / std::numbers::pi);
}
double Conversion::Refl::qz2lambda(double alpha, double qz)
{
return 4.0 * std::numbers::pi * std::sin(alpha) / qz;
}
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file Base/Util/ConversionUtil.h
//! @brief Implements namespace Conversion.
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2023
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#ifndef BORNAGAIN_BASE_UTIL_CONVERSIONUTIL_H
#define BORNAGAIN_BASE_UTIL_CONVERSIONUTIL_H
namespace Conversion::Refl {
double qz2alpha(double lambda, double qz);
double qz2lambda(double alpha, double qz);
}
#endif // BORNAGAIN_BASE_UTIL_CONVERSIONUTIL_H
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "Base/Axis/MakeScale.h" #include "Base/Axis/MakeScale.h"
#include "Base/Axis/Scale.h" #include "Base/Axis/Scale.h"
#include "Base/Util/Assert.h" #include "Base/Util/Assert.h"
#include "Base/Util/ConversionUtil.h"
#include "Device/Pol/PolFilter.h" #include "Device/Pol/PolFilter.h"
#include "Param/Distrib/Distributions.h" #include "Param/Distrib/Distributions.h"
#include "Param/Distrib/ParameterSample.h" #include "Param/Distrib/ParameterSample.h"
...@@ -36,9 +37,7 @@ QzScan::QzScan(Scale* qs_nm) ...@@ -36,9 +37,7 @@ QzScan::QzScan(Scale* qs_nm)
m_beams.clear(); m_beams.clear();
for (size_t i = 0; i < nScan(); i++) { for (size_t i = 0; i < nScan(); i++) {
// Qz scan is internally understood as wavelength scan // Qz scan is internally understood as wavelength scan
// TODO use some shared function "qz2lambda" double lambda = Conversion::Refl::qz2lambda(defaultInclination, m_axis->binCenter(i));
double lambda =
4.0 * std::numbers::pi * std::sin(defaultInclination) / m_axis->binCenter(i);
auto* beam = new Beam(defaultIntensity, lambda, defaultInclination); auto* beam = new Beam(defaultIntensity, lambda, defaultInclination);
// Since the grazing geometry is not clear in q-space, the footprint should not be used // Since the grazing geometry is not clear in q-space, the footprint should not be used
beam->setFootprint(nullptr); beam->setFootprint(nullptr);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment