From b769b7c8231fab6fe9d54fbb6903aa21a28a2f0f Mon Sep 17 00:00:00 2001
From: Mikhail Svechnikov <svechnikovmv@gmail.com>
Date: Thu, 30 Nov 2023 21:53:44 +0100
Subject: [PATCH] rm ConversionUtils

---
 Base/Util/ConversionUtil.cpp         | 34 ----------------------------
 Base/Util/ConversionUtil.h           | 28 -----------------------
 GUI/Model/Beam/SourceItems.cpp       |  1 -
 GUI/Model/Device/InstrumentItems.cpp | 10 ++++----
 Sim/Scan/QzScan.cpp                  |  5 ++--
 Tests/SimFactory/MakeSimulations.cpp |  3 +--
 6 files changed, 9 insertions(+), 72 deletions(-)
 delete mode 100644 Base/Util/ConversionUtil.cpp
 delete mode 100644 Base/Util/ConversionUtil.h

diff --git a/Base/Util/ConversionUtil.cpp b/Base/Util/ConversionUtil.cpp
deleted file mode 100644
index cf5ed5979a5..00000000000
--- a/Base/Util/ConversionUtil.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-//  ************************************************************************************************
-//
-//  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 <cmath>
-#include <numbers>
-
-using std::numbers::pi;
-
-double Convert::qz2alpha(double lambda, double qz)
-{
-    return std::asin(qz * lambda / 4 / pi);
-}
-
-double Convert::qz2lambda(double alpha, double qz)
-{
-    return 4 * pi * std::sin(alpha) / qz;
-}
-
-double Convert::qz(double alpha, double lambda)
-{
-    return qz2lambda(alpha, lambda);
-}
diff --git a/Base/Util/ConversionUtil.h b/Base/Util/ConversionUtil.h
deleted file mode 100644
index 0b24f7a19f1..00000000000
--- a/Base/Util/ConversionUtil.h
+++ /dev/null
@@ -1,28 +0,0 @@
-//  ************************************************************************************************
-//
-//  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 Convert {
-
-double qz2alpha(double lambda, double qz);
-
-double qz2lambda(double alpha, double qz);
-
-double qz(double alpha, double lambda);
-
-} // namespace Convert::Refl
-
-#endif // BORNAGAIN_BASE_UTIL_CONVERSIONUTIL_H
diff --git a/GUI/Model/Beam/SourceItems.cpp b/GUI/Model/Beam/SourceItems.cpp
index 1d3d1cc41cc..f95d0dedcb3 100644
--- a/GUI/Model/Beam/SourceItems.cpp
+++ b/GUI/Model/Beam/SourceItems.cpp
@@ -16,7 +16,6 @@
 #include "Base/Axis/Scale.h"
 #include "Base/Const/Units.h"
 #include "Base/Util/Assert.h"
-#include "Base/Util/ConversionUtil.h"
 #include "Device/Beam/Beam.h"
 #include "Device/Beam/FootprintGauss.h"
 #include "Device/Beam/FootprintSquare.h"
diff --git a/GUI/Model/Device/InstrumentItems.cpp b/GUI/Model/Device/InstrumentItems.cpp
index a3be350a5b6..fb69b026e1f 100644
--- a/GUI/Model/Device/InstrumentItems.cpp
+++ b/GUI/Model/Device/InstrumentItems.cpp
@@ -17,7 +17,6 @@
 #include "Base/Axis/Scale.h"
 #include "Base/Const/Units.h"
 #include "Base/Util/Assert.h"
-#include "Base/Util/ConversionUtil.h"
 #include "Device/Beam/Beam.h"
 #include "Device/Beam/IFootprint.h"
 #include "Device/Data/Datafield.h"
@@ -414,10 +413,11 @@ Frame SpecularInstrumentItem::makeFrame() const
             return Frame({});
 
         if (pAxis->unit() == "1/nm") {
-            double l = scanItem()->wavelength();
-            Scale ax = pAxis->transformedScale(Coordinate("alpha_i", "rad").label(), [l](double x) {
-                return Convert::qz2alpha(l, x);
-            });
+            double lambda = scanItem()->wavelength();
+            Scale ax =
+                pAxis->transformedScale(Coordinate("alpha_i", "rad").label(), [lambda](double qz) {
+                    return std::asin(qz * lambda / 4 / pi);
+                });
             return Frame(ax.clone());
         }
         Scale* ax0 = pAxis->clone();
diff --git a/Sim/Scan/QzScan.cpp b/Sim/Scan/QzScan.cpp
index 32e9d161380..a51e54192d6 100644
--- a/Sim/Scan/QzScan.cpp
+++ b/Sim/Scan/QzScan.cpp
@@ -16,7 +16,6 @@
 #include "Base/Axis/MakeScale.h"
 #include "Base/Axis/Scale.h"
 #include "Base/Util/Assert.h"
-#include "Base/Util/ConversionUtil.h"
 #include "Device/Pol/PolFilter.h"
 #include "Param/Distrib/Distributions.h"
 #include "Param/Distrib/ParameterSample.h"
@@ -24,6 +23,8 @@
 #include <algorithm> // is_sorted
 #include <numbers>
 
+using std::numbers::pi;
+
 QzScan::QzScan(Scale* qs_nm)
     : BeamScan(qs_nm)
 {
@@ -37,7 +38,7 @@ QzScan::QzScan(Scale* qs_nm)
     m_beams.clear();
     for (size_t i = 0; i < nScan(); i++) {
         // Qz scan is internally understood as wavelength scan
-        double lambda = Convert::qz2lambda(defaultInclination, m_axis->binCenter(i));
+        double lambda = 4 * pi * std::sin(defaultInclination) / m_axis->binCenter(i);
         auto* beam = new Beam(defaultIntensity, lambda, defaultInclination);
         // Since the grazing geometry is not clear in q-space, the footprint should not be used
         beam->setFootprint(nullptr);
diff --git a/Tests/SimFactory/MakeSimulations.cpp b/Tests/SimFactory/MakeSimulations.cpp
index cf89e03e25c..6d37620c2c5 100644
--- a/Tests/SimFactory/MakeSimulations.cpp
+++ b/Tests/SimFactory/MakeSimulations.cpp
@@ -16,7 +16,6 @@
 #include "Base/Axis/MakeScale.h"
 #include "Base/Axis/Scale.h"
 #include "Base/Const/Units.h"
-#include "Base/Util/ConversionUtil.h"
 #include "Device/Beam/Beam.h"
 #include "Device/Beam/FootprintGauss.h"
 #include "Device/Beam/FootprintSquare.h"
@@ -289,7 +288,7 @@ BeamScan* test::makeSimulation::BasicSpecularScan(bool vsQ)
         auto angles = angle_axis.binCenters();
         std::vector<double> qs(angle_axis.size(), 0.0);
         for (size_t i = 0, size = qs.size(); i < size; ++i)
-            qs[i] = Convert::qz(angles[i], wavelength);
+            qs[i] = 4 * pi * std::sin(angles[i]) / wavelength;
         return new QzScan(qs);
     }
     auto* result = new AlphaScan(EquiScan("alpha_i (rad)", n, max_angle / n, max_angle));
-- 
GitLab