From 831cc59d925f579ac4997f8ee899bfab12a37e66 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 09:58:22 +0200
Subject: [PATCH 01/63] rm tag

---
 GUI/Model/Device/InstrumentItems.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/GUI/Model/Device/InstrumentItems.h b/GUI/Model/Device/InstrumentItems.h
index 98642bf3dd6..4e1221a03c7 100644
--- a/GUI/Model/Device/InstrumentItems.h
+++ b/GUI/Model/Device/InstrumentItems.h
@@ -90,14 +90,12 @@ public:
     DOUBLE_PROPERTY(analyzerEfficiency, AnalyzerEfficiency)
     DOUBLE_PROPERTY(analyzerTotalTransmission, AnalyzerTotalTransmission);
 
-
 protected:
     explicit InstrumentItem(const QString& modelType);
 
     template <typename T>
     T* beam() const;
 
-protected:
     QString m_id;
     QString m_name;
     QString m_description;
-- 
GitLab


From 5d071ac6700de33631c18848e7af1ec4a70fec8f Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 10:06:00 +0200
Subject: [PATCH 02/63] spell out setPolFilters; fct name instrumentItem()

---
 GUI/Model/Device/InstrumentItems.cpp   | 28 +++++++++++++++-----------
 GUI/Model/Device/InstrumentItems.h     |  2 +-
 GUI/Model/Model/ParameterTreeUtils.cpp |  4 ++--
 GUI/View/FromDomain/FromDomain.cpp     |  2 +-
 Tests/Unit/GUI/TestDetectorItems.cpp   |  2 +-
 Tests/Unit/GUI/TestLinkInstrument.cpp  |  2 +-
 6 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/GUI/Model/Device/InstrumentItems.cpp b/GUI/Model/Device/InstrumentItems.cpp
index f39d0ca589e..a71e1e81364 100644
--- a/GUI/Model/Device/InstrumentItems.cpp
+++ b/GUI/Model/Device/InstrumentItems.cpp
@@ -342,7 +342,7 @@ void Instrument2DItem::serialize(Streamer& s)
     Serialize::rwSelected<DetectorItemCatalog>(s, m_detectorItem);
 }
 
-DetectorItem* Instrument2DItem::detector() const
+DetectorItem* Instrument2DItem::detectorItem() const
 {
     return m_detectorItem.get();
 }
@@ -354,20 +354,24 @@ SelectionDescriptor<DetectorItem*> Instrument2DItem::detectorSelection() const
 
 void Instrument2DItem::importMasks(const MaskContainerItem* maskContainer)
 {
-    detector()->importMasks(maskContainer);
+    detectorItem()->importMasks(maskContainer);
 }
 
 std::unique_ptr<Instrument> Instrument2DItem::createInstrument() const
 {
-    std::unique_ptr<Instrument> instrument(new Instrument);
-    instrument->setBeam(*beamItem()->createBeam());
-    instrument->setDetector(*detector()->createDetector());
+    auto beam = beamItem()->createBeam();
+    beam->setPolarization(m_polarization);
+    auto detector = detectorItem()->createDetector();
+    detector->setDetectorNormal(beam->direction().zReflected());
 
     // TODO: Why not check "if (withPolarizerAnalyzer())"? But if it is inserted, some of the unit
     // tests fail (because in the unit tests this flag is never set to true)
     // The Unit test are e.g. TestGuiStd/Std/MagneticCylinders
-    instrument->setPolFilters(m_polarization, m_analyzerDirection, m_analyzerEfficiency,
-                              m_analyzerTotalTransmission);
+    detector->setAnalyzer(m_analyzerDirection, m_analyzerEfficiency, m_analyzerTotalTransmission);
+
+    std::unique_ptr<Instrument> instrument(new Instrument);
+    instrument->setBeam(*beam);
+    instrument->setDetector(*detector);
 
     return instrument;
 }
@@ -378,7 +382,7 @@ std::unique_ptr<Instrument> Instrument2DItem::createInstrument() const
 
 std::vector<int> GISASInstrumentItem::shape() const
 {
-    auto* detector_item = detector();
+    auto* detector_item = detectorItem();
     return {detector_item->xSize(), detector_item->ySize()};
 }
 
@@ -391,8 +395,8 @@ void GISASInstrumentItem::updateToRealData(const RealDataItem* item)
     if (shape().size() != data_shape.size())
         throw Error("Error in GISASInstrumentItem::updateToRealData: The type of "
                     "instrument is incompatible with passed data shape.");
-    detector()->setXSize(data_shape[0]);
-    detector()->setYSize(data_shape[1]);
+    detectorItem()->setXSize(data_shape[0]);
+    detectorItem()->setYSize(data_shape[1]);
 }
 
 QString GISASInstrumentItem::defaultName() const
@@ -437,7 +441,7 @@ void OffSpecularInstrumentItem::serialize(Streamer& s)
 
 std::vector<int> OffSpecularInstrumentItem::shape() const
 {
-    return {(int)m_alphaAxis.nbins(), detector()->ySize()};
+    return {(int)m_alphaAxis.nbins(), detectorItem()->ySize()};
 }
 
 void OffSpecularInstrumentItem::updateToRealData(const RealDataItem* dataItem)
@@ -451,7 +455,7 @@ void OffSpecularInstrumentItem::updateToRealData(const RealDataItem* dataItem)
                     "instrument is incompatible with passed data shape.");
 
     m_alphaAxis.setNbins(data_shape[0]);
-    detector()->setYSize(data_shape[1]);
+    detectorItem()->setYSize(data_shape[1]);
 }
 
 QString OffSpecularInstrumentItem::defaultName() const
diff --git a/GUI/Model/Device/InstrumentItems.h b/GUI/Model/Device/InstrumentItems.h
index 4e1221a03c7..ea9b2bd1a32 100644
--- a/GUI/Model/Device/InstrumentItems.h
+++ b/GUI/Model/Device/InstrumentItems.h
@@ -147,7 +147,7 @@ class Instrument2DItem : public InstrumentItem {
 public:
     void serialize(Streamer& s) override;
 
-    DetectorItem* detector() const;
+    DetectorItem* detectorItem() const;
     GroupItem* detectorGroup();
     template <typename T>
     T* setDetectorType();
diff --git a/GUI/Model/Model/ParameterTreeUtils.cpp b/GUI/Model/Model/ParameterTreeUtils.cpp
index 51db0764ab0..765dc4cae36 100644
--- a/GUI/Model/Model/ParameterTreeUtils.cpp
+++ b/GUI/Model/Model/ParameterTreeUtils.cpp
@@ -324,7 +324,7 @@ void ParameterTreeBuilder::addInstrument()
         addBeamDistribution(beamLabel, beamItem->wavelengthItem(), "Wavelength");
         addBeamDistribution(beamLabel, beamItem->inclinationAngleItem(), "Inclination angle");
         addBeamDistribution(beamLabel, beamItem->azimuthalAngleItem(), "Azimuthal angle");
-        addDetector(label, gisas->detector());
+        addDetector(label, gisas->detectorItem());
         addPolarization(label, instrument);
         addBackground(label, instrument->backgroundItem());
     } else if (instrument->is<SpecularInstrumentItem>()) {
@@ -340,7 +340,7 @@ void ParameterTreeBuilder::addInstrument()
         addParameterItem(beamLabel, beamItem->intensity());
         addBeamDistribution(beamLabel, beamItem->wavelengthItem(), "Wavelength");
         addBeamDistribution(beamLabel, beamItem->azimuthalAngleItem(), "Azimuthal angle");
-        addDetector(label, os->detector());
+        addDetector(label, os->detectorItem());
         addPolarization(label, instrument);
     } else if (instrument->is<DepthProbeInstrumentItem>()) {
         auto* beamLabel = new ParameterLabelItem("Parameters", label);
diff --git a/GUI/View/FromDomain/FromDomain.cpp b/GUI/View/FromDomain/FromDomain.cpp
index 33b3fc17b4c..061ec61fa5e 100644
--- a/GUI/View/FromDomain/FromDomain.cpp
+++ b/GUI/View/FromDomain/FromDomain.cpp
@@ -497,7 +497,7 @@ void GUI::Transform::FromDomain::setDetector(Instrument2DItem* instrument_item,
     const IDetector& detector = simulation.detector();
     setDetectorGeometry(instrument_item, detector);
 
-    auto* detector_item = instrument_item->detector();
+    auto* detector_item = instrument_item->detectorItem();
 
     setDetectorResolution(detector_item, detector);
     setDetectorMasks(detector_item, simulation);
diff --git a/Tests/Unit/GUI/TestDetectorItems.cpp b/Tests/Unit/GUI/TestDetectorItems.cpp
index 08f7471559e..b9603f692a2 100644
--- a/Tests/Unit/GUI/TestDetectorItems.cpp
+++ b/Tests/Unit/GUI/TestDetectorItems.cpp
@@ -17,7 +17,7 @@ TEST_F(TestDetectorItems, resolutionFunction)
     InstrumentItems model;
     auto* instrument = model.addInstrument<GISASInstrumentItem>();
 
-    DetectorItem* detectorItem = instrument->detector();
+    DetectorItem* detectorItem = instrument->detectorItem();
 
     detectorItem->setResolutionFunctionType<ResolutionFunction2DGaussianItem>();
 
diff --git a/Tests/Unit/GUI/TestLinkInstrument.cpp b/Tests/Unit/GUI/TestLinkInstrument.cpp
index 38f36ca1204..af7e01f7f76 100644
--- a/Tests/Unit/GUI/TestLinkInstrument.cpp
+++ b/Tests/Unit/GUI/TestLinkInstrument.cpp
@@ -57,7 +57,7 @@ TEST_F(TestLinkInstrument, canLinkToInstrument)
                                                                               << realData);
 
     // changing detector binning and checking that link is destroyed
-    auto* detectorItem = dynamic_cast<RectangularDetectorItem*>(instrument->detector());
+    auto* detectorItem = dynamic_cast<RectangularDetectorItem*>(instrument->detectorItem());
     detectorItem->setXSize(10);
     document.instrumentsEditController()->notifyInstrumentChanged(instrument);
 
-- 
GitLab


From 3b40dd9366847980685b688feeac12e004ca9514 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 12:10:00 +0200
Subject: [PATCH 03/63] move check, eliminate next calls of setPolFilters

---
 Device/Detector/IDetector.cpp                    | 3 ++-
 Examples/specular/BasicPolarizedReflectometry.py | 4 ++--
 GUI/Model/Device/InstrumentItems.cpp             | 7 ++++---
 Tests/Unit/Device/SphericalDetectorTest.cpp      | 3 ---
 Tests/Unit/Sim/RectangularDetectorTest.cpp       | 5 -----
 5 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/Device/Detector/IDetector.cpp b/Device/Detector/IDetector.cpp
index 659a8278440..f2f4893d7a4 100644
--- a/Device/Detector/IDetector.cpp
+++ b/Device/Detector/IDetector.cpp
@@ -140,7 +140,8 @@ size_t IDetector::detectorIndexToRegionOfInterestIndex(const size_t detectorInde
 
 void IDetector::setAnalyzer(const R3 direction, double efficiency, double total_transmission)
 {
-    m_detection_properties.setDirEffTra(direction, efficiency, total_transmission);
+    if (direction.mag()>0)
+        m_detection_properties.setDirEffTra(direction, efficiency, total_transmission);
 }
 
 void IDetector::setDetectorResolution(const IDetectorResolution& p_detector_resolution)
diff --git a/Examples/specular/BasicPolarizedReflectometry.py b/Examples/specular/BasicPolarizedReflectometry.py
index 55cb8099dd8..c45f2dae4e4 100755
--- a/Examples/specular/BasicPolarizedReflectometry.py
+++ b/Examples/specular/BasicPolarizedReflectometry.py
@@ -49,8 +49,8 @@ def simulate(polarizer_dir, analyzer_dir, title):
     simulation.setScan(scan)
     simulation.setSample(get_sample())
 
-    simulation.instrument().setPolFilters(polarizer_dir, analyzer_dir, 1,
-                                          0.5)
+    simulation.beam().setPolarization(polarizer_dir)
+    simulation.detector().setAnalyzer(analyzer_dir, 1, 0.5)
 
     result = simulation.simulate()
     result.setTitle(title)
diff --git a/GUI/Model/Device/InstrumentItems.cpp b/GUI/Model/Device/InstrumentItems.cpp
index a71e1e81364..884f8687bf1 100644
--- a/GUI/Model/Device/InstrumentItems.cpp
+++ b/GUI/Model/Device/InstrumentItems.cpp
@@ -222,7 +222,7 @@ ICoordSystem* SpecularInstrumentItem::createCoordSystem() const
 {
     std::unique_ptr<Instrument> instrument(new Instrument);
     instrument->setBeam(*beamItem()->createBeam());
-    // TODO setPolFilters ?
+    // TODO set pol filters ?
     auto* axis_item = beamItem()->inclinationAxis();
     if (auto* pointwise_axis = dynamic_cast<PointwiseAxisItem*>(axis_item)) {
         if (!pointwise_axis->axis()) // workaround for loading project
@@ -321,7 +321,7 @@ std::unique_ptr<DepthProbeSimulation> DepthProbeInstrumentItem::createSimulation
 
 ICoordSystem* DepthProbeInstrumentItem::createCoordSystem() const
 {
-    // TODO setPolFilters ?
+    // TODO set pol filters ?
     return createSimulation()->createCoordSystem();
 }
 
@@ -367,7 +367,8 @@ std::unique_ptr<Instrument> Instrument2DItem::createInstrument() const
     // TODO: Why not check "if (withPolarizerAnalyzer())"? But if it is inserted, some of the unit
     // tests fail (because in the unit tests this flag is never set to true)
     // The Unit test are e.g. TestGuiStd/Std/MagneticCylinders
-    detector->setAnalyzer(m_analyzerDirection, m_analyzerEfficiency, m_analyzerTotalTransmission);
+    detector->setAnalyzer(
+            m_analyzerDirection, m_analyzerEfficiency, m_analyzerTotalTransmission);
 
     std::unique_ptr<Instrument> instrument(new Instrument);
     instrument->setBeam(*beam);
diff --git a/Tests/Unit/Device/SphericalDetectorTest.cpp b/Tests/Unit/Device/SphericalDetectorTest.cpp
index 8331ed13b43..118f4a251a3 100644
--- a/Tests/Unit/Device/SphericalDetectorTest.cpp
+++ b/Tests/Unit/Device/SphericalDetectorTest.cpp
@@ -219,9 +219,6 @@ TEST_F(SphericalDetectorTest, AnalyzerProperties)
     double total_transmission = 1.0;
     R3 unit_direction;
 
-    // if direction is the zero vector, an exception is thrown
-    EXPECT_FAILED_ASSERT(detector.setAnalyzer(direction, efficiency, total_transmission));
-
     // zero efficiency
     direction = R3(1.0, 0.0, 0.0);
     unit_direction = direction.unit();
diff --git a/Tests/Unit/Sim/RectangularDetectorTest.cpp b/Tests/Unit/Sim/RectangularDetectorTest.cpp
index ae3013b86da..48dd5278a93 100644
--- a/Tests/Unit/Sim/RectangularDetectorTest.cpp
+++ b/Tests/Unit/Sim/RectangularDetectorTest.cpp
@@ -2,7 +2,6 @@
 #include "Base/Const/Units.h"
 #include "Base/Util/Algorithms.h"
 #include "Device/Beam/Beam.h"
-#include "Sim/Simulation/ScatteringSimulation.h"
 #include "Tests/GTestWrapper/google_test.h"
 #include <iostream>
 #include <memory>
@@ -153,10 +152,6 @@ TEST_F(RectangularDetectorTest, AnalyzerProperties)
     double total_transmission = 1.0;
     R3 unit_direction;
 
-    // if direction is the zero vector, an exception is thrown
-    EXPECT_THROW(detector.setAnalyzer(direction, efficiency, total_transmission),
-                 std::runtime_error);
-
     // zero efficiency
     direction = R3(1.0, 0.0, 0.0);
     unit_direction = direction.unit();
-- 
GitLab


From 8f69886dd1dbc281fba5954bcd8a6d850ffa7d4a Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 12:28:50 +0200
Subject: [PATCH 04/63] rm setPolFilters from py examples

---
 Examples/scatter2d/MagneticCylinders2.py                  | 5 +++--
 Examples/scatter2d/MagneticSpheres.py                     | 4 ++--
 Examples/scatter2d/PolarizedSANS.py                       | 5 ++---
 Examples/specular/PolarizedNonperfectAnalyzerPolarizer.py | 6 ++----
 Examples/specular/PolarizedSpinAsymmetry.py               | 4 ++--
 Examples/specular/PolarizedSpinFlip.py                    | 4 ++--
 6 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/Examples/scatter2d/MagneticCylinders2.py b/Examples/scatter2d/MagneticCylinders2.py
index 32fd6298f48..45894e6c5c9 100755
--- a/Examples/scatter2d/MagneticCylinders2.py
+++ b/Examples/scatter2d/MagneticCylinders2.py
@@ -34,12 +34,13 @@ def get_sample():
     return sample
 
 def get_simulation(sample, pol_dir, efficiency):
+    z_up = R3(0, 0, 1)
     n = bp.simargs['n']
     beam = ba.Beam(1e9, 0.1*nm, ba.Direction(0.2*deg, 0))
+    beam.setPolarization(pol_dir)
     detector = ba.SphericalDetector(n, -1*deg, 1*deg, n, 0, 2*deg)
+    detector.setAnalyzer(z_up, efficiency, 0.5)
     simulation = ba.ScatteringSimulation(beam, sample, detector)
-    z_up = R3(0, 0, 1)
-    simulation.instrument().setPolFilters(pol_dir, z_up, efficiency, 0.5)
     return simulation
 
 def simulate(title, pol_dir, efficiency):
diff --git a/Examples/scatter2d/MagneticSpheres.py b/Examples/scatter2d/MagneticSpheres.py
index 8e674cfca47..c1483742f71 100755
--- a/Examples/scatter2d/MagneticSpheres.py
+++ b/Examples/scatter2d/MagneticSpheres.py
@@ -53,8 +53,8 @@ def get_simulation(sample):
 
     polarizer_dir = R3(0, 0, 1)
     analyzer_dir = R3(0, 0, -1)
-    simulation.instrument().setPolFilters(polarizer_dir, analyzer_dir, 1,
-                                          0.5)
+    simulation.beam().setPolarization(polarizer_dir)
+    simulation.detector().setAnalyzer(analyzer_dir, 1, 0.5)
 
     return simulation
 
diff --git a/Examples/scatter2d/PolarizedSANS.py b/Examples/scatter2d/PolarizedSANS.py
index 5de7d1174fa..2a3206773ff 100755
--- a/Examples/scatter2d/PolarizedSANS.py
+++ b/Examples/scatter2d/PolarizedSANS.py
@@ -57,17 +57,16 @@ def get_simulation(sample):
 
     # Beam from above (perpendicular to sample):
     beam = ba.Beam(1, 0.4*nm, ba.Direction(90*deg, 0))
+    beam.setPolarization(R3(0, 1, 0))
 
     # Detector opposite to source:
     detPos = 2000  # distance from sample center to detector in mm
     detWid = 500  # detector width in mm
     det = ba.RectangularDetector(n, detWid, n, detWid)
     det.setPerpendicularToDirectBeam(detPos, detWid/2, detWid/2)
-
+    det.setAnalyzer(R3(0, -1, 0), 1, 0.5)
     sim = ba.ScatteringSimulation(beam, sample, det)
 
-    sim.instrument().setPolFilters(R3(0, 1, 0), R3(0, -1, 0), 1, 0.5)
-
     return sim
 
 
diff --git a/Examples/specular/PolarizedNonperfectAnalyzerPolarizer.py b/Examples/specular/PolarizedNonperfectAnalyzerPolarizer.py
index cb363700922..86ae7c0fa68 100755
--- a/Examples/specular/PolarizedNonperfectAnalyzerPolarizer.py
+++ b/Examples/specular/PolarizedNonperfectAnalyzerPolarizer.py
@@ -80,10 +80,8 @@ def run_simulation(*,
     sample = get_sample()
     simulation = get_simulation(sample)
 
-    simulation.instrument().setPolFilters(
-        polarizer_dir*polarizer_efficiency, analyzer_dir,
-        analyzer_efficiency, 0.5)
-
+    simulation.beam().setPolarization(polarizer_dir*polarizer_efficiency)
+    simulation.detector().setAnalyzer(analyzer_dir, analyzer_efficiency, 0.5)
     simulation.setBackground(ba.ConstantBackground(1e-7))
 
     return simulation.simulate()
diff --git a/Examples/specular/PolarizedSpinAsymmetry.py b/Examples/specular/PolarizedSpinAsymmetry.py
index 0f0200419b0..aa40ca18d42 100755
--- a/Examples/specular/PolarizedSpinAsymmetry.py
+++ b/Examples/specular/PolarizedSpinAsymmetry.py
@@ -80,8 +80,8 @@ def get_simulation(q_axis, parameters, polarizer_dir, analyzer_dir):
     distr = ba.RangedDistributionGaussian(n_samples, n_sig)
     scan.setAbsoluteQResolution(distr, parameters["q_res"])
 
-    simulation.instrument().setPolFilters(polarizer_dir, analyzer_dir, 1,
-                                          0.5)
+    simulation.beam().setPolarization(polarizer_dir)
+    simulation.detector().setAnalyzer(analyzer_dir, 1, 0.5)
 
     simulation.setScan(scan)
     return simulation
diff --git a/Examples/specular/PolarizedSpinFlip.py b/Examples/specular/PolarizedSpinFlip.py
index e4c4b4a1357..3bc5cdb4704 100755
--- a/Examples/specular/PolarizedSpinFlip.py
+++ b/Examples/specular/PolarizedSpinFlip.py
@@ -55,8 +55,8 @@ def run_simulation(polarizer_dir=ba.R3(0, 1, 0),
     sample = get_sample()
     simulation = get_simulation(sample)
 
-    simulation.instrument().setPolFilters(polarizer_dir, analyzer_dir, 1,
-                                          0.5)
+    simulation.beam().setPolarization(polarizer_dir)
+    simulation.detector().setAnalyzer(analyzer_dir, 1, 0.5)
 
     return simulation.simulate()
 
-- 
GitLab


From 068341bbc83f436d2114dbe4068497d1415a9b0c Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 12:45:49 +0200
Subject: [PATCH 05/63] rm Instrument::setPolFilters

---
 Device/Instrument/Instrument.cpp           |  8 ---
 Device/Instrument/Instrument.h             |  3 -
 Tests/Functional/Suite/MakeSimulations.cpp |  9 ++-
 Tests/Unit/Sim/SpecularSimulationTest.cpp  |  6 +-
 auto/Wrap/doxygenDevice.i                  |  3 -
 auto/Wrap/libBornAgainDevice.py            |  8 ---
 auto/Wrap/libBornAgainDevice_wrap.cpp      | 64 ----------------------
 7 files changed, 10 insertions(+), 91 deletions(-)

diff --git a/Device/Instrument/Instrument.cpp b/Device/Instrument/Instrument.cpp
index 8782da713cf..f56ae36694c 100644
--- a/Device/Instrument/Instrument.cpp
+++ b/Device/Instrument/Instrument.cpp
@@ -115,11 +115,3 @@ IDetector& Instrument::detector()
     ASSERT(m_detector);
     return *m_detector;
 }
-
-void Instrument::setPolFilters(const R3& polarizer_dir, const R3& analyzer_dir,
-                               double analyzer_efficiency, double analyzer_transmission)
-{
-    m_beam->setPolarization(polarizer_dir);
-    if (analyzer_dir.mag() > 0.0)
-        m_detector->setAnalyzer(analyzer_dir, analyzer_efficiency, analyzer_transmission);
-}
diff --git a/Device/Instrument/Instrument.h b/Device/Instrument/Instrument.h
index 7f2ba93a797..f1ea452f1ac 100644
--- a/Device/Instrument/Instrument.h
+++ b/Device/Instrument/Instrument.h
@@ -54,9 +54,6 @@ public:
     //! init detector with beam settings
     void initDetector();
 
-    void setPolFilters(const R3& polarizer_dir, const R3& analyzer_dir, double analyzer_efficiency,
-                       double analyzer_transmission);
-
     std::vector<const INode*> nodeChildren() const override;
 
 protected:
diff --git a/Tests/Functional/Suite/MakeSimulations.cpp b/Tests/Functional/Suite/MakeSimulations.cpp
index 368f6261c4d..f793bb860bb 100644
--- a/Tests/Functional/Suite/MakeSimulations.cpp
+++ b/Tests/Functional/Suite/MakeSimulations.cpp
@@ -111,7 +111,8 @@ std::unique_ptr<ScatteringSimulation> test::makeSimulation::BasicGISAS(const Mul
 std::unique_ptr<ScatteringSimulation> test::makeSimulation::SpinflipGISAS(const MultiLayer& sample)
 {
     std::unique_ptr<ScatteringSimulation> result = BasicGISAS(sample);
-    result->instrument().setPolFilters(zplus, zplus, -1.0, 0.5);
+    result->beam().setPolarization(zplus);
+    result->detector().setAnalyzer(zplus, -1.0, 0.5);
     return result;
 }
 
@@ -203,7 +204,8 @@ std::unique_ptr<ScatteringSimulation> test::makeSimulation::MaxiGISAS(const Mult
 std::unique_ptr<ScatteringSimulation> test::makeSimulation::MaxiGISAS00(const MultiLayer& sample)
 {
     std::unique_ptr<ScatteringSimulation> result = MaxiGISAS(sample);
-    result->instrument().setPolFilters(zplus, zplus, 1.0, 0.5);
+    result->beam().setPolarization(zplus);
+    result->detector().setAnalyzer(zplus, 1.0, 0.5);
     return result;
 }
 
@@ -389,7 +391,8 @@ test::makeSimulation::BasicYPolarizedSpecular(const MultiLayer& sample, const st
 {
     const auto yCase = YPolarizationCases.at(polCase);
     auto simulation = BasicSpecular(sample, vsQ);
-    simulation->instrument().setPolFilters(yCase.first, yCase.second, 1.0, 0.5);
+    simulation->beam().setPolarization(yCase.first);
+    simulation->detector().setAnalyzer(yCase.second, 1.0, 0.5);
     simulation->setSample(sample);
     return simulation;
 }
diff --git a/Tests/Unit/Sim/SpecularSimulationTest.cpp b/Tests/Unit/Sim/SpecularSimulationTest.cpp
index 854fb9d2be4..4e007b1c2c2 100644
--- a/Tests/Unit/Sim/SpecularSimulationTest.cpp
+++ b/Tests/Unit/Sim/SpecularSimulationTest.cpp
@@ -91,7 +91,8 @@ TEST_F(SpecularSimulationTest, SetAngularScan)
     AlphaScan scan4(1.0, 10, .0 * Units::deg, 2.0 * Units::deg);
     const auto polarizer_dir = R3({0., 0., 0.876});
     const auto analyzer_dir = R3({0., 0., 1.});
-    sim4.instrument().setPolFilters(polarizer_dir, analyzer_dir, 0.33, 0.22);
+    sim4.beam().setPolarization(polarizer_dir);
+    sim4.detector().setAnalyzer(analyzer_dir, 0.33, 0.22);
     sim4.setScan(scan4);
     EXPECT_FAILED_ASSERT(sim4.setScan(scan4));
 
@@ -144,7 +145,8 @@ TEST_F(SpecularSimulationTest, SetQScan)
     QzScan scan3(10, 1.0, 10.0);
     const auto polarizer_dir = R3({0., 0., 0.876});
     const auto analyzer_dir = R3({0., 0., 1.});
-    sim3.instrument().setPolFilters(polarizer_dir, analyzer_dir, 0.33, 0.22);
+    sim3.beam().setPolarization(polarizer_dir);
+    sim3.detector().setAnalyzer(analyzer_dir, 0.33, 0.22);
     sim3.setScan(scan3);
 
     EXPECT_EQ(1.0, sim3.coordinateAxis()->min());
diff --git a/auto/Wrap/doxygenDevice.i b/auto/Wrap/doxygenDevice.i
index c9425f44a14..b9ee32b9b5d 100644
--- a/auto/Wrap/doxygenDevice.i
+++ b/auto/Wrap/doxygenDevice.i
@@ -1558,9 +1558,6 @@ Sets the detector (axes can be overwritten later)
 init detector with beam settings 
 ";
 
-%feature("docstring")  Instrument::setPolFilters "void Instrument::setPolFilters(const R3 &polarizer_dir, const R3 &analyzer_dir, double analyzer_efficiency, double analyzer_transmission)
-";
-
 %feature("docstring")  Instrument::nodeChildren "std::vector< const INode * > Instrument::nodeChildren() const override
 ";
 
diff --git a/auto/Wrap/libBornAgainDevice.py b/auto/Wrap/libBornAgainDevice.py
index cfd7aee188a..27bb73879d5 100644
--- a/auto/Wrap/libBornAgainDevice.py
+++ b/auto/Wrap/libBornAgainDevice.py
@@ -4320,14 +4320,6 @@ class Instrument(libBornAgainParam.INode):
         """
         return _libBornAgainDevice.Instrument_initDetector(self)
 
-    def setPolFilters(self, polarizer_dir, analyzer_dir, analyzer_efficiency, analyzer_transmission):
-        r"""
-        setPolFilters(Instrument self, R3 polarizer_dir, R3 analyzer_dir, double analyzer_efficiency, double analyzer_transmission)
-        void Instrument::setPolFilters(const R3 &polarizer_dir, const R3 &analyzer_dir, double analyzer_efficiency, double analyzer_transmission)
-
-        """
-        return _libBornAgainDevice.Instrument_setPolFilters(self, polarizer_dir, analyzer_dir, analyzer_efficiency, analyzer_transmission)
-
     def nodeChildren(self):
         r"""
         nodeChildren(Instrument self) -> std::vector< INode const *,std::allocator< INode const * > >
diff --git a/auto/Wrap/libBornAgainDevice_wrap.cpp b/auto/Wrap/libBornAgainDevice_wrap.cpp
index 1be164b3376..f7606935a7f 100644
--- a/auto/Wrap/libBornAgainDevice_wrap.cpp
+++ b/auto/Wrap/libBornAgainDevice_wrap.cpp
@@ -36211,65 +36211,6 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_Instrument_setPolFilters(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  Instrument *arg1 = (Instrument *) 0 ;
-  R3 *arg2 = 0 ;
-  R3 *arg3 = 0 ;
-  double arg4 ;
-  double arg5 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  void *argp2 = 0 ;
-  int res2 = 0 ;
-  void *argp3 = 0 ;
-  int res3 = 0 ;
-  double val4 ;
-  int ecode4 = 0 ;
-  double val5 ;
-  int ecode5 = 0 ;
-  PyObject *swig_obj[5] ;
-  
-  if (!SWIG_Python_UnpackTuple(args, "Instrument_setPolFilters", 5, 5, swig_obj)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_Instrument, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Instrument_setPolFilters" "', argument " "1"" of type '" "Instrument *""'"); 
-  }
-  arg1 = reinterpret_cast< Instrument * >(argp1);
-  res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_Vec3T_double_t,  0  | 0);
-  if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Instrument_setPolFilters" "', argument " "2"" of type '" "R3 const &""'"); 
-  }
-  if (!argp2) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Instrument_setPolFilters" "', argument " "2"" of type '" "R3 const &""'"); 
-  }
-  arg2 = reinterpret_cast< R3 * >(argp2);
-  res3 = SWIG_ConvertPtr(swig_obj[2], &argp3, SWIGTYPE_p_Vec3T_double_t,  0  | 0);
-  if (!SWIG_IsOK(res3)) {
-    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Instrument_setPolFilters" "', argument " "3"" of type '" "R3 const &""'"); 
-  }
-  if (!argp3) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Instrument_setPolFilters" "', argument " "3"" of type '" "R3 const &""'"); 
-  }
-  arg3 = reinterpret_cast< R3 * >(argp3);
-  ecode4 = SWIG_AsVal_double(swig_obj[3], &val4);
-  if (!SWIG_IsOK(ecode4)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "Instrument_setPolFilters" "', argument " "4"" of type '" "double""'");
-  } 
-  arg4 = static_cast< double >(val4);
-  ecode5 = SWIG_AsVal_double(swig_obj[4], &val5);
-  if (!SWIG_IsOK(ecode5)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "Instrument_setPolFilters" "', argument " "5"" of type '" "double""'");
-  } 
-  arg5 = static_cast< double >(val5);
-  (arg1)->setPolFilters((R3 const &)*arg2,(R3 const &)*arg3,arg4,arg5);
-  resultobj = SWIG_Py_Void();
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
 SWIGINTERN PyObject *_wrap_Instrument_nodeChildren(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   Instrument *arg1 = (Instrument *) 0 ;
@@ -43486,11 +43427,6 @@ static PyMethodDef SwigMethods[] = {
 		"init detector with beam settings \n"
 		"\n"
 		""},
-	 { "Instrument_setPolFilters", _wrap_Instrument_setPolFilters, METH_VARARGS, "\n"
-		"Instrument_setPolFilters(Instrument self, R3 polarizer_dir, R3 analyzer_dir, double analyzer_efficiency, double analyzer_transmission)\n"
-		"void Instrument::setPolFilters(const R3 &polarizer_dir, const R3 &analyzer_dir, double analyzer_efficiency, double analyzer_transmission)\n"
-		"\n"
-		""},
 	 { "Instrument_nodeChildren", _wrap_Instrument_nodeChildren, METH_O, "\n"
 		"Instrument_nodeChildren(Instrument self) -> std::vector< INode const *,std::allocator< INode const * > >\n"
 		"std::vector< const INode * > Instrument::nodeChildren() const override\n"
-- 
GitLab


From f583eb148e8bd1d9e514606c2070247cde7fc922 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 13:50:41 +0200
Subject: [PATCH 06/63] disambiguate setDetector

---
 GUI/Model/Device/InstrumentItems.cpp     | 4 +---
 GUI/View/FromDomain/FromDomain.cpp       | 2 +-
 GUI/View/FromDomain/FromDomain.h         | 2 +-
 GUI/View/FromDomain/GUIObjectBuilder.cpp | 4 ++--
 4 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/GUI/Model/Device/InstrumentItems.cpp b/GUI/Model/Device/InstrumentItems.cpp
index 884f8687bf1..1c4a9b20683 100644
--- a/GUI/Model/Device/InstrumentItems.cpp
+++ b/GUI/Model/Device/InstrumentItems.cpp
@@ -370,9 +370,7 @@ std::unique_ptr<Instrument> Instrument2DItem::createInstrument() const
     detector->setAnalyzer(
             m_analyzerDirection, m_analyzerEfficiency, m_analyzerTotalTransmission);
 
-    std::unique_ptr<Instrument> instrument(new Instrument);
-    instrument->setBeam(*beam);
-    instrument->setDetector(*detector);
+    std::unique_ptr<Instrument> instrument(new Instrument(*beam, *detector));
 
     return instrument;
 }
diff --git a/GUI/View/FromDomain/FromDomain.cpp b/GUI/View/FromDomain/FromDomain.cpp
index 061ec61fa5e..1c774142e4a 100644
--- a/GUI/View/FromDomain/FromDomain.cpp
+++ b/GUI/View/FromDomain/FromDomain.cpp
@@ -491,7 +491,7 @@ void GUI::Transform::FromDomain::setSpecularBeamItem(SpecularBeamItem* beam_item
     }
 }
 
-void GUI::Transform::FromDomain::setDetector(Instrument2DItem* instrument_item,
+void GUI::Transform::FromDomain::updateDetector(Instrument2DItem* instrument_item,
                                              const ISimulation2D& simulation)
 {
     const IDetector& detector = simulation.detector();
diff --git a/GUI/View/FromDomain/FromDomain.h b/GUI/View/FromDomain/FromDomain.h
index 85a30718be0..dc73a664a8d 100644
--- a/GUI/View/FromDomain/FromDomain.h
+++ b/GUI/View/FromDomain/FromDomain.h
@@ -95,7 +95,7 @@ void setOffSpecularBeamItem(BeamItem* beam_item, const OffSpecularSimulation& si
 
 void setSpecularBeamItem(SpecularBeamItem* beam_item, const SpecularSimulation& simulation);
 
-void setDetector(Instrument2DItem* instrument_item, const ISimulation2D& simulation);
+void updateDetector(Instrument2DItem* instrument_item, const ISimulation2D& simulation);
 
 void setDetectorGeometry(Instrument2DItem* instrument_item, const IDetector& detector);
 
diff --git a/GUI/View/FromDomain/GUIObjectBuilder.cpp b/GUI/View/FromDomain/GUIObjectBuilder.cpp
index 2f714a04a4a..be3fbe118c9 100644
--- a/GUI/View/FromDomain/GUIObjectBuilder.cpp
+++ b/GUI/View/FromDomain/GUIObjectBuilder.cpp
@@ -31,7 +31,7 @@ GISASInstrumentItem* createGISASInstrumentItem(InstrumentItems* model,
     auto* result = model->addInstrument<GISASInstrumentItem>();
     result->setInstrumentName(name);
     GUI::Transform::FromDomain::setGISASBeamItem(result->beamItem(), simulation);
-    GUI::Transform::FromDomain::setDetector(result, simulation);
+    GUI::Transform::FromDomain::updateDetector(result, simulation);
     GUI::Transform::FromDomain::setBackground(result, simulation);
 
     return result;
@@ -44,7 +44,7 @@ OffSpecularInstrumentItem* createOffSpecularInstrumentItem(InstrumentItems* mode
     auto* result = model->addInstrument<OffSpecularInstrumentItem>();
     result->setInstrumentName(name);
     GUI::Transform::FromDomain::setOffSpecularBeamItem(result->beamItem(), simulation);
-    GUI::Transform::FromDomain::setDetector(result, simulation);
+    GUI::Transform::FromDomain::updateDetector(result, simulation);
     GUI::Transform::FromDomain::setBackground(result, simulation);
 
     const double factor = 1. / Units::deg;
-- 
GitLab


From fdd9e0d0321a163a282cbaf8f232ac439cadf31a Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 14:01:22 +0200
Subject: [PATCH 07/63] rm Instrument::setBeam; simplify Instrument::operator=

---
 Device/Instrument/Instrument.cpp      | 17 ++----------
 Device/Instrument/Instrument.h        |  1 -
 GUI/Model/Device/InstrumentItems.cpp  |  7 +++--
 auto/Wrap/doxygenDevice.i             |  3 ---
 auto/Wrap/libBornAgainDevice.py       |  8 ------
 auto/Wrap/libBornAgainDevice_wrap.cpp | 37 ---------------------------
 6 files changed, 5 insertions(+), 68 deletions(-)

diff --git a/Device/Instrument/Instrument.cpp b/Device/Instrument/Instrument.cpp
index f56ae36694c..2d2c2133e56 100644
--- a/Device/Instrument/Instrument.cpp
+++ b/Device/Instrument/Instrument.cpp
@@ -44,14 +44,8 @@ Instrument::~Instrument() = default;
 Instrument& Instrument::operator=(const Instrument& other)
 {
     if (this != &other) {
-        if (other.m_beam)
-            setBeam(*other.m_beam);
-        else
-            m_beam.release();
-        if (other.m_detector)
-            setDetector(*other.m_detector);
-        else
-            m_detector.release();
+        Instrument tmp(other.beam(), other.detector());
+        std::swap(*this, tmp);
     }
     return *this;
 }
@@ -62,13 +56,6 @@ void Instrument::setDetector(const IDetector& detector)
     initDetector();
 }
 
-void Instrument::setBeam(const Beam& beam)
-{
-    m_beam.reset(beam.clone());
-    if (m_detector)
-        initDetector();
-}
-
 void Instrument::initDetector()
 {
     if (!m_detector)
diff --git a/Device/Instrument/Instrument.h b/Device/Instrument/Instrument.h
index f1ea452f1ac..8ea4aa01c69 100644
--- a/Device/Instrument/Instrument.h
+++ b/Device/Instrument/Instrument.h
@@ -38,7 +38,6 @@ public:
 
     Beam& beam() { return *m_beam; }
     const Beam& beam() const { return *m_beam; }
-    void setBeam(const Beam& beam);
 
     //! Sets the beam wavelength and incoming angles
     void setBeamParameters(double wavelength, double alpha_i, double phi_i);
diff --git a/GUI/Model/Device/InstrumentItems.cpp b/GUI/Model/Device/InstrumentItems.cpp
index 1c4a9b20683..78313490abc 100644
--- a/GUI/Model/Device/InstrumentItems.cpp
+++ b/GUI/Model/Device/InstrumentItems.cpp
@@ -220,19 +220,18 @@ bool SpecularInstrumentItem::alignedWith(const RealDataItem* item) const
 
 ICoordSystem* SpecularInstrumentItem::createCoordSystem() const
 {
-    std::unique_ptr<Instrument> instrument(new Instrument);
-    instrument->setBeam(*beamItem()->createBeam());
+    std::unique_ptr<Beam> beam = beamItem()->createBeam();
     // TODO set pol filters ?
     auto* axis_item = beamItem()->inclinationAxis();
     if (auto* pointwise_axis = dynamic_cast<PointwiseAxisItem*>(axis_item)) {
         if (!pointwise_axis->axis()) // workaround for loading project
             return nullptr;
         Coords native_units = GUI::Util::CoordName::coordFromName(pointwise_axis->getUnitsLabel());
-        return new AngularReflectometryCoordinates(instrument->beam().wavelength(),
+        return new AngularReflectometryCoordinates(beam->wavelength(),
                                                    *pointwise_axis->axis(), native_units);
     }
 
-    return new AngularReflectometryCoordinates(instrument->beam().wavelength(),
+    return new AngularReflectometryCoordinates(beam->wavelength(),
                                                *axis_item->createAxis(1.0), Coords::DEGREES);
 }
 
diff --git a/auto/Wrap/doxygenDevice.i b/auto/Wrap/doxygenDevice.i
index b9ee32b9b5d..8f9967e78e0 100644
--- a/auto/Wrap/doxygenDevice.i
+++ b/auto/Wrap/doxygenDevice.i
@@ -1528,9 +1528,6 @@ C++ includes: Instrument.h
 %feature("docstring")  Instrument::beam "const Beam& Instrument::beam() const
 ";
 
-%feature("docstring")  Instrument::setBeam "void Instrument::setBeam(const Beam &beam)
-";
-
 %feature("docstring")  Instrument::setBeamParameters "void Instrument::setBeamParameters(double wavelength, double alpha_i, double phi_i)
 
 Sets the beam wavelength and incoming angles. 
diff --git a/auto/Wrap/libBornAgainDevice.py b/auto/Wrap/libBornAgainDevice.py
index 27bb73879d5..f0a7e57fa3a 100644
--- a/auto/Wrap/libBornAgainDevice.py
+++ b/auto/Wrap/libBornAgainDevice.py
@@ -4264,14 +4264,6 @@ class Instrument(libBornAgainParam.INode):
         """
         return _libBornAgainDevice.Instrument_beam(self, *args)
 
-    def setBeam(self, beam):
-        r"""
-        setBeam(Instrument self, Beam beam)
-        void Instrument::setBeam(const Beam &beam)
-
-        """
-        return _libBornAgainDevice.Instrument_setBeam(self, beam)
-
     def setBeamParameters(self, wavelength, alpha_i, phi_i):
         r"""
         setBeamParameters(Instrument self, double wavelength, double alpha_i, double phi_i)
diff --git a/auto/Wrap/libBornAgainDevice_wrap.cpp b/auto/Wrap/libBornAgainDevice_wrap.cpp
index f7606935a7f..6dd67d9a555 100644
--- a/auto/Wrap/libBornAgainDevice_wrap.cpp
+++ b/auto/Wrap/libBornAgainDevice_wrap.cpp
@@ -35924,38 +35924,6 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_Instrument_setBeam(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  Instrument *arg1 = (Instrument *) 0 ;
-  Beam *arg2 = 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  void *argp2 = 0 ;
-  int res2 = 0 ;
-  PyObject *swig_obj[2] ;
-  
-  if (!SWIG_Python_UnpackTuple(args, "Instrument_setBeam", 2, 2, swig_obj)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_Instrument, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Instrument_setBeam" "', argument " "1"" of type '" "Instrument *""'"); 
-  }
-  arg1 = reinterpret_cast< Instrument * >(argp1);
-  res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_Beam,  0  | 0);
-  if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Instrument_setBeam" "', argument " "2"" of type '" "Beam const &""'"); 
-  }
-  if (!argp2) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Instrument_setBeam" "', argument " "2"" of type '" "Beam const &""'"); 
-  }
-  arg2 = reinterpret_cast< Beam * >(argp2);
-  (arg1)->setBeam((Beam const &)*arg2);
-  resultobj = SWIG_Py_Void();
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
 SWIGINTERN PyObject *_wrap_Instrument_setBeamParameters(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   Instrument *arg1 = (Instrument *) 0 ;
@@ -43389,11 +43357,6 @@ static PyMethodDef SwigMethods[] = {
 		"const Beam& Instrument::beam() const\n"
 		"\n"
 		""},
-	 { "Instrument_setBeam", _wrap_Instrument_setBeam, METH_VARARGS, "\n"
-		"Instrument_setBeam(Instrument self, Beam beam)\n"
-		"void Instrument::setBeam(const Beam &beam)\n"
-		"\n"
-		""},
 	 { "Instrument_setBeamParameters", _wrap_Instrument_setBeamParameters, METH_VARARGS, "\n"
 		"Instrument_setBeamParameters(Instrument self, double wavelength, double alpha_i, double phi_i)\n"
 		"void Instrument::setBeamParameters(double wavelength, double alpha_i, double phi_i)\n"
-- 
GitLab


From 4b931b11ea058138a390bdd1d439cfbdd9021a9d Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 14:17:37 +0200
Subject: [PATCH 08/63] disambiguate setBeamParameters|Params

---
 Device/Instrument/Instrument.cpp         |  2 +-
 Device/Instrument/Instrument.h           |  2 +-
 Sim/Simulation/DepthProbeSimulation.cpp  |  2 +-
 Sim/Simulation/OffSpecularSimulation.cpp |  2 +-
 Sim/Simulation/SpecularSimulation.cpp    |  2 +-
 auto/Wrap/doxygenDevice.i                |  2 +-
 auto/Wrap/libBornAgainDevice.py          |  8 ++++----
 auto/Wrap/libBornAgainDevice_wrap.cpp    | 20 ++++++++++----------
 8 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/Device/Instrument/Instrument.cpp b/Device/Instrument/Instrument.cpp
index 2d2c2133e56..7db9bf4ae10 100644
--- a/Device/Instrument/Instrument.cpp
+++ b/Device/Instrument/Instrument.cpp
@@ -73,7 +73,7 @@ std::vector<const INode*> Instrument::nodeChildren() const
     return result;
 }
 
-void Instrument::setBeamParameters(double wavelength, double alpha_i, double phi_i)
+void Instrument::setBeamParams(double wavelength, double alpha_i, double phi_i)
 {
     m_beam->setWavelength(wavelength);
     m_beam->setDirection({alpha_i, phi_i});
diff --git a/Device/Instrument/Instrument.h b/Device/Instrument/Instrument.h
index 8ea4aa01c69..2fa6f426ae6 100644
--- a/Device/Instrument/Instrument.h
+++ b/Device/Instrument/Instrument.h
@@ -40,7 +40,7 @@ public:
     const Beam& beam() const { return *m_beam; }
 
     //! Sets the beam wavelength and incoming angles
-    void setBeamParameters(double wavelength, double alpha_i, double phi_i);
+    void setBeamParams(double wavelength, double alpha_i, double phi_i);
 
     IDetector* getDetector();
     const IDetector* getDetector() const;
diff --git a/Sim/Simulation/DepthProbeSimulation.cpp b/Sim/Simulation/DepthProbeSimulation.cpp
index cceb8736377..cb09a325322 100644
--- a/Sim/Simulation/DepthProbeSimulation.cpp
+++ b/Sim/Simulation/DepthProbeSimulation.cpp
@@ -125,7 +125,7 @@ void DepthProbeSimulation::setBeamParameters(double lambda, const IAxis& alpha_a
     // beam is initialized with zero-valued angles
     // Zero-valued incident alpha is required for proper
     // taking into account beam resolution effects
-    instrument().setBeamParameters(lambda, zero_alpha_i, zero_phi_i);
+    instrument().setBeamParams(lambda, zero_alpha_i, zero_phi_i);
 
     if (beam_shape)
         beam().setFootprintFactor(*beam_shape);
diff --git a/Sim/Simulation/OffSpecularSimulation.cpp b/Sim/Simulation/OffSpecularSimulation.cpp
index 4b731655854..b618b43221f 100644
--- a/Sim/Simulation/OffSpecularSimulation.cpp
+++ b/Sim/Simulation/OffSpecularSimulation.cpp
@@ -70,7 +70,7 @@ void OffSpecularSimulation::setBeamParameters(double wavelength, const IAxis& al
         throw std::runtime_error("OffSpecularSimulation::prepareSimulation() "
                                  "-> Error. Incoming alpha range size < 1.");
     const double alpha_zero = alpha_axis.min();
-    instrument().setBeamParameters(wavelength, alpha_zero, phi_i);
+    instrument().setBeamParams(wavelength, alpha_zero, phi_i);
     updateIntensityMap();
 }
 
diff --git a/Sim/Simulation/SpecularSimulation.cpp b/Sim/Simulation/SpecularSimulation.cpp
index 7a231b0ac78..c9991a00f83 100644
--- a/Sim/Simulation/SpecularSimulation.cpp
+++ b/Sim/Simulation/SpecularSimulation.cpp
@@ -99,7 +99,7 @@ void SpecularSimulation::setScan(const ISpecularScan& scan)
 
     // TODO: remove when pointwise resolution is implemented
     if (const auto* aScan = dynamic_cast<const AlphaScan*>(&scan))
-        instrument().setBeamParameters(aScan->wavelength(), 0.0, 0.0);
+        instrument().setBeamParams(aScan->wavelength(), 0.0, 0.0);
 }
 
 const IAxis* SpecularSimulation::coordinateAxis() const
diff --git a/auto/Wrap/doxygenDevice.i b/auto/Wrap/doxygenDevice.i
index 8f9967e78e0..868197e3592 100644
--- a/auto/Wrap/doxygenDevice.i
+++ b/auto/Wrap/doxygenDevice.i
@@ -1528,7 +1528,7 @@ C++ includes: Instrument.h
 %feature("docstring")  Instrument::beam "const Beam& Instrument::beam() const
 ";
 
-%feature("docstring")  Instrument::setBeamParameters "void Instrument::setBeamParameters(double wavelength, double alpha_i, double phi_i)
+%feature("docstring")  Instrument::setBeamParams "void Instrument::setBeamParams(double wavelength, double alpha_i, double phi_i)
 
 Sets the beam wavelength and incoming angles. 
 ";
diff --git a/auto/Wrap/libBornAgainDevice.py b/auto/Wrap/libBornAgainDevice.py
index f0a7e57fa3a..b721061e08e 100644
--- a/auto/Wrap/libBornAgainDevice.py
+++ b/auto/Wrap/libBornAgainDevice.py
@@ -4264,15 +4264,15 @@ class Instrument(libBornAgainParam.INode):
         """
         return _libBornAgainDevice.Instrument_beam(self, *args)
 
-    def setBeamParameters(self, wavelength, alpha_i, phi_i):
+    def setBeamParams(self, wavelength, alpha_i, phi_i):
         r"""
-        setBeamParameters(Instrument self, double wavelength, double alpha_i, double phi_i)
-        void Instrument::setBeamParameters(double wavelength, double alpha_i, double phi_i)
+        setBeamParams(Instrument self, double wavelength, double alpha_i, double phi_i)
+        void Instrument::setBeamParams(double wavelength, double alpha_i, double phi_i)
 
         Sets the beam wavelength and incoming angles. 
 
         """
-        return _libBornAgainDevice.Instrument_setBeamParameters(self, wavelength, alpha_i, phi_i)
+        return _libBornAgainDevice.Instrument_setBeamParams(self, wavelength, alpha_i, phi_i)
 
     def getDetector(self, *args):
         r"""
diff --git a/auto/Wrap/libBornAgainDevice_wrap.cpp b/auto/Wrap/libBornAgainDevice_wrap.cpp
index 6dd67d9a555..c1fc89868be 100644
--- a/auto/Wrap/libBornAgainDevice_wrap.cpp
+++ b/auto/Wrap/libBornAgainDevice_wrap.cpp
@@ -35924,7 +35924,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_Instrument_setBeamParameters(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Instrument_setBeamParams(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   Instrument *arg1 = (Instrument *) 0 ;
   double arg2 ;
@@ -35940,28 +35940,28 @@ SWIGINTERN PyObject *_wrap_Instrument_setBeamParameters(PyObject *SWIGUNUSEDPARM
   int ecode4 = 0 ;
   PyObject *swig_obj[4] ;
   
-  if (!SWIG_Python_UnpackTuple(args, "Instrument_setBeamParameters", 4, 4, swig_obj)) SWIG_fail;
+  if (!SWIG_Python_UnpackTuple(args, "Instrument_setBeamParams", 4, 4, swig_obj)) SWIG_fail;
   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_Instrument, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Instrument_setBeamParameters" "', argument " "1"" of type '" "Instrument *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Instrument_setBeamParams" "', argument " "1"" of type '" "Instrument *""'"); 
   }
   arg1 = reinterpret_cast< Instrument * >(argp1);
   ecode2 = SWIG_AsVal_double(swig_obj[1], &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Instrument_setBeamParameters" "', argument " "2"" of type '" "double""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Instrument_setBeamParams" "', argument " "2"" of type '" "double""'");
   } 
   arg2 = static_cast< double >(val2);
   ecode3 = SWIG_AsVal_double(swig_obj[2], &val3);
   if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Instrument_setBeamParameters" "', argument " "3"" of type '" "double""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Instrument_setBeamParams" "', argument " "3"" of type '" "double""'");
   } 
   arg3 = static_cast< double >(val3);
   ecode4 = SWIG_AsVal_double(swig_obj[3], &val4);
   if (!SWIG_IsOK(ecode4)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "Instrument_setBeamParameters" "', argument " "4"" of type '" "double""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "Instrument_setBeamParams" "', argument " "4"" of type '" "double""'");
   } 
   arg4 = static_cast< double >(val4);
-  (arg1)->setBeamParameters(arg2,arg3,arg4);
+  (arg1)->setBeamParams(arg2,arg3,arg4);
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -43357,9 +43357,9 @@ static PyMethodDef SwigMethods[] = {
 		"const Beam& Instrument::beam() const\n"
 		"\n"
 		""},
-	 { "Instrument_setBeamParameters", _wrap_Instrument_setBeamParameters, METH_VARARGS, "\n"
-		"Instrument_setBeamParameters(Instrument self, double wavelength, double alpha_i, double phi_i)\n"
-		"void Instrument::setBeamParameters(double wavelength, double alpha_i, double phi_i)\n"
+	 { "Instrument_setBeamParams", _wrap_Instrument_setBeamParams, METH_VARARGS, "\n"
+		"Instrument_setBeamParams(Instrument self, double wavelength, double alpha_i, double phi_i)\n"
+		"void Instrument::setBeamParams(double wavelength, double alpha_i, double phi_i)\n"
 		"\n"
 		"Sets the beam wavelength and incoming angles. \n"
 		"\n"
-- 
GitLab


From 2fcec72eeec194646a3e740059d5f846a496d3e6 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 14:18:33 +0200
Subject: [PATCH 09/63] mv unit test

---
 Tests/Unit/{Sim => Device}/RectangularDetectorTest.cpp | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename Tests/Unit/{Sim => Device}/RectangularDetectorTest.cpp (100%)

diff --git a/Tests/Unit/Sim/RectangularDetectorTest.cpp b/Tests/Unit/Device/RectangularDetectorTest.cpp
similarity index 100%
rename from Tests/Unit/Sim/RectangularDetectorTest.cpp
rename to Tests/Unit/Device/RectangularDetectorTest.cpp
-- 
GitLab


From 3087c9da957e8290e4c755ffa1d4bcafaf35d332 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 15:36:12 +0200
Subject: [PATCH 10/63] move up getDetector

---
 Sim/Simulation/ISimulation.h            | 1 +
 Sim/Simulation/ScatteringSimulation.cpp | 5 ++---
 auto/Wrap/doxygenSim.i                  | 3 +++
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/Sim/Simulation/ISimulation.h b/Sim/Simulation/ISimulation.h
index 73a6b01c501..52509eded5f 100644
--- a/Sim/Simulation/ISimulation.h
+++ b/Sim/Simulation/ISimulation.h
@@ -78,6 +78,7 @@ public:
     const Instrument& instrument() const { return m_instrument; }
     const Beam& beam() const { return m_instrument.beam(); }
     const IDetector& detector() const { return m_instrument.detector(); }
+    const IDetector* getDetector() const { return m_instrument.getDetector(); }
     const IBackground* background() const { return m_background.get(); }
 
     const std::vector<ParameterDistribution>& getDistributions() const;
diff --git a/Sim/Simulation/ScatteringSimulation.cpp b/Sim/Simulation/ScatteringSimulation.cpp
index 1fca8e28891..b36774368e2 100644
--- a/Sim/Simulation/ScatteringSimulation.cpp
+++ b/Sim/Simulation/ScatteringSimulation.cpp
@@ -30,7 +30,6 @@ void ScatteringSimulation::prepareSimulation()
     if (detector().rank() != 2)
         throw std::runtime_error("ScatteringSimulation::prepareSimulation() "
                                  "-> Error. The detector was not properly configured.");
-    instrument().initDetector();
     ISimulation2D::prepareSimulation();
 }
 
@@ -52,9 +51,9 @@ size_t ScatteringSimulation::intensityMapSize() const
 #ifndef SWIG
 ICoordSystem* ScatteringSimulation::createCoordSystem() const
 {
-    const auto* det2D = dynamic_cast<const IDetector2D*>(instrument().getDetector());
+    auto* const det2D = dynamic_cast<const IDetector2D*>(getDetector());
     ASSERT(det2D);
-    return det2D->scatteringCoords(instrument().beam());
+    return det2D->scatteringCoords(beam());
 }
 #endif
 
diff --git a/auto/Wrap/doxygenSim.i b/auto/Wrap/doxygenSim.i
index 7dafc73e234..4ca5b3efd7d 100644
--- a/auto/Wrap/doxygenSim.i
+++ b/auto/Wrap/doxygenSim.i
@@ -931,6 +931,9 @@ Initializes a progress monitor that prints to stdout.
 %feature("docstring")  ISimulation::detector "const IDetector& ISimulation::detector() const
 ";
 
+%feature("docstring")  ISimulation::getDetector "const IDetector* ISimulation::getDetector() const
+";
+
 %feature("docstring")  ISimulation::background "const IBackground* ISimulation::background() const
 ";
 
-- 
GitLab


From 1df88de019ea3c78bc21ff7c04d40f1a37445e1f Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 15:44:34 +0200
Subject: [PATCH 11/63] rm TODO

---
 GUI/Model/Device/InstrumentItems.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/GUI/Model/Device/InstrumentItems.cpp b/GUI/Model/Device/InstrumentItems.cpp
index 78313490abc..1c5c5619f5c 100644
--- a/GUI/Model/Device/InstrumentItems.cpp
+++ b/GUI/Model/Device/InstrumentItems.cpp
@@ -221,7 +221,6 @@ bool SpecularInstrumentItem::alignedWith(const RealDataItem* item) const
 ICoordSystem* SpecularInstrumentItem::createCoordSystem() const
 {
     std::unique_ptr<Beam> beam = beamItem()->createBeam();
-    // TODO set pol filters ?
     auto* axis_item = beamItem()->inclinationAxis();
     if (auto* pointwise_axis = dynamic_cast<PointwiseAxisItem*>(axis_item)) {
         if (!pointwise_axis->axis()) // workaround for loading project
-- 
GitLab


From 253794d621779b93a9271f3a3286f788b12659d8 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 15:54:50 +0200
Subject: [PATCH 12/63] rm ASSERT

---
 Device/Instrument/Instrument.cpp | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/Device/Instrument/Instrument.cpp b/Device/Instrument/Instrument.cpp
index 7db9bf4ae10..759681111ca 100644
--- a/Device/Instrument/Instrument.cpp
+++ b/Device/Instrument/Instrument.cpp
@@ -58,9 +58,6 @@ void Instrument::setDetector(const IDetector& detector)
 
 void Instrument::initDetector()
 {
-    if (!m_detector)
-        throw std::runtime_error(
-            "Instrument::initDetector() -> Error. Detector is not initialized.");
     m_detector->setDetectorNormal(beam().direction().zReflected());
 }
 
@@ -93,12 +90,10 @@ IDetector* Instrument::getDetector()
 
 const IDetector& Instrument::detector() const
 {
-    ASSERT(m_detector);
     return *m_detector;
 }
 
 IDetector& Instrument::detector()
 {
-    ASSERT(m_detector);
     return *m_detector;
 }
-- 
GitLab


From b230e47f20af9cef2a39b4cad3c7db33af783b41 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 16:43:05 +0200
Subject: [PATCH 13/63] rm Instrument::initDetector

---
 Device/Instrument/Instrument.cpp      |   9 -
 Device/Instrument/Instrument.h        |   3 -
 GUI/Model/Device/InstrumentItems.cpp  |   2 -
 Sim/Simulation/ISimulation.cpp        |   1 +
 Sim/Simulation/ISimulation.h          |  11 +-
 Sim/Simulation/SpecularSimulation.cpp |   1 -
 auto/Wrap/doxygenDevice.i             |   5 -
 auto/Wrap/doxygenSim.i                |  18 +-
 auto/Wrap/libBornAgainDevice.py       |  10 -
 auto/Wrap/libBornAgainDevice_wrap.cpp |  29 ---
 auto/Wrap/libBornAgainSim.py          |  40 ++--
 auto/Wrap/libBornAgainSim_wrap.cpp    | 295 ++++++++++++--------------
 12 files changed, 164 insertions(+), 260 deletions(-)

diff --git a/Device/Instrument/Instrument.cpp b/Device/Instrument/Instrument.cpp
index 759681111ca..3b263c2bd81 100644
--- a/Device/Instrument/Instrument.cpp
+++ b/Device/Instrument/Instrument.cpp
@@ -26,7 +26,6 @@ Instrument::Instrument(const Beam& beam, const IDetector& detector)
     : m_beam(beam.clone())
     , m_detector(detector.clone())
 {
-    initDetector();
 }
 
 Instrument::Instrument()
@@ -53,12 +52,6 @@ Instrument& Instrument::operator=(const Instrument& other)
 void Instrument::setDetector(const IDetector& detector)
 {
     m_detector.reset(detector.clone());
-    initDetector();
-}
-
-void Instrument::initDetector()
-{
-    m_detector->setDetectorNormal(beam().direction().zReflected());
 }
 
 std::vector<const INode*> Instrument::nodeChildren() const
@@ -74,8 +67,6 @@ void Instrument::setBeamParams(double wavelength, double alpha_i, double phi_i)
 {
     m_beam->setWavelength(wavelength);
     m_beam->setDirection({alpha_i, phi_i});
-    if (m_detector)
-        initDetector();
 }
 
 const IDetector* Instrument::getDetector() const
diff --git a/Device/Instrument/Instrument.h b/Device/Instrument/Instrument.h
index 2fa6f426ae6..e19900f7ffd 100644
--- a/Device/Instrument/Instrument.h
+++ b/Device/Instrument/Instrument.h
@@ -50,9 +50,6 @@ public:
     //! Sets the detector (axes can be overwritten later)
     void setDetector(const IDetector& detector);
 
-    //! init detector with beam settings
-    void initDetector();
-
     std::vector<const INode*> nodeChildren() const override;
 
 protected:
diff --git a/GUI/Model/Device/InstrumentItems.cpp b/GUI/Model/Device/InstrumentItems.cpp
index 1c5c5619f5c..a235368001f 100644
--- a/GUI/Model/Device/InstrumentItems.cpp
+++ b/GUI/Model/Device/InstrumentItems.cpp
@@ -409,7 +409,6 @@ QString GISASInstrumentItem::instrumentType() const
 ICoordSystem* GISASInstrumentItem::createCoordSystem() const
 {
     const auto instrument = createInstrument();
-    instrument->initDetector();
     const auto* det2D = dynamic_cast<const IDetector2D*>(instrument->getDetector());
     ASSERT(det2D);
     return det2D->scatteringCoords(instrument->beam());
@@ -471,7 +470,6 @@ ICoordSystem* OffSpecularInstrumentItem::createCoordSystem() const
                                         m_alphaAxis.min() * Units::deg,
                                         m_alphaAxis.max() * Units::deg);
     const auto instrument = createInstrument();
-    instrument->initDetector();
     const auto* const detector2d = dynamic_cast<const IDetector2D*>(instrument->getDetector());
     ASSERT(detector2d);
     return detector2d->offspecCoords(alphaAxis, instrument->beam().direction());
diff --git a/Sim/Simulation/ISimulation.cpp b/Sim/Simulation/ISimulation.cpp
index 74c33b7534c..7cf253bd800 100644
--- a/Sim/Simulation/ISimulation.cpp
+++ b/Sim/Simulation/ISimulation.cpp
@@ -112,6 +112,7 @@ ISimulation::ISimulation(const Beam& beam, const MultiLayer& sample, const IDete
     , m_progress(std::make_unique<ProgressHandler>())
     , m_instrument(beam, detector)
 {
+    m_instrument.detector().setDetectorNormal(m_instrument.beam().direction().zReflected());
     setSample(sample);
     initialize();
 }
diff --git a/Sim/Simulation/ISimulation.h b/Sim/Simulation/ISimulation.h
index 52509eded5f..ba57a4166cf 100644
--- a/Sim/Simulation/ISimulation.h
+++ b/Sim/Simulation/ISimulation.h
@@ -51,10 +51,6 @@ public:
     //! Run a simulation, and return the result.
     SimulationResult simulate();
 
-    Instrument& instrument() { return m_instrument; }
-    Beam& beam() { return m_instrument.beam(); }
-    IDetector& detector() { return m_instrument.detector(); }
-
     void setSample(const MultiLayer& sample);
     void setBackground(const IBackground& bg);
 
@@ -69,16 +65,23 @@ public:
 
     void setTerminalProgressMonitor();
 
+    Beam& beam() { return m_instrument.beam(); }
+    IDetector& detector() { return m_instrument.detector(); }
+
 #ifndef SWIG
     void subscribe(const std::function<bool(size_t)>& inform);
 
     std::string unitOfParameter(ParameterDistribution::WhichParameter which) const;
 
     const MultiLayer* sample() const;
+
+    Instrument& instrument() { return m_instrument; }
     const Instrument& instrument() const { return m_instrument; }
+
     const Beam& beam() const { return m_instrument.beam(); }
     const IDetector& detector() const { return m_instrument.detector(); }
     const IDetector* getDetector() const { return m_instrument.getDetector(); }
+
     const IBackground* background() const { return m_background.get(); }
 
     const std::vector<ParameterDistribution>& getDistributions() const;
diff --git a/Sim/Simulation/SpecularSimulation.cpp b/Sim/Simulation/SpecularSimulation.cpp
index c9991a00f83..c0e3c202727 100644
--- a/Sim/Simulation/SpecularSimulation.cpp
+++ b/Sim/Simulation/SpecularSimulation.cpp
@@ -64,7 +64,6 @@ SpecularSimulation::SpecularSimulation(SpecularSimulation&&) = default;
 void SpecularSimulation::prepareSimulation()
 {
     ASSERT(detector().rank() == 1);
-    instrument().initDetector();
     ISimulation::prepareSimulation();
 }
 
diff --git a/auto/Wrap/doxygenDevice.i b/auto/Wrap/doxygenDevice.i
index 868197e3592..84b9c234a40 100644
--- a/auto/Wrap/doxygenDevice.i
+++ b/auto/Wrap/doxygenDevice.i
@@ -1550,11 +1550,6 @@ Sets the beam wavelength and incoming angles.
 Sets the detector (axes can be overwritten later) 
 ";
 
-%feature("docstring")  Instrument::initDetector "void Instrument::initDetector()
-
-init detector with beam settings 
-";
-
 %feature("docstring")  Instrument::nodeChildren "std::vector< const INode * > Instrument::nodeChildren() const override
 ";
 
diff --git a/auto/Wrap/doxygenSim.i b/auto/Wrap/doxygenSim.i
index 4ca5b3efd7d..cff7329cace 100644
--- a/auto/Wrap/doxygenSim.i
+++ b/auto/Wrap/doxygenSim.i
@@ -879,15 +879,6 @@ Run a simulation, and return the result.
 Runs simulation with possible averaging over parameter distributions; returns result. 
 ";
 
-%feature("docstring")  ISimulation::instrument "Instrument& ISimulation::instrument()
-";
-
-%feature("docstring")  ISimulation::beam "Beam& ISimulation::beam()
-";
-
-%feature("docstring")  ISimulation::detector "IDetector& ISimulation::detector()
-";
-
 %feature("docstring")  ISimulation::setSample "void ISimulation::setSample(const MultiLayer &sample)
 
 The MultiLayer object will not be owned by the  ISimulation object. 
@@ -913,6 +904,12 @@ The MultiLayer object will not be owned by the  ISimulation object.
 Initializes a progress monitor that prints to stdout. 
 ";
 
+%feature("docstring")  ISimulation::beam "Beam& ISimulation::beam()
+";
+
+%feature("docstring")  ISimulation::detector "IDetector& ISimulation::detector()
+";
+
 %feature("docstring")  ISimulation::subscribe "void ISimulation::subscribe(const std::function< bool(size_t)> &inform)
 ";
 
@@ -922,6 +919,9 @@ Initializes a progress monitor that prints to stdout.
 %feature("docstring")  ISimulation::sample "const MultiLayer * ISimulation::sample() const
 ";
 
+%feature("docstring")  ISimulation::instrument "Instrument& ISimulation::instrument()
+";
+
 %feature("docstring")  ISimulation::instrument "const Instrument& ISimulation::instrument() const
 ";
 
diff --git a/auto/Wrap/libBornAgainDevice.py b/auto/Wrap/libBornAgainDevice.py
index b721061e08e..0bc2cffdf65 100644
--- a/auto/Wrap/libBornAgainDevice.py
+++ b/auto/Wrap/libBornAgainDevice.py
@@ -4302,16 +4302,6 @@ class Instrument(libBornAgainParam.INode):
         """
         return _libBornAgainDevice.Instrument_setDetector(self, detector)
 
-    def initDetector(self):
-        r"""
-        initDetector(Instrument self)
-        void Instrument::initDetector()
-
-        init detector with beam settings 
-
-        """
-        return _libBornAgainDevice.Instrument_initDetector(self)
-
     def nodeChildren(self):
         r"""
         nodeChildren(Instrument self) -> std::vector< INode const *,std::allocator< INode const * > >
diff --git a/auto/Wrap/libBornAgainDevice_wrap.cpp b/auto/Wrap/libBornAgainDevice_wrap.cpp
index c1fc89868be..fa28c435250 100644
--- a/auto/Wrap/libBornAgainDevice_wrap.cpp
+++ b/auto/Wrap/libBornAgainDevice_wrap.cpp
@@ -36157,28 +36157,6 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_Instrument_initDetector(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  Instrument *arg1 = (Instrument *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject *swig_obj[1] ;
-  
-  if (!args) SWIG_fail;
-  swig_obj[0] = args;
-  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_Instrument, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Instrument_initDetector" "', argument " "1"" of type '" "Instrument *""'"); 
-  }
-  arg1 = reinterpret_cast< Instrument * >(argp1);
-  (arg1)->initDetector();
-  resultobj = SWIG_Py_Void();
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
 SWIGINTERN PyObject *_wrap_Instrument_nodeChildren(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   Instrument *arg1 = (Instrument *) 0 ;
@@ -43383,13 +43361,6 @@ static PyMethodDef SwigMethods[] = {
 		"Sets the detector (axes can be overwritten later) \n"
 		"\n"
 		""},
-	 { "Instrument_initDetector", _wrap_Instrument_initDetector, METH_O, "\n"
-		"Instrument_initDetector(Instrument self)\n"
-		"void Instrument::initDetector()\n"
-		"\n"
-		"init detector with beam settings \n"
-		"\n"
-		""},
 	 { "Instrument_nodeChildren", _wrap_Instrument_nodeChildren, METH_O, "\n"
 		"Instrument_nodeChildren(Instrument self) -> std::vector< INode const *,std::allocator< INode const * > >\n"
 		"std::vector< const INode * > Instrument::nodeChildren() const override\n"
diff --git a/auto/Wrap/libBornAgainSim.py b/auto/Wrap/libBornAgainSim.py
index c86e7193ba2..ae32d166b45 100644
--- a/auto/Wrap/libBornAgainSim.py
+++ b/auto/Wrap/libBornAgainSim.py
@@ -3360,30 +3360,6 @@ class ISimulation(libBornAgainParam.INode):
         """
         return _libBornAgainSim.ISimulation_simulate(self)
 
-    def instrument(self):
-        r"""
-        instrument(ISimulation self) -> Instrument &
-        const Instrument& ISimulation::instrument() const
-
-        """
-        return _libBornAgainSim.ISimulation_instrument(self)
-
-    def beam(self):
-        r"""
-        beam(ISimulation self) -> Beam &
-        const Beam& ISimulation::beam() const
-
-        """
-        return _libBornAgainSim.ISimulation_beam(self)
-
-    def detector(self):
-        r"""
-        detector(ISimulation self) -> IDetector &
-        const IDetector& ISimulation::detector() const
-
-        """
-        return _libBornAgainSim.ISimulation_detector(self)
-
     def setSample(self, sample):
         r"""
         setSample(ISimulation self, MultiLayer const & sample)
@@ -3430,6 +3406,22 @@ class ISimulation(libBornAgainParam.INode):
         """
         return _libBornAgainSim.ISimulation_setTerminalProgressMonitor(self)
 
+    def beam(self):
+        r"""
+        beam(ISimulation self) -> Beam &
+        const Beam& ISimulation::beam() const
+
+        """
+        return _libBornAgainSim.ISimulation_beam(self)
+
+    def detector(self):
+        r"""
+        detector(ISimulation self) -> IDetector &
+        const IDetector& ISimulation::detector() const
+
+        """
+        return _libBornAgainSim.ISimulation_detector(self)
+
 # Register ISimulation in _libBornAgainSim:
 _libBornAgainSim.ISimulation_swigregister(ISimulation)
 
diff --git a/auto/Wrap/libBornAgainSim_wrap.cpp b/auto/Wrap/libBornAgainSim_wrap.cpp
index 3de3037d67f..d915e53885f 100644
--- a/auto/Wrap/libBornAgainSim_wrap.cpp
+++ b/auto/Wrap/libBornAgainSim_wrap.cpp
@@ -3120,82 +3120,81 @@ namespace Swig {
 #define SWIGTYPE_p_ISimulation2D swig_types[20]
 #define SWIGTYPE_p_ISpecularScan swig_types[21]
 #define SWIGTYPE_p_IVarianceFunction swig_types[22]
-#define SWIGTYPE_p_Instrument swig_types[23]
-#define SWIGTYPE_p_IntensityFunctionLog swig_types[24]
-#define SWIGTYPE_p_IntensityFunctionSqrt swig_types[25]
-#define SWIGTYPE_p_IterationInfo swig_types[26]
-#define SWIGTYPE_p_MultiLayer swig_types[27]
-#define SWIGTYPE_p_OffSpecularSimulation swig_types[28]
-#define SWIGTYPE_p_ParameterDistribution swig_types[29]
-#define SWIGTYPE_p_PoissonBackground swig_types[30]
-#define SWIGTYPE_p_PyBuilderCallback swig_types[31]
-#define SWIGTYPE_p_PyObserverCallback swig_types[32]
-#define SWIGTYPE_p_QzScan swig_types[33]
-#define SWIGTYPE_p_RealLimits swig_types[34]
-#define SWIGTYPE_p_ScanResolution swig_types[35]
-#define SWIGTYPE_p_ScatteringSimulation swig_types[36]
-#define SWIGTYPE_p_SimulationOptions swig_types[37]
-#define SWIGTYPE_p_SimulationResult swig_types[38]
-#define SWIGTYPE_p_SpecularSimulation swig_types[39]
-#define SWIGTYPE_p_VarianceConstantFunction swig_types[40]
-#define SWIGTYPE_p_VarianceSimFunction swig_types[41]
-#define SWIGTYPE_p_Vec3T_double_t swig_types[42]
-#define SWIGTYPE_p_Vec3T_int_t swig_types[43]
-#define SWIGTYPE_p_Vec3T_std__complexT_double_t_t swig_types[44]
-#define SWIGTYPE_p_allocator_type swig_types[45]
-#define SWIGTYPE_p_char swig_types[46]
-#define SWIGTYPE_p_difference_type swig_types[47]
-#define SWIGTYPE_p_first_type swig_types[48]
-#define SWIGTYPE_p_int swig_types[49]
-#define SWIGTYPE_p_key_type swig_types[50]
-#define SWIGTYPE_p_long_long swig_types[51]
-#define SWIGTYPE_p_mapped_type swig_types[52]
-#define SWIGTYPE_p_mumufit__MinimizerResult swig_types[53]
-#define SWIGTYPE_p_mumufit__Parameters swig_types[54]
-#define SWIGTYPE_p_p_PyObject swig_types[55]
-#define SWIGTYPE_p_second_type swig_types[56]
-#define SWIGTYPE_p_short swig_types[57]
-#define SWIGTYPE_p_signed_char swig_types[58]
-#define SWIGTYPE_p_size_type swig_types[59]
-#define SWIGTYPE_p_std__allocatorT_AxisInfo_t swig_types[60]
-#define SWIGTYPE_p_std__allocatorT_INode_const_p_t swig_types[61]
-#define SWIGTYPE_p_std__allocatorT_INode_p_t swig_types[62]
-#define SWIGTYPE_p_std__allocatorT_Vec3T_double_t_t swig_types[63]
-#define SWIGTYPE_p_std__allocatorT_double_t swig_types[64]
-#define SWIGTYPE_p_std__allocatorT_int_t swig_types[65]
-#define SWIGTYPE_p_std__allocatorT_std__complexT_double_t_t swig_types[66]
-#define SWIGTYPE_p_std__allocatorT_std__pairT_double_double_t_t swig_types[67]
-#define SWIGTYPE_p_std__allocatorT_std__pairT_std__string_const_double_t_t swig_types[68]
-#define SWIGTYPE_p_std__allocatorT_std__string_t swig_types[69]
-#define SWIGTYPE_p_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t swig_types[70]
-#define SWIGTYPE_p_std__allocatorT_std__vectorT_int_std__allocatorT_int_t_t_t swig_types[71]
-#define SWIGTYPE_p_std__allocatorT_unsigned_long_t swig_types[72]
-#define SWIGTYPE_p_std__complexT_double_t swig_types[73]
-#define SWIGTYPE_p_std__invalid_argument swig_types[74]
-#define SWIGTYPE_p_std__lessT_std__string_t swig_types[75]
-#define SWIGTYPE_p_std__mapT_std__string_double_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_double_t_t_t swig_types[76]
-#define SWIGTYPE_p_std__pairT_double_double_t swig_types[77]
-#define SWIGTYPE_p_std__vectorT_AxisInfo_std__allocatorT_AxisInfo_t_t swig_types[78]
-#define SWIGTYPE_p_std__vectorT_INode_const_p_std__allocatorT_INode_const_p_t_t swig_types[79]
-#define SWIGTYPE_p_std__vectorT_INode_p_std__allocatorT_INode_p_t_t swig_types[80]
-#define SWIGTYPE_p_std__vectorT_ParaMeta_std__allocatorT_ParaMeta_t_t swig_types[81]
-#define SWIGTYPE_p_std__vectorT_Vec3T_double_t_std__allocatorT_Vec3T_double_t_t_t swig_types[82]
-#define SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t swig_types[83]
-#define SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t swig_types[84]
-#define SWIGTYPE_p_std__vectorT_std__complexT_double_t_std__allocatorT_std__complexT_double_t_t_t swig_types[85]
-#define SWIGTYPE_p_std__vectorT_std__pairT_double_double_t_std__allocatorT_std__pairT_double_double_t_t_t swig_types[86]
-#define SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t swig_types[87]
-#define SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t swig_types[88]
-#define SWIGTYPE_p_std__vectorT_std__vectorT_int_std__allocatorT_int_t_t_std__allocatorT_std__vectorT_int_std__allocatorT_int_t_t_t_t swig_types[89]
-#define SWIGTYPE_p_std__vectorT_unsigned_long_std__allocatorT_unsigned_long_t_t swig_types[90]
-#define SWIGTYPE_p_swig__SwigPyIterator swig_types[91]
-#define SWIGTYPE_p_unsigned_char swig_types[92]
-#define SWIGTYPE_p_unsigned_int swig_types[93]
-#define SWIGTYPE_p_unsigned_long_long swig_types[94]
-#define SWIGTYPE_p_unsigned_short swig_types[95]
-#define SWIGTYPE_p_value_type swig_types[96]
-static swig_type_info *swig_types[98];
-static swig_module_info swig_module = {swig_types, 97, 0, 0, 0, 0};
+#define SWIGTYPE_p_IntensityFunctionLog swig_types[23]
+#define SWIGTYPE_p_IntensityFunctionSqrt swig_types[24]
+#define SWIGTYPE_p_IterationInfo swig_types[25]
+#define SWIGTYPE_p_MultiLayer swig_types[26]
+#define SWIGTYPE_p_OffSpecularSimulation swig_types[27]
+#define SWIGTYPE_p_ParameterDistribution swig_types[28]
+#define SWIGTYPE_p_PoissonBackground swig_types[29]
+#define SWIGTYPE_p_PyBuilderCallback swig_types[30]
+#define SWIGTYPE_p_PyObserverCallback swig_types[31]
+#define SWIGTYPE_p_QzScan swig_types[32]
+#define SWIGTYPE_p_RealLimits swig_types[33]
+#define SWIGTYPE_p_ScanResolution swig_types[34]
+#define SWIGTYPE_p_ScatteringSimulation swig_types[35]
+#define SWIGTYPE_p_SimulationOptions swig_types[36]
+#define SWIGTYPE_p_SimulationResult swig_types[37]
+#define SWIGTYPE_p_SpecularSimulation swig_types[38]
+#define SWIGTYPE_p_VarianceConstantFunction swig_types[39]
+#define SWIGTYPE_p_VarianceSimFunction swig_types[40]
+#define SWIGTYPE_p_Vec3T_double_t swig_types[41]
+#define SWIGTYPE_p_Vec3T_int_t swig_types[42]
+#define SWIGTYPE_p_Vec3T_std__complexT_double_t_t swig_types[43]
+#define SWIGTYPE_p_allocator_type swig_types[44]
+#define SWIGTYPE_p_char swig_types[45]
+#define SWIGTYPE_p_difference_type swig_types[46]
+#define SWIGTYPE_p_first_type swig_types[47]
+#define SWIGTYPE_p_int swig_types[48]
+#define SWIGTYPE_p_key_type swig_types[49]
+#define SWIGTYPE_p_long_long swig_types[50]
+#define SWIGTYPE_p_mapped_type swig_types[51]
+#define SWIGTYPE_p_mumufit__MinimizerResult swig_types[52]
+#define SWIGTYPE_p_mumufit__Parameters swig_types[53]
+#define SWIGTYPE_p_p_PyObject swig_types[54]
+#define SWIGTYPE_p_second_type swig_types[55]
+#define SWIGTYPE_p_short swig_types[56]
+#define SWIGTYPE_p_signed_char swig_types[57]
+#define SWIGTYPE_p_size_type swig_types[58]
+#define SWIGTYPE_p_std__allocatorT_AxisInfo_t swig_types[59]
+#define SWIGTYPE_p_std__allocatorT_INode_const_p_t swig_types[60]
+#define SWIGTYPE_p_std__allocatorT_INode_p_t swig_types[61]
+#define SWIGTYPE_p_std__allocatorT_Vec3T_double_t_t swig_types[62]
+#define SWIGTYPE_p_std__allocatorT_double_t swig_types[63]
+#define SWIGTYPE_p_std__allocatorT_int_t swig_types[64]
+#define SWIGTYPE_p_std__allocatorT_std__complexT_double_t_t swig_types[65]
+#define SWIGTYPE_p_std__allocatorT_std__pairT_double_double_t_t swig_types[66]
+#define SWIGTYPE_p_std__allocatorT_std__pairT_std__string_const_double_t_t swig_types[67]
+#define SWIGTYPE_p_std__allocatorT_std__string_t swig_types[68]
+#define SWIGTYPE_p_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t swig_types[69]
+#define SWIGTYPE_p_std__allocatorT_std__vectorT_int_std__allocatorT_int_t_t_t swig_types[70]
+#define SWIGTYPE_p_std__allocatorT_unsigned_long_t swig_types[71]
+#define SWIGTYPE_p_std__complexT_double_t swig_types[72]
+#define SWIGTYPE_p_std__invalid_argument swig_types[73]
+#define SWIGTYPE_p_std__lessT_std__string_t swig_types[74]
+#define SWIGTYPE_p_std__mapT_std__string_double_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_double_t_t_t swig_types[75]
+#define SWIGTYPE_p_std__pairT_double_double_t swig_types[76]
+#define SWIGTYPE_p_std__vectorT_AxisInfo_std__allocatorT_AxisInfo_t_t swig_types[77]
+#define SWIGTYPE_p_std__vectorT_INode_const_p_std__allocatorT_INode_const_p_t_t swig_types[78]
+#define SWIGTYPE_p_std__vectorT_INode_p_std__allocatorT_INode_p_t_t swig_types[79]
+#define SWIGTYPE_p_std__vectorT_ParaMeta_std__allocatorT_ParaMeta_t_t swig_types[80]
+#define SWIGTYPE_p_std__vectorT_Vec3T_double_t_std__allocatorT_Vec3T_double_t_t_t swig_types[81]
+#define SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t swig_types[82]
+#define SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t swig_types[83]
+#define SWIGTYPE_p_std__vectorT_std__complexT_double_t_std__allocatorT_std__complexT_double_t_t_t swig_types[84]
+#define SWIGTYPE_p_std__vectorT_std__pairT_double_double_t_std__allocatorT_std__pairT_double_double_t_t_t swig_types[85]
+#define SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t swig_types[86]
+#define SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t swig_types[87]
+#define SWIGTYPE_p_std__vectorT_std__vectorT_int_std__allocatorT_int_t_t_std__allocatorT_std__vectorT_int_std__allocatorT_int_t_t_t_t swig_types[88]
+#define SWIGTYPE_p_std__vectorT_unsigned_long_std__allocatorT_unsigned_long_t_t swig_types[89]
+#define SWIGTYPE_p_swig__SwigPyIterator swig_types[90]
+#define SWIGTYPE_p_unsigned_char swig_types[91]
+#define SWIGTYPE_p_unsigned_int swig_types[92]
+#define SWIGTYPE_p_unsigned_long_long swig_types[93]
+#define SWIGTYPE_p_unsigned_short swig_types[94]
+#define SWIGTYPE_p_value_type swig_types[95]
+static swig_type_info *swig_types[97];
+static swig_module_info swig_module = {swig_types, 96, 0, 0, 0, 0};
 #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
 #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
 
@@ -37174,75 +37173,6 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_ISimulation_instrument(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  ISimulation *arg1 = (ISimulation *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject *swig_obj[1] ;
-  Instrument *result = 0 ;
-  
-  if (!args) SWIG_fail;
-  swig_obj[0] = args;
-  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ISimulation, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ISimulation_instrument" "', argument " "1"" of type '" "ISimulation *""'"); 
-  }
-  arg1 = reinterpret_cast< ISimulation * >(argp1);
-  result = (Instrument *) &(arg1)->instrument();
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Instrument, 0 |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_ISimulation_beam(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  ISimulation *arg1 = (ISimulation *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject *swig_obj[1] ;
-  Beam *result = 0 ;
-  
-  if (!args) SWIG_fail;
-  swig_obj[0] = args;
-  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ISimulation, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ISimulation_beam" "', argument " "1"" of type '" "ISimulation *""'"); 
-  }
-  arg1 = reinterpret_cast< ISimulation * >(argp1);
-  result = (Beam *) &(arg1)->beam();
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Beam, 0 |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_ISimulation_detector(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  ISimulation *arg1 = (ISimulation *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject *swig_obj[1] ;
-  IDetector *result = 0 ;
-  
-  if (!args) SWIG_fail;
-  swig_obj[0] = args;
-  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ISimulation, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ISimulation_detector" "', argument " "1"" of type '" "ISimulation *""'"); 
-  }
-  arg1 = reinterpret_cast< ISimulation * >(argp1);
-  result = (IDetector *) &(arg1)->detector();
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_IDetector, 0 |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
 SWIGINTERN PyObject *_wrap_ISimulation_setSample(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   ISimulation *arg1 = (ISimulation *) 0 ;
@@ -37730,6 +37660,52 @@ fail:
 }
 
 
+SWIGINTERN PyObject *_wrap_ISimulation_beam(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  ISimulation *arg1 = (ISimulation *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject *swig_obj[1] ;
+  Beam *result = 0 ;
+  
+  if (!args) SWIG_fail;
+  swig_obj[0] = args;
+  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ISimulation, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ISimulation_beam" "', argument " "1"" of type '" "ISimulation *""'"); 
+  }
+  arg1 = reinterpret_cast< ISimulation * >(argp1);
+  result = (Beam *) &(arg1)->beam();
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Beam, 0 |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ISimulation_detector(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  ISimulation *arg1 = (ISimulation *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject *swig_obj[1] ;
+  IDetector *result = 0 ;
+  
+  if (!args) SWIG_fail;
+  swig_obj[0] = args;
+  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ISimulation, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ISimulation_detector" "', argument " "1"" of type '" "ISimulation *""'"); 
+  }
+  arg1 = reinterpret_cast< ISimulation * >(argp1);
+  result = (IDetector *) &(arg1)->detector();
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_IDetector, 0 |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
 SWIGINTERN PyObject *ISimulation_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *obj;
   if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL;
@@ -41832,21 +41808,6 @@ static PyMethodDef SwigMethods[] = {
 		"Runs simulation with possible averaging over parameter distributions; returns result. \n"
 		"\n"
 		""},
-	 { "ISimulation_instrument", _wrap_ISimulation_instrument, METH_O, "\n"
-		"ISimulation_instrument(ISimulation self) -> Instrument &\n"
-		"const Instrument& ISimulation::instrument() const\n"
-		"\n"
-		""},
-	 { "ISimulation_beam", _wrap_ISimulation_beam, METH_O, "\n"
-		"ISimulation_beam(ISimulation self) -> Beam &\n"
-		"const Beam& ISimulation::beam() const\n"
-		"\n"
-		""},
-	 { "ISimulation_detector", _wrap_ISimulation_detector, METH_O, "\n"
-		"ISimulation_detector(ISimulation self) -> IDetector &\n"
-		"const IDetector& ISimulation::detector() const\n"
-		"\n"
-		""},
 	 { "ISimulation_setSample", _wrap_ISimulation_setSample, METH_VARARGS, "\n"
 		"ISimulation_setSample(ISimulation self, MultiLayer const & sample)\n"
 		"void ISimulation::setSample(const MultiLayer &sample)\n"
@@ -41878,6 +41839,16 @@ static PyMethodDef SwigMethods[] = {
 		"Initializes a progress monitor that prints to stdout. \n"
 		"\n"
 		""},
+	 { "ISimulation_beam", _wrap_ISimulation_beam, METH_O, "\n"
+		"ISimulation_beam(ISimulation self) -> Beam &\n"
+		"const Beam& ISimulation::beam() const\n"
+		"\n"
+		""},
+	 { "ISimulation_detector", _wrap_ISimulation_detector, METH_O, "\n"
+		"ISimulation_detector(ISimulation self) -> IDetector &\n"
+		"const IDetector& ISimulation::detector() const\n"
+		"\n"
+		""},
 	 { "ISimulation_swigregister", ISimulation_swigregister, METH_O, NULL},
 	 { "delete_ISimulation2D", _wrap_delete_ISimulation2D, METH_O, "\n"
 		"delete_ISimulation2D(ISimulation2D self)\n"
@@ -42520,7 +42491,6 @@ static swig_type_info _swigt__p_ISimulation = {"_p_ISimulation", "ISimulation *"
 static swig_type_info _swigt__p_ISimulation2D = {"_p_ISimulation2D", "ISimulation2D *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_ISpecularScan = {"_p_ISpecularScan", "ISpecularScan *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_IVarianceFunction = {"_p_IVarianceFunction", "IVarianceFunction *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_Instrument = {"_p_Instrument", "Instrument *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_IntensityFunctionLog = {"_p_IntensityFunctionLog", "IntensityFunctionLog *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_IntensityFunctionSqrt = {"_p_IntensityFunctionSqrt", "IntensityFunctionSqrt *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_IterationInfo = {"_p_IterationInfo", "IterationInfo *", 0, 0, (void*)0, 0};
@@ -42619,7 +42589,6 @@ static swig_type_info *swig_type_initial[] = {
   &_swigt__p_ISimulation2D,
   &_swigt__p_ISpecularScan,
   &_swigt__p_IVarianceFunction,
-  &_swigt__p_Instrument,
   &_swigt__p_IntensityFunctionLog,
   &_swigt__p_IntensityFunctionSqrt,
   &_swigt__p_IterationInfo,
@@ -42718,7 +42687,6 @@ static swig_cast_info _swigc__p_ISimulation[] = {  {&_swigt__p_ISimulation2D, _p
 static swig_cast_info _swigc__p_ISimulation2D[] = {  {&_swigt__p_ISimulation2D, 0, 0, 0},  {&_swigt__p_ScatteringSimulation, _p_ScatteringSimulationTo_p_ISimulation2D, 0, 0},  {&_swigt__p_OffSpecularSimulation, _p_OffSpecularSimulationTo_p_ISimulation2D, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_ISpecularScan[] = {  {&_swigt__p_QzScan, _p_QzScanTo_p_ISpecularScan, 0, 0},  {&_swigt__p_AlphaScan, _p_AlphaScanTo_p_ISpecularScan, 0, 0},  {&_swigt__p_ISpecularScan, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_IVarianceFunction[] = {  {&_swigt__p_IVarianceFunction, 0, 0, 0},  {&_swigt__p_VarianceConstantFunction, _p_VarianceConstantFunctionTo_p_IVarianceFunction, 0, 0},  {&_swigt__p_VarianceSimFunction, _p_VarianceSimFunctionTo_p_IVarianceFunction, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_Instrument[] = {  {&_swigt__p_Instrument, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_IntensityFunctionLog[] = {  {&_swigt__p_IntensityFunctionLog, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_IntensityFunctionSqrt[] = {  {&_swigt__p_IntensityFunctionSqrt, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_IterationInfo[] = {  {&_swigt__p_IterationInfo, 0, 0, 0},{0, 0, 0, 0}};
@@ -42817,7 +42785,6 @@ static swig_cast_info *swig_cast_initial[] = {
   _swigc__p_ISimulation2D,
   _swigc__p_ISpecularScan,
   _swigc__p_IVarianceFunction,
-  _swigc__p_Instrument,
   _swigc__p_IntensityFunctionLog,
   _swigc__p_IntensityFunctionSqrt,
   _swigc__p_IterationInfo,
-- 
GitLab


From 19b63b72a2cf947bc6f5796397987f77e24188a4 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 16:47:28 +0200
Subject: [PATCH 14/63] replace setBeamParameters

---
 Sim/Simulation/SpecularSimulation.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Sim/Simulation/SpecularSimulation.cpp b/Sim/Simulation/SpecularSimulation.cpp
index c0e3c202727..e5ed80dd586 100644
--- a/Sim/Simulation/SpecularSimulation.cpp
+++ b/Sim/Simulation/SpecularSimulation.cpp
@@ -98,7 +98,7 @@ void SpecularSimulation::setScan(const ISpecularScan& scan)
 
     // TODO: remove when pointwise resolution is implemented
     if (const auto* aScan = dynamic_cast<const AlphaScan*>(&scan))
-        instrument().setBeamParams(aScan->wavelength(), 0.0, 0.0);
+        beam().setWavelength(aScan->wavelength());
 }
 
 const IAxis* SpecularSimulation::coordinateAxis() const
-- 
GitLab


From 0a1da78338a8c57b55c6fe13519a0d9761a3f1d2 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 16:56:24 +0200
Subject: [PATCH 15/63] get rid of setBeamParams

---
 Device/Instrument/Instrument.cpp         | 6 ------
 Device/Instrument/Instrument.h           | 3 ---
 Sim/Simulation/DepthProbeSimulation.cpp  | 3 ++-
 Sim/Simulation/OffSpecularSimulation.cpp | 3 ++-
 4 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/Device/Instrument/Instrument.cpp b/Device/Instrument/Instrument.cpp
index 3b263c2bd81..cbadec1c6a0 100644
--- a/Device/Instrument/Instrument.cpp
+++ b/Device/Instrument/Instrument.cpp
@@ -63,12 +63,6 @@ std::vector<const INode*> Instrument::nodeChildren() const
     return result;
 }
 
-void Instrument::setBeamParams(double wavelength, double alpha_i, double phi_i)
-{
-    m_beam->setWavelength(wavelength);
-    m_beam->setDirection({alpha_i, phi_i});
-}
-
 const IDetector* Instrument::getDetector() const
 {
     return m_detector.get();
diff --git a/Device/Instrument/Instrument.h b/Device/Instrument/Instrument.h
index e19900f7ffd..b8717b4a821 100644
--- a/Device/Instrument/Instrument.h
+++ b/Device/Instrument/Instrument.h
@@ -39,9 +39,6 @@ public:
     Beam& beam() { return *m_beam; }
     const Beam& beam() const { return *m_beam; }
 
-    //! Sets the beam wavelength and incoming angles
-    void setBeamParams(double wavelength, double alpha_i, double phi_i);
-
     IDetector* getDetector();
     const IDetector* getDetector() const;
     IDetector& detector();
diff --git a/Sim/Simulation/DepthProbeSimulation.cpp b/Sim/Simulation/DepthProbeSimulation.cpp
index cb09a325322..f75b78aec86 100644
--- a/Sim/Simulation/DepthProbeSimulation.cpp
+++ b/Sim/Simulation/DepthProbeSimulation.cpp
@@ -125,7 +125,8 @@ void DepthProbeSimulation::setBeamParameters(double lambda, const IAxis& alpha_a
     // beam is initialized with zero-valued angles
     // Zero-valued incident alpha is required for proper
     // taking into account beam resolution effects
-    instrument().setBeamParams(lambda, zero_alpha_i, zero_phi_i);
+    beam().setWavelength(lambda);
+    beam().setDirection({zero_alpha_i, zero_phi_i});
 
     if (beam_shape)
         beam().setFootprintFactor(*beam_shape);
diff --git a/Sim/Simulation/OffSpecularSimulation.cpp b/Sim/Simulation/OffSpecularSimulation.cpp
index b618b43221f..f7312166ce9 100644
--- a/Sim/Simulation/OffSpecularSimulation.cpp
+++ b/Sim/Simulation/OffSpecularSimulation.cpp
@@ -70,7 +70,8 @@ void OffSpecularSimulation::setBeamParameters(double wavelength, const IAxis& al
         throw std::runtime_error("OffSpecularSimulation::prepareSimulation() "
                                  "-> Error. Incoming alpha range size < 1.");
     const double alpha_zero = alpha_axis.min();
-    instrument().setBeamParams(wavelength, alpha_zero, phi_i);
+    beam().setWavelength(wavelength);
+    beam().setDirection({alpha_zero, phi_i});
     updateIntensityMap();
 }
 
-- 
GitLab


From 168c669c56e8b9b29671d8b86158c0db12a7ffd8 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 17:09:01 +0200
Subject: [PATCH 16/63] regenerate; rm GUI fct

---
 .../Instrument/InstrumentEditController.cpp   |  5 --
 .../Instrument/InstrumentEditController.h     |  3 --
 auto/Wrap/doxygenDevice.i                     |  5 --
 auto/Wrap/libBornAgainDevice.py               | 10 ----
 auto/Wrap/libBornAgainDevice_wrap.cpp         | 52 -------------------
 5 files changed, 75 deletions(-)

diff --git a/GUI/View/Instrument/InstrumentEditController.cpp b/GUI/View/Instrument/InstrumentEditController.cpp
index 4905156cf46..27f962fd211 100644
--- a/GUI/View/Instrument/InstrumentEditController.cpp
+++ b/GUI/View/Instrument/InstrumentEditController.cpp
@@ -25,11 +25,6 @@ InstrumentEditController::InstrumentEditController(InstrumentsEditController* ec
 {
 }
 
-InstrumentItem* InstrumentEditController::instrument()
-{
-    return m_instrumentItem;
-}
-
 void InstrumentEditController::setInstrumentName(const QString& name)
 {
     m_ec->setInstrumentName(m_instrumentItem, name);
diff --git a/GUI/View/Instrument/InstrumentEditController.h b/GUI/View/Instrument/InstrumentEditController.h
index 34201d6a18b..06a1ae7a472 100644
--- a/GUI/View/Instrument/InstrumentEditController.h
+++ b/GUI/View/Instrument/InstrumentEditController.h
@@ -36,9 +36,6 @@ class InstrumentEditController : public QObject {
 public:
     InstrumentEditController(InstrumentsEditController* ec, InstrumentItem* instrument);
 
-    //! The handled instrument
-    InstrumentItem* instrument();
-
     //! Set the instrument name and emit the respective signal.
     //!
     //! The signal is emitted by the parent InstrumentsEditController.
diff --git a/auto/Wrap/doxygenDevice.i b/auto/Wrap/doxygenDevice.i
index 84b9c234a40..5a1f2119b51 100644
--- a/auto/Wrap/doxygenDevice.i
+++ b/auto/Wrap/doxygenDevice.i
@@ -1528,11 +1528,6 @@ C++ includes: Instrument.h
 %feature("docstring")  Instrument::beam "const Beam& Instrument::beam() const
 ";
 
-%feature("docstring")  Instrument::setBeamParams "void Instrument::setBeamParams(double wavelength, double alpha_i, double phi_i)
-
-Sets the beam wavelength and incoming angles. 
-";
-
 %feature("docstring")  Instrument::getDetector "IDetector * Instrument::getDetector()
 ";
 
diff --git a/auto/Wrap/libBornAgainDevice.py b/auto/Wrap/libBornAgainDevice.py
index 0bc2cffdf65..689ce8e1bb8 100644
--- a/auto/Wrap/libBornAgainDevice.py
+++ b/auto/Wrap/libBornAgainDevice.py
@@ -4264,16 +4264,6 @@ class Instrument(libBornAgainParam.INode):
         """
         return _libBornAgainDevice.Instrument_beam(self, *args)
 
-    def setBeamParams(self, wavelength, alpha_i, phi_i):
-        r"""
-        setBeamParams(Instrument self, double wavelength, double alpha_i, double phi_i)
-        void Instrument::setBeamParams(double wavelength, double alpha_i, double phi_i)
-
-        Sets the beam wavelength and incoming angles. 
-
-        """
-        return _libBornAgainDevice.Instrument_setBeamParams(self, wavelength, alpha_i, phi_i)
-
     def getDetector(self, *args):
         r"""
         getDetector(Instrument self) -> IDetector
diff --git a/auto/Wrap/libBornAgainDevice_wrap.cpp b/auto/Wrap/libBornAgainDevice_wrap.cpp
index fa28c435250..2bfcc0ccbe6 100644
--- a/auto/Wrap/libBornAgainDevice_wrap.cpp
+++ b/auto/Wrap/libBornAgainDevice_wrap.cpp
@@ -35924,51 +35924,6 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_Instrument_setBeamParams(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  Instrument *arg1 = (Instrument *) 0 ;
-  double arg2 ;
-  double arg3 ;
-  double arg4 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  double val2 ;
-  int ecode2 = 0 ;
-  double val3 ;
-  int ecode3 = 0 ;
-  double val4 ;
-  int ecode4 = 0 ;
-  PyObject *swig_obj[4] ;
-  
-  if (!SWIG_Python_UnpackTuple(args, "Instrument_setBeamParams", 4, 4, swig_obj)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_Instrument, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Instrument_setBeamParams" "', argument " "1"" of type '" "Instrument *""'"); 
-  }
-  arg1 = reinterpret_cast< Instrument * >(argp1);
-  ecode2 = SWIG_AsVal_double(swig_obj[1], &val2);
-  if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Instrument_setBeamParams" "', argument " "2"" of type '" "double""'");
-  } 
-  arg2 = static_cast< double >(val2);
-  ecode3 = SWIG_AsVal_double(swig_obj[2], &val3);
-  if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Instrument_setBeamParams" "', argument " "3"" of type '" "double""'");
-  } 
-  arg3 = static_cast< double >(val3);
-  ecode4 = SWIG_AsVal_double(swig_obj[3], &val4);
-  if (!SWIG_IsOK(ecode4)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "Instrument_setBeamParams" "', argument " "4"" of type '" "double""'");
-  } 
-  arg4 = static_cast< double >(val4);
-  (arg1)->setBeamParams(arg2,arg3,arg4);
-  resultobj = SWIG_Py_Void();
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
 SWIGINTERN PyObject *_wrap_Instrument_getDetector__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) {
   PyObject *resultobj = 0;
   Instrument *arg1 = (Instrument *) 0 ;
@@ -43335,13 +43290,6 @@ static PyMethodDef SwigMethods[] = {
 		"const Beam& Instrument::beam() const\n"
 		"\n"
 		""},
-	 { "Instrument_setBeamParams", _wrap_Instrument_setBeamParams, METH_VARARGS, "\n"
-		"Instrument_setBeamParams(Instrument self, double wavelength, double alpha_i, double phi_i)\n"
-		"void Instrument::setBeamParams(double wavelength, double alpha_i, double phi_i)\n"
-		"\n"
-		"Sets the beam wavelength and incoming angles. \n"
-		"\n"
-		""},
 	 { "Instrument_getDetector", _wrap_Instrument_getDetector, METH_VARARGS, "\n"
 		"Instrument_getDetector(Instrument self) -> IDetector\n"
 		"Instrument_getDetector(Instrument self) -> IDetector\n"
-- 
GitLab


From f525de23c317a38fdb746ec3d7cb815b6d74c574 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 17:13:44 +0200
Subject: [PATCH 17/63] setting name to 'Instrument' is pointless

---
 GUI/View/FromDomain/GUIObjectBuilder.cpp | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/GUI/View/FromDomain/GUIObjectBuilder.cpp b/GUI/View/FromDomain/GUIObjectBuilder.cpp
index be3fbe118c9..7dc8faee771 100644
--- a/GUI/View/FromDomain/GUIObjectBuilder.cpp
+++ b/GUI/View/FromDomain/GUIObjectBuilder.cpp
@@ -79,17 +79,13 @@ void GUI::Transform::FromDomain::populateInstrumentItems(InstrumentItems* instru
 {
     ASSERT(instrumentItems);
 
-    QString name = instrument_name.isEmpty()
-                       ? QString::fromStdString(simulation.instrument().className())
-                       : instrument_name;
-
     if (const auto* gisasSimulation = dynamic_cast<const ScatteringSimulation*>(&simulation))
-        createGISASInstrumentItem(instrumentItems, *gisasSimulation, name);
+        createGISASInstrumentItem(instrumentItems, *gisasSimulation, instrument_name);
     else if (const auto* offSpecSimulation =
                  dynamic_cast<const OffSpecularSimulation*>(&simulation))
-        createOffSpecularInstrumentItem(instrumentItems, *offSpecSimulation, name);
+        createOffSpecularInstrumentItem(instrumentItems, *offSpecSimulation, instrument_name);
     else if (const auto* spec_simulation = dynamic_cast<const SpecularSimulation*>(&simulation))
-        createSpecularInstrumentItem(instrumentItems, *spec_simulation, name);
+        createSpecularInstrumentItem(instrumentItems, *spec_simulation, instrument_name);
     else
         ASSERT(0);
 }
-- 
GitLab


From 58547615e6d4c19170aadd1809d798c2fecc513e Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 17:38:09 +0200
Subject: [PATCH 18/63] m_beam, m_detector moved to ISimulation

---
 GUI/Model/Device/InstrumentItems.cpp     |  1 +
 GUI/Model/To/DomainSimulationBuilder.cpp |  1 +
 Sim/Simulation/DepthProbeSimulation.cpp  |  3 +--
 Sim/Simulation/ISimulation.cpp           | 20 +++++++++++++-------
 Sim/Simulation/ISimulation.h             | 22 ++++++++++++----------
 Sim/Simulation/SpecularSimulation.cpp    |  4 ++--
 auto/Wrap/doxygenSim.i                   |  6 ------
 7 files changed, 30 insertions(+), 27 deletions(-)

diff --git a/GUI/Model/Device/InstrumentItems.cpp b/GUI/Model/Device/InstrumentItems.cpp
index a235368001f..cd77db10c37 100644
--- a/GUI/Model/Device/InstrumentItems.cpp
+++ b/GUI/Model/Device/InstrumentItems.cpp
@@ -20,6 +20,7 @@
 #include "Device/Coord/CoordSystem2D.h"
 #include "Device/Detector/RectangularDetector.h"
 #include "Device/Detector/SphericalDetector.h"
+#include "Device/Instrument/Instrument.h"
 #include "GUI/Model/CatDevice/BackgroundItemCatalog.h"
 #include "GUI/Model/CatDevice/DetectorItemCatalog.h"
 #include "GUI/Model/CatDevice/InstrumentItemCatalog.h"
diff --git a/GUI/Model/To/DomainSimulationBuilder.cpp b/GUI/Model/To/DomainSimulationBuilder.cpp
index 36551e0031a..18f8979a3cd 100644
--- a/GUI/Model/To/DomainSimulationBuilder.cpp
+++ b/GUI/Model/To/DomainSimulationBuilder.cpp
@@ -17,6 +17,7 @@
 #include "Base/Util/Assert.h"
 #include "Device/Beam/Beam.h"
 #include "Device/Beam/IFootprintFactor.h"
+#include "Device/Instrument/Instrument.h"
 #include "GUI/Model/Device/AxesItems.h"
 #include "GUI/Model/Device/BackgroundItems.h"
 #include "GUI/Model/Device/BeamAngleItems.h"
diff --git a/Sim/Simulation/DepthProbeSimulation.cpp b/Sim/Simulation/DepthProbeSimulation.cpp
index f75b78aec86..114dc0e710d 100644
--- a/Sim/Simulation/DepthProbeSimulation.cpp
+++ b/Sim/Simulation/DepthProbeSimulation.cpp
@@ -118,8 +118,7 @@ void DepthProbeSimulation::setBeamParameters(double lambda, const IAxis& alpha_a
         throw std::runtime_error(
             "Error in DepthProbeSimulation::setBeamParameters: angle axis is empty");
 
-    SpecularDetector1D detector(alpha_axis);
-    instrument().setDetector(detector);
+    m_detector.reset(new SpecularDetector1D(alpha_axis));
     m_alpha_axis.reset(alpha_axis.clone());
 
     // beam is initialized with zero-valued angles
diff --git a/Sim/Simulation/ISimulation.cpp b/Sim/Simulation/ISimulation.cpp
index 7cf253bd800..b1b0e630c3a 100644
--- a/Sim/Simulation/ISimulation.cpp
+++ b/Sim/Simulation/ISimulation.cpp
@@ -19,6 +19,7 @@
 #include "Device/Beam/Beam.h"
 #include "Device/Detector/IDetector.h"
 #include "Device/Histo/SimulationResult.h"
+#include "Device/Detector/SphericalDetector.h"
 #include "Resample/Options/SimulationOptions.h"
 #include "Resample/Processed/ReSample.h"
 #include "Sample/Multilayer/MultiLayer.h"
@@ -108,17 +109,20 @@ void runComputations(const std::vector<std::unique_ptr<IComputation>>& computati
 //  ************************************************************************************************
 
 ISimulation::ISimulation(const Beam& beam, const MultiLayer& sample, const IDetector& detector)
-    : m_options(std::make_unique<SimulationOptions>())
+    : m_beam(beam.clone())
+    , m_detector(detector.clone())
+    , m_options(std::make_unique<SimulationOptions>())
     , m_progress(std::make_unique<ProgressHandler>())
-    , m_instrument(beam, detector)
 {
-    m_instrument.detector().setDetectorNormal(m_instrument.beam().direction().zReflected());
+    m_detector->setDetectorNormal(m_beam->direction().zReflected());
     setSample(sample);
     initialize();
 }
 
 ISimulation::ISimulation()
-    : m_options(std::make_unique<SimulationOptions>())
+    : m_beam(Beam::horizontalBeam().clone())
+    , m_detector(new SphericalDetector())
+    , m_options(std::make_unique<SimulationOptions>())
     , m_progress(std::make_unique<ProgressHandler>())
 {
     initialize();
@@ -249,11 +253,13 @@ void ISimulation::setBackground(const IBackground& bg)
 std::vector<const INode*> ISimulation::nodeChildren() const
 {
     std::vector<const INode*> result;
-    result << &instrument();
-    if (m_sample)
-        result << m_sample.get();
+    result.push_back(m_beam.get());
+    if (m_detector)
+        result.push_back(m_detector.get());
     if (m_background)
         result << m_background.get();
+    if (m_sample)
+        result << m_sample.get();
     return result;
 }
 
diff --git a/Sim/Simulation/ISimulation.h b/Sim/Simulation/ISimulation.h
index ba57a4166cf..87823cf2e7d 100644
--- a/Sim/Simulation/ISimulation.h
+++ b/Sim/Simulation/ISimulation.h
@@ -15,11 +15,14 @@
 #ifndef BORNAGAIN_SIM_SIMULATION_ISIMULATION_H
 #define BORNAGAIN_SIM_SIMULATION_ISIMULATION_H
 
-#include "Device/Instrument/Instrument.h"
+#include "Param/Node/INode.h"
 #include "Param/Distrib/DistributionHandler.h"
 
 template <class T>
 class Powerfield;
+
+class Beam;
+class IDetector;
 class IBackground;
 class IComputation;
 class ICoordSystem;
@@ -65,8 +68,8 @@ public:
 
     void setTerminalProgressMonitor();
 
-    Beam& beam() { return m_instrument.beam(); }
-    IDetector& detector() { return m_instrument.detector(); }
+    Beam& beam() { return *m_beam; }
+    IDetector& detector() { return *m_detector; }
 
 #ifndef SWIG
     void subscribe(const std::function<bool(size_t)>& inform);
@@ -75,12 +78,9 @@ public:
 
     const MultiLayer* sample() const;
 
-    Instrument& instrument() { return m_instrument; }
-    const Instrument& instrument() const { return m_instrument; }
-
-    const Beam& beam() const { return m_instrument.beam(); }
-    const IDetector& detector() const { return m_instrument.detector(); }
-    const IDetector* getDetector() const { return m_instrument.getDetector(); }
+    const Beam& beam() const { return *m_beam; }
+    const IDetector& detector() const { return *m_detector; }
+    const IDetector* getDetector() const { return m_detector.get(); }
 
     const IBackground* background() const { return m_background.get(); }
 
@@ -110,6 +110,9 @@ protected:
 
     ProgressHandler& progress();
 
+    std::unique_ptr<Beam> m_beam;
+    std::unique_ptr<IDetector> m_detector;
+
 private:
     void initialize();
 
@@ -141,7 +144,6 @@ private:
     std::shared_ptr<ProgressHandler> m_progress;
     std::shared_ptr<MultiLayer> m_sample;
     DistributionHandler m_distribution_handler;
-    Instrument m_instrument;
     std::shared_ptr<IBackground> m_background;
 #endif // SWIG
 };
diff --git a/Sim/Simulation/SpecularSimulation.cpp b/Sim/Simulation/SpecularSimulation.cpp
index e5ed80dd586..5fa3af3cec9 100644
--- a/Sim/Simulation/SpecularSimulation.cpp
+++ b/Sim/Simulation/SpecularSimulation.cpp
@@ -53,8 +53,8 @@ std::unique_ptr<AlphaScan> mangledScan(const AlphaScan& scan, const Beam& beam)
 
 SpecularSimulation::SpecularSimulation()
 {
-    SpecularDetector1D detector;
-    instrument().setDetector(detector);
+    m_detector.reset(new SpecularDetector1D);
+
 }
 
 SpecularSimulation::~SpecularSimulation() = default;
diff --git a/auto/Wrap/doxygenSim.i b/auto/Wrap/doxygenSim.i
index cff7329cace..5fdb58a7a84 100644
--- a/auto/Wrap/doxygenSim.i
+++ b/auto/Wrap/doxygenSim.i
@@ -919,12 +919,6 @@ Initializes a progress monitor that prints to stdout.
 %feature("docstring")  ISimulation::sample "const MultiLayer * ISimulation::sample() const
 ";
 
-%feature("docstring")  ISimulation::instrument "Instrument& ISimulation::instrument()
-";
-
-%feature("docstring")  ISimulation::instrument "const Instrument& ISimulation::instrument() const
-";
-
 %feature("docstring")  ISimulation::beam "const Beam& ISimulation::beam() const
 ";
 
-- 
GitLab


From 991fed8150e1dfc3b33f86e753e9d2d7f729abaa Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 17:48:04 +0200
Subject: [PATCH 19/63] mv source pair Instrument out of core

---
 .../Model/Device}/Instrument.cpp              |   4 +-
 .../Model/Device}/Instrument.h                |   8 +-
 GUI/Model/Device/InstrumentItems.cpp          |   2 +-
 GUI/Model/Model/JobFunctions.cpp              |   2 +-
 GUI/Model/To/DomainSimulationBuilder.cpp      |   2 +-
 Tests/Unit/Sim/SpecularScanTest.cpp           |   1 -
 Wrap/Swig/libBornAgainDevice.i                |   3 -
 auto/Wrap/libBornAgainDevice.py               |  80 ---
 auto/Wrap/libBornAgainDevice_wrap.cpp         | 679 +++---------------
 9 files changed, 90 insertions(+), 691 deletions(-)
 rename {Device/Instrument => GUI/Model/Device}/Instrument.cpp (95%)
 rename {Device/Instrument => GUI/Model/Device}/Instrument.h (89%)

diff --git a/Device/Instrument/Instrument.cpp b/GUI/Model/Device/Instrument.cpp
similarity index 95%
rename from Device/Instrument/Instrument.cpp
rename to GUI/Model/Device/Instrument.cpp
index cbadec1c6a0..57ebc412850 100644
--- a/Device/Instrument/Instrument.cpp
+++ b/GUI/Model/Device/Instrument.cpp
@@ -2,7 +2,7 @@
 //
 //  BornAgain: simulate and fit reflection and scattering
 //
-//! @file      Device/Instrument/Instrument.cpp
+//! @file      GUI/Model/Device/Instrument.cpp
 //! @brief     Implements class Instrument.
 //!
 //! @homepage  http://www.bornagainproject.org
@@ -12,7 +12,7 @@
 //
 //  ************************************************************************************************
 
-#include "Device/Instrument/Instrument.h"
+#include "GUI/Model/Device/Instrument.h"
 #include "Base/Element/PolMatrices.h"
 #include "Base/Pixel/RectangularPixel.h"
 #include "Device/Beam/Beam.h"
diff --git a/Device/Instrument/Instrument.h b/GUI/Model/Device/Instrument.h
similarity index 89%
rename from Device/Instrument/Instrument.h
rename to GUI/Model/Device/Instrument.h
index b8717b4a821..0be144cf9a6 100644
--- a/Device/Instrument/Instrument.h
+++ b/GUI/Model/Device/Instrument.h
@@ -2,7 +2,7 @@
 //
 //  BornAgain: simulate and fit reflection and scattering
 //
-//! @file      Device/Instrument/Instrument.h
+//! @file      GUI/Model/Device/Instrument.h
 //! @brief     Defines class Instrument.
 //!
 //! @homepage  http://www.bornagainproject.org
@@ -13,8 +13,8 @@
 //  ************************************************************************************************
 
 #ifndef USER_API
-#ifndef BORNAGAIN_DEVICE_INSTRUMENT_INSTRUMENT_H
-#define BORNAGAIN_DEVICE_INSTRUMENT_INSTRUMENT_H
+#ifndef BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENT_H
+#define BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENT_H
 
 #include "Param/Node/INode.h"
 #include <heinz/Vectors3D.h>
@@ -54,5 +54,5 @@ protected:
     std::unique_ptr<IDetector> m_detector;
 };
 
-#endif // BORNAGAIN_DEVICE_INSTRUMENT_INSTRUMENT_H
+#endif // BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENT_H
 #endif // USER_API
diff --git a/GUI/Model/Device/InstrumentItems.cpp b/GUI/Model/Device/InstrumentItems.cpp
index cd77db10c37..3e79bc0eba5 100644
--- a/GUI/Model/Device/InstrumentItems.cpp
+++ b/GUI/Model/Device/InstrumentItems.cpp
@@ -20,7 +20,7 @@
 #include "Device/Coord/CoordSystem2D.h"
 #include "Device/Detector/RectangularDetector.h"
 #include "Device/Detector/SphericalDetector.h"
-#include "Device/Instrument/Instrument.h"
+#include "GUI/Model/Device/Instrument.h"
 #include "GUI/Model/CatDevice/BackgroundItemCatalog.h"
 #include "GUI/Model/CatDevice/DetectorItemCatalog.h"
 #include "GUI/Model/CatDevice/InstrumentItemCatalog.h"
diff --git a/GUI/Model/Model/JobFunctions.cpp b/GUI/Model/Model/JobFunctions.cpp
index 6abf67b2133..bad5de3f67c 100644
--- a/GUI/Model/Model/JobFunctions.cpp
+++ b/GUI/Model/Model/JobFunctions.cpp
@@ -14,7 +14,7 @@
 
 #include "GUI/Model/Model/JobFunctions.h"
 #include "Base/Util/Assert.h"
-#include "Device/Instrument/Instrument.h"
+#include "GUI/Model/Device/Instrument.h"
 #include "GUI/Model/Data/Data1DViewItem.h"
 #include "GUI/Model/Data/DataPropertyContainer.h"
 #include "GUI/Model/Data/IntensityDataItem.h"
diff --git a/GUI/Model/To/DomainSimulationBuilder.cpp b/GUI/Model/To/DomainSimulationBuilder.cpp
index 18f8979a3cd..db786957dbf 100644
--- a/GUI/Model/To/DomainSimulationBuilder.cpp
+++ b/GUI/Model/To/DomainSimulationBuilder.cpp
@@ -17,7 +17,7 @@
 #include "Base/Util/Assert.h"
 #include "Device/Beam/Beam.h"
 #include "Device/Beam/IFootprintFactor.h"
-#include "Device/Instrument/Instrument.h"
+#include "GUI/Model/Device/Instrument.h"
 #include "GUI/Model/Device/AxesItems.h"
 #include "GUI/Model/Device/BackgroundItems.h"
 #include "GUI/Model/Device/BeamAngleItems.h"
diff --git a/Tests/Unit/Sim/SpecularScanTest.cpp b/Tests/Unit/Sim/SpecularScanTest.cpp
index 6c6d87fc70d..f54c489a47d 100644
--- a/Tests/Unit/Sim/SpecularScanTest.cpp
+++ b/Tests/Unit/Sim/SpecularScanTest.cpp
@@ -1,7 +1,6 @@
 #include "Base/Axis/FixedBinAxis.h"
 #include "Base/Axis/PointwiseAxis.h"
 #include "Device/Beam/FootprintGauss.h"
-#include "Device/Instrument/Instrument.h"
 #include "Param/Distrib/RangedDistributions.h"
 #include "Resample/Element/SpecularElement.h"
 #include "Resample/Slice/SliceStack.h"
diff --git a/Wrap/Swig/libBornAgainDevice.i b/Wrap/Swig/libBornAgainDevice.i
index 31f332cc43b..73721b2d447 100644
--- a/Wrap/Swig/libBornAgainDevice.i
+++ b/Wrap/Swig/libBornAgainDevice.i
@@ -34,7 +34,6 @@
 #include "Device/Histo/Histogram2D.h"
 #include "Device/Histo/IOFactory.h"
 #include "Device/Histo/SimulationResult.h"
-#include "Device/Instrument/Instrument.h"
 #include "Device/Mask/Ellipse.h"
 #include "Device/Mask/Line.h"
 #include "Device/Mask/Polygon.h"
@@ -88,8 +87,6 @@
 %include "Device/Detector/RectangularDetector.h"
 %include "Device/Detector/SphericalDetector.h"
 
-%include "Device/Instrument/Instrument.h"
-
 %include "Device/Histo/HistoUtils.h"
 %include "Device/Histo/IHistogram.h"
 %include "Device/Histo/Histogram1D.h"
diff --git a/auto/Wrap/libBornAgainDevice.py b/auto/Wrap/libBornAgainDevice.py
index 689ce8e1bb8..28465d4ea6d 100644
--- a/auto/Wrap/libBornAgainDevice.py
+++ b/auto/Wrap/libBornAgainDevice.py
@@ -4223,86 +4223,6 @@ class SphericalDetector(IDetector2D):
 # Register SphericalDetector in _libBornAgainDevice:
 _libBornAgainDevice.SphericalDetector_swigregister(SphericalDetector)
 
-class Instrument(libBornAgainParam.INode):
-    r"""
-
-
-    Assembles beam, detector and their relative positions with respect to the sample.
-
-    C++ includes: Instrument.h
-
-    """
-
-    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
-    __repr__ = _swig_repr
-
-    def __init__(self, *args):
-        r"""
-        __init__(Instrument self) -> Instrument
-        __init__(Instrument self, Beam beam, IDetector detector) -> Instrument
-        __init__(Instrument self, Instrument other) -> Instrument
-        Instrument::Instrument(const Instrument &other)
-
-        """
-        _libBornAgainDevice.Instrument_swiginit(self, _libBornAgainDevice.new_Instrument(*args))
-    __swig_destroy__ = _libBornAgainDevice.delete_Instrument
-
-    def className(self):
-        r"""
-        className(Instrument self) -> std::string
-        std::string Instrument::className() const final
-
-        """
-        return _libBornAgainDevice.Instrument_className(self)
-
-    def beam(self, *args):
-        r"""
-        beam(Instrument self) -> Beam
-        beam(Instrument self) -> Beam
-        const Beam& Instrument::beam() const
-
-        """
-        return _libBornAgainDevice.Instrument_beam(self, *args)
-
-    def getDetector(self, *args):
-        r"""
-        getDetector(Instrument self) -> IDetector
-        getDetector(Instrument self) -> IDetector
-        const IDetector * Instrument::getDetector() const
-
-        """
-        return _libBornAgainDevice.Instrument_getDetector(self, *args)
-
-    def detector(self, *args):
-        r"""
-        detector(Instrument self) -> IDetector
-        detector(Instrument self) -> IDetector
-        const IDetector & Instrument::detector() const
-
-        """
-        return _libBornAgainDevice.Instrument_detector(self, *args)
-
-    def setDetector(self, detector):
-        r"""
-        setDetector(Instrument self, IDetector detector)
-        void Instrument::setDetector(const IDetector &detector)
-
-        Sets the detector (axes can be overwritten later) 
-
-        """
-        return _libBornAgainDevice.Instrument_setDetector(self, detector)
-
-    def nodeChildren(self):
-        r"""
-        nodeChildren(Instrument self) -> std::vector< INode const *,std::allocator< INode const * > >
-        std::vector< const INode * > Instrument::nodeChildren() const override
-
-        """
-        return _libBornAgainDevice.Instrument_nodeChildren(self)
-
-# Register Instrument in _libBornAgainDevice:
-_libBornAgainDevice.Instrument_swigregister(Instrument)
-
 
 def FindPeaks(*args):
     r"""
diff --git a/auto/Wrap/libBornAgainDevice_wrap.cpp b/auto/Wrap/libBornAgainDevice_wrap.cpp
index 2bfcc0ccbe6..d8e94d7b0ff 100644
--- a/auto/Wrap/libBornAgainDevice_wrap.cpp
+++ b/auto/Wrap/libBornAgainDevice_wrap.cpp
@@ -3123,87 +3123,86 @@ namespace Swig {
 #define SWIGTYPE_p_IPixel swig_types[23]
 #define SWIGTYPE_p_IResolutionFunction2D swig_types[24]
 #define SWIGTYPE_p_IShape2D swig_types[25]
-#define SWIGTYPE_p_Instrument swig_types[26]
-#define SWIGTYPE_p_Line swig_types[27]
-#define SWIGTYPE_p_MaskPattern swig_types[28]
-#define SWIGTYPE_p_OwningVectorT_IAxis_t swig_types[29]
-#define SWIGTYPE_p_Polygon swig_types[30]
-#define SWIGTYPE_p_PolygonPrivate swig_types[31]
-#define SWIGTYPE_p_PowerfieldIteratorT_double_PowerfieldT_double_t_t swig_types[32]
-#define SWIGTYPE_p_PowerfieldIteratorT_double_const_PowerfieldT_double_t_const_t swig_types[33]
-#define SWIGTYPE_p_PowerfieldT_CumulativeValue_t swig_types[34]
-#define SWIGTYPE_p_PowerfieldT_bool_t swig_types[35]
-#define SWIGTYPE_p_PowerfieldT_double_t swig_types[36]
-#define SWIGTYPE_p_RealLimits swig_types[37]
-#define SWIGTYPE_p_Rectangle swig_types[38]
-#define SWIGTYPE_p_RectangularDetector swig_types[39]
-#define SWIGTYPE_p_RectangularPixel swig_types[40]
-#define SWIGTYPE_p_ResolutionFunction2DGaussian swig_types[41]
-#define SWIGTYPE_p_SimulationResult swig_types[42]
-#define SWIGTYPE_p_SphericalDetector swig_types[43]
-#define SWIGTYPE_p_SpinMatrix swig_types[44]
-#define SWIGTYPE_p_Vec3T_double_t swig_types[45]
-#define SWIGTYPE_p_Vec3T_int_t swig_types[46]
-#define SWIGTYPE_p_Vec3T_std__complexT_double_t_t swig_types[47]
-#define SWIGTYPE_p_VerticalLine swig_types[48]
-#define SWIGTYPE_p_allocator_type swig_types[49]
-#define SWIGTYPE_p_char swig_types[50]
-#define SWIGTYPE_p_const_iterator swig_types[51]
-#define SWIGTYPE_p_corr_matrix_t swig_types[52]
-#define SWIGTYPE_p_difference_type swig_types[53]
-#define SWIGTYPE_p_double swig_types[54]
-#define SWIGTYPE_p_first_type swig_types[55]
-#define SWIGTYPE_p_int swig_types[56]
-#define SWIGTYPE_p_iterator swig_types[57]
-#define SWIGTYPE_p_key_type swig_types[58]
-#define SWIGTYPE_p_long_long swig_types[59]
-#define SWIGTYPE_p_mapped_type swig_types[60]
-#define SWIGTYPE_p_p_ICoordSystem swig_types[61]
-#define SWIGTYPE_p_p_PyObject swig_types[62]
-#define SWIGTYPE_p_parameters_t swig_types[63]
-#define SWIGTYPE_p_second_type swig_types[64]
-#define SWIGTYPE_p_short swig_types[65]
-#define SWIGTYPE_p_signed_char swig_types[66]
-#define SWIGTYPE_p_size_type swig_types[67]
-#define SWIGTYPE_p_std__allocatorT_Vec3T_double_t_t swig_types[68]
-#define SWIGTYPE_p_std__allocatorT_double_t swig_types[69]
-#define SWIGTYPE_p_std__allocatorT_int_t swig_types[70]
-#define SWIGTYPE_p_std__allocatorT_std__complexT_double_t_t swig_types[71]
-#define SWIGTYPE_p_std__allocatorT_std__pairT_double_double_t_t swig_types[72]
-#define SWIGTYPE_p_std__allocatorT_std__pairT_std__string_const_double_t_t swig_types[73]
-#define SWIGTYPE_p_std__allocatorT_std__string_t swig_types[74]
-#define SWIGTYPE_p_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t swig_types[75]
-#define SWIGTYPE_p_std__allocatorT_std__vectorT_int_std__allocatorT_int_t_t_t swig_types[76]
-#define SWIGTYPE_p_std__allocatorT_unsigned_long_t swig_types[77]
-#define SWIGTYPE_p_std__complexT_double_t swig_types[78]
-#define SWIGTYPE_p_std__functionT_void_fSimulationAreaIterator_const_RF_t swig_types[79]
-#define SWIGTYPE_p_std__invalid_argument swig_types[80]
-#define SWIGTYPE_p_std__lessT_std__string_t swig_types[81]
-#define SWIGTYPE_p_std__mapT_std__string_double_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_double_t_t_t swig_types[82]
-#define SWIGTYPE_p_std__pairT_double_double_t swig_types[83]
-#define SWIGTYPE_p_std__vectorT_AxisInfo_std__allocatorT_AxisInfo_t_t swig_types[84]
-#define SWIGTYPE_p_std__vectorT_IAxis_p_std__allocatorT_IAxis_p_t_t swig_types[85]
-#define SWIGTYPE_p_std__vectorT_INode_const_p_std__allocatorT_INode_const_p_t_t swig_types[86]
-#define SWIGTYPE_p_std__vectorT_ParaMeta_std__allocatorT_ParaMeta_t_t swig_types[87]
-#define SWIGTYPE_p_std__vectorT_Vec3T_double_t_std__allocatorT_Vec3T_double_t_t_t swig_types[88]
-#define SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t swig_types[89]
-#define SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t swig_types[90]
-#define SWIGTYPE_p_std__vectorT_size_t_std__allocatorT_size_t_t_t swig_types[91]
-#define SWIGTYPE_p_std__vectorT_std__complexT_double_t_std__allocatorT_std__complexT_double_t_t_t swig_types[92]
-#define SWIGTYPE_p_std__vectorT_std__pairT_double_double_t_std__allocatorT_std__pairT_double_double_t_t_t swig_types[93]
-#define SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t swig_types[94]
-#define SWIGTYPE_p_std__vectorT_std__unique_ptrT_DiffuseElement_t_std__allocatorT_std__unique_ptrT_DiffuseElement_t_t_t swig_types[95]
-#define SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t swig_types[96]
-#define SWIGTYPE_p_std__vectorT_std__vectorT_int_std__allocatorT_int_t_t_std__allocatorT_std__vectorT_int_std__allocatorT_int_t_t_t_t swig_types[97]
-#define SWIGTYPE_p_std__vectorT_unsigned_long_std__allocatorT_unsigned_long_t_t swig_types[98]
-#define SWIGTYPE_p_swig__SwigPyIterator swig_types[99]
-#define SWIGTYPE_p_unsigned_char swig_types[100]
-#define SWIGTYPE_p_unsigned_int swig_types[101]
-#define SWIGTYPE_p_unsigned_long_long swig_types[102]
-#define SWIGTYPE_p_unsigned_short swig_types[103]
-#define SWIGTYPE_p_value_type swig_types[104]
-static swig_type_info *swig_types[106];
-static swig_module_info swig_module = {swig_types, 105, 0, 0, 0, 0};
+#define SWIGTYPE_p_Line swig_types[26]
+#define SWIGTYPE_p_MaskPattern swig_types[27]
+#define SWIGTYPE_p_OwningVectorT_IAxis_t swig_types[28]
+#define SWIGTYPE_p_Polygon swig_types[29]
+#define SWIGTYPE_p_PolygonPrivate swig_types[30]
+#define SWIGTYPE_p_PowerfieldIteratorT_double_PowerfieldT_double_t_t swig_types[31]
+#define SWIGTYPE_p_PowerfieldIteratorT_double_const_PowerfieldT_double_t_const_t swig_types[32]
+#define SWIGTYPE_p_PowerfieldT_CumulativeValue_t swig_types[33]
+#define SWIGTYPE_p_PowerfieldT_bool_t swig_types[34]
+#define SWIGTYPE_p_PowerfieldT_double_t swig_types[35]
+#define SWIGTYPE_p_RealLimits swig_types[36]
+#define SWIGTYPE_p_Rectangle swig_types[37]
+#define SWIGTYPE_p_RectangularDetector swig_types[38]
+#define SWIGTYPE_p_RectangularPixel swig_types[39]
+#define SWIGTYPE_p_ResolutionFunction2DGaussian swig_types[40]
+#define SWIGTYPE_p_SimulationResult swig_types[41]
+#define SWIGTYPE_p_SphericalDetector swig_types[42]
+#define SWIGTYPE_p_SpinMatrix swig_types[43]
+#define SWIGTYPE_p_Vec3T_double_t swig_types[44]
+#define SWIGTYPE_p_Vec3T_int_t swig_types[45]
+#define SWIGTYPE_p_Vec3T_std__complexT_double_t_t swig_types[46]
+#define SWIGTYPE_p_VerticalLine swig_types[47]
+#define SWIGTYPE_p_allocator_type swig_types[48]
+#define SWIGTYPE_p_char swig_types[49]
+#define SWIGTYPE_p_const_iterator swig_types[50]
+#define SWIGTYPE_p_corr_matrix_t swig_types[51]
+#define SWIGTYPE_p_difference_type swig_types[52]
+#define SWIGTYPE_p_double swig_types[53]
+#define SWIGTYPE_p_first_type swig_types[54]
+#define SWIGTYPE_p_int swig_types[55]
+#define SWIGTYPE_p_iterator swig_types[56]
+#define SWIGTYPE_p_key_type swig_types[57]
+#define SWIGTYPE_p_long_long swig_types[58]
+#define SWIGTYPE_p_mapped_type swig_types[59]
+#define SWIGTYPE_p_p_ICoordSystem swig_types[60]
+#define SWIGTYPE_p_p_PyObject swig_types[61]
+#define SWIGTYPE_p_parameters_t swig_types[62]
+#define SWIGTYPE_p_second_type swig_types[63]
+#define SWIGTYPE_p_short swig_types[64]
+#define SWIGTYPE_p_signed_char swig_types[65]
+#define SWIGTYPE_p_size_type swig_types[66]
+#define SWIGTYPE_p_std__allocatorT_Vec3T_double_t_t swig_types[67]
+#define SWIGTYPE_p_std__allocatorT_double_t swig_types[68]
+#define SWIGTYPE_p_std__allocatorT_int_t swig_types[69]
+#define SWIGTYPE_p_std__allocatorT_std__complexT_double_t_t swig_types[70]
+#define SWIGTYPE_p_std__allocatorT_std__pairT_double_double_t_t swig_types[71]
+#define SWIGTYPE_p_std__allocatorT_std__pairT_std__string_const_double_t_t swig_types[72]
+#define SWIGTYPE_p_std__allocatorT_std__string_t swig_types[73]
+#define SWIGTYPE_p_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t swig_types[74]
+#define SWIGTYPE_p_std__allocatorT_std__vectorT_int_std__allocatorT_int_t_t_t swig_types[75]
+#define SWIGTYPE_p_std__allocatorT_unsigned_long_t swig_types[76]
+#define SWIGTYPE_p_std__complexT_double_t swig_types[77]
+#define SWIGTYPE_p_std__functionT_void_fSimulationAreaIterator_const_RF_t swig_types[78]
+#define SWIGTYPE_p_std__invalid_argument swig_types[79]
+#define SWIGTYPE_p_std__lessT_std__string_t swig_types[80]
+#define SWIGTYPE_p_std__mapT_std__string_double_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_double_t_t_t swig_types[81]
+#define SWIGTYPE_p_std__pairT_double_double_t swig_types[82]
+#define SWIGTYPE_p_std__vectorT_AxisInfo_std__allocatorT_AxisInfo_t_t swig_types[83]
+#define SWIGTYPE_p_std__vectorT_IAxis_p_std__allocatorT_IAxis_p_t_t swig_types[84]
+#define SWIGTYPE_p_std__vectorT_INode_const_p_std__allocatorT_INode_const_p_t_t swig_types[85]
+#define SWIGTYPE_p_std__vectorT_ParaMeta_std__allocatorT_ParaMeta_t_t swig_types[86]
+#define SWIGTYPE_p_std__vectorT_Vec3T_double_t_std__allocatorT_Vec3T_double_t_t_t swig_types[87]
+#define SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t swig_types[88]
+#define SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t swig_types[89]
+#define SWIGTYPE_p_std__vectorT_size_t_std__allocatorT_size_t_t_t swig_types[90]
+#define SWIGTYPE_p_std__vectorT_std__complexT_double_t_std__allocatorT_std__complexT_double_t_t_t swig_types[91]
+#define SWIGTYPE_p_std__vectorT_std__pairT_double_double_t_std__allocatorT_std__pairT_double_double_t_t_t swig_types[92]
+#define SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t swig_types[93]
+#define SWIGTYPE_p_std__vectorT_std__unique_ptrT_DiffuseElement_t_std__allocatorT_std__unique_ptrT_DiffuseElement_t_t_t swig_types[94]
+#define SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t swig_types[95]
+#define SWIGTYPE_p_std__vectorT_std__vectorT_int_std__allocatorT_int_t_t_std__allocatorT_std__vectorT_int_std__allocatorT_int_t_t_t_t swig_types[96]
+#define SWIGTYPE_p_std__vectorT_unsigned_long_std__allocatorT_unsigned_long_t_t swig_types[97]
+#define SWIGTYPE_p_swig__SwigPyIterator swig_types[98]
+#define SWIGTYPE_p_unsigned_char swig_types[99]
+#define SWIGTYPE_p_unsigned_int swig_types[100]
+#define SWIGTYPE_p_unsigned_long_long swig_types[101]
+#define SWIGTYPE_p_unsigned_short swig_types[102]
+#define SWIGTYPE_p_value_type swig_types[103]
+static swig_type_info *swig_types[105];
+static swig_module_info swig_module = {swig_types, 104, 0, 0, 0, 0};
 #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
 #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
 
@@ -6709,7 +6708,6 @@ SWIGINTERN void std_vector_Sl_std_pair_Sl_double_Sc_double_Sg__Sg__insert__SWIG_
 #include "Device/Histo/Histogram2D.h"
 #include "Device/Histo/IOFactory.h"
 #include "Device/Histo/SimulationResult.h"
-#include "Device/Instrument/Instrument.h"
 #include "Device/Mask/Ellipse.h"
 #include "Device/Mask/Line.h"
 #include "Device/Mask/Polygon.h"
@@ -35687,465 +35685,6 @@ SWIGINTERN PyObject *SphericalDetector_swiginit(PyObject *SWIGUNUSEDPARM(self),
   return SWIG_Python_InitShadowInstance(args);
 }
 
-SWIGINTERN PyObject *_wrap_new_Instrument__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **SWIGUNUSEDPARM(swig_obj)) {
-  PyObject *resultobj = 0;
-  Instrument *result = 0 ;
-  
-  if ((nobjs < 0) || (nobjs > 0)) SWIG_fail;
-  result = (Instrument *)new Instrument();
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Instrument, SWIG_POINTER_NEW |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_new_Instrument__SWIG_1(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) {
-  PyObject *resultobj = 0;
-  Beam *arg1 = 0 ;
-  IDetector *arg2 = 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  void *argp2 = 0 ;
-  int res2 = 0 ;
-  Instrument *result = 0 ;
-  
-  if ((nobjs < 2) || (nobjs > 2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1, SWIGTYPE_p_Beam,  0  | 0);
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Instrument" "', argument " "1"" of type '" "Beam const &""'"); 
-  }
-  if (!argp1) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Instrument" "', argument " "1"" of type '" "Beam const &""'"); 
-  }
-  arg1 = reinterpret_cast< Beam * >(argp1);
-  res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_IDetector,  0  | 0);
-  if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_Instrument" "', argument " "2"" of type '" "IDetector const &""'"); 
-  }
-  if (!argp2) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Instrument" "', argument " "2"" of type '" "IDetector const &""'"); 
-  }
-  arg2 = reinterpret_cast< IDetector * >(argp2);
-  result = (Instrument *)new Instrument((Beam const &)*arg1,(IDetector const &)*arg2);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Instrument, SWIG_POINTER_NEW |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_new_Instrument__SWIG_2(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) {
-  PyObject *resultobj = 0;
-  Instrument *arg1 = 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  Instrument *result = 0 ;
-  
-  if ((nobjs < 1) || (nobjs > 1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1, SWIGTYPE_p_Instrument,  0  | 0);
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Instrument" "', argument " "1"" of type '" "Instrument const &""'"); 
-  }
-  if (!argp1) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Instrument" "', argument " "1"" of type '" "Instrument const &""'"); 
-  }
-  arg1 = reinterpret_cast< Instrument * >(argp1);
-  result = (Instrument *)new Instrument((Instrument const &)*arg1);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Instrument, SWIG_POINTER_NEW |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_new_Instrument(PyObject *self, PyObject *args) {
-  Py_ssize_t argc;
-  PyObject *argv[3] = {
-    0
-  };
-  
-  if (!(argc = SWIG_Python_UnpackTuple(args, "new_Instrument", 0, 2, argv))) SWIG_fail;
-  --argc;
-  if (argc == 0) {
-    return _wrap_new_Instrument__SWIG_0(self, argc, argv);
-  }
-  if (argc == 1) {
-    int _v;
-    int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_Instrument, SWIG_POINTER_NO_NULL | 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      return _wrap_new_Instrument__SWIG_2(self, argc, argv);
-    }
-  }
-  if (argc == 2) {
-    int _v;
-    int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_Beam, SWIG_POINTER_NO_NULL | 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_IDetector, SWIG_POINTER_NO_NULL | 0);
-      _v = SWIG_CheckState(res);
-      if (_v) {
-        return _wrap_new_Instrument__SWIG_1(self, argc, argv);
-      }
-    }
-  }
-  
-fail:
-  SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'new_Instrument'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    Instrument::Instrument()\n"
-    "    Instrument::Instrument(Beam const &,IDetector const &)\n"
-    "    Instrument::Instrument(Instrument const &)\n");
-  return 0;
-}
-
-
-SWIGINTERN PyObject *_wrap_delete_Instrument(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  Instrument *arg1 = (Instrument *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject *swig_obj[1] ;
-  
-  if (!args) SWIG_fail;
-  swig_obj[0] = args;
-  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_Instrument, SWIG_POINTER_DISOWN |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Instrument" "', argument " "1"" of type '" "Instrument *""'"); 
-  }
-  arg1 = reinterpret_cast< Instrument * >(argp1);
-  delete arg1;
-  resultobj = SWIG_Py_Void();
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Instrument_className(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  Instrument *arg1 = (Instrument *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject *swig_obj[1] ;
-  std::string result;
-  
-  if (!args) SWIG_fail;
-  swig_obj[0] = args;
-  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_Instrument, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Instrument_className" "', argument " "1"" of type '" "Instrument const *""'"); 
-  }
-  arg1 = reinterpret_cast< Instrument * >(argp1);
-  result = ((Instrument const *)arg1)->className();
-  resultobj = SWIG_From_std_string(static_cast< std::string >(result));
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Instrument_beam__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) {
-  PyObject *resultobj = 0;
-  Instrument *arg1 = (Instrument *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  Beam *result = 0 ;
-  
-  if ((nobjs < 1) || (nobjs > 1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_Instrument, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Instrument_beam" "', argument " "1"" of type '" "Instrument *""'"); 
-  }
-  arg1 = reinterpret_cast< Instrument * >(argp1);
-  result = (Beam *) &(arg1)->beam();
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Beam, 0 |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Instrument_beam__SWIG_1(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) {
-  PyObject *resultobj = 0;
-  Instrument *arg1 = (Instrument *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  Beam *result = 0 ;
-  
-  if ((nobjs < 1) || (nobjs > 1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_Instrument, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Instrument_beam" "', argument " "1"" of type '" "Instrument const *""'"); 
-  }
-  arg1 = reinterpret_cast< Instrument * >(argp1);
-  result = (Beam *) &((Instrument const *)arg1)->beam();
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Beam, 0 |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Instrument_beam(PyObject *self, PyObject *args) {
-  Py_ssize_t argc;
-  PyObject *argv[2] = {
-    0
-  };
-  
-  if (!(argc = SWIG_Python_UnpackTuple(args, "Instrument_beam", 0, 1, argv))) SWIG_fail;
-  --argc;
-  if (argc == 1) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Instrument, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      return _wrap_Instrument_beam__SWIG_0(self, argc, argv);
-    }
-  }
-  if (argc == 1) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Instrument, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      return _wrap_Instrument_beam__SWIG_1(self, argc, argv);
-    }
-  }
-  
-fail:
-  SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'Instrument_beam'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    Instrument::beam()\n"
-    "    Instrument::beam() const\n");
-  return 0;
-}
-
-
-SWIGINTERN PyObject *_wrap_Instrument_getDetector__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) {
-  PyObject *resultobj = 0;
-  Instrument *arg1 = (Instrument *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  IDetector *result = 0 ;
-  
-  if ((nobjs < 1) || (nobjs > 1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_Instrument, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Instrument_getDetector" "', argument " "1"" of type '" "Instrument *""'"); 
-  }
-  arg1 = reinterpret_cast< Instrument * >(argp1);
-  result = (IDetector *)(arg1)->getDetector();
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_IDetector, 0 |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Instrument_getDetector__SWIG_1(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) {
-  PyObject *resultobj = 0;
-  Instrument *arg1 = (Instrument *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  IDetector *result = 0 ;
-  
-  if ((nobjs < 1) || (nobjs > 1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_Instrument, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Instrument_getDetector" "', argument " "1"" of type '" "Instrument const *""'"); 
-  }
-  arg1 = reinterpret_cast< Instrument * >(argp1);
-  result = (IDetector *)((Instrument const *)arg1)->getDetector();
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_IDetector, 0 |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Instrument_getDetector(PyObject *self, PyObject *args) {
-  Py_ssize_t argc;
-  PyObject *argv[2] = {
-    0
-  };
-  
-  if (!(argc = SWIG_Python_UnpackTuple(args, "Instrument_getDetector", 0, 1, argv))) SWIG_fail;
-  --argc;
-  if (argc == 1) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Instrument, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      return _wrap_Instrument_getDetector__SWIG_0(self, argc, argv);
-    }
-  }
-  if (argc == 1) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Instrument, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      return _wrap_Instrument_getDetector__SWIG_1(self, argc, argv);
-    }
-  }
-  
-fail:
-  SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'Instrument_getDetector'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    Instrument::getDetector()\n"
-    "    Instrument::getDetector() const\n");
-  return 0;
-}
-
-
-SWIGINTERN PyObject *_wrap_Instrument_detector__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) {
-  PyObject *resultobj = 0;
-  Instrument *arg1 = (Instrument *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  IDetector *result = 0 ;
-  
-  if ((nobjs < 1) || (nobjs > 1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_Instrument, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Instrument_detector" "', argument " "1"" of type '" "Instrument *""'"); 
-  }
-  arg1 = reinterpret_cast< Instrument * >(argp1);
-  result = (IDetector *) &(arg1)->detector();
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_IDetector, 0 |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Instrument_detector__SWIG_1(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) {
-  PyObject *resultobj = 0;
-  Instrument *arg1 = (Instrument *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  IDetector *result = 0 ;
-  
-  if ((nobjs < 1) || (nobjs > 1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_Instrument, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Instrument_detector" "', argument " "1"" of type '" "Instrument const *""'"); 
-  }
-  arg1 = reinterpret_cast< Instrument * >(argp1);
-  result = (IDetector *) &((Instrument const *)arg1)->detector();
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_IDetector, 0 |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Instrument_detector(PyObject *self, PyObject *args) {
-  Py_ssize_t argc;
-  PyObject *argv[2] = {
-    0
-  };
-  
-  if (!(argc = SWIG_Python_UnpackTuple(args, "Instrument_detector", 0, 1, argv))) SWIG_fail;
-  --argc;
-  if (argc == 1) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Instrument, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      return _wrap_Instrument_detector__SWIG_0(self, argc, argv);
-    }
-  }
-  if (argc == 1) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Instrument, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      return _wrap_Instrument_detector__SWIG_1(self, argc, argv);
-    }
-  }
-  
-fail:
-  SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'Instrument_detector'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    Instrument::detector()\n"
-    "    Instrument::detector() const\n");
-  return 0;
-}
-
-
-SWIGINTERN PyObject *_wrap_Instrument_setDetector(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  Instrument *arg1 = (Instrument *) 0 ;
-  IDetector *arg2 = 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  void *argp2 = 0 ;
-  int res2 = 0 ;
-  PyObject *swig_obj[2] ;
-  
-  if (!SWIG_Python_UnpackTuple(args, "Instrument_setDetector", 2, 2, swig_obj)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_Instrument, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Instrument_setDetector" "', argument " "1"" of type '" "Instrument *""'"); 
-  }
-  arg1 = reinterpret_cast< Instrument * >(argp1);
-  res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_IDetector,  0  | 0);
-  if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Instrument_setDetector" "', argument " "2"" of type '" "IDetector const &""'"); 
-  }
-  if (!argp2) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Instrument_setDetector" "', argument " "2"" of type '" "IDetector const &""'"); 
-  }
-  arg2 = reinterpret_cast< IDetector * >(argp2);
-  (arg1)->setDetector((IDetector const &)*arg2);
-  resultobj = SWIG_Py_Void();
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Instrument_nodeChildren(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  Instrument *arg1 = (Instrument *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject *swig_obj[1] ;
-  SwigValueWrapper< std::vector< INode const *,std::allocator< INode const * > > > result;
-  
-  if (!args) SWIG_fail;
-  swig_obj[0] = args;
-  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_Instrument, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Instrument_nodeChildren" "', argument " "1"" of type '" "Instrument const *""'"); 
-  }
-  arg1 = reinterpret_cast< Instrument * >(argp1);
-  result = ((Instrument const *)arg1)->nodeChildren();
-  resultobj = SWIG_NewPointerObj((new std::vector< INode const *,std::allocator< INode const * > >(static_cast< const std::vector< INode const *,std::allocator< INode const * > >& >(result))), SWIGTYPE_p_std__vectorT_INode_const_p_std__allocatorT_INode_const_p_t_t, SWIG_POINTER_OWN |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *Instrument_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *obj;
-  if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL;
-  SWIG_TypeNewClientData(SWIGTYPE_p_Instrument, SWIG_NewClientData(obj));
-  return SWIG_Py_Void();
-}
-
-SWIGINTERN PyObject *Instrument_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  return SWIG_Python_InitShadowInstance(args);
-}
-
 SWIGINTERN PyObject *_wrap_FindPeaks__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) {
   PyObject *resultobj = 0;
   Histogram2D *arg1 = 0 ;
@@ -43267,55 +42806,6 @@ static PyMethodDef SwigMethods[] = {
 		""},
 	 { "SphericalDetector_swigregister", SphericalDetector_swigregister, METH_O, NULL},
 	 { "SphericalDetector_swiginit", SphericalDetector_swiginit, METH_VARARGS, NULL},
-	 { "new_Instrument", _wrap_new_Instrument, METH_VARARGS, "\n"
-		"Instrument()\n"
-		"Instrument(Beam beam, IDetector detector)\n"
-		"new_Instrument(Instrument other) -> Instrument\n"
-		"Instrument::Instrument(const Instrument &other)\n"
-		"\n"
-		""},
-	 { "delete_Instrument", _wrap_delete_Instrument, METH_O, "\n"
-		"delete_Instrument(Instrument self)\n"
-		"Instrument::~Instrument() override\n"
-		"\n"
-		""},
-	 { "Instrument_className", _wrap_Instrument_className, METH_O, "\n"
-		"Instrument_className(Instrument self) -> std::string\n"
-		"std::string Instrument::className() const final\n"
-		"\n"
-		""},
-	 { "Instrument_beam", _wrap_Instrument_beam, METH_VARARGS, "\n"
-		"Instrument_beam(Instrument self) -> Beam\n"
-		"Instrument_beam(Instrument self) -> Beam\n"
-		"const Beam& Instrument::beam() const\n"
-		"\n"
-		""},
-	 { "Instrument_getDetector", _wrap_Instrument_getDetector, METH_VARARGS, "\n"
-		"Instrument_getDetector(Instrument self) -> IDetector\n"
-		"Instrument_getDetector(Instrument self) -> IDetector\n"
-		"const IDetector * Instrument::getDetector() const\n"
-		"\n"
-		""},
-	 { "Instrument_detector", _wrap_Instrument_detector, METH_VARARGS, "\n"
-		"Instrument_detector(Instrument self) -> IDetector\n"
-		"Instrument_detector(Instrument self) -> IDetector\n"
-		"const IDetector & Instrument::detector() const\n"
-		"\n"
-		""},
-	 { "Instrument_setDetector", _wrap_Instrument_setDetector, METH_VARARGS, "\n"
-		"Instrument_setDetector(Instrument self, IDetector detector)\n"
-		"void Instrument::setDetector(const IDetector &detector)\n"
-		"\n"
-		"Sets the detector (axes can be overwritten later) \n"
-		"\n"
-		""},
-	 { "Instrument_nodeChildren", _wrap_Instrument_nodeChildren, METH_O, "\n"
-		"Instrument_nodeChildren(Instrument self) -> std::vector< INode const *,std::allocator< INode const * > >\n"
-		"std::vector< const INode * > Instrument::nodeChildren() const override\n"
-		"\n"
-		""},
-	 { "Instrument_swigregister", Instrument_swigregister, METH_O, NULL},
-	 { "Instrument_swiginit", Instrument_swiginit, METH_VARARGS, NULL},
 	 { "FindPeaks", _wrap_FindPeaks, METH_VARARGS, "\n"
 		"FindPeaks(Histogram2D hist, double sigma=2, std::string const & option={}, double threshold=0.05) -> vector_pvacuum_double_t\n"
 		"std::vector< std::pair< double, double > > DataUtils::Histo::FindPeaks(const Histogram2D &hist, double sigma=2, const std::string &option={}, double threshold=0.05)\n"
@@ -43981,9 +43471,6 @@ static void *_p_FootprintSquareTo_p_INode(void *x, int *SWIGUNUSEDPARM(newmemory
 static void *_p_IDetectorResolutionTo_p_INode(void *x, int *SWIGUNUSEDPARM(newmemory)) {
     return (void *)((INode *)  ((IDetectorResolution *) x));
 }
-static void *_p_InstrumentTo_p_INode(void *x, int *SWIGUNUSEDPARM(newmemory)) {
-    return (void *)((INode *)  ((Instrument *) x));
-}
 static void *_p_IFootprintFactorTo_p_INode(void *x, int *SWIGUNUSEDPARM(newmemory)) {
     return (void *)((INode *)  ((IFootprintFactor *) x));
 }
@@ -44094,7 +43581,6 @@ static swig_type_info _swigt__p_IOFactory = {"_p_IOFactory", "IOFactory *", 0, 0
 static swig_type_info _swigt__p_IPixel = {"_p_IPixel", "IPixel *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_IResolutionFunction2D = {"_p_IResolutionFunction2D", "IResolutionFunction2D *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_IShape2D = {"_p_IShape2D", "IShape2D *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_Instrument = {"_p_Instrument", "Instrument *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_Line = {"_p_Line", "Line *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_MaskPattern = {"_p_MaskPattern", "MaskPattern *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_OwningVectorT_IAxis_t = {"_p_OwningVectorT_IAxis_t", "OwningVector< IAxis > *", 0, 0, (void*)0, 0};
@@ -44201,7 +43687,6 @@ static swig_type_info *swig_type_initial[] = {
   &_swigt__p_IPixel,
   &_swigt__p_IResolutionFunction2D,
   &_swigt__p_IShape2D,
-  &_swigt__p_Instrument,
   &_swigt__p_Line,
   &_swigt__p_MaskPattern,
   &_swigt__p_OwningVectorT_IAxis_t,
@@ -44303,12 +43788,11 @@ static swig_cast_info _swigc__p_IDetector2D[] = {  {&_swigt__p_RectangularDetect
 static swig_cast_info _swigc__p_IDetectorResolution[] = {  {&_swigt__p_IDetectorResolution, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_IFootprintFactor[] = {  {&_swigt__p_FootprintSquare, _p_FootprintSquareTo_p_IFootprintFactor, 0, 0},  {&_swigt__p_IFootprintFactor, 0, 0, 0},  {&_swigt__p_FootprintGauss, _p_FootprintGaussTo_p_IFootprintFactor, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_IHistogram[] = {  {&_swigt__p_IHistogram, 0, 0, 0},  {&_swigt__p_Histogram2D, _p_Histogram2DTo_p_IHistogram, 0, 0},  {&_swigt__p_Histogram1D, _p_Histogram1DTo_p_IHistogram, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_INode[] = {  {&_swigt__p_INode, 0, 0, 0},  {&_swigt__p_FootprintSquare, _p_FootprintSquareTo_p_INode, 0, 0},  {&_swigt__p_IDetectorResolution, _p_IDetectorResolutionTo_p_INode, 0, 0},  {&_swigt__p_Instrument, _p_InstrumentTo_p_INode, 0, 0},  {&_swigt__p_IFootprintFactor, _p_IFootprintFactorTo_p_INode, 0, 0},  {&_swigt__p_Beam, _p_BeamTo_p_INode, 0, 0},  {&_swigt__p_IResolutionFunction2D, _p_IResolutionFunction2DTo_p_INode, 0, 0},  {&_swigt__p_ResolutionFunction2DGaussian, _p_ResolutionFunction2DGaussianTo_p_INode, 0, 0},  {&_swigt__p_IDetector, _p_IDetectorTo_p_INode, 0, 0},  {&_swigt__p_RectangularDetector, _p_RectangularDetectorTo_p_INode, 0, 0},  {&_swigt__p_SphericalDetector, _p_SphericalDetectorTo_p_INode, 0, 0},  {&_swigt__p_FootprintGauss, _p_FootprintGaussTo_p_INode, 0, 0},  {&_swigt__p_IDetector2D, _p_IDetector2DTo_p_INode, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_INode[] = {  {&_swigt__p_INode, 0, 0, 0},  {&_swigt__p_FootprintSquare, _p_FootprintSquareTo_p_INode, 0, 0},  {&_swigt__p_IDetectorResolution, _p_IDetectorResolutionTo_p_INode, 0, 0},  {&_swigt__p_IFootprintFactor, _p_IFootprintFactorTo_p_INode, 0, 0},  {&_swigt__p_Beam, _p_BeamTo_p_INode, 0, 0},  {&_swigt__p_IResolutionFunction2D, _p_IResolutionFunction2DTo_p_INode, 0, 0},  {&_swigt__p_ResolutionFunction2DGaussian, _p_ResolutionFunction2DGaussianTo_p_INode, 0, 0},  {&_swigt__p_IDetector, _p_IDetectorTo_p_INode, 0, 0},  {&_swigt__p_RectangularDetector, _p_RectangularDetectorTo_p_INode, 0, 0},  {&_swigt__p_SphericalDetector, _p_SphericalDetectorTo_p_INode, 0, 0},  {&_swigt__p_FootprintGauss, _p_FootprintGaussTo_p_INode, 0, 0},  {&_swigt__p_IDetector2D, _p_IDetector2DTo_p_INode, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_IOFactory[] = {  {&_swigt__p_IOFactory, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_IPixel[] = {  {&_swigt__p_IPixel, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_IResolutionFunction2D[] = {  {&_swigt__p_IResolutionFunction2D, 0, 0, 0},  {&_swigt__p_ResolutionFunction2DGaussian, _p_ResolutionFunction2DGaussianTo_p_IResolutionFunction2D, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_IShape2D[] = {  {&_swigt__p_Polygon, _p_PolygonTo_p_IShape2D, 0, 0},  {&_swigt__p_Line, _p_LineTo_p_IShape2D, 0, 0},  {&_swigt__p_VerticalLine, _p_VerticalLineTo_p_IShape2D, 0, 0},  {&_swigt__p_Ellipse, _p_EllipseTo_p_IShape2D, 0, 0},  {&_swigt__p_HorizontalLine, _p_HorizontalLineTo_p_IShape2D, 0, 0},  {&_swigt__p_Rectangle, _p_RectangleTo_p_IShape2D, 0, 0},  {&_swigt__p_IShape2D, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_Instrument[] = {  {&_swigt__p_Instrument, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_Line[] = {  {&_swigt__p_Line, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_MaskPattern[] = {  {&_swigt__p_MaskPattern, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_OwningVectorT_IAxis_t[] = {  {&_swigt__p_OwningVectorT_IAxis_t, 0, 0, 0},{0, 0, 0, 0}};
@@ -44415,7 +43899,6 @@ static swig_cast_info *swig_cast_initial[] = {
   _swigc__p_IPixel,
   _swigc__p_IResolutionFunction2D,
   _swigc__p_IShape2D,
-  _swigc__p_Instrument,
   _swigc__p_Line,
   _swigc__p_MaskPattern,
   _swigc__p_OwningVectorT_IAxis_t,
-- 
GitLab


From 01ffb97b5e8771548b6fde39003ca94bdbd3b660 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 17:48:57 +0200
Subject: [PATCH 20/63] rm unused fct

---
 GUI/Model/Device/Instrument.cpp | 9 ---------
 GUI/Model/Device/Instrument.h   | 1 -
 2 files changed, 10 deletions(-)

diff --git a/GUI/Model/Device/Instrument.cpp b/GUI/Model/Device/Instrument.cpp
index 57ebc412850..77351b6a909 100644
--- a/GUI/Model/Device/Instrument.cpp
+++ b/GUI/Model/Device/Instrument.cpp
@@ -40,15 +40,6 @@ Instrument::Instrument(const Instrument& other)
 
 Instrument::~Instrument() = default;
 
-Instrument& Instrument::operator=(const Instrument& other)
-{
-    if (this != &other) {
-        Instrument tmp(other.beam(), other.detector());
-        std::swap(*this, tmp);
-    }
-    return *this;
-}
-
 void Instrument::setDetector(const IDetector& detector)
 {
     m_detector.reset(detector.clone());
diff --git a/GUI/Model/Device/Instrument.h b/GUI/Model/Device/Instrument.h
index 0be144cf9a6..defa70f597b 100644
--- a/GUI/Model/Device/Instrument.h
+++ b/GUI/Model/Device/Instrument.h
@@ -31,7 +31,6 @@ public:
     Instrument();
     Instrument(const Beam& beam, const IDetector& detector);
     Instrument(const Instrument& other);
-    Instrument& operator=(const Instrument& other);
     ~Instrument() override;
 
     std::string className() const final { return "Instrument"; }
-- 
GitLab


From c5f1c77fb695535fa6669c6f0cd9a5b12c8fc3e0 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 17:49:37 +0200
Subject: [PATCH 21/63] rm unused includes

---
 GUI/Model/Device/Instrument.cpp | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/GUI/Model/Device/Instrument.cpp b/GUI/Model/Device/Instrument.cpp
index 77351b6a909..7abf6178cc0 100644
--- a/GUI/Model/Device/Instrument.cpp
+++ b/GUI/Model/Device/Instrument.cpp
@@ -14,13 +14,8 @@
 
 #include "GUI/Model/Device/Instrument.h"
 #include "Base/Element/PolMatrices.h"
-#include "Base/Pixel/RectangularPixel.h"
 #include "Device/Beam/Beam.h"
-#include "Device/Coord/CoordSystem2D.h"
-#include "Device/Detector/RectangularDetector.h"
 #include "Device/Detector/SphericalDetector.h"
-#include "Device/Histo/Histogram2D.h"
-#include "Device/Resolution/IResolutionFunction2D.h"
 
 Instrument::Instrument(const Beam& beam, const IDetector& detector)
     : m_beam(beam.clone())
-- 
GitLab


From 56474136e6d8f1eced155bdf5c58ba7d7954bdeb Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 17:50:16 +0200
Subject: [PATCH 22/63] rm unused

---
 GUI/Model/Device/Instrument.cpp | 5 -----
 GUI/Model/Device/Instrument.h   | 3 ---
 2 files changed, 8 deletions(-)

diff --git a/GUI/Model/Device/Instrument.cpp b/GUI/Model/Device/Instrument.cpp
index 7abf6178cc0..72d601a62bb 100644
--- a/GUI/Model/Device/Instrument.cpp
+++ b/GUI/Model/Device/Instrument.cpp
@@ -23,11 +23,6 @@ Instrument::Instrument(const Beam& beam, const IDetector& detector)
 {
 }
 
-Instrument::Instrument()
-    : Instrument(Beam::horizontalBeam(), SphericalDetector())
-{
-}
-
 Instrument::Instrument(const Instrument& other)
     : Instrument(other.beam(), other.detector())
 {
diff --git a/GUI/Model/Device/Instrument.h b/GUI/Model/Device/Instrument.h
index defa70f597b..dd0dbc337f0 100644
--- a/GUI/Model/Device/Instrument.h
+++ b/GUI/Model/Device/Instrument.h
@@ -17,18 +17,15 @@
 #define BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENT_H
 
 #include "Param/Node/INode.h"
-#include <heinz/Vectors3D.h>
 #include <memory>
 
 class Beam;
-class CoordSystem2D;
 class IDetector;
 
 //! Assembles beam, detector and their relative positions with respect to the sample.
 
 class Instrument : public INode {
 public:
-    Instrument();
     Instrument(const Beam& beam, const IDetector& detector);
     Instrument(const Instrument& other);
     ~Instrument() override;
-- 
GitLab


From 83ad6ee88f8cdb0ae8397484b3af762b71c14799 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 17:51:50 +0200
Subject: [PATCH 23/63] rm inheritance from INode

---
 GUI/Model/Device/Instrument.cpp | 9 ---------
 GUI/Model/Device/Instrument.h   | 9 ++-------
 2 files changed, 2 insertions(+), 16 deletions(-)

diff --git a/GUI/Model/Device/Instrument.cpp b/GUI/Model/Device/Instrument.cpp
index 72d601a62bb..b5c7f288c8e 100644
--- a/GUI/Model/Device/Instrument.cpp
+++ b/GUI/Model/Device/Instrument.cpp
@@ -35,15 +35,6 @@ void Instrument::setDetector(const IDetector& detector)
     m_detector.reset(detector.clone());
 }
 
-std::vector<const INode*> Instrument::nodeChildren() const
-{
-    std::vector<const INode*> result;
-    result.push_back(m_beam.get());
-    if (m_detector)
-        result.push_back(m_detector.get());
-    return result;
-}
-
 const IDetector* Instrument::getDetector() const
 {
     return m_detector.get();
diff --git a/GUI/Model/Device/Instrument.h b/GUI/Model/Device/Instrument.h
index dd0dbc337f0..7da84756ec6 100644
--- a/GUI/Model/Device/Instrument.h
+++ b/GUI/Model/Device/Instrument.h
@@ -16,7 +16,6 @@
 #ifndef BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENT_H
 #define BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENT_H
 
-#include "Param/Node/INode.h"
 #include <memory>
 
 class Beam;
@@ -24,13 +23,11 @@ class IDetector;
 
 //! Assembles beam, detector and their relative positions with respect to the sample.
 
-class Instrument : public INode {
+class Instrument {
 public:
     Instrument(const Beam& beam, const IDetector& detector);
     Instrument(const Instrument& other);
-    ~Instrument() override;
-
-    std::string className() const final { return "Instrument"; }
+    ~Instrument();
 
     Beam& beam() { return *m_beam; }
     const Beam& beam() const { return *m_beam; }
@@ -43,8 +40,6 @@ public:
     //! Sets the detector (axes can be overwritten later)
     void setDetector(const IDetector& detector);
 
-    std::vector<const INode*> nodeChildren() const override;
-
 protected:
     std::unique_ptr<Beam> m_beam;
     std::unique_ptr<IDetector> m_detector;
-- 
GitLab


From 8388570b9ee2dbc0b705a1995bc0492f9af685c7 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 17:52:43 +0200
Subject: [PATCH 24/63] rm unused fct

---
 GUI/Model/Device/Instrument.cpp | 5 -----
 GUI/Model/Device/Instrument.h   | 4 ----
 2 files changed, 9 deletions(-)

diff --git a/GUI/Model/Device/Instrument.cpp b/GUI/Model/Device/Instrument.cpp
index b5c7f288c8e..a1e3d361e4a 100644
--- a/GUI/Model/Device/Instrument.cpp
+++ b/GUI/Model/Device/Instrument.cpp
@@ -30,11 +30,6 @@ Instrument::Instrument(const Instrument& other)
 
 Instrument::~Instrument() = default;
 
-void Instrument::setDetector(const IDetector& detector)
-{
-    m_detector.reset(detector.clone());
-}
-
 const IDetector* Instrument::getDetector() const
 {
     return m_detector.get();
diff --git a/GUI/Model/Device/Instrument.h b/GUI/Model/Device/Instrument.h
index 7da84756ec6..4121912bd34 100644
--- a/GUI/Model/Device/Instrument.h
+++ b/GUI/Model/Device/Instrument.h
@@ -29,7 +29,6 @@ public:
     Instrument(const Instrument& other);
     ~Instrument();
 
-    Beam& beam() { return *m_beam; }
     const Beam& beam() const { return *m_beam; }
 
     IDetector* getDetector();
@@ -37,9 +36,6 @@ public:
     IDetector& detector();
     const IDetector& detector() const;
 
-    //! Sets the detector (axes can be overwritten later)
-    void setDetector(const IDetector& detector);
-
 protected:
     std::unique_ptr<Beam> m_beam;
     std::unique_ptr<IDetector> m_detector;
-- 
GitLab


From b94a7d1dc12dff6e009effd4db23d9153067fb5e Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 17:54:58 +0200
Subject: [PATCH 25/63] rm unused fct

---
 GUI/Model/Device/Instrument.cpp  | 5 -----
 GUI/Model/Device/Instrument.h    | 1 -
 GUI/Model/Model/JobFunctions.cpp | 2 +-
 3 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/GUI/Model/Device/Instrument.cpp b/GUI/Model/Device/Instrument.cpp
index a1e3d361e4a..b831b936fe5 100644
--- a/GUI/Model/Device/Instrument.cpp
+++ b/GUI/Model/Device/Instrument.cpp
@@ -35,11 +35,6 @@ const IDetector* Instrument::getDetector() const
     return m_detector.get();
 }
 
-IDetector* Instrument::getDetector()
-{
-    return m_detector.get();
-}
-
 const IDetector& Instrument::detector() const
 {
     return *m_detector;
diff --git a/GUI/Model/Device/Instrument.h b/GUI/Model/Device/Instrument.h
index 4121912bd34..275f9ce106d 100644
--- a/GUI/Model/Device/Instrument.h
+++ b/GUI/Model/Device/Instrument.h
@@ -31,7 +31,6 @@ public:
 
     const Beam& beam() const { return *m_beam; }
 
-    IDetector* getDetector();
     const IDetector* getDetector() const;
     IDetector& detector();
     const IDetector& detector() const;
diff --git a/GUI/Model/Model/JobFunctions.cpp b/GUI/Model/Model/JobFunctions.cpp
index bad5de3f67c..b1d42c592c1 100644
--- a/GUI/Model/Model/JobFunctions.cpp
+++ b/GUI/Model/Model/JobFunctions.cpp
@@ -70,7 +70,7 @@ void cropRealData(JobItem* jobItem)
     auto* instrument_item = jobItem->instrument2DItem();
     GUI::Model::JobItemUtils::createDefaultDetectorMap(intensityItem, instrument_item);
 
-    instrument_item->createInstrument()->getDetector()->iterateOverNonMaskedPoints(
+    instrument_item->createInstrument()->detector().iterateOverNonMaskedPoints(
         [&](IDetector::const_iterator it) {
             auto* cropped_data = intensityItem->getPowerfield();
             (*cropped_data)[it.roiIndex()] = (*origData)[it.detectorIndex()];
-- 
GitLab


From 826412c11e57941519760b57e4fc34d079d17d2c Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 17:55:26 +0200
Subject: [PATCH 26/63] rm unused c'tor

---
 GUI/Model/Device/Instrument.cpp | 5 -----
 GUI/Model/Device/Instrument.h   | 1 -
 2 files changed, 6 deletions(-)

diff --git a/GUI/Model/Device/Instrument.cpp b/GUI/Model/Device/Instrument.cpp
index b831b936fe5..03e260ebbe8 100644
--- a/GUI/Model/Device/Instrument.cpp
+++ b/GUI/Model/Device/Instrument.cpp
@@ -23,11 +23,6 @@ Instrument::Instrument(const Beam& beam, const IDetector& detector)
 {
 }
 
-Instrument::Instrument(const Instrument& other)
-    : Instrument(other.beam(), other.detector())
-{
-}
-
 Instrument::~Instrument() = default;
 
 const IDetector* Instrument::getDetector() const
diff --git a/GUI/Model/Device/Instrument.h b/GUI/Model/Device/Instrument.h
index 275f9ce106d..4d10c322ecc 100644
--- a/GUI/Model/Device/Instrument.h
+++ b/GUI/Model/Device/Instrument.h
@@ -26,7 +26,6 @@ class IDetector;
 class Instrument {
 public:
     Instrument(const Beam& beam, const IDetector& detector);
-    Instrument(const Instrument& other);
     ~Instrument();
 
     const Beam& beam() const { return *m_beam; }
-- 
GitLab


From a46785cd13caddb6e61700c943d01817b5ce8a95 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 17:56:20 +0200
Subject: [PATCH 27/63] rm unused modifying fct

---
 GUI/Model/Device/Instrument.cpp | 5 -----
 GUI/Model/Device/Instrument.h   | 1 -
 2 files changed, 6 deletions(-)

diff --git a/GUI/Model/Device/Instrument.cpp b/GUI/Model/Device/Instrument.cpp
index 03e260ebbe8..73fb065b6c3 100644
--- a/GUI/Model/Device/Instrument.cpp
+++ b/GUI/Model/Device/Instrument.cpp
@@ -34,8 +34,3 @@ const IDetector& Instrument::detector() const
 {
     return *m_detector;
 }
-
-IDetector& Instrument::detector()
-{
-    return *m_detector;
-}
diff --git a/GUI/Model/Device/Instrument.h b/GUI/Model/Device/Instrument.h
index 4d10c322ecc..85daa6f3009 100644
--- a/GUI/Model/Device/Instrument.h
+++ b/GUI/Model/Device/Instrument.h
@@ -31,7 +31,6 @@ public:
     const Beam& beam() const { return *m_beam; }
 
     const IDetector* getDetector() const;
-    IDetector& detector();
     const IDetector& detector() const;
 
 protected:
-- 
GitLab


From d5813edbe704d6719b26190506b8283aba23afef Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 17:57:00 +0200
Subject: [PATCH 28/63] rm unused includes

---
 GUI/Model/Device/Instrument.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/GUI/Model/Device/Instrument.cpp b/GUI/Model/Device/Instrument.cpp
index 73fb065b6c3..234f75efe6b 100644
--- a/GUI/Model/Device/Instrument.cpp
+++ b/GUI/Model/Device/Instrument.cpp
@@ -13,9 +13,8 @@
 //  ************************************************************************************************
 
 #include "GUI/Model/Device/Instrument.h"
-#include "Base/Element/PolMatrices.h"
 #include "Device/Beam/Beam.h"
-#include "Device/Detector/SphericalDetector.h"
+#include "Device/Detector/IDetector.h"
 
 Instrument::Instrument(const Beam& beam, const IDetector& detector)
     : m_beam(beam.clone())
-- 
GitLab


From ed0d133aadf952617461ac953fd7c4345d70108c Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 18:04:24 +0200
Subject: [PATCH 29/63] narrow down -> IDetector2D

---
 GUI/Model/Device/Instrument.cpp          |   8 +-
 GUI/Model/Device/Instrument.h            |  10 +-
 GUI/Model/Model/JobFunctions.cpp         |   1 +
 Sim/Simulation/OffSpecularSimulation.cpp |   2 +-
 Sim/Simulation/OffSpecularSimulation.h   |   2 +-
 Sim/Simulation/ScatteringSimulation.cpp  |   2 +-
 Sim/Simulation/ScatteringSimulation.h    |   2 +-
 auto/Wrap/doxygenSim.i                   |   4 +-
 auto/Wrap/libBornAgainSim.py             |   6 +-
 auto/Wrap/libBornAgainSim_wrap.cpp       | 211 ++++++++++++-----------
 10 files changed, 127 insertions(+), 121 deletions(-)

diff --git a/GUI/Model/Device/Instrument.cpp b/GUI/Model/Device/Instrument.cpp
index 234f75efe6b..e3cc7cdfbae 100644
--- a/GUI/Model/Device/Instrument.cpp
+++ b/GUI/Model/Device/Instrument.cpp
@@ -14,9 +14,9 @@
 
 #include "GUI/Model/Device/Instrument.h"
 #include "Device/Beam/Beam.h"
-#include "Device/Detector/IDetector.h"
+#include "Device/Detector/IDetector2D.h"
 
-Instrument::Instrument(const Beam& beam, const IDetector& detector)
+Instrument::Instrument(const Beam& beam, const IDetector2D& detector)
     : m_beam(beam.clone())
     , m_detector(detector.clone())
 {
@@ -24,12 +24,12 @@ Instrument::Instrument(const Beam& beam, const IDetector& detector)
 
 Instrument::~Instrument() = default;
 
-const IDetector* Instrument::getDetector() const
+const IDetector2D* Instrument::getDetector() const
 {
     return m_detector.get();
 }
 
-const IDetector& Instrument::detector() const
+const IDetector2D& Instrument::detector() const
 {
     return *m_detector;
 }
diff --git a/GUI/Model/Device/Instrument.h b/GUI/Model/Device/Instrument.h
index 85daa6f3009..3f21d567079 100644
--- a/GUI/Model/Device/Instrument.h
+++ b/GUI/Model/Device/Instrument.h
@@ -19,23 +19,23 @@
 #include <memory>
 
 class Beam;
-class IDetector;
+class IDetector2D;
 
 //! Assembles beam, detector and their relative positions with respect to the sample.
 
 class Instrument {
 public:
-    Instrument(const Beam& beam, const IDetector& detector);
+    Instrument(const Beam& beam, const IDetector2D& detector);
     ~Instrument();
 
     const Beam& beam() const { return *m_beam; }
 
-    const IDetector* getDetector() const;
-    const IDetector& detector() const;
+    const IDetector2D* getDetector() const;
+    const IDetector2D& detector() const;
 
 protected:
     std::unique_ptr<Beam> m_beam;
-    std::unique_ptr<IDetector> m_detector;
+    std::unique_ptr<IDetector2D> m_detector;
 };
 
 #endif // BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENT_H
diff --git a/GUI/Model/Model/JobFunctions.cpp b/GUI/Model/Model/JobFunctions.cpp
index b1d42c592c1..211f6918783 100644
--- a/GUI/Model/Model/JobFunctions.cpp
+++ b/GUI/Model/Model/JobFunctions.cpp
@@ -14,6 +14,7 @@
 
 #include "GUI/Model/Model/JobFunctions.h"
 #include "Base/Util/Assert.h"
+#include "Device/Detector/IDetector2D.h"
 #include "GUI/Model/Device/Instrument.h"
 #include "GUI/Model/Data/Data1DViewItem.h"
 #include "GUI/Model/Data/DataPropertyContainer.h"
diff --git a/Sim/Simulation/OffSpecularSimulation.cpp b/Sim/Simulation/OffSpecularSimulation.cpp
index f7312166ce9..41a2e46ed9c 100644
--- a/Sim/Simulation/OffSpecularSimulation.cpp
+++ b/Sim/Simulation/OffSpecularSimulation.cpp
@@ -26,7 +26,7 @@
 #include "Resample/Element/DiffuseElement.h"
 
 OffSpecularSimulation::OffSpecularSimulation(const Beam& beam, const MultiLayer& sample,
-                                             const IDetector& detector)
+                                             const IDetector2D& detector)
     : ISimulation2D(beam, sample, detector)
 {
 }
diff --git a/Sim/Simulation/OffSpecularSimulation.h b/Sim/Simulation/OffSpecularSimulation.h
index 52c5f2ff096..11c6cdc2342 100644
--- a/Sim/Simulation/OffSpecularSimulation.h
+++ b/Sim/Simulation/OffSpecularSimulation.h
@@ -30,7 +30,7 @@ class Powerfield;
 
 class OffSpecularSimulation : public ISimulation2D {
 public:
-    OffSpecularSimulation(const Beam& beam, const MultiLayer& sample, const IDetector& detector);
+    OffSpecularSimulation(const Beam& beam, const MultiLayer& sample, const IDetector2D& detector);
     OffSpecularSimulation();
     ~OffSpecularSimulation() override = default;
 
diff --git a/Sim/Simulation/ScatteringSimulation.cpp b/Sim/Simulation/ScatteringSimulation.cpp
index b36774368e2..b7db5d553e0 100644
--- a/Sim/Simulation/ScatteringSimulation.cpp
+++ b/Sim/Simulation/ScatteringSimulation.cpp
@@ -20,7 +20,7 @@
 #include "Resample/Element/DiffuseElement.h"
 
 ScatteringSimulation::ScatteringSimulation(const Beam& beam, const MultiLayer& sample,
-                                           const IDetector& detector)
+                                           const IDetector2D& detector)
     : ISimulation2D(beam, sample, detector)
 {
 }
diff --git a/Sim/Simulation/ScatteringSimulation.h b/Sim/Simulation/ScatteringSimulation.h
index 28bdfff03ae..7f20b83afe3 100644
--- a/Sim/Simulation/ScatteringSimulation.h
+++ b/Sim/Simulation/ScatteringSimulation.h
@@ -27,7 +27,7 @@ class MultiLayer;
 
 class ScatteringSimulation : public ISimulation2D {
 public:
-    ScatteringSimulation(const Beam& beam, const MultiLayer& sample, const IDetector& detector);
+    ScatteringSimulation(const Beam& beam, const MultiLayer& sample, const IDetector2D& detector);
     ~ScatteringSimulation() override = default;
 
     std::string className() const final { return "ScatteringSimulation"; }
diff --git a/auto/Wrap/doxygenSim.i b/auto/Wrap/doxygenSim.i
index 5fdb58a7a84..0820f5320a9 100644
--- a/auto/Wrap/doxygenSim.i
+++ b/auto/Wrap/doxygenSim.i
@@ -1285,7 +1285,7 @@ Holds an instrument and sample model. Computes reflected and scattered intensity
 C++ includes: OffSpecularSimulation.h
 ";
 
-%feature("docstring")  OffSpecularSimulation::OffSpecularSimulation "OffSpecularSimulation::OffSpecularSimulation(const Beam &beam, const MultiLayer &sample, const IDetector &detector)
+%feature("docstring")  OffSpecularSimulation::OffSpecularSimulation "OffSpecularSimulation::OffSpecularSimulation(const Beam &beam, const MultiLayer &sample, const IDetector2D &detector)
 ";
 
 %feature("docstring")  OffSpecularSimulation::OffSpecularSimulation "OffSpecularSimulation::OffSpecularSimulation()
@@ -1738,7 +1738,7 @@ Holds an instrument and sample model. Computes the scattered intensity as functi
 C++ includes: ScatteringSimulation.h
 ";
 
-%feature("docstring")  ScatteringSimulation::ScatteringSimulation "ScatteringSimulation::ScatteringSimulation(const Beam &beam, const MultiLayer &sample, const IDetector &detector)
+%feature("docstring")  ScatteringSimulation::ScatteringSimulation "ScatteringSimulation::ScatteringSimulation(const Beam &beam, const MultiLayer &sample, const IDetector2D &detector)
 ";
 
 %feature("docstring")  ScatteringSimulation::~ScatteringSimulation "ScatteringSimulation::~ScatteringSimulation() override=default
diff --git a/auto/Wrap/libBornAgainSim.py b/auto/Wrap/libBornAgainSim.py
index ae32d166b45..ce499f33a2c 100644
--- a/auto/Wrap/libBornAgainSim.py
+++ b/auto/Wrap/libBornAgainSim.py
@@ -3536,8 +3536,8 @@ class ScatteringSimulation(ISimulation2D):
 
     def __init__(self, beam, sample, detector):
         r"""
-        __init__(ScatteringSimulation self, Beam const & beam, MultiLayer const & sample, IDetector const & detector) -> ScatteringSimulation
-        ScatteringSimulation::ScatteringSimulation(const Beam &beam, const MultiLayer &sample, const IDetector &detector)
+        __init__(ScatteringSimulation self, Beam const & beam, MultiLayer const & sample, IDetector2D const & detector) -> ScatteringSimulation
+        ScatteringSimulation::ScatteringSimulation(const Beam &beam, const MultiLayer &sample, const IDetector2D &detector)
 
         """
         _libBornAgainSim.ScatteringSimulation_swiginit(self, _libBornAgainSim.new_ScatteringSimulation(beam, sample, detector))
@@ -3742,7 +3742,7 @@ class OffSpecularSimulation(ISimulation2D):
 
     def __init__(self, *args):
         r"""
-        __init__(OffSpecularSimulation self, Beam const & beam, MultiLayer const & sample, IDetector const & detector) -> OffSpecularSimulation
+        __init__(OffSpecularSimulation self, Beam const & beam, MultiLayer const & sample, IDetector2D const & detector) -> OffSpecularSimulation
         __init__(OffSpecularSimulation self) -> OffSpecularSimulation
         OffSpecularSimulation::OffSpecularSimulation()
 
diff --git a/auto/Wrap/libBornAgainSim_wrap.cpp b/auto/Wrap/libBornAgainSim_wrap.cpp
index d915e53885f..66ab5bbcf56 100644
--- a/auto/Wrap/libBornAgainSim_wrap.cpp
+++ b/auto/Wrap/libBornAgainSim_wrap.cpp
@@ -3109,92 +3109,93 @@ namespace Swig {
 #define SWIGTYPE_p_IChiSquaredModule swig_types[9]
 #define SWIGTYPE_p_ICloneable swig_types[10]
 #define SWIGTYPE_p_IDetector swig_types[11]
-#define SWIGTYPE_p_IDistribution1D swig_types[12]
-#define SWIGTYPE_p_IFootprintFactor swig_types[13]
-#define SWIGTYPE_p_IIntensityFunction swig_types[14]
-#define SWIGTYPE_p_INode swig_types[15]
-#define SWIGTYPE_p_IRangedDistribution swig_types[16]
-#define SWIGTYPE_p_ISampleNode swig_types[17]
-#define SWIGTYPE_p_IShape2D swig_types[18]
-#define SWIGTYPE_p_ISimulation swig_types[19]
-#define SWIGTYPE_p_ISimulation2D swig_types[20]
-#define SWIGTYPE_p_ISpecularScan swig_types[21]
-#define SWIGTYPE_p_IVarianceFunction swig_types[22]
-#define SWIGTYPE_p_IntensityFunctionLog swig_types[23]
-#define SWIGTYPE_p_IntensityFunctionSqrt swig_types[24]
-#define SWIGTYPE_p_IterationInfo swig_types[25]
-#define SWIGTYPE_p_MultiLayer swig_types[26]
-#define SWIGTYPE_p_OffSpecularSimulation swig_types[27]
-#define SWIGTYPE_p_ParameterDistribution swig_types[28]
-#define SWIGTYPE_p_PoissonBackground swig_types[29]
-#define SWIGTYPE_p_PyBuilderCallback swig_types[30]
-#define SWIGTYPE_p_PyObserverCallback swig_types[31]
-#define SWIGTYPE_p_QzScan swig_types[32]
-#define SWIGTYPE_p_RealLimits swig_types[33]
-#define SWIGTYPE_p_ScanResolution swig_types[34]
-#define SWIGTYPE_p_ScatteringSimulation swig_types[35]
-#define SWIGTYPE_p_SimulationOptions swig_types[36]
-#define SWIGTYPE_p_SimulationResult swig_types[37]
-#define SWIGTYPE_p_SpecularSimulation swig_types[38]
-#define SWIGTYPE_p_VarianceConstantFunction swig_types[39]
-#define SWIGTYPE_p_VarianceSimFunction swig_types[40]
-#define SWIGTYPE_p_Vec3T_double_t swig_types[41]
-#define SWIGTYPE_p_Vec3T_int_t swig_types[42]
-#define SWIGTYPE_p_Vec3T_std__complexT_double_t_t swig_types[43]
-#define SWIGTYPE_p_allocator_type swig_types[44]
-#define SWIGTYPE_p_char swig_types[45]
-#define SWIGTYPE_p_difference_type swig_types[46]
-#define SWIGTYPE_p_first_type swig_types[47]
-#define SWIGTYPE_p_int swig_types[48]
-#define SWIGTYPE_p_key_type swig_types[49]
-#define SWIGTYPE_p_long_long swig_types[50]
-#define SWIGTYPE_p_mapped_type swig_types[51]
-#define SWIGTYPE_p_mumufit__MinimizerResult swig_types[52]
-#define SWIGTYPE_p_mumufit__Parameters swig_types[53]
-#define SWIGTYPE_p_p_PyObject swig_types[54]
-#define SWIGTYPE_p_second_type swig_types[55]
-#define SWIGTYPE_p_short swig_types[56]
-#define SWIGTYPE_p_signed_char swig_types[57]
-#define SWIGTYPE_p_size_type swig_types[58]
-#define SWIGTYPE_p_std__allocatorT_AxisInfo_t swig_types[59]
-#define SWIGTYPE_p_std__allocatorT_INode_const_p_t swig_types[60]
-#define SWIGTYPE_p_std__allocatorT_INode_p_t swig_types[61]
-#define SWIGTYPE_p_std__allocatorT_Vec3T_double_t_t swig_types[62]
-#define SWIGTYPE_p_std__allocatorT_double_t swig_types[63]
-#define SWIGTYPE_p_std__allocatorT_int_t swig_types[64]
-#define SWIGTYPE_p_std__allocatorT_std__complexT_double_t_t swig_types[65]
-#define SWIGTYPE_p_std__allocatorT_std__pairT_double_double_t_t swig_types[66]
-#define SWIGTYPE_p_std__allocatorT_std__pairT_std__string_const_double_t_t swig_types[67]
-#define SWIGTYPE_p_std__allocatorT_std__string_t swig_types[68]
-#define SWIGTYPE_p_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t swig_types[69]
-#define SWIGTYPE_p_std__allocatorT_std__vectorT_int_std__allocatorT_int_t_t_t swig_types[70]
-#define SWIGTYPE_p_std__allocatorT_unsigned_long_t swig_types[71]
-#define SWIGTYPE_p_std__complexT_double_t swig_types[72]
-#define SWIGTYPE_p_std__invalid_argument swig_types[73]
-#define SWIGTYPE_p_std__lessT_std__string_t swig_types[74]
-#define SWIGTYPE_p_std__mapT_std__string_double_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_double_t_t_t swig_types[75]
-#define SWIGTYPE_p_std__pairT_double_double_t swig_types[76]
-#define SWIGTYPE_p_std__vectorT_AxisInfo_std__allocatorT_AxisInfo_t_t swig_types[77]
-#define SWIGTYPE_p_std__vectorT_INode_const_p_std__allocatorT_INode_const_p_t_t swig_types[78]
-#define SWIGTYPE_p_std__vectorT_INode_p_std__allocatorT_INode_p_t_t swig_types[79]
-#define SWIGTYPE_p_std__vectorT_ParaMeta_std__allocatorT_ParaMeta_t_t swig_types[80]
-#define SWIGTYPE_p_std__vectorT_Vec3T_double_t_std__allocatorT_Vec3T_double_t_t_t swig_types[81]
-#define SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t swig_types[82]
-#define SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t swig_types[83]
-#define SWIGTYPE_p_std__vectorT_std__complexT_double_t_std__allocatorT_std__complexT_double_t_t_t swig_types[84]
-#define SWIGTYPE_p_std__vectorT_std__pairT_double_double_t_std__allocatorT_std__pairT_double_double_t_t_t swig_types[85]
-#define SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t swig_types[86]
-#define SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t swig_types[87]
-#define SWIGTYPE_p_std__vectorT_std__vectorT_int_std__allocatorT_int_t_t_std__allocatorT_std__vectorT_int_std__allocatorT_int_t_t_t_t swig_types[88]
-#define SWIGTYPE_p_std__vectorT_unsigned_long_std__allocatorT_unsigned_long_t_t swig_types[89]
-#define SWIGTYPE_p_swig__SwigPyIterator swig_types[90]
-#define SWIGTYPE_p_unsigned_char swig_types[91]
-#define SWIGTYPE_p_unsigned_int swig_types[92]
-#define SWIGTYPE_p_unsigned_long_long swig_types[93]
-#define SWIGTYPE_p_unsigned_short swig_types[94]
-#define SWIGTYPE_p_value_type swig_types[95]
-static swig_type_info *swig_types[97];
-static swig_module_info swig_module = {swig_types, 96, 0, 0, 0, 0};
+#define SWIGTYPE_p_IDetector2D swig_types[12]
+#define SWIGTYPE_p_IDistribution1D swig_types[13]
+#define SWIGTYPE_p_IFootprintFactor swig_types[14]
+#define SWIGTYPE_p_IIntensityFunction swig_types[15]
+#define SWIGTYPE_p_INode swig_types[16]
+#define SWIGTYPE_p_IRangedDistribution swig_types[17]
+#define SWIGTYPE_p_ISampleNode swig_types[18]
+#define SWIGTYPE_p_IShape2D swig_types[19]
+#define SWIGTYPE_p_ISimulation swig_types[20]
+#define SWIGTYPE_p_ISimulation2D swig_types[21]
+#define SWIGTYPE_p_ISpecularScan swig_types[22]
+#define SWIGTYPE_p_IVarianceFunction swig_types[23]
+#define SWIGTYPE_p_IntensityFunctionLog swig_types[24]
+#define SWIGTYPE_p_IntensityFunctionSqrt swig_types[25]
+#define SWIGTYPE_p_IterationInfo swig_types[26]
+#define SWIGTYPE_p_MultiLayer swig_types[27]
+#define SWIGTYPE_p_OffSpecularSimulation swig_types[28]
+#define SWIGTYPE_p_ParameterDistribution swig_types[29]
+#define SWIGTYPE_p_PoissonBackground swig_types[30]
+#define SWIGTYPE_p_PyBuilderCallback swig_types[31]
+#define SWIGTYPE_p_PyObserverCallback swig_types[32]
+#define SWIGTYPE_p_QzScan swig_types[33]
+#define SWIGTYPE_p_RealLimits swig_types[34]
+#define SWIGTYPE_p_ScanResolution swig_types[35]
+#define SWIGTYPE_p_ScatteringSimulation swig_types[36]
+#define SWIGTYPE_p_SimulationOptions swig_types[37]
+#define SWIGTYPE_p_SimulationResult swig_types[38]
+#define SWIGTYPE_p_SpecularSimulation swig_types[39]
+#define SWIGTYPE_p_VarianceConstantFunction swig_types[40]
+#define SWIGTYPE_p_VarianceSimFunction swig_types[41]
+#define SWIGTYPE_p_Vec3T_double_t swig_types[42]
+#define SWIGTYPE_p_Vec3T_int_t swig_types[43]
+#define SWIGTYPE_p_Vec3T_std__complexT_double_t_t swig_types[44]
+#define SWIGTYPE_p_allocator_type swig_types[45]
+#define SWIGTYPE_p_char swig_types[46]
+#define SWIGTYPE_p_difference_type swig_types[47]
+#define SWIGTYPE_p_first_type swig_types[48]
+#define SWIGTYPE_p_int swig_types[49]
+#define SWIGTYPE_p_key_type swig_types[50]
+#define SWIGTYPE_p_long_long swig_types[51]
+#define SWIGTYPE_p_mapped_type swig_types[52]
+#define SWIGTYPE_p_mumufit__MinimizerResult swig_types[53]
+#define SWIGTYPE_p_mumufit__Parameters swig_types[54]
+#define SWIGTYPE_p_p_PyObject swig_types[55]
+#define SWIGTYPE_p_second_type swig_types[56]
+#define SWIGTYPE_p_short swig_types[57]
+#define SWIGTYPE_p_signed_char swig_types[58]
+#define SWIGTYPE_p_size_type swig_types[59]
+#define SWIGTYPE_p_std__allocatorT_AxisInfo_t swig_types[60]
+#define SWIGTYPE_p_std__allocatorT_INode_const_p_t swig_types[61]
+#define SWIGTYPE_p_std__allocatorT_INode_p_t swig_types[62]
+#define SWIGTYPE_p_std__allocatorT_Vec3T_double_t_t swig_types[63]
+#define SWIGTYPE_p_std__allocatorT_double_t swig_types[64]
+#define SWIGTYPE_p_std__allocatorT_int_t swig_types[65]
+#define SWIGTYPE_p_std__allocatorT_std__complexT_double_t_t swig_types[66]
+#define SWIGTYPE_p_std__allocatorT_std__pairT_double_double_t_t swig_types[67]
+#define SWIGTYPE_p_std__allocatorT_std__pairT_std__string_const_double_t_t swig_types[68]
+#define SWIGTYPE_p_std__allocatorT_std__string_t swig_types[69]
+#define SWIGTYPE_p_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t swig_types[70]
+#define SWIGTYPE_p_std__allocatorT_std__vectorT_int_std__allocatorT_int_t_t_t swig_types[71]
+#define SWIGTYPE_p_std__allocatorT_unsigned_long_t swig_types[72]
+#define SWIGTYPE_p_std__complexT_double_t swig_types[73]
+#define SWIGTYPE_p_std__invalid_argument swig_types[74]
+#define SWIGTYPE_p_std__lessT_std__string_t swig_types[75]
+#define SWIGTYPE_p_std__mapT_std__string_double_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_double_t_t_t swig_types[76]
+#define SWIGTYPE_p_std__pairT_double_double_t swig_types[77]
+#define SWIGTYPE_p_std__vectorT_AxisInfo_std__allocatorT_AxisInfo_t_t swig_types[78]
+#define SWIGTYPE_p_std__vectorT_INode_const_p_std__allocatorT_INode_const_p_t_t swig_types[79]
+#define SWIGTYPE_p_std__vectorT_INode_p_std__allocatorT_INode_p_t_t swig_types[80]
+#define SWIGTYPE_p_std__vectorT_ParaMeta_std__allocatorT_ParaMeta_t_t swig_types[81]
+#define SWIGTYPE_p_std__vectorT_Vec3T_double_t_std__allocatorT_Vec3T_double_t_t_t swig_types[82]
+#define SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t swig_types[83]
+#define SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t swig_types[84]
+#define SWIGTYPE_p_std__vectorT_std__complexT_double_t_std__allocatorT_std__complexT_double_t_t_t swig_types[85]
+#define SWIGTYPE_p_std__vectorT_std__pairT_double_double_t_std__allocatorT_std__pairT_double_double_t_t_t swig_types[86]
+#define SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t swig_types[87]
+#define SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t swig_types[88]
+#define SWIGTYPE_p_std__vectorT_std__vectorT_int_std__allocatorT_int_t_t_std__allocatorT_std__vectorT_int_std__allocatorT_int_t_t_t_t swig_types[89]
+#define SWIGTYPE_p_std__vectorT_unsigned_long_std__allocatorT_unsigned_long_t_t swig_types[90]
+#define SWIGTYPE_p_swig__SwigPyIterator swig_types[91]
+#define SWIGTYPE_p_unsigned_char swig_types[92]
+#define SWIGTYPE_p_unsigned_int swig_types[93]
+#define SWIGTYPE_p_unsigned_long_long swig_types[94]
+#define SWIGTYPE_p_unsigned_short swig_types[95]
+#define SWIGTYPE_p_value_type swig_types[96]
+static swig_type_info *swig_types[98];
+static swig_module_info swig_module = {swig_types, 97, 0, 0, 0, 0};
 #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
 #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
 
@@ -38010,7 +38011,7 @@ SWIGINTERN PyObject *_wrap_new_ScatteringSimulation(PyObject *SWIGUNUSEDPARM(sel
   PyObject *resultobj = 0;
   Beam *arg1 = 0 ;
   MultiLayer *arg2 = 0 ;
-  IDetector *arg3 = 0 ;
+  IDetector2D *arg3 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 = 0 ;
@@ -38037,15 +38038,15 @@ SWIGINTERN PyObject *_wrap_new_ScatteringSimulation(PyObject *SWIGUNUSEDPARM(sel
     SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_ScatteringSimulation" "', argument " "2"" of type '" "MultiLayer const &""'"); 
   }
   arg2 = reinterpret_cast< MultiLayer * >(argp2);
-  res3 = SWIG_ConvertPtr(swig_obj[2], &argp3, SWIGTYPE_p_IDetector,  0  | 0);
+  res3 = SWIG_ConvertPtr(swig_obj[2], &argp3, SWIGTYPE_p_IDetector2D,  0  | 0);
   if (!SWIG_IsOK(res3)) {
-    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "new_ScatteringSimulation" "', argument " "3"" of type '" "IDetector const &""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "new_ScatteringSimulation" "', argument " "3"" of type '" "IDetector2D const &""'"); 
   }
   if (!argp3) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_ScatteringSimulation" "', argument " "3"" of type '" "IDetector const &""'"); 
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_ScatteringSimulation" "', argument " "3"" of type '" "IDetector2D const &""'"); 
   }
-  arg3 = reinterpret_cast< IDetector * >(argp3);
-  result = (ScatteringSimulation *)new ScatteringSimulation((Beam const &)*arg1,(MultiLayer const &)*arg2,(IDetector const &)*arg3);
+  arg3 = reinterpret_cast< IDetector2D * >(argp3);
+  result = (ScatteringSimulation *)new ScatteringSimulation((Beam const &)*arg1,(MultiLayer const &)*arg2,(IDetector2D const &)*arg3);
   resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ScatteringSimulation, SWIG_POINTER_NEW |  0 );
   return resultobj;
 fail:
@@ -38744,7 +38745,7 @@ SWIGINTERN PyObject *_wrap_new_OffSpecularSimulation__SWIG_0(PyObject *SWIGUNUSE
   PyObject *resultobj = 0;
   Beam *arg1 = 0 ;
   MultiLayer *arg2 = 0 ;
-  IDetector *arg3 = 0 ;
+  IDetector2D *arg3 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 = 0 ;
@@ -38770,15 +38771,15 @@ SWIGINTERN PyObject *_wrap_new_OffSpecularSimulation__SWIG_0(PyObject *SWIGUNUSE
     SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_OffSpecularSimulation" "', argument " "2"" of type '" "MultiLayer const &""'"); 
   }
   arg2 = reinterpret_cast< MultiLayer * >(argp2);
-  res3 = SWIG_ConvertPtr(swig_obj[2], &argp3, SWIGTYPE_p_IDetector,  0  | 0);
+  res3 = SWIG_ConvertPtr(swig_obj[2], &argp3, SWIGTYPE_p_IDetector2D,  0  | 0);
   if (!SWIG_IsOK(res3)) {
-    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "new_OffSpecularSimulation" "', argument " "3"" of type '" "IDetector const &""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "new_OffSpecularSimulation" "', argument " "3"" of type '" "IDetector2D const &""'"); 
   }
   if (!argp3) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_OffSpecularSimulation" "', argument " "3"" of type '" "IDetector const &""'"); 
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_OffSpecularSimulation" "', argument " "3"" of type '" "IDetector2D const &""'"); 
   }
-  arg3 = reinterpret_cast< IDetector * >(argp3);
-  result = (OffSpecularSimulation *)new OffSpecularSimulation((Beam const &)*arg1,(MultiLayer const &)*arg2,(IDetector const &)*arg3);
+  arg3 = reinterpret_cast< IDetector2D * >(argp3);
+  result = (OffSpecularSimulation *)new OffSpecularSimulation((Beam const &)*arg1,(MultiLayer const &)*arg2,(IDetector2D const &)*arg3);
   resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OffSpecularSimulation, SWIG_POINTER_NEW |  0 );
   return resultobj;
 fail:
@@ -38818,7 +38819,7 @@ SWIGINTERN PyObject *_wrap_new_OffSpecularSimulation(PyObject *self, PyObject *a
       int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_MultiLayer, SWIG_POINTER_NO_NULL | 0);
       _v = SWIG_CheckState(res);
       if (_v) {
-        int res = SWIG_ConvertPtr(argv[2], 0, SWIGTYPE_p_IDetector, SWIG_POINTER_NO_NULL | 0);
+        int res = SWIG_ConvertPtr(argv[2], 0, SWIGTYPE_p_IDetector2D, SWIG_POINTER_NO_NULL | 0);
         _v = SWIG_CheckState(res);
         if (_v) {
           return _wrap_new_OffSpecularSimulation__SWIG_0(self, argc, argv);
@@ -38830,7 +38831,7 @@ SWIGINTERN PyObject *_wrap_new_OffSpecularSimulation(PyObject *self, PyObject *a
 fail:
   SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'new_OffSpecularSimulation'.\n"
     "  Possible C/C++ prototypes are:\n"
-    "    OffSpecularSimulation::OffSpecularSimulation(Beam const &,MultiLayer const &,IDetector const &)\n"
+    "    OffSpecularSimulation::OffSpecularSimulation(Beam const &,MultiLayer const &,IDetector2D const &)\n"
     "    OffSpecularSimulation::OffSpecularSimulation()\n");
   return 0;
 }
@@ -41915,8 +41916,8 @@ static PyMethodDef SwigMethods[] = {
 		""},
 	 { "ISimulation2D_swigregister", ISimulation2D_swigregister, METH_O, NULL},
 	 { "new_ScatteringSimulation", _wrap_new_ScatteringSimulation, METH_VARARGS, "\n"
-		"new_ScatteringSimulation(Beam const & beam, MultiLayer const & sample, IDetector const & detector) -> ScatteringSimulation\n"
-		"ScatteringSimulation::ScatteringSimulation(const Beam &beam, const MultiLayer &sample, const IDetector &detector)\n"
+		"new_ScatteringSimulation(Beam const & beam, MultiLayer const & sample, IDetector2D const & detector) -> ScatteringSimulation\n"
+		"ScatteringSimulation::ScatteringSimulation(const Beam &beam, const MultiLayer &sample, const IDetector2D &detector)\n"
 		"\n"
 		""},
 	 { "delete_ScatteringSimulation", _wrap_delete_ScatteringSimulation, METH_O, "\n"
@@ -42037,7 +42038,7 @@ static PyMethodDef SwigMethods[] = {
 	 { "SpecularSimulation_swigregister", SpecularSimulation_swigregister, METH_O, NULL},
 	 { "SpecularSimulation_swiginit", SpecularSimulation_swiginit, METH_VARARGS, NULL},
 	 { "new_OffSpecularSimulation", _wrap_new_OffSpecularSimulation, METH_VARARGS, "\n"
-		"OffSpecularSimulation(Beam const & beam, MultiLayer const & sample, IDetector const & detector)\n"
+		"OffSpecularSimulation(Beam const & beam, MultiLayer const & sample, IDetector2D const & detector)\n"
 		"new_OffSpecularSimulation() -> OffSpecularSimulation\n"
 		"OffSpecularSimulation::OffSpecularSimulation()\n"
 		"\n"
@@ -42481,6 +42482,7 @@ static swig_type_info _swigt__p_IChiSquaredModule = {"_p_IChiSquaredModule", "IC
 static swig_type_info _swigt__p_ICloneable = {"_p_ICloneable", "ICloneable *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_ISampleNode = {"_p_ISampleNode", 0, 0, 0, 0, 0};
 static swig_type_info _swigt__p_IDetector = {"_p_IDetector", "IDetector *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_IDetector2D = {"_p_IDetector2D", "IDetector2D *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_IDistribution1D = {"_p_IDistribution1D", "IDistribution1D *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_IFootprintFactor = {"_p_IFootprintFactor", "IFootprintFactor *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_IIntensityFunction = {"_p_IIntensityFunction", "IIntensityFunction *", 0, 0, (void*)0, 0};
@@ -42578,6 +42580,7 @@ static swig_type_info *swig_type_initial[] = {
   &_swigt__p_IChiSquaredModule,
   &_swigt__p_ICloneable,
   &_swigt__p_IDetector,
+  &_swigt__p_IDetector2D,
   &_swigt__p_IDistribution1D,
   &_swigt__p_IFootprintFactor,
   &_swigt__p_IIntensityFunction,
@@ -42677,6 +42680,7 @@ static swig_cast_info _swigc__p_IChiSquaredModule[] = {  {&_swigt__p_IChiSquared
 static swig_cast_info _swigc__p_ISampleNode[] = {{&_swigt__p_ISampleNode, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_ICloneable[] = {  {&_swigt__p_ScanResolution, _p_ScanResolutionTo_p_ICloneable, 0, 0},  {&_swigt__p_IChiSquaredModule, _p_IChiSquaredModuleTo_p_ICloneable, 0, 0},  {&_swigt__p_ChiSquaredModule, _p_ChiSquaredModuleTo_p_ICloneable, 0, 0},  {&_swigt__p_QzScan, _p_QzScanTo_p_ICloneable, 0, 0},  {&_swigt__p_AlphaScan, _p_AlphaScanTo_p_ICloneable, 0, 0},  {&_swigt__p_IBackground, _p_IBackgroundTo_p_ICloneable, 0, 0},  {&_swigt__p_ConstantBackground, _p_ConstantBackgroundTo_p_ICloneable, 0, 0},  {&_swigt__p_PoissonBackground, _p_PoissonBackgroundTo_p_ICloneable, 0, 0},  {&_swigt__p_ICloneable, 0, 0, 0},  {&_swigt__p_ISampleNode, _p_ISampleNodeTo_p_ICloneable, 0, 0},  {&_swigt__p_ISpecularScan, _p_ISpecularScanTo_p_ICloneable, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_IDetector[] = {  {&_swigt__p_IDetector, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_IDetector2D[] = {  {&_swigt__p_IDetector2D, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_IDistribution1D[] = {  {&_swigt__p_IDistribution1D, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_IFootprintFactor[] = {  {&_swigt__p_IFootprintFactor, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_IIntensityFunction[] = {  {&_swigt__p_IntensityFunctionSqrt, _p_IntensityFunctionSqrtTo_p_IIntensityFunction, 0, 0},  {&_swigt__p_IIntensityFunction, 0, 0, 0},  {&_swigt__p_IntensityFunctionLog, _p_IntensityFunctionLogTo_p_IIntensityFunction, 0, 0},{0, 0, 0, 0}};
@@ -42774,6 +42778,7 @@ static swig_cast_info *swig_cast_initial[] = {
   _swigc__p_IChiSquaredModule,
   _swigc__p_ICloneable,
   _swigc__p_IDetector,
+  _swigc__p_IDetector2D,
   _swigc__p_IDistribution1D,
   _swigc__p_IFootprintFactor,
   _swigc__p_IIntensityFunction,
-- 
GitLab


From db03aa9255aba3fff493af4406f3d8733b13a591 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 18:07:51 +0200
Subject: [PATCH 30/63] rm getDetector()

---
 GUI/Model/Device/Instrument.cpp      | 10 ----------
 GUI/Model/Device/Instrument.h        |  4 +---
 GUI/Model/Device/InstrumentItems.cpp |  8 ++------
 3 files changed, 3 insertions(+), 19 deletions(-)

diff --git a/GUI/Model/Device/Instrument.cpp b/GUI/Model/Device/Instrument.cpp
index e3cc7cdfbae..1fedcd70855 100644
--- a/GUI/Model/Device/Instrument.cpp
+++ b/GUI/Model/Device/Instrument.cpp
@@ -23,13 +23,3 @@ Instrument::Instrument(const Beam& beam, const IDetector2D& detector)
 }
 
 Instrument::~Instrument() = default;
-
-const IDetector2D* Instrument::getDetector() const
-{
-    return m_detector.get();
-}
-
-const IDetector2D& Instrument::detector() const
-{
-    return *m_detector;
-}
diff --git a/GUI/Model/Device/Instrument.h b/GUI/Model/Device/Instrument.h
index 3f21d567079..12ada5bb769 100644
--- a/GUI/Model/Device/Instrument.h
+++ b/GUI/Model/Device/Instrument.h
@@ -29,9 +29,7 @@ public:
     ~Instrument();
 
     const Beam& beam() const { return *m_beam; }
-
-    const IDetector2D* getDetector() const;
-    const IDetector2D& detector() const;
+    const IDetector2D& detector() const { return *m_detector; }
 
 protected:
     std::unique_ptr<Beam> m_beam;
diff --git a/GUI/Model/Device/InstrumentItems.cpp b/GUI/Model/Device/InstrumentItems.cpp
index 3e79bc0eba5..b61556352b5 100644
--- a/GUI/Model/Device/InstrumentItems.cpp
+++ b/GUI/Model/Device/InstrumentItems.cpp
@@ -410,9 +410,7 @@ QString GISASInstrumentItem::instrumentType() const
 ICoordSystem* GISASInstrumentItem::createCoordSystem() const
 {
     const auto instrument = createInstrument();
-    const auto* det2D = dynamic_cast<const IDetector2D*>(instrument->getDetector());
-    ASSERT(det2D);
-    return det2D->scatteringCoords(instrument->beam());
+    return instrument->detector().scatteringCoords(instrument->beam());
 }
 
 //  ************************************************************************************************
@@ -471,9 +469,7 @@ ICoordSystem* OffSpecularInstrumentItem::createCoordSystem() const
                                         m_alphaAxis.min() * Units::deg,
                                         m_alphaAxis.max() * Units::deg);
     const auto instrument = createInstrument();
-    const auto* const detector2d = dynamic_cast<const IDetector2D*>(instrument->getDetector());
-    ASSERT(detector2d);
-    return detector2d->offspecCoords(alphaAxis, instrument->beam().direction());
+    return instrument->detector().offspecCoords(alphaAxis, instrument->beam().direction());
 }
 
 //  ************************************************************************************************
-- 
GitLab


From 1b942296eb86968730c22c3142705acc47cb9c9f Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 18:11:33 +0200
Subject: [PATCH 31/63] + TODO note

---
 GUI/Model/Device/Instrument.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/GUI/Model/Device/Instrument.cpp b/GUI/Model/Device/Instrument.cpp
index 1fedcd70855..4dcd051de10 100644
--- a/GUI/Model/Device/Instrument.cpp
+++ b/GUI/Model/Device/Instrument.cpp
@@ -17,7 +17,7 @@
 #include "Device/Detector/IDetector2D.h"
 
 Instrument::Instrument(const Beam& beam, const IDetector2D& detector)
-    : m_beam(beam.clone())
+    : m_beam(beam.clone())          // TODO take ownership of pointer arg instead of cloning
     , m_detector(detector.clone())
 {
 }
-- 
GitLab


From cad46184b7ec16512bae74e1c1c9684f45e7450d Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 18:26:54 +0200
Subject: [PATCH 32/63] rename ->  m_polAnalyzer

---
 Device/Detector/IDetector.cpp | 6 +++---
 Device/Detector/IDetector.h   | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/Device/Detector/IDetector.cpp b/Device/Detector/IDetector.cpp
index f2f4893d7a4..2e2c1f9bdac 100644
--- a/Device/Detector/IDetector.cpp
+++ b/Device/Detector/IDetector.cpp
@@ -24,7 +24,7 @@ IDetector::IDetector(const IDetector& other)
     : INode()
     , m_explicitROI(other.m_explicitROI)
     , m_axes(other.m_axes)
-    , m_detection_properties(other.m_detection_properties)
+    , m_polAnalyzer(other.m_polAnalyzer)
 {
     if (other.m_detector_resolution)
         setDetectorResolution(*other.m_detector_resolution);
@@ -141,7 +141,7 @@ size_t IDetector::detectorIndexToRegionOfInterestIndex(const size_t detectorInde
 void IDetector::setAnalyzer(const R3 direction, double efficiency, double total_transmission)
 {
     if (direction.mag()>0)
-        m_detection_properties.setDirEffTra(direction, efficiency, total_transmission);
+        m_polAnalyzer.setDirEffTra(direction, efficiency, total_transmission);
 }
 
 void IDetector::setDetectorResolution(const IDetectorResolution& p_detector_resolution)
@@ -243,7 +243,7 @@ std::pair<double, double> IDetector::regionOfInterestBounds(size_t iAxis) const
 
 std::vector<const INode*> IDetector::nodeChildren() const
 {
-    return std::vector<const INode*>() << &m_detection_properties << m_detector_resolution;
+    return std::vector<const INode*>() << &m_polAnalyzer << m_detector_resolution;
 }
 
 void IDetector::iterateOverRegionOfInterest(std::function<void(const_iterator)> func) const
diff --git a/Device/Detector/IDetector.h b/Device/Detector/IDetector.h
index 066e8c30dcd..cdbd98ebc51 100644
--- a/Device/Detector/IDetector.h
+++ b/Device/Detector/IDetector.h
@@ -156,7 +156,7 @@ public:
     std::unique_ptr<Powerfield<double>> createDetectorMap() const;
 
     //! Returns detection properties
-    const PolFilter& analyzer() const { return m_detection_properties; }
+    const PolFilter& analyzer() const { return m_polAnalyzer; }
 #endif // SWIG
 
     //! Returns new intensity map with resolution applied, and cropped to ROI if applicable.
@@ -216,7 +216,7 @@ private:
                               const std::vector<std::unique_ptr<DiffuseElement>>& elements) const;
 
     OwningVector<IAxis> m_axes;
-    PolFilter m_detection_properties;
+    PolFilter m_polAnalyzer;
     std::unique_ptr<IDetectorResolution> m_detector_resolution;
 #endif // SWIG
 };
-- 
GitLab


From 93107d60607ac9fadee515eac2ac3c1667f50272 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 18:27:16 +0200
Subject: [PATCH 33/63] clang-format

---
 Device/Coord/CoordSystem2D.cpp                |  5 ++---
 Device/Detector/IDetector.cpp                 |  2 +-
 Device/Detector/RectangularDetector.cpp       |  4 ++--
 Device/Detector/SphericalDetector.cpp         |  4 ++--
 GUI/Model/Device/Instrument.cpp               |  2 +-
 GUI/Model/Device/InstrumentItems.cpp          | 19 +++++++++----------
 GUI/Model/Model/JobFunctions.cpp              |  2 +-
 GUI/Model/To/DomainSimulationBuilder.cpp      |  2 +-
 GUI/View/FromDomain/FromDomain.cpp            |  2 +-
 Sim/Fitting/SimDataPair.cpp                   |  1 -
 Sim/Simulation/ISimulation.cpp                |  2 +-
 Sim/Simulation/ISimulation.h                  |  2 +-
 Sim/Simulation/SpecularSimulation.cpp         |  1 -
 Tests/Functional/Suite/MakeSimulations.cpp    |  2 +-
 Tests/Unit/Device/DepthProbeConverterTest.cpp |  2 +-
 .../Unit/Device/RectangularConverterTest.cpp  | 12 ++++++------
 16 files changed, 30 insertions(+), 34 deletions(-)

diff --git a/Device/Coord/CoordSystem2D.cpp b/Device/Coord/CoordSystem2D.cpp
index 3da5a3084e3..2720200418c 100644
--- a/Device/Coord/CoordSystem2D.cpp
+++ b/Device/Coord/CoordSystem2D.cpp
@@ -185,9 +185,8 @@ std::vector<std::map<Coords, std::string>> SphericalCoords::createNameMaps() con
 //  class ImageCoords
 //  ************************************************************************************************
 
-ImageCoords::ImageCoords(const OwningVector<IAxis>& axes,
-                         RectangularPixel* regionOfInterestPixel, const Direction& direction,
-                         double wavelength)
+ImageCoords::ImageCoords(const OwningVector<IAxis>& axes, RectangularPixel* regionOfInterestPixel,
+                         const Direction& direction, double wavelength)
     : CoordSystem2D(axes, direction, wavelength)
     , m_detector_pixel(regionOfInterestPixel)
 {
diff --git a/Device/Detector/IDetector.cpp b/Device/Detector/IDetector.cpp
index 2e2c1f9bdac..edd6b3f69b0 100644
--- a/Device/Detector/IDetector.cpp
+++ b/Device/Detector/IDetector.cpp
@@ -140,7 +140,7 @@ size_t IDetector::detectorIndexToRegionOfInterestIndex(const size_t detectorInde
 
 void IDetector::setAnalyzer(const R3 direction, double efficiency, double total_transmission)
 {
-    if (direction.mag()>0)
+    if (direction.mag() > 0)
         m_polAnalyzer.setDirEffTra(direction, efficiency, total_transmission);
 }
 
diff --git a/Device/Detector/RectangularDetector.cpp b/Device/Detector/RectangularDetector.cpp
index 72331b2e9d5..137d988449d 100644
--- a/Device/Detector/RectangularDetector.cpp
+++ b/Device/Detector/RectangularDetector.cpp
@@ -273,8 +273,8 @@ void RectangularDetector::initUandV(double alpha_i)
     }
 }
 
-ICoordSystem* RectangularDetector::offspecCoords(
-    IAxis* beamAxis, const Direction& beamDirection) const
+ICoordSystem* RectangularDetector::offspecCoords(IAxis* beamAxis,
+                                                 const Direction& beamDirection) const
 {
     const auto axes = axesClippedToRegionOfInterest();
     ASSERT(axes.size() == 2);
diff --git a/Device/Detector/SphericalDetector.cpp b/Device/Detector/SphericalDetector.cpp
index 761aca48ebd..705ba8af708 100644
--- a/Device/Detector/SphericalDetector.cpp
+++ b/Device/Detector/SphericalDetector.cpp
@@ -79,8 +79,8 @@ size_t SphericalDetector::indexOfSpecular(const Beam& beam) const
     return totalSize();
 }
 
-ICoordSystem* SphericalDetector::offspecCoords(
-    IAxis* beamAxis, const Direction& beamDirection) const
+ICoordSystem* SphericalDetector::offspecCoords(IAxis* beamAxis,
+                                               const Direction& beamDirection) const
 {
     const auto axes = axesClippedToRegionOfInterest();
     ASSERT(axes.size() == 2);
diff --git a/GUI/Model/Device/Instrument.cpp b/GUI/Model/Device/Instrument.cpp
index 4dcd051de10..35229cd6889 100644
--- a/GUI/Model/Device/Instrument.cpp
+++ b/GUI/Model/Device/Instrument.cpp
@@ -17,7 +17,7 @@
 #include "Device/Detector/IDetector2D.h"
 
 Instrument::Instrument(const Beam& beam, const IDetector2D& detector)
-    : m_beam(beam.clone())          // TODO take ownership of pointer arg instead of cloning
+    : m_beam(beam.clone()) // TODO take ownership of pointer arg instead of cloning
     , m_detector(detector.clone())
 {
 }
diff --git a/GUI/Model/Device/InstrumentItems.cpp b/GUI/Model/Device/InstrumentItems.cpp
index b61556352b5..88099968855 100644
--- a/GUI/Model/Device/InstrumentItems.cpp
+++ b/GUI/Model/Device/InstrumentItems.cpp
@@ -20,7 +20,6 @@
 #include "Device/Coord/CoordSystem2D.h"
 #include "Device/Detector/RectangularDetector.h"
 #include "Device/Detector/SphericalDetector.h"
-#include "GUI/Model/Device/Instrument.h"
 #include "GUI/Model/CatDevice/BackgroundItemCatalog.h"
 #include "GUI/Model/CatDevice/DetectorItemCatalog.h"
 #include "GUI/Model/CatDevice/InstrumentItemCatalog.h"
@@ -28,6 +27,7 @@
 #include "GUI/Model/Device/BackgroundItems.h"
 #include "GUI/Model/Device/BeamWavelengthItem.h"
 #include "GUI/Model/Device/DetectorItems.h"
+#include "GUI/Model/Device/Instrument.h"
 #include "GUI/Model/Device/PointwiseAxisItem.h"
 #include "GUI/Model/Device/RectangularDetectorItem.h"
 #include "GUI/Model/Device/SphericalDetectorItem.h"
@@ -227,12 +227,12 @@ ICoordSystem* SpecularInstrumentItem::createCoordSystem() const
         if (!pointwise_axis->axis()) // workaround for loading project
             return nullptr;
         Coords native_units = GUI::Util::CoordName::coordFromName(pointwise_axis->getUnitsLabel());
-        return new AngularReflectometryCoordinates(beam->wavelength(),
-                                                   *pointwise_axis->axis(), native_units);
+        return new AngularReflectometryCoordinates(beam->wavelength(), *pointwise_axis->axis(),
+                                                   native_units);
     }
 
-    return new AngularReflectometryCoordinates(beam->wavelength(),
-                                               *axis_item->createAxis(1.0), Coords::DEGREES);
+    return new AngularReflectometryCoordinates(beam->wavelength(), *axis_item->createAxis(1.0),
+                                               Coords::DEGREES);
 }
 
 QString SpecularInstrumentItem::instrumentType() const
@@ -366,8 +366,7 @@ std::unique_ptr<Instrument> Instrument2DItem::createInstrument() const
     // TODO: Why not check "if (withPolarizerAnalyzer())"? But if it is inserted, some of the unit
     // tests fail (because in the unit tests this flag is never set to true)
     // The Unit test are e.g. TestGuiStd/Std/MagneticCylinders
-    detector->setAnalyzer(
-            m_analyzerDirection, m_analyzerEfficiency, m_analyzerTotalTransmission);
+    detector->setAnalyzer(m_analyzerDirection, m_analyzerEfficiency, m_analyzerTotalTransmission);
 
     std::unique_ptr<Instrument> instrument(new Instrument(*beam, *detector));
 
@@ -465,9 +464,9 @@ QString OffSpecularInstrumentItem::instrumentType() const
 
 ICoordSystem* OffSpecularInstrumentItem::createCoordSystem() const
 {
-    IAxis* alphaAxis = new FixedBinAxis("alpha", m_alphaAxis.nbins(),
-                                        m_alphaAxis.min() * Units::deg,
-                                        m_alphaAxis.max() * Units::deg);
+    IAxis* alphaAxis =
+        new FixedBinAxis("alpha", m_alphaAxis.nbins(), m_alphaAxis.min() * Units::deg,
+                         m_alphaAxis.max() * Units::deg);
     const auto instrument = createInstrument();
     return instrument->detector().offspecCoords(alphaAxis, instrument->beam().direction());
 }
diff --git a/GUI/Model/Model/JobFunctions.cpp b/GUI/Model/Model/JobFunctions.cpp
index 211f6918783..5a6b41659bd 100644
--- a/GUI/Model/Model/JobFunctions.cpp
+++ b/GUI/Model/Model/JobFunctions.cpp
@@ -15,13 +15,13 @@
 #include "GUI/Model/Model/JobFunctions.h"
 #include "Base/Util/Assert.h"
 #include "Device/Detector/IDetector2D.h"
-#include "GUI/Model/Device/Instrument.h"
 #include "GUI/Model/Data/Data1DViewItem.h"
 #include "GUI/Model/Data/DataPropertyContainer.h"
 #include "GUI/Model/Data/IntensityDataItem.h"
 #include "GUI/Model/Data/JobItemUtils.h"
 #include "GUI/Model/Data/RealDataItem.h"
 #include "GUI/Model/Data/SpecularDataItem.h"
+#include "GUI/Model/Device/Instrument.h"
 #include "GUI/Model/Device/InstrumentItems.h"
 #include "GUI/Model/Device/PointwiseAxisItem.h"
 #include "GUI/Model/Job/FitSuiteItem.h"
diff --git a/GUI/Model/To/DomainSimulationBuilder.cpp b/GUI/Model/To/DomainSimulationBuilder.cpp
index db786957dbf..2ba0d96ffad 100644
--- a/GUI/Model/To/DomainSimulationBuilder.cpp
+++ b/GUI/Model/To/DomainSimulationBuilder.cpp
@@ -17,12 +17,12 @@
 #include "Base/Util/Assert.h"
 #include "Device/Beam/Beam.h"
 #include "Device/Beam/IFootprintFactor.h"
-#include "GUI/Model/Device/Instrument.h"
 #include "GUI/Model/Device/AxesItems.h"
 #include "GUI/Model/Device/BackgroundItems.h"
 #include "GUI/Model/Device/BeamAngleItems.h"
 #include "GUI/Model/Device/BeamWavelengthItem.h"
 #include "GUI/Model/Device/FootprintItems.h"
+#include "GUI/Model/Device/Instrument.h"
 #include "GUI/Model/Device/InstrumentItems.h"
 #include "GUI/Model/Sample/MultiLayerItem.h"
 #include "GUI/Model/To/ToDomain.h"
diff --git a/GUI/View/FromDomain/FromDomain.cpp b/GUI/View/FromDomain/FromDomain.cpp
index 1c774142e4a..f7d451c7757 100644
--- a/GUI/View/FromDomain/FromDomain.cpp
+++ b/GUI/View/FromDomain/FromDomain.cpp
@@ -492,7 +492,7 @@ void GUI::Transform::FromDomain::setSpecularBeamItem(SpecularBeamItem* beam_item
 }
 
 void GUI::Transform::FromDomain::updateDetector(Instrument2DItem* instrument_item,
-                                             const ISimulation2D& simulation)
+                                                const ISimulation2D& simulation)
 {
     const IDetector& detector = simulation.detector();
     setDetectorGeometry(instrument_item, detector);
diff --git a/Sim/Fitting/SimDataPair.cpp b/Sim/Fitting/SimDataPair.cpp
index a0eb75d851c..531e783a413 100644
--- a/Sim/Fitting/SimDataPair.cpp
+++ b/Sim/Fitting/SimDataPair.cpp
@@ -151,7 +151,6 @@ void SimDataPair::execSimulation(const mumufit::Parameters& params)
         auto dummy_array = std::make_unique<Powerfield<double>>(converter.defaultAxes());
         m_uncertainties = SimulationResult(*dummy_array, converter);
     }
-
 }
 
 bool SimDataPair::containsUncertainties() const
diff --git a/Sim/Simulation/ISimulation.cpp b/Sim/Simulation/ISimulation.cpp
index b1b0e630c3a..aa171fce490 100644
--- a/Sim/Simulation/ISimulation.cpp
+++ b/Sim/Simulation/ISimulation.cpp
@@ -18,8 +18,8 @@
 #include "Base/Util/StringUtils.h"
 #include "Device/Beam/Beam.h"
 #include "Device/Detector/IDetector.h"
-#include "Device/Histo/SimulationResult.h"
 #include "Device/Detector/SphericalDetector.h"
+#include "Device/Histo/SimulationResult.h"
 #include "Resample/Options/SimulationOptions.h"
 #include "Resample/Processed/ReSample.h"
 #include "Sample/Multilayer/MultiLayer.h"
diff --git a/Sim/Simulation/ISimulation.h b/Sim/Simulation/ISimulation.h
index 87823cf2e7d..582309d2614 100644
--- a/Sim/Simulation/ISimulation.h
+++ b/Sim/Simulation/ISimulation.h
@@ -15,8 +15,8 @@
 #ifndef BORNAGAIN_SIM_SIMULATION_ISIMULATION_H
 #define BORNAGAIN_SIM_SIMULATION_ISIMULATION_H
 
-#include "Param/Node/INode.h"
 #include "Param/Distrib/DistributionHandler.h"
+#include "Param/Node/INode.h"
 
 template <class T>
 class Powerfield;
diff --git a/Sim/Simulation/SpecularSimulation.cpp b/Sim/Simulation/SpecularSimulation.cpp
index 5fa3af3cec9..076952cfeea 100644
--- a/Sim/Simulation/SpecularSimulation.cpp
+++ b/Sim/Simulation/SpecularSimulation.cpp
@@ -54,7 +54,6 @@ std::unique_ptr<AlphaScan> mangledScan(const AlphaScan& scan, const Beam& beam)
 SpecularSimulation::SpecularSimulation()
 {
     m_detector.reset(new SpecularDetector1D);
-
 }
 
 SpecularSimulation::~SpecularSimulation() = default;
diff --git a/Tests/Functional/Suite/MakeSimulations.cpp b/Tests/Functional/Suite/MakeSimulations.cpp
index f793bb860bb..3222c21f8a3 100644
--- a/Tests/Functional/Suite/MakeSimulations.cpp
+++ b/Tests/Functional/Suite/MakeSimulations.cpp
@@ -316,7 +316,7 @@ test::makeSimulation::ExtraLongWavelengthGISAS(const MultiLayer& sample)
 //! Beam intensity set to provide reasonably large values in detector channels.
 std::unique_ptr<ScatteringSimulation> test::makeSimulation::MiniGISASFit(const MultiLayer& sample)
 {
-    Beam beam(1e6, 1*angstrom, Direction(0.2 * deg, 0));
+    Beam beam(1e6, 1 * angstrom, Direction(0.2 * deg, 0));
     SphericalDetector detector(25, -2 * deg, 2 * deg, 25, 0, 2 * deg);
     return std::make_unique<ScatteringSimulation>(beam, sample, detector);
 }
diff --git a/Tests/Unit/Device/DepthProbeConverterTest.cpp b/Tests/Unit/Device/DepthProbeConverterTest.cpp
index 71305888b56..5b30a962274 100644
--- a/Tests/Unit/Device/DepthProbeConverterTest.cpp
+++ b/Tests/Unit/Device/DepthProbeConverterTest.cpp
@@ -24,7 +24,7 @@ protected:
 DepthProbeCoordinatesTest::DepthProbeCoordinatesTest()
     : m_beam(Beam::horizontalBeam())
     , m_axes({new FixedBinAxis("Angles", m_nbins, m_alpha_start, m_alpha_end), // angles in radians
-            new FixedBinAxis("Positions", m_nbins, m_z_start, m_z_end) })         // z positions in nm
+              new FixedBinAxis("Positions", m_nbins, m_z_start, m_z_end)})     // z positions in nm
 {
 }
 
diff --git a/Tests/Unit/Device/RectangularConverterTest.cpp b/Tests/Unit/Device/RectangularConverterTest.cpp
index 694c8109764..2f788e93e4d 100644
--- a/Tests/Unit/Device/RectangularConverterTest.cpp
+++ b/Tests/Unit/Device/RectangularConverterTest.cpp
@@ -47,8 +47,8 @@ RectangularConverterTest::RectangularConverterTest()
 TEST_F(RectangularConverterTest, ImageCoords)
 {
     ImageCoords converter(m_detector.axesClippedToRegionOfInterest(),
-                          m_detector.regionOfInterestPixel(),
-                          m_beam.direction(), m_beam.wavelength());
+                          m_detector.regionOfInterestPixel(), m_beam.direction(),
+                          m_beam.wavelength());
 
     EXPECT_EQ(converter.rank(), 2u);
 
@@ -107,8 +107,8 @@ TEST_F(RectangularConverterTest, ImageCoords)
 TEST_F(RectangularConverterTest, ImageCoordsClone)
 {
     ImageCoords converter(m_detector.axesClippedToRegionOfInterest(),
-                          m_detector.regionOfInterestPixel(),
-                          m_beam.direction(), m_beam.wavelength());
+                          m_detector.regionOfInterestPixel(), m_beam.direction(),
+                          m_beam.wavelength());
     std::unique_ptr<ImageCoords> P_clone(converter.clone());
 
     EXPECT_EQ(P_clone->rank(), 2u);
@@ -160,8 +160,8 @@ TEST_F(RectangularConverterTest, ImageCoordsWithROI)
 
     m_detector.setRegionOfInterest(roi_xmin, roi_ymin, roi_xmax, roi_ymax);
     ImageCoords converter(m_detector.axesClippedToRegionOfInterest(),
-                          m_detector.regionOfInterestPixel(),
-                          m_beam.direction(), m_beam.wavelength());
+                          m_detector.regionOfInterestPixel(), m_beam.direction(),
+                          m_beam.wavelength());
 
     EXPECT_EQ(converter.calculateMin(0, Coords::UNDEFINED), 100);
     EXPECT_EQ(converter.calculateMax(0, Coords::UNDEFINED), 152);
-- 
GitLab


From 2d024f9f451ba70508258e75ddb68472178257a1 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 18:28:31 +0200
Subject: [PATCH 34/63] rename -> m_beamPolarization

---
 Device/Beam/Beam.cpp | 14 +++++++-------
 Device/Beam/Beam.h   |  2 +-
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/Device/Beam/Beam.cpp b/Device/Beam/Beam.cpp
index 40847f5a820..c36cf6f3f52 100644
--- a/Device/Beam/Beam.cpp
+++ b/Device/Beam/Beam.cpp
@@ -53,7 +53,7 @@ Beam Beam::horizontalBeam()
 Beam::Beam(const Beam& other)
     : Beam(other.m_intensity, other.m_wavelength, other.direction())
 {
-    m_bloch_vector = other.m_bloch_vector;
+    m_beamPolarization = other.m_beamPolarization;
     if (other.m_shape_factor)
         m_shape_factor.reset(other.m_shape_factor->clone());
 }
@@ -67,7 +67,7 @@ Beam& Beam::operator=(const Beam& other)
     // m_direction = other.m_direction;
     m_alpha = other.m_alpha;
     m_phi = other.m_phi;
-    m_bloch_vector = other.m_bloch_vector;
+    m_beamPolarization = other.m_beamPolarization;
     if (other.m_shape_factor)
         m_shape_factor.reset(other.m_shape_factor->clone());
     else
@@ -144,19 +144,19 @@ void Beam::setPolarization(const R3 bloch_vector)
             "Beam::setPolarization: "
             "The given Bloch vector cannot represent a real physical ensemble");
     }
-    m_bloch_vector = bloch_vector;
+    m_beamPolarization = bloch_vector;
 }
 
 R3 Beam::getBlochVector() const
 {
-    return m_bloch_vector;
+    return m_beamPolarization;
 }
 
 SpinMatrix Beam::getPolarization() const
 {
-    double x = m_bloch_vector.x();
-    double y = m_bloch_vector.y();
-    double z = m_bloch_vector.z();
+    double x = m_beamPolarization.x();
+    double y = m_beamPolarization.y();
+    double z = m_beamPolarization.z();
     return {(1.0 + z) / 2.0, complex_t(x, -y) / 2.0, complex_t(x, y) / 2.0, (1.0 - z) / 2.0};
 }
 
diff --git a/Device/Beam/Beam.h b/Device/Beam/Beam.h
index 5d7031a4e30..9b4e72d197d 100644
--- a/Device/Beam/Beam.h
+++ b/Device/Beam/Beam.h
@@ -83,7 +83,7 @@ private:
     double m_alpha;
     double m_phi;
     std::unique_ptr<IFootprintFactor> m_shape_factor; //!< footprint correction handler
-    R3 m_bloch_vector; //!< Bloch vector encoding the beam's polarization
+    R3 m_beamPolarization; //!< Bloch vector encoding the beam's polarization
 
     RealLimits m_alphaLimits;
 
-- 
GitLab


From 8e322a8a28d12c259cb1f80b87e50977721aaef9 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 18:43:21 +0200
Subject: [PATCH 35/63] call setPolarization from ISimulation

---
 Examples/scatter2d/MagneticSpheres.py         |  2 +-
 .../specular/BasicPolarizedReflectometry.py   |  2 +-
 Examples/specular/PolarizedNoAnalyzer.py      |  2 +-
 .../PolarizedNonperfectAnalyzerPolarizer.py   |  2 +-
 Examples/specular/PolarizedSpinAsymmetry.py   |  2 +-
 Examples/specular/PolarizedSpinFlip.py        |  2 +-
 Sim/Simulation/ISimulation.cpp                |  5 ++
 Sim/Simulation/ISimulation.h                  |  4 ++
 Tests/Functional/Suite/MakeSimulations.cpp    |  6 +-
 Tests/Unit/Sim/SpecularSimulationTest.cpp     |  4 +-
 auto/Wrap/doxygenDevice.i                     | 59 -------------------
 auto/Wrap/doxygenSim.i                        |  5 ++
 auto/Wrap/libBornAgainSim.py                  | 10 ++++
 auto/Wrap/libBornAgainSim_wrap.cpp            | 44 ++++++++++++++
 14 files changed, 79 insertions(+), 70 deletions(-)

diff --git a/Examples/scatter2d/MagneticSpheres.py b/Examples/scatter2d/MagneticSpheres.py
index c1483742f71..04a0ad72f27 100755
--- a/Examples/scatter2d/MagneticSpheres.py
+++ b/Examples/scatter2d/MagneticSpheres.py
@@ -53,7 +53,7 @@ def get_simulation(sample):
 
     polarizer_dir = R3(0, 0, 1)
     analyzer_dir = R3(0, 0, -1)
-    simulation.beam().setPolarization(polarizer_dir)
+    simulation.setPolarization(polarizer_dir)
     simulation.detector().setAnalyzer(analyzer_dir, 1, 0.5)
 
     return simulation
diff --git a/Examples/specular/BasicPolarizedReflectometry.py b/Examples/specular/BasicPolarizedReflectometry.py
index c45f2dae4e4..d733db72200 100755
--- a/Examples/specular/BasicPolarizedReflectometry.py
+++ b/Examples/specular/BasicPolarizedReflectometry.py
@@ -49,7 +49,7 @@ def simulate(polarizer_dir, analyzer_dir, title):
     simulation.setScan(scan)
     simulation.setSample(get_sample())
 
-    simulation.beam().setPolarization(polarizer_dir)
+    simulation.setPolarization(polarizer_dir)
     simulation.detector().setAnalyzer(analyzer_dir, 1, 0.5)
 
     result = simulation.simulate()
diff --git a/Examples/specular/PolarizedNoAnalyzer.py b/Examples/specular/PolarizedNoAnalyzer.py
index a3310d890a7..b1d51f7bdf5 100755
--- a/Examples/specular/PolarizedNoAnalyzer.py
+++ b/Examples/specular/PolarizedNoAnalyzer.py
@@ -56,7 +56,7 @@ def run_simulation(polarizer_dir=R3(0, 1, 0), analyzer_dir=None):
     simulation = get_simulation(sample)
 
     # adding polarizer and analyzer operator
-    simulation.beam().setPolarization(polarizer_dir)
+    simulation.setPolarization(polarizer_dir)
     if analyzer_dir:
         simulation.detector().setAnalyzer(analyzer_dir, 1, 0.5)
 
diff --git a/Examples/specular/PolarizedNonperfectAnalyzerPolarizer.py b/Examples/specular/PolarizedNonperfectAnalyzerPolarizer.py
index 86ae7c0fa68..15fbf3791a0 100755
--- a/Examples/specular/PolarizedNonperfectAnalyzerPolarizer.py
+++ b/Examples/specular/PolarizedNonperfectAnalyzerPolarizer.py
@@ -80,7 +80,7 @@ def run_simulation(*,
     sample = get_sample()
     simulation = get_simulation(sample)
 
-    simulation.beam().setPolarization(polarizer_dir*polarizer_efficiency)
+    simulation.setPolarization(polarizer_dir*polarizer_efficiency)
     simulation.detector().setAnalyzer(analyzer_dir, analyzer_efficiency, 0.5)
     simulation.setBackground(ba.ConstantBackground(1e-7))
 
diff --git a/Examples/specular/PolarizedSpinAsymmetry.py b/Examples/specular/PolarizedSpinAsymmetry.py
index aa40ca18d42..10f6cb53957 100755
--- a/Examples/specular/PolarizedSpinAsymmetry.py
+++ b/Examples/specular/PolarizedSpinAsymmetry.py
@@ -80,7 +80,7 @@ def get_simulation(q_axis, parameters, polarizer_dir, analyzer_dir):
     distr = ba.RangedDistributionGaussian(n_samples, n_sig)
     scan.setAbsoluteQResolution(distr, parameters["q_res"])
 
-    simulation.beam().setPolarization(polarizer_dir)
+    simulation.setPolarization(polarizer_dir)
     simulation.detector().setAnalyzer(analyzer_dir, 1, 0.5)
 
     simulation.setScan(scan)
diff --git a/Examples/specular/PolarizedSpinFlip.py b/Examples/specular/PolarizedSpinFlip.py
index 3bc5cdb4704..109088f228f 100755
--- a/Examples/specular/PolarizedSpinFlip.py
+++ b/Examples/specular/PolarizedSpinFlip.py
@@ -55,7 +55,7 @@ def run_simulation(polarizer_dir=ba.R3(0, 1, 0),
     sample = get_sample()
     simulation = get_simulation(sample)
 
-    simulation.beam().setPolarization(polarizer_dir)
+    simulation.setPolarization(polarizer_dir)
     simulation.detector().setAnalyzer(analyzer_dir, 1, 0.5)
 
     return simulation.simulate()
diff --git a/Sim/Simulation/ISimulation.cpp b/Sim/Simulation/ISimulation.cpp
index aa171fce490..d85c8b41692 100644
--- a/Sim/Simulation/ISimulation.cpp
+++ b/Sim/Simulation/ISimulation.cpp
@@ -174,6 +174,11 @@ void ISimulation::setTerminalProgressMonitor()
     });
 }
 
+void ISimulation::setPolarization(R3 bloch_vector)
+{
+    beam().setPolarization(bloch_vector);
+}
+
 void ISimulation::prepareSimulation()
 {
     if (!m_sample)
diff --git a/Sim/Simulation/ISimulation.h b/Sim/Simulation/ISimulation.h
index 582309d2614..ce037f41f81 100644
--- a/Sim/Simulation/ISimulation.h
+++ b/Sim/Simulation/ISimulation.h
@@ -17,6 +17,7 @@
 
 #include "Param/Distrib/DistributionHandler.h"
 #include "Param/Node/INode.h"
+#include <heinz/Vectors3D.h>
 
 template <class T>
 class Powerfield;
@@ -71,6 +72,9 @@ public:
     Beam& beam() { return *m_beam; }
     IDetector& detector() { return *m_detector; }
 
+    //! Sets the polarization density matrix according to the given Bloch vector
+    void setPolarization(R3 bloch_vector);
+
 #ifndef SWIG
     void subscribe(const std::function<bool(size_t)>& inform);
 
diff --git a/Tests/Functional/Suite/MakeSimulations.cpp b/Tests/Functional/Suite/MakeSimulations.cpp
index 3222c21f8a3..592f7374693 100644
--- a/Tests/Functional/Suite/MakeSimulations.cpp
+++ b/Tests/Functional/Suite/MakeSimulations.cpp
@@ -111,7 +111,7 @@ std::unique_ptr<ScatteringSimulation> test::makeSimulation::BasicGISAS(const Mul
 std::unique_ptr<ScatteringSimulation> test::makeSimulation::SpinflipGISAS(const MultiLayer& sample)
 {
     std::unique_ptr<ScatteringSimulation> result = BasicGISAS(sample);
-    result->beam().setPolarization(zplus);
+    result->setPolarization(zplus);
     result->detector().setAnalyzer(zplus, -1.0, 0.5);
     return result;
 }
@@ -204,7 +204,7 @@ std::unique_ptr<ScatteringSimulation> test::makeSimulation::MaxiGISAS(const Mult
 std::unique_ptr<ScatteringSimulation> test::makeSimulation::MaxiGISAS00(const MultiLayer& sample)
 {
     std::unique_ptr<ScatteringSimulation> result = MaxiGISAS(sample);
-    result->beam().setPolarization(zplus);
+    result->setPolarization(zplus);
     result->detector().setAnalyzer(zplus, 1.0, 0.5);
     return result;
 }
@@ -391,7 +391,7 @@ test::makeSimulation::BasicYPolarizedSpecular(const MultiLayer& sample, const st
 {
     const auto yCase = YPolarizationCases.at(polCase);
     auto simulation = BasicSpecular(sample, vsQ);
-    simulation->beam().setPolarization(yCase.first);
+    simulation->setPolarization(yCase.first);
     simulation->detector().setAnalyzer(yCase.second, 1.0, 0.5);
     simulation->setSample(sample);
     return simulation;
diff --git a/Tests/Unit/Sim/SpecularSimulationTest.cpp b/Tests/Unit/Sim/SpecularSimulationTest.cpp
index 4e007b1c2c2..0fdaad9a290 100644
--- a/Tests/Unit/Sim/SpecularSimulationTest.cpp
+++ b/Tests/Unit/Sim/SpecularSimulationTest.cpp
@@ -91,7 +91,7 @@ TEST_F(SpecularSimulationTest, SetAngularScan)
     AlphaScan scan4(1.0, 10, .0 * Units::deg, 2.0 * Units::deg);
     const auto polarizer_dir = R3({0., 0., 0.876});
     const auto analyzer_dir = R3({0., 0., 1.});
-    sim4.beam().setPolarization(polarizer_dir);
+    sim4.setPolarization(polarizer_dir);
     sim4.detector().setAnalyzer(analyzer_dir, 0.33, 0.22);
     sim4.setScan(scan4);
     EXPECT_FAILED_ASSERT(sim4.setScan(scan4));
@@ -145,7 +145,7 @@ TEST_F(SpecularSimulationTest, SetQScan)
     QzScan scan3(10, 1.0, 10.0);
     const auto polarizer_dir = R3({0., 0., 0.876});
     const auto analyzer_dir = R3({0., 0., 1.});
-    sim3.beam().setPolarization(polarizer_dir);
+    sim3.setPolarization(polarizer_dir);
     sim3.detector().setAnalyzer(analyzer_dir, 0.33, 0.22);
     sim3.setScan(scan3);
 
diff --git a/auto/Wrap/doxygenDevice.i b/auto/Wrap/doxygenDevice.i
index 5a1f2119b51..d62d9b57eda 100644
--- a/auto/Wrap/doxygenDevice.i
+++ b/auto/Wrap/doxygenDevice.i
@@ -1499,56 +1499,6 @@ Returns true if area defined by two bins is inside or on border of polygon (more
 ";
 
 
-// File: classInstrument.xml
-%feature("docstring") Instrument "
-
-Assembles beam, detector and their relative positions with respect to the sample.
-
-C++ includes: Instrument.h
-";
-
-%feature("docstring")  Instrument::Instrument "Instrument::Instrument()
-";
-
-%feature("docstring")  Instrument::Instrument "Instrument::Instrument(const Beam &beam, const IDetector &detector)
-";
-
-%feature("docstring")  Instrument::Instrument "Instrument::Instrument(const Instrument &other)
-";
-
-%feature("docstring")  Instrument::~Instrument "Instrument::~Instrument() override
-";
-
-%feature("docstring")  Instrument::className "std::string Instrument::className() const final
-";
-
-%feature("docstring")  Instrument::beam "Beam& Instrument::beam()
-";
-
-%feature("docstring")  Instrument::beam "const Beam& Instrument::beam() const
-";
-
-%feature("docstring")  Instrument::getDetector "IDetector * Instrument::getDetector()
-";
-
-%feature("docstring")  Instrument::getDetector "const IDetector * Instrument::getDetector() const
-";
-
-%feature("docstring")  Instrument::detector "IDetector & Instrument::detector()
-";
-
-%feature("docstring")  Instrument::detector "const IDetector & Instrument::detector() const
-";
-
-%feature("docstring")  Instrument::setDetector "void Instrument::setDetector(const IDetector &detector)
-
-Sets the detector (axes can be overwritten later) 
-";
-
-%feature("docstring")  Instrument::nodeChildren "std::vector< const INode * > Instrument::nodeChildren() const override
-";
-
-
 // File: classIOFactory.xml
 %feature("docstring") IOFactory "
 
@@ -2989,12 +2939,6 @@ make Swappable
 // File: ReadWriteTiff_8h.xml
 
 
-// File: Instrument_8cpp.xml
-
-
-// File: Instrument_8h.xml
-
-
 // File: DetectorMask_8cpp.xml
 
 
@@ -3085,9 +3029,6 @@ make Swappable
 // File: dir_9f013251ba980bff6504d6613b69183d.xml
 
 
-// File: dir_550e786a97bd4c801929243ea9773c04.xml
-
-
 // File: dir_4866552d576e04b61ad8ade47c8db877.xml
 
 
diff --git a/auto/Wrap/doxygenSim.i b/auto/Wrap/doxygenSim.i
index 0820f5320a9..309a91d1d51 100644
--- a/auto/Wrap/doxygenSim.i
+++ b/auto/Wrap/doxygenSim.i
@@ -910,6 +910,11 @@ Initializes a progress monitor that prints to stdout.
 %feature("docstring")  ISimulation::detector "IDetector& ISimulation::detector()
 ";
 
+%feature("docstring")  ISimulation::setPolarization "void ISimulation::setPolarization(R3 bloch_vector)
+
+Sets the polarization density matrix according to the given Bloch vector. 
+";
+
 %feature("docstring")  ISimulation::subscribe "void ISimulation::subscribe(const std::function< bool(size_t)> &inform)
 ";
 
diff --git a/auto/Wrap/libBornAgainSim.py b/auto/Wrap/libBornAgainSim.py
index ce499f33a2c..9050961aeb2 100644
--- a/auto/Wrap/libBornAgainSim.py
+++ b/auto/Wrap/libBornAgainSim.py
@@ -3422,6 +3422,16 @@ class ISimulation(libBornAgainParam.INode):
         """
         return _libBornAgainSim.ISimulation_detector(self)
 
+    def setPolarization(self, bloch_vector):
+        r"""
+        setPolarization(ISimulation self, R3 bloch_vector)
+        void ISimulation::setPolarization(R3 bloch_vector)
+
+        Sets the polarization density matrix according to the given Bloch vector. 
+
+        """
+        return _libBornAgainSim.ISimulation_setPolarization(self, bloch_vector)
+
 # Register ISimulation in _libBornAgainSim:
 _libBornAgainSim.ISimulation_swigregister(ISimulation)
 
diff --git a/auto/Wrap/libBornAgainSim_wrap.cpp b/auto/Wrap/libBornAgainSim_wrap.cpp
index 66ab5bbcf56..cb2aa8e4216 100644
--- a/auto/Wrap/libBornAgainSim_wrap.cpp
+++ b/auto/Wrap/libBornAgainSim_wrap.cpp
@@ -37707,6 +37707,43 @@ fail:
 }
 
 
+SWIGINTERN PyObject *_wrap_ISimulation_setPolarization(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  ISimulation *arg1 = (ISimulation *) 0 ;
+  R3 arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 ;
+  int res2 = 0 ;
+  PyObject *swig_obj[2] ;
+  
+  if (!SWIG_Python_UnpackTuple(args, "ISimulation_setPolarization", 2, 2, swig_obj)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ISimulation, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ISimulation_setPolarization" "', argument " "1"" of type '" "ISimulation *""'"); 
+  }
+  arg1 = reinterpret_cast< ISimulation * >(argp1);
+  {
+    res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_Vec3T_double_t,  0  | 0);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ISimulation_setPolarization" "', argument " "2"" of type '" "R3""'"); 
+    }  
+    if (!argp2) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "ISimulation_setPolarization" "', argument " "2"" of type '" "R3""'");
+    } else {
+      R3 * temp = reinterpret_cast< R3 * >(argp2);
+      arg2 = *temp;
+      if (SWIG_IsNewObj(res2)) delete temp;
+    }
+  }
+  (arg1)->setPolarization(arg2);
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
 SWIGINTERN PyObject *ISimulation_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *obj;
   if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL;
@@ -41850,6 +41887,13 @@ static PyMethodDef SwigMethods[] = {
 		"const IDetector& ISimulation::detector() const\n"
 		"\n"
 		""},
+	 { "ISimulation_setPolarization", _wrap_ISimulation_setPolarization, METH_VARARGS, "\n"
+		"ISimulation_setPolarization(ISimulation self, R3 bloch_vector)\n"
+		"void ISimulation::setPolarization(R3 bloch_vector)\n"
+		"\n"
+		"Sets the polarization density matrix according to the given Bloch vector. \n"
+		"\n"
+		""},
 	 { "ISimulation_swigregister", ISimulation_swigregister, METH_O, NULL},
 	 { "delete_ISimulation2D", _wrap_delete_ISimulation2D, METH_O, "\n"
 		"delete_ISimulation2D(ISimulation2D self)\n"
-- 
GitLab


From 7d2bae0e64d12e18300f4bec25dc09f7e2fe18f6 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 19:09:07 +0200
Subject: [PATCH 36/63] Examples use ISimulation::setPolarization

---
 Examples/scatter2d/MagneticCylinders2.py | 4 +++-
 Examples/scatter2d/PolarizedSANS.py      | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/Examples/scatter2d/MagneticCylinders2.py b/Examples/scatter2d/MagneticCylinders2.py
index 45894e6c5c9..24a41b8db46 100755
--- a/Examples/scatter2d/MagneticCylinders2.py
+++ b/Examples/scatter2d/MagneticCylinders2.py
@@ -37,10 +37,12 @@ def get_simulation(sample, pol_dir, efficiency):
     z_up = R3(0, 0, 1)
     n = bp.simargs['n']
     beam = ba.Beam(1e9, 0.1*nm, ba.Direction(0.2*deg, 0))
-    beam.setPolarization(pol_dir)
     detector = ba.SphericalDetector(n, -1*deg, 1*deg, n, 0, 2*deg)
     detector.setAnalyzer(z_up, efficiency, 0.5)
     simulation = ba.ScatteringSimulation(beam, sample, detector)
+
+    simulation.setPolarization(pol_dir)
+
     return simulation
 
 def simulate(title, pol_dir, efficiency):
diff --git a/Examples/scatter2d/PolarizedSANS.py b/Examples/scatter2d/PolarizedSANS.py
index 2a3206773ff..e5e9f28ff60 100755
--- a/Examples/scatter2d/PolarizedSANS.py
+++ b/Examples/scatter2d/PolarizedSANS.py
@@ -57,7 +57,6 @@ def get_simulation(sample):
 
     # Beam from above (perpendicular to sample):
     beam = ba.Beam(1, 0.4*nm, ba.Direction(90*deg, 0))
-    beam.setPolarization(R3(0, 1, 0))
 
     # Detector opposite to source:
     detPos = 2000  # distance from sample center to detector in mm
@@ -67,6 +66,8 @@ def get_simulation(sample):
     det.setAnalyzer(R3(0, -1, 0), 1, 0.5)
     sim = ba.ScatteringSimulation(beam, sample, det)
 
+    sim.setPolarization(R3(0, 1, 0))
+
     return sim
 
 
-- 
GitLab


From 248b1dd78b6860db5498518046cfc11ac0b5ff8c Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 19:16:07 +0200
Subject: [PATCH 37/63] MakeSimulations use ISimulation::setPolarization

---
 Tests/Functional/Suite/MakeSimulations.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/Tests/Functional/Suite/MakeSimulations.cpp b/Tests/Functional/Suite/MakeSimulations.cpp
index 592f7374693..69c3268d63d 100644
--- a/Tests/Functional/Suite/MakeSimulations.cpp
+++ b/Tests/Functional/Suite/MakeSimulations.cpp
@@ -90,10 +90,11 @@ test::makeSimulation::MiniZPolarizedGISAS(const MultiLayer& sample, const std::s
 {
     const auto zCase = ZPolarizationCases.at(polCase);
     Beam beam(1.0, 1 * angstrom, Direction(0.2 * deg, 0));
-    beam.setPolarization(zCase.first);
     SphericalDetector det(25, -2 * deg, 2 * deg, 25, 0, 2 * deg);
     det.setAnalyzer(zCase.second, 1., .5);
-    return std::make_unique<ScatteringSimulation>(beam, sample, det);
+    auto sim = std::make_unique<ScatteringSimulation>(beam, sample, det);
+    sim->setPolarization(zCase.first);
+    return sim;
 }
 
 
-- 
GitLab


From 4121a309e50b9c544dc488b3dd5c1903d81341a0 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 19:26:11 +0200
Subject: [PATCH 38/63] setAnalyzer called from ISimulation

---
 Examples/scatter2d/MagneticCylinders2.py      |  3 +-
 Examples/scatter2d/MagneticSpheres.py         |  2 +-
 Examples/scatter2d/PolarizedSANS.py           |  3 +-
 .../specular/BasicPolarizedReflectometry.py   |  2 +-
 Examples/specular/PolarizedNoAnalyzer.py      |  2 +-
 .../PolarizedNonperfectAnalyzerPolarizer.py   |  2 +-
 Examples/specular/PolarizedSpinAsymmetry.py   |  2 +-
 Examples/specular/PolarizedSpinFlip.py        |  2 +-
 Sim/Simulation/ISimulation.cpp                |  6 ++
 Sim/Simulation/ISimulation.h                  |  3 +
 Tests/Unit/Sim/SpecularSimulationTest.cpp     |  4 +-
 auto/Wrap/doxygenSim.i                        |  5 ++
 auto/Wrap/libBornAgainSim.py                  | 10 ++++
 auto/Wrap/libBornAgainSim_wrap.cpp            | 60 +++++++++++++++++++
 14 files changed, 94 insertions(+), 12 deletions(-)

diff --git a/Examples/scatter2d/MagneticCylinders2.py b/Examples/scatter2d/MagneticCylinders2.py
index 24a41b8db46..7e0a9c38f1b 100755
--- a/Examples/scatter2d/MagneticCylinders2.py
+++ b/Examples/scatter2d/MagneticCylinders2.py
@@ -38,11 +38,10 @@ def get_simulation(sample, pol_dir, efficiency):
     n = bp.simargs['n']
     beam = ba.Beam(1e9, 0.1*nm, ba.Direction(0.2*deg, 0))
     detector = ba.SphericalDetector(n, -1*deg, 1*deg, n, 0, 2*deg)
-    detector.setAnalyzer(z_up, efficiency, 0.5)
     simulation = ba.ScatteringSimulation(beam, sample, detector)
 
     simulation.setPolarization(pol_dir)
-
+    simulation.setAnalyzer(z_up, efficiency, 0.5)
     return simulation
 
 def simulate(title, pol_dir, efficiency):
diff --git a/Examples/scatter2d/MagneticSpheres.py b/Examples/scatter2d/MagneticSpheres.py
index 04a0ad72f27..893f8b76caa 100755
--- a/Examples/scatter2d/MagneticSpheres.py
+++ b/Examples/scatter2d/MagneticSpheres.py
@@ -54,7 +54,7 @@ def get_simulation(sample):
     polarizer_dir = R3(0, 0, 1)
     analyzer_dir = R3(0, 0, -1)
     simulation.setPolarization(polarizer_dir)
-    simulation.detector().setAnalyzer(analyzer_dir, 1, 0.5)
+    simulation.setAnalyzer(analyzer_dir, 1, 0.5)
 
     return simulation
 
diff --git a/Examples/scatter2d/PolarizedSANS.py b/Examples/scatter2d/PolarizedSANS.py
index e5e9f28ff60..072d487323a 100755
--- a/Examples/scatter2d/PolarizedSANS.py
+++ b/Examples/scatter2d/PolarizedSANS.py
@@ -63,11 +63,10 @@ def get_simulation(sample):
     detWid = 500  # detector width in mm
     det = ba.RectangularDetector(n, detWid, n, detWid)
     det.setPerpendicularToDirectBeam(detPos, detWid/2, detWid/2)
-    det.setAnalyzer(R3(0, -1, 0), 1, 0.5)
     sim = ba.ScatteringSimulation(beam, sample, det)
 
     sim.setPolarization(R3(0, 1, 0))
-
+    sim.setAnalyzer(R3(0, -1, 0), 1, 0.5)
     return sim
 
 
diff --git a/Examples/specular/BasicPolarizedReflectometry.py b/Examples/specular/BasicPolarizedReflectometry.py
index d733db72200..a20d9685c81 100755
--- a/Examples/specular/BasicPolarizedReflectometry.py
+++ b/Examples/specular/BasicPolarizedReflectometry.py
@@ -50,7 +50,7 @@ def simulate(polarizer_dir, analyzer_dir, title):
     simulation.setSample(get_sample())
 
     simulation.setPolarization(polarizer_dir)
-    simulation.detector().setAnalyzer(analyzer_dir, 1, 0.5)
+    simulation.setAnalyzer(analyzer_dir, 1, 0.5)
 
     result = simulation.simulate()
     result.setTitle(title)
diff --git a/Examples/specular/PolarizedNoAnalyzer.py b/Examples/specular/PolarizedNoAnalyzer.py
index b1d51f7bdf5..78a46aa29f0 100755
--- a/Examples/specular/PolarizedNoAnalyzer.py
+++ b/Examples/specular/PolarizedNoAnalyzer.py
@@ -58,7 +58,7 @@ def run_simulation(polarizer_dir=R3(0, 1, 0), analyzer_dir=None):
     # adding polarizer and analyzer operator
     simulation.setPolarization(polarizer_dir)
     if analyzer_dir:
-        simulation.detector().setAnalyzer(analyzer_dir, 1, 0.5)
+        simulation.setAnalyzer(analyzer_dir, 1, 0.5)
 
     result = simulation.simulate()
 
diff --git a/Examples/specular/PolarizedNonperfectAnalyzerPolarizer.py b/Examples/specular/PolarizedNonperfectAnalyzerPolarizer.py
index 15fbf3791a0..03e0f386754 100755
--- a/Examples/specular/PolarizedNonperfectAnalyzerPolarizer.py
+++ b/Examples/specular/PolarizedNonperfectAnalyzerPolarizer.py
@@ -81,7 +81,7 @@ def run_simulation(*,
     simulation = get_simulation(sample)
 
     simulation.setPolarization(polarizer_dir*polarizer_efficiency)
-    simulation.detector().setAnalyzer(analyzer_dir, analyzer_efficiency, 0.5)
+    simulation.setAnalyzer(analyzer_dir, analyzer_efficiency, 0.5)
     simulation.setBackground(ba.ConstantBackground(1e-7))
 
     return simulation.simulate()
diff --git a/Examples/specular/PolarizedSpinAsymmetry.py b/Examples/specular/PolarizedSpinAsymmetry.py
index 10f6cb53957..b1c0fdaeac7 100755
--- a/Examples/specular/PolarizedSpinAsymmetry.py
+++ b/Examples/specular/PolarizedSpinAsymmetry.py
@@ -81,7 +81,7 @@ def get_simulation(q_axis, parameters, polarizer_dir, analyzer_dir):
     scan.setAbsoluteQResolution(distr, parameters["q_res"])
 
     simulation.setPolarization(polarizer_dir)
-    simulation.detector().setAnalyzer(analyzer_dir, 1, 0.5)
+    simulation.setAnalyzer(analyzer_dir, 1, 0.5)
 
     simulation.setScan(scan)
     return simulation
diff --git a/Examples/specular/PolarizedSpinFlip.py b/Examples/specular/PolarizedSpinFlip.py
index 109088f228f..05dee45de5d 100755
--- a/Examples/specular/PolarizedSpinFlip.py
+++ b/Examples/specular/PolarizedSpinFlip.py
@@ -56,7 +56,7 @@ def run_simulation(polarizer_dir=ba.R3(0, 1, 0),
     simulation = get_simulation(sample)
 
     simulation.setPolarization(polarizer_dir)
-    simulation.detector().setAnalyzer(analyzer_dir, 1, 0.5)
+    simulation.setAnalyzer(analyzer_dir, 1, 0.5)
 
     return simulation.simulate()
 
diff --git a/Sim/Simulation/ISimulation.cpp b/Sim/Simulation/ISimulation.cpp
index d85c8b41692..d7c3932df9d 100644
--- a/Sim/Simulation/ISimulation.cpp
+++ b/Sim/Simulation/ISimulation.cpp
@@ -179,6 +179,12 @@ void ISimulation::setPolarization(R3 bloch_vector)
     beam().setPolarization(bloch_vector);
 }
 
+void ISimulation::setAnalyzer(const R3 direction, double efficiency, double total_transmission)
+{
+    detector().setAnalyzer(direction, efficiency, total_transmission);
+}
+
+
 void ISimulation::prepareSimulation()
 {
     if (!m_sample)
diff --git a/Sim/Simulation/ISimulation.h b/Sim/Simulation/ISimulation.h
index ce037f41f81..b69acd42c01 100644
--- a/Sim/Simulation/ISimulation.h
+++ b/Sim/Simulation/ISimulation.h
@@ -75,6 +75,9 @@ public:
     //! Sets the polarization density matrix according to the given Bloch vector
     void setPolarization(R3 bloch_vector);
 
+    //! Sets the polarization analyzer characteristics of the detector
+    void setAnalyzer(R3 direction, double efficiency, double total_transmission);
+
 #ifndef SWIG
     void subscribe(const std::function<bool(size_t)>& inform);
 
diff --git a/Tests/Unit/Sim/SpecularSimulationTest.cpp b/Tests/Unit/Sim/SpecularSimulationTest.cpp
index 0fdaad9a290..6f6e0822854 100644
--- a/Tests/Unit/Sim/SpecularSimulationTest.cpp
+++ b/Tests/Unit/Sim/SpecularSimulationTest.cpp
@@ -92,7 +92,7 @@ TEST_F(SpecularSimulationTest, SetAngularScan)
     const auto polarizer_dir = R3({0., 0., 0.876});
     const auto analyzer_dir = R3({0., 0., 1.});
     sim4.setPolarization(polarizer_dir);
-    sim4.detector().setAnalyzer(analyzer_dir, 0.33, 0.22);
+    sim4.setAnalyzer(analyzer_dir, 0.33, 0.22);
     sim4.setScan(scan4);
     EXPECT_FAILED_ASSERT(sim4.setScan(scan4));
 
@@ -146,7 +146,7 @@ TEST_F(SpecularSimulationTest, SetQScan)
     const auto polarizer_dir = R3({0., 0., 0.876});
     const auto analyzer_dir = R3({0., 0., 1.});
     sim3.setPolarization(polarizer_dir);
-    sim3.detector().setAnalyzer(analyzer_dir, 0.33, 0.22);
+    sim3.setAnalyzer(analyzer_dir, 0.33, 0.22);
     sim3.setScan(scan3);
 
     EXPECT_EQ(1.0, sim3.coordinateAxis()->min());
diff --git a/auto/Wrap/doxygenSim.i b/auto/Wrap/doxygenSim.i
index 309a91d1d51..0a233d2465e 100644
--- a/auto/Wrap/doxygenSim.i
+++ b/auto/Wrap/doxygenSim.i
@@ -915,6 +915,11 @@ Initializes a progress monitor that prints to stdout.
 Sets the polarization density matrix according to the given Bloch vector. 
 ";
 
+%feature("docstring")  ISimulation::setAnalyzer "void ISimulation::setAnalyzer(R3 direction, double efficiency, double total_transmission)
+
+Sets the polarization analyzer characteristics of the detector. 
+";
+
 %feature("docstring")  ISimulation::subscribe "void ISimulation::subscribe(const std::function< bool(size_t)> &inform)
 ";
 
diff --git a/auto/Wrap/libBornAgainSim.py b/auto/Wrap/libBornAgainSim.py
index 9050961aeb2..8865dfa8f1a 100644
--- a/auto/Wrap/libBornAgainSim.py
+++ b/auto/Wrap/libBornAgainSim.py
@@ -3432,6 +3432,16 @@ class ISimulation(libBornAgainParam.INode):
         """
         return _libBornAgainSim.ISimulation_setPolarization(self, bloch_vector)
 
+    def setAnalyzer(self, direction, efficiency, total_transmission):
+        r"""
+        setAnalyzer(ISimulation self, R3 direction, double efficiency, double total_transmission)
+        void ISimulation::setAnalyzer(R3 direction, double efficiency, double total_transmission)
+
+        Sets the polarization analyzer characteristics of the detector. 
+
+        """
+        return _libBornAgainSim.ISimulation_setAnalyzer(self, direction, efficiency, total_transmission)
+
 # Register ISimulation in _libBornAgainSim:
 _libBornAgainSim.ISimulation_swigregister(ISimulation)
 
diff --git a/auto/Wrap/libBornAgainSim_wrap.cpp b/auto/Wrap/libBornAgainSim_wrap.cpp
index cb2aa8e4216..c0ca4016783 100644
--- a/auto/Wrap/libBornAgainSim_wrap.cpp
+++ b/auto/Wrap/libBornAgainSim_wrap.cpp
@@ -37744,6 +37744,59 @@ fail:
 }
 
 
+SWIGINTERN PyObject *_wrap_ISimulation_setAnalyzer(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  ISimulation *arg1 = (ISimulation *) 0 ;
+  R3 arg2 ;
+  double arg3 ;
+  double arg4 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 ;
+  int res2 = 0 ;
+  double val3 ;
+  int ecode3 = 0 ;
+  double val4 ;
+  int ecode4 = 0 ;
+  PyObject *swig_obj[4] ;
+  
+  if (!SWIG_Python_UnpackTuple(args, "ISimulation_setAnalyzer", 4, 4, swig_obj)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ISimulation, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ISimulation_setAnalyzer" "', argument " "1"" of type '" "ISimulation *""'"); 
+  }
+  arg1 = reinterpret_cast< ISimulation * >(argp1);
+  {
+    res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_Vec3T_double_t,  0  | 0);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ISimulation_setAnalyzer" "', argument " "2"" of type '" "R3""'"); 
+    }  
+    if (!argp2) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "ISimulation_setAnalyzer" "', argument " "2"" of type '" "R3""'");
+    } else {
+      R3 * temp = reinterpret_cast< R3 * >(argp2);
+      arg2 = *temp;
+      if (SWIG_IsNewObj(res2)) delete temp;
+    }
+  }
+  ecode3 = SWIG_AsVal_double(swig_obj[2], &val3);
+  if (!SWIG_IsOK(ecode3)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "ISimulation_setAnalyzer" "', argument " "3"" of type '" "double""'");
+  } 
+  arg3 = static_cast< double >(val3);
+  ecode4 = SWIG_AsVal_double(swig_obj[3], &val4);
+  if (!SWIG_IsOK(ecode4)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "ISimulation_setAnalyzer" "', argument " "4"" of type '" "double""'");
+  } 
+  arg4 = static_cast< double >(val4);
+  (arg1)->setAnalyzer(arg2,arg3,arg4);
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
 SWIGINTERN PyObject *ISimulation_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *obj;
   if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL;
@@ -41894,6 +41947,13 @@ static PyMethodDef SwigMethods[] = {
 		"Sets the polarization density matrix according to the given Bloch vector. \n"
 		"\n"
 		""},
+	 { "ISimulation_setAnalyzer", _wrap_ISimulation_setAnalyzer, METH_VARARGS, "\n"
+		"ISimulation_setAnalyzer(ISimulation self, R3 direction, double efficiency, double total_transmission)\n"
+		"void ISimulation::setAnalyzer(R3 direction, double efficiency, double total_transmission)\n"
+		"\n"
+		"Sets the polarization analyzer characteristics of the detector. \n"
+		"\n"
+		""},
 	 { "ISimulation_swigregister", ISimulation_swigregister, METH_O, NULL},
 	 { "delete_ISimulation2D", _wrap_delete_ISimulation2D, METH_O, "\n"
 		"delete_ISimulation2D(ISimulation2D self)\n"
-- 
GitLab


From 2bc13e5bb7b1686f6cea76f74b4003003b8d4e9a Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 19:28:30 +0200
Subject: [PATCH 39/63] ctd

---
 Sim/Export/SimulationToPython.cpp          | 2 +-
 Tests/Functional/Suite/MakeSimulations.cpp | 9 ++++-----
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/Sim/Export/SimulationToPython.cpp b/Sim/Export/SimulationToPython.cpp
index 574955c704d..5d132c4c645 100644
--- a/Sim/Export/SimulationToPython.cpp
+++ b/Sim/Export/SimulationToPython.cpp
@@ -250,7 +250,7 @@ std::string defineDetectorPolarizationAnalysis(const ISimulation* simulation)
                << Py::Fmt::printDouble(analyzer_direction.x()) << ", "
                << Py::Fmt::printDouble(analyzer_direction.y()) << ", "
                << Py::Fmt::printDouble(analyzer_direction.z()) << ")\n";
-        result << indent() << "simulation.detector().setAnalyzer(" << direction_name << ", "
+        result << indent() << "simulation.setAnalyzer(" << direction_name << ", "
                << Py::Fmt::printDouble(analyzer_efficiency) << ", "
                << Py::Fmt::printDouble(analyzer_total_transmission) << ")\n";
     }
diff --git a/Tests/Functional/Suite/MakeSimulations.cpp b/Tests/Functional/Suite/MakeSimulations.cpp
index 69c3268d63d..cd9c81d26f5 100644
--- a/Tests/Functional/Suite/MakeSimulations.cpp
+++ b/Tests/Functional/Suite/MakeSimulations.cpp
@@ -91,9 +91,9 @@ test::makeSimulation::MiniZPolarizedGISAS(const MultiLayer& sample, const std::s
     const auto zCase = ZPolarizationCases.at(polCase);
     Beam beam(1.0, 1 * angstrom, Direction(0.2 * deg, 0));
     SphericalDetector det(25, -2 * deg, 2 * deg, 25, 0, 2 * deg);
-    det.setAnalyzer(zCase.second, 1., .5);
     auto sim = std::make_unique<ScatteringSimulation>(beam, sample, det);
     sim->setPolarization(zCase.first);
+    sim->setAnalyzer(zCase.second, 1., .5);
     return sim;
 }
 
@@ -113,7 +113,7 @@ std::unique_ptr<ScatteringSimulation> test::makeSimulation::SpinflipGISAS(const
 {
     std::unique_ptr<ScatteringSimulation> result = BasicGISAS(sample);
     result->setPolarization(zplus);
-    result->detector().setAnalyzer(zplus, -1.0, 0.5);
+    result->setAnalyzer(zplus, -1.0, 0.5);
     return result;
 }
 
@@ -206,7 +206,7 @@ std::unique_ptr<ScatteringSimulation> test::makeSimulation::MaxiGISAS00(const Mu
 {
     std::unique_ptr<ScatteringSimulation> result = MaxiGISAS(sample);
     result->setPolarization(zplus);
-    result->detector().setAnalyzer(zplus, 1.0, 0.5);
+    result->setAnalyzer(zplus, 1.0, 0.5);
     return result;
 }
 
@@ -393,8 +393,7 @@ test::makeSimulation::BasicYPolarizedSpecular(const MultiLayer& sample, const st
     const auto yCase = YPolarizationCases.at(polCase);
     auto simulation = BasicSpecular(sample, vsQ);
     simulation->setPolarization(yCase.first);
-    simulation->detector().setAnalyzer(yCase.second, 1.0, 0.5);
-    simulation->setSample(sample);
+    simulation->setAnalyzer(yCase.second, 1.0, 0.5);
     return simulation;
 }
 
-- 
GitLab


From 486e0b29572e3c1ebf4bdbcd61808369a91b7a8c Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 19:32:45 +0200
Subject: [PATCH 40/63] rm trivial unit tests of ana/pol in detectors

---
 Tests/Unit/Device/RectangularDetectorTest.cpp | 80 ------------------
 Tests/Unit/Device/SpecularDetector1DTest.cpp  |  7 --
 Tests/Unit/Device/SphericalDetectorTest.cpp   | 81 -------------------
 3 files changed, 168 deletions(-)

diff --git a/Tests/Unit/Device/RectangularDetectorTest.cpp b/Tests/Unit/Device/RectangularDetectorTest.cpp
index 48dd5278a93..253df2927a7 100644
--- a/Tests/Unit/Device/RectangularDetectorTest.cpp
+++ b/Tests/Unit/Device/RectangularDetectorTest.cpp
@@ -141,83 +141,3 @@ TEST_F(RectangularDetectorTest, PerpToReflectedBeamDpos)
     EXPECT_EQ(RectangularDetector::PERPENDICULAR_TO_REFLECTED_BEAM_DPOS,
               det.getDetectorArrangment());
 }
-
-// Test retrieval of analyzer properties
-TEST_F(RectangularDetectorTest, AnalyzerProperties)
-{
-    RectangularDetector detector(50u, 10.0, 60u, 20.0);
-
-    R3 direction;
-    double efficiency = 0.0;
-    double total_transmission = 1.0;
-    R3 unit_direction;
-
-    // zero efficiency
-    direction = R3(1.0, 0.0, 0.0);
-    unit_direction = direction.unit();
-    detector.setAnalyzer(direction, efficiency, total_transmission);
-    const PolFilter& detect_properties = detector.analyzer();
-
-    EXPECT_NEAR(detect_properties.polEfficiency(), efficiency, 1e-8);
-    EXPECT_NEAR(detect_properties.totalTransmission(), total_transmission, 1e-8);
-    // direction vector returned is zero vector because efficiency is zero
-    EXPECT_NEAR(detect_properties.polDirection().x(), 0.0, 1e-8);
-    EXPECT_NEAR(detect_properties.polDirection().y(), 0.0, 1e-8);
-    EXPECT_NEAR(detect_properties.polDirection().z(), 0.0, 1e-8);
-
-    // intermediate efficiency
-    direction = R3(1.0, 0.0, 0.0);
-    efficiency = 0.5;
-    total_transmission = 0.6;
-    unit_direction = direction.unit();
-    detector.setAnalyzer(direction, efficiency, total_transmission);
-    const PolFilter& detect_properties2 = detector.analyzer();
-
-    EXPECT_NEAR(detect_properties2.polEfficiency(), efficiency, 1e-8);
-    EXPECT_NEAR(detect_properties2.totalTransmission(), total_transmission, 1e-8);
-    EXPECT_NEAR(detect_properties2.polDirection().x(), unit_direction.x(), 1e-8);
-    EXPECT_NEAR(detect_properties2.polDirection().y(), unit_direction.y(), 1e-8);
-    EXPECT_NEAR(detect_properties2.polDirection().z(), unit_direction.z(), 1e-8);
-
-    // maximum efficiency
-    direction = R3(1.0, 0.0, 0.0);
-    efficiency = 1.0;
-    total_transmission = 0.5;
-    unit_direction = direction.unit();
-    detector.setAnalyzer(direction, efficiency, total_transmission);
-    const PolFilter& detect_properties3 = detector.analyzer();
-
-    EXPECT_NEAR(detect_properties3.polEfficiency(), efficiency, 1e-8);
-    EXPECT_NEAR(detect_properties3.totalTransmission(), total_transmission, 1e-8);
-    EXPECT_NEAR(detect_properties3.polDirection().x(), unit_direction.x(), 1e-8);
-    EXPECT_NEAR(detect_properties3.polDirection().y(), unit_direction.y(), 1e-8);
-    EXPECT_NEAR(detect_properties3.polDirection().z(), unit_direction.z(), 1e-8);
-
-    // non-axis direction
-    direction = R3(1.0, 2.0, 3.0);
-    efficiency = 1.0;
-    total_transmission = 0.5;
-    unit_direction = direction.unit();
-    detector.setAnalyzer(direction, efficiency, total_transmission);
-    const PolFilter& detect_properties4 = detector.analyzer();
-
-    EXPECT_NEAR(detect_properties4.polEfficiency(), efficiency, 1e-8);
-    EXPECT_NEAR(detect_properties4.totalTransmission(), total_transmission, 1e-8);
-    EXPECT_NEAR(detect_properties4.polDirection().x(), unit_direction.x(), 1e-8);
-    EXPECT_NEAR(detect_properties4.polDirection().y(), unit_direction.y(), 1e-8);
-    EXPECT_NEAR(detect_properties4.polDirection().z(), unit_direction.z(), 1e-8);
-
-    // maximum efficiency and negative efficiency
-    direction = R3(0.0, -1.0, -1.0);
-    efficiency = -1.0;
-    total_transmission = 0.5;
-    unit_direction = direction.unit();
-    detector.setAnalyzer(direction, efficiency, total_transmission);
-    const PolFilter& detect_properties5 = detector.analyzer();
-
-    EXPECT_NEAR(detect_properties5.polEfficiency(), efficiency, 1e-8);
-    EXPECT_NEAR(detect_properties5.totalTransmission(), total_transmission, 1e-8);
-    EXPECT_NEAR(detect_properties5.polDirection().x(), unit_direction.x(), 1e-8);
-    EXPECT_NEAR(detect_properties5.polDirection().y(), unit_direction.y(), 1e-8);
-    EXPECT_NEAR(detect_properties5.polDirection().z(), unit_direction.z(), 1e-8);
-}
diff --git a/Tests/Unit/Device/SpecularDetector1DTest.cpp b/Tests/Unit/Device/SpecularDetector1DTest.cpp
index 6aa80565099..3a7b1e9dfb2 100644
--- a/Tests/Unit/Device/SpecularDetector1DTest.cpp
+++ b/Tests/Unit/Device/SpecularDetector1DTest.cpp
@@ -47,9 +47,6 @@ TEST_F(SpecularDetectorTest, Clone)
     FixedBinAxis axis("axis0", 5, 1.0 * Units::deg, 10.0 * Units::deg);
     SpecularDetector1D detector(axis);
 
-    const auto analyzer = R3({0., 0., 1.});
-    detector.setAnalyzer(analyzer, 0.33, 0.22);
-
     std::unique_ptr<SpecularDetector1D> clone(detector.clone());
 
     const auto data = clone->createDetectorMap();
@@ -66,8 +63,4 @@ TEST_F(SpecularDetectorTest, Clone)
     for (auto it = clone->beginNonMaskedPoints(); it != clone->endNonMaskedPoints(); ++it)
         detectorIndexes.push_back(it.detectorIndex());
     EXPECT_EQ(detectorIndexes, expectedDetectorIndexes);
-
-    EXPECT_EQ(clone->analyzer().polDirection(), analyzer);
-    EXPECT_EQ(clone->analyzer().polEfficiency(), 0.33);
-    EXPECT_EQ(clone->analyzer().totalTransmission(), 0.22);
 }
diff --git a/Tests/Unit/Device/SphericalDetectorTest.cpp b/Tests/Unit/Device/SphericalDetectorTest.cpp
index 118f4a251a3..d1087f1337e 100644
--- a/Tests/Unit/Device/SphericalDetectorTest.cpp
+++ b/Tests/Unit/Device/SphericalDetectorTest.cpp
@@ -207,84 +207,3 @@ TEST_F(SphericalDetectorTest, Clone)
         detectorIndexes.push_back(it.detectorIndex());
     EXPECT_EQ(detectorIndexes, expectedDetectorIndexes);
 }
-
-// Test retrieval of analyzer properties
-TEST_F(SphericalDetectorTest, AnalyzerProperties)
-{
-    SphericalDetector detector(6, -1.0 * Units::deg, 5.0 * Units::deg, 4, 0.0 * Units::deg,
-                               4.0 * Units::deg);
-
-    R3 direction;
-    double efficiency = 0.0;
-    double total_transmission = 1.0;
-    R3 unit_direction;
-
-    // zero efficiency
-    direction = R3(1.0, 0.0, 0.0);
-    unit_direction = direction.unit();
-    detector.setAnalyzer(direction, efficiency, total_transmission);
-    const PolFilter& detect_properties = detector.analyzer();
-
-    EXPECT_NEAR(detect_properties.polEfficiency(), efficiency, 1e-8);
-    EXPECT_NEAR(detect_properties.totalTransmission(), total_transmission, 1e-8);
-    // direction vector returned is zero vector because efficiency is zero
-    EXPECT_NEAR(detect_properties.polDirection().x(), 0.0, 1e-8);
-    EXPECT_NEAR(detect_properties.polDirection().y(), 0.0, 1e-8);
-    EXPECT_NEAR(detect_properties.polDirection().z(), 0.0, 1e-8);
-
-    // intermediate efficiency
-    direction = R3(1.0, 0.0, 0.0);
-    efficiency = 0.5;
-    total_transmission = 0.6;
-    unit_direction = direction.unit();
-    detector.setAnalyzer(direction, efficiency, total_transmission);
-    const PolFilter& detect_properties2 = detector.analyzer();
-
-    EXPECT_NEAR(detect_properties2.polEfficiency(), efficiency, 1e-8);
-    EXPECT_NEAR(detect_properties2.totalTransmission(), total_transmission, 1e-8);
-    EXPECT_NEAR(detect_properties2.polDirection().x(), unit_direction.x(), 1e-8);
-    EXPECT_NEAR(detect_properties2.polDirection().y(), unit_direction.y(), 1e-8);
-    EXPECT_NEAR(detect_properties2.polDirection().z(), unit_direction.z(), 1e-8);
-
-    // maximum efficiency
-    direction = R3(1.0, 0.0, 0.0);
-    efficiency = 1.0;
-    total_transmission = 0.5;
-    unit_direction = direction.unit();
-    detector.setAnalyzer(direction, efficiency, total_transmission);
-    const PolFilter& detect_properties3 = detector.analyzer();
-
-    EXPECT_NEAR(detect_properties3.polEfficiency(), efficiency, 1e-8);
-    EXPECT_NEAR(detect_properties3.totalTransmission(), total_transmission, 1e-8);
-    EXPECT_NEAR(detect_properties3.polDirection().x(), unit_direction.x(), 1e-8);
-    EXPECT_NEAR(detect_properties3.polDirection().y(), unit_direction.y(), 1e-8);
-    EXPECT_NEAR(detect_properties3.polDirection().z(), unit_direction.z(), 1e-8);
-
-    // non-axis direction
-    direction = R3(1.0, 2.0, 3.0);
-    efficiency = 1.0;
-    total_transmission = 0.5;
-    unit_direction = direction.unit();
-    detector.setAnalyzer(direction, efficiency, total_transmission);
-    const PolFilter& detect_properties4 = detector.analyzer();
-
-    EXPECT_NEAR(detect_properties4.polEfficiency(), efficiency, 1e-8);
-    EXPECT_NEAR(detect_properties4.totalTransmission(), total_transmission, 1e-8);
-    EXPECT_NEAR(detect_properties4.polDirection().x(), unit_direction.x(), 1e-8);
-    EXPECT_NEAR(detect_properties4.polDirection().y(), unit_direction.y(), 1e-8);
-    EXPECT_NEAR(detect_properties4.polDirection().z(), unit_direction.z(), 1e-8);
-
-    // maximum efficiency and negative efficiency
-    direction = R3(0.0, -1.0, -1.0);
-    efficiency = -1.0;
-    total_transmission = 0.5;
-    unit_direction = direction.unit();
-    detector.setAnalyzer(direction, efficiency, total_transmission);
-    const PolFilter& detect_properties5 = detector.analyzer();
-
-    EXPECT_NEAR(detect_properties5.polEfficiency(), efficiency, 1e-8);
-    EXPECT_NEAR(detect_properties5.totalTransmission(), total_transmission, 1e-8);
-    EXPECT_NEAR(detect_properties5.polDirection().x(), unit_direction.x(), 1e-8);
-    EXPECT_NEAR(detect_properties5.polDirection().y(), unit_direction.y(), 1e-8);
-    EXPECT_NEAR(detect_properties5.polDirection().z(), unit_direction.z(), 1e-8);
-}
-- 
GitLab


From e1f4d3d23e3b1749888cbbf22741e94697c48195 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 20:13:00 +0200
Subject: [PATCH 41/63] set polarization only where needed

---
 GUI/Model/Device/InstrumentItems.cpp     | 13 ++++++++++---
 GUI/Model/Device/InstrumentItems.h       |  1 +
 GUI/Model/To/DomainSimulationBuilder.cpp |  4 ++--
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/GUI/Model/Device/InstrumentItems.cpp b/GUI/Model/Device/InstrumentItems.cpp
index 88099968855..998ce397f33 100644
--- a/GUI/Model/Device/InstrumentItems.cpp
+++ b/GUI/Model/Device/InstrumentItems.cpp
@@ -357,6 +357,15 @@ void Instrument2DItem::importMasks(const MaskContainerItem* maskContainer)
 }
 
 std::unique_ptr<Instrument> Instrument2DItem::createInstrument() const
+{
+    auto beam = beamItem()->createBeam();
+    auto detector = detectorItem()->createDetector();
+    detector->setDetectorNormal(beam->direction().zReflected());
+
+    return std::make_unique<Instrument>(*beam, *detector);
+}
+
+std::unique_ptr<Instrument> Instrument2DItem::createPolInstrument() const
 {
     auto beam = beamItem()->createBeam();
     beam->setPolarization(m_polarization);
@@ -368,9 +377,7 @@ std::unique_ptr<Instrument> Instrument2DItem::createInstrument() const
     // The Unit test are e.g. TestGuiStd/Std/MagneticCylinders
     detector->setAnalyzer(m_analyzerDirection, m_analyzerEfficiency, m_analyzerTotalTransmission);
 
-    std::unique_ptr<Instrument> instrument(new Instrument(*beam, *detector));
-
-    return instrument;
+    return std::make_unique<Instrument>(*beam, *detector);
 }
 
 //  ************************************************************************************************
diff --git a/GUI/Model/Device/InstrumentItems.h b/GUI/Model/Device/InstrumentItems.h
index ea9b2bd1a32..efe28f1247b 100644
--- a/GUI/Model/Device/InstrumentItems.h
+++ b/GUI/Model/Device/InstrumentItems.h
@@ -156,6 +156,7 @@ public:
     void importMasks(const MaskContainerItem* maskContainer) override;
 
     std::unique_ptr<Instrument> createInstrument() const;
+    std::unique_ptr<Instrument> createPolInstrument() const;
 
     static bool isDetectorPropertyName(const QString& name);
 
diff --git a/GUI/Model/To/DomainSimulationBuilder.cpp b/GUI/Model/To/DomainSimulationBuilder.cpp
index 2ba0d96ffad..9bf027f1241 100644
--- a/GUI/Model/To/DomainSimulationBuilder.cpp
+++ b/GUI/Model/To/DomainSimulationBuilder.cpp
@@ -119,7 +119,7 @@ createScatteringSimulation(std::unique_ptr<MultiLayer> multilayer,
                            const GISASInstrumentItem* instrumentItem,
                            const SimulationOptionsItem& optionsItem)
 {
-    std::unique_ptr<const Instrument> instrument = instrumentItem->createInstrument();
+    std::unique_ptr<const Instrument> instrument = instrumentItem->createPolInstrument();
     std::unique_ptr<ScatteringSimulation> result{
         new ScatteringSimulation(instrument->beam(), *multilayer, instrument->detector())};
 
@@ -138,7 +138,7 @@ createOffSpecularSimulation(std::unique_ptr<MultiLayer> multilayer,
                             const OffSpecularInstrumentItem* instrumentItem,
                             const SimulationOptionsItem& optionsItem)
 {
-    std::unique_ptr<const Instrument> instrument = instrumentItem->createInstrument();
+    std::unique_ptr<const Instrument> instrument = instrumentItem->createPolInstrument();
     std::unique_ptr<OffSpecularSimulation> result{
         new OffSpecularSimulation(instrument->beam(), *multilayer, instrument->detector())};
 
-- 
GitLab


From fc1d92d228af515683d7bfe09da48f04fa48d76a Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 20:20:20 +0200
Subject: [PATCH 42/63] make_unique

---
 GUI/Model/Sample/InterferenceItems.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/GUI/Model/Sample/InterferenceItems.cpp b/GUI/Model/Sample/InterferenceItems.cpp
index 16da34649af..1a26f7ee83a 100644
--- a/GUI/Model/Sample/InterferenceItems.cpp
+++ b/GUI/Model/Sample/InterferenceItems.cpp
@@ -268,13 +268,13 @@ InterferenceFinite2DLatticeItem::InterferenceFinite2DLatticeItem()
 std::unique_ptr<IInterference> InterferenceFinite2DLatticeItem::createInterference() const
 {
     Lattice2DItem* latticeItem = latticeType().currentItem();
-    std::unique_ptr<InterferenceFinite2DLattice> result(new InterferenceFinite2DLattice(
-        *latticeItem->createLattice(), m_domainSize1, m_domainSize2));
+    auto result = std::make_unique<InterferenceFinite2DLattice>(
+        *latticeItem->createLattice(), m_domainSize1, m_domainSize2);
 
     result->setIntegrationOverXi(xiIntegration());
     result->setPositionVariance(positionVariance());
 
-    return std::unique_ptr<IInterference>(result.release());
+    return result;
 }
 
 void InterferenceFinite2DLatticeItem::serialize(Streamer& s)
-- 
GitLab


From c73b9094063400522e6583419b6a5d75d4109117 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 20:25:13 +0200
Subject: [PATCH 43/63] uniform local var 'result', not 'ret'

---
 Base/Spin/SpinMatrix.cpp              |  6 +++---
 Device/Coord/ICoordSystem.cpp         |  6 +++---
 Device/Histo/IOFactory.cpp            | 14 +++++++-------
 GUI/Model/Data/DataViewUtils.cpp      |  6 +++---
 GUI/Model/Model/FitParameterModel.cpp | 12 ++++++------
 Sample/Aggregate/ParticleLayout.cpp   |  6 +++---
 Wrap/Swig/doxy2swig.py                | 10 +++++-----
 7 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/Base/Spin/SpinMatrix.cpp b/Base/Spin/SpinMatrix.cpp
index 650f5197fa9..442b31260b9 100644
--- a/Base/Spin/SpinMatrix.cpp
+++ b/Base/Spin/SpinMatrix.cpp
@@ -70,9 +70,9 @@ SpinMatrix SpinMatrix::operator*(const SpinMatrix& o) const
 
 SpinMatrix SpinMatrix::operator*=(const SpinMatrix& o)
 {
-    const SpinMatrix ret(*this * o);
-    *this = ret;
-    return ret;
+    const SpinMatrix tmp(*this * o);
+    *this = tmp;
+    return *this;
 }
 
 Spinor SpinMatrix::operator*(const Spinor& s) const
diff --git a/Device/Coord/ICoordSystem.cpp b/Device/Coord/ICoordSystem.cpp
index 2a60be6f36e..81985b0529e 100644
--- a/Device/Coord/ICoordSystem.cpp
+++ b/Device/Coord/ICoordSystem.cpp
@@ -25,10 +25,10 @@ std::vector<IAxis*> ICoordSystem::defaultAxes() const
 
 std::vector<IAxis*> ICoordSystem::convertedAxes(Coords units) const
 {
-    std::vector<IAxis*> ret;
+    std::vector<IAxis*> result;
     for (size_t i = 0; i < rank(); ++i)
-        ret.emplace_back(createConvertedAxis(i, units));
-    return ret;
+        result.emplace_back(createConvertedAxis(i, units));
+    return result;
 }
 
 std::string ICoordSystem::axisName(size_t i_axis, const Coords units) const
diff --git a/Device/Histo/IOFactory.cpp b/Device/Histo/IOFactory.cpp
index 35d7cb81092..a361d0c62e9 100644
--- a/Device/Histo/IOFactory.cpp
+++ b/Device/Histo/IOFactory.cpp
@@ -43,18 +43,18 @@ Powerfield<double>* IOFactory::readPowerfield(const std::string& file_name, Load
                    && fileTypeMatchesLoaderSelector(file_name, testForSelector));
     };
 
-    Powerfield<double>* ret = nullptr;
+    Powerfield<double>* result = nullptr;
 
     if (readAs(bornagain))
-        ret = readPowerfield(file_name,
+        result = readPowerfield(file_name,
                              [](std::istream& s) { return ReadWriteINT().readPowerfield(s); });
 
     else if (readAs(nicos))
-        ret = readPowerfield(file_name, [](std::istream& s) { return IO::readNicosData(s); });
+        result = readPowerfield(file_name, [](std::istream& s) { return IO::readNicosData(s); });
 
 #ifdef BA_TIFF_SUPPORT
     else if (readAs(tiff))
-        ret = readPowerfield(file_name,
+        result = readPowerfield(file_name,
                              [](std::istream& s) { return ReadWriteTiff().readPowerfield(s); });
 #endif
 
@@ -62,11 +62,11 @@ Powerfield<double>* IOFactory::readPowerfield(const std::string& file_name, Load
         // Try to read ASCII by default. Binary maps to ASCII.
         // If the file is not actually a matrix of numbers,
         // the error will be thrown during the reading.
-        ret = readPowerfield(file_name,
+        result = readPowerfield(file_name,
                              [](std::istream& s) { return ReadWriteNumpyTXT().readPowerfield(s); });
 
-    ASSERT(ret);
-    return ret;
+    ASSERT(result);
+    return result;
 }
 
 Powerfield<double>* IOFactory::readReflectometryData(const std::string& file_name)
diff --git a/GUI/Model/Data/DataViewUtils.cpp b/GUI/Model/Data/DataViewUtils.cpp
index 4994b928f0c..24071f66e66 100644
--- a/GUI/Model/Data/DataViewUtils.cpp
+++ b/GUI/Model/Data/DataViewUtils.cpp
@@ -59,9 +59,9 @@ GUI::Model::DataViewUtils::getTranslatedData(Data1DViewItem* view_item, DataItem
     auto* converter = getConverter(view_item);
     auto current_units = selectedUnits(view_item);
 
-    auto ret = std::make_unique<Powerfield<double>>(converter->convertedAxes(current_units));
+    auto result = std::make_unique<Powerfield<double>>(converter->convertedAxes(current_units));
 
-    ret->setRawDataVector(data_item->getPowerfield()->getRawDataVector());
+    result->setRawDataVector(data_item->getPowerfield()->getRawDataVector());
 
-    return ret;
+    return result;
 }
diff --git a/GUI/Model/Model/FitParameterModel.cpp b/GUI/Model/Model/FitParameterModel.cpp
index 19f20a127f2..21b93176f34 100644
--- a/GUI/Model/Model/FitParameterModel.cpp
+++ b/GUI/Model/Model/FitParameterModel.cpp
@@ -64,28 +64,28 @@ Qt::ItemFlags FitParameterModel::flags(const QModelIndex& index) const
     if (!m_parameterContainer)
         return Qt::NoItemFlags;
 
-    Qt::ItemFlags returnVal = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
+    Qt::ItemFlags result = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
     if (SessionItem* item = itemForIndex(index)) {
         if (item->isEditable() && index.column() != COL_NAME)
-            returnVal |= Qt::ItemIsEditable;
+            result |= Qt::ItemIsEditable;
         if (item->parent()->hasModelType<FitParameterLinkItem>() && index.column() == COL_NAME)
-            returnVal |= Qt::ItemIsDragEnabled;
+            result |= Qt::ItemIsDragEnabled;
         const bool allow_one_fit_parameter_to_have_more_than_one_link = true;
         if (allow_one_fit_parameter_to_have_more_than_one_link) {
             // drop is allowed to fit parameter container, and, to FitParameterItem itself.
             // (i.e. we can have more than one link in single FitParameterItem)
             if (item->hasModelType<FitParameterItem>()
                 || item->hasModelType<FitParameterContainerItem>()) {
-                returnVal |= Qt::ItemIsDropEnabled;
+                result |= Qt::ItemIsDropEnabled;
             }
         } else {
             // drop is allowed only to fit parameter container
             // (i.e. only one link is allowed in FitParameterItem)
             if (item->hasModelType<FitParameterContainerItem>())
-                returnVal |= Qt::ItemIsDropEnabled;
+                result |= Qt::ItemIsDropEnabled;
         }
     }
-    return returnVal;
+    return result;
 }
 
 QModelIndex FitParameterModel::index(int row, int column, const QModelIndex& parent) const
diff --git a/Sample/Aggregate/ParticleLayout.cpp b/Sample/Aggregate/ParticleLayout.cpp
index 509bb67b539..56d08d7aeb9 100644
--- a/Sample/Aggregate/ParticleLayout.cpp
+++ b/Sample/Aggregate/ParticleLayout.cpp
@@ -63,10 +63,10 @@ void ParticleLayout::addParticle(const IParticle& particle, double abundance)
 
 std::vector<const IParticle*> ParticleLayout::particles() const
 {
-    std::vector<const IParticle*> ret;
+    std::vector<const IParticle*> result;
     for (const IParticle* p : m_particles)
-        ret.emplace_back(p);
-    return ret;
+        result.emplace_back(p);
+    return result;
 }
 
 const IInterference* ParticleLayout::interferenceFunction() const
diff --git a/Wrap/Swig/doxy2swig.py b/Wrap/Swig/doxy2swig.py
index 397c85d91d0..e155662d1aa 100755
--- a/Wrap/Swig/doxy2swig.py
+++ b/Wrap/Swig/doxy2swig.py
@@ -343,18 +343,18 @@ class Doxy2SWIG:
                 ret.append(i)
 
         _data = "".join(ret)
-        ret = []
+        result = []
         for i in _data.split('\n\n'):
             if i == 'Parameters:':
-                ret.extend(['Parameters:\n-----------', '\n\n'])
+                result.extend(['Parameters:\n-----------', '\n\n'])
             elif i.find('// File:') > -1:  # leave comments alone.
-                ret.extend([i, '\n'])
+                result.extend([i, '\n'])
             else:
                 #_tmp = textwrap.fill(i.strip())
                 _tmp = i.strip()
                 _tmp = self.lead_spc.sub(r'\1"\2', _tmp)
-                ret.extend([_tmp, '\n\n'])
-        return ret
+                result.extend([_tmp, '\n\n'])
+        return result
 
 
 def main(input, output):
-- 
GitLab


From 040e70d600f9fb3a3527a9dae4518b4d1a844e22 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 20:26:23 +0200
Subject: [PATCH 44/63] make_unique

---
 GUI/View/Fit/FitObjectiveBuilder.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/GUI/View/Fit/FitObjectiveBuilder.cpp b/GUI/View/Fit/FitObjectiveBuilder.cpp
index d91be69e259..b7aea1060d1 100644
--- a/GUI/View/Fit/FitObjectiveBuilder.cpp
+++ b/GUI/View/Fit/FitObjectiveBuilder.cpp
@@ -69,7 +69,7 @@ void FitObjectiveBuilder::runFit()
 
 std::unique_ptr<FitObjective> FitObjectiveBuilder::createFitObjective() const
 {
-    std::unique_ptr<FitObjective> result(new FitObjective);
+    auto result = std::make_unique<FitObjective>();
 
     simulation_builder_t builder = [&](const mumufit::Parameters& params) {
         return buildSimulation(params);
-- 
GitLab


From 81c4efac2e706fbf685ae2425cac4cb4fc3fd531 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 20:30:10 +0200
Subject: [PATCH 45/63] make_unique

---
 Sim/Simulation/DepthProbeSimulation.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Sim/Simulation/DepthProbeSimulation.cpp b/Sim/Simulation/DepthProbeSimulation.cpp
index 114dc0e710d..a1c50d5c6ce 100644
--- a/Sim/Simulation/DepthProbeSimulation.cpp
+++ b/Sim/Simulation/DepthProbeSimulation.cpp
@@ -244,7 +244,7 @@ double DepthProbeSimulation::incidentAngle(size_t index) const
 
 std::unique_ptr<Powerfield<double>> DepthProbeSimulation::createIntensityData() const
 {
-    std::unique_ptr<Powerfield<double>> result(new Powerfield<double>(*alphaAxis(), *zAxis()));
+    auto result = std::make_unique<Powerfield<double>>(*alphaAxis(), *zAxis());
 
     std::vector<double> rawData;
     rawData.reserve(alphaAxis()->size() * zAxis()->size());
-- 
GitLab


From 5149c8f474c332288a47be654679cbd27e4ff321 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 20:32:20 +0200
Subject: [PATCH 46/63] make_unique

---
 Device/Data/DataUtils.cpp     | 2 +-
 Device/Detector/IDetector.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Device/Data/DataUtils.cpp b/Device/Data/DataUtils.cpp
index 8f00965d9dd..5ba5adb5651 100644
--- a/Device/Data/DataUtils.cpp
+++ b/Device/Data/DataUtils.cpp
@@ -122,7 +122,7 @@ DataUtils::Data::createClippedDataSet(const Powerfield<double>& origin, double x
             new_axis->clip(y1, y2);
         axes.emplace_back(new_axis);
     }
-    std::unique_ptr<Powerfield<double>> result(new Powerfield<double>(axes));
+    auto result = std::make_unique<Powerfield<double>>(axes);
     result->setAllTo(0.0);
 
     Powerfield<double>::const_iterator it_origin = origin.cbegin();
diff --git a/Device/Detector/IDetector.cpp b/Device/Detector/IDetector.cpp
index edd6b3f69b0..583125fbbdc 100644
--- a/Device/Detector/IDetector.cpp
+++ b/Device/Detector/IDetector.cpp
@@ -208,7 +208,7 @@ std::unique_ptr<Powerfield<double>> IDetector::createDetectorMap() const
         axes.emplace_back(tmp);
     }
 
-    return std::unique_ptr<Powerfield<double>>{new Powerfield<double>(axes)};
+    return std::make_unique<Powerfield<double>>(axes);
 }
 
 void IDetector::setDataToDetectorMap(
-- 
GitLab


From 20540605b995ba9671b473516e7701e8265a4de8 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 20:45:43 +0200
Subject: [PATCH 47/63] make_unique

---
 GUI/Model/To/DomainSimulationBuilder.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/GUI/Model/To/DomainSimulationBuilder.cpp b/GUI/Model/To/DomainSimulationBuilder.cpp
index 9bf027f1241..ba396a918e4 100644
--- a/GUI/Model/To/DomainSimulationBuilder.cpp
+++ b/GUI/Model/To/DomainSimulationBuilder.cpp
@@ -120,8 +120,8 @@ createScatteringSimulation(std::unique_ptr<MultiLayer> multilayer,
                            const SimulationOptionsItem& optionsItem)
 {
     std::unique_ptr<const Instrument> instrument = instrumentItem->createPolInstrument();
-    std::unique_ptr<ScatteringSimulation> result{
-        new ScatteringSimulation(instrument->beam(), *multilayer, instrument->detector())};
+    auto result = std::make_unique<ScatteringSimulation>(
+        instrument->beam(), *multilayer, instrument->detector());
 
     addDistributionParametersToSimulation(*instrumentItem->beamItem(), *result);
 
@@ -139,8 +139,8 @@ createOffSpecularSimulation(std::unique_ptr<MultiLayer> multilayer,
                             const SimulationOptionsItem& optionsItem)
 {
     std::unique_ptr<const Instrument> instrument = instrumentItem->createPolInstrument();
-    std::unique_ptr<OffSpecularSimulation> result{
-        new OffSpecularSimulation(instrument->beam(), *multilayer, instrument->detector())};
+    auto result = std::make_unique<OffSpecularSimulation>(
+        instrument->beam(), *multilayer, instrument->detector());
 
     auto* beamItem = instrumentItem->beamItem();
     const auto axis = instrumentItem->alphaAxis().createAxis(Units::deg);
-- 
GitLab


From 65b49c67953fcffda046197bb27d97f66391fb6a Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 20:46:13 +0200
Subject: [PATCH 48/63] rm comment

---
 GUI/Model/Device/InstrumentItems.cpp | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/GUI/Model/Device/InstrumentItems.cpp b/GUI/Model/Device/InstrumentItems.cpp
index 998ce397f33..06e693a6ff3 100644
--- a/GUI/Model/Device/InstrumentItems.cpp
+++ b/GUI/Model/Device/InstrumentItems.cpp
@@ -368,13 +368,10 @@ std::unique_ptr<Instrument> Instrument2DItem::createInstrument() const
 std::unique_ptr<Instrument> Instrument2DItem::createPolInstrument() const
 {
     auto beam = beamItem()->createBeam();
-    beam->setPolarization(m_polarization);
     auto detector = detectorItem()->createDetector();
     detector->setDetectorNormal(beam->direction().zReflected());
 
-    // TODO: Why not check "if (withPolarizerAnalyzer())"? But if it is inserted, some of the unit
-    // tests fail (because in the unit tests this flag is never set to true)
-    // The Unit test are e.g. TestGuiStd/Std/MagneticCylinders
+    beam->setPolarization(m_polarization);
     detector->setAnalyzer(m_analyzerDirection, m_analyzerEfficiency, m_analyzerTotalTransmission);
 
     return std::make_unique<Instrument>(*beam, *detector);
-- 
GitLab


From 1204d989136cdee5576229795ed60ce234d06119 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Mon, 23 May 2022 20:57:26 +0200
Subject: [PATCH 49/63] also in GUI, set polarization at simulation level

---
 GUI/Model/Device/InstrumentItems.cpp     | 24 ++++++++++++++++++++----
 GUI/Model/Device/InstrumentItems.h       | 10 ++++++++--
 GUI/Model/To/DomainSimulationBuilder.cpp | 10 ++++------
 3 files changed, 32 insertions(+), 12 deletions(-)

diff --git a/GUI/Model/Device/InstrumentItems.cpp b/GUI/Model/Device/InstrumentItems.cpp
index 06e693a6ff3..b97248f622a 100644
--- a/GUI/Model/Device/InstrumentItems.cpp
+++ b/GUI/Model/Device/InstrumentItems.cpp
@@ -37,6 +37,8 @@
 #include "GUI/Util/Error.h"
 #include "GUI/Util/String.h"
 #include "Sim/Simulation/DepthProbeSimulation.h"
+#include "Sim/Simulation/OffSpecularSimulation.h"
+#include "Sim/Simulation/ScatteringSimulation.h"
 
 namespace {
 
@@ -365,16 +367,30 @@ std::unique_ptr<Instrument> Instrument2DItem::createInstrument() const
     return std::make_unique<Instrument>(*beam, *detector);
 }
 
-std::unique_ptr<Instrument> Instrument2DItem::createPolInstrument() const
+std::unique_ptr<ScatteringSimulation> Instrument2DItem::createScatteringSimulation(
+    const MultiLayer& sample) const
 {
     auto beam = beamItem()->createBeam();
     auto detector = detectorItem()->createDetector();
     detector->setDetectorNormal(beam->direction().zReflected());
 
-    beam->setPolarization(m_polarization);
-    detector->setAnalyzer(m_analyzerDirection, m_analyzerEfficiency, m_analyzerTotalTransmission);
+    auto result = std::make_unique<ScatteringSimulation>(*beam, sample, *detector);
+    result->setPolarization(m_polarization);
+    result->setAnalyzer(m_analyzerDirection, m_analyzerEfficiency, m_analyzerTotalTransmission);
+    return result;
+}
 
-    return std::make_unique<Instrument>(*beam, *detector);
+std::unique_ptr<OffSpecularSimulation> Instrument2DItem::createOffSpecularSimulation(
+    const MultiLayer& sample) const
+{
+    auto beam = beamItem()->createBeam();
+    auto detector = detectorItem()->createDetector();
+    detector->setDetectorNormal(beam->direction().zReflected());
+
+    auto result = std::make_unique<OffSpecularSimulation>(*beam, sample, *detector);
+    result->setPolarization(m_polarization);
+    result->setAnalyzer(m_analyzerDirection, m_analyzerEfficiency, m_analyzerTotalTransmission);
+    return result;
 }
 
 //  ************************************************************************************************
diff --git a/GUI/Model/Device/InstrumentItems.h b/GUI/Model/Device/InstrumentItems.h
index efe28f1247b..f758b690d08 100644
--- a/GUI/Model/Device/InstrumentItems.h
+++ b/GUI/Model/Device/InstrumentItems.h
@@ -28,10 +28,13 @@
 class BackgroundItem;
 class DataItem;
 class DepthProbeSimulation;
-class Instrument;
 class ICoordSystem;
+class Instrument;
 class MaskContainerItem;
+class MultiLayer;
 class RealDataItem;
+class OffSpecularSimulation;
+class ScatteringSimulation;
 
 //! Abstract base class for instrument-specific item classes.
 
@@ -156,7 +159,10 @@ public:
     void importMasks(const MaskContainerItem* maskContainer) override;
 
     std::unique_ptr<Instrument> createInstrument() const;
-    std::unique_ptr<Instrument> createPolInstrument() const;
+    std::unique_ptr<ScatteringSimulation> createScatteringSimulation(
+        const MultiLayer& sample) const;
+    std::unique_ptr<OffSpecularSimulation> createOffSpecularSimulation(
+        const MultiLayer& sample) const;
 
     static bool isDetectorPropertyName(const QString& name);
 
diff --git a/GUI/Model/To/DomainSimulationBuilder.cpp b/GUI/Model/To/DomainSimulationBuilder.cpp
index ba396a918e4..1a9af18fb27 100644
--- a/GUI/Model/To/DomainSimulationBuilder.cpp
+++ b/GUI/Model/To/DomainSimulationBuilder.cpp
@@ -119,9 +119,8 @@ createScatteringSimulation(std::unique_ptr<MultiLayer> multilayer,
                            const GISASInstrumentItem* instrumentItem,
                            const SimulationOptionsItem& optionsItem)
 {
-    std::unique_ptr<const Instrument> instrument = instrumentItem->createPolInstrument();
-    auto result = std::make_unique<ScatteringSimulation>(
-        instrument->beam(), *multilayer, instrument->detector());
+    std::unique_ptr<ScatteringSimulation> result(
+        instrumentItem->createScatteringSimulation(*multilayer));
 
     addDistributionParametersToSimulation(*instrumentItem->beamItem(), *result);
 
@@ -138,9 +137,8 @@ createOffSpecularSimulation(std::unique_ptr<MultiLayer> multilayer,
                             const OffSpecularInstrumentItem* instrumentItem,
                             const SimulationOptionsItem& optionsItem)
 {
-    std::unique_ptr<const Instrument> instrument = instrumentItem->createPolInstrument();
-    auto result = std::make_unique<OffSpecularSimulation>(
-        instrument->beam(), *multilayer, instrument->detector());
+    std::unique_ptr<OffSpecularSimulation> result(
+        instrumentItem->createOffSpecularSimulation(*multilayer));
 
     auto* beamItem = instrumentItem->beamItem();
     const auto axis = instrumentItem->alphaAxis().createAxis(Units::deg);
-- 
GitLab


From c4b61fc7baefcb2ea9e3fe561a5a8e380f8ce9a5 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Tue, 24 May 2022 10:24:51 +0200
Subject: [PATCH 50/63] Honeycomb fit example works again (but opens an empty
 plot besides two valid ones)

---
 Examples/fit/scatter2d/Honeycomb_fit.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/Examples/fit/scatter2d/Honeycomb_fit.py b/Examples/fit/scatter2d/Honeycomb_fit.py
index 3bc0f5961d4..3f01274449a 100755
--- a/Examples/fit/scatter2d/Honeycomb_fit.py
+++ b/Examples/fit/scatter2d/Honeycomb_fit.py
@@ -12,7 +12,7 @@ import numpy
 import matplotlib.pyplot as plt
 from scipy.optimize import differential_evolution
 import bornagain as ba
-from bornagain import angstrom
+from bornagain import angstrom, sample_tools as st
 
 # number of points on which the computed result is plotted
 scan_size = 1500
@@ -158,12 +158,12 @@ def plot_sld_profile(fitParams, filename):
     plt.figure()
     parameters = dict(fitParams, **fixedParams)
 
-    z_300_p, sld_300_p = ba.materialProfile(get_sample(parameters, 1))
-    z_300_m, sld_300_m = ba.materialProfile(get_sample(parameters, -1))
+    z_300_p, sld_300_p = st.materialProfile(get_sample(parameters, 1))
+    z_300_m, sld_300_m = st.materialProfile(get_sample(parameters, -1))
 
-    z_150_p, sld_150_p = ba.materialProfile(
+    z_150_p, sld_150_p = st.materialProfile(
         get_sample(parameters, 1, ms150=parameters["ms150"]))
-    z_150_m, sld_150_m = ba.materialProfile(
+    z_150_m, sld_150_m = st.materialProfile(
         get_sample(parameters, -1, ms150=parameters["ms150"]))
 
     plt.figure()
@@ -179,7 +179,7 @@ def plot_sld_profile(fitParams, filename):
     plt.legend()
     plt.tight_layout()
     plt.savefig(filename)
-    plt.close()
+#    plt.close()
 
 
 ####################################################################
-- 
GitLab


From faacebf2ee74a6fd980d0b4dda5b83ea55cec759 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Tue, 24 May 2022 10:26:21 +0200
Subject: [PATCH 51/63] mv specular fit examples to right directory

---
 Examples/fit/{scatter2d => specular}/Honeycomb_fit.py | 0
 Examples/fit/{scatter2d => specular}/Pt_layer_fit.py  | 0
 2 files changed, 0 insertions(+), 0 deletions(-)
 rename Examples/fit/{scatter2d => specular}/Honeycomb_fit.py (100%)
 rename Examples/fit/{scatter2d => specular}/Pt_layer_fit.py (100%)

diff --git a/Examples/fit/scatter2d/Honeycomb_fit.py b/Examples/fit/specular/Honeycomb_fit.py
similarity index 100%
rename from Examples/fit/scatter2d/Honeycomb_fit.py
rename to Examples/fit/specular/Honeycomb_fit.py
diff --git a/Examples/fit/scatter2d/Pt_layer_fit.py b/Examples/fit/specular/Pt_layer_fit.py
similarity index 100%
rename from Examples/fit/scatter2d/Pt_layer_fit.py
rename to Examples/fit/specular/Pt_layer_fit.py
-- 
GitLab


From 52cc30887ef7f83079498e986b97d7a34203ef1d Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Tue, 24 May 2022 10:34:57 +0200
Subject: [PATCH 52/63] cover two specular fits by manualtest

---
 Examples/fit/specular/Pt_layer_fit.py | 23 +++++++++++------------
 Tests/Examples/CMakeLists.txt         |  2 ++
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/Examples/fit/specular/Pt_layer_fit.py b/Examples/fit/specular/Pt_layer_fit.py
index ed37f444dc1..cb0b31afb9f 100755
--- a/Examples/fit/specular/Pt_layer_fit.py
+++ b/Examples/fit/specular/Pt_layer_fit.py
@@ -6,10 +6,10 @@ https://doi.org/10.5281/zenodo.4072376
 """
 
 import os, sys
-import numpy
 import matplotlib.pyplot as plt
+import numpy as np
 import bornagain as ba
-from bornagain import angstrom
+from bornagain import angstrom, ba_plot as bp
 
 # filename of the experimental data to be loaded
 datadir = os.getenv('BA_EXAMPLE_DATA_DIR', '')
@@ -87,8 +87,8 @@ def qr(result):
     """
     Return q and reflectivity arrays from simulation result.
     """
-    q = numpy.array(result.convertedBinCenters(ba.Coords_QSPACE))
-    r = numpy.array(result.array(ba.Coords_QSPACE))
+    q = np.array(result.convertedBinCenters(ba.Coords_QSPACE))
+    r = np.array(result.array(ba.Coords_QSPACE))
 
     return q, r
 
@@ -141,10 +141,10 @@ def get_Experimental_data(filepath, qmin, qmax):
     """
     Read experimental data, remove duplicate q values, convert q to nm^-1.
     """
-    data = numpy.genfromtxt(filepath, unpack=True)
+    data = np.genfromtxt(filepath, unpack=True)
 
-    r0 = numpy.where(data[0] - numpy.roll(data[0], 1) == 0)
-    data = numpy.delete(data, r0, 1)
+    r0 = np.where(data[0] - np.roll(data[0], 1) == 0)
+    data = np.delete(data, r0, 1)
 
     data[0] = data[0]/angstrom
     data[3] = data[3]/angstrom
@@ -152,12 +152,12 @@ def get_Experimental_data(filepath, qmin, qmax):
     data[1] = data[1]
     data[2] = data[2]
 
-    so = numpy.argsort(data[0])
+    so = np.argsort(data[0])
 
     data = data[:, so]
 
-    minIndex = numpy.argmin(numpy.abs(data[0] - qmin))
-    maxIndex = numpy.argmin(numpy.abs(data[0] - qmax))
+    minIndex = np.argmin(np.abs(data[0] - qmin))
+    maxIndex = np.argmin(np.abs(data[0] - qmax))
 
     return data[:, minIndex:maxIndex + 1]
 
@@ -196,7 +196,6 @@ def run_fit_ba(q_axis, r_data, r_uncertainty, simulationFactory,
 ####################################################################
 
 if __name__ == '__main__':
-
     if len(sys.argv) > 1 and sys.argv[1] == "fit":
         fixedParams = {
             # parameters can be moved here to keep them fixed
@@ -229,7 +228,7 @@ if __name__ == '__main__':
 
     paramsInitial = {d: v[0] for d, v in startParams.items()}
 
-    qzs = numpy.linspace(qmin, qmax, scan_size)
+    qzs = np.linspace(qmin, qmax, scan_size)
     q, r = qr(run_simulation(qzs, paramsInitial))
     data = get_Experimental_data(filepath, qmin, qmax)
 
diff --git a/Tests/Examples/CMakeLists.txt b/Tests/Examples/CMakeLists.txt
index 99aa180b2a2..f107e467b55 100644
--- a/Tests/Examples/CMakeLists.txt
+++ b/Tests/Examples/CMakeLists.txt
@@ -198,6 +198,8 @@ run_example(varia/MaterialProfileWithParticles)
 run_plotless(fit/algo/fit_rosenbrock)
 run_plotless(fit/scatter2d/fit2d)
 run_plotless(fit/scatter2d/custom_objective_function)
+run_manually(fit/specular/Pt_layer_fit)
+run_manually(fit/specular/Honeycomb_fit)
 # TODO restore (needs ParameterDistribution) # run_plotless(fit/scatter2d/expfit_galaxi)
 run_manually(fit/scatter2d/find_background)
 run_manually(fit/scatter2d/fit_along_slices)
-- 
GitLab


From 4cbf14e3c611bfb0f614c3230b1570c7c181cecc Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Tue, 24 May 2022 10:46:39 +0200
Subject: [PATCH 53/63] SpecularSimulation + c'tor(scan, sample)

---
 Sim/Simulation/SpecularSimulation.cpp | 6 ++++++
 Sim/Simulation/SpecularSimulation.h   | 1 +
 2 files changed, 7 insertions(+)

diff --git a/Sim/Simulation/SpecularSimulation.cpp b/Sim/Simulation/SpecularSimulation.cpp
index 076952cfeea..1a55b54ac68 100644
--- a/Sim/Simulation/SpecularSimulation.cpp
+++ b/Sim/Simulation/SpecularSimulation.cpp
@@ -56,6 +56,12 @@ SpecularSimulation::SpecularSimulation()
     m_detector.reset(new SpecularDetector1D);
 }
 
+SpecularSimulation::SpecularSimulation(const ISpecularScan& scan, const MultiLayer& sample)
+{
+    setScan(scan);
+    setSample(sample);
+}
+
 SpecularSimulation::~SpecularSimulation() = default;
 
 SpecularSimulation::SpecularSimulation(SpecularSimulation&&) = default;
diff --git a/Sim/Simulation/SpecularSimulation.h b/Sim/Simulation/SpecularSimulation.h
index 0c29de18b24..2efe9a321c6 100644
--- a/Sim/Simulation/SpecularSimulation.h
+++ b/Sim/Simulation/SpecularSimulation.h
@@ -34,6 +34,7 @@ class SpecularElement;
 class SpecularSimulation : public ISimulation {
 public:
     SpecularSimulation();
+    SpecularSimulation(const ISpecularScan& scan, const MultiLayer& sample);
     ~SpecularSimulation() override;
     SpecularSimulation(SpecularSimulation&&);
 
-- 
GitLab


From 663cc0ca6e5c83c6410a704e3dcb095d2cde9652 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Tue, 24 May 2022 11:31:04 +0200
Subject: [PATCH 54/63] SpecularSimulation(scan, sample)

---
 Examples/anaklasis/ba_anaklasis.py            |  5 +-
 Examples/bayesian/likelihood_sampling.py      | 10 ++--
 Examples/fit/specular/FitSpecularBasics.py    |  8 +--
 Examples/fit/specular/Honeycomb_fit.py        |  6 +-
 Examples/fit/specular/Pt_layer_fit.py         |  9 ++-
 .../specular/RealLifeReflectometryFitting.py  |  9 ++-
 Examples/specular/AlternatingLayers1.py       |  5 +-
 Examples/specular/AlternatingLayers2.py       |  5 +-
 .../specular/BasicPolarizedReflectometry.py   | 21 ++-----
 Examples/specular/BeamAngularDivergence.py    |  6 +-
 Examples/specular/BeamFullDivergence.py       |  4 +-
 Examples/specular/FootprintCorrection.py      |  5 +-
 Examples/specular/PolarizedNoAnalyzer.py      |  5 +-
 .../PolarizedNonperfectAnalyzerPolarizer.py   |  5 +-
 Examples/specular/PolarizedSpinAsymmetry.py   |  8 +--
 Examples/specular/PolarizedSpinFlip.py        | 26 +++------
 Examples/specular/RoughnessModel.py           |  6 +-
 .../SpecularSimulationWithRoughness.py        |  5 +-
 Examples/specular/TOFRWithResolution.py       |  6 +-
 .../specular/TimeOfFlightReflectometry.py     |  5 +-
 Tests/Unit/Sim/SpecularSimulationTest.cpp     | 47 ++++-----------
 Wrap/Python/std_simulations.py                |  5 +-
 auto/Wrap/doxygenSim.i                        |  3 +
 auto/Wrap/libBornAgainSim.py                  |  1 +
 auto/Wrap/libBornAgainSim_wrap.cpp            | 57 +++++++++++++++++--
 25 files changed, 117 insertions(+), 155 deletions(-)

diff --git a/Examples/anaklasis/ba_anaklasis.py b/Examples/anaklasis/ba_anaklasis.py
index 0257cb23710..0822d7671f7 100755
--- a/Examples/anaklasis/ba_anaklasis.py
+++ b/Examples/anaklasis/ba_anaklasis.py
@@ -449,7 +449,6 @@ def simulate(sample,
     if qmax:
         qzs = np.linspace(0., qmax[0]/angstrom, scan_size)
 
-    simulation = ba.SpecularSimulation()
 
     n_sig = 4.0
     n_samples = 25
@@ -462,11 +461,9 @@ def simulate(sample,
     else:
         scan.setRelativeQResolution(distr, 0.5*resolution)
 
-    simulation.setScan(scan)
-
+    simulation = ba.SpecularSimulation(scan, sample)
     simulation.setBackground(ba.ConstantBackground(background/scale))
 
-    simulation.setSample(sample)
     result = simulation.simulate()
 
     return np.array(result.axis(
diff --git a/Examples/bayesian/likelihood_sampling.py b/Examples/bayesian/likelihood_sampling.py
index 760a909cb8c..be455ef29aa 100755
--- a/Examples/bayesian/likelihood_sampling.py
+++ b/Examples/bayesian/likelihood_sampling.py
@@ -76,15 +76,13 @@ def get_real_data():
 
 
 # Define the simulation
-def get_simulation(alpha):
+def get_simulation(sample, alpha):
     """
     Defines and returns a specular simulation.
     """
     wavelength = 0.154  #nm
     scan = ba.AlphaScan(wavelength, alpha)
-    simulation = ba.SpecularSimulation()
-    simulation.setScan(scan)
-    return simulation
+    return ba.SpecularSimulation(scan, sample)
 
 
 # Run the simulation
@@ -97,8 +95,8 @@ def run_simulation(alpha, ni_thickness, ti_thickness):
     :return: simulated reflected intensity
     """
     sample = get_sample(ni_thickness, ti_thickness)
-    simulation = get_simulation(alpha)
-    simulation.setSample(sample)
+    simulation = get_simulation(sample, alpha)
+
     result = simulation.simulate()
     return result.array()
 
diff --git a/Examples/fit/specular/FitSpecularBasics.py b/Examples/fit/specular/FitSpecularBasics.py
index b086df09c3c..022344a0440 100755
--- a/Examples/fit/specular/FitSpecularBasics.py
+++ b/Examples/fit/specular/FitSpecularBasics.py
@@ -92,12 +92,10 @@ def get_simulation(params):
     Create and return specular simulation with its instrument defined
     """
     wavelength = 1.54*ba.angstrom  # beam wavelength
-
-    simulation = ba.SpecularSimulation()
     scan = ba.AlphaScan(wavelength, get_real_data_axis())
-    simulation.setScan(scan)
-    simulation.setSample(get_sample(params))
-    return simulation
+    sample = get_sample(params)
+
+    return ba.SpecularSimulation(scan, sample)
 
 
 def run_fitting():
diff --git a/Examples/fit/specular/Honeycomb_fit.py b/Examples/fit/specular/Honeycomb_fit.py
index 3f01274449a..f8755973fab 100755
--- a/Examples/fit/specular/Honeycomb_fit.py
+++ b/Examples/fit/specular/Honeycomb_fit.py
@@ -88,9 +88,6 @@ def get_simulation(q_axis, fitParams, sign, ms150=False):
     scan = ba.QzScan(q_axis)
     scan.setAbsoluteQResolution(q_distr, dq)
 
-    simulation = ba.SpecularSimulation()
-    simulation.setScan(scan)
-    simulation.beam().setIntensity(parameters["intensity"])
 
     if ms150:
         sample = get_sample(parameters=parameters,
@@ -99,7 +96,8 @@ def get_simulation(q_axis, fitParams, sign, ms150=False):
     else:
         sample = get_sample(parameters=parameters, sign=sign, ms150=1)
 
-    simulation.setSample(sample)
+    simulation = ba.SpecularSimulation(scan, sample)
+    simulation.beam().setIntensity(parameters["intensity"])
     simulation.setBackground(ba.ConstantBackground(5e-7))
 
     return simulation
diff --git a/Examples/fit/specular/Pt_layer_fit.py b/Examples/fit/specular/Pt_layer_fit.py
index cb0b31afb9f..55ee70c557e 100755
--- a/Examples/fit/specular/Pt_layer_fit.py
+++ b/Examples/fit/specular/Pt_layer_fit.py
@@ -56,6 +56,8 @@ def get_sample(params):
 
 def get_simulation(q_axis, parameters):
 
+    sample = get_sample(parameters)
+
     scan = ba.QzScan(q_axis)
     scan.setOffset(parameters["q_offset"])
 
@@ -65,21 +67,18 @@ def get_simulation(q_axis, parameters):
     distr = ba.RangedDistributionGaussian(n_samples, n_sig)
     scan.setAbsoluteQResolution(distr, parameters["q_res/q"])
 
-    simulation = ba.SpecularSimulation()
+    simulation = ba.SpecularSimulation(scan, sample)
+
     simulation.beam().setIntensity(parameters["intensity"])
 
-    simulation.setScan(scan)
     return simulation
 
 
 def run_simulation(q_axis, fitParams):
     parameters = dict(fitParams, **fixedParams)
 
-    sample = get_sample(parameters)
     simulation = get_simulation(q_axis, parameters)
 
-    simulation.setSample(sample)
-
     return simulation.simulate()
 
 
diff --git a/Examples/fit/specular/RealLifeReflectometryFitting.py b/Examples/fit/specular/RealLifeReflectometryFitting.py
index 787d8123cd6..348d6aaa34a 100755
--- a/Examples/fit/specular/RealLifeReflectometryFitting.py
+++ b/Examples/fit/specular/RealLifeReflectometryFitting.py
@@ -88,7 +88,7 @@ def get_weights(start, end):
     return expdata[start:end, 2]
 
 
-def create_simulation(arg_dict, bin_start, bin_end):
+def create_simulation(sample, arg_dict, bin_start, bin_end):
     """
     Creates and returns specular simulation
     """
@@ -100,8 +100,7 @@ def create_simulation(arg_dict, bin_start, bin_end):
     scan.setAbsoluteAngularResolution(alpha_distr, arg_dict["divergence"])
     scan.setFootprintFactor(footprint)
 
-    simulation = ba.SpecularSimulation()
-    simulation.setScan(scan)
+    simulation = ba.SpecularSimulation(scan, sample)
     simulation.beam().setIntensity(arg_dict["intensity"])
     return simulation
 
@@ -139,8 +138,8 @@ def run_simulation(arg_dict, bin_start=0, bin_end=-1):
     Runs simulation and returns its result
     """
 
-    simulation = create_simulation(arg_dict, bin_start, bin_end)
-    simulation.setSample(buildSample(arg_dict))
+    sample = buildSample(arg_dict)
+    simulation = create_simulation(sample, arg_dict, bin_start, bin_end)
 
     return simulation.simulate()
 
diff --git a/Examples/specular/AlternatingLayers1.py b/Examples/specular/AlternatingLayers1.py
index 536e3fc7814..b25da0888d5 100755
--- a/Examples/specular/AlternatingLayers1.py
+++ b/Examples/specular/AlternatingLayers1.py
@@ -42,11 +42,8 @@ def get_simulation(sample):
     A standard specular simulation setup.
     """
     n = bp.simargs['n']
-    simulation = ba.SpecularSimulation()
     scan = ba.AlphaScan(1.54*angstrom, n, 0, 2*deg)
-    simulation.setScan(scan)
-    simulation.setSample(sample)
-    return simulation
+    return ba.SpecularSimulation(scan, sample)
 
 
 if __name__ == '__main__':
diff --git a/Examples/specular/AlternatingLayers2.py b/Examples/specular/AlternatingLayers2.py
index 47023a901a3..acac1dfc64d 100755
--- a/Examples/specular/AlternatingLayers2.py
+++ b/Examples/specular/AlternatingLayers2.py
@@ -18,11 +18,8 @@ def get_simulation(sample):
     A standard specular simulation setup.
     """
     n = bp.simargs['n']
-    simulation = ba.SpecularSimulation()
     scan = ba.AlphaScan(1.54*angstrom, n, 0, 2*deg)
-    simulation.setScan(scan)
-    simulation.setSample(sample)
-    return simulation
+    return ba.SpecularSimulation(scan, sample)
 
 
 if __name__ == '__main__':
diff --git a/Examples/specular/BasicPolarizedReflectometry.py b/Examples/specular/BasicPolarizedReflectometry.py
index a20d9685c81..af7248250a9 100755
--- a/Examples/specular/BasicPolarizedReflectometry.py
+++ b/Examples/specular/BasicPolarizedReflectometry.py
@@ -36,18 +36,10 @@ def get_sample():
     return sample
 
 
-def get_simulation(sample, scan_size=500):
-    """
-    Defines and returns a specular simulation.
-    """
-
-
-def simulate(polarizer_dir, analyzer_dir, title):
+def simulate(sample, polarizer_dir, analyzer_dir, title):
     n = bp.simargs['n']
-    simulation = ba.SpecularSimulation()
     scan = ba.AlphaScan(1.54*angstrom, n, 0, 5*deg)
-    simulation.setScan(scan)
-    simulation.setSample(get_sample())
+    simulation = ba.SpecularSimulation(scan, sample)
 
     simulation.setPolarization(polarizer_dir)
     simulation.setAnalyzer(analyzer_dir, 1, 0.5)
@@ -57,16 +49,13 @@ def simulate(polarizer_dir, analyzer_dir, title):
     return result
 
 
-def run_simulations():
-    return ret
-
-
 if __name__ == '__main__':
     bp.parse_args(sim_n=500)
 
+    sample = get_sample()
     results = [
-        simulate(ba.R3(0, +1, 0), ba.R3(0, +1, 0), "$++$"),
-        simulate(ba.R3(0, -1, 0), ba.R3(0, -1, 0), "$--$"),
+        simulate(sample, ba.R3(0, +1, 0), ba.R3(0, +1, 0), "$++$"),
+        simulate(sample, ba.R3(0, -1, 0), ba.R3(0, -1, 0), "$--$"),
     ]
 
     bp.plot_multicurve_specular(results)
diff --git a/Examples/specular/BeamAngularDivergence.py b/Examples/specular/BeamAngularDivergence.py
index b8e3f6a38a3..557fcc62be8 100755
--- a/Examples/specular/BeamAngularDivergence.py
+++ b/Examples/specular/BeamAngularDivergence.py
@@ -51,11 +51,7 @@ def get_simulation(sample, **kwargs):
     scan.setFootprintFactor(footprint)
     scan.setAbsoluteAngularResolution(alpha_distr, d_ang)
 
-    simulation = ba.SpecularSimulation()
-    simulation.setScan(scan)
-    simulation.setSample(sample)
-
-    return simulation
+    return ba.SpecularSimulation(scan, sample)
 
 
 if __name__ == '__main__':
diff --git a/Examples/specular/BeamFullDivergence.py b/Examples/specular/BeamFullDivergence.py
index bb3a9b3f6ba..cd09f06fd02 100755
--- a/Examples/specular/BeamFullDivergence.py
+++ b/Examples/specular/BeamFullDivergence.py
@@ -35,9 +35,7 @@ def get_simulation(sample):
     scan.setAbsoluteAngularResolution(alpha_distr, d_ang)
     scan.setAbsoluteWavelengthResolution(wavelength_distr, d_wl)
 
-    simulation = ba.SpecularSimulation()
-    simulation.setScan(scan)
-    simulation.setSample(sample)
+    return ba.SpecularSimulation(scan, sample)
 
     return simulation
 
diff --git a/Examples/specular/FootprintCorrection.py b/Examples/specular/FootprintCorrection.py
index 793d5cdcfb2..c9889c4fda2 100755
--- a/Examples/specular/FootprintCorrection.py
+++ b/Examples/specular/FootprintCorrection.py
@@ -12,12 +12,11 @@ sample = std_samples.alternating_layers()
 
 
 def simulate(footprint, title):
-    simulation = ba.SpecularSimulation()
     n = bp.simargs['n']
     scan = ba.AlphaScan(1.54*angstrom, n, 0, 0.6*deg)
     scan.setFootprintFactor(footprint)
-    simulation.setScan(scan)
-    simulation.setSample(sample)
+    simulation = ba.SpecularSimulation(scan, sample)
+
     result = simulation.simulate()
     result.setTitle(title)
     return result
diff --git a/Examples/specular/PolarizedNoAnalyzer.py b/Examples/specular/PolarizedNoAnalyzer.py
index 78a46aa29f0..f2642fd5441 100755
--- a/Examples/specular/PolarizedNoAnalyzer.py
+++ b/Examples/specular/PolarizedNoAnalyzer.py
@@ -40,12 +40,9 @@ def get_simulation(sample):
     """
     Defines and returns a specular simulation.
     """
-    simulation = ba.SpecularSimulation()
     n = bp.simargs['n']
     scan = ba.AlphaScan(1.54*angstrom, n, 0, 5*deg)
-    simulation.setScan(scan)
-    simulation.setSample(sample)
-    return simulation
+    return ba.SpecularSimulation(scan, sample)
 
 
 def run_simulation(polarizer_dir=R3(0, 1, 0), analyzer_dir=None):
diff --git a/Examples/specular/PolarizedNonperfectAnalyzerPolarizer.py b/Examples/specular/PolarizedNonperfectAnalyzerPolarizer.py
index 03e0f386754..b7e8f34b562 100755
--- a/Examples/specular/PolarizedNonperfectAnalyzerPolarizer.py
+++ b/Examples/specular/PolarizedNonperfectAnalyzerPolarizer.py
@@ -54,7 +54,6 @@ def get_simulation(sample, scan_size=1500):
     """
     Defines and returns a specular simulation.
     """
-    simulation = ba.SpecularSimulation()
     qzs = numpy.linspace(0.1, 1.5, scan_size)
 
     n_sig = 4.0
@@ -64,9 +63,7 @@ def get_simulation(sample, scan_size=1500):
     scan = ba.QzScan(qzs)
     scan.setAbsoluteQResolution(distr, 0.008)
 
-    simulation.setScan(scan)
-    simulation.setSample(sample)
-    return simulation
+    return ba.SpecularSimulation(scan, sample)
 
 
 def run_simulation(*,
diff --git a/Examples/specular/PolarizedSpinAsymmetry.py b/Examples/specular/PolarizedSpinAsymmetry.py
index b1c0fdaeac7..a6e2bdeb1b4 100755
--- a/Examples/specular/PolarizedSpinAsymmetry.py
+++ b/Examples/specular/PolarizedSpinAsymmetry.py
@@ -63,13 +63,12 @@ def get_sample(params):
     return multi_layer
 
 
-def get_simulation(q_axis, parameters, polarizer_dir, analyzer_dir):
+def get_simulation(sample, q_axis, parameters, polarizer_dir, analyzer_dir):
     """
     Returns a simulation object.
     Polarization, analyzer and resolution are set
     from given parameters
     """
-    simulation = ba.SpecularSimulation()
     q_axis = q_axis + parameters["q_offset"]
     scan = ba.QzScan(q_axis)
 
@@ -80,10 +79,10 @@ def get_simulation(q_axis, parameters, polarizer_dir, analyzer_dir):
     distr = ba.RangedDistributionGaussian(n_samples, n_sig)
     scan.setAbsoluteQResolution(distr, parameters["q_res"])
 
+    simulation = ba.SpecularSimulation(scan, sample)
     simulation.setPolarization(polarizer_dir)
     simulation.setAnalyzer(analyzer_dir, 1, 0.5)
 
-    simulation.setScan(scan)
     return simulation
 
 
@@ -96,10 +95,9 @@ def run_simulation(q_axis, fitParams, *, polarizer_dir, analyzer_dir):
     parameters = dict(fitParams, **fixedParams)
 
     sample = get_sample(parameters)
-    simulation = get_simulation(q_axis, parameters, polarizer_dir,
+    simulation = get_simulation(sample, q_axis, parameters, polarizer_dir,
                                 analyzer_dir)
 
-    simulation.setSample(sample)
     return simulation.simulate()
 
 
diff --git a/Examples/specular/PolarizedSpinFlip.py b/Examples/specular/PolarizedSpinFlip.py
index 05dee45de5d..96cf227411f 100755
--- a/Examples/specular/PolarizedSpinFlip.py
+++ b/Examples/specular/PolarizedSpinFlip.py
@@ -36,25 +36,14 @@ def get_sample():
     return sample
 
 
-def get_simulation(sample, scan_size=500):
-    """
-    Defines and returns a specular simulation.
-    """
-    simulation = ba.SpecularSimulation()
-    scan = ba.AlphaScan(1.54*angstrom, scan_size, 0, 5*deg)
-    simulation.setScan(scan)
-    simulation.setSample(sample)
-    return simulation
-
-
-def run_simulation(polarizer_dir=ba.R3(0, 1, 0),
+def run_simulation(sample, polarizer_dir=ba.R3(0, 1, 0),
                    analyzer_dir=ba.R3(0, 1, 0)):
     """
     Runs simulation and returns its result.
     """
-    sample = get_sample()
-    simulation = get_simulation(sample)
+    scan = ba.AlphaScan(1.54*angstrom, 500, 0, 5*deg)
 
+    simulation = ba.SpecularSimulation(scan, sample)
     simulation.setPolarization(polarizer_dir)
     simulation.setAnalyzer(analyzer_dir, 1, 0.5)
 
@@ -81,11 +70,12 @@ def plot(data, labels):
 if __name__ == '__main__':
     bp.parse_args()
 
-    results_pp = run_simulation(ba.R3(0, 1, 0), ba.R3(0, 1, 0))
-    results_mm = run_simulation(ba.R3(0, -1, 0), ba.R3(0, -1, 0))
+    sample = get_sample()
 
-    results_pm = run_simulation(ba.R3(0, 1, 0), ba.R3(0, -1, 0))
-    results_mp = run_simulation(ba.R3(0, -1, 0), ba.R3(0, 1, 0))
+    results_pp = run_simulation(sample, ba.R3(0, 1, 0), ba.R3(0, 1, 0))
+    results_mm = run_simulation(sample, ba.R3(0, -1, 0), ba.R3(0, -1, 0))
+    results_pm = run_simulation(sample, ba.R3(0, 1, 0), ba.R3(0, -1, 0))
+    results_mp = run_simulation(sample, ba.R3(0, -1, 0), ba.R3(0, 1, 0))
 
     plot([results_pp, results_mm, results_pm, results_mp],
          ["$++$", "$--$", "$+-$", "$-+$"])
diff --git a/Examples/specular/RoughnessModel.py b/Examples/specular/RoughnessModel.py
index 1a9a208a6a4..0291e12efe9 100755
--- a/Examples/specular/RoughnessModel.py
+++ b/Examples/specular/RoughnessModel.py
@@ -47,12 +47,10 @@ def get_simulation(sample):
     """
     Defines and returns a specular simulation.
     """
-    simulation = ba.SpecularSimulation()
     n = bp.simargs['n']
     scan = ba.AlphaScan(1.54*angstrom, n, 0, 2*deg)
-    simulation.setScan(scan)
-    simulation.setSample(sample)
-    return simulation
+
+    return ba.SpecularSimulation(scan, sample)
 
 
 def simulate(roughness_model, title):
diff --git a/Examples/specular/SpecularSimulationWithRoughness.py b/Examples/specular/SpecularSimulationWithRoughness.py
index 57cb74e83f6..304598c0e3d 100755
--- a/Examples/specular/SpecularSimulationWithRoughness.py
+++ b/Examples/specular/SpecularSimulationWithRoughness.py
@@ -35,12 +35,9 @@ def get_sample():
 
 
 def get_simulation(sample):
-    simulation = ba.SpecularSimulation()
     n = bp.simargs['n']
     scan = ba.AlphaScan(1.54*angstrom, n, 0, 2*deg)
-    simulation.setScan(scan)
-    simulation.setSample(sample)
-    return simulation
+    return ba.SpecularSimulation(scan, sample)
 
 
 if __name__ == '__main__':
diff --git a/Examples/specular/TOFRWithResolution.py b/Examples/specular/TOFRWithResolution.py
index 558cadeed1f..ddcb3687090 100755
--- a/Examples/specular/TOFRWithResolution.py
+++ b/Examples/specular/TOFRWithResolution.py
@@ -36,11 +36,7 @@ def get_simulation(sample):
     scan = ba.QzScan(qzs)
     scan.setAbsoluteQResolution(distr, dq)
 
-    simulation = ba.SpecularSimulation()
-    simulation.setScan(scan)
-    simulation.setSample(sample)
-
-    return simulation
+    return ba.SpecularSimulation(scan, sample)
 
 
 if __name__ == '__main__':
diff --git a/Examples/specular/TimeOfFlightReflectometry.py b/Examples/specular/TimeOfFlightReflectometry.py
index 49260477651..f656a4dac7c 100755
--- a/Examples/specular/TimeOfFlightReflectometry.py
+++ b/Examples/specular/TimeOfFlightReflectometry.py
@@ -25,10 +25,7 @@ def get_simulation(sample):
     n = bp.simargs['n']
     qzs = np.linspace(0.01, 1, n)  # qz-values
     scan = ba.QzScan(qzs)
-    simulation = ba.SpecularSimulation()
-    simulation.setScan(scan)
-    simulation.setSample(sample)
-    return simulation
+    return ba.SpecularSimulation(scan, sample)
 
 
 if __name__ == '__main__':
diff --git a/Tests/Unit/Sim/SpecularSimulationTest.cpp b/Tests/Unit/Sim/SpecularSimulationTest.cpp
index 6f6e0822854..370f643de33 100644
--- a/Tests/Unit/Sim/SpecularSimulationTest.cpp
+++ b/Tests/Unit/Sim/SpecularSimulationTest.cpp
@@ -23,7 +23,7 @@ protected:
 
     std::unique_ptr<SpecularSimulation> defaultSimulation();
 
-    MultiLayer multilayer;
+    MultiLayer sample;
 };
 
 SpecularSimulationTest::SpecularSimulationTest()
@@ -36,25 +36,22 @@ SpecularSimulationTest::SpecularSimulationTest()
     Layer layer1(mat1, 10 * Units::nm);
     Layer layer2(mat2);
 
-    multilayer.addLayer(layer0);
-    multilayer.addLayer(layer1);
-    multilayer.addLayer(layer2);
+    sample.addLayer(layer0);
+    sample.addLayer(layer1);
+    sample.addLayer(layer2);
 }
 
 std::unique_ptr<SpecularSimulation> SpecularSimulationTest::defaultSimulation()
 {
-    auto result = std::make_unique<SpecularSimulation>();
     AlphaScan scan(1.0, FixedBinAxis("axis", 10, 0.0 * Units::deg, 2.0 * Units::deg));
-    result->setScan(scan);
-    result->setSample(multilayer);
-    return result;
+    return std::make_unique<SpecularSimulation>(scan, sample);
 }
 
 TEST_F(SpecularSimulationTest, SetAngularScan)
 {
-    SpecularSimulation sim;
     AlphaScan scan(1.0, std::vector<double>{1.0 * Units::deg, 3.0 * Units::deg});
-    sim.setScan(scan);
+    SpecularSimulation sim(scan, sample);
+
     const auto& beam = sim.beam();
 
     EXPECT_EQ(2u, sim.coordinateAxis()->size());
@@ -65,21 +62,8 @@ TEST_F(SpecularSimulationTest, SetAngularScan)
     EXPECT_EQ(0.0, beam.direction().alpha());
     EXPECT_EQ(0.0, beam.direction().phi());
 
-    SpecularSimulation sim2;
     AlphaScan scan2(1.0, 10, 1.0 * Units::deg, 10.0 * Units::deg);
-    sim2.setScan(scan2);
-    EXPECT_EQ(10u, sim2.coordinateAxis()->size());
-    EXPECT_EQ(1.0 * Units::deg, sim2.coordinateAxis()->min());
-    EXPECT_EQ(10.0 * Units::deg, sim2.coordinateAxis()->max());
-    EXPECT_EQ(1.0, beam.wavelength());
-    EXPECT_EQ(0.0, beam.direction().alpha());
-    EXPECT_EQ(0.0, beam.direction().phi());
-
-    SpecularSimulation sim3;
-    AlphaScan scan3(1.0, 10, -1.0 * Units::deg, 2.0 * Units::deg);
-    EXPECT_FAILED_ASSERT(sim3.setScan(scan3));
-
-    EXPECT_FAILED_ASSERT(sim2.setScan(scan2));
+    SpecularSimulation sim2(scan2, sample);
     EXPECT_EQ(10u, sim2.coordinateAxis()->size());
     EXPECT_EQ(1.0 * Units::deg, sim2.coordinateAxis()->min());
     EXPECT_EQ(10.0 * Units::deg, sim2.coordinateAxis()->max());
@@ -87,14 +71,12 @@ TEST_F(SpecularSimulationTest, SetAngularScan)
     EXPECT_EQ(0.0, beam.direction().alpha());
     EXPECT_EQ(0.0, beam.direction().phi());
 
-    SpecularSimulation sim4;
     AlphaScan scan4(1.0, 10, .0 * Units::deg, 2.0 * Units::deg);
+    SpecularSimulation sim4(scan4, sample);
     const auto polarizer_dir = R3({0., 0., 0.876});
     const auto analyzer_dir = R3({0., 0., 1.});
     sim4.setPolarization(polarizer_dir);
     sim4.setAnalyzer(analyzer_dir, 0.33, 0.22);
-    sim4.setScan(scan4);
-    EXPECT_FAILED_ASSERT(sim4.setScan(scan4));
 
     EXPECT_EQ(.0 * Units::deg, sim4.coordinateAxis()->min());
     EXPECT_EQ(2.0 * Units::deg, sim4.coordinateAxis()->max());
@@ -112,10 +94,8 @@ TEST_F(SpecularSimulationTest, SetAngularScan)
 
 TEST_F(SpecularSimulationTest, SetQScan)
 {
-    SpecularSimulation sim;
-
     QzScan scan(std::vector<double>{1.0, 3.0});
-    sim.setScan(scan);
+    SpecularSimulation sim(scan, sample);
 
     const auto& beam = sim.beam();
 
@@ -130,9 +110,8 @@ TEST_F(SpecularSimulationTest, SetQScan)
     sim.beam().setIntensity(2.0);
     EXPECT_EQ(2.0, beam.intensity());
 
-    SpecularSimulation sim2;
     QzScan scan2(10, 1.0, 10.0);
-    sim2.setScan(scan2);
+    SpecularSimulation sim2(scan2, sample);
     EXPECT_EQ(10u, sim2.coordinateAxis()->size());
     EXPECT_EQ(1.0, sim2.coordinateAxis()->min());
     EXPECT_EQ(10.0, sim2.coordinateAxis()->max());
@@ -141,13 +120,11 @@ TEST_F(SpecularSimulationTest, SetQScan)
     EXPECT_EQ(0.0, beam.direction().alpha());
     EXPECT_EQ(0.0, beam.direction().phi());
 
-    SpecularSimulation sim3;
-    QzScan scan3(10, 1.0, 10.0);
+    SpecularSimulation sim3(scan2, sample);
     const auto polarizer_dir = R3({0., 0., 0.876});
     const auto analyzer_dir = R3({0., 0., 1.});
     sim3.setPolarization(polarizer_dir);
     sim3.setAnalyzer(analyzer_dir, 0.33, 0.22);
-    sim3.setScan(scan3);
 
     EXPECT_EQ(1.0, sim3.coordinateAxis()->min());
     EXPECT_EQ(10.0, sim3.coordinateAxis()->max());
diff --git a/Wrap/Python/std_simulations.py b/Wrap/Python/std_simulations.py
index 4d92918388a..425868ed269 100644
--- a/Wrap/Python/std_simulations.py
+++ b/Wrap/Python/std_simulations.py
@@ -9,11 +9,8 @@ def specular(sample, scan_size):
     """
     Returns a standard specular simulation.
     """
-    simulation = ba.SpecularSimulation()
     scan = ba.AlphaScan(1.54 * angstrom, scan_size, 0, 2 * deg)
-    simulation.setScan(scan)
-    simulation.setSample(sample)
-    return simulation
+    return ba.SpecularSimulation(scan, sample)
 
 
 def sas(sample, npix):
diff --git a/auto/Wrap/doxygenSim.i b/auto/Wrap/doxygenSim.i
index 0a233d2465e..b73c4c1c192 100644
--- a/auto/Wrap/doxygenSim.i
+++ b/auto/Wrap/doxygenSim.i
@@ -1894,6 +1894,9 @@ C++ includes: SpecularSimulation.h
 %feature("docstring")  SpecularSimulation::SpecularSimulation "SpecularSimulation::SpecularSimulation()
 ";
 
+%feature("docstring")  SpecularSimulation::SpecularSimulation "SpecularSimulation::SpecularSimulation(const ISpecularScan &scan, const MultiLayer &sample)
+";
+
 %feature("docstring")  SpecularSimulation::~SpecularSimulation "SpecularSimulation::~SpecularSimulation() override
 ";
 
diff --git a/auto/Wrap/libBornAgainSim.py b/auto/Wrap/libBornAgainSim.py
index 8865dfa8f1a..1357e914972 100644
--- a/auto/Wrap/libBornAgainSim.py
+++ b/auto/Wrap/libBornAgainSim.py
@@ -3688,6 +3688,7 @@ class SpecularSimulation(ISimulation):
     def __init__(self, *args):
         r"""
         __init__(SpecularSimulation self) -> SpecularSimulation
+        __init__(SpecularSimulation self, ISpecularScan const & scan, MultiLayer const & sample) -> SpecularSimulation
         __init__(SpecularSimulation self, SpecularSimulation arg2) -> SpecularSimulation
         SpecularSimulation::SpecularSimulation(SpecularSimulation &&)
 
diff --git a/auto/Wrap/libBornAgainSim_wrap.cpp b/auto/Wrap/libBornAgainSim_wrap.cpp
index c0ca4016783..45a09be043c 100644
--- a/auto/Wrap/libBornAgainSim_wrap.cpp
+++ b/auto/Wrap/libBornAgainSim_wrap.cpp
@@ -38620,6 +38620,41 @@ fail:
 }
 
 
+SWIGINTERN PyObject *_wrap_new_SpecularSimulation__SWIG_1(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) {
+  PyObject *resultobj = 0;
+  ISpecularScan *arg1 = 0 ;
+  MultiLayer *arg2 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 = 0 ;
+  int res2 = 0 ;
+  SpecularSimulation *result = 0 ;
+  
+  if ((nobjs < 2) || (nobjs > 2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1, SWIGTYPE_p_ISpecularScan,  0  | 0);
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_SpecularSimulation" "', argument " "1"" of type '" "ISpecularScan const &""'"); 
+  }
+  if (!argp1) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_SpecularSimulation" "', argument " "1"" of type '" "ISpecularScan const &""'"); 
+  }
+  arg1 = reinterpret_cast< ISpecularScan * >(argp1);
+  res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_MultiLayer,  0  | 0);
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_SpecularSimulation" "', argument " "2"" of type '" "MultiLayer const &""'"); 
+  }
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_SpecularSimulation" "', argument " "2"" of type '" "MultiLayer const &""'"); 
+  }
+  arg2 = reinterpret_cast< MultiLayer * >(argp2);
+  result = (SpecularSimulation *)new SpecularSimulation((ISpecularScan const &)*arg1,(MultiLayer const &)*arg2);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_SpecularSimulation, SWIG_POINTER_NEW |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
 SWIGINTERN PyObject *_wrap_delete_SpecularSimulation(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   SpecularSimulation *arg1 = (SpecularSimulation *) 0 ;
@@ -38642,7 +38677,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_new_SpecularSimulation__SWIG_1(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) {
+SWIGINTERN PyObject *_wrap_new_SpecularSimulation__SWIG_2(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) {
   PyObject *resultobj = 0;
   SpecularSimulation *arg1 = 0 ;
   void *argp1 = 0 ;
@@ -38668,11 +38703,11 @@ fail:
 
 SWIGINTERN PyObject *_wrap_new_SpecularSimulation(PyObject *self, PyObject *args) {
   Py_ssize_t argc;
-  PyObject *argv[2] = {
+  PyObject *argv[3] = {
     0
   };
   
-  if (!(argc = SWIG_Python_UnpackTuple(args, "new_SpecularSimulation", 0, 1, argv))) SWIG_fail;
+  if (!(argc = SWIG_Python_UnpackTuple(args, "new_SpecularSimulation", 0, 2, argv))) SWIG_fail;
   --argc;
   if (argc == 0) {
     return _wrap_new_SpecularSimulation__SWIG_0(self, argc, argv);
@@ -38683,7 +38718,19 @@ SWIGINTERN PyObject *_wrap_new_SpecularSimulation(PyObject *self, PyObject *args
     int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_SpecularSimulation, SWIG_POINTER_NO_NULL);
     _v = SWIG_CheckState(res);
     if (_v) {
-      return _wrap_new_SpecularSimulation__SWIG_1(self, argc, argv);
+      return _wrap_new_SpecularSimulation__SWIG_2(self, argc, argv);
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_ISpecularScan, SWIG_POINTER_NO_NULL | 0);
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_MultiLayer, SWIG_POINTER_NO_NULL | 0);
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        return _wrap_new_SpecularSimulation__SWIG_1(self, argc, argv);
+      }
     }
   }
   
@@ -38691,6 +38738,7 @@ fail:
   SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'new_SpecularSimulation'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    SpecularSimulation::SpecularSimulation()\n"
+    "    SpecularSimulation::SpecularSimulation(ISpecularScan const &,MultiLayer const &)\n"
     "    SpecularSimulation::SpecularSimulation(SpecularSimulation &&)\n");
   return 0;
 }
@@ -42102,6 +42150,7 @@ static PyMethodDef SwigMethods[] = {
 		""},
 	 { "new_SpecularSimulation", _wrap_new_SpecularSimulation, METH_VARARGS, "\n"
 		"SpecularSimulation()\n"
+		"SpecularSimulation(ISpecularScan const & scan, MultiLayer const & sample)\n"
 		"new_SpecularSimulation(SpecularSimulation arg1) -> SpecularSimulation\n"
 		"SpecularSimulation::SpecularSimulation(SpecularSimulation &&)\n"
 		"\n"
-- 
GitLab


From 3bfca808e33a80371af973d99e37b209b396d441 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Tue, 24 May 2022 11:34:14 +0200
Subject: [PATCH 55/63] disambiguate resample vs multilayer

---
 Resample/Swig/MultiLayerFuncs.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/Resample/Swig/MultiLayerFuncs.cpp b/Resample/Swig/MultiLayerFuncs.cpp
index 907fec3ed49..9ffe959f8d3 100644
--- a/Resample/Swig/MultiLayerFuncs.cpp
+++ b/Resample/Swig/MultiLayerFuncs.cpp
@@ -33,8 +33,8 @@ std::vector<complex_t> swigAPI::materialProfileSLD(const MultiLayer& multilayer,
 {
     SimulationOptions options;
     options.setUseAvgMaterials(true);
-    const reSample sample = reSample::make(multilayer, options);
-    ProfileHelper helper(sample.averageSlices());
+    const reSample resample = reSample::make(multilayer, options);
+    ProfileHelper helper(resample.averageSlices());
     std::vector<double> z_values = generateZValues(n_points, z_min, z_max);
     return helper.calculateProfile(z_values);
 }
@@ -43,7 +43,7 @@ std::pair<double, double> swigAPI::defaultMaterialProfileLimits(const MultiLayer
 {
     SimulationOptions options;
     options.setUseAvgMaterials(true);
-    const reSample sample = reSample::make(multilayer, options);
-    ProfileHelper helper(sample.averageSlices());
+    const reSample resample = reSample::make(multilayer, options);
+    ProfileHelper helper(resample.averageSlices());
     return helper.defaultLimits();
 }
-- 
GitLab


From 925465c8690f045859e7b85eb7e7a517ef4f4a64 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Tue, 24 May 2022 11:37:09 +0200
Subject: [PATCH 56/63] disambiguate sampleItem vs multilayer

---
 GUI/View/SampleDesigner/SampleListModel.cpp | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/GUI/View/SampleDesigner/SampleListModel.cpp b/GUI/View/SampleDesigner/SampleListModel.cpp
index f6ce2848d24..a729151c552 100644
--- a/GUI/View/SampleDesigner/SampleListModel.cpp
+++ b/GUI/View/SampleDesigner/SampleListModel.cpp
@@ -168,16 +168,16 @@ QModelIndex SampleListModel::createSampleFromPython()
         return {}; // any messages already shown to user; no dlg necessary anymore
 
 
-    auto* sample = PyImportAssistant::createMultiLayerItem(*multiLayer);
-    if (!sample)
+    auto* sampleItem = PyImportAssistant::createMultiLayerItem(*multiLayer);
+    if (!sampleItem)
         return {}; // any messages already shown to user; no dlg necessary anymore
 
-    sample->setDescription("Imported from python code");
+    sampleItem->setDescription("Imported from python code");
 
     const int row = m_multiLayerItems->multiLayerItems().size();
     beginInsertRows(QModelIndex(), row, row);
-    m_multiLayerItems->addMultiLayer(sample);
+    m_multiLayerItems->addMultiLayer(sampleItem);
     endInsertRows();
-    return indexForItem(sample);
+    return indexForItem(sampleItem);
 }
 #endif
-- 
GitLab


From 0b71561376d5b5767e0f07e2816d7035f828e241 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Tue, 24 May 2022 11:39:19 +0200
Subject: [PATCH 57/63] unify local var name sample <- multi_layer etc

---
 Doc/PhysicsManual/fig/drawing/Green.py        |   2 +-
 .../anaklasis/calculate_lipid_multilayer.py   |   4 +-
 Examples/bayesian/likelihood_sampling.py      |  12 +-
 Examples/fit/scatter2d/consecutive_fitting.py |   8 +-
 Examples/fit/scatter2d/expfit_galaxi.py       |   2 +-
 Examples/fit/scatter2d/minimizer_settings.py  |   8 +-
 Examples/fit/scatter2d/multiple_datasets.py   |   8 +-
 Examples/fit/specular/FitSpecularBasics.py    |  12 +-
 Examples/fit/specular/Pt_layer_fit.py         |  10 +-
 .../specular/RealLifeReflectometryFitting.py  |  12 +-
 Examples/scatter2d/CustomFormFactor.py        |  10 +-
 Examples/scatter2d/CylindersInAverageLayer.py |  10 +-
 Examples/scatter2d/FindPeaks.py               |   8 +-
 Examples/scatter2d/GratingMC.py               |   8 +-
 .../scatter2d/LargeParticlesFormFactor.py     |   8 +-
 Examples/scatter2d/PositionVariance.py        |   8 +-
 Examples/scatter2d/RectangularGrating.py      |   8 +-
 .../Interference2DLatticeSumOfRotated.py      |   8 +-
 .../PolarizedNonperfectAnalyzerPolarizer.py   |  12 +-
 Examples/specular/PolarizedSpinAsymmetry.py   |  10 +-
 Examples/specular/RoughnessModel.py           |  16 +--
 .../SpecularSimulationWithRoughness.py        |  12 +-
 Examples/varia/MaterialProfile.py             |  16 +--
 .../varia/MaterialProfileWithParticles.py     |  16 +--
 GUI/Model/Job/JobItem.cpp                     |  12 +-
 GUI/Model/Job/JobItem.h                       |   2 +-
 GUI/Model/Model/JobModel.cpp                  |   6 +-
 GUI/Model/Model/JobModel.h                    |   2 +-
 GUI/Model/Project/ProjectDocument.cpp         |   8 +-
 GUI/Model/Project/ProjectDocument.h           |   4 +-
 GUI/Model/Sample/MultiLayerItems.cpp          |  26 ++--
 GUI/Model/Sample/MultiLayerItems.h            |  12 +-
 GUI/Model/Sample/SampleValidator.cpp          |   4 +-
 GUI/Model/Sample/SampleValidator.h            |   2 +-
 GUI/Model/To/DomainSimulationBuilder.cpp      |  26 ++--
 GUI/Model/To/ToDomain.cpp                     |  20 +--
 GUI/View/FromDomain/GUIExamplesFactory.h      |   2 +-
 GUI/View/FromDomain/GUISampleBuilder.cpp      |  42 +++---
 GUI/View/FromDomain/GUISampleBuilder.h        |   4 +-
 .../MaterialEditor/MaterialEditorDialog.cpp   |  18 +--
 .../MaterialEditor/MaterialEditorDialog.h     |   8 +-
 GUI/View/Project/PyImportAssistant.cpp        |  18 +--
 GUI/View/Project/PyImportAssistant.h          |   6 +-
 GUI/View/SampleDesigner/LayerForm.cpp         |  16 +--
 .../LayerOrientedSampleEditor.cpp             |   4 +-
 .../LayerOrientedSampleEditor.h               |   2 +-
 .../SampleDesigner/MaterialInplaceForm.cpp    |   6 +-
 GUI/View/SampleDesigner/MultiLayerForm.cpp    |  20 +--
 GUI/View/SampleDesigner/MultiLayerForm.h      |   4 +-
 .../SampleDesigner/SampleEditorCommands.cpp   |   6 +-
 .../SampleDesigner/SampleEditorCommands.h     |   4 +-
 .../SampleDesigner/SampleEditorController.cpp | 128 +++++++++---------
 .../SampleDesigner/SampleEditorController.h   |   8 +-
 GUI/View/SampleDesigner/SampleListModel.cpp   |  36 ++---
 GUI/View/SampleDesigner/SampleListModel.h     |   6 +-
 GUI/View/SampleDesigner/SampleListView.cpp    |  10 +-
 GUI/View/SampleDesigner/SampleListView.h      |   2 +-
 GUI/View/SampleDesigner/SampleView.cpp        |   2 +-
 GUI/View/SampleDesigner/ScriptPanel.cpp       |   8 +-
 GUI/View/SampleDesigner/ScriptPanel.h         |   2 +-
 GUI/View/SampleDesigner/WidgetMoverButton.h   |   2 +-
 GUI/View/Toplevel/ProjectSettingsView.cpp     |   2 +-
 GUI/View/Toplevel/SimulationView.cpp          |   8 +-
 GUI/View/Toplevel/SimulationView.h            |   2 +-
 Resample/Processed/ParticleRegions.cpp        |  14 +-
 Resample/Processed/ParticleRegions.h          |   2 +-
 Resample/Specular/ComputeFluxMagnetic.h       |   4 +-
 Resample/Specular/ComputeFluxScalar.h         |   2 +-
 Resample/Specular/TransitionMagneticNevot.h   |   2 +-
 Resample/Specular/TransitionMagneticTanh.h    |   2 +-
 Resample/Swig/MultiLayerFuncs.cpp             |   8 +-
 Resample/Swig/MultiLayerFuncs.h               |   6 +-
 Sample/Aggregate/IInterference.h              |   2 +-
 Sample/Multilayer/MultiLayer.h                |   4 +-
 Sample/Multilayer/MultilayerUtils.cpp         |  14 +-
 Sample/Multilayer/MultilayerUtils.h           |   8 +-
 Sample/Multilayer/PyImport.cpp                |   4 +-
 .../LayersWithAbsorptionBuilder.h             |   2 +-
 .../LayersWithAbsorptionBySLDBuilder.h        |   2 +-
 .../StandardSamples/ParticleInVacuumBuilder.h |   2 +-
 Sample/StandardSamples/ResonatorBuilder.h     |   2 +-
 Sim/Contrib/RoughMultiLayerContribution.h     |   2 +-
 Sim/Export/ExportToPython.cpp                 |   4 +-
 Sim/Export/ExportToPython.h                   |   2 +-
 Sim/Export/SampleToPython.cpp                 |  34 ++---
 Sim/Export/SampleToPython.h                   |   4 +-
 Tests/Functional/GUI/Check.cpp                |   4 +-
 Tests/Functional/Py/Embedded/Tests.cpp        |  22 +--
 Tests/PyUnit/sliced_composition.py            |  12 +-
 Tests/PyUnit/sliced_spheres.py                |  10 +-
 Tests/PyUnit/transform_BoxComposition.py      |  10 +-
 Tests/PyUnit/transform_CoreShellBox.py        |  10 +-
 Tests/PyUnit/transform_box.py                 |  10 +-
 Tests/PyUnit/transform_cube.py                |  10 +-
 Tests/Unit/GUI/TestSessionModel.cpp           |   8 +-
 Tests/Unit/Resample/SpecularMagneticTest.cpp  |  10 +-
 Tests/Unit/Sim/DepthProbeSimulationTest.cpp   |  10 +-
 Wrap/Python/sample_tools.py                   |  10 +-
 Wrap/Python/std_samples.py                    |   2 +-
 auto/Wrap/doxygenResample.i                   |  12 +-
 auto/Wrap/doxygenSample.i                     |  18 +--
 auto/Wrap/doxygenSim.i                        |   6 +-
 auto/Wrap/libBornAgainResample.py             |  18 +--
 auto/Wrap/libBornAgainResample_wrap.cpp       |  10 +-
 auto/Wrap/libBornAgainSample.py               |  10 +-
 auto/Wrap/libBornAgainSample_wrap.cpp         |  10 +-
 auto/Wrap/libBornAgainSim.py                  |   8 +-
 auto/Wrap/libBornAgainSim_wrap.cpp            |   4 +-
 .../mesocrystal.py                            |  10 +-
 .../mesocrystal_4plots.py                     |  10 +-
 .../particle_composition.py                   |  10 +-
 ...cle_composition_rotational_distribution.py |   8 +-
 112 files changed, 558 insertions(+), 558 deletions(-)

diff --git a/Doc/PhysicsManual/fig/drawing/Green.py b/Doc/PhysicsManual/fig/drawing/Green.py
index e2dd0ffd549..703a073522a 100755
--- a/Doc/PhysicsManual/fig/drawing/Green.py
+++ b/Doc/PhysicsManual/fig/drawing/Green.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 """
-Compute radiation trajectories through multilayer sample
+Compute radiation trajectories through sample sample
 for use in figure that explains the Green function.
 """
 
diff --git a/Examples/anaklasis/calculate_lipid_multilayer.py b/Examples/anaklasis/calculate_lipid_multilayer.py
index 510f9e364f7..c6d5e3f9b66 100755
--- a/Examples/anaklasis/calculate_lipid_multilayer.py
+++ b/Examples/anaklasis/calculate_lipid_multilayer.py
@@ -1,8 +1,8 @@
-# perform neutron reflectivity calculation for a lipid multilayer
+# perform neutron reflectivity calculation for a lipid sample
 
 import ba_anaklasis
 
-project = 'lipid_multilayer'
+project = 'lipid_sample'
 
 patches = [1.0]  # single laterally uniform layer
 
diff --git a/Examples/bayesian/likelihood_sampling.py b/Examples/bayesian/likelihood_sampling.py
index be455ef29aa..177c0e3779c 100755
--- a/Examples/bayesian/likelihood_sampling.py
+++ b/Examples/bayesian/likelihood_sampling.py
@@ -45,13 +45,13 @@ def get_sample(ni_thickness, ti_thickness):
     ni_layer = ba.Layer(m_ni, ni_thickness)
     ti_layer = ba.Layer(m_ti, ti_thickness)
     substrate_layer = ba.Layer(m_substrate)
-    multi_layer = ba.MultiLayer()
-    multi_layer.addLayer(vacuum_layer)
+    sample = ba.MultiLayer()
+    sample.addLayer(vacuum_layer)
     for _ in range(n_repetitions):
-        multi_layer.addLayer(ti_layer)
-        multi_layer.addLayer(ni_layer)
-    multi_layer.addLayer(substrate_layer)
-    return multi_layer
+        sample.addLayer(ti_layer)
+        sample.addLayer(ni_layer)
+    sample.addLayer(substrate_layer)
+    return sample
 
 
 # Source the real data and add an uncertainty to the ordinate
diff --git a/Examples/fit/scatter2d/consecutive_fitting.py b/Examples/fit/scatter2d/consecutive_fitting.py
index 873e6294865..1c924df67ee 100755
--- a/Examples/fit/scatter2d/consecutive_fitting.py
+++ b/Examples/fit/scatter2d/consecutive_fitting.py
@@ -34,10 +34,10 @@ def get_sample(params):
     vacuum_layer.addLayout(layout)
 
     substrate_layer = ba.Layer(m_substrate, 0)
-    multi_layer = ba.MultiLayer()
-    multi_layer.addLayer(vacuum_layer)
-    multi_layer.addLayer(substrate_layer)
-    return multi_layer
+    sample = ba.MultiLayer()
+    sample.addLayer(vacuum_layer)
+    sample.addLayer(substrate_layer)
+    return sample
 
 
 def get_simulation(params):
diff --git a/Examples/fit/scatter2d/expfit_galaxi.py b/Examples/fit/scatter2d/expfit_galaxi.py
index 2d66f00cba5..e1f65b777e0 100755
--- a/Examples/fit/scatter2d/expfit_galaxi.py
+++ b/Examples/fit/scatter2d/expfit_galaxi.py
@@ -82,7 +82,7 @@ def get_sample(params):
     ptfe_layer = ba.Layer(m_PTFE, ptfe_thickness)
     substrate_layer = ba.Layer(m_Si)
 
-    # assembling multilayer
+    # assembling sample
     sample = ba.MultiLayer()
     sample.addLayer(vacuum_layer)
     sample.addLayerWithTopRoughness(hmdso_layer, r_hmdso)
diff --git a/Examples/fit/scatter2d/minimizer_settings.py b/Examples/fit/scatter2d/minimizer_settings.py
index 596c7e3175a..737ad5f21ec 100755
--- a/Examples/fit/scatter2d/minimizer_settings.py
+++ b/Examples/fit/scatter2d/minimizer_settings.py
@@ -35,10 +35,10 @@ def get_sample(params):
     vacuum_layer = ba.Layer(m_vacuum)
     vacuum_layer.addLayout(layout)
     substrate_layer = ba.Layer(m_substrate, 0)
-    multi_layer = ba.MultiLayer()
-    multi_layer.addLayer(vacuum_layer)
-    multi_layer.addLayer(substrate_layer)
-    return multi_layer
+    sample = ba.MultiLayer()
+    sample.addLayer(vacuum_layer)
+    sample.addLayer(substrate_layer)
+    return sample
 
 
 def get_simulation(params):
diff --git a/Examples/fit/scatter2d/multiple_datasets.py b/Examples/fit/scatter2d/multiple_datasets.py
index 67d7f0db589..6b071f14b5b 100755
--- a/Examples/fit/scatter2d/multiple_datasets.py
+++ b/Examples/fit/scatter2d/multiple_datasets.py
@@ -33,10 +33,10 @@ def get_sample(params):
     vacuum_layer.addLayout(layout)
 
     substrate_layer = ba.Layer(m_substrate)
-    multi_layer = ba.MultiLayer()
-    multi_layer.addLayer(vacuum_layer)
-    multi_layer.addLayer(substrate_layer)
-    return multi_layer
+    sample = ba.MultiLayer()
+    sample.addLayer(vacuum_layer)
+    sample.addLayer(substrate_layer)
+    return sample
 
 
 def get_simulation(params):
diff --git a/Examples/fit/specular/FitSpecularBasics.py b/Examples/fit/specular/FitSpecularBasics.py
index 022344a0440..af862e1ee5f 100755
--- a/Examples/fit/specular/FitSpecularBasics.py
+++ b/Examples/fit/specular/FitSpecularBasics.py
@@ -44,13 +44,13 @@ def get_sample(params):
     ni_layer = ba.Layer(m_ni, ni_thickness)
     ti_layer = ba.Layer(m_ti, ti_thickness)
     substrate_layer = ba.Layer(m_substrate)
-    multi_layer = ba.MultiLayer()
-    multi_layer.addLayer(vacuum_layer)
+    sample = ba.MultiLayer()
+    sample.addLayer(vacuum_layer)
     for _ in range(n_repetitions):
-        multi_layer.addLayer(ti_layer)
-        multi_layer.addLayer(ni_layer)
-    multi_layer.addLayer(substrate_layer)
-    return multi_layer
+        sample.addLayer(ti_layer)
+        sample.addLayer(ni_layer)
+    sample.addLayer(substrate_layer)
+    return sample
 
 
 def get_real_data(filename):
diff --git a/Examples/fit/specular/Pt_layer_fit.py b/Examples/fit/specular/Pt_layer_fit.py
index 55ee70c557e..3fe550ed6da 100755
--- a/Examples/fit/specular/Pt_layer_fit.py
+++ b/Examples/fit/specular/Pt_layer_fit.py
@@ -45,13 +45,13 @@ def get_sample(params):
     r_si = ba.LayerRoughness(params["r_si/nm"])
     r_pt = ba.LayerRoughness(params["r_pt/nm"])
 
-    multi_layer = ba.MultiLayer()
-    multi_layer.addLayer(ambient_layer)
-    multi_layer.addLayerWithTopRoughness(layer, r_pt)
+    sample = ba.MultiLayer()
+    sample.addLayer(ambient_layer)
+    sample.addLayerWithTopRoughness(layer, r_pt)
 
-    multi_layer.addLayerWithTopRoughness(substrate_layer, r_si)
+    sample.addLayerWithTopRoughness(substrate_layer, r_si)
 
-    return multi_layer
+    return sample
 
 
 def get_simulation(q_axis, parameters):
diff --git a/Examples/fit/specular/RealLifeReflectometryFitting.py b/Examples/fit/specular/RealLifeReflectometryFitting.py
index 348d6aaa34a..c9229d7bc81 100755
--- a/Examples/fit/specular/RealLifeReflectometryFitting.py
+++ b/Examples/fit/specular/RealLifeReflectometryFitting.py
@@ -124,13 +124,13 @@ def buildSample(arg_dict):
     oxide_layer = ba.Layer(m_si_o2, arg_dict["thickness"])
     substrate_layer = ba.Layer(m_si)
 
-    # assembling multilayer
-    multi_layer = ba.MultiLayer()
-    multi_layer.addLayer(vacuum_layer)
-    multi_layer.addLayerWithTopRoughness(oxide_layer, r_si)
-    multi_layer.addLayerWithTopRoughness(substrate_layer, r_si)
+    # assembling sample
+    sample = ba.MultiLayer()
+    sample.addLayer(vacuum_layer)
+    sample.addLayerWithTopRoughness(oxide_layer, r_si)
+    sample.addLayerWithTopRoughness(substrate_layer, r_si)
 
-    return multi_layer
+    return sample
 
 
 def run_simulation(arg_dict, bin_start=0, bin_end=-1):
diff --git a/Examples/scatter2d/CustomFormFactor.py b/Examples/scatter2d/CustomFormFactor.py
index 1b94dbe38dd..cecd6ed3420 100755
--- a/Examples/scatter2d/CustomFormFactor.py
+++ b/Examples/scatter2d/CustomFormFactor.py
@@ -69,11 +69,11 @@ def get_sample():
     vacuum_layer.addLayout(particle_layout)
     substrate_layer = ba.Layer(m_substrate)
 
-    # assemble multilayer
-    multi_layer = ba.MultiLayer()
-    multi_layer.addLayer(vacuum_layer)
-    multi_layer.addLayer(substrate_layer)
-    return multi_layer
+    # assemble sample
+    sample = ba.MultiLayer()
+    sample.addLayer(vacuum_layer)
+    sample.addLayer(substrate_layer)
+    return sample
 
 
 def get_simulation(sample):
diff --git a/Examples/scatter2d/CylindersInAverageLayer.py b/Examples/scatter2d/CylindersInAverageLayer.py
index e2b98bbeeb4..7f19cc7c13a 100755
--- a/Examples/scatter2d/CylindersInAverageLayer.py
+++ b/Examples/scatter2d/CylindersInAverageLayer.py
@@ -34,11 +34,11 @@ def get_sample(cyl_height=5*nm):
     intermediate_layer.addLayout(particle_layout)
     substrate_layer = ba.Layer(m_substrate)
 
-    multi_layer = ba.MultiLayer()
-    multi_layer.addLayer(vacuum_layer)
-    multi_layer.addLayer(intermediate_layer)
-    multi_layer.addLayer(substrate_layer)
-    return multi_layer
+    sample = ba.MultiLayer()
+    sample.addLayer(vacuum_layer)
+    sample.addLayer(intermediate_layer)
+    sample.addLayer(substrate_layer)
+    return sample
 
 
 def get_simulation(sample):
diff --git a/Examples/scatter2d/FindPeaks.py b/Examples/scatter2d/FindPeaks.py
index 561e728cf2b..c604e07d865 100755
--- a/Examples/scatter2d/FindPeaks.py
+++ b/Examples/scatter2d/FindPeaks.py
@@ -45,10 +45,10 @@ def get_sample(lattice_rotation_angle=0*deg):
     sigma, hurst, corrLength = 5*nm, 0.5, 10*nm
     roughness = ba.LayerRoughness(sigma, hurst, corrLength)
 
-    multi_layer = ba.MultiLayer()
-    multi_layer.addLayer(vacuum_layer)
-    multi_layer.addLayerWithTopRoughness(substrate_layer, roughness)
-    return multi_layer
+    sample = ba.MultiLayer()
+    sample.addLayer(vacuum_layer)
+    sample.addLayerWithTopRoughness(substrate_layer, roughness)
+    return sample
 
 
 def get_simulation(sample):
diff --git a/Examples/scatter2d/GratingMC.py b/Examples/scatter2d/GratingMC.py
index 8a43cff01af..0575a40d76f 100755
--- a/Examples/scatter2d/GratingMC.py
+++ b/Examples/scatter2d/GratingMC.py
@@ -46,10 +46,10 @@ def get_sample(lattice_rotation_angle=0*deg):
     sigma, hurst, corrLength = 5*nm, 0.5, 10*nm
     roughness = ba.LayerRoughness(sigma, hurst, corrLength)
 
-    multi_layer = ba.MultiLayer()
-    multi_layer.addLayer(vacuum_layer)
-    multi_layer.addLayerWithTopRoughness(substrate_layer, roughness)
-    return multi_layer
+    sample = ba.MultiLayer()
+    sample.addLayer(vacuum_layer)
+    sample.addLayerWithTopRoughness(substrate_layer, roughness)
+    return sample
 
 
 def get_simulation(sample):
diff --git a/Examples/scatter2d/LargeParticlesFormFactor.py b/Examples/scatter2d/LargeParticlesFormFactor.py
index 66327c8f37a..0c8f770fed5 100755
--- a/Examples/scatter2d/LargeParticlesFormFactor.py
+++ b/Examples/scatter2d/LargeParticlesFormFactor.py
@@ -33,10 +33,10 @@ def get_sample(cylinder_radius, cylinder_height):
     substrate_layer = ba.Layer(m_substrate)
 
     # Define sample
-    multi_layer = ba.MultiLayer()
-    multi_layer.addLayer(vacuum_layer)
-    multi_layer.addLayer(substrate_layer)
-    return multi_layer
+    sample = ba.MultiLayer()
+    sample.addLayer(vacuum_layer)
+    sample.addLayer(substrate_layer)
+    return sample
 
 
 def get_simulation(sample, integration_flag):
diff --git a/Examples/scatter2d/PositionVariance.py b/Examples/scatter2d/PositionVariance.py
index 5dca94a66eb..06debeec77f 100755
--- a/Examples/scatter2d/PositionVariance.py
+++ b/Examples/scatter2d/PositionVariance.py
@@ -36,10 +36,10 @@ def get_sample(hasVariance, xi):
     l_substrate = ba.Layer(m_substrate)
 
     # Define sample
-    multilayer = ba.MultiLayer()
-    multilayer.addLayer(l_air)
-    multilayer.addLayer(l_substrate)
-    return multilayer
+    sample = ba.MultiLayer()
+    sample.addLayer(l_air)
+    sample.addLayer(l_substrate)
+    return sample
 
 
 def get_simulation(sample):
diff --git a/Examples/scatter2d/RectangularGrating.py b/Examples/scatter2d/RectangularGrating.py
index 91b3753a1c4..5324db87cf3 100755
--- a/Examples/scatter2d/RectangularGrating.py
+++ b/Examples/scatter2d/RectangularGrating.py
@@ -43,10 +43,10 @@ def get_sample(lattice_rotation_angle=0*deg):
     sigma, hurst, corrLength = 5*nm, 0.5, 10*nm
     roughness = ba.LayerRoughness(sigma, hurst, corrLength)
 
-    multi_layer = ba.MultiLayer()
-    multi_layer.addLayer(vacuum_layer)
-    multi_layer.addLayerWithTopRoughness(substrate_layer, roughness)
-    return multi_layer
+    sample = ba.MultiLayer()
+    sample.addLayer(vacuum_layer)
+    sample.addLayerWithTopRoughness(substrate_layer, roughness)
+    return sample
 
 
 def get_simulation(sample):
diff --git a/Examples/scatter2d/disabled/Interference2DLatticeSumOfRotated.py b/Examples/scatter2d/disabled/Interference2DLatticeSumOfRotated.py
index 02422e28055..e5878eb16f2 100755
--- a/Examples/scatter2d/disabled/Interference2DLatticeSumOfRotated.py
+++ b/Examples/scatter2d/disabled/Interference2DLatticeSumOfRotated.py
@@ -30,10 +30,10 @@ def get_sample():
 
     vacuum_layer.addLayout(particle_layout)
 
-    multi_layer = ba.MultiLayer()
-    multi_layer.addLayer(vacuum_layer)
-    multi_layer.addLayer(substrate_layer)
-    return multi_layer
+    sample = ba.MultiLayer()
+    sample.addLayer(vacuum_layer)
+    sample.addLayer(substrate_layer)
+    return sample
 
 
 def get_simulation(sample):
diff --git a/Examples/specular/PolarizedNonperfectAnalyzerPolarizer.py b/Examples/specular/PolarizedNonperfectAnalyzerPolarizer.py
index b7e8f34b562..1287d76a4ea 100755
--- a/Examples/specular/PolarizedNonperfectAnalyzerPolarizer.py
+++ b/Examples/specular/PolarizedNonperfectAnalyzerPolarizer.py
@@ -40,14 +40,14 @@ def get_sample(*, magnetization=magnetizationVector):
     roughness = ba.LayerRoughness(20*angstrom)
 
     # create sample
-    multi_layer = ba.MultiLayer()
+    sample = ba.MultiLayer()
 
-    multi_layer.addLayer(layer_vacuum)
-    multi_layer.addLayerWithTopRoughness(layer_Pd, roughness)
-    multi_layer.addLayerWithTopRoughness(layer_Fe, roughness)
-    multi_layer.addLayerWithTopRoughness(layer_substrate, roughness)
+    sample.addLayer(layer_vacuum)
+    sample.addLayerWithTopRoughness(layer_Pd, roughness)
+    sample.addLayerWithTopRoughness(layer_Fe, roughness)
+    sample.addLayerWithTopRoughness(layer_substrate, roughness)
 
-    return multi_layer
+    return sample
 
 
 def get_simulation(sample, scan_size=1500):
diff --git a/Examples/specular/PolarizedSpinAsymmetry.py b/Examples/specular/PolarizedSpinAsymmetry.py
index a6e2bdeb1b4..39504ebc6c8 100755
--- a/Examples/specular/PolarizedSpinAsymmetry.py
+++ b/Examples/specular/PolarizedSpinAsymmetry.py
@@ -55,12 +55,12 @@ def get_sample(params):
     r_Mafo = ba.LayerRoughness(params["r_Mafo"]*angstrom)
     r_substrate = ba.LayerRoughness(params["r_Mao"]*angstrom)
 
-    multi_layer = ba.MultiLayer()
-    multi_layer.addLayer(ambient_layer)
-    multi_layer.addLayerWithTopRoughness(layer, r_Mafo)
-    multi_layer.addLayerWithTopRoughness(substrate_layer, r_substrate)
+    sample = ba.MultiLayer()
+    sample.addLayer(ambient_layer)
+    sample.addLayerWithTopRoughness(layer, r_Mafo)
+    sample.addLayerWithTopRoughness(substrate_layer, r_substrate)
 
-    return multi_layer
+    return sample
 
 
 def get_simulation(sample, q_axis, parameters, polarizer_dir, analyzer_dir):
diff --git a/Examples/specular/RoughnessModel.py b/Examples/specular/RoughnessModel.py
index 0291e12efe9..84d4830d4a3 100755
--- a/Examples/specular/RoughnessModel.py
+++ b/Examples/specular/RoughnessModel.py
@@ -30,17 +30,17 @@ def get_sample(roughness_model):
     # define roughness
     roughness = ba.LayerRoughness(10*angstrom)
 
-    # create multilayer
-    multi_layer = ba.MultiLayer()
-    multi_layer.addLayer(ambient_layer)
+    # create sample
+    sample = ba.MultiLayer()
+    sample.addLayer(ambient_layer)
     for _ in range(10):
-        multi_layer.addLayerWithTopRoughness(ti_layer, roughness)
-        multi_layer.addLayerWithTopRoughness(ni_layer, roughness)
-    multi_layer.addLayerWithTopRoughness(substrate_layer, roughness)
+        sample.addLayerWithTopRoughness(ti_layer, roughness)
+        sample.addLayerWithTopRoughness(ni_layer, roughness)
+    sample.addLayerWithTopRoughness(substrate_layer, roughness)
 
-    multi_layer.setRoughnessModel(roughness_model)
+    sample.setRoughnessModel(roughness_model)
 
-    return multi_layer
+    return sample
 
 
 def get_simulation(sample):
diff --git a/Examples/specular/SpecularSimulationWithRoughness.py b/Examples/specular/SpecularSimulationWithRoughness.py
index 304598c0e3d..41c24d2f3cd 100755
--- a/Examples/specular/SpecularSimulationWithRoughness.py
+++ b/Examples/specular/SpecularSimulationWithRoughness.py
@@ -24,14 +24,14 @@ def get_sample():
     roughness = ba.LayerRoughness(1*nm)
 
     # Sample
-    multi_layer = ba.MultiLayer()
-    multi_layer.addLayer(ambient_layer)
+    sample = ba.MultiLayer()
+    sample.addLayer(ambient_layer)
     for _ in range(10):
-        multi_layer.addLayerWithTopRoughness(ti_layer, roughness)
-        multi_layer.addLayerWithTopRoughness(ni_layer, roughness)
-    multi_layer.addLayerWithTopRoughness(substrate_layer, roughness)
+        sample.addLayerWithTopRoughness(ti_layer, roughness)
+        sample.addLayerWithTopRoughness(ni_layer, roughness)
+    sample.addLayerWithTopRoughness(substrate_layer, roughness)
 
-    return multi_layer
+    return sample
 
 
 def get_simulation(sample):
diff --git a/Examples/varia/MaterialProfile.py b/Examples/varia/MaterialProfile.py
index 9eef50d066e..8a6299cfc41 100755
--- a/Examples/varia/MaterialProfile.py
+++ b/Examples/varia/MaterialProfile.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 """
-Basic example for producing a profile of SLD of a multilayer.
+Basic example for producing a profile of SLD of a sample.
 """
 
 import bornagain as ba
@@ -26,16 +26,16 @@ def get_sample():
     ni_layer = ba.Layer(m_ni, 70*angstrom)
     substrate_layer = ba.Layer(m_substrate)
 
-    # create multilayer
-    multi_layer = ba.MultiLayer()
-    multi_layer.addLayer(ambient_layer)
+    # create sample
+    sample = ba.MultiLayer()
+    sample.addLayer(ambient_layer)
     roughness = ba.LayerRoughness(5*angstrom, 0.5, 10*angstrom)
     for _ in range(4):
-        multi_layer.addLayerWithTopRoughness(ti_layer, roughness)
-        multi_layer.addLayerWithTopRoughness(ni_layer, roughness)
-    multi_layer.addLayer(substrate_layer)
+        sample.addLayerWithTopRoughness(ti_layer, roughness)
+        sample.addLayerWithTopRoughness(ni_layer, roughness)
+    sample.addLayer(substrate_layer)
 
-    return multi_layer
+    return sample
 
 
 if __name__ == '__main__':
diff --git a/Examples/varia/MaterialProfileWithParticles.py b/Examples/varia/MaterialProfileWithParticles.py
index 9d15c21afcd..0af35ccafd7 100755
--- a/Examples/varia/MaterialProfileWithParticles.py
+++ b/Examples/varia/MaterialProfileWithParticles.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 """
-Example for producing a profile of SLD of a multilayer with particles
+Example for producing a profile of SLD of a sample with particles
 and slicing.
 """
 
@@ -41,15 +41,15 @@ def get_sample():
     ambient_layer.addLayout(layout)
     ambient_layer.setNumberOfSlices(20)
 
-    # creating multilayer
-    multi_layer = ba.MultiLayer()
-    multi_layer.addLayer(ambient_layer)
+    # creating sample
+    sample = ba.MultiLayer()
+    sample.addLayer(ambient_layer)
     for _ in range(2):
-        multi_layer.addLayerWithTopRoughness(ti_layer, roughness)
-        multi_layer.addLayerWithTopRoughness(ni_layer, roughness)
-    multi_layer.addLayer(substrate_layer)
+        sample.addLayerWithTopRoughness(ti_layer, roughness)
+        sample.addLayerWithTopRoughness(ni_layer, roughness)
+    sample.addLayer(substrate_layer)
 
-    return multi_layer
+    return sample
 
 
 if __name__ == '__main__':
diff --git a/GUI/Model/Job/JobItem.cpp b/GUI/Model/Job/JobItem.cpp
index 93cb6f65ea3..5ade581e34e 100644
--- a/GUI/Model/Job/JobItem.cpp
+++ b/GUI/Model/Job/JobItem.cpp
@@ -250,13 +250,13 @@ bool JobItem::runInBackground() const
 
 MultiLayerItem* JobItem::sampleItem()
 {
-    return &m_multiLayerItem;
+    return &m_sampleItem;
 }
 
 MultiLayerItem* JobItem::copySampleIntoJob(const MultiLayerItem* sample)
 {
-    m_multiLayerItem.initFrom(sample);
-    return &m_multiLayerItem;
+    m_sampleItem.initFrom(sample);
+    return &m_sampleItem;
 }
 
 InstrumentItem* JobItem::instrumentItem() const
@@ -348,7 +348,7 @@ Data1DViewItem* JobItem::createDataViewItem()
 
 QString JobItem::sampleName() const
 {
-    return m_multiLayerItem.sampleName();
+    return m_sampleItem.sampleName();
 }
 
 QString JobItem::instrumentName() const
@@ -382,7 +382,7 @@ void JobItem::writeNonSessionItems(QXmlStreamWriter* writer) const
     Streamer(writer).write<InstrumentItemCatalog>(Tags::Instrument, m_instrument.get());
 
     writer->writeStartElement(Tags::Sample);
-    m_multiLayerItem.writeContentTo(writer);
+    m_sampleItem.writeContentTo(writer);
     writer->writeEndElement();
 
     writer->writeStartElement(Tags::ParameterContainer);
@@ -412,7 +412,7 @@ void JobItem::readNonSessionItems(QXmlStreamReader* reader)
             m_parameterContainer.readContentFrom(reader);
             GUI::Session::XML::gotoEndElementOfTag(reader, Tags::ParameterContainer);
         } else if (reader->name() == Tags::Sample) {
-            m_multiLayerItem.readContentFrom(reader);
+            m_sampleItem.readContentFrom(reader);
             GUI::Session::XML::gotoEndElementOfTag(reader, Tags::Sample);
         }
     }
diff --git a/GUI/Model/Job/JobItem.h b/GUI/Model/Job/JobItem.h
index d18dd1d718a..a5a936ebd6d 100644
--- a/GUI/Model/Job/JobItem.h
+++ b/GUI/Model/Job/JobItem.h
@@ -155,7 +155,7 @@ private:
 
     SimulationOptionsItem m_simulationOptionsItem;
     ParameterContainerItem m_parameterContainer;
-    MultiLayerItem m_multiLayerItem;
+    MultiLayerItem m_sampleItem;
     std::unique_ptr<InstrumentItem> m_instrument;
 };
 
diff --git a/GUI/Model/Model/JobModel.cpp b/GUI/Model/Model/JobModel.cpp
index 93b611b424a..2563898c8b9 100644
--- a/GUI/Model/Model/JobModel.cpp
+++ b/GUI/Model/Model/JobModel.cpp
@@ -50,18 +50,18 @@ JobItem* JobModel::getJobItemForIdentifier(const QString& identifier)
 }
 
 //! Main method to add a job
-JobItem* JobModel::addJob(const MultiLayerItem* multiLayerItem,
+JobItem* JobModel::addJob(const MultiLayerItem* sampleItem,
                           const InstrumentItem* instrumentItem, const RealDataItem* realDataItem,
                           const SimulationOptionsItem& optionItem)
 {
-    ASSERT(multiLayerItem);
+    ASSERT(sampleItem);
     ASSERT(instrumentItem);
 
     auto* jobItem = insertItem<JobItem>();
     jobItem->setItemName(generateJobName());
     jobItem->setIdentifier(QUuid::createUuid().toString());
 
-    jobItem->copySampleIntoJob(multiLayerItem);
+    jobItem->copySampleIntoJob(sampleItem);
     GUI::Model::JobFunctions::setupJobItemInstrument(jobItem, instrumentItem);
 
     jobItem->copySimulationOptionsIntoJob(optionItem);
diff --git a/GUI/Model/Model/JobModel.h b/GUI/Model/Model/JobModel.h
index 5985312ded4..27bcc68fbf2 100644
--- a/GUI/Model/Model/JobModel.h
+++ b/GUI/Model/Model/JobModel.h
@@ -33,7 +33,7 @@ public:
 
     JobItem* getJobItemForIdentifier(const QString& identifier);
 
-    JobItem* addJob(const MultiLayerItem* multiLayerItem, const InstrumentItem* instrumentItem,
+    JobItem* addJob(const MultiLayerItem* sampleItem, const InstrumentItem* instrumentItem,
                     const RealDataItem* realDataItem, const SimulationOptionsItem& optionItem);
 
     QVector<JobItem*> jobItems() const;
diff --git a/GUI/Model/Project/ProjectDocument.cpp b/GUI/Model/Project/ProjectDocument.cpp
index 12112596acd..632eb5205e2 100644
--- a/GUI/Model/Project/ProjectDocument.cpp
+++ b/GUI/Model/Project/ProjectDocument.cpp
@@ -128,9 +128,9 @@ InstrumentItems* ProjectDocument::instrumentItems() const
     return const_cast<InstrumentItems*>(&m_instruments);
 }
 
-MultiLayerItems* ProjectDocument::multiLayerItems()
+MultiLayerItems* ProjectDocument::sampleItems()
 {
-    return &m_multiLayerItems;
+    return &m_sampleItems;
 }
 
 RealDataModel* ProjectDocument::realDataModel() const
@@ -347,7 +347,7 @@ ProjectDocument::ReadResult ProjectDocument::readProject(QIODevice* device,
                             GUI::Session::XML::assertExpectedTag(&reader, SimulationOptionsTag);
                         } else if (reader.name() == SamplesTag) {
                             Streamer s(&reader);
-                            m_multiLayerItems.serialize(s);
+                            m_sampleItems.serialize(s);
                             // cleanup
                             if (reader.name() != SamplesTag) {
                                 if (!reader.isEndElement())
@@ -412,7 +412,7 @@ void ProjectDocument::writeTo(QIODevice* device)
 
     writer.writeStartElement(SamplesTag);
     Streamer s(&writer);
-    m_multiLayerItems.serialize(s);
+    m_sampleItems.serialize(s);
     writer.writeEndElement();
 
     writer.writeStartElement(InstrumentsTag);
diff --git a/GUI/Model/Project/ProjectDocument.h b/GUI/Model/Project/ProjectDocument.h
index e5367731b3d..430e182dd7e 100644
--- a/GUI/Model/Project/ProjectDocument.h
+++ b/GUI/Model/Project/ProjectDocument.h
@@ -71,7 +71,7 @@ public:
     void setProjectFileName(const QString& projectFileName);
 
     InstrumentItems* instrumentItems() const;
-    MultiLayerItems* multiLayerItems();
+    MultiLayerItems* sampleItems();
     RealDataModel* realDataModel() const;
     JobModel* jobModel() const;
     SimulationOptionsItem* simulationOptionsItem();
@@ -143,7 +143,7 @@ private:
     bool m_singleSampleMode;
     Functionalities m_functionalities;
     SimulationOptionsItem m_simulationOptionsItem;
-    MultiLayerItems m_multiLayerItems;
+    MultiLayerItems m_sampleItems;
     InstrumentsEditController m_instrumentEditController;
     InstrumentItems m_instruments;
 };
diff --git a/GUI/Model/Sample/MultiLayerItems.cpp b/GUI/Model/Sample/MultiLayerItems.cpp
index 3aa5f76b58b..02b48b3fadf 100644
--- a/GUI/Model/Sample/MultiLayerItems.cpp
+++ b/GUI/Model/Sample/MultiLayerItems.cpp
@@ -20,35 +20,35 @@
 
 MultiLayerItems::~MultiLayerItems()
 {
-    qDeleteAll(m_multiLayers);
+    qDeleteAll(m_samples);
 }
 
-QVector<MultiLayerItem*> MultiLayerItems::multiLayerItems() const
+QVector<MultiLayerItem*> MultiLayerItems::sampleItems() const
 {
-    return m_multiLayers;
+    return m_samples;
 }
 
 MultiLayerItem* MultiLayerItems::addMultiLayer()
 {
-    m_multiLayers << new MultiLayerItem();
-    return m_multiLayers.back();
+    m_samples << new MultiLayerItem();
+    return m_samples.back();
 }
 
-void MultiLayerItems::addMultiLayer(MultiLayerItem* multilayer)
+void MultiLayerItems::addMultiLayer(MultiLayerItem* sample)
 {
-    m_multiLayers << multilayer;
+    m_samples << sample;
 }
 
-void MultiLayerItems::removeMultiLayer(MultiLayerItem* multilayer)
+void MultiLayerItems::removeMultiLayer(MultiLayerItem* sample)
 {
-    m_multiLayers.removeAll(multilayer);
-    delete multilayer;
+    m_samples.removeAll(sample);
+    delete sample;
 }
 
-QStringList MultiLayerItems::multiLayerNames() const
+QStringList MultiLayerItems::sampleNames() const
 {
     QStringList existingNames;
-    for (const auto* item : m_multiLayers)
+    for (const auto* item : m_samples)
         existingNames << item->sampleName();
     return existingNames;
 }
@@ -56,5 +56,5 @@ QStringList MultiLayerItems::multiLayerNames() const
 void MultiLayerItems::serialize(Streamer& s)
 {
     s.assertVersion(0);
-    Serialize::rwVector(s, "Multilayers", m_multiLayers);
+    Serialize::rwVector(s, "Multilayers", m_samples);
 }
diff --git a/GUI/Model/Sample/MultiLayerItems.h b/GUI/Model/Sample/MultiLayerItems.h
index ef26529db42..ca38ab14365 100644
--- a/GUI/Model/Sample/MultiLayerItems.h
+++ b/GUI/Model/Sample/MultiLayerItems.h
@@ -25,19 +25,19 @@ class Streamer;
 class MultiLayerItems {
 public:
     ~MultiLayerItems();
-    QVector<MultiLayerItem*> multiLayerItems() const;
+    QVector<MultiLayerItem*> sampleItems() const;
 
-    //! Adds a multilayer and returns the new item.
+    //! Adds a sample and returns the new item.
     MultiLayerItem* addMultiLayer();
-    void addMultiLayer(MultiLayerItem* multilayer);
-    void removeMultiLayer(MultiLayerItem* multilayer);
+    void addMultiLayer(MultiLayerItem* sample);
+    void removeMultiLayer(MultiLayerItem* sample);
 
-    QStringList multiLayerNames() const;
+    QStringList sampleNames() const;
 
     void serialize(Streamer& s);
 
 private:
-    QVector<MultiLayerItem*> m_multiLayers;
+    QVector<MultiLayerItem*> m_samples;
 };
 
 #endif // BORNAGAIN_GUI_MODEL_SAMPLE_MULTILAYERITEMS_H
diff --git a/GUI/Model/Sample/SampleValidator.cpp b/GUI/Model/Sample/SampleValidator.cpp
index fc007f85257..2e0bbd85134 100644
--- a/GUI/Model/Sample/SampleValidator.cpp
+++ b/GUI/Model/Sample/SampleValidator.cpp
@@ -61,11 +61,11 @@ void SampleValidator::addMessage(const QString& m)
     m_messages += QString("* ") + m + "\n";
 }
 
-bool SampleValidator::isValidMultiLayer(const MultiLayerItem* multilayer)
+bool SampleValidator::isValidMultiLayer(const MultiLayerItem* sample)
 {
     m_messages.clear();
 
-    QVector<LayerItem*> layers = multilayer->layers();
+    QVector<LayerItem*> layers = sample->layers();
 
     if (layers.isEmpty())
         addMessage("MultiLayer should contain at least one layer.");
diff --git a/GUI/Model/Sample/SampleValidator.h b/GUI/Model/Sample/SampleValidator.h
index 139f9b1abc5..73d4af41aa9 100644
--- a/GUI/Model/Sample/SampleValidator.h
+++ b/GUI/Model/Sample/SampleValidator.h
@@ -24,7 +24,7 @@ class ItemWithParticles;
 //! Validates whether MultiLayerItem is suitable for simulation
 class SampleValidator {
 public:
-    bool isValidMultiLayer(const MultiLayerItem* multilayer);
+    bool isValidMultiLayer(const MultiLayerItem* sample);
 
     QString getValidationMessage() const { return m_messages; }
 
diff --git a/GUI/Model/To/DomainSimulationBuilder.cpp b/GUI/Model/To/DomainSimulationBuilder.cpp
index 1a9af18fb27..1a50b07a41e 100644
--- a/GUI/Model/To/DomainSimulationBuilder.cpp
+++ b/GUI/Model/To/DomainSimulationBuilder.cpp
@@ -115,12 +115,12 @@ void setSimulationOptions(ISimulation* simulation, const SimulationOptionsItem&
 }
 
 std::unique_ptr<ScatteringSimulation>
-createScatteringSimulation(std::unique_ptr<MultiLayer> multilayer,
+createScatteringSimulation(std::unique_ptr<MultiLayer> sample,
                            const GISASInstrumentItem* instrumentItem,
                            const SimulationOptionsItem& optionsItem)
 {
     std::unique_ptr<ScatteringSimulation> result(
-        instrumentItem->createScatteringSimulation(*multilayer));
+        instrumentItem->createScatteringSimulation(*sample));
 
     addDistributionParametersToSimulation(*instrumentItem->beamItem(), *result);
 
@@ -133,12 +133,12 @@ createScatteringSimulation(std::unique_ptr<MultiLayer> multilayer,
 }
 
 std::unique_ptr<OffSpecularSimulation>
-createOffSpecularSimulation(std::unique_ptr<MultiLayer> multilayer,
+createOffSpecularSimulation(std::unique_ptr<MultiLayer> sample,
                             const OffSpecularInstrumentItem* instrumentItem,
                             const SimulationOptionsItem& optionsItem)
 {
     std::unique_ptr<OffSpecularSimulation> result(
-        instrumentItem->createOffSpecularSimulation(*multilayer));
+        instrumentItem->createOffSpecularSimulation(*sample));
 
     auto* beamItem = instrumentItem->beamItem();
     const auto axis = instrumentItem->alphaAxis().createAxis(Units::deg);
@@ -157,12 +157,12 @@ createOffSpecularSimulation(std::unique_ptr<MultiLayer> multilayer,
 }
 
 std::unique_ptr<SpecularSimulation>
-createSpecularSimulation(std::unique_ptr<MultiLayer> P_multilayer,
+createSpecularSimulation(std::unique_ptr<MultiLayer> P_sample,
                          const SpecularInstrumentItem* instrument,
                          const SimulationOptionsItem& optionsItem)
 {
     std::unique_ptr<SpecularSimulation> result = std::make_unique<SpecularSimulation>();
-    result->setSample(*P_multilayer);
+    result->setSample(*P_sample);
 
     auto* beam_item = instrument->beamItem();
     auto* const axis_item = beam_item->inclinationAxis();
@@ -185,12 +185,12 @@ createSpecularSimulation(std::unique_ptr<MultiLayer> P_multilayer,
 }
 
 std::unique_ptr<DepthProbeSimulation>
-createDepthProbeSimulation(std::unique_ptr<MultiLayer> multilayer,
+createDepthProbeSimulation(std::unique_ptr<MultiLayer> sample,
                            const DepthProbeInstrumentItem* instrument,
                            const SimulationOptionsItem& optionsItem)
 {
     std::unique_ptr<DepthProbeSimulation> result = instrument->createSimulation();
-    result->setSample(*multilayer);
+    result->setSample(*sample);
 
     setSimulationOptions(result.get(), optionsItem);
 
@@ -212,18 +212,18 @@ GUI::Model::DomainSimulationBuilder::createSimulation(const MultiLayerItem* samp
         throw Error(message);
     }
 
-    auto P_multilayer = GUI::Transform::ToDomain::buildMultiLayer(*sampleItem);
+    auto P_sample = GUI::Transform::ToDomain::buildMultiLayer(*sampleItem);
 
     if (const auto* gisasInstrument = dynamic_cast<const GISASInstrumentItem*>(instrumentItem))
-        return createScatteringSimulation(std::move(P_multilayer), gisasInstrument, optionsItem);
+        return createScatteringSimulation(std::move(P_sample), gisasInstrument, optionsItem);
     if (const auto* offspecInstrument =
             dynamic_cast<const OffSpecularInstrumentItem*>(instrumentItem))
-        return createOffSpecularSimulation(std::move(P_multilayer), offspecInstrument, optionsItem);
+        return createOffSpecularSimulation(std::move(P_sample), offspecInstrument, optionsItem);
     if (const auto* specular_instrument =
             dynamic_cast<const SpecularInstrumentItem*>(instrumentItem))
-        return createSpecularSimulation(std::move(P_multilayer), specular_instrument, optionsItem);
+        return createSpecularSimulation(std::move(P_sample), specular_instrument, optionsItem);
     if (const auto* penetrator = dynamic_cast<const DepthProbeInstrumentItem*>(instrumentItem))
-        return createDepthProbeSimulation(std::move(P_multilayer), penetrator, optionsItem);
+        return createDepthProbeSimulation(std::move(P_sample), penetrator, optionsItem);
 
     ASSERT(0);
 }
diff --git a/GUI/Model/To/ToDomain.cpp b/GUI/Model/To/ToDomain.cpp
index 1fde2138956..75476985708 100644
--- a/GUI/Model/To/ToDomain.cpp
+++ b/GUI/Model/To/ToDomain.cpp
@@ -40,13 +40,13 @@ namespace {
 
 std::unique_ptr<MultiLayer> createMultiLayer(const MultiLayerItem& item)
 {
-    auto P_multilayer = std::make_unique<MultiLayer>();
+    auto P_sample = std::make_unique<MultiLayer>();
     double cross_corr_length = item.crossCorrLength();
     if (cross_corr_length > 0)
-        P_multilayer->setCrossCorrLength(cross_corr_length);
+        P_sample->setCrossCorrLength(cross_corr_length);
     R3 external_field = item.externalField();
-    P_multilayer->setExternalField(external_field);
-    return P_multilayer;
+    P_sample->setExternalField(external_field);
+    return P_sample;
 }
 
 std::unique_ptr<Layer> createLayer(const LayerItem& item)
@@ -131,18 +131,18 @@ GUI::Transform::ToDomain::createLayerRoughness(LayerBasicRoughnessItem* roughnes
 }
 
 std::unique_ptr<MultiLayer>
-GUI::Transform::ToDomain::buildMultiLayer(const MultiLayerItem& multiLayerItem)
+GUI::Transform::ToDomain::buildMultiLayer(const MultiLayerItem& sampleItem)
 {
-    auto P_multilayer = createMultiLayer(multiLayerItem);
-    for (auto* layerItem : multiLayerItem.layers()) {
+    auto P_sample = createMultiLayer(sampleItem);
+    for (auto* layerItem : sampleItem.layers()) {
         auto P_layer = buildLayer(*layerItem);
         ASSERT(P_layer);
         const auto roughness = layerItem->roughness().currentItem();
         auto P_roughness = createLayerRoughness(roughness);
         if (P_roughness && !layerItem->isTopLayer())
-            P_multilayer->addLayerWithTopRoughness(*P_layer, *P_roughness);
+            P_sample->addLayerWithTopRoughness(*P_layer, *P_roughness);
         else
-            P_multilayer->addLayer(*P_layer);
+            P_sample->addLayer(*P_layer);
     }
-    return P_multilayer;
+    return P_sample;
 }
diff --git a/GUI/View/FromDomain/GUIExamplesFactory.h b/GUI/View/FromDomain/GUIExamplesFactory.h
index ead7cffc55d..2d25ce55388 100644
--- a/GUI/View/FromDomain/GUIExamplesFactory.h
+++ b/GUI/View/FromDomain/GUIExamplesFactory.h
@@ -24,7 +24,7 @@ namespace GUI::ExamplesFactory {
 
 bool isValidExampleName(const QString& name);
 
-//! Create a multilayer item of the built-in example with the given internal name.
+//! Create a sample item of the built-in example with the given internal name.
 MultiLayerItem* createMultiLayerItem(const QString& name);
 
 //! The internal example name, e.g. for creation with createMultiLayerItem.
diff --git a/GUI/View/FromDomain/GUISampleBuilder.cpp b/GUI/View/FromDomain/GUISampleBuilder.cpp
index 4b353104e6e..abcfb9289e3 100644
--- a/GUI/View/FromDomain/GUISampleBuilder.cpp
+++ b/GUI/View/FromDomain/GUISampleBuilder.cpp
@@ -34,26 +34,26 @@
 
 namespace GUI::Transform::FromDomain {
 
-MultiLayerItem* GUISampleBuilder::createMultiLayerItem(const MultiLayer& multiLayer,
+MultiLayerItem* GUISampleBuilder::createMultiLayerItem(const MultiLayer& sample,
                                                        const QString& nodeName)
 {
-    m_multilayerItem = new MultiLayerItem();
-    m_multilayerItem->setSampleName(
-        nodeName.isEmpty() ? QString::fromStdString(multiLayer.sampleName()) : nodeName);
-    m_multilayerItem->crossCorrLength().set(multiLayer.crossCorrLength());
-    m_multilayerItem->setExternalField(multiLayer.externalField());
+    m_sampleItem = new MultiLayerItem();
+    m_sampleItem->setSampleName(
+        nodeName.isEmpty() ? QString::fromStdString(sample.sampleName()) : nodeName);
+    m_sampleItem->crossCorrLength().set(sample.crossCorrLength());
+    m_sampleItem->setExternalField(sample.externalField());
 
     //  iterate over layers
-    for (size_t layerIndex = 0; layerIndex < multiLayer.numberOfLayers(); layerIndex++) {
-        const auto* layer = multiLayer.layer(layerIndex);
+    for (size_t layerIndex = 0; layerIndex < sample.numberOfLayers(); layerIndex++) {
+        const auto* layer = sample.layer(layerIndex);
 
         const LayerInterface* top_interface =
-            layerIndex == 0 ? nullptr : multiLayer.layerInterface(layerIndex - 1);
+            layerIndex == 0 ? nullptr : sample.layerInterface(layerIndex - 1);
 
-        auto* layerItem = m_multilayerItem->addLayer();
+        auto* layerItem = m_sampleItem->addLayer();
         layerItem->setMaterial(createMaterialFromDomain(layer->material()));
         layerItem->setIsTopLayer(layerIndex == 0);
-        layerItem->setIsBottomLayer(layerIndex == multiLayer.numberOfLayers() - 1);
+        layerItem->setIsBottomLayer(layerIndex == sample.numberOfLayers() - 1);
 
         FromDomain::setLayerItem(layerItem, layer, top_interface);
 
@@ -70,23 +70,23 @@ MultiLayerItem* GUISampleBuilder::createMultiLayerItem(const MultiLayer& multiLa
         }
     }
 
-    return m_multilayerItem;
+    return m_sampleItem;
 }
 
 MaterialItem* GUISampleBuilder::createMaterialFromDomain(const Material* material)
 {
     QString materialName = QString::fromStdString(material->materialName());
 
-    if (auto* materialItem = m_multilayerItem->materialItems().materialFromName(materialName))
+    if (auto* materialItem = m_sampleItem->materialItems().materialFromName(materialName))
         return materialItem;
 
     complex_t material_data = material->materialData();
     MaterialItem* materialItem(nullptr);
     if (material->typeID() == MATERIAL_TYPES::RefractiveMaterial) {
-        materialItem = m_multilayerItem->materialItems().addRefractiveMaterial(
+        materialItem = m_sampleItem->materialItems().addRefractiveMaterial(
             materialName, material_data.real(), material_data.imag());
     } else if (material->typeID() == MATERIAL_TYPES::MaterialBySLD) {
-        materialItem = m_multilayerItem->materialItems().addSLDMaterial(
+        materialItem = m_sampleItem->materialItems().addSLDMaterial(
             materialName, material_data.real(), material_data.imag());
     } else
         ASSERT(0);
@@ -108,7 +108,7 @@ void GUISampleBuilder::copyParticle(const IParticle* iparticle,
                                     std::function<void(ItemWithParticles*)> addToParent)
 {
     if (const auto* particle = dynamic_cast<const Particle*>(iparticle)) {
-        auto* particle_item = new ParticleItem(&m_multilayerItem->materialItems());
+        auto* particle_item = new ParticleItem(&m_sampleItem->materialItems());
         copyParticle(particle_item, particle);
         addToParent(particle_item);
     } else if (const auto* coreshell = dynamic_cast<const ParticleCoreShell*>(iparticle)) {
@@ -117,17 +117,17 @@ void GUISampleBuilder::copyParticle(const IParticle* iparticle,
         if (!coreshell->shellParticle())
             throw Exception("Sim/shell particle has no shell particle.");
 
-        auto* coreShellItem = new ParticleCoreShellItem(&m_multilayerItem->materialItems());
+        auto* coreShellItem = new ParticleCoreShellItem(&m_sampleItem->materialItems());
         coreShellItem->setAbundance(coreshell->abundance());
         coreShellItem->setPosition(coreshell->particlePosition());
         FromDomain::setRotation(coreShellItem, coreshell->rotation());
 
         if (coreshell->coreParticle()) {
-            coreShellItem->createCore(&m_multilayerItem->materialItems());
+            coreShellItem->createCore(&m_sampleItem->materialItems());
             copyParticle(coreShellItem->core(), coreshell->coreParticle());
         }
         if (coreshell->shellParticle()) {
-            coreShellItem->createShell(&m_multilayerItem->materialItems());
+            coreShellItem->createShell(&m_sampleItem->materialItems());
             copyParticle(coreShellItem->shell(), coreshell->shellParticle());
         }
 
@@ -136,7 +136,7 @@ void GUISampleBuilder::copyParticle(const IParticle* iparticle,
         if (!meso->particleStructure().basis())
             throw Exception("Meso crystal has no basis.");
 
-        auto* mesoItem = new MesoCrystalItem(&m_multilayerItem->materialItems());
+        auto* mesoItem = new MesoCrystalItem(&m_sampleItem->materialItems());
         mesoItem->setAbundance(meso->abundance());
         mesoItem->setPosition(meso->particlePosition());
         FromDomain::setFormFactor(mesoItem, meso->outerShape());
@@ -154,7 +154,7 @@ void GUISampleBuilder::copyParticle(const IParticle* iparticle,
     } else if (const auto* particleComposition =
                    dynamic_cast<const ParticleComposition*>(iparticle)) {
         auto* particleCompositionItem =
-            new ParticleCompositionItem(&m_multilayerItem->materialItems());
+            new ParticleCompositionItem(&m_sampleItem->materialItems());
 
         particleCompositionItem->setAbundance(particleComposition->abundance());
         particleCompositionItem->setPosition(particleComposition->particlePosition());
diff --git a/GUI/View/FromDomain/GUISampleBuilder.h b/GUI/View/FromDomain/GUISampleBuilder.h
index 9a6f6f5b7fa..cc3693308f3 100644
--- a/GUI/View/FromDomain/GUISampleBuilder.h
+++ b/GUI/View/FromDomain/GUISampleBuilder.h
@@ -46,7 +46,7 @@ public:
         QByteArray m_msgAsLatin1;
     };
 
-    MultiLayerItem* createMultiLayerItem(const MultiLayer& multiLayer,
+    MultiLayerItem* createMultiLayerItem(const MultiLayer& sample,
                                          const QString& nodeName = "");
 
 private:
@@ -56,7 +56,7 @@ private:
                       std::function<void(ItemWithParticles*)> addToParent);
     void copyParticle(ParticleItem* particleItem, const Particle* particle);
 
-    MultiLayerItem* m_multilayerItem;
+    MultiLayerItem* m_sampleItem;
 };
 
 } // namespace GUI::Transform::FromDomain
diff --git a/GUI/View/MaterialEditor/MaterialEditorDialog.cpp b/GUI/View/MaterialEditor/MaterialEditorDialog.cpp
index 09ccc91d0a5..e08bb5ca9a0 100644
--- a/GUI/View/MaterialEditor/MaterialEditorDialog.cpp
+++ b/GUI/View/MaterialEditor/MaterialEditorDialog.cpp
@@ -32,12 +32,12 @@
 #include <QToolBar>
 #include <QVBoxLayout>
 
-MaterialEditorDialog::MaterialEditorDialog(MultiLayerItem* multiLayer, QWidget* parent)
+MaterialEditorDialog::MaterialEditorDialog(MultiLayerItem* sample, QWidget* parent)
     : QDialog(parent)
     , m_ui(new Ui::MaterialEditorDialog)
-    , m_multiLayer(multiLayer)
+    , m_sample(sample)
 {
-    m_tmpMaterialItems.initFrom(m_multiLayer->materialItems());
+    m_tmpMaterialItems.initFrom(m_sample->materialItems());
 
     m_model = new MaterialEditorModel(&m_tmpMaterialItems);
 
@@ -147,14 +147,14 @@ MaterialEditorDialog::~MaterialEditorDialog()
 
 void MaterialEditorDialog::accept()
 {
-    m_multiLayer->materialItems().initFrom(m_tmpMaterialItems);
+    m_sample->materialItems().initFrom(m_tmpMaterialItems);
     QDialog::accept();
 }
 
-QString MaterialEditorDialog::chooseMaterial(QWidget* parent, MultiLayerItem* multiLayer,
+QString MaterialEditorDialog::chooseMaterial(QWidget* parent, MultiLayerItem* sample,
                                              const QString& identifierOfPreviousMaterial)
 {
-    MaterialEditorDialog dialog(multiLayer, parent);
+    MaterialEditorDialog dialog(sample, parent);
     dialog.setCurrentMaterial(identifierOfPreviousMaterial);
     if (dialog.exec() == QDialog::Accepted)
         if (MaterialItem* material = dialog.currentMaterial())
@@ -163,9 +163,9 @@ QString MaterialEditorDialog::chooseMaterial(QWidget* parent, MultiLayerItem* mu
     return QString();
 }
 
-void MaterialEditorDialog::editMaterials(QWidget* parent, MultiLayerItem* multiLayer)
+void MaterialEditorDialog::editMaterials(QWidget* parent, MultiLayerItem* sample)
 {
-    MaterialEditorDialog dialog(multiLayer, parent);
+    MaterialEditorDialog dialog(sample, parent);
     dialog.exec();
 }
 
@@ -278,7 +278,7 @@ QModelIndex MaterialEditorDialog::currentIndex() const
 QStringList MaterialEditorDialog::identifiersOfUsedMaterials() const
 {
     QStringList result;
-    for (auto* p : m_multiLayer->itemsWithMaterial())
+    for (auto* p : m_sample->itemsWithMaterial())
         result << p->materialIdentifier();
     return result;
 }
diff --git a/GUI/View/MaterialEditor/MaterialEditorDialog.h b/GUI/View/MaterialEditor/MaterialEditorDialog.h
index da3d4af4619..5007d2170cf 100644
--- a/GUI/View/MaterialEditor/MaterialEditorDialog.h
+++ b/GUI/View/MaterialEditor/MaterialEditorDialog.h
@@ -40,14 +40,14 @@ public:
     //! selected when opening the dialog. Returns the identifier of the newly selected material.
     //! Returns an empty string, if the dialog is
     //! cancelled.
-    static QString chooseMaterial(QWidget* parent, MultiLayerItem* multiLayer,
+    static QString chooseMaterial(QWidget* parent, MultiLayerItem* sample,
                                   const QString& identifierOfPreviousMaterial);
 
     //! Use this to edit the list of existing materials.
-    static void editMaterials(QWidget* parent, MultiLayerItem* multiLayer);
+    static void editMaterials(QWidget* parent, MultiLayerItem* sample);
 
 private:
-    MaterialEditorDialog(MultiLayerItem* multiLayer, QWidget* parent = nullptr);
+    MaterialEditorDialog(MultiLayerItem* sample, QWidget* parent = nullptr);
     ~MaterialEditorDialog() override;
 
     //! updates original material model with the edited model
@@ -79,7 +79,7 @@ private:
     Ui::MaterialEditorDialog* m_ui;
 
     MaterialEditorModel* m_model; //! Model for the left list. Works on m_tmpMaterialItems
-    MultiLayerItem* m_multiLayer;
+    MultiLayerItem* m_sample;
 };
 
 #endif // BORNAGAIN_GUI_VIEW_MATERIALEDITOR_MATERIALEDITORDIALOG_H
diff --git a/GUI/View/Project/PyImportAssistant.cpp b/GUI/View/Project/PyImportAssistant.cpp
index 5b840b9c23f..1d887cbdd9e 100644
--- a/GUI/View/Project/PyImportAssistant.cpp
+++ b/GUI/View/Project/PyImportAssistant.cpp
@@ -56,7 +56,7 @@ QString getCandidate(const QStringList& funcNames)
 
     for (auto str : funcNames) {
         QString name = str.toLower();
-        if (name.contains("sample") || name.contains("multilayer"))
+        if (name.contains("sample") || name.contains("sample"))
             return str;
     }
 
@@ -109,7 +109,7 @@ std::unique_ptr<MultiLayer> createMultiLayer(const QString& snippet, const QStri
                                               bornagainDir());
     } catch (const std::exception& ex) {
         QApplication::restoreOverrideCursor();
-        QString message("Exception thrown while executing Python code to create multilayer.\n\n");
+        QString message("Exception thrown while executing Python code to create sample.\n\n");
         QString details = QString::fromStdString(std::string(ex.what()));
         DetailedMessageBox(GUI::Global::mainWindow, "Python failure", message, details).exec();
     }
@@ -184,20 +184,20 @@ std::unique_ptr<MultiLayer> PyImportAssistant::importMultiLayer()
     if (funcName.isEmpty())
         return {};
 
-    auto multilayer = createMultiLayer(snippet, funcName);
-    if (!multilayer)
+    auto sample = createMultiLayer(snippet, funcName);
+    if (!sample)
         return {};
 
-    if (multilayer->sampleName() == "Unnamed")
-        multilayer->setSampleName(GUI::Util::Path::baseName(fileName).toStdString());
+    if (sample->sampleName() == "Unnamed")
+        sample->setSampleName(GUI::Util::Path::baseName(fileName).toStdString());
 
-    return multilayer;
+    return sample;
 }
 
-MultiLayerItem* PyImportAssistant::createMultiLayerItem(const MultiLayer& multilayer)
+MultiLayerItem* PyImportAssistant::createMultiLayerItem(const MultiLayer& sample)
 {
     try {
-        auto* newItem = GUI::Transform::FromDomain::createMultiLayerItem(multilayer);
+        auto* newItem = GUI::Transform::FromDomain::createMultiLayerItem(sample);
 
         QString message("Seems that import was successful.\n\n"
                         "Check SampleView for new sample and material editor for new materials.");
diff --git a/GUI/View/Project/PyImportAssistant.h b/GUI/View/Project/PyImportAssistant.h
index 5b7704b53c7..3ec3d35658d 100644
--- a/GUI/View/Project/PyImportAssistant.h
+++ b/GUI/View/Project/PyImportAssistant.h
@@ -26,13 +26,13 @@ class MultiLayer;
 
 namespace PyImportAssistant {
 
-//! Show select-file dialog, try to import via python, return created multilayer.
+//! Show select-file dialog, try to import via python, return created sample.
 //!
 //! If sth. went wrong, a dialog has presented already and nullptr is returned.
 std::unique_ptr<MultiLayer> importMultiLayer();
 
-//! Populates GUI multilayer with domain multilayer.
-MultiLayerItem* createMultiLayerItem(const MultiLayer& multilayer);
+//! Populates GUI sample with domain sample.
+MultiLayerItem* createMultiLayerItem(const MultiLayer& sample);
 
 } // namespace PyImportAssistant
 
diff --git a/GUI/View/SampleDesigner/LayerForm.cpp b/GUI/View/SampleDesigner/LayerForm.cpp
index 4c82604bf3a..18167777545 100644
--- a/GUI/View/SampleDesigner/LayerForm.cpp
+++ b/GUI/View/SampleDesigner/LayerForm.cpp
@@ -107,7 +107,7 @@ void LayerForm::enableStructureEditing(bool b)
     for (auto* w : m_structureEditingWidgets)
         w->setVisible(b);
 
-    if (b && m_ec->multiLayerItem()->layers().size() < 2)
+    if (b && m_ec->sampleItem()->layers().size() < 2)
         m_moveButton->setVisible(false);
 }
 
@@ -119,7 +119,7 @@ void LayerForm::updateColor()
 
 void LayerForm::updateTitle()
 {
-    int i = m_ec->multiLayerItem()->layers().indexOf(m_layer);
+    int i = m_ec->sampleItem()->layers().indexOf(m_layer);
     m_collapser->setTitle("Layer " + QString::number(i)
                           + "     Material: " + m_layer->materialName());
 }
@@ -136,12 +136,12 @@ void LayerForm::updateLayerPositionDependentElements()
 
     updateTitle();
 
-    const auto* multiLayer = m_ec->multiLayerItem();
-    const bool isFirstLayer = multiLayer->layers().first() == m_layer;
-    const bool isLastLayer = multiLayer->layers().last() == m_layer;
+    const auto* sample = m_ec->sampleItem();
+    const bool isFirstLayer = sample->layers().first() == m_layer;
+    const bool isLastLayer = sample->layers().last() == m_layer;
     const bool thicknessIsSemiInfinite =
-        (isFirstLayer || isLastLayer) && (multiLayer->layers().size() != 1);
-    const bool thicknessIsInfinite = multiLayer->layers().size() == 1;
+        (isFirstLayer || isLastLayer) && (sample->layers().size() != 1);
+    const bool thicknessIsInfinite = sample->layers().size() == 1;
 
     m_layouter->setRowVisible(m_roughnessRow, !isFirstLayer);
 
@@ -164,7 +164,7 @@ void LayerForm::updateLayerPositionDependentElements()
         m_layouter->insertValue(m_thicknessRow, m_layer->thickness());
     }
 
-    if (m_ec->multiLayerItem()->layers().size() < 2)
+    if (m_ec->sampleItem()->layers().size() < 2)
         m_moveButton->setVisible(false);
 }
 
diff --git a/GUI/View/SampleDesigner/LayerOrientedSampleEditor.cpp b/GUI/View/SampleDesigner/LayerOrientedSampleEditor.cpp
index a58651ecf0a..51096eb251b 100644
--- a/GUI/View/SampleDesigner/LayerOrientedSampleEditor.cpp
+++ b/GUI/View/SampleDesigner/LayerOrientedSampleEditor.cpp
@@ -88,7 +88,7 @@ LayerOrientedSampleEditor::~LayerOrientedSampleEditor()
     qDeleteAll(m_editControllers.values());
 }
 
-void LayerOrientedSampleEditor::setCurrentSample(MultiLayerItem* multiLayerItem)
+void LayerOrientedSampleEditor::setCurrentSample(MultiLayerItem* sampleItem)
 {
     if (m_currentMultiLayerItem != nullptr)
         m_editControllers[m_currentMultiLayerItem]->setMultiLayerForm(nullptr);
@@ -102,7 +102,7 @@ void LayerOrientedSampleEditor::setCurrentSample(MultiLayerItem* multiLayerItem)
     delete m_redoAction;
     m_redoAction = nullptr;
 
-    m_currentMultiLayerItem = multiLayerItem;
+    m_currentMultiLayerItem = sampleItem;
     if (m_currentMultiLayerItem == nullptr) {
         m_scrollArea->setWidget(createEmptyWidget());
         updateActionEnabling();
diff --git a/GUI/View/SampleDesigner/LayerOrientedSampleEditor.h b/GUI/View/SampleDesigner/LayerOrientedSampleEditor.h
index 154ece95e52..4c76d70ba7e 100644
--- a/GUI/View/SampleDesigner/LayerOrientedSampleEditor.h
+++ b/GUI/View/SampleDesigner/LayerOrientedSampleEditor.h
@@ -34,7 +34,7 @@ public:
     LayerOrientedSampleEditor(QWidget* parent, ProjectDocument* document);
     ~LayerOrientedSampleEditor() override;
 
-    void setCurrentSample(MultiLayerItem* multiLayerItem);
+    void setCurrentSample(MultiLayerItem* sampleItem);
 
 signals:
     void requestViewInRealSpace(SampleItem itemToShow);
diff --git a/GUI/View/SampleDesigner/MaterialInplaceForm.cpp b/GUI/View/SampleDesigner/MaterialInplaceForm.cpp
index 8c0e98c7b68..31482c44f79 100644
--- a/GUI/View/SampleDesigner/MaterialInplaceForm.cpp
+++ b/GUI/View/SampleDesigner/MaterialInplaceForm.cpp
@@ -65,9 +65,9 @@ void MaterialInplaceForm::updateValues()
 
 void MaterialInplaceForm::selectMaterial()
 {
-    const auto materialsBackup = GUI::Util::createBackup(&m_ec->multiLayerItem()->materialItems());
+    const auto materialsBackup = GUI::Util::createBackup(&m_ec->sampleItem()->materialItems());
     const QString newMaterialIdentifier = MaterialEditorDialog::chooseMaterial(
-        GUI::Global::mainWindow, m_ec->multiLayerItem(), m_item->materialIdentifier());
+        GUI::Global::mainWindow, m_ec->sampleItem(), m_item->materialIdentifier());
 
     if (!newMaterialIdentifier.isEmpty() && newMaterialIdentifier != m_item->materialIdentifier()) {
         itemWithMaterial()->materialItem()->disconnect(this);
@@ -82,7 +82,7 @@ void MaterialInplaceForm::selectMaterial()
 
         // If the list of materials was edited (e.g. a material added), but the current was not
         // changed, no modified signal would be sent. Check now for changes and emit if necessary.
-        if (GUI::Util::createBackup(&m_ec->multiLayerItem()->materialItems()) != materialsBackup)
+        if (GUI::Util::createBackup(&m_ec->sampleItem()->materialItems()) != materialsBackup)
             m_ec->modified();
     }
 }
diff --git a/GUI/View/SampleDesigner/MultiLayerForm.cpp b/GUI/View/SampleDesigner/MultiLayerForm.cpp
index 8a1de6c9a3e..185f30c93ef 100644
--- a/GUI/View/SampleDesigner/MultiLayerForm.cpp
+++ b/GUI/View/SampleDesigner/MultiLayerForm.cpp
@@ -52,10 +52,10 @@ public:
 
 } // namespace
 
-MultiLayerForm::MultiLayerForm(QWidget* parent, MultiLayerItem* multiLayerItem,
+MultiLayerForm::MultiLayerForm(QWidget* parent, MultiLayerItem* sampleItem,
                                SampleEditorController* ec)
     : QWidget(parent)
-    , m_multiLayerItem(multiLayerItem)
+    , m_sampleItem(sampleItem)
     , m_ec(ec)
     , m_useAngstrom(false)
     , m_useRadiant(false)
@@ -72,7 +72,7 @@ MultiLayerForm::MultiLayerForm(QWidget* parent, MultiLayerItem* multiLayerItem,
 
     auto* nameEdit = new QLineEdit(props);
     layouter.addRow("Name:", nameEdit);
-    nameEdit->setText(multiLayerItem->sampleName());
+    nameEdit->setText(sampleItem->sampleName());
     connect(nameEdit, &QLineEdit::textEdited, ec, &SampleEditorController::setSampleName);
 
     auto* descriptionEdit = new QTextEdit(props);
@@ -80,23 +80,23 @@ MultiLayerForm::MultiLayerForm(QWidget* parent, MultiLayerItem* multiLayerItem,
     descriptionEdit->setMaximumHeight(100);
     descriptionEdit->setAcceptRichText(false);
     descriptionEdit->setTabChangesFocus(true);
-    descriptionEdit->setPlainText(multiLayerItem->description());
+    descriptionEdit->setPlainText(sampleItem->description());
     layouter.addRow("Description:", descriptionEdit);
     connect(descriptionEdit, &QTextEdit::textChanged,
             [=]() { m_ec->setSampleDescription(descriptionEdit->toPlainText()); });
 
-    layouter.addValue(multiLayerItem->crossCorrLength());
-    layouter.addVector(multiLayerItem->externalFieldVector(), false);
+    layouter.addValue(sampleItem->crossCorrLength());
+    layouter.addVector(sampleItem->externalFieldVector(), false);
     auto* collapser = GroupBoxCollapser::installIntoGroupBox(props, false);
 
     auto* showInRealSpaceAction = ActionFactory::createShowInRealSpaceAction(
-        this, "sample", [=] { m_ec->requestViewInRealSpace(m_multiLayerItem); });
+        this, "sample", [=] { m_ec->requestViewInRealSpace(m_sampleItem); });
 
     collapser->addAction(showInRealSpaceAction);
 
     m_layout->addWidget(props);
 
-    for (auto* layer : multiLayerItem->layers()) {
+    for (auto* layer : sampleItem->layers()) {
         m_layout->addWidget(new AddLayerWidget(this, layer, m_ec));
         m_layout->addWidget(new LayerForm(this, layer, m_ec));
     }
@@ -113,7 +113,7 @@ void MultiLayerForm::showInlineEditButtons(bool b)
 
 void MultiLayerForm::onLayerAdded(LayerItem* layerItem)
 {
-    const int rowInMultiLayer = m_multiLayerItem->layers().indexOf(layerItem);
+    const int rowInMultiLayer = m_sampleItem->layers().indexOf(layerItem);
 
     const int rowInLayout = rowInMultiLayer * 2 + 1;
 
@@ -147,7 +147,7 @@ void MultiLayerForm::onLayerMoved(LayerItem* layerItem)
             }
     }
 
-    const int rowInMultiLayer = m_multiLayerItem->layers().indexOf(layerItem);
+    const int rowInMultiLayer = m_sampleItem->layers().indexOf(layerItem);
     const int rowInLayout = rowInMultiLayer * 2 + 1;
 
     m_layout->insertWidget(rowInLayout, wl);
diff --git a/GUI/View/SampleDesigner/MultiLayerForm.h b/GUI/View/SampleDesigner/MultiLayerForm.h
index a4e8bd67a2f..c6ec52109c2 100644
--- a/GUI/View/SampleDesigner/MultiLayerForm.h
+++ b/GUI/View/SampleDesigner/MultiLayerForm.h
@@ -28,7 +28,7 @@ class LayerForm;
 class MultiLayerForm : public QWidget {
     Q_OBJECT
 public:
-    MultiLayerForm(QWidget* parent, MultiLayerItem* multiLayerItem, SampleEditorController* ec);
+    MultiLayerForm(QWidget* parent, MultiLayerItem* sampleItem, SampleEditorController* ec);
 
     //! Show or hide all buttons related to structure editing (like "add layer", "remove particle")
     void showInlineEditButtons(bool b);
@@ -72,7 +72,7 @@ public:
 
 private:
     QVBoxLayout* m_layout;
-    MultiLayerItem* m_multiLayerItem; //!< Ptr is borrowed, don't delete
+    MultiLayerItem* m_sampleItem; //!< Ptr is borrowed, don't delete
     SampleEditorController* m_ec;     //!< Ptr is borrowed, don't delete
     bool m_showInlineEditButtons = false;
     bool m_useAngstrom;
diff --git a/GUI/View/SampleDesigner/SampleEditorCommands.cpp b/GUI/View/SampleDesigner/SampleEditorCommands.cpp
index 78c125ed91f..263eaacf018 100644
--- a/GUI/View/SampleDesigner/SampleEditorCommands.cpp
+++ b/GUI/View/SampleDesigner/SampleEditorCommands.cpp
@@ -33,7 +33,7 @@ CommandRemoveLayer::CommandRemoveLayer(SampleEditorController* ec, LayerItem* la
     , m_ec(ec)
 {
     setText("Remove layer");
-    m_indexOfLayer = ec->multiLayerItem()->layers().indexOf(layerItem);
+    m_indexOfLayer = ec->sampleItem()->layers().indexOf(layerItem);
     m_layerItemBackup = GUI::Util::createBackup(layerItem);
 }
 
@@ -44,9 +44,9 @@ void CommandRemoveLayer::redo()
 
 void CommandRemoveLayer::undo()
 {
-    LayerItem* restoredLayer = m_ec->multiLayerItem()->addLayer(m_indexOfLayer);
+    LayerItem* restoredLayer = m_ec->sampleItem()->addLayer(m_indexOfLayer);
     GUI::Util::restoreBackup(restoredLayer, m_layerItemBackup);
-    m_ec->multiLayerForm()->onLayerAdded(restoredLayer);
+    m_ec->sampleForm()->onLayerAdded(restoredLayer);
     emit m_ec->modified();
 }
 
diff --git a/GUI/View/SampleDesigner/SampleEditorCommands.h b/GUI/View/SampleDesigner/SampleEditorCommands.h
index 4f8308c6087..0a58d850da7 100644
--- a/GUI/View/SampleDesigner/SampleEditorCommands.h
+++ b/GUI/View/SampleDesigner/SampleEditorCommands.h
@@ -40,7 +40,7 @@ private:
     bool m_isFirst = true;
 };
 
-//! Command to add a layer to a multilayer
+//! Command to add a layer to a sample
 class CommandAddLayer : public QUndoCommand {
 public:
     CommandAddLayer(SampleEditorController* ec, int atIndex, QUndoCommand* parent = nullptr);
@@ -53,7 +53,7 @@ private:
     int m_atIndex;
 };
 
-//! Command to remove a layer from a multilayer
+//! Command to remove a layer from a sample
 class CommandRemoveLayer : public QUndoCommand {
 public:
     CommandRemoveLayer(SampleEditorController* ec, LayerItem* layerItem,
diff --git a/GUI/View/SampleDesigner/SampleEditorController.cpp b/GUI/View/SampleDesigner/SampleEditorController.cpp
index b2bd5c0db97..e7859f7f4b5 100644
--- a/GUI/View/SampleDesigner/SampleEditorController.cpp
+++ b/GUI/View/SampleDesigner/SampleEditorController.cpp
@@ -39,31 +39,31 @@
 #include "Sample/HardParticle/Cylinder.h"
 
 SampleEditorController::SampleEditorController(ProjectDocument* document, MultiLayerItem* multi)
-    : m_multiLayerItem(multi)
-    , m_multiLayerForm(nullptr)
+    : m_sampleItem(multi)
+    , m_sampleForm(nullptr)
     , m_document(document)
 {
 }
 
 void SampleEditorController::setMultiLayerForm(MultiLayerForm* view)
 {
-    m_multiLayerForm = view;
+    m_sampleForm = view;
 }
 
-MultiLayerForm* SampleEditorController::multiLayerForm() const
+MultiLayerForm* SampleEditorController::sampleForm() const
 {
-    return m_multiLayerForm;
+    return m_sampleForm;
 }
 
-MultiLayerItem* SampleEditorController::multiLayerItem() const
+MultiLayerItem* SampleEditorController::sampleItem() const
 {
-    return m_multiLayerItem;
+    return m_sampleItem;
 }
 
 void SampleEditorController::addLayer(LayerItem* before)
 {
-    const int newIndex = (before != nullptr) ? m_multiLayerItem->layers().indexOf(before)
-                                             : m_multiLayerItem->layers().size();
+    const int newIndex = (before != nullptr) ? m_sampleItem->layers().indexOf(before)
+                                             : m_sampleItem->layers().size();
     m_undoStack.push(new CommandAddLayer(this, newIndex));
 }
 
@@ -73,7 +73,7 @@ void SampleEditorController::addLayerFromUndo(int atIndex)
     // -- find a color for the new layer
     QColor color;
     auto unusedColors = LayerEditorUtils::predefinedLayerColors();
-    for (auto* l : m_multiLayerItem->layers())
+    for (auto* l : m_sampleItem->layers())
         unusedColors.removeAll(l->color());
     if (!unusedColors.isEmpty())
         color = unusedColors.first();
@@ -81,7 +81,7 @@ void SampleEditorController::addLayerFromUndo(int atIndex)
         // search for a color which has been used the less, and which is not the same as in the
         // layers above and below
         QMap<QString, int> usage;
-        for (auto* l : m_multiLayerItem->layers())
+        for (auto* l : m_sampleItem->layers())
             usage[l->color().name()] += 1;
 
         auto sortedByUsage = LayerEditorUtils::predefinedLayerColors();
@@ -91,9 +91,9 @@ void SampleEditorController::addLayerFromUndo(int atIndex)
 
 
         const QColor above =
-            (atIndex > 0) ? m_multiLayerItem->layers()[atIndex - 1]->color() : QColor();
-        const QColor below = (atIndex < m_multiLayerItem->layers().size())
-                                 ? m_multiLayerItem->layers()[atIndex]->color()
+            (atIndex > 0) ? m_sampleItem->layers()[atIndex - 1]->color() : QColor();
+        const QColor below = (atIndex < m_sampleItem->layers().size())
+                                 ? m_sampleItem->layers()[atIndex]->color()
                                  : QColor();
 
         for (const auto& col : sortedByUsage)
@@ -104,18 +104,18 @@ void SampleEditorController::addLayerFromUndo(int atIndex)
     }
 
     // - create new layer
-    LayerItem* layer = m_multiLayerItem->addLayer(atIndex);
+    LayerItem* layer = m_sampleItem->addLayer(atIndex);
     layer->setMaterial(materialItems()->defaultMaterial());
     layer->setColor(color);
 
-    ASSERT(m_multiLayerForm);
-    m_multiLayerForm->onLayerAdded(layer);
-    m_multiLayerForm->updateUnits();
+    ASSERT(m_sampleForm);
+    m_sampleForm->onLayerAdded(layer);
+    m_sampleForm->updateUnits();
 
     emit modified();
 
     // expand the new layer's form for better workflow
-    for (auto* c : m_multiLayerForm->findChildren<LayerForm*>())
+    for (auto* c : m_sampleForm->findChildren<LayerForm*>())
         if (c->layerItem() == layer)
             c->expand();
 }
@@ -124,7 +124,7 @@ void SampleEditorController::addLayout(LayerForm* layerItemWidget)
 {
     auto* newLayoutItem = layerItemWidget->layerItem()->addLayout();
     layerItemWidget->onLayoutAdded(newLayoutItem);
-    m_multiLayerForm->updateUnits();
+    m_sampleForm->updateUnits();
 
     for (auto* layoutForms : layerItemWidget->findChildren<ParticleLayoutForm*>())
         layoutForms->updateTitle(layerItemWidget->layerItem());
@@ -139,11 +139,11 @@ void SampleEditorController::removeLayer(LayerItem* layerItem)
 
 void SampleEditorController::removeLayerFromUndo(int atIndex)
 {
-    auto* layer = m_multiLayerItem->layers()[atIndex];
+    auto* layer = m_sampleItem->layers()[atIndex];
     emit aboutToRemoveItem(layer);
-    m_multiLayerForm->onAboutToRemoveLayer(layer);
-    m_multiLayerItem->removeLayer(layer);
-    m_multiLayerForm->updateRowVisibilities();
+    m_sampleForm->onAboutToRemoveLayer(layer);
+    m_sampleItem->removeLayer(layer);
+    m_sampleForm->updateRowVisibilities();
     emit modified();
 }
 
@@ -168,11 +168,11 @@ void SampleEditorController::addParticle(ParticleLayoutItem* layoutItem,
     emit modified();
 
     //  search for particle layout widget for notification
-    ASSERT(m_multiLayerForm);
-    for (auto* w : m_multiLayerForm->findChildren<ParticleLayoutForm*>())
+    ASSERT(m_sampleForm);
+    for (auto* w : m_sampleForm->findChildren<ParticleLayoutForm*>())
         if (w->layoutItem() == layoutItem)
             w->onParticleAdded(newParticle);
-    m_multiLayerForm->updateUnits();
+    m_sampleForm->updateUnits();
 }
 
 void SampleEditorController::addParticle(ParticleLayoutItem* layoutItem,
@@ -184,11 +184,11 @@ void SampleEditorController::addParticle(ParticleLayoutItem* layoutItem,
     emit modified();
 
     //  search for particle layout widget for notification
-    ASSERT(m_multiLayerForm);
-    for (auto* w : m_multiLayerForm->findChildren<ParticleLayoutForm*>())
+    ASSERT(m_sampleForm);
+    for (auto* w : m_sampleForm->findChildren<ParticleLayoutForm*>())
         if (w->layoutItem() == layoutItem)
             w->onParticleAdded(newItem);
-    m_multiLayerForm->updateUnits();
+    m_sampleForm->updateUnits();
 }
 
 void SampleEditorController::addParticle(ParticleCompositionItem* compositionItem,
@@ -200,11 +200,11 @@ void SampleEditorController::addParticle(ParticleCompositionItem* compositionIte
     emit modified();
 
     //  search for composition widget for notification
-    ASSERT(m_multiLayerForm);
-    for (auto* c : m_multiLayerForm->findChildren<ParticleCompositionForm*>())
+    ASSERT(m_sampleForm);
+    for (auto* c : m_sampleForm->findChildren<ParticleCompositionForm*>())
         if (c->compositionItem() == compositionItem)
             c->onParticleAdded(newItem);
-    m_multiLayerForm->updateUnits();
+    m_sampleForm->updateUnits();
 }
 
 void SampleEditorController::addParticle(ParticleCompositionItem* compositionItem,
@@ -216,11 +216,11 @@ void SampleEditorController::addParticle(ParticleCompositionItem* compositionIte
     emit modified();
 
     //  search for composition widget for notification
-    ASSERT(m_multiLayerForm);
-    for (auto* c : m_multiLayerForm->findChildren<ParticleCompositionForm*>())
+    ASSERT(m_sampleForm);
+    for (auto* c : m_sampleForm->findChildren<ParticleCompositionForm*>())
         if (c->compositionItem() == compositionItem)
             c->onParticleAdded(newParticle);
-    m_multiLayerForm->updateUnits();
+    m_sampleForm->updateUnits();
 }
 
 ItemWithParticles*
@@ -264,7 +264,7 @@ void SampleEditorController::setCoreFormFactor(ParticleCoreShellForm* widget,
 
     particleCoreShell->core()->setFormFactor(FormFactorItemCatalog::create(type));
     widget->createCoreWidgets();
-    m_multiLayerForm->updateUnits();
+    m_sampleForm->updateUnits();
     emit modified();
 }
 
@@ -278,15 +278,15 @@ void SampleEditorController::setShellFormFactor(ParticleCoreShellForm* widget,
 
     particleCoreShell->shell()->setFormFactor(FormFactorItemCatalog::create(type));
     widget->createShellWidgets();
-    m_multiLayerForm->updateUnits();
+    m_sampleForm->updateUnits();
     emit modified();
 }
 
 void SampleEditorController::removeParticle(ItemWithParticles* itemToRemove)
 {
-    ASSERT(m_multiLayerForm);
+    ASSERT(m_sampleForm);
 
-    for (auto* layoutForm : m_multiLayerForm->findChildren<ParticleLayoutForm*>())
+    for (auto* layoutForm : m_sampleForm->findChildren<ParticleLayoutForm*>())
         if (layoutForm->layoutItem()->particles().contains(itemToRemove)) {
             layoutForm->onAboutToRemoveParticle(itemToRemove);
 
@@ -296,7 +296,7 @@ void SampleEditorController::removeParticle(ItemWithParticles* itemToRemove)
             return;
         }
 
-    for (auto* c : m_multiLayerForm->findChildren<ParticleCompositionForm*>())
+    for (auto* c : m_sampleForm->findChildren<ParticleCompositionForm*>())
         if (c->compositionItem()->particles().contains(itemToRemove)) {
             c->onAboutToRemoveParticle(itemToRemove);
 
@@ -316,10 +316,10 @@ void SampleEditorController::setDouble(double newValue, DoubleDescriptor d)
 
 void SampleEditorController::setDoubleFromUndo(double newValue, const QString& path)
 {
-    ASSERT(m_multiLayerForm);
+    ASSERT(m_sampleForm);
 
     DoubleSpinBox* spinBox = nullptr;
-    for (auto* s : m_multiLayerForm->findChildren<DoubleSpinBox*>()) {
+    for (auto* s : m_sampleForm->findChildren<DoubleSpinBox*>()) {
         if (s->valueDescriptor().path() == path) {
             spinBox = s;
             break;
@@ -331,7 +331,7 @@ void SampleEditorController::setDoubleFromUndo(double newValue, const QString& p
 
     spinBox->valueDescriptor().set(newValue);
 
-    m_multiLayerForm->ensureVisible(spinBox);
+    m_sampleForm->ensureVisible(spinBox);
     QSignalBlocker b(spinBox);
     spinBox->setBaseValue(newValue);
     spinBox->setFocus();
@@ -351,7 +351,7 @@ void SampleEditorController::setCurrentIndex(AbstractSelectionContainerForm* wid
 {
     d.setCurrentIndex(index);
     widget->createContent();
-    m_multiLayerForm->updateUnits();
+    m_sampleForm->updateUnits();
     emit modified();
 }
 
@@ -362,7 +362,7 @@ QUndoStack* SampleEditorController::undoStack()
 
 MaterialItems* SampleEditorController::materialItems() const
 {
-    return &m_multiLayerItem->materialItems();
+    return &m_sampleItem->materialItems();
 }
 
 ProjectDocument* SampleEditorController::projectDocument() const
@@ -376,8 +376,8 @@ void SampleEditorController::selectMaterial(ItemWithMaterial* item,
     item->setMaterial(newMaterialIdentifier);
 
     //  update Layer title
-    ASSERT(m_multiLayerForm);
-    for (auto* c : m_multiLayerForm->findChildren<LayerForm*>())
+    ASSERT(m_sampleForm);
+    for (auto* c : m_sampleForm->findChildren<LayerForm*>())
         if (c->layerItem() == item)
             c->updateTitle();
 
@@ -391,8 +391,8 @@ void SampleEditorController::setMaterialValue(ItemWithMaterial* item, double new
     setDouble(newValue, d);
 
     // -- notify all other users of this material (update values in the UI)
-    ASSERT(m_multiLayerForm);
-    for (auto* c : m_multiLayerForm->findChildren<MaterialInplaceForm*>())
+    ASSERT(m_sampleForm);
+    for (auto* c : m_sampleForm->findChildren<MaterialInplaceForm*>())
         if (c->itemWithMaterial() != item
             && c->itemWithMaterial()->materialIdentifier() == item->materialIdentifier())
             c->updateValues();
@@ -405,8 +405,8 @@ void SampleEditorController::setDensityRelatedValue(InterferenceItem* interferen
     setDouble(newValue, d);
 
     // -- notify the containing particle layout UI about changed value
-    ASSERT(m_multiLayerForm);
-    for (auto* c : m_multiLayerForm->findChildren<ParticleLayoutForm*>())
+    ASSERT(m_sampleForm);
+    for (auto* c : m_sampleForm->findChildren<ParticleLayoutForm*>())
         if (c->layoutItem()->interference() == interferenceItem) {
             c->updateDensityValue();
             break;
@@ -415,22 +415,22 @@ void SampleEditorController::setDensityRelatedValue(InterferenceItem* interferen
 
 void SampleEditorController::onStartingToMoveLayer()
 {
-    ASSERT(m_multiLayerForm);
-    m_multiLayerForm->showAddLayerButtons(false);
+    ASSERT(m_sampleForm);
+    m_sampleForm->showAddLayerButtons(false);
 }
 
 void SampleEditorController::onStoppedToMoveLayer(QWidget* widgetToMove,
                                                   QWidget* moveAboveThisWidget)
 {
-    ASSERT(m_multiLayerForm);
-    m_multiLayerForm->showAddLayerButtons(true);
-    const auto* moveAboveThisLayerForm = m_multiLayerForm->findNextLayerForm(moveAboveThisWidget);
+    ASSERT(m_sampleForm);
+    m_sampleForm->showAddLayerButtons(true);
+    const auto* moveAboveThisLayerForm = m_sampleForm->findNextLayerForm(moveAboveThisWidget);
     auto* itemToMove = dynamic_cast<LayerForm*>(widgetToMove)->layerItem();
     auto* moveBeforeThisItem =
         moveAboveThisLayerForm != nullptr ? moveAboveThisLayerForm->layerItem() : nullptr;
 
-    m_multiLayerItem->moveLayer(itemToMove, moveBeforeThisItem);
-    m_multiLayerForm->onLayerMoved(itemToMove);
+    m_sampleItem->moveLayer(itemToMove, moveBeforeThisItem);
+    m_sampleForm->onLayerMoved(itemToMove);
 
     // #baLayerEditor: tab order!
 
@@ -439,13 +439,13 @@ void SampleEditorController::onStoppedToMoveLayer(QWidget* widgetToMove,
 
 void SampleEditorController::setSampleName(const QString& name)
 {
-    m_multiLayerItem->setSampleName(name);
+    m_sampleItem->setSampleName(name);
     emit modified();
 }
 
 void SampleEditorController::setSampleDescription(const QString& description)
 {
-    m_multiLayerItem->setDescription(description);
+    m_sampleItem->setDescription(description);
     emit modified();
 }
 
@@ -455,7 +455,7 @@ void SampleEditorController::setMesoCrystalBasis(MesoCrystalForm* widget,
     auto* meso = widget->mesoCrystalItem();
     meso->setBasis(createAndInitParticle(type));
     widget->createBasisWidgets();
-    m_multiLayerForm->updateUnits();
+    m_sampleForm->updateUnits();
     emit modified();
 }
 
@@ -465,7 +465,7 @@ void SampleEditorController::setMesoCrystalBasis(MesoCrystalForm* widget,
     auto* meso = widget->mesoCrystalItem();
     meso->setBasis(createAndInitParticle(type));
     widget->createBasisWidgets();
-    m_multiLayerForm->updateUnits();
+    m_sampleForm->updateUnits();
     emit modified();
 }
 
@@ -473,7 +473,7 @@ void SampleEditorController::selectInterference(InterferenceForm* widget, int ne
 {
     widget->layoutItem()->interference().setCurrentIndex(newIndex);
     widget->onInterferenceTypeChanged();
-    m_multiLayerForm->updateUnits();
+    m_sampleForm->updateUnits();
 
     // Disable/enable total density property in the particle layout, depending on type of
     // interference function.
diff --git a/GUI/View/SampleDesigner/SampleEditorController.h b/GUI/View/SampleDesigner/SampleEditorController.h
index b6e533167e3..804129a9df4 100644
--- a/GUI/View/SampleDesigner/SampleEditorController.h
+++ b/GUI/View/SampleDesigner/SampleEditorController.h
@@ -59,10 +59,10 @@ public:
     void setMultiLayerForm(MultiLayerForm* view);
 
     //! The current form.
-    MultiLayerForm* multiLayerForm() const;
+    MultiLayerForm* sampleForm() const;
 
     //! The item on which this controller operates.
-    MultiLayerItem* multiLayerItem() const;
+    MultiLayerItem* sampleItem() const;
 
     //! The contained undo stack.
     QUndoStack* undoStack();
@@ -128,8 +128,8 @@ private:
 
 private:
     QUndoStack m_undoStack;
-    MultiLayerItem* m_multiLayerItem;
-    MultiLayerForm* m_multiLayerForm;
+    MultiLayerItem* m_sampleItem;
+    MultiLayerForm* m_sampleForm;
     ProjectDocument* m_document;
 };
 
diff --git a/GUI/View/SampleDesigner/SampleListModel.cpp b/GUI/View/SampleDesigner/SampleListModel.cpp
index a729151c552..72e38bbe6f5 100644
--- a/GUI/View/SampleDesigner/SampleListModel.cpp
+++ b/GUI/View/SampleDesigner/SampleListModel.cpp
@@ -27,7 +27,7 @@
 
 SampleListModel::SampleListModel(QObject* parent, MultiLayerItems* model)
     : QAbstractListModel(parent)
-    , m_multiLayerItems(model)
+    , m_sampleItems(model)
 {
 }
 
@@ -36,7 +36,7 @@ int SampleListModel::rowCount(const QModelIndex& parent) const
     if (parent.isValid())
         return 0;
 
-    return m_multiLayerItems->multiLayerItems().size();
+    return m_sampleItems->sampleItems().size();
 }
 
 QVariant SampleListModel::data(const QModelIndex& index, int role) const
@@ -99,12 +99,12 @@ MultiLayerItem* SampleListModel::itemForIndex(const QModelIndex& index) const
     if (!index.isValid())
         return nullptr;
 
-    return m_multiLayerItems->multiLayerItems()[index.row()];
+    return m_sampleItems->sampleItems()[index.row()];
 }
 
 QModelIndex SampleListModel::indexForItem(MultiLayerItem* item) const
 {
-    if (auto row = m_multiLayerItems->multiLayerItems().indexOf(item); row >= 0)
+    if (auto row = m_sampleItems->sampleItems().indexOf(item); row >= 0)
         return index(row, 0);
 
     return QModelIndex();
@@ -117,21 +117,21 @@ void SampleListModel::removeSample(MultiLayerItem* item)
         return;
 
     beginRemoveRows(index.parent(), index.row(), index.row());
-    m_multiLayerItems->removeMultiLayer(item);
+    m_sampleItems->removeMultiLayer(item);
     endRemoveRows();
 }
 
 QModelIndex SampleListModel::createSample()
 {
-    const QStringList existingNames = m_multiLayerItems->multiLayerNames();
+    const QStringList existingNames = m_sampleItems->sampleNames();
 
-    const int row = m_multiLayerItems->multiLayerItems().size();
+    const int row = m_sampleItems->sampleItems().size();
     beginInsertRows(QModelIndex(), row, row);
-    auto* multilayer_item = m_multiLayerItems->addMultiLayer();
-    multilayer_item->setSampleName(GUI::Util::String::suggestName(existingNames, "Sample"));
-    multilayer_item->addStandardMaterials();
+    auto* sample_item = m_sampleItems->addMultiLayer();
+    sample_item->setSampleName(GUI::Util::String::suggestName(existingNames, "Sample"));
+    sample_item->addStandardMaterials();
     endInsertRows();
-    return indexForItem(multilayer_item);
+    return indexForItem(sample_item);
 }
 
 QModelIndex SampleListModel::createSampleFromExamples(const QString& className,
@@ -146,9 +146,9 @@ QModelIndex SampleListModel::createSampleFromExamples(const QString& className,
         sample->setSampleName(title);
         sample->setDescription(description);
 
-        const int row = m_multiLayerItems->multiLayerItems().size();
+        const int row = m_sampleItems->sampleItems().size();
         beginInsertRows(QModelIndex(), row, row);
-        m_multiLayerItems->addMultiLayer(sample);
+        m_sampleItems->addMultiLayer(sample);
         endInsertRows();
         return indexForItem(sample);
     } catch (const GUI::Transform::FromDomain::GUISampleBuilder::Exception& ex) {
@@ -163,20 +163,20 @@ QModelIndex SampleListModel::createSampleFromExamples(const QString& className,
 #ifdef BORNAGAIN_PYTHON
 QModelIndex SampleListModel::createSampleFromPython()
 {
-    auto multiLayer = PyImportAssistant::importMultiLayer();
-    if (!multiLayer)
+    auto sample = PyImportAssistant::importMultiLayer();
+    if (!sample)
         return {}; // any messages already shown to user; no dlg necessary anymore
 
 
-    auto* sampleItem = PyImportAssistant::createMultiLayerItem(*multiLayer);
+    auto* sampleItem = PyImportAssistant::createMultiLayerItem(*sample);
     if (!sampleItem)
         return {}; // any messages already shown to user; no dlg necessary anymore
 
     sampleItem->setDescription("Imported from python code");
 
-    const int row = m_multiLayerItems->multiLayerItems().size();
+    const int row = m_sampleItems->sampleItems().size();
     beginInsertRows(QModelIndex(), row, row);
-    m_multiLayerItems->addMultiLayer(sampleItem);
+    m_sampleItems->addMultiLayer(sampleItem);
     endInsertRows();
     return indexForItem(sampleItem);
 }
diff --git a/GUI/View/SampleDesigner/SampleListModel.h b/GUI/View/SampleDesigner/SampleListModel.h
index a13ddcd26ba..2dbecf1326c 100644
--- a/GUI/View/SampleDesigner/SampleListModel.h
+++ b/GUI/View/SampleDesigner/SampleListModel.h
@@ -33,10 +33,10 @@ public:
     MultiLayerItem* itemForIndex(const QModelIndex& index) const;
     QModelIndex indexForItem(MultiLayerItem* item) const;
 
-    //! Remove the given multilayer. nullptr is allowed.
+    //! Remove the given sample. nullptr is allowed.
     void removeSample(MultiLayerItem* item);
 
-    //! Create a new sample (multilayer) and return the index of it.
+    //! Create a new sample (sample) and return the index of it.
     QModelIndex createSample();
 
     //! Create sample from list of built-in examples.
@@ -53,7 +53,7 @@ public:
 #endif
 
 private:
-    MultiLayerItems* m_multiLayerItems = nullptr;
+    MultiLayerItems* m_sampleItems = nullptr;
 };
 
 #endif // BORNAGAIN_GUI_VIEW_SAMPLEDESIGNER_SAMPLELISTMODEL_H
diff --git a/GUI/View/SampleDesigner/SampleListView.cpp b/GUI/View/SampleDesigner/SampleListView.cpp
index 4c55fc8ad18..c15ae358c69 100644
--- a/GUI/View/SampleDesigner/SampleListView.cpp
+++ b/GUI/View/SampleDesigner/SampleListView.cpp
@@ -65,7 +65,7 @@ SampleListView::SampleListView(QWidget* parent, ProjectDocument* document)
     : QListView(parent)
     , m_document(document)
 {
-    m_model = new SampleListModel(this, document->multiLayerItems());
+    m_model = new SampleListModel(this, document->sampleItems());
 
     setContextMenuPolicy(Qt::CustomContextMenu);
     setModel(m_model);
@@ -127,9 +127,9 @@ SampleListView::SampleListView(QWidget* parent, ProjectDocument* document)
     }
 }
 
-void SampleListView::setCurrentSample(MultiLayerItem* multiLayer)
+void SampleListView::setCurrentSample(MultiLayerItem* sample)
 {
-    setCurrentIndex(m_model->indexForItem(multiLayer));
+    setCurrentIndex(m_model->indexForItem(sample));
 }
 
 MultiLayerItem* SampleListView::currentSample()
@@ -139,9 +139,9 @@ MultiLayerItem* SampleListView::currentSample()
 
 void SampleListView::selectFirstSample()
 {
-    if (m_document->multiLayerItems()->multiLayerItems().isEmpty())
+    if (m_document->sampleItems()->sampleItems().isEmpty())
         return;
-    setCurrentSample(m_document->multiLayerItems()->multiLayerItems()[0]);
+    setCurrentSample(m_document->sampleItems()->sampleItems()[0]);
 }
 
 QAction* SampleListView::newSampleAction()
diff --git a/GUI/View/SampleDesigner/SampleListView.h b/GUI/View/SampleDesigner/SampleListView.h
index 64aae3cfab3..6ac87396b10 100644
--- a/GUI/View/SampleDesigner/SampleListView.h
+++ b/GUI/View/SampleDesigner/SampleListView.h
@@ -27,7 +27,7 @@ class SampleListView : public QListView {
 public:
     SampleListView(QWidget* parent, ProjectDocument* document);
 
-    void setCurrentSample(MultiLayerItem* multiLayer);
+    void setCurrentSample(MultiLayerItem* sample);
     MultiLayerItem* currentSample();
 
     //! Select first sample, if any sample exists
diff --git a/GUI/View/SampleDesigner/SampleView.cpp b/GUI/View/SampleDesigner/SampleView.cpp
index 643a97aafc9..fcfdf7f16c6 100644
--- a/GUI/View/SampleDesigner/SampleView.cpp
+++ b/GUI/View/SampleDesigner/SampleView.cpp
@@ -149,7 +149,7 @@ void SampleView::onAboutToRemoveItem(SampleItem itemToRemove)
     };
 
     if (itemToRemove.get_if<MultiLayerItem*>()) {
-        // -- itemToRemove is a multilayer. In this case: always reset
+        // -- itemToRemove is a sample. In this case: always reset
         canvas->resetScene();
     } else if (auto* layerToRemove = itemToRemove.get_if<LayerItem*>()) {
         // -- itemToRemove is a layer
diff --git a/GUI/View/SampleDesigner/ScriptPanel.cpp b/GUI/View/SampleDesigner/ScriptPanel.cpp
index 3b426ed23c6..2e5d6a4dd89 100644
--- a/GUI/View/SampleDesigner/ScriptPanel.cpp
+++ b/GUI/View/SampleDesigner/ScriptPanel.cpp
@@ -58,9 +58,9 @@ ScriptPanel::ScriptPanel(QWidget* parent)
             Qt::UniqueConnection);
 }
 
-void ScriptPanel::setCurrentSample(MultiLayerItem* multiLayerItem)
+void ScriptPanel::setCurrentSample(MultiLayerItem* sampleItem)
 {
-    m_currentMultiLayerItem = multiLayerItem;
+    m_currentMultiLayerItem = sampleItem;
     updateEditor();
 }
 
@@ -107,8 +107,8 @@ QString ScriptPanel::generateCodeSnippet()
 
     QString result;
     try {
-        auto multilayer = GUI::Transform::ToDomain::buildMultiLayer(*m_currentMultiLayerItem);
-        result.append(QString::fromStdString(Py::Export::sampleCode(*multilayer)));
+        auto sample = GUI::Transform::ToDomain::buildMultiLayer(*m_currentMultiLayerItem);
+        result.append(QString::fromStdString(Py::Export::sampleCode(*sample)));
     } catch (const std::exception& ex) {
         QString message =
             QString("Generation of Python Script failed. Code is not complete.\n\n"
diff --git a/GUI/View/SampleDesigner/ScriptPanel.h b/GUI/View/SampleDesigner/ScriptPanel.h
index df24407c04d..9d9a0f149d0 100644
--- a/GUI/View/SampleDesigner/ScriptPanel.h
+++ b/GUI/View/SampleDesigner/ScriptPanel.h
@@ -34,7 +34,7 @@ class ScriptPanel : public QWidget {
 public:
     explicit ScriptPanel(QWidget* parent);
 
-    void setCurrentSample(MultiLayerItem* multiLayerItem);
+    void setCurrentSample(MultiLayerItem* sampleItem);
     void onSampleModified();
 
 protected:
diff --git a/GUI/View/SampleDesigner/WidgetMoverButton.h b/GUI/View/SampleDesigner/WidgetMoverButton.h
index fbbae3cca77..80f5a97e2b0 100644
--- a/GUI/View/SampleDesigner/WidgetMoverButton.h
+++ b/GUI/View/SampleDesigner/WidgetMoverButton.h
@@ -39,7 +39,7 @@ public:
     //!
     //! If the widget shall not be able to be dragged on the top position, this can be defined by
     //! ignoreOnTop (the number of widgets at the top of the layout which shall not be affected by
-    //! the reordering). In the case of the layer moving, the topmost Form (the multilayer
+    //! the reordering). In the case of the layer moving, the topmost Form (the sample
     //! properties) shall not be part of reordering.
     WidgetMoverButton(QWidget* parent, QWidget* widgetToMove, int ignoreOnTop = 0);
 
diff --git a/GUI/View/Toplevel/ProjectSettingsView.cpp b/GUI/View/Toplevel/ProjectSettingsView.cpp
index 49ad78501ad..9822b39cafb 100644
--- a/GUI/View/Toplevel/ProjectSettingsView.cpp
+++ b/GUI/View/Toplevel/ProjectSettingsView.cpp
@@ -135,7 +135,7 @@ void ProjectSettingsView::onSingleInstrumentRadioToggled(bool newState)
 void ProjectSettingsView::onSingleSampleRadioToggled(bool newState)
 {
     if (newState) {
-        if (m_document->multiLayerItems()->multiLayerItems().size() > 1) {
+        if (m_document->sampleItems()->sampleItems().size() > 1) {
             QMessageBox::warning(this, "Select single sample mode",
                                  "This project already contains more than one sample. Changing "
                                  "this setting is not possible.");
diff --git a/GUI/View/Toplevel/SimulationView.cpp b/GUI/View/Toplevel/SimulationView.cpp
index 8fcd9e12439..06b661b8990 100644
--- a/GUI/View/Toplevel/SimulationView.cpp
+++ b/GUI/View/Toplevel/SimulationView.cpp
@@ -107,7 +107,7 @@ void SimulationView::writeOptionsToUI()
 
     // -- selection group
     updateSelection(m_ui->instrumentCombo, m_document->instrumentItems()->instrumentNames());
-    updateSelection(m_ui->sampleCombo, m_document->multiLayerItems()->multiLayerNames());
+    updateSelection(m_ui->sampleCombo, m_document->sampleItems()->sampleNames());
     updateSelection(m_ui->realDataCombo, m_document->realDataModel()->realDataNames(), true);
 
     // -- options group
@@ -230,9 +230,9 @@ void SimulationView::updateFunctionalityNarrowing()
     m_ui->instrumentLabel->setVisible(!m_document->singleInstrumentMode());
 }
 
-QVector<MultiLayerItem*> SimulationView::multiLayerItems() const
+QVector<MultiLayerItem*> SimulationView::sampleItems() const
 {
-    return m_document->multiLayerItems()->multiLayerItems();
+    return m_document->sampleItems()->sampleItems();
 }
 
 QVector<InstrumentItem*> SimulationView::instrumentItems() const
@@ -252,7 +252,7 @@ SimulationOptionsItem* SimulationView::optionsItem() const
 
 const MultiLayerItem* SimulationView::selectedSample() const
 {
-    return multiLayerItems().value(m_ui->sampleCombo->currentIndex(), nullptr);
+    return sampleItems().value(m_ui->sampleCombo->currentIndex(), nullptr);
 }
 
 const InstrumentItem* SimulationView::selectedInstrument() const
diff --git a/GUI/View/Toplevel/SimulationView.h b/GUI/View/Toplevel/SimulationView.h
index 4d116f3183e..7fe9b8b1d59 100644
--- a/GUI/View/Toplevel/SimulationView.h
+++ b/GUI/View/Toplevel/SimulationView.h
@@ -82,7 +82,7 @@ private:
     void updateFunctionalityNarrowing();
 
     // Convenience methods for easier access
-    QVector<MultiLayerItem*> multiLayerItems() const;
+    QVector<MultiLayerItem*> sampleItems() const;
     QVector<InstrumentItem*> instrumentItems() const;
     QVector<RealDataItem*> realDataItems() const;
     SimulationOptionsItem* optionsItem() const;
diff --git a/Resample/Processed/ParticleRegions.cpp b/Resample/Processed/ParticleRegions.cpp
index f74a1644538..3fd4432ddec 100644
--- a/Resample/Processed/ParticleRegions.cpp
+++ b/Resample/Processed/ParticleRegions.cpp
@@ -61,15 +61,15 @@ private:
 
 namespace {
 
-std::vector<double> bottomLayerCoordinates(const MultiLayer& multilayer)
+std::vector<double> bottomLayerCoordinates(const MultiLayer& sample)
 {
-    const size_t n_layers = multilayer.numberOfLayers();
+    const size_t n_layers = sample.numberOfLayers();
     if (n_layers < 2)
         return {};
     std::vector<double> result(n_layers - 1);
     result[0] = 0.0;
     for (size_t i = 1; i < n_layers - 1; ++i)
-        result[i] = result[i - 1] - multilayer.layer(i)->thickness();
+        result[i] = result[i - 1] - sample.layer(i)->thickness();
     return result;
 }
 
@@ -154,14 +154,14 @@ void LayerFillLimits::updateLayerLimits(size_t i_layer, ZLimits limits)
 //  ************************************************************************************************
 
 //! Calculate z-admixtures occupied by particles
-std::vector<ZLimits> Compute::Slicing::particleRegions(const MultiLayer& multilayer,
+std::vector<ZLimits> Compute::Slicing::particleRegions(const MultiLayer& sample,
                                                        bool use_slicing)
 {
-    const std::vector<double> bottom_coords = bottomLayerCoordinates(multilayer);
+    const std::vector<double> bottom_coords = bottomLayerCoordinates(sample);
     LayerFillLimits layer_fill_limits(bottom_coords);
     if (use_slicing) {
-        for (size_t i = 0; i < multilayer.numberOfLayers(); ++i) {
-            const Layer* layer = multilayer.layer(i);
+        for (size_t i = 0; i < sample.numberOfLayers(); ++i) {
+            const Layer* layer = sample.layer(i);
             const double offset = (i == 0) ? 0 : bottom_coords[i - 1];
             for (const auto* layout : layer->layouts())
                 for (const IParticle* particle : layout->particles())
diff --git a/Resample/Processed/ParticleRegions.h b/Resample/Processed/ParticleRegions.h
index 55619d6d2a1..d3dbc45d314 100644
--- a/Resample/Processed/ParticleRegions.h
+++ b/Resample/Processed/ParticleRegions.h
@@ -27,7 +27,7 @@ class ZLimits;
 
 namespace Compute::Slicing {
 
-std::vector<ZLimits> particleRegions(const MultiLayer& multilayer, bool use_slicing);
+std::vector<ZLimits> particleRegions(const MultiLayer& sample, bool use_slicing);
 
 } // namespace Compute::Slicing
 
diff --git a/Resample/Specular/ComputeFluxMagnetic.h b/Resample/Specular/ComputeFluxMagnetic.h
index 1cfd5599be3..da3201d69ba 100644
--- a/Resample/Specular/ComputeFluxMagnetic.h
+++ b/Resample/Specular/ComputeFluxMagnetic.h
@@ -34,14 +34,14 @@ using Fluxes = std::vector<std::unique_ptr<const IFlux>>;
 //! Methods to compute polarized propagation directions and fluxes as function of slice.
 //!
 //! Implements the transfer matrix formalism for the calculation of wave
-//! amplitudes of the coherent wave solution in a multilayer with magnetization.
+//! amplitudes of the coherent wave solution in a sample with magnetization.
 //! For a description, see internal
 //! document "Polarized Implementation of the Transfer Matrix Method"
 
 namespace Compute::SpecularMagnetic {
 
 //! Computes refraction angle reflection/transmission coefficients
-//! for given sliced multilayer and wavevector k
+//! for given sliced sample and wavevector k
 Fluxes fluxes(const SliceStack& slices, const R3& k, bool forward);
 
 //! Computes the Fresnel R coefficient for the top layer only
diff --git a/Resample/Specular/ComputeFluxScalar.h b/Resample/Specular/ComputeFluxScalar.h
index 1d6a4c566e7..f434dfd8a5c 100644
--- a/Resample/Specular/ComputeFluxScalar.h
+++ b/Resample/Specular/ComputeFluxScalar.h
@@ -35,7 +35,7 @@ using Fluxes = std::vector<std::unique_ptr<const IFlux>>;
 namespace Compute::SpecularScalar {
 
 //! Computes refraction angles and transmission/reflection coefficients
-//! for given coherent wave propagation in a multilayer.
+//! for given coherent wave propagation in a sample.
 Fluxes fluxes(const SliceStack& slices, const R3& k);
 
 //! Computes the Fresnel R coefficient for the top layer only.
diff --git a/Resample/Specular/TransitionMagneticNevot.h b/Resample/Specular/TransitionMagneticNevot.h
index 61724aaa03d..690c4bd81b2 100644
--- a/Resample/Specular/TransitionMagneticNevot.h
+++ b/Resample/Specular/TransitionMagneticNevot.h
@@ -28,7 +28,7 @@ class MatrixFlux;
 //! Implements the magnetic Fresnel computation with Nevot-Croce roughness
 //!
 //! Implements the transfer matrix formalism for the calculation of wave
-//! amplitudes of the coherent wave solution in a multilayer with magnetization.
+//! amplitudes of the coherent wave solution in a sample with magnetization.
 //! For a description, see internal
 //! document "Polarized Implementation of the Transfer Matrix Method"
 
diff --git a/Resample/Specular/TransitionMagneticTanh.h b/Resample/Specular/TransitionMagneticTanh.h
index 10abb1e9019..5461b001026 100644
--- a/Resample/Specular/TransitionMagneticTanh.h
+++ b/Resample/Specular/TransitionMagneticTanh.h
@@ -28,7 +28,7 @@ class MatrixFlux;
 //! Implements the magnetic Fresnel computation with the analytical Tanh roughness
 //!
 //! Implements the transfer matrix formalism for the calculation of wave
-//! amplitudes of the coherent wave solution in a multilayer with magnetization.
+//! amplitudes of the coherent wave solution in a sample with magnetization.
 //! For a description, see internal
 //! document "Polarized Implementation of the Transfer Matrix Method"
 
diff --git a/Resample/Swig/MultiLayerFuncs.cpp b/Resample/Swig/MultiLayerFuncs.cpp
index 9ffe959f8d3..b30cef7b8a8 100644
--- a/Resample/Swig/MultiLayerFuncs.cpp
+++ b/Resample/Swig/MultiLayerFuncs.cpp
@@ -28,22 +28,22 @@ std::vector<double> swigAPI::generateZValues(int n_points, double z_min, double
     return result;
 }
 
-std::vector<complex_t> swigAPI::materialProfileSLD(const MultiLayer& multilayer, int n_points,
+std::vector<complex_t> swigAPI::materialProfileSLD(const MultiLayer& sample, int n_points,
                                                    double z_min, double z_max)
 {
     SimulationOptions options;
     options.setUseAvgMaterials(true);
-    const reSample resample = reSample::make(multilayer, options);
+    const reSample resample = reSample::make(sample, options);
     ProfileHelper helper(resample.averageSlices());
     std::vector<double> z_values = generateZValues(n_points, z_min, z_max);
     return helper.calculateProfile(z_values);
 }
 
-std::pair<double, double> swigAPI::defaultMaterialProfileLimits(const MultiLayer& multilayer)
+std::pair<double, double> swigAPI::defaultMaterialProfileLimits(const MultiLayer& sample)
 {
     SimulationOptions options;
     options.setUseAvgMaterials(true);
-    const reSample resample = reSample::make(multilayer, options);
+    const reSample resample = reSample::make(sample, options);
     ProfileHelper helper(resample.averageSlices());
     return helper.defaultLimits();
 }
diff --git a/Resample/Swig/MultiLayerFuncs.h b/Resample/Swig/MultiLayerFuncs.h
index f9739e052ed..a3b6279bd3f 100644
--- a/Resample/Swig/MultiLayerFuncs.h
+++ b/Resample/Swig/MultiLayerFuncs.h
@@ -29,12 +29,12 @@ namespace swigAPI {
 
 std::vector<double> generateZValues(int n_points, double z_min, double z_max);
 
-//! Calculate average material profile for given multilayer
-std::vector<complex_t> materialProfileSLD(const MultiLayer& multilayer, int n_points, double z_min,
+//! Calculate average material profile for given sample
+std::vector<complex_t> materialProfileSLD(const MultiLayer& sample, int n_points, double z_min,
                                           double z_max);
 
 //! Get default z limits for generating a material profile
-std::pair<double, double> defaultMaterialProfileLimits(const MultiLayer& multilayer);
+std::pair<double, double> defaultMaterialProfileLimits(const MultiLayer& sample);
 
 } // namespace swigAPI
 
diff --git a/Sample/Aggregate/IInterference.h b/Sample/Aggregate/IInterference.h
index 439312cc6d6..2364b2e7c06 100644
--- a/Sample/Aggregate/IInterference.h
+++ b/Sample/Aggregate/IInterference.h
@@ -43,7 +43,7 @@ public:
     //!  area). Otherwise, returns zero or a user-defined value
     virtual double particleDensity() const { return 0.0; }
 
-    //! Indicates if this interference function can be used with a multilayer (DWBA mode)
+    //! Indicates if this interference function can be used with a sample (DWBA mode)
     virtual bool supportsMultilayer() const { return true; }
 
     //! structureFactors the Debye-Waller factor for a given wavevector transfer
diff --git a/Sample/Multilayer/MultiLayer.h b/Sample/Multilayer/MultiLayer.h
index 707ae1a4d12..ea620f8af29 100644
--- a/Sample/Multilayer/MultiLayer.h
+++ b/Sample/Multilayer/MultiLayer.h
@@ -55,7 +55,7 @@ public:
     void setRoughnessModel(RoughnessModel roughnessModel);
     //! Sets cross correlation length of roughnesses between interfaces
     void setCrossCorrLength(double crossCorrLength);
-    //! Sets the external field applied to the multilayer (units: A/m)
+    //! Sets the external field applied to the sample (units: A/m)
     void setExternalField(R3 ext_field);
 
     //! Returns layer with given index
@@ -67,7 +67,7 @@ public:
     RoughnessModel roughnessModel() const { return m_roughness_model; }
     //! Returns cross correlation length of roughnesses between interfaces
     double crossCorrLength() const { return m_crossCorrLength; }
-    //! Returns the external field applied to the multilayer (units: A/m)
+    //! Returns the external field applied to the sample (units: A/m)
     R3 externalField() const { return m_ext_field; }
 
     std::vector<const INode*> nodeChildren() const override;
diff --git a/Sample/Multilayer/MultilayerUtils.cpp b/Sample/Multilayer/MultilayerUtils.cpp
index c90734d3e0e..f6bf3d71f94 100644
--- a/Sample/Multilayer/MultilayerUtils.cpp
+++ b/Sample/Multilayer/MultilayerUtils.cpp
@@ -18,25 +18,25 @@
 #include "Sample/Multilayer/Layer.h"
 #include "Sample/Multilayer/MultiLayer.h"
 
-const LayerRoughness* SampleUtils::Multilayer::LayerTopRoughness(const MultiLayer& multilayer,
+const LayerRoughness* SampleUtils::Multilayer::LayerTopRoughness(const MultiLayer& sample,
                                                                  size_t i)
 {
     if (i == 0)
         return nullptr;
-    return multilayer.layerInterface(i - 1)->roughness();
+    return sample.layerInterface(i - 1)->roughness();
 }
 
-size_t SampleUtils::Multilayer::IndexOfLayer(const MultiLayer& multilayer, const Layer* p_layer)
+size_t SampleUtils::Multilayer::IndexOfLayer(const MultiLayer& sample, const Layer* p_layer)
 {
-    for (size_t i = 0; i < multilayer.numberOfLayers(); ++i)
-        if (p_layer == multilayer.layer(i))
+    for (size_t i = 0; i < sample.numberOfLayers(); ++i)
+        if (p_layer == sample.layer(i))
             return i;
     throw std::out_of_range("SampleUtils::Multilayer::IndexOfLayer: layer not found");
 }
 
-bool SampleUtils::Multilayer::ContainsCompatibleMaterials(const MultiLayer& multilayer)
+bool SampleUtils::Multilayer::ContainsCompatibleMaterials(const MultiLayer& sample)
 {
-    return MaterialUtils::checkMaterialTypes(multilayer.containedMaterials())
+    return MaterialUtils::checkMaterialTypes(sample.containedMaterials())
            != MATERIAL_TYPES::InvalidMaterialType;
 }
 
diff --git a/Sample/Multilayer/MultilayerUtils.h b/Sample/Multilayer/MultilayerUtils.h
index 2e9466c856e..5dbcfe7a924 100644
--- a/Sample/Multilayer/MultilayerUtils.h
+++ b/Sample/Multilayer/MultilayerUtils.h
@@ -33,13 +33,13 @@ class MultiLayer;
 namespace SampleUtils::Multilayer {
 
 //! Returns top roughness of layer
-const LayerRoughness* LayerTopRoughness(const MultiLayer& multilayer, size_t i);
+const LayerRoughness* LayerTopRoughness(const MultiLayer& sample, size_t i);
 
 //! Returns the index of the given layer
-size_t IndexOfLayer(const MultiLayer& multilayer, const Layer* p_layer);
+size_t IndexOfLayer(const MultiLayer& sample, const Layer* p_layer);
 
-//! Returns true if the multilayer contains non-default materials of one type only
-bool ContainsCompatibleMaterials(const MultiLayer& multilayer);
+//! Returns true if the sample contains non-default materials of one type only
+bool ContainsCompatibleMaterials(const MultiLayer& sample);
 
 bool hasRoughness(const MultiLayer& sample);
 
diff --git a/Sample/Multilayer/PyImport.cpp b/Sample/Multilayer/PyImport.cpp
index cd825af734d..41446afee5a 100644
--- a/Sample/Multilayer/PyImport.cpp
+++ b/Sample/Multilayer/PyImport.cpp
@@ -75,8 +75,8 @@ std::unique_ptr<MultiLayer> Py::Import::createFromPython(const std::string& scri
         throw std::runtime_error("SWIG failed to extract a MultiLayer.");
     }
 
-    MultiLayer* multilayer = reinterpret_cast<MultiLayer*>(argp1);
-    std::unique_ptr<MultiLayer> result(multilayer->clone());
+    MultiLayer* sample = reinterpret_cast<MultiLayer*>(argp1);
+    std::unique_ptr<MultiLayer> result(sample->clone());
 
     Py_DecRef(instance);
 
diff --git a/Sample/StandardSamples/LayersWithAbsorptionBuilder.h b/Sample/StandardSamples/LayersWithAbsorptionBuilder.h
index 43e41f8dc0d..730808a3f73 100644
--- a/Sample/StandardSamples/LayersWithAbsorptionBuilder.h
+++ b/Sample/StandardSamples/LayersWithAbsorptionBuilder.h
@@ -23,7 +23,7 @@
 class IFormFactor;
 class MultiLayer;
 
-//! The LayersWithAbsorptionBuilder class generates a multilayer with 3 layers with
+//! The LayersWithAbsorptionBuilder class generates a sample with 3 layers with
 //! absorption (refractive index has imaginary part).
 //!
 //! The middle layer is populated with particles.
diff --git a/Sample/StandardSamples/LayersWithAbsorptionBySLDBuilder.h b/Sample/StandardSamples/LayersWithAbsorptionBySLDBuilder.h
index 300a079b6d8..13a8b2f9e0c 100644
--- a/Sample/StandardSamples/LayersWithAbsorptionBySLDBuilder.h
+++ b/Sample/StandardSamples/LayersWithAbsorptionBySLDBuilder.h
@@ -23,7 +23,7 @@
 class MultiLayer;
 
 
-//! The LayersWithAbsorptionBySLDBuilder class generates a multilayer with 3 layers with
+//! The LayersWithAbsorptionBySLDBuilder class generates a sample with 3 layers with
 //! absorption (refractive index has imaginary part). //! The middle layer is populated with
 //! particles. MaterialBySLD is used to generate maaterials
 //! @ingroup standard_samples
diff --git a/Sample/StandardSamples/ParticleInVacuumBuilder.h b/Sample/StandardSamples/ParticleInVacuumBuilder.h
index 49e16e0007f..8faeec1f48a 100644
--- a/Sample/StandardSamples/ParticleInVacuumBuilder.h
+++ b/Sample/StandardSamples/ParticleInVacuumBuilder.h
@@ -23,7 +23,7 @@
 class IFormFactor;
 class MultiLayer;
 
-//! The ParticleInVacuumBuilder class generates a multilayer with single vacuum layer
+//! The ParticleInVacuumBuilder class generates a sample with single vacuum layer
 //! populated with particles of certain types.
 //! @ingroup standard_samples
 
diff --git a/Sample/StandardSamples/ResonatorBuilder.h b/Sample/StandardSamples/ResonatorBuilder.h
index f389d103011..f4543c4507b 100644
--- a/Sample/StandardSamples/ResonatorBuilder.h
+++ b/Sample/StandardSamples/ResonatorBuilder.h
@@ -23,7 +23,7 @@
 class MultiLayer;
 
 
-//! Builds sample: multilayer with Ti/Pt layers sequence.
+//! Builds sample: sample with Ti/Pt layers sequence.
 //! @ingroup standard_samples
 
 namespace ExemplarySamples {
diff --git a/Sim/Contrib/RoughMultiLayerContribution.h b/Sim/Contrib/RoughMultiLayerContribution.h
index 4b88a38c07e..e06da60687d 100644
--- a/Sim/Contrib/RoughMultiLayerContribution.h
+++ b/Sim/Contrib/RoughMultiLayerContribution.h
@@ -25,7 +25,7 @@
 class reSample;
 class DiffuseElement;
 
-//! Computes the diffuse reflection from the rough interfaces of a multilayer.
+//! Computes the diffuse reflection from the rough interfaces of a sample.
 //! Used by DWBAComputation.
 
 class RoughMultiLayerContribution final {
diff --git a/Sim/Export/ExportToPython.cpp b/Sim/Export/ExportToPython.cpp
index 79fa39e8ca9..35f568daf7e 100644
--- a/Sim/Export/ExportToPython.cpp
+++ b/Sim/Export/ExportToPython.cpp
@@ -17,9 +17,9 @@
 #include "Sim/Export/SimulationToPython.h"
 #include "Sim/Simulation/ISimulation.h"
 
-std::string Py::Export::sampleCode(const MultiLayer& multilayer)
+std::string Py::Export::sampleCode(const MultiLayer& sample)
 {
-    return SampleToPython().sampleCode(multilayer);
+    return SampleToPython().sampleCode(sample);
 }
 
 std::string Py::Export::simulationPlotCode(const ISimulation& simulation)
diff --git a/Sim/Export/ExportToPython.h b/Sim/Export/ExportToPython.h
index 3c189fe57e7..da34ce9af97 100644
--- a/Sim/Export/ExportToPython.h
+++ b/Sim/Export/ExportToPython.h
@@ -24,7 +24,7 @@ class ISimulation;
 
 namespace Py::Export {
 
-std::string sampleCode(const MultiLayer& multilayer);
+std::string sampleCode(const MultiLayer& sample);
 std::string simulationPlotCode(const ISimulation& simulation);
 std::string simulationSaveCode(const ISimulation& simulation, const std::string& fname);
 
diff --git a/Sim/Export/SampleToPython.cpp b/Sim/Export/SampleToPython.cpp
index fe69556c108..44480919457 100644
--- a/Sim/Export/SampleToPython.cpp
+++ b/Sim/Export/SampleToPython.cpp
@@ -93,44 +93,44 @@ void setPositionInformation(const IParticle* particle, std::string name, std::os
 //  class SampleToPython
 //  ************************************************************************************************
 
-std::string SampleToPython::sampleCode(const MultiLayer& multilayer)
+std::string SampleToPython::sampleCode(const MultiLayer& sample)
 {
-    initLabels(multilayer);
+    initLabels(sample);
     return defineGetSample();
 }
 
-void SampleToPython::initLabels(const MultiLayer& multilayer)
+void SampleToPython::initLabels(const MultiLayer& sample)
 {
     m_objs = std::make_unique<ComponentKeyHandler>();
     m_materials = std::make_unique<MaterialKeyHandler>();
 
-    for (const auto* x : multilayer.containedMaterials())
+    for (const auto* x : sample.containedMaterials())
         m_materials->insertMaterial(x);
 
-    m_objs->insertModel("sample", &multilayer);
-    for (const auto* x : NodeUtils::AllDescendantsOfType<Layer>(multilayer))
+    m_objs->insertModel("sample", &sample);
+    for (const auto* x : NodeUtils::AllDescendantsOfType<Layer>(sample))
         m_objs->insertModel("layer", x);
-    for (const auto* x : NodeUtils::AllDescendantsOfType<LayerRoughness>(multilayer))
+    for (const auto* x : NodeUtils::AllDescendantsOfType<LayerRoughness>(sample))
         m_objs->insertModel("roughness", x);
-    for (const auto* x : NodeUtils::AllDescendantsOfType<ParticleLayout>(multilayer))
+    for (const auto* x : NodeUtils::AllDescendantsOfType<ParticleLayout>(sample))
         m_objs->insertModel("layout", x);
-    for (const auto* x : NodeUtils::AllDescendantsOfType<IFormFactor>(multilayer))
+    for (const auto* x : NodeUtils::AllDescendantsOfType<IFormFactor>(sample))
         m_objs->insertModel("ff", x);
-    for (const auto* x : NodeUtils::AllDescendantsOfType<IInterference>(multilayer))
+    for (const auto* x : NodeUtils::AllDescendantsOfType<IInterference>(sample))
         m_objs->insertModel("iff", x);
-    for (const auto* x : NodeUtils::AllDescendantsOfType<Particle>(multilayer))
+    for (const auto* x : NodeUtils::AllDescendantsOfType<Particle>(sample))
         m_objs->insertModel("particle", x);
-    for (const auto* x : NodeUtils::AllDescendantsOfType<ParticleComposition>(multilayer))
+    for (const auto* x : NodeUtils::AllDescendantsOfType<ParticleComposition>(sample))
         m_objs->insertModel("particle", x);
-    for (const auto* x : NodeUtils::AllDescendantsOfType<ParticleCoreShell>(multilayer))
+    for (const auto* x : NodeUtils::AllDescendantsOfType<ParticleCoreShell>(sample))
         m_objs->insertModel("particle", x);
-    for (const auto* x : NodeUtils::AllDescendantsOfType<MesoCrystal>(multilayer))
+    for (const auto* x : NodeUtils::AllDescendantsOfType<MesoCrystal>(sample))
         m_objs->insertModel("particle", x);
-    for (const auto* x : NodeUtils::AllDescendantsOfType<Lattice2D>(multilayer))
+    for (const auto* x : NodeUtils::AllDescendantsOfType<Lattice2D>(sample))
         m_objs->insertModel("lattice", x);
-    for (const auto* x : NodeUtils::AllDescendantsOfType<Lattice3D>(multilayer))
+    for (const auto* x : NodeUtils::AllDescendantsOfType<Lattice3D>(sample))
         m_objs->insertModel("lattice", x);
-    for (const auto* x : NodeUtils::AllDescendantsOfType<Crystal>(multilayer))
+    for (const auto* x : NodeUtils::AllDescendantsOfType<Crystal>(sample))
         m_objs->insertModel("crystal", x);
 }
 
diff --git a/Sim/Export/SampleToPython.h b/Sim/Export/SampleToPython.h
index b5e2bc22d9c..698475aafe7 100644
--- a/Sim/Export/SampleToPython.h
+++ b/Sim/Export/SampleToPython.h
@@ -35,10 +35,10 @@ public:
     SampleToPython();
     ~SampleToPython();
 
-    std::string sampleCode(const MultiLayer& multilayer);
+    std::string sampleCode(const MultiLayer& sample);
 
 private:
-    void initLabels(const MultiLayer& multilayer);
+    void initLabels(const MultiLayer& sample);
 
     std::string defineGetSample() const;
     std::string defineMaterials() const;
diff --git a/Tests/Functional/GUI/Check.cpp b/Tests/Functional/GUI/Check.cpp
index 9ba39442d14..adf60a53738 100644
--- a/Tests/Functional/GUI/Check.cpp
+++ b/Tests/Functional/GUI/Check.cpp
@@ -36,14 +36,14 @@ std::unique_ptr<Powerfield<double>> domainData(const std::string& /*test_name*/,
     SimulationOptionsItem optionsItem;
     InstrumentItems instrumentItems;
 
-    std::unique_ptr<MultiLayerItem> multiLayerItem(
+    std::unique_ptr<MultiLayerItem> sampleItem(
         GUI::Transform::FromDomain::createMultiLayerItem(*direct_simulation.sample()));
     GUI::Transform::FromDomain::populateInstrumentItems(&instrumentItems, direct_simulation);
     GUI::Transform::FromDomain::populateSimulationOptions(&optionsItem, direct_simulation);
 
     std::unique_ptr<ISimulation> domain_simulation =
         GUI::Model::DomainSimulationBuilder::createSimulation(
-            multiLayerItem.get(), instrumentItems.instrumentItems().front(), optionsItem);
+            sampleItem.get(), instrumentItems.instrumentItems().front(), optionsItem);
 
     return std::unique_ptr<Powerfield<double>>(domain_simulation->simulate().data());
 }
diff --git a/Tests/Functional/Py/Embedded/Tests.cpp b/Tests/Functional/Py/Embedded/Tests.cpp
index 8ddf4d7596e..61be4ceb03b 100644
--- a/Tests/Functional/Py/Embedded/Tests.cpp
+++ b/Tests/Functional/Py/Embedded/Tests.cpp
@@ -269,8 +269,8 @@ TEST_F(PyEmbedded, ObjectExtract)
     if (!SWIG_IsOK(res))
         throw std::runtime_error("SWIG failed extract object");
 
-    auto* multilayer = reinterpret_cast<MultiLayer*>(argp1);
-    std::string name = multilayer->className();
+    auto* sample = reinterpret_cast<MultiLayer*>(argp1);
+    std::string name = sample->className();
 
     Py_DecRef(instance);
     Py_DecRef(ml);
@@ -280,7 +280,7 @@ TEST_F(PyEmbedded, ObjectExtract)
     EXPECT_TRUE(name == "MultiLayer");
 }
 
-//! Running Python snippet which creates a multilayer in embedded way.
+//! Running Python snippet which creates a sample in embedded way.
 //! Casting resulting PyObject to C++ MultiLayer.
 
 TEST_F(PyEmbedded, EmbeddedMultiLayer)
@@ -295,9 +295,9 @@ TEST_F(PyEmbedded, EmbeddedMultiLayer)
     buf << "def get_simulation():\n";
     buf << "    m_vacuum = ba.RefractiveMaterial(\"Vacuum\", 0.0, 0.0)\n";
     buf << "    vacuum_layer = ba.Layer(m_vacuum)\n";
-    buf << "    multilayer = ba.MultiLayer()\n";
-    buf << "    multilayer.addLayer(vacuum_layer)\n";
-    buf << "    return multilayer\n";
+    buf << "    sample = ba.MultiLayer()\n";
+    buf << "    sample.addLayer(vacuum_layer)\n";
+    buf << "    return sample\n";
 
     PyObject* pCompiledFn = Py_CompileString(buf.str().c_str(), "", Py_file_input);
     if (!pCompiledFn)
@@ -329,8 +329,8 @@ TEST_F(PyEmbedded, EmbeddedMultiLayer)
     if (!SWIG_IsOK(res))
         throw std::runtime_error("SWIG failed extract object");
 
-    auto* multilayer = reinterpret_cast<MultiLayer*>(argp1);
-    size_t n_layers = multilayer->numberOfLayers();
+    auto* sample = reinterpret_cast<MultiLayer*>(argp1);
+    size_t n_layers = sample->numberOfLayers();
 
     Py_DecRef(instance);
 
@@ -396,9 +396,9 @@ TEST_F(PyEmbedded, ModuleFunctionsList)
     buf << "def get_simulation():\n";
     buf << "    m_vacuum = ba.RefractiveMaterial(\"Vacuum\", 0.0, 0.0)\n";
     buf << "    vacuum_layer = ba.Layer(m_vacuum)\n";
-    buf << "    multilayer = ba.MultiLayer()\n";
-    buf << "    multilayer.addLayer(vacuum_layer)\n";
-    buf << "    return multilayer\n";
+    buf << "    sample = ba.MultiLayer()\n";
+    buf << "    sample.addLayer(vacuum_layer)\n";
+    buf << "    return sample\n";
 
     auto listOfFunc = Py::Import::listOfFunctions(buf.str(), BABuild::buildLibDir());
     for (auto s : listOfFunc)
diff --git a/Tests/PyUnit/sliced_composition.py b/Tests/PyUnit/sliced_composition.py
index a759c0c44cb..42818e3430d 100644
--- a/Tests/PyUnit/sliced_composition.py
+++ b/Tests/PyUnit/sliced_composition.py
@@ -19,7 +19,7 @@ class SlicedSpheresTest(unittest.TestCase):
 
     def get_sample(self, particle_to_air=None, particle_to_substrate=None):
         """
-        Helper function returning a multilayer (air, substrate) using particles provided
+        Helper function returning a sample (air, substrate) using particles provided
         by the user.
         """
 
@@ -35,10 +35,10 @@ class SlicedSpheresTest(unittest.TestCase):
             layout.addParticle(particle_to_substrate)
             substrate.addLayout(layout)
 
-        multi_layer = ba.MultiLayer()
-        multi_layer.addLayer(vacuum_layer)
-        multi_layer.addLayer(substrate)
-        return multi_layer
+        sample = ba.MultiLayer()
+        sample.addLayer(vacuum_layer)
+        sample.addLayer(substrate)
+        return sample
 
     def get_result(self, particle_to_air=None, particle_to_substrate=None):
         sample = self.get_sample(particle_to_air, particle_to_substrate)
@@ -139,7 +139,7 @@ class SlicedSpheresTest(unittest.TestCase):
 
         shift = bottom_cup_height
 
-        # Scattering from empty multilayer
+        # Scattering from empty sample
         reference = self.get_result()
 
         # spherical composition
diff --git a/Tests/PyUnit/sliced_spheres.py b/Tests/PyUnit/sliced_spheres.py
index e19f9b38815..fffd27ce1ce 100644
--- a/Tests/PyUnit/sliced_spheres.py
+++ b/Tests/PyUnit/sliced_spheres.py
@@ -15,7 +15,7 @@ class SlicedSpheresTest(unittest.TestCase):
 
     def get_sample(self, particle_to_air=None, particle_to_substrate=None):
         """
-        Helper function returning a multilayer (air, substrate) using particles provided
+        Helper function returning a sample (air, substrate) using particles provided
         by the user.
         """
 
@@ -31,10 +31,10 @@ class SlicedSpheresTest(unittest.TestCase):
             layout.addParticle(particle_to_substrate)
             substrate.addLayout(layout)
 
-        multi_layer = ba.MultiLayer()
-        multi_layer.addLayer(vacuum_layer)
-        multi_layer.addLayer(substrate)
-        return multi_layer
+        sample = ba.MultiLayer()
+        sample.addLayer(vacuum_layer)
+        sample.addLayer(substrate)
+        return sample
 
     def get_result(self, particle_to_air=None, particle_to_substrate=None):
         sample = self.get_sample(particle_to_air, particle_to_substrate)
diff --git a/Tests/PyUnit/transform_BoxComposition.py b/Tests/PyUnit/transform_BoxComposition.py
index db0896c4c15..ad11bddf76c 100644
--- a/Tests/PyUnit/transform_BoxComposition.py
+++ b/Tests/PyUnit/transform_BoxComposition.py
@@ -35,11 +35,11 @@ class TransformBoxCompositionTest(unittest.TestCase):
         middle_layer.addLayout(layout)
         substrate = Layer(mSubstrate)
 
-        multi_layer = MultiLayer()
-        multi_layer.addLayer(vacuum_layer)
-        multi_layer.addLayer(middle_layer)
-        multi_layer.addLayer(substrate)
-        return multi_layer
+        sample = MultiLayer()
+        sample.addLayer(vacuum_layer)
+        sample.addLayer(middle_layer)
+        sample.addLayer(substrate)
+        return sample
 
     def get_result(self, particle):
         sample = self.get_sample(particle)
diff --git a/Tests/PyUnit/transform_CoreShellBox.py b/Tests/PyUnit/transform_CoreShellBox.py
index fab72d72f31..6ffb1771b74 100644
--- a/Tests/PyUnit/transform_CoreShellBox.py
+++ b/Tests/PyUnit/transform_CoreShellBox.py
@@ -28,11 +28,11 @@ class TransformCoreShellBoxTest(unittest.TestCase):
         middle_layer.addLayout(layout)
         substrate = Layer(mSubstrate)
 
-        multi_layer = MultiLayer()
-        multi_layer.addLayer(vacuum_layer)
-        multi_layer.addLayer(middle_layer)
-        multi_layer.addLayer(substrate)
-        return multi_layer
+        sample = MultiLayer()
+        sample.addLayer(vacuum_layer)
+        sample.addLayer(middle_layer)
+        sample.addLayer(substrate)
+        return sample
 
     def get_result(self, particle):
         sample = self.get_sample(particle)
diff --git a/Tests/PyUnit/transform_box.py b/Tests/PyUnit/transform_box.py
index 1842f71390d..0b7cf3d32ba 100644
--- a/Tests/PyUnit/transform_box.py
+++ b/Tests/PyUnit/transform_box.py
@@ -27,11 +27,11 @@ class BoxTransformationsTest(unittest.TestCase):
         middle_layer.addLayout(layout)
         substrate = ba.Layer(mSubstrate)
 
-        multi_layer = ba.MultiLayer()
-        multi_layer.addLayer(vacuum_layer)
-        multi_layer.addLayer(middle_layer)
-        multi_layer.addLayer(substrate)
-        return multi_layer
+        sample = ba.MultiLayer()
+        sample.addLayer(vacuum_layer)
+        sample.addLayer(middle_layer)
+        sample.addLayer(substrate)
+        return sample
 
     def get_result(self, particle):
         sample = self.get_sample(particle)
diff --git a/Tests/PyUnit/transform_cube.py b/Tests/PyUnit/transform_cube.py
index 4e9db12a08d..837baf2fbef 100644
--- a/Tests/PyUnit/transform_cube.py
+++ b/Tests/PyUnit/transform_cube.py
@@ -48,11 +48,11 @@ class RotationsCubeTest(unittest.TestCase):
         else:
             middle_layer.addLayout(layout)
 
-        multi_layer = MultiLayer()
-        multi_layer.addLayer(vacuum_layer)
-        multi_layer.addLayer(middle_layer)
-        multi_layer.addLayer(substrate)
-        return multi_layer
+        sample = MultiLayer()
+        sample.addLayer(vacuum_layer)
+        sample.addLayer(middle_layer)
+        sample.addLayer(substrate)
+        return sample
 
     def get_result(self, data, add_to="Vacuum"):
         ff = data[0]
diff --git a/Tests/Unit/GUI/TestSessionModel.cpp b/Tests/Unit/GUI/TestSessionModel.cpp
index a92beea71cd..98a40ecffaa 100644
--- a/Tests/Unit/GUI/TestSessionModel.cpp
+++ b/Tests/Unit/GUI/TestSessionModel.cpp
@@ -46,9 +46,9 @@ TEST_F(TestSessionModel, setData)
 
 TEST_F(TestSessionModel, copyItem)
 {
-    auto multilayer1 = std::make_unique<MultiLayerItem>();
-    multilayer1->setSampleName("multilayer1");
-    multilayer1->addStandardMaterials();
+    auto sample1 = std::make_unique<MultiLayerItem>();
+    sample1->setSampleName("sample1");
+    sample1->addStandardMaterials();
 
     InstrumentItems instrumentItems;
     auto* instrument1 = instrumentItems.addInstrument<GISASInstrumentItem>();
@@ -57,7 +57,7 @@ TEST_F(TestSessionModel, copyItem)
     JobModel jobModel;
     auto* jobItem = jobModel.insertItem<JobItem>();
 
-    jobItem->copySampleIntoJob(multilayer1.get());
+    jobItem->copySampleIntoJob(sample1.get());
     EXPECT_NE(jobItem->sampleItem(), nullptr);
 
     jobItem->copyInstrumentIntoJob(instrument1);
diff --git a/Tests/Unit/Resample/SpecularMagneticTest.cpp b/Tests/Unit/Resample/SpecularMagneticTest.cpp
index 65050c52e98..65449579de8 100644
--- a/Tests/Unit/Resample/SpecularMagneticTest.cpp
+++ b/Tests/Unit/Resample/SpecularMagneticTest.cpp
@@ -101,21 +101,21 @@ TEST_F(SpecularMagneticTest, degenerate_)
 
 std::unique_ptr<const reSample> SpecularMagneticTest::sample_zerofield(bool slab)
 {
-    MultiLayer multi_layer_scalar;
+    MultiLayer sample_scalar;
     Material substr_material_scalar = RefractiveMaterial("Substrate", 7e-6, 2e-8);
     Layer vacuum_layer(RefractiveMaterial("Vacuum", 0.0, 0.0));
     Layer substr_layer_scalar(substr_material_scalar);
-    multi_layer_scalar.addLayer(vacuum_layer);
+    sample_scalar.addLayer(vacuum_layer);
 
     if (slab) {
         Material layer_material = RefractiveMaterial("Layer", 3e-6, 1e-8);
         Layer layer(layer_material, 10. * Units::nm);
-        multi_layer_scalar.addLayer(layer);
+        sample_scalar.addLayer(layer);
     }
 
-    multi_layer_scalar.addLayer(substr_layer_scalar);
+    sample_scalar.addLayer(substr_layer_scalar);
 
-    return std::make_unique<reSample>(reSample::make(multi_layer_scalar, {}));
+    return std::make_unique<reSample>(reSample::make(sample_scalar, {}));
 }
 
 template <typename Strategy>
diff --git a/Tests/Unit/Sim/DepthProbeSimulationTest.cpp b/Tests/Unit/Sim/DepthProbeSimulationTest.cpp
index f9451a891a8..377719182d9 100644
--- a/Tests/Unit/Sim/DepthProbeSimulationTest.cpp
+++ b/Tests/Unit/Sim/DepthProbeSimulationTest.cpp
@@ -18,7 +18,7 @@ protected:
     void checkBeamState(const DepthProbeSimulation& sim);
     void checkEmptySimulation(DepthProbeSimulation& sim);
 
-    MultiLayer multilayer;
+    MultiLayer sample;
 };
 
 DepthProbeSimulationTest::DepthProbeSimulationTest()
@@ -31,9 +31,9 @@ DepthProbeSimulationTest::DepthProbeSimulationTest()
     Layer layer1(mat1, 10 * Units::nm);
     Layer layer2(mat2);
 
-    multilayer.addLayer(layer0);
-    multilayer.addLayer(layer1);
-    multilayer.addLayer(layer2);
+    sample.addLayer(layer0);
+    sample.addLayer(layer1);
+    sample.addLayer(layer2);
 }
 
 std::unique_ptr<DepthProbeSimulation> DepthProbeSimulationTest::defaultSimulation()
@@ -41,7 +41,7 @@ std::unique_ptr<DepthProbeSimulation> DepthProbeSimulationTest::defaultSimulatio
     std::unique_ptr<DepthProbeSimulation> result = std::make_unique<DepthProbeSimulation>();
     result->setBeamParameters(1.0, 10, 0.0 * Units::deg, 2.0 * Units::deg);
     result->setZSpan(12, -30.0 * Units::nm, 10.0 * Units::nm);
-    result->setSample(multilayer);
+    result->setSample(sample);
     return result;
 }
 
diff --git a/Wrap/Python/sample_tools.py b/Wrap/Python/sample_tools.py
index 21b47f5501f..39f46f76863 100644
--- a/Wrap/Python/sample_tools.py
+++ b/Wrap/Python/sample_tools.py
@@ -5,20 +5,20 @@ import bornagain as ba
 from bornagain import deg, nm
 
 
-def materialProfile(multilayer, n_points=400, z_min=None, z_max=None):
+def materialProfile(sample, n_points=400, z_min=None, z_max=None):
     """
-    Creates a material profile from the given multilayer. If no limits are given,
+    Creates a material profile from the given sample. If no limits are given,
     it will provide sensible default values, considering the included particles and
     interface roughnesses.
-    :param multilayer: bornagain.MultiLayer object
+    :param sample: bornagain.MultiLayer object
     :param n_points: number of points to generate
     :param z_min: starting value for z
     :param z_max: ending value for z
     :return: numpy arrays containing z positions and the complex material values in those positions
     """
-    def_z_min, def_z_max = ba.defaultMaterialProfileLimits(multilayer)
+    def_z_min, def_z_max = ba.defaultMaterialProfileLimits(sample)
     z_min = def_z_min if z_min is None else z_min
     z_max = def_z_max if z_max is None else z_max
     z_points = ba.generateZValues(n_points, z_min, z_max)
-    material_values = ba.materialProfileSLD(multilayer, n_points, z_min, z_max)
+    material_values = ba.materialProfileSLD(sample, n_points, z_min, z_max)
     return (z_points, material_values)
diff --git a/Wrap/Python/std_samples.py b/Wrap/Python/std_samples.py
index c936f11ad39..aeefaf553a8 100644
--- a/Wrap/Python/std_samples.py
+++ b/Wrap/Python/std_samples.py
@@ -7,7 +7,7 @@ from bornagain import deg, nm
 
 def alternating_layers():
     """
-    Returns multilayer sample consisting of 20 alternating Ti and Ni layers.
+    Returns sample sample consisting of 20 alternating Ti and Ni layers.
     """
 
     # Define materials
diff --git a/auto/Wrap/doxygenResample.i b/auto/Wrap/doxygenResample.i
index 14c8601bbfe..6041890e587 100644
--- a/auto/Wrap/doxygenResample.i
+++ b/auto/Wrap/doxygenResample.i
@@ -1101,7 +1101,7 @@ Computes kz values from k-vector of the incoming beam known at a distant point i
 
 
 // File: namespaceCompute_1_1Slicing.xml
-%feature("docstring")  Compute::Slicing::particleRegions "std::vector< ZLimits > Compute::Slicing::particleRegions(const MultiLayer &multilayer, bool use_slicing)
+%feature("docstring")  Compute::Slicing::particleRegions "std::vector< ZLimits > Compute::Slicing::particleRegions(const MultiLayer &sample, bool use_slicing)
 
 Calculate z-admixtures occupied by particles. 
 ";
@@ -1116,7 +1116,7 @@ Calculate z-admixtures occupied by particles.
 // File: namespaceCompute_1_1SpecularMagnetic.xml
 %feature("docstring")  Compute::SpecularMagnetic::fluxes "Fluxes Compute::SpecularMagnetic::fluxes(const SliceStack &slices, const R3 &k, bool forward)
 
-Computes refraction angle reflection/transmission coefficients for given sliced multilayer and wavevector k 
+Computes refraction angle reflection/transmission coefficients for given sliced sample and wavevector k 
 ";
 
 %feature("docstring")  Compute::SpecularMagnetic::topLayerR "SpinMatrix Compute::SpecularMagnetic::topLayerR(const SliceStack &slices, const std::vector< complex_t > &kzs, bool forward)
@@ -1128,7 +1128,7 @@ Computes the Fresnel R coefficient for the top layer only Introduced in order to
 // File: namespaceCompute_1_1SpecularScalar.xml
 %feature("docstring")  Compute::SpecularScalar::fluxes "Fluxes Compute::SpecularScalar::fluxes(const SliceStack &slices, const R3 &k)
 
-Computes refraction angles and transmission/reflection coefficients for given coherent wave propagation in a multilayer. 
+Computes refraction angles and transmission/reflection coefficients for given coherent wave propagation in a sample. 
 ";
 
 %feature("docstring")  Compute::SpecularScalar::topLayerR "complex_t Compute::SpecularScalar::topLayerR(const SliceStack &slices, const std::vector< complex_t > &kz)
@@ -1149,12 +1149,12 @@ Computes the Fresnel R coefficient for the top layer only. Introduced in order t
 %feature("docstring")  swigAPI::generateZValues "std::vector< double > swigAPI::generateZValues(int n_points, double z_min, double z_max)
 ";
 
-%feature("docstring")  swigAPI::materialProfileSLD "std::vector< complex_t > swigAPI::materialProfileSLD(const MultiLayer &multilayer, int n_points, double z_min, double z_max)
+%feature("docstring")  swigAPI::materialProfileSLD "std::vector< complex_t > swigAPI::materialProfileSLD(const MultiLayer &sample, int n_points, double z_min, double z_max)
 
-Calculate average material profile for given multilayer. 
+Calculate average material profile for given sample. 
 ";
 
-%feature("docstring")  swigAPI::defaultMaterialProfileLimits "std::pair< double, double > swigAPI::defaultMaterialProfileLimits(const MultiLayer &multilayer)
+%feature("docstring")  swigAPI::defaultMaterialProfileLimits "std::pair< double, double > swigAPI::defaultMaterialProfileLimits(const MultiLayer &sample)
 
 Get default z limits for generating a material profile. 
 ";
diff --git a/auto/Wrap/doxygenSample.i b/auto/Wrap/doxygenSample.i
index 2c57cdc9087..0acb43933a3 100644
--- a/auto/Wrap/doxygenSample.i
+++ b/auto/Wrap/doxygenSample.i
@@ -1339,7 +1339,7 @@ If defined by this interference function's parameters, returns the particle dens
 
 %feature("docstring")  IInterference::supportsMultilayer "virtual bool IInterference::supportsMultilayer() const
 
-Indicates if this interference function can be used with a multilayer (DWBA mode) 
+Indicates if this interference function can be used with a sample (DWBA mode) 
 ";
 
 %feature("docstring")  IInterference::DWfactor "double IInterference::DWfactor(R3 q) const
@@ -1659,7 +1659,7 @@ C++ includes: Interference3DLattice.h
 
 %feature("docstring")  Interference3DLattice::supportsMultilayer "bool Interference3DLattice::supportsMultilayer() const override
 
-Indicates if this interference function can be used with a multilayer (DWBA mode) 
+Indicates if this interference function can be used with a sample (DWBA mode) 
 ";
 
 %feature("docstring")  Interference3DLattice::nodeChildren "std::vector< const INode * > Interference3DLattice::nodeChildren() const override
@@ -1758,7 +1758,7 @@ C++ includes: InterferenceFinite3DLattice.h
 
 %feature("docstring")  InterferenceFinite3DLattice::supportsMultilayer "bool InterferenceFinite3DLattice::supportsMultilayer() const override
 
-Indicates if this interference function can be used with a multilayer (DWBA mode) 
+Indicates if this interference function can be used with a sample (DWBA mode) 
 ";
 
 %feature("docstring")  InterferenceFinite3DLattice::nodeChildren "std::vector< const INode * > InterferenceFinite3DLattice::nodeChildren() const override
@@ -3151,7 +3151,7 @@ Sets cross correlation length of roughnesses between interfaces.
 
 %feature("docstring")  MultiLayer::setExternalField "void MultiLayer::setExternalField(R3 ext_field)
 
-Sets the external field applied to the multilayer (units: A/m) 
+Sets the external field applied to the sample (units: A/m) 
 ";
 
 %feature("docstring")  MultiLayer::layer "const Layer * MultiLayer::layer(size_t i_layer) const
@@ -3174,7 +3174,7 @@ Returns cross correlation length of roughnesses between interfaces.
 
 %feature("docstring")  MultiLayer::externalField "R3 MultiLayer::externalField() const
 
-Returns the external field applied to the multilayer (units: A/m) 
+Returns the external field applied to the sample (units: A/m) 
 ";
 
 %feature("docstring")  MultiLayer::nodeChildren "std::vector< const INode * > MultiLayer::nodeChildren() const override
@@ -5028,19 +5028,19 @@ Complex form factor of triangular ripple.
 
 
 // File: namespaceSampleUtils_1_1Multilayer.xml
-%feature("docstring")  SampleUtils::Multilayer::LayerTopRoughness "const LayerRoughness * SampleUtils::Multilayer::LayerTopRoughness(const MultiLayer &multilayer, size_t i)
+%feature("docstring")  SampleUtils::Multilayer::LayerTopRoughness "const LayerRoughness * SampleUtils::Multilayer::LayerTopRoughness(const MultiLayer &sample, size_t i)
 
 Returns top roughness of layer. 
 ";
 
-%feature("docstring")  SampleUtils::Multilayer::IndexOfLayer "size_t SampleUtils::Multilayer::IndexOfLayer(const MultiLayer &multilayer, const Layer *p_layer)
+%feature("docstring")  SampleUtils::Multilayer::IndexOfLayer "size_t SampleUtils::Multilayer::IndexOfLayer(const MultiLayer &sample, const Layer *p_layer)
 
 Returns the index of the given layer. 
 ";
 
-%feature("docstring")  SampleUtils::Multilayer::ContainsCompatibleMaterials "bool SampleUtils::Multilayer::ContainsCompatibleMaterials(const MultiLayer &multilayer)
+%feature("docstring")  SampleUtils::Multilayer::ContainsCompatibleMaterials "bool SampleUtils::Multilayer::ContainsCompatibleMaterials(const MultiLayer &sample)
 
-Returns true if the multilayer contains non-default materials of one type only. 
+Returns true if the sample contains non-default materials of one type only. 
 ";
 
 %feature("docstring")  SampleUtils::Multilayer::hasRoughness "bool SampleUtils::Multilayer::hasRoughness(const MultiLayer &sample)
diff --git a/auto/Wrap/doxygenSim.i b/auto/Wrap/doxygenSim.i
index b73c4c1c192..0f0713ce035 100644
--- a/auto/Wrap/doxygenSim.i
+++ b/auto/Wrap/doxygenSim.i
@@ -1637,7 +1637,7 @@ user-defined weighting factors. Used linearly, no matter which norm is chosen.
 // File: classRoughMultiLayerContribution.xml
 %feature("docstring") RoughMultiLayerContribution "
 
-Computes the diffuse reflection from the rough interfaces of a multilayer. Used by  DWBAComputation.
+Computes the diffuse reflection from the rough interfaces of a sample. Used by  DWBAComputation.
 
 C++ includes: RoughMultiLayerContribution.h
 ";
@@ -1692,7 +1692,7 @@ C++ includes: SampleToPython.h
 %feature("docstring")  SampleToPython::~SampleToPython "SampleToPython::~SampleToPython()
 ";
 
-%feature("docstring")  SampleToPython::sampleCode "std::string SampleToPython::sampleCode(const MultiLayer &multilayer)
+%feature("docstring")  SampleToPython::sampleCode "std::string SampleToPython::sampleCode(const MultiLayer &sample)
 ";
 
 
@@ -2072,7 +2072,7 @@ Returns default metric name.
 
 
 // File: namespacePy_1_1Export.xml
-%feature("docstring")  Py::Export::sampleCode "std::string Py::Export::sampleCode(const MultiLayer &multilayer)
+%feature("docstring")  Py::Export::sampleCode "std::string Py::Export::sampleCode(const MultiLayer &sample)
 ";
 
 %feature("docstring")  Py::Export::simulationPlotCode "std::string Py::Export::simulationPlotCode(const ISimulation &simulation)
diff --git a/auto/Wrap/libBornAgainResample.py b/auto/Wrap/libBornAgainResample.py
index bf58df01e73..0cc597a568c 100644
--- a/auto/Wrap/libBornAgainResample.py
+++ b/auto/Wrap/libBornAgainResample.py
@@ -2205,23 +2205,23 @@ def generateZValues(n_points, z_min, z_max):
     """
     return _libBornAgainResample.generateZValues(n_points, z_min, z_max)
 
-def materialProfileSLD(multilayer, n_points, z_min, z_max):
+def materialProfileSLD(sample, n_points, z_min, z_max):
     r"""
-    materialProfileSLD(MultiLayer const & multilayer, int n_points, double z_min, double z_max) -> vector_complex_t
-    std::vector< complex_t > swigAPI::materialProfileSLD(const MultiLayer &multilayer, int n_points, double z_min, double z_max)
+    materialProfileSLD(MultiLayer const & sample, int n_points, double z_min, double z_max) -> vector_complex_t
+    std::vector< complex_t > swigAPI::materialProfileSLD(const MultiLayer &sample, int n_points, double z_min, double z_max)
 
-    Calculate average material profile for given multilayer. 
+    Calculate average material profile for given sample. 
 
     """
-    return _libBornAgainResample.materialProfileSLD(multilayer, n_points, z_min, z_max)
+    return _libBornAgainResample.materialProfileSLD(sample, n_points, z_min, z_max)
 
-def defaultMaterialProfileLimits(multilayer):
+def defaultMaterialProfileLimits(sample):
     r"""
-    defaultMaterialProfileLimits(MultiLayer const & multilayer) -> pvacuum_double_t
-    std::pair< double, double > swigAPI::defaultMaterialProfileLimits(const MultiLayer &multilayer)
+    defaultMaterialProfileLimits(MultiLayer const & sample) -> pvacuum_double_t
+    std::pair< double, double > swigAPI::defaultMaterialProfileLimits(const MultiLayer &sample)
 
     Get default z limits for generating a material profile. 
 
     """
-    return _libBornAgainResample.defaultMaterialProfileLimits(multilayer)
+    return _libBornAgainResample.defaultMaterialProfileLimits(sample)
 
diff --git a/auto/Wrap/libBornAgainResample_wrap.cpp b/auto/Wrap/libBornAgainResample_wrap.cpp
index 0baaf8fcab7..5309084f817 100644
--- a/auto/Wrap/libBornAgainResample_wrap.cpp
+++ b/auto/Wrap/libBornAgainResample_wrap.cpp
@@ -28356,15 +28356,15 @@ static PyMethodDef SwigMethods[] = {
 		"\n"
 		""},
 	 { "materialProfileSLD", _wrap_materialProfileSLD, METH_VARARGS, "\n"
-		"materialProfileSLD(MultiLayer const & multilayer, int n_points, double z_min, double z_max) -> vector_complex_t\n"
-		"std::vector< complex_t > swigAPI::materialProfileSLD(const MultiLayer &multilayer, int n_points, double z_min, double z_max)\n"
+		"materialProfileSLD(MultiLayer const & sample, int n_points, double z_min, double z_max) -> vector_complex_t\n"
+		"std::vector< complex_t > swigAPI::materialProfileSLD(const MultiLayer &sample, int n_points, double z_min, double z_max)\n"
 		"\n"
-		"Calculate average material profile for given multilayer. \n"
+		"Calculate average material profile for given sample. \n"
 		"\n"
 		""},
 	 { "defaultMaterialProfileLimits", _wrap_defaultMaterialProfileLimits, METH_O, "\n"
-		"defaultMaterialProfileLimits(MultiLayer const & multilayer) -> pvacuum_double_t\n"
-		"std::pair< double, double > swigAPI::defaultMaterialProfileLimits(const MultiLayer &multilayer)\n"
+		"defaultMaterialProfileLimits(MultiLayer const & sample) -> pvacuum_double_t\n"
+		"std::pair< double, double > swigAPI::defaultMaterialProfileLimits(const MultiLayer &sample)\n"
 		"\n"
 		"Get default z limits for generating a material profile. \n"
 		"\n"
diff --git a/auto/Wrap/libBornAgainSample.py b/auto/Wrap/libBornAgainSample.py
index cb05dca14a2..2d136e29bf7 100644
--- a/auto/Wrap/libBornAgainSample.py
+++ b/auto/Wrap/libBornAgainSample.py
@@ -5316,7 +5316,7 @@ class IInterference(libBornAgainBase.ICloneable, libBornAgainParam.INode):
         supportsMultilayer(IInterference self) -> bool
         virtual bool IInterference::supportsMultilayer() const
 
-        Indicates if this interference function can be used with a multilayer (DWBA mode) 
+        Indicates if this interference function can be used with a sample (DWBA mode) 
 
         """
         return _libBornAgainSample.IInterference_supportsMultilayer(self)
@@ -5925,7 +5925,7 @@ class Interference3DLattice(IInterference):
         supportsMultilayer(Interference3DLattice self) -> bool
         bool Interference3DLattice::supportsMultilayer() const override
 
-        Indicates if this interference function can be used with a multilayer (DWBA mode) 
+        Indicates if this interference function can be used with a sample (DWBA mode) 
 
         """
         return _libBornAgainSample.Interference3DLattice_supportsMultilayer(self)
@@ -6129,7 +6129,7 @@ class InterferenceFinite3DLattice(IInterference):
         supportsMultilayer(InterferenceFinite3DLattice self) -> bool
         bool InterferenceFinite3DLattice::supportsMultilayer() const override
 
-        Indicates if this interference function can be used with a multilayer (DWBA mode) 
+        Indicates if this interference function can be used with a sample (DWBA mode) 
 
         """
         return _libBornAgainSample.InterferenceFinite3DLattice_supportsMultilayer(self)
@@ -7023,7 +7023,7 @@ class MultiLayer(ISampleNode):
         setExternalField(MultiLayer self, R3 ext_field)
         void MultiLayer::setExternalField(R3 ext_field)
 
-        Sets the external field applied to the multilayer (units: A/m) 
+        Sets the external field applied to the sample (units: A/m) 
 
         """
         return _libBornAgainSample.MultiLayer_setExternalField(self, ext_field)
@@ -7071,7 +7071,7 @@ class MultiLayer(ISampleNode):
         externalField(MultiLayer self) -> R3
         R3 MultiLayer::externalField() const
 
-        Returns the external field applied to the multilayer (units: A/m) 
+        Returns the external field applied to the sample (units: A/m) 
 
         """
         return _libBornAgainSample.MultiLayer_externalField(self)
diff --git a/auto/Wrap/libBornAgainSample_wrap.cpp b/auto/Wrap/libBornAgainSample_wrap.cpp
index cf04a0f1ec0..a96930ee8e0 100644
--- a/auto/Wrap/libBornAgainSample_wrap.cpp
+++ b/auto/Wrap/libBornAgainSample_wrap.cpp
@@ -62525,7 +62525,7 @@ static PyMethodDef SwigMethods[] = {
 		"IInterference_supportsMultilayer(IInterference self) -> bool\n"
 		"virtual bool IInterference::supportsMultilayer() const\n"
 		"\n"
-		"Indicates if this interference function can be used with a multilayer (DWBA mode) \n"
+		"Indicates if this interference function can be used with a sample (DWBA mode) \n"
 		"\n"
 		""},
 	 { "IInterference_DWfactor", _wrap_IInterference_DWfactor, METH_VARARGS, "\n"
@@ -62924,7 +62924,7 @@ static PyMethodDef SwigMethods[] = {
 		"Interference3DLattice_supportsMultilayer(Interference3DLattice self) -> bool\n"
 		"bool Interference3DLattice::supportsMultilayer() const override\n"
 		"\n"
-		"Indicates if this interference function can be used with a multilayer (DWBA mode) \n"
+		"Indicates if this interference function can be used with a sample (DWBA mode) \n"
 		"\n"
 		""},
 	 { "Interference3DLattice_nodeChildren", _wrap_Interference3DLattice_nodeChildren, METH_O, "\n"
@@ -63051,7 +63051,7 @@ static PyMethodDef SwigMethods[] = {
 		"InterferenceFinite3DLattice_supportsMultilayer(InterferenceFinite3DLattice self) -> bool\n"
 		"bool InterferenceFinite3DLattice::supportsMultilayer() const override\n"
 		"\n"
-		"Indicates if this interference function can be used with a multilayer (DWBA mode) \n"
+		"Indicates if this interference function can be used with a sample (DWBA mode) \n"
 		"\n"
 		""},
 	 { "InterferenceFinite3DLattice_nodeChildren", _wrap_InterferenceFinite3DLattice_nodeChildren, METH_O, "\n"
@@ -63598,7 +63598,7 @@ static PyMethodDef SwigMethods[] = {
 		"MultiLayer_setExternalField(MultiLayer self, R3 ext_field)\n"
 		"void MultiLayer::setExternalField(R3 ext_field)\n"
 		"\n"
-		"Sets the external field applied to the multilayer (units: A/m) \n"
+		"Sets the external field applied to the sample (units: A/m) \n"
 		"\n"
 		""},
 	 { "MultiLayer_layer", _wrap_MultiLayer_layer, METH_VARARGS, "\n"
@@ -63631,7 +63631,7 @@ static PyMethodDef SwigMethods[] = {
 		"MultiLayer_externalField(MultiLayer self) -> R3\n"
 		"R3 MultiLayer::externalField() const\n"
 		"\n"
-		"Returns the external field applied to the multilayer (units: A/m) \n"
+		"Returns the external field applied to the sample (units: A/m) \n"
 		"\n"
 		""},
 	 { "MultiLayer_nodeChildren", _wrap_MultiLayer_nodeChildren, METH_O, "\n"
diff --git a/auto/Wrap/libBornAgainSim.py b/auto/Wrap/libBornAgainSim.py
index 1357e914972..3c24ae79759 100644
--- a/auto/Wrap/libBornAgainSim.py
+++ b/auto/Wrap/libBornAgainSim.py
@@ -3966,13 +3966,13 @@ class PoissonBackground(IBackground):
 _libBornAgainSim.PoissonBackground_swigregister(PoissonBackground)
 
 
-def sampleCode(multilayer):
+def sampleCode(sample):
     r"""
-    sampleCode(MultiLayer const & multilayer) -> std::string
-    std::string Py::Export::sampleCode(const MultiLayer &multilayer)
+    sampleCode(MultiLayer const & sample) -> std::string
+    std::string Py::Export::sampleCode(const MultiLayer &sample)
 
     """
-    return _libBornAgainSim.sampleCode(multilayer)
+    return _libBornAgainSim.sampleCode(sample)
 
 def simulationPlotCode(simulation):
     r"""
diff --git a/auto/Wrap/libBornAgainSim_wrap.cpp b/auto/Wrap/libBornAgainSim_wrap.cpp
index 45a09be043c..cd334895e70 100644
--- a/auto/Wrap/libBornAgainSim_wrap.cpp
+++ b/auto/Wrap/libBornAgainSim_wrap.cpp
@@ -42303,8 +42303,8 @@ static PyMethodDef SwigMethods[] = {
 	 { "PoissonBackground_swigregister", PoissonBackground_swigregister, METH_O, NULL},
 	 { "PoissonBackground_swiginit", PoissonBackground_swiginit, METH_VARARGS, NULL},
 	 { "sampleCode", _wrap_sampleCode, METH_O, "\n"
-		"sampleCode(MultiLayer const & multilayer) -> std::string\n"
-		"std::string Py::Export::sampleCode(const MultiLayer &multilayer)\n"
+		"sampleCode(MultiLayer const & sample) -> std::string\n"
+		"std::string Py::Export::sampleCode(const MultiLayer &sample)\n"
 		"\n"
 		""},
 	 { "simulationPlotCode", _wrap_simulationPlotCode, METH_O, "\n"
diff --git a/hugo/content/py/sample/interference/3d-nanoparticle-arrangements/mesocrystal.py b/hugo/content/py/sample/interference/3d-nanoparticle-arrangements/mesocrystal.py
index 45a554d9583..90972535920 100644
--- a/hugo/content/py/sample/interference/3d-nanoparticle-arrangements/mesocrystal.py
+++ b/hugo/content/py/sample/interference/3d-nanoparticle-arrangements/mesocrystal.py
@@ -53,11 +53,11 @@ def get_sample():
     l_air.addLayout(layout)
 
     # Defining Multilayers
-    multilayer = ba.MultiLayer()
-    multilayer.addLayer(l_air)
-    multilayer.addLayer(l_substrate)
-    # print(multilayer.parametersToString())
-    return multilayer
+    sample = ba.MultiLayer()
+    sample.addLayer(l_air)
+    sample.addLayer(l_substrate)
+    # print(sample.parametersToString())
+    return sample
 
 
 def get_simulation():
diff --git a/hugo/content/py/sample/interference/3d-nanoparticle-arrangements/mesocrystal_4plots.py b/hugo/content/py/sample/interference/3d-nanoparticle-arrangements/mesocrystal_4plots.py
index 657dd4e6307..58d5eb0c5a3 100644
--- a/hugo/content/py/sample/interference/3d-nanoparticle-arrangements/mesocrystal_4plots.py
+++ b/hugo/content/py/sample/interference/3d-nanoparticle-arrangements/mesocrystal_4plots.py
@@ -53,11 +53,11 @@ def get_sample():
     l_air.addLayout(layout)
 
     # Defining Multilayers
-    multilayer = ba.MultiLayer()
-    multilayer.addLayer(l_air)
-    multilayer.addLayer(l_substrate)
-    # print(multilayer.parametersToString())
-    return multilayer
+    sample = ba.MultiLayer()
+    sample.addLayer(l_air)
+    sample.addLayer(l_substrate)
+    # print(sample.parametersToString())
+    return sample
 
 
 def get_simulation():
diff --git a/hugo/content/py/sample/interference/3d-nanoparticle-arrangements/particle_composition.py b/hugo/content/py/sample/interference/3d-nanoparticle-arrangements/particle_composition.py
index 446235e7ab0..2fd3a65b333 100644
--- a/hugo/content/py/sample/interference/3d-nanoparticle-arrangements/particle_composition.py
+++ b/hugo/content/py/sample/interference/3d-nanoparticle-arrangements/particle_composition.py
@@ -51,11 +51,11 @@ def get_sample():
     l_air.addLayout(layout)
 
     # Defining Multilayers
-    multilayer = ba.MultiLayer()
-    multilayer.addLayer(l_air)
-    multilayer.addLayer(l_substrate)
-    # print(multilayer.parametersToString())     # uncomment to print sample parameters
-    return multilayer
+    sample = ba.MultiLayer()
+    sample.addLayer(l_air)
+    sample.addLayer(l_substrate)
+    # print(sample.parametersToString())     # uncomment to print sample parameters
+    return sample
 
 
 def get_simulation():
diff --git a/hugo/content/py/sample/interference/3d-nanoparticle-arrangements/particle_composition_rotational_distribution.py b/hugo/content/py/sample/interference/3d-nanoparticle-arrangements/particle_composition_rotational_distribution.py
index 4a79dc8084d..79af55745a1 100644
--- a/hugo/content/py/sample/interference/3d-nanoparticle-arrangements/particle_composition_rotational_distribution.py
+++ b/hugo/content/py/sample/interference/3d-nanoparticle-arrangements/particle_composition_rotational_distribution.py
@@ -53,10 +53,10 @@ def get_sample():
         l_air.addLayout(layout)
 
     # Defining Multilayers
-    multilayer = ba.MultiLayer()
-    multilayer.addLayer(l_air)
-    multilayer.addLayer(l_substrate)
-    return multilayer
+    sample = ba.MultiLayer()
+    sample.addLayer(l_air)
+    sample.addLayer(l_substrate)
+    return sample
 
 
 def get_simulation():
-- 
GitLab


From c8a8534cbeaed17dbbd8e7bb8e6cb77a12f71a9a Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Tue, 24 May 2022 11:39:44 +0200
Subject: [PATCH 58/63] clang-format

---
 Device/Histo/IOFactory.cpp               | 8 ++++----
 GUI/Model/Device/InstrumentItems.cpp     | 8 ++++----
 GUI/Model/Device/InstrumentItems.h       | 8 ++++----
 GUI/Model/Model/JobModel.cpp             | 5 ++---
 GUI/Model/Sample/InterferenceItems.cpp   | 4 ++--
 GUI/View/FromDomain/GUISampleBuilder.cpp | 7 +++----
 GUI/View/FromDomain/GUISampleBuilder.h   | 3 +--
 GUI/View/SampleDesigner/MultiLayerForm.h | 2 +-
 Resample/Processed/ParticleRegions.cpp   | 3 +--
 Sample/Multilayer/MultilayerUtils.cpp    | 3 +--
 10 files changed, 23 insertions(+), 28 deletions(-)

diff --git a/Device/Histo/IOFactory.cpp b/Device/Histo/IOFactory.cpp
index a361d0c62e9..c3a722e5d57 100644
--- a/Device/Histo/IOFactory.cpp
+++ b/Device/Histo/IOFactory.cpp
@@ -47,7 +47,7 @@ Powerfield<double>* IOFactory::readPowerfield(const std::string& file_name, Load
 
     if (readAs(bornagain))
         result = readPowerfield(file_name,
-                             [](std::istream& s) { return ReadWriteINT().readPowerfield(s); });
+                                [](std::istream& s) { return ReadWriteINT().readPowerfield(s); });
 
     else if (readAs(nicos))
         result = readPowerfield(file_name, [](std::istream& s) { return IO::readNicosData(s); });
@@ -55,15 +55,15 @@ Powerfield<double>* IOFactory::readPowerfield(const std::string& file_name, Load
 #ifdef BA_TIFF_SUPPORT
     else if (readAs(tiff))
         result = readPowerfield(file_name,
-                             [](std::istream& s) { return ReadWriteTiff().readPowerfield(s); });
+                                [](std::istream& s) { return ReadWriteTiff().readPowerfield(s); });
 #endif
 
     else
         // Try to read ASCII by default. Binary maps to ASCII.
         // If the file is not actually a matrix of numbers,
         // the error will be thrown during the reading.
-        result = readPowerfield(file_name,
-                             [](std::istream& s) { return ReadWriteNumpyTXT().readPowerfield(s); });
+        result = readPowerfield(
+            file_name, [](std::istream& s) { return ReadWriteNumpyTXT().readPowerfield(s); });
 
     ASSERT(result);
     return result;
diff --git a/GUI/Model/Device/InstrumentItems.cpp b/GUI/Model/Device/InstrumentItems.cpp
index b97248f622a..cd74007802a 100644
--- a/GUI/Model/Device/InstrumentItems.cpp
+++ b/GUI/Model/Device/InstrumentItems.cpp
@@ -367,8 +367,8 @@ std::unique_ptr<Instrument> Instrument2DItem::createInstrument() const
     return std::make_unique<Instrument>(*beam, *detector);
 }
 
-std::unique_ptr<ScatteringSimulation> Instrument2DItem::createScatteringSimulation(
-    const MultiLayer& sample) const
+std::unique_ptr<ScatteringSimulation>
+Instrument2DItem::createScatteringSimulation(const MultiLayer& sample) const
 {
     auto beam = beamItem()->createBeam();
     auto detector = detectorItem()->createDetector();
@@ -380,8 +380,8 @@ std::unique_ptr<ScatteringSimulation> Instrument2DItem::createScatteringSimulati
     return result;
 }
 
-std::unique_ptr<OffSpecularSimulation> Instrument2DItem::createOffSpecularSimulation(
-    const MultiLayer& sample) const
+std::unique_ptr<OffSpecularSimulation>
+Instrument2DItem::createOffSpecularSimulation(const MultiLayer& sample) const
 {
     auto beam = beamItem()->createBeam();
     auto detector = detectorItem()->createDetector();
diff --git a/GUI/Model/Device/InstrumentItems.h b/GUI/Model/Device/InstrumentItems.h
index f758b690d08..053ab145c9a 100644
--- a/GUI/Model/Device/InstrumentItems.h
+++ b/GUI/Model/Device/InstrumentItems.h
@@ -159,10 +159,10 @@ public:
     void importMasks(const MaskContainerItem* maskContainer) override;
 
     std::unique_ptr<Instrument> createInstrument() const;
-    std::unique_ptr<ScatteringSimulation> createScatteringSimulation(
-        const MultiLayer& sample) const;
-    std::unique_ptr<OffSpecularSimulation> createOffSpecularSimulation(
-        const MultiLayer& sample) const;
+    std::unique_ptr<ScatteringSimulation>
+    createScatteringSimulation(const MultiLayer& sample) const;
+    std::unique_ptr<OffSpecularSimulation>
+    createOffSpecularSimulation(const MultiLayer& sample) const;
 
     static bool isDetectorPropertyName(const QString& name);
 
diff --git a/GUI/Model/Model/JobModel.cpp b/GUI/Model/Model/JobModel.cpp
index 2563898c8b9..be48d324927 100644
--- a/GUI/Model/Model/JobModel.cpp
+++ b/GUI/Model/Model/JobModel.cpp
@@ -50,9 +50,8 @@ JobItem* JobModel::getJobItemForIdentifier(const QString& identifier)
 }
 
 //! Main method to add a job
-JobItem* JobModel::addJob(const MultiLayerItem* sampleItem,
-                          const InstrumentItem* instrumentItem, const RealDataItem* realDataItem,
-                          const SimulationOptionsItem& optionItem)
+JobItem* JobModel::addJob(const MultiLayerItem* sampleItem, const InstrumentItem* instrumentItem,
+                          const RealDataItem* realDataItem, const SimulationOptionsItem& optionItem)
 {
     ASSERT(sampleItem);
     ASSERT(instrumentItem);
diff --git a/GUI/Model/Sample/InterferenceItems.cpp b/GUI/Model/Sample/InterferenceItems.cpp
index 1a26f7ee83a..6e08df7b68d 100644
--- a/GUI/Model/Sample/InterferenceItems.cpp
+++ b/GUI/Model/Sample/InterferenceItems.cpp
@@ -268,8 +268,8 @@ InterferenceFinite2DLatticeItem::InterferenceFinite2DLatticeItem()
 std::unique_ptr<IInterference> InterferenceFinite2DLatticeItem::createInterference() const
 {
     Lattice2DItem* latticeItem = latticeType().currentItem();
-    auto result = std::make_unique<InterferenceFinite2DLattice>(
-        *latticeItem->createLattice(), m_domainSize1, m_domainSize2);
+    auto result = std::make_unique<InterferenceFinite2DLattice>(*latticeItem->createLattice(),
+                                                                m_domainSize1, m_domainSize2);
 
     result->setIntegrationOverXi(xiIntegration());
     result->setPositionVariance(positionVariance());
diff --git a/GUI/View/FromDomain/GUISampleBuilder.cpp b/GUI/View/FromDomain/GUISampleBuilder.cpp
index abcfb9289e3..edd32988e85 100644
--- a/GUI/View/FromDomain/GUISampleBuilder.cpp
+++ b/GUI/View/FromDomain/GUISampleBuilder.cpp
@@ -38,8 +38,8 @@ MultiLayerItem* GUISampleBuilder::createMultiLayerItem(const MultiLayer& sample,
                                                        const QString& nodeName)
 {
     m_sampleItem = new MultiLayerItem();
-    m_sampleItem->setSampleName(
-        nodeName.isEmpty() ? QString::fromStdString(sample.sampleName()) : nodeName);
+    m_sampleItem->setSampleName(nodeName.isEmpty() ? QString::fromStdString(sample.sampleName())
+                                                   : nodeName);
     m_sampleItem->crossCorrLength().set(sample.crossCorrLength());
     m_sampleItem->setExternalField(sample.externalField());
 
@@ -153,8 +153,7 @@ void GUISampleBuilder::copyParticle(const IParticle* iparticle,
 
     } else if (const auto* particleComposition =
                    dynamic_cast<const ParticleComposition*>(iparticle)) {
-        auto* particleCompositionItem =
-            new ParticleCompositionItem(&m_sampleItem->materialItems());
+        auto* particleCompositionItem = new ParticleCompositionItem(&m_sampleItem->materialItems());
 
         particleCompositionItem->setAbundance(particleComposition->abundance());
         particleCompositionItem->setPosition(particleComposition->particlePosition());
diff --git a/GUI/View/FromDomain/GUISampleBuilder.h b/GUI/View/FromDomain/GUISampleBuilder.h
index cc3693308f3..33a76131408 100644
--- a/GUI/View/FromDomain/GUISampleBuilder.h
+++ b/GUI/View/FromDomain/GUISampleBuilder.h
@@ -46,8 +46,7 @@ public:
         QByteArray m_msgAsLatin1;
     };
 
-    MultiLayerItem* createMultiLayerItem(const MultiLayer& sample,
-                                         const QString& nodeName = "");
+    MultiLayerItem* createMultiLayerItem(const MultiLayer& sample, const QString& nodeName = "");
 
 private:
     MaterialItem* createMaterialFromDomain(const Material* material);
diff --git a/GUI/View/SampleDesigner/MultiLayerForm.h b/GUI/View/SampleDesigner/MultiLayerForm.h
index c6ec52109c2..0b6e39d601c 100644
--- a/GUI/View/SampleDesigner/MultiLayerForm.h
+++ b/GUI/View/SampleDesigner/MultiLayerForm.h
@@ -73,7 +73,7 @@ public:
 private:
     QVBoxLayout* m_layout;
     MultiLayerItem* m_sampleItem; //!< Ptr is borrowed, don't delete
-    SampleEditorController* m_ec;     //!< Ptr is borrowed, don't delete
+    SampleEditorController* m_ec; //!< Ptr is borrowed, don't delete
     bool m_showInlineEditButtons = false;
     bool m_useAngstrom;
     bool m_useRadiant;
diff --git a/Resample/Processed/ParticleRegions.cpp b/Resample/Processed/ParticleRegions.cpp
index 3fd4432ddec..a3d40a4bd30 100644
--- a/Resample/Processed/ParticleRegions.cpp
+++ b/Resample/Processed/ParticleRegions.cpp
@@ -154,8 +154,7 @@ void LayerFillLimits::updateLayerLimits(size_t i_layer, ZLimits limits)
 //  ************************************************************************************************
 
 //! Calculate z-admixtures occupied by particles
-std::vector<ZLimits> Compute::Slicing::particleRegions(const MultiLayer& sample,
-                                                       bool use_slicing)
+std::vector<ZLimits> Compute::Slicing::particleRegions(const MultiLayer& sample, bool use_slicing)
 {
     const std::vector<double> bottom_coords = bottomLayerCoordinates(sample);
     LayerFillLimits layer_fill_limits(bottom_coords);
diff --git a/Sample/Multilayer/MultilayerUtils.cpp b/Sample/Multilayer/MultilayerUtils.cpp
index f6bf3d71f94..d651967ea92 100644
--- a/Sample/Multilayer/MultilayerUtils.cpp
+++ b/Sample/Multilayer/MultilayerUtils.cpp
@@ -18,8 +18,7 @@
 #include "Sample/Multilayer/Layer.h"
 #include "Sample/Multilayer/MultiLayer.h"
 
-const LayerRoughness* SampleUtils::Multilayer::LayerTopRoughness(const MultiLayer& sample,
-                                                                 size_t i)
+const LayerRoughness* SampleUtils::Multilayer::LayerTopRoughness(const MultiLayer& sample, size_t i)
 {
     if (i == 0)
         return nullptr;
-- 
GitLab


From c4b8df8ad0e3ed8d7eb6c93a39f7574c2b5c1f5d Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Tue, 24 May 2022 11:54:22 +0200
Subject: [PATCH 59/63] SpecularSimulation rm default c'tor

---
 GUI/Model/To/DomainSimulationBuilder.cpp   |  5 +--
 Sim/Export/SimulationToPython.cpp          |  8 ++---
 Sim/Simulation/SpecularSimulation.cpp      |  6 +---
 Sim/Simulation/SpecularSimulation.h        |  1 -
 Tests/Functional/Suite/MakeSimulations.cpp | 42 ++++++++--------------
 auto/Wrap/doxygenSim.i                     |  3 --
 auto/Wrap/libBornAgainSim.py               |  1 -
 auto/Wrap/libBornAgainSim_wrap.cpp         | 26 +++-----------
 8 files changed, 23 insertions(+), 69 deletions(-)

diff --git a/GUI/Model/To/DomainSimulationBuilder.cpp b/GUI/Model/To/DomainSimulationBuilder.cpp
index 1a50b07a41e..3910d72b712 100644
--- a/GUI/Model/To/DomainSimulationBuilder.cpp
+++ b/GUI/Model/To/DomainSimulationBuilder.cpp
@@ -161,9 +161,6 @@ createSpecularSimulation(std::unique_ptr<MultiLayer> P_sample,
                          const SpecularInstrumentItem* instrument,
                          const SimulationOptionsItem& optionsItem)
 {
-    std::unique_ptr<SpecularSimulation> result = std::make_unique<SpecularSimulation>();
-    result->setSample(*P_sample);
-
     auto* beam_item = instrument->beamItem();
     auto* const axis_item = beam_item->inclinationAxis();
     auto* const footprint = beam_item->footprint();
@@ -173,8 +170,8 @@ createSpecularSimulation(std::unique_ptr<MultiLayer> P_sample,
 
     addBeamDivergencesToScan(*beam_item, scan);
 
+    auto result = std::make_unique<SpecularSimulation>(scan, *P_sample);
     result->beam().setIntensity(beam_item->intensity());
-    result->setScan(scan);
 
     // ISimulation options
     setSimulationOptions(result.get(), optionsItem);
diff --git a/Sim/Export/SimulationToPython.cpp b/Sim/Export/SimulationToPython.cpp
index 5d132c4c645..67c60ed35ef 100644
--- a/Sim/Export/SimulationToPython.cpp
+++ b/Sim/Export/SimulationToPython.cpp
@@ -321,8 +321,6 @@ std::string defineSpecularScan(const SpecularSimulation& simulation)
         throw std::runtime_error("Error defineSpecularScan: passed simulation "
                                  "does not contain any scan");
     result << defineScan(scan) << "\n";
-    result << indent() << "simulation.setScan(scan)\n";
-    result << defineBeamIntensity(simulation.beam()) << "\n";
     return result.str();
 }
 
@@ -441,13 +439,13 @@ std::string defineOffSpecularSimulation(const OffSpecularSimulation* simulation)
 std::string defineSpecularSimulation(const SpecularSimulation* simulation)
 {
     std::ostringstream result;
-    result << indent() << "simulation = ba.SpecularSimulation()\n";
-    result << defineDetectorPolarizationAnalysis(simulation);
     result << defineSpecularScan(*simulation);
+    result << indent() << "simulation = ba.SpecularSimulation(scan, sample)\n";
+    result << defineDetectorPolarizationAnalysis(simulation);
     result << defineParameterDistributions(simulation);
     result << defineSimulationOptions(simulation);
     result << defineBackground(simulation);
-    result << "    simulation.setSample(sample)\n";
+    result << defineBeamIntensity(simulation->beam()) << "\n";
     return result.str();
 }
 
diff --git a/Sim/Simulation/SpecularSimulation.cpp b/Sim/Simulation/SpecularSimulation.cpp
index 1a55b54ac68..70a34710c12 100644
--- a/Sim/Simulation/SpecularSimulation.cpp
+++ b/Sim/Simulation/SpecularSimulation.cpp
@@ -51,15 +51,11 @@ std::unique_ptr<AlphaScan> mangledScan(const AlphaScan& scan, const Beam& beam)
 //  class SpecularSimulation
 //  ************************************************************************************************
 
-SpecularSimulation::SpecularSimulation()
-{
-    m_detector.reset(new SpecularDetector1D);
-}
-
 SpecularSimulation::SpecularSimulation(const ISpecularScan& scan, const MultiLayer& sample)
 {
     setScan(scan);
     setSample(sample);
+    // TODO rm class ??? m_detector.reset(new SpecularDetector1D);
 }
 
 SpecularSimulation::~SpecularSimulation() = default;
diff --git a/Sim/Simulation/SpecularSimulation.h b/Sim/Simulation/SpecularSimulation.h
index 2efe9a321c6..94c2ad7d02f 100644
--- a/Sim/Simulation/SpecularSimulation.h
+++ b/Sim/Simulation/SpecularSimulation.h
@@ -33,7 +33,6 @@ class SpecularElement;
 
 class SpecularSimulation : public ISimulation {
 public:
-    SpecularSimulation();
     SpecularSimulation(const ISpecularScan& scan, const MultiLayer& sample);
     ~SpecularSimulation() override;
     SpecularSimulation(SpecularSimulation&&);
diff --git a/Tests/Functional/Suite/MakeSimulations.cpp b/Tests/Functional/Suite/MakeSimulations.cpp
index cd9c81d26f5..cf594b2aa0b 100644
--- a/Tests/Functional/Suite/MakeSimulations.cpp
+++ b/Tests/Functional/Suite/MakeSimulations.cpp
@@ -366,7 +366,7 @@ std::unique_ptr<SpecularSimulation> test::makeSimulation::BasicSpecular(const Mu
     const double min_angle = 0;
     const double max_angle = 5 * deg;
 
-    auto result = std::make_unique<SpecularSimulation>();
+    std::unique_ptr<SpecularSimulation> result;
 
     if (vsQ) {
         FixedBinAxis angle_axis("axis", number_of_bins, min_angle, max_angle);
@@ -375,13 +375,12 @@ std::unique_ptr<SpecularSimulation> test::makeSimulation::BasicSpecular(const Mu
         for (size_t i = 0, size = qs.size(); i < size; ++i)
             qs[i] = 4.0 * M_PI * std::sin(angles[i]) / wavelength;
         QzScan scan(qs);
-        result->setScan(scan);
+        result.reset(new SpecularSimulation(scan, sample));
     } else {
         AlphaScan scan(wavelength, FixedBinAxis("axis", number_of_bins, min_angle, max_angle));
-        result->setScan(scan);
+        result.reset(new SpecularSimulation(scan, sample));
     }
 
-    result->setSample(sample);
     result->options().setUseAvgMaterials(true);
     return result;
 }
@@ -408,10 +407,7 @@ test::makeSimulation::SpecularWithGaussianBeam(const MultiLayer& sample)
     AlphaScan scan(wavelength, FixedBinAxis("axis", number_of_bins, min_angle, max_angle));
     scan.setFootprintFactor(gaussian_ff.get());
 
-    auto result = std::make_unique<SpecularSimulation>();
-    result->setScan(scan);
-    result->setSample(sample);
-    return result;
+    return std::make_unique<SpecularSimulation>(scan, sample);
 }
 
 std::unique_ptr<SpecularSimulation>
@@ -425,10 +421,7 @@ test::makeSimulation::SpecularWithSquareBeam(const MultiLayer& sample)
     AlphaScan scan(wavelength, FixedBinAxis("axis", number_of_bins, min_angle, max_angle));
     scan.setFootprintFactor(square_ff.get());
 
-    auto result = std::make_unique<SpecularSimulation>();
-    result->setScan(scan);
-    result->setSample(sample);
-    return result;
+    return std::make_unique<SpecularSimulation>(scan, sample);
 }
 
 std::unique_ptr<SpecularSimulation>
@@ -454,23 +447,18 @@ test::makeSimulation::SpecularDivergentBeam(const MultiLayer& sample)
     scan.setWavelengthResolution(*wl_res);
     scan.setAngleResolution(*ang_res);
 
-    auto result = std::make_unique<SpecularSimulation>();
-    result->setScan(scan);
-    result->setSample(sample);
-    return result;
+    return std::make_unique<SpecularSimulation>(scan, sample);
 }
 
 std::unique_ptr<SpecularSimulation>
 test::makeSimulation::TOFRWithRelativeResolution(const MultiLayer& sample)
 {
     FixedBinAxis qs("axis", 500, 0.0, 1.0);
-    QzScan q_scan(qs);
-    q_scan.setRelativeQResolution(RangedDistributionGaussian(20, 2.0), 0.03);
+    QzScan scan(qs);
+    scan.setRelativeQResolution(RangedDistributionGaussian(20, 2.0), 0.03);
 
-    auto result = std::make_unique<SpecularSimulation>();
-    result->setScan(q_scan);
+    auto result = std::make_unique<SpecularSimulation>(scan, sample);
     result->options().setUseAvgMaterials(true);
-    result->setSample(sample);
     return result;
 }
 
@@ -478,19 +466,17 @@ std::unique_ptr<SpecularSimulation>
 test::makeSimulation::TOFRWithPointwiseResolution(const MultiLayer& sample)
 {
     FixedBinAxis qs("axis", 500, 0.0, 1.0);
-    QzScan q_scan(qs);
+    QzScan scan(qs);
 
     std::vector<double> resolutions;
     resolutions.reserve(qs.size());
     auto qs_vector = qs.binCenters();
     std::for_each(qs_vector.begin(), qs_vector.end(),
                   [&resolutions](double q_val) { resolutions.push_back(0.03 * q_val); });
-    q_scan.setAbsoluteQResolution(RangedDistributionGaussian(20, 2.0), resolutions);
+    scan.setAbsoluteQResolution(RangedDistributionGaussian(20, 2.0), resolutions);
 
-    auto result = std::make_unique<SpecularSimulation>();
-    result->setScan(q_scan);
+    auto result = std::make_unique<SpecularSimulation>(scan, sample);
     result->options().setUseAvgMaterials(true);
-    result->setSample(sample);
     return result;
 }
 
@@ -501,8 +487,6 @@ test::makeSimulation::TOFRWithPointwiseResolution(const MultiLayer& sample)
 std::unique_ptr<DepthProbeSimulation>
 test::makeSimulation::BasicDepthProbe(const MultiLayer& sample)
 {
-    auto result = std::make_unique<DepthProbeSimulation>();
-
     const double wavelength = 10 * angstrom;
     const size_t n_alpha = 20;
     const double alpha_min = 0;
@@ -511,6 +495,8 @@ test::makeSimulation::BasicDepthProbe(const MultiLayer& sample)
     const double z_min = -100.0 * Units::nm;
     const double z_max = 100.0 * Units::nm;
 
+    auto result = std::make_unique<DepthProbeSimulation>();
+
     result->setBeamParameters(wavelength, n_alpha, alpha_min, alpha_max);
     result->setZSpan(n_z, z_min, z_max);
 
diff --git a/auto/Wrap/doxygenSim.i b/auto/Wrap/doxygenSim.i
index 0f0713ce035..5602be2cf77 100644
--- a/auto/Wrap/doxygenSim.i
+++ b/auto/Wrap/doxygenSim.i
@@ -1891,9 +1891,6 @@ Holds an instrument and sample model. Computes detected intensity as function of
 C++ includes: SpecularSimulation.h
 ";
 
-%feature("docstring")  SpecularSimulation::SpecularSimulation "SpecularSimulation::SpecularSimulation()
-";
-
 %feature("docstring")  SpecularSimulation::SpecularSimulation "SpecularSimulation::SpecularSimulation(const ISpecularScan &scan, const MultiLayer &sample)
 ";
 
diff --git a/auto/Wrap/libBornAgainSim.py b/auto/Wrap/libBornAgainSim.py
index 3c24ae79759..3b249549a63 100644
--- a/auto/Wrap/libBornAgainSim.py
+++ b/auto/Wrap/libBornAgainSim.py
@@ -3687,7 +3687,6 @@ class SpecularSimulation(ISimulation):
 
     def __init__(self, *args):
         r"""
-        __init__(SpecularSimulation self) -> SpecularSimulation
         __init__(SpecularSimulation self, ISpecularScan const & scan, MultiLayer const & sample) -> SpecularSimulation
         __init__(SpecularSimulation self, SpecularSimulation arg2) -> SpecularSimulation
         SpecularSimulation::SpecularSimulation(SpecularSimulation &&)
diff --git a/auto/Wrap/libBornAgainSim_wrap.cpp b/auto/Wrap/libBornAgainSim_wrap.cpp
index cd334895e70..aa8aeac7ae9 100644
--- a/auto/Wrap/libBornAgainSim_wrap.cpp
+++ b/auto/Wrap/libBornAgainSim_wrap.cpp
@@ -38607,20 +38607,7 @@ SWIGINTERN PyObject *DepthProbeSimulation_swiginit(PyObject *SWIGUNUSEDPARM(self
   return SWIG_Python_InitShadowInstance(args);
 }
 
-SWIGINTERN PyObject *_wrap_new_SpecularSimulation__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **SWIGUNUSEDPARM(swig_obj)) {
-  PyObject *resultobj = 0;
-  SpecularSimulation *result = 0 ;
-  
-  if ((nobjs < 0) || (nobjs > 0)) SWIG_fail;
-  result = (SpecularSimulation *)new SpecularSimulation();
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_SpecularSimulation, SWIG_POINTER_NEW |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_new_SpecularSimulation__SWIG_1(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) {
+SWIGINTERN PyObject *_wrap_new_SpecularSimulation__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) {
   PyObject *resultobj = 0;
   ISpecularScan *arg1 = 0 ;
   MultiLayer *arg2 = 0 ;
@@ -38677,7 +38664,7 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_new_SpecularSimulation__SWIG_2(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) {
+SWIGINTERN PyObject *_wrap_new_SpecularSimulation__SWIG_1(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) {
   PyObject *resultobj = 0;
   SpecularSimulation *arg1 = 0 ;
   void *argp1 = 0 ;
@@ -38709,16 +38696,13 @@ SWIGINTERN PyObject *_wrap_new_SpecularSimulation(PyObject *self, PyObject *args
   
   if (!(argc = SWIG_Python_UnpackTuple(args, "new_SpecularSimulation", 0, 2, argv))) SWIG_fail;
   --argc;
-  if (argc == 0) {
-    return _wrap_new_SpecularSimulation__SWIG_0(self, argc, argv);
-  }
   if (argc == 1) {
     int _v;
     void *vptr = 0;
     int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_SpecularSimulation, SWIG_POINTER_NO_NULL);
     _v = SWIG_CheckState(res);
     if (_v) {
-      return _wrap_new_SpecularSimulation__SWIG_2(self, argc, argv);
+      return _wrap_new_SpecularSimulation__SWIG_1(self, argc, argv);
     }
   }
   if (argc == 2) {
@@ -38729,7 +38713,7 @@ SWIGINTERN PyObject *_wrap_new_SpecularSimulation(PyObject *self, PyObject *args
       int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_MultiLayer, SWIG_POINTER_NO_NULL | 0);
       _v = SWIG_CheckState(res);
       if (_v) {
-        return _wrap_new_SpecularSimulation__SWIG_1(self, argc, argv);
+        return _wrap_new_SpecularSimulation__SWIG_0(self, argc, argv);
       }
     }
   }
@@ -38737,7 +38721,6 @@ SWIGINTERN PyObject *_wrap_new_SpecularSimulation(PyObject *self, PyObject *args
 fail:
   SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'new_SpecularSimulation'.\n"
     "  Possible C/C++ prototypes are:\n"
-    "    SpecularSimulation::SpecularSimulation()\n"
     "    SpecularSimulation::SpecularSimulation(ISpecularScan const &,MultiLayer const &)\n"
     "    SpecularSimulation::SpecularSimulation(SpecularSimulation &&)\n");
   return 0;
@@ -42149,7 +42132,6 @@ static PyMethodDef SwigMethods[] = {
 		"\n"
 		""},
 	 { "new_SpecularSimulation", _wrap_new_SpecularSimulation, METH_VARARGS, "\n"
-		"SpecularSimulation()\n"
 		"SpecularSimulation(ISpecularScan const & scan, MultiLayer const & sample)\n"
 		"new_SpecularSimulation(SpecularSimulation arg1) -> SpecularSimulation\n"
 		"SpecularSimulation::SpecularSimulation(SpecularSimulation &&)\n"
-- 
GitLab


From a25293154470705989457521b20fdf0a3454d3ff Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Tue, 24 May 2022 11:56:22 +0200
Subject: [PATCH 60/63] rename files OffSepcular... -> Offspec

---
 GUI/Model/Device/InstrumentItems.cpp                      | 2 +-
 GUI/View/Instrument/InstrumentLibraryEditor.cpp           | 2 +-
 GUI/View/Instrument/InstrumentView.cpp                    | 2 +-
 .../{OffSpecularBeamEditor.cpp => OffspecBeamEditor.cpp}  | 4 ++--
 .../{OffSpecularBeamEditor.h => OffspecBeamEditor.h}      | 8 ++++----
 ...arInstrumentEditor.cpp => OffspecInstrumentEditor.cpp} | 6 +++---
 ...ecularInstrumentEditor.h => OffspecInstrumentEditor.h} | 8 ++++----
 .../{OffSpecularSimulation.cpp => OffspecSimulation.cpp}  | 4 ++--
 .../{OffSpecularSimulation.h => OffspecSimulation.h}      | 8 ++++----
 Sim/Simulation/includeSimulations.h                       | 2 +-
 Tests/Functional/Core/Fitting/FitTests.cpp                | 2 +-
 ...SpecularConverterTest.cpp => OffspecConverterTest.cpp} | 0
 Wrap/Swig/libBornAgainSim.i                               | 4 ++--
 13 files changed, 26 insertions(+), 26 deletions(-)
 rename GUI/View/Instrument/{OffSpecularBeamEditor.cpp => OffspecBeamEditor.cpp} (96%)
 rename GUI/View/Instrument/{OffSpecularBeamEditor.h => OffspecBeamEditor.h} (78%)
 rename GUI/View/Instrument/{OffSpecularInstrumentEditor.cpp => OffspecInstrumentEditor.cpp} (90%)
 rename GUI/View/Instrument/{OffSpecularInstrumentEditor.h => OffspecInstrumentEditor.h} (75%)
 rename Sim/Simulation/{OffSpecularSimulation.cpp => OffspecSimulation.cpp} (98%)
 rename Sim/Simulation/{OffSpecularSimulation.h => OffspecSimulation.h} (91%)
 rename Tests/Unit/Device/{OffSpecularConverterTest.cpp => OffspecConverterTest.cpp} (100%)

diff --git a/GUI/Model/Device/InstrumentItems.cpp b/GUI/Model/Device/InstrumentItems.cpp
index cd74007802a..1417cf73251 100644
--- a/GUI/Model/Device/InstrumentItems.cpp
+++ b/GUI/Model/Device/InstrumentItems.cpp
@@ -37,7 +37,7 @@
 #include "GUI/Util/Error.h"
 #include "GUI/Util/String.h"
 #include "Sim/Simulation/DepthProbeSimulation.h"
-#include "Sim/Simulation/OffSpecularSimulation.h"
+#include "Sim/Simulation/OffspecSimulation.h"
 #include "Sim/Simulation/ScatteringSimulation.h"
 
 namespace {
diff --git a/GUI/View/Instrument/InstrumentLibraryEditor.cpp b/GUI/View/Instrument/InstrumentLibraryEditor.cpp
index f68560f7ace..ade8d6ee622 100644
--- a/GUI/View/Instrument/InstrumentLibraryEditor.cpp
+++ b/GUI/View/Instrument/InstrumentLibraryEditor.cpp
@@ -19,7 +19,7 @@
 #include "GUI/View/Common/ItemViewOverlayButtons.h"
 #include "GUI/View/Instrument/DepthProbeInstrumentEditor.h"
 #include "GUI/View/Instrument/GISASInstrumentEditor.h"
-#include "GUI/View/Instrument/OffSpecularInstrumentEditor.h"
+#include "GUI/View/Instrument/OffspecInstrumentEditor.h"
 #include "GUI/View/Instrument/SpecularInstrumentEditor.h"
 #include "GUI/View/Tool/GroupBoxCollapser.h"
 #include "GUI/View/Tool/ItemDelegateForHTML.h"
diff --git a/GUI/View/Instrument/InstrumentView.cpp b/GUI/View/Instrument/InstrumentView.cpp
index 7a7efaec84c..769c9882b22 100644
--- a/GUI/View/Instrument/InstrumentView.cpp
+++ b/GUI/View/Instrument/InstrumentView.cpp
@@ -19,7 +19,7 @@
 #include "GUI/View/Instrument/DepthProbeInstrumentEditor.h"
 #include "GUI/View/Instrument/GISASInstrumentEditor.h"
 #include "GUI/View/Instrument/InstrumentListView.h"
-#include "GUI/View/Instrument/OffSpecularInstrumentEditor.h"
+#include "GUI/View/Instrument/OffspecInstrumentEditor.h"
 #include "GUI/View/Instrument/SpecularInstrumentEditor.h"
 #include "GUI/View/Tool/GroupBoxCollapser.h"
 #include <QBoxLayout>
diff --git a/GUI/View/Instrument/OffSpecularBeamEditor.cpp b/GUI/View/Instrument/OffspecBeamEditor.cpp
similarity index 96%
rename from GUI/View/Instrument/OffSpecularBeamEditor.cpp
rename to GUI/View/Instrument/OffspecBeamEditor.cpp
index 1c1706567de..a11c660f652 100644
--- a/GUI/View/Instrument/OffSpecularBeamEditor.cpp
+++ b/GUI/View/Instrument/OffspecBeamEditor.cpp
@@ -2,7 +2,7 @@
 //
 //  BornAgain: simulate and fit reflection and scattering
 //
-//! @file      GUI/View/Instrument/OffSpecularBeamEditor.cpp
+//! @file      GUI/View/Instrument/OffspecBeamEditor.cpp
 //! @brief     Implements class OffSpecularBeamEditor
 //!
 //! @homepage  http://www.bornagainproject.org
@@ -12,7 +12,7 @@
 //
 //  ************************************************************************************************
 
-#include "GUI/View/Instrument/OffSpecularBeamEditor.h"
+#include "GUI/View/Instrument/OffspecBeamEditor.h"
 #include "GUI/Model/Descriptor/DoubleDescriptor.h"
 #include "GUI/Model/Device/BeamAngleItems.h"
 #include "GUI/Model/Device/BeamWavelengthItem.h"
diff --git a/GUI/View/Instrument/OffSpecularBeamEditor.h b/GUI/View/Instrument/OffspecBeamEditor.h
similarity index 78%
rename from GUI/View/Instrument/OffSpecularBeamEditor.h
rename to GUI/View/Instrument/OffspecBeamEditor.h
index 5d805e55770..81a30f57cb1 100644
--- a/GUI/View/Instrument/OffSpecularBeamEditor.h
+++ b/GUI/View/Instrument/OffspecBeamEditor.h
@@ -2,7 +2,7 @@
 //
 //  BornAgain: simulate and fit reflection and scattering
 //
-//! @file      GUI/View/Instrument/OffSpecularBeamEditor.h
+//! @file      GUI/View/Instrument/OffspecBeamEditor.h
 //! @brief     Defines class OffSpecularBeamEditor
 //!
 //! @homepage  http://www.bornagainproject.org
@@ -12,8 +12,8 @@
 //
 //  ************************************************************************************************
 
-#ifndef BORNAGAIN_GUI_VIEW_INSTRUMENT_OFFSPECULARBEAMEDITOR_H
-#define BORNAGAIN_GUI_VIEW_INSTRUMENT_OFFSPECULARBEAMEDITOR_H
+#ifndef BORNAGAIN_GUI_VIEW_INSTRUMENT_OFFSPECBEAMEDITOR_H
+#define BORNAGAIN_GUI_VIEW_INSTRUMENT_OFFSPECBEAMEDITOR_H
 
 #include <QGroupBox>
 
@@ -31,4 +31,4 @@ signals:
     void dataChanged();
 };
 
-#endif // BORNAGAIN_GUI_VIEW_INSTRUMENT_OFFSPECULARBEAMEDITOR_H
+#endif // BORNAGAIN_GUI_VIEW_INSTRUMENT_OFFSPECBEAMEDITOR_H
diff --git a/GUI/View/Instrument/OffSpecularInstrumentEditor.cpp b/GUI/View/Instrument/OffspecInstrumentEditor.cpp
similarity index 90%
rename from GUI/View/Instrument/OffSpecularInstrumentEditor.cpp
rename to GUI/View/Instrument/OffspecInstrumentEditor.cpp
index b9fff6aadf8..df899ccde78 100644
--- a/GUI/View/Instrument/OffSpecularInstrumentEditor.cpp
+++ b/GUI/View/Instrument/OffspecInstrumentEditor.cpp
@@ -2,7 +2,7 @@
 //
 //  BornAgain: simulate and fit reflection and scattering
 //
-//! @file      GUI/View/Instrument/OffSpecularInstrumentEditor.cpp
+//! @file      GUI/View/Instrument/OffspecInstrumentEditor.cpp
 //! @brief     Implements class OffSpecularInstrumentEditor
 //!
 //! @homepage  http://www.bornagainproject.org
@@ -12,10 +12,10 @@
 //
 //  ************************************************************************************************
 
-#include "GUI/View/Instrument/OffSpecularInstrumentEditor.h"
+#include "GUI/View/Instrument/OffspecInstrumentEditor.h"
 #include "GUI/Model/Device/InstrumentItems.h"
 #include "GUI/View/Instrument/DetectorEditor.h"
-#include "GUI/View/Instrument/OffSpecularBeamEditor.h"
+#include "GUI/View/Instrument/OffspecBeamEditor.h"
 #include "GUI/View/Instrument/PolarizationAnalysisEditor.h"
 
 #include <QVBoxLayout>
diff --git a/GUI/View/Instrument/OffSpecularInstrumentEditor.h b/GUI/View/Instrument/OffspecInstrumentEditor.h
similarity index 75%
rename from GUI/View/Instrument/OffSpecularInstrumentEditor.h
rename to GUI/View/Instrument/OffspecInstrumentEditor.h
index 79c89a3ef8c..35a6bf73ff8 100644
--- a/GUI/View/Instrument/OffSpecularInstrumentEditor.h
+++ b/GUI/View/Instrument/OffspecInstrumentEditor.h
@@ -2,7 +2,7 @@
 //
 //  BornAgain: simulate and fit reflection and scattering
 //
-//! @file      GUI/View/Instrument/OffSpecularInstrumentEditor.h
+//! @file      GUI/View/Instrument/OffspecInstrumentEditor.h
 //! @brief     Defines class OffSpecularInstrumentEditor
 //!
 //! @homepage  http://www.bornagainproject.org
@@ -12,8 +12,8 @@
 //
 //  ************************************************************************************************
 
-#ifndef BORNAGAIN_GUI_VIEW_INSTRUMENT_OFFSPECULARINSTRUMENTEDITOR_H
-#define BORNAGAIN_GUI_VIEW_INSTRUMENT_OFFSPECULARINSTRUMENTEDITOR_H
+#ifndef BORNAGAIN_GUI_VIEW_INSTRUMENT_OFFSPECINSTRUMENTEDITOR_H
+#define BORNAGAIN_GUI_VIEW_INSTRUMENT_OFFSPECINSTRUMENTEDITOR_H
 
 #include <QWidget>
 
@@ -29,4 +29,4 @@ signals:
     void dataChanged();
 };
 
-#endif // BORNAGAIN_GUI_VIEW_INSTRUMENT_OFFSPECULARINSTRUMENTEDITOR_H
+#endif // BORNAGAIN_GUI_VIEW_INSTRUMENT_OFFSPECINSTRUMENTEDITOR_H
diff --git a/Sim/Simulation/OffSpecularSimulation.cpp b/Sim/Simulation/OffspecSimulation.cpp
similarity index 98%
rename from Sim/Simulation/OffSpecularSimulation.cpp
rename to Sim/Simulation/OffspecSimulation.cpp
index 41a2e46ed9c..5d0fbcae583 100644
--- a/Sim/Simulation/OffSpecularSimulation.cpp
+++ b/Sim/Simulation/OffspecSimulation.cpp
@@ -2,7 +2,7 @@
 //
 //  BornAgain: simulate and fit reflection and scattering
 //
-//! @file      Sim/Simulation/OffSpecularSimulation.cpp
+//! @file      Sim/Simulation/OffspecSimulation.cpp
 //! @brief     Implements class OffSpecularSimulation.
 //!
 //! @homepage  http://www.bornagainproject.org
@@ -12,7 +12,7 @@
 //
 //  ************************************************************************************************
 
-#include "Sim/Simulation/OffSpecularSimulation.h"
+#include "Sim/Simulation/OffspecSimulation.h"
 #include "Base/Axis/Bin.h"
 #include "Base/Pixel/RectangularPixel.h"
 #include "Base/Util/Assert.h"
diff --git a/Sim/Simulation/OffSpecularSimulation.h b/Sim/Simulation/OffspecSimulation.h
similarity index 91%
rename from Sim/Simulation/OffSpecularSimulation.h
rename to Sim/Simulation/OffspecSimulation.h
index 11c6cdc2342..6f9513029db 100644
--- a/Sim/Simulation/OffSpecularSimulation.h
+++ b/Sim/Simulation/OffspecSimulation.h
@@ -2,7 +2,7 @@
 //
 //  BornAgain: simulate and fit reflection and scattering
 //
-//! @file      Sim/Simulation/OffSpecularSimulation.h
+//! @file      Sim/Simulation/OffspecSimulation.h
 //! @brief     Defines class OffSpecularSimulation.
 //!
 //! @homepage  http://www.bornagainproject.org
@@ -12,8 +12,8 @@
 //
 //  ************************************************************************************************
 
-#ifndef BORNAGAIN_SIM_SIMULATION_OFFSPECULARSIMULATION_H
-#define BORNAGAIN_SIM_SIMULATION_OFFSPECULARSIMULATION_H
+#ifndef BORNAGAIN_SIM_SIMULATION_OFFSPECSIMULATION_H
+#define BORNAGAIN_SIM_SIMULATION_OFFSPECSIMULATION_H
 
 #include "Sim/Simulation/ISimulation2D.h"
 
@@ -80,4 +80,4 @@ private:
 #endif
 };
 
-#endif // BORNAGAIN_SIM_SIMULATION_OFFSPECULARSIMULATION_H
+#endif // BORNAGAIN_SIM_SIMULATION_OFFSPECSIMULATION_H
diff --git a/Sim/Simulation/includeSimulations.h b/Sim/Simulation/includeSimulations.h
index 14f80983e19..56364f0bda6 100644
--- a/Sim/Simulation/includeSimulations.h
+++ b/Sim/Simulation/includeSimulations.h
@@ -16,7 +16,7 @@
 #define BORNAGAIN_SIM_SIMULATION_INCLUDESIMULATIONS_H
 
 #include "Sim/Simulation/DepthProbeSimulation.h"
-#include "Sim/Simulation/OffSpecularSimulation.h"
+#include "Sim/Simulation/OffspecSimulation.h"
 #include "Sim/Simulation/ScatteringSimulation.h"
 #include "Sim/Simulation/SpecularSimulation.h"
 
diff --git a/Tests/Functional/Core/Fitting/FitTests.cpp b/Tests/Functional/Core/Fitting/FitTests.cpp
index 195c97a8de2..d481085f3f8 100644
--- a/Tests/Functional/Core/Fitting/FitTests.cpp
+++ b/Tests/Functional/Core/Fitting/FitTests.cpp
@@ -20,7 +20,7 @@
 #include "Sample/Multilayer/MultiLayer.h"
 #include "Sample/StandardSamples/ExemplarySamples.h"
 #include "Sim/Fitting/FitObjective.h"
-#include "Sim/Simulation/OffSpecularSimulation.h"
+#include "Sim/Simulation/OffspecSimulation.h"
 #include "Sim/Simulation/ScatteringSimulation.h"
 #include "Sim/Simulation/SpecularSimulation.h"
 #include "Tests/Functional/Core/Fitting/SimfitTestPlan.h"
diff --git a/Tests/Unit/Device/OffSpecularConverterTest.cpp b/Tests/Unit/Device/OffspecConverterTest.cpp
similarity index 100%
rename from Tests/Unit/Device/OffSpecularConverterTest.cpp
rename to Tests/Unit/Device/OffspecConverterTest.cpp
diff --git a/Wrap/Swig/libBornAgainSim.i b/Wrap/Swig/libBornAgainSim.i
index 73199e55f24..d7ee1a55f85 100644
--- a/Wrap/Swig/libBornAgainSim.i
+++ b/Wrap/Swig/libBornAgainSim.i
@@ -72,7 +72,7 @@
 #include "Sim/Scan/ScanResolution.h"
 #include "Sim/Simulation/DepthProbeSimulation.h"
 #include "Sim/Simulation/ScatteringSimulation.h"
-#include "Sim/Simulation/OffSpecularSimulation.h"
+#include "Sim/Simulation/OffspecSimulation.h"
 #include "Sim/Simulation/SpecularSimulation.h"
 %}
 
@@ -109,7 +109,7 @@
 %include "Sim/Simulation/ScatteringSimulation.h"
 %include "Sim/Simulation/DepthProbeSimulation.h"
 %include "Sim/Simulation/SpecularSimulation.h"
-%include "Sim/Simulation/OffSpecularSimulation.h"
+%include "Sim/Simulation/OffspecSimulation.h"
 
 %include "Sim/Background/IBackground.h"
 %include "Sim/Background/ConstantBackground.h"
-- 
GitLab


From bade13403a59af5df0644d82d41e1c57c706bfa0 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Tue, 24 May 2022 11:57:03 +0200
Subject: [PATCH 61/63] ditto in code

---
 Device/Coord/AxisNames.cpp                    |   4 +-
 Device/Coord/AxisNames.h                      |   4 +-
 Device/Coord/CoordSystem2D.cpp                |  17 +-
 Device/Coord/CoordSystem2D.h                  |   8 +-
 Device/Detector/RectangularDetector.cpp       |   2 +-
 Device/Detector/SphericalDetector.cpp         |   2 +-
 Examples/varia/OffSpecularSimulation.py       |   4 +-
 GUI/Model/CatDevice/InstrumentItemCatalog.cpp |  12 +-
 GUI/Model/CatDevice/InstrumentItemCatalog.h   |   2 +-
 GUI/Model/Device/InstrumentItems.cpp          |  26 +-
 GUI/Model/Device/InstrumentItems.h            |   9 +-
 GUI/Model/Model/JobFunctions.cpp              |   2 +-
 GUI/Model/Model/ParameterTreeUtils.cpp        |   2 +-
 GUI/Model/Project/ProjectDocument.h           |   4 +-
 GUI/Model/To/DomainSimulationBuilder.cpp      |  16 +-
 GUI/View/FromDomain/FromDomain.cpp            |   4 +-
 GUI/View/FromDomain/FromDomain.h              |   4 +-
 GUI/View/FromDomain/GUIObjectBuilder.cpp      |  15 +-
 GUI/View/Import/ImportDataView.cpp            |   2 +-
 GUI/View/Import/RealDataSelectorWidget.cpp    |   2 +-
 .../Instrument/InstrumentLibraryEditor.cpp    |  12 +-
 GUI/View/Instrument/InstrumentLibraryEditor.h |   2 +-
 GUI/View/Instrument/InstrumentListModel.cpp   |  16 +-
 GUI/View/Instrument/InstrumentListModel.h     |   4 +-
 GUI/View/Instrument/InstrumentListView.cpp    |  27 +-
 GUI/View/Instrument/InstrumentListView.h      |   4 +-
 GUI/View/Instrument/InstrumentView.cpp        |   6 +-
 GUI/View/Instrument/InstrumentsTreeModel.cpp  |  16 +-
 GUI/View/Instrument/InstrumentsTreeModel.h    |   4 +-
 GUI/View/Instrument/OffspecBeamEditor.cpp     |  10 +-
 GUI/View/Instrument/OffspecBeamEditor.h       |  10 +-
 .../Instrument/OffspecInstrumentEditor.cpp    |  15 +-
 GUI/View/Instrument/OffspecInstrumentEditor.h |   8 +-
 GUI/View/Toplevel/ProjectSettingsView.cpp     |   8 +-
 GUI/View/Toplevel/ProjectSettingsView.ui      | 732 +++++++++---------
 Sim/Export/SimulationToPython.cpp             |  12 +-
 Sim/Simulation/ISimulation2D.h                |   2 +-
 Sim/Simulation/OffspecSimulation.cpp          |  39 +-
 Sim/Simulation/OffspecSimulation.h            |  12 +-
 Sim/Simulation/SpecularSimulation.cpp         |   2 +-
 Tests/Functional/Core/Fitting/FitTests.cpp    |   4 +-
 Tests/Functional/Suite/MakeSimulations.cpp    |   5 +-
 Tests/Functional/Suite/MakeSimulations.h      |   4 +-
 Tests/Functional/Suite/TestSuite.h            |   6 +-
 ...sonator.int.gz => OffspecResonator.int.gz} | Bin
 Tests/Unit/Device/OffspecConverterTest.cpp    |  20 +-
 Tests/Unit/GUI/TestInstrumentItems.cpp        |   2 +-
 Tests/Unit/GUI/TestSessionXML.cpp             |   6 +-
 Wrap/Python/ba_plot.py                        |   2 +-
 auto/Wrap/doxygenDevice.i                     |  10 +-
 auto/Wrap/doxygenSim.i                        |  28 +-
 auto/Wrap/libBornAgainSim.py                  |  44 +-
 auto/Wrap/libBornAgainSim_wrap.cpp            | 186 ++---
 53 files changed, 695 insertions(+), 704 deletions(-)
 rename Tests/ReferenceData/Suite/{OffSpecularResonator.int.gz => OffspecResonator.int.gz} (100%)

diff --git a/Device/Coord/AxisNames.cpp b/Device/Coord/AxisNames.cpp
index c1b86808b4e..0adab59fe7e 100644
--- a/Device/Coord/AxisNames.cpp
+++ b/Device/Coord/AxisNames.cpp
@@ -43,11 +43,11 @@ BA_DEVICE_API_ const std::map<Coords, std::string> rectangularAxis1 = {
 
 // For off-specular simulations (both spherical and rectangular detectors)
 // Currently 'mm' is not supported for the y-axis
-BA_DEVICE_API_ const std::map<Coords, std::string> offSpecularAxis0 = {
+BA_DEVICE_API_ const std::map<Coords, std::string> offspecAxis0 = {
     {Coords::NBINS, "X [nbins]"},
     {Coords::RADIANS, "alpha_i [rad]"},
     {Coords::DEGREES, "alpha_i [deg]"}};
-BA_DEVICE_API_ const std::map<Coords, std::string> offSpecularAxis1 = {
+BA_DEVICE_API_ const std::map<Coords, std::string> offspecAxis1 = {
     {Coords::NBINS, "Y [nbins]"},
     {Coords::RADIANS, "alpha_f [rad]"},
     {Coords::DEGREES, "alpha_f [deg]"}};
diff --git a/Device/Coord/AxisNames.h b/Device/Coord/AxisNames.h
index 70659c1cc9e..66d5405819e 100644
--- a/Device/Coord/AxisNames.h
+++ b/Device/Coord/AxisNames.h
@@ -39,8 +39,8 @@ extern BA_DEVICE_API_ const std::map<Coords, std::string> sphericalAxis0;
 extern BA_DEVICE_API_ const std::map<Coords, std::string> sphericalAxis1;
 extern BA_DEVICE_API_ const std::map<Coords, std::string> rectangularAxis0;
 extern BA_DEVICE_API_ const std::map<Coords, std::string> rectangularAxis1;
-extern BA_DEVICE_API_ const std::map<Coords, std::string> offSpecularAxis0;
-extern BA_DEVICE_API_ const std::map<Coords, std::string> offSpecularAxis1;
+extern BA_DEVICE_API_ const std::map<Coords, std::string> offspecAxis0;
+extern BA_DEVICE_API_ const std::map<Coords, std::string> offspecAxis1;
 extern BA_DEVICE_API_ const std::map<Coords, std::string> specAxis;
 extern BA_DEVICE_API_ const std::map<Coords, std::string> specAxisQ;
 extern BA_DEVICE_API_ const std::map<Coords, std::string> sampleDepthAxis;
diff --git a/Device/Coord/CoordSystem2D.cpp b/Device/Coord/CoordSystem2D.cpp
index 2720200418c..7f00ca9bb1b 100644
--- a/Device/Coord/CoordSystem2D.cpp
+++ b/Device/Coord/CoordSystem2D.cpp
@@ -258,26 +258,25 @@ std::vector<std::map<Coords, std::string>> ImageCoords::createNameMaps() const
 }
 
 //  ************************************************************************************************
-//  class OffSpecularCoordinates
+//  class OffspecCoordinates
 //  ************************************************************************************************
 
-OffSpecularCoordinates::OffSpecularCoordinates(const OwningVector<IAxis>& axes,
-                                               const Direction& direction)
+OffspecCoordinates::OffspecCoordinates(const OwningVector<IAxis>& axes, const Direction& direction)
     : CoordSystem2D(axes, direction)
 {
 }
 
-OffSpecularCoordinates::OffSpecularCoordinates(const OffSpecularCoordinates& other)
+OffspecCoordinates::OffspecCoordinates(const OffspecCoordinates& other)
     : CoordSystem2D(other)
 {
 }
 
-OffSpecularCoordinates* OffSpecularCoordinates::clone() const
+OffspecCoordinates* OffspecCoordinates::clone() const
 {
-    return new OffSpecularCoordinates(*this);
+    return new OffspecCoordinates(*this);
 }
 
-double OffSpecularCoordinates::calculateValue(size_t, Coords units, double value) const
+double OffspecCoordinates::calculateValue(size_t, Coords units, double value) const
 {
     switch (units) {
     case Coords::RADIANS:
@@ -289,9 +288,9 @@ double OffSpecularCoordinates::calculateValue(size_t, Coords units, double value
     }
 }
 
-std::vector<std::map<Coords, std::string>> OffSpecularCoordinates::createNameMaps() const
+std::vector<std::map<Coords, std::string>> OffspecCoordinates::createNameMaps() const
 {
-    return {DataUtils::AxisNames::offSpecularAxis0, DataUtils::AxisNames::offSpecularAxis1};
+    return {DataUtils::AxisNames::offspecAxis0, DataUtils::AxisNames::offspecAxis1};
 }
 
 //  ************************************************************************************************
diff --git a/Device/Coord/CoordSystem2D.h b/Device/Coord/CoordSystem2D.h
index 48c892770c4..94e1d176425 100644
--- a/Device/Coord/CoordSystem2D.h
+++ b/Device/Coord/CoordSystem2D.h
@@ -112,16 +112,16 @@ private:
 //! with a spherical detector
 //! Its default units are radians for both axes
 
-class OffSpecularCoordinates : public CoordSystem2D {
+class OffspecCoordinates : public CoordSystem2D {
 public:
-    OffSpecularCoordinates(const OwningVector<IAxis>& axes, const Direction& direction);
+    OffspecCoordinates(const OwningVector<IAxis>& axes, const Direction& direction);
 
-    OffSpecularCoordinates* clone() const override;
+    OffspecCoordinates* clone() const override;
 
     Coords defaultUnits() const override { return Coords::DEGREES; }
 
 private:
-    OffSpecularCoordinates(const OffSpecularCoordinates& other); //!< used by clone()
+    OffspecCoordinates(const OffspecCoordinates& other); //!< used by clone()
     double calculateValue(size_t i_axis, Coords units, double value) const override;
     std::vector<std::map<Coords, std::string>> createNameMaps() const override;
 };
diff --git a/Device/Detector/RectangularDetector.cpp b/Device/Detector/RectangularDetector.cpp
index 137d988449d..10226f8b97f 100644
--- a/Device/Detector/RectangularDetector.cpp
+++ b/Device/Detector/RectangularDetector.cpp
@@ -284,7 +284,7 @@ ICoordSystem* RectangularDetector::offspecCoords(IAxis* beamAxis,
     IAxis* alpha_f_axis = det_pixel->createAxis(yAxis.size());
 
     OwningVector<IAxis> axes2({beamAxis, alpha_f_axis});
-    return new OffSpecularCoordinates(axes2, beamDirection);
+    return new OffspecCoordinates(axes2, beamDirection);
 }
 
 CoordSystem2D* RectangularDetector::scatteringCoords(const Beam& beam) const
diff --git a/Device/Detector/SphericalDetector.cpp b/Device/Detector/SphericalDetector.cpp
index 705ba8af708..b08e19471f6 100644
--- a/Device/Detector/SphericalDetector.cpp
+++ b/Device/Detector/SphericalDetector.cpp
@@ -87,7 +87,7 @@ ICoordSystem* SphericalDetector::offspecCoords(IAxis* beamAxis,
     const IAxis& yAxis = *axes[1];
 
     OwningVector<IAxis> axes2({beamAxis, yAxis.clone()});
-    return new OffSpecularCoordinates(axes2, beamDirection);
+    return new OffspecCoordinates(axes2, beamDirection);
 }
 
 CoordSystem2D* SphericalDetector::scatteringCoords(const Beam& beam) const
diff --git a/Examples/varia/OffSpecularSimulation.py b/Examples/varia/OffSpecularSimulation.py
index dc714a72e04..e96e8041666 100755
--- a/Examples/varia/OffSpecularSimulation.py
+++ b/Examples/varia/OffSpecularSimulation.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 """
-Long boxes at 1D lattice, ba.OffSpecular simulation
+Long boxes at 1D lattice, ba.Offspec simulation
 """
 import bornagain as ba
 from bornagain import ba_plot as bp, deg, nm
@@ -58,7 +58,7 @@ def get_simulation(sample):
     Returns an off-specular simulation with beam and detector defined.
     """
     n = bp.simargs['n']
-    simulation = ba.OffSpecularSimulation()
+    simulation = ba.OffspecSimulation()
     simulation.setDetectorParameters(20, phi_f_min*deg, phi_f_max*deg, n,
                                      alpha_f_min*deg, alpha_f_max*deg)
     # define the beam with alpha_i varied between alpha_i_min and alpha_i_max
diff --git a/GUI/Model/CatDevice/InstrumentItemCatalog.cpp b/GUI/Model/CatDevice/InstrumentItemCatalog.cpp
index 60c481d2409..6c25b326146 100644
--- a/GUI/Model/CatDevice/InstrumentItemCatalog.cpp
+++ b/GUI/Model/CatDevice/InstrumentItemCatalog.cpp
@@ -21,8 +21,8 @@ InstrumentItem* InstrumentItemCatalog::create(Type type)
     switch (type) {
     case Type::GISAS:
         return new GISASInstrumentItem();
-    case Type::OffSpec:
-        return new OffSpecularInstrumentItem();
+    case Type::Offspec:
+        return new OffspecInstrumentItem();
     case Type::Specular:
         return new SpecularInstrumentItem();
     case Type::DepthProbe:
@@ -33,7 +33,7 @@ InstrumentItem* InstrumentItemCatalog::create(Type type)
 
 QVector<InstrumentItemCatalog::Type> InstrumentItemCatalog::types()
 {
-    return {Type::GISAS, Type::OffSpec, Type::Specular, Type::DepthProbe};
+    return {Type::GISAS, Type::Offspec, Type::Specular, Type::DepthProbe};
 }
 
 InstrumentItemCatalog::UiInfo InstrumentItemCatalog::uiInfo(Type type)
@@ -41,7 +41,7 @@ InstrumentItemCatalog::UiInfo InstrumentItemCatalog::uiInfo(Type type)
     switch (type) {
     case Type::GISAS:
         return {"GISAS", ""};
-    case Type::OffSpec:
+    case Type::Offspec:
         return {"Off specular", ""};
     case Type::Specular:
         return {"Specular", ""};
@@ -55,8 +55,8 @@ InstrumentItemCatalog::Type InstrumentItemCatalog::type(const InstrumentItem* it
 {
     if (dynamic_cast<const GISASInstrumentItem*>(item))
         return Type::GISAS;
-    if (dynamic_cast<const OffSpecularInstrumentItem*>(item))
-        return Type::OffSpec;
+    if (dynamic_cast<const OffspecInstrumentItem*>(item))
+        return Type::Offspec;
     if (dynamic_cast<const SpecularInstrumentItem*>(item))
         return Type::Specular;
     if (dynamic_cast<const DepthProbeInstrumentItem*>(item))
diff --git a/GUI/Model/CatDevice/InstrumentItemCatalog.h b/GUI/Model/CatDevice/InstrumentItemCatalog.h
index 09920cdf828..d7410893ccf 100644
--- a/GUI/Model/CatDevice/InstrumentItemCatalog.h
+++ b/GUI/Model/CatDevice/InstrumentItemCatalog.h
@@ -25,7 +25,7 @@ public:
     using CatalogedType = InstrumentItem;
 
     // Do not change the numbering! It is serialized!
-    enum class Type : uint8_t { GISAS = 0, OffSpec = 1, Specular = 2, DepthProbe = 3 };
+    enum class Type : uint8_t { GISAS = 0, Offspec = 1, Specular = 2, DepthProbe = 3 };
 
     struct UiInfo {
         QString menuEntry;
diff --git a/GUI/Model/Device/InstrumentItems.cpp b/GUI/Model/Device/InstrumentItems.cpp
index 1417cf73251..d218b6a9a0f 100644
--- a/GUI/Model/Device/InstrumentItems.cpp
+++ b/GUI/Model/Device/InstrumentItems.cpp
@@ -380,14 +380,14 @@ Instrument2DItem::createScatteringSimulation(const MultiLayer& sample) const
     return result;
 }
 
-std::unique_ptr<OffSpecularSimulation>
-Instrument2DItem::createOffSpecularSimulation(const MultiLayer& sample) const
+std::unique_ptr<OffspecSimulation>
+Instrument2DItem::createOffspecSimulation(const MultiLayer& sample) const
 {
     auto beam = beamItem()->createBeam();
     auto detector = detectorItem()->createDetector();
     detector->setDetectorNormal(beam->direction().zReflected());
 
-    auto result = std::make_unique<OffSpecularSimulation>(*beam, sample, *detector);
+    auto result = std::make_unique<OffspecSimulation>(*beam, sample, *detector);
     result->setPolarization(m_polarization);
     result->setAnalyzer(m_analyzerDirection, m_analyzerEfficiency, m_analyzerTotalTransmission);
     return result;
@@ -433,10 +433,10 @@ ICoordSystem* GISASInstrumentItem::createCoordSystem() const
 }
 
 //  ************************************************************************************************
-//  class OffSpecularInstrumentItem
+//  class OffspecInstrumentItem
 //  ************************************************************************************************
 
-OffSpecularInstrumentItem::OffSpecularInstrumentItem()
+OffspecInstrumentItem::OffspecInstrumentItem()
 {
     m_alphaAxis.initNbins("Nbins", "Number of points in scan");
     m_alphaAxis.initMin("Min", "Starting value", 0.0, Unit::degree, RealLimits::limited(-90, 90));
@@ -446,43 +446,43 @@ OffSpecularInstrumentItem::OffSpecularInstrumentItem()
     beam_item->setInclinationAngleGetter([=]() { return m_alphaAxis.min(); });
 }
 
-void OffSpecularInstrumentItem::serialize(Streamer& s)
+void OffspecInstrumentItem::serialize(Streamer& s)
 {
     s.assertVersion(0);
     Serialize::rwBaseClass<Instrument2DItem>(s, "Instrument2DItem", this);
     m_alphaAxis.rwAxisProperty(s, "alphaAxis");
 }
 
-std::vector<int> OffSpecularInstrumentItem::shape() const
+std::vector<int> OffspecInstrumentItem::shape() const
 {
     return {(int)m_alphaAxis.nbins(), detectorItem()->ySize()};
 }
 
-void OffSpecularInstrumentItem::updateToRealData(const RealDataItem* dataItem)
+void OffspecInstrumentItem::updateToRealData(const RealDataItem* dataItem)
 {
     if (!dataItem)
         return;
 
     const auto data_shape = dataItem->shape();
     if (shape().size() != data_shape.size())
-        throw Error("Error in OffSpecularInstrumentItem::updateToRealData: The type of "
+        throw Error("Error in OffspecInstrumentItem::updateToRealData: The type of "
                     "instrument is incompatible with passed data shape.");
 
     m_alphaAxis.setNbins(data_shape[0]);
     detectorItem()->setYSize(data_shape[1]);
 }
 
-QString OffSpecularInstrumentItem::defaultName() const
+QString OffspecInstrumentItem::defaultName() const
 {
-    return "OffSpecular";
+    return "Offspec";
 }
 
-QString OffSpecularInstrumentItem::instrumentType() const
+QString OffspecInstrumentItem::instrumentType() const
 {
     return "Off specular";
 }
 
-ICoordSystem* OffSpecularInstrumentItem::createCoordSystem() const
+ICoordSystem* OffspecInstrumentItem::createCoordSystem() const
 {
     IAxis* alphaAxis =
         new FixedBinAxis("alpha", m_alphaAxis.nbins(), m_alphaAxis.min() * Units::deg,
diff --git a/GUI/Model/Device/InstrumentItems.h b/GUI/Model/Device/InstrumentItems.h
index 053ab145c9a..1fbdee79ad8 100644
--- a/GUI/Model/Device/InstrumentItems.h
+++ b/GUI/Model/Device/InstrumentItems.h
@@ -33,7 +33,7 @@ class Instrument;
 class MaskContainerItem;
 class MultiLayer;
 class RealDataItem;
-class OffSpecularSimulation;
+class OffspecSimulation;
 class ScatteringSimulation;
 
 //! Abstract base class for instrument-specific item classes.
@@ -161,8 +161,7 @@ public:
     std::unique_ptr<Instrument> createInstrument() const;
     std::unique_ptr<ScatteringSimulation>
     createScatteringSimulation(const MultiLayer& sample) const;
-    std::unique_ptr<OffSpecularSimulation>
-    createOffSpecularSimulation(const MultiLayer& sample) const;
+    std::unique_ptr<OffspecSimulation> createOffspecSimulation(const MultiLayer& sample) const;
 
     static bool isDetectorPropertyName(const QString& name);
 
@@ -184,9 +183,9 @@ public:
 };
 
 
-class OffSpecularInstrumentItem : public Instrument2DItem {
+class OffspecInstrumentItem : public Instrument2DItem {
 public:
-    OffSpecularInstrumentItem();
+    OffspecInstrumentItem();
     void serialize(Streamer& s) override;
 
     std::vector<int> shape() const override;
diff --git a/GUI/Model/Model/JobFunctions.cpp b/GUI/Model/Model/JobFunctions.cpp
index 5a6b41659bd..24cffe014be 100644
--- a/GUI/Model/Model/JobFunctions.cpp
+++ b/GUI/Model/Model/JobFunctions.cpp
@@ -128,7 +128,7 @@ void GUI::Model::JobFunctions::setupJobItemOutput(JobItem* jobItem)
 {
     const bool isSpecularInstrument = jobItem->instrumentItem()->is<SpecularInstrumentItem>();
     const bool isIntensityInstrument = jobItem->instrumentItem()->is<GISASInstrumentItem>()
-                                       || jobItem->instrumentItem()->is<OffSpecularInstrumentItem>()
+                                       || jobItem->instrumentItem()->is<OffspecInstrumentItem>()
                                        || jobItem->instrumentItem()->is<DepthProbeInstrumentItem>();
 
     ASSERT(isSpecularInstrument || isIntensityInstrument);
diff --git a/GUI/Model/Model/ParameterTreeUtils.cpp b/GUI/Model/Model/ParameterTreeUtils.cpp
index 765dc4cae36..da6a72c72c8 100644
--- a/GUI/Model/Model/ParameterTreeUtils.cpp
+++ b/GUI/Model/Model/ParameterTreeUtils.cpp
@@ -335,7 +335,7 @@ void ParameterTreeBuilder::addInstrument()
                             false);
         addPolarization(label, instrument);
         addBackground(label, instrument->backgroundItem());
-    } else if (auto* os = dynamic_cast<const OffSpecularInstrumentItem*>(instrument)) {
+    } else if (auto* os = dynamic_cast<const OffspecInstrumentItem*>(instrument)) {
         auto* beamLabel = new ParameterLabelItem("Beam", label);
         addParameterItem(beamLabel, beamItem->intensity());
         addBeamDistribution(beamLabel, beamItem->wavelengthItem(), "Wavelength");
diff --git a/GUI/Model/Project/ProjectDocument.h b/GUI/Model/Project/ProjectDocument.h
index 430e182dd7e..01123beca5c 100644
--- a/GUI/Model/Project/ProjectDocument.h
+++ b/GUI/Model/Project/ProjectDocument.h
@@ -49,10 +49,10 @@ public:
     enum Functionality {
         None = 0x0,
         Gisas = 0x1,
-        OffSpecular = 0x2,
+        Offspec = 0x2,
         Specular = 0x4,
         DepthProbe = 0x8,
-        All = Gisas | OffSpecular | Specular | DepthProbe
+        All = Gisas | Offspec | Specular | DepthProbe
     };
     Q_DECLARE_FLAGS(Functionalities, Functionality)
     Q_FLAG(Functionalities)
diff --git a/GUI/Model/To/DomainSimulationBuilder.cpp b/GUI/Model/To/DomainSimulationBuilder.cpp
index 3910d72b712..1f148e65616 100644
--- a/GUI/Model/To/DomainSimulationBuilder.cpp
+++ b/GUI/Model/To/DomainSimulationBuilder.cpp
@@ -132,13 +132,12 @@ createScatteringSimulation(std::unique_ptr<MultiLayer> sample,
     return result;
 }
 
-std::unique_ptr<OffSpecularSimulation>
-createOffSpecularSimulation(std::unique_ptr<MultiLayer> sample,
-                            const OffSpecularInstrumentItem* instrumentItem,
-                            const SimulationOptionsItem& optionsItem)
+std::unique_ptr<OffspecSimulation>
+createOffspecSimulation(std::unique_ptr<MultiLayer> sample,
+                        const OffspecInstrumentItem* instrumentItem,
+                        const SimulationOptionsItem& optionsItem)
 {
-    std::unique_ptr<OffSpecularSimulation> result(
-        instrumentItem->createOffSpecularSimulation(*sample));
+    std::unique_ptr<OffspecSimulation> result(instrumentItem->createOffspecSimulation(*sample));
 
     auto* beamItem = instrumentItem->beamItem();
     const auto axis = instrumentItem->alphaAxis().createAxis(Units::deg);
@@ -213,9 +212,8 @@ GUI::Model::DomainSimulationBuilder::createSimulation(const MultiLayerItem* samp
 
     if (const auto* gisasInstrument = dynamic_cast<const GISASInstrumentItem*>(instrumentItem))
         return createScatteringSimulation(std::move(P_sample), gisasInstrument, optionsItem);
-    if (const auto* offspecInstrument =
-            dynamic_cast<const OffSpecularInstrumentItem*>(instrumentItem))
-        return createOffSpecularSimulation(std::move(P_sample), offspecInstrument, optionsItem);
+    if (const auto* offspecInstrument = dynamic_cast<const OffspecInstrumentItem*>(instrumentItem))
+        return createOffspecSimulation(std::move(P_sample), offspecInstrument, optionsItem);
     if (const auto* specular_instrument =
             dynamic_cast<const SpecularInstrumentItem*>(instrumentItem))
         return createSpecularSimulation(std::move(P_sample), specular_instrument, optionsItem);
diff --git a/GUI/View/FromDomain/FromDomain.cpp b/GUI/View/FromDomain/FromDomain.cpp
index f7d451c7757..2c8c90b8abb 100644
--- a/GUI/View/FromDomain/FromDomain.cpp
+++ b/GUI/View/FromDomain/FromDomain.cpp
@@ -443,8 +443,8 @@ void GUI::Transform::FromDomain::setGISASBeamItem(BeamItem* beam_item,
     }
 }
 
-void GUI::Transform::FromDomain::setOffSpecularBeamItem(BeamItem* beam_item,
-                                                        const OffSpecularSimulation& simulation)
+void GUI::Transform::FromDomain::setOffspecBeamItem(BeamItem* beam_item,
+                                                    const OffspecSimulation& simulation)
 {
     const Beam& beam = simulation.beam();
 
diff --git a/GUI/View/FromDomain/FromDomain.h b/GUI/View/FromDomain/FromDomain.h
index dc73a664a8d..041bfbf4a62 100644
--- a/GUI/View/FromDomain/FromDomain.h
+++ b/GUI/View/FromDomain/FromDomain.h
@@ -56,7 +56,7 @@ class GISASInstrumentItem;
 class Instrument2DItem;
 class InstrumentItem;
 class ISimulation2D;
-class OffSpecularSimulation;
+class OffspecSimulation;
 class IAxis;
 class ItemWithParticles;
 class IRotation;
@@ -91,7 +91,7 @@ bool isValidRoughness(const LayerRoughness* roughness);
 
 void setGISASBeamItem(BeamItem* beam_item, const ScatteringSimulation& simulation);
 
-void setOffSpecularBeamItem(BeamItem* beam_item, const OffSpecularSimulation& simulation);
+void setOffspecBeamItem(BeamItem* beam_item, const OffspecSimulation& simulation);
 
 void setSpecularBeamItem(SpecularBeamItem* beam_item, const SpecularSimulation& simulation);
 
diff --git a/GUI/View/FromDomain/GUIObjectBuilder.cpp b/GUI/View/FromDomain/GUIObjectBuilder.cpp
index 7dc8faee771..58dae3fe8ef 100644
--- a/GUI/View/FromDomain/GUIObjectBuilder.cpp
+++ b/GUI/View/FromDomain/GUIObjectBuilder.cpp
@@ -37,13 +37,13 @@ GISASInstrumentItem* createGISASInstrumentItem(InstrumentItems* model,
     return result;
 }
 
-OffSpecularInstrumentItem* createOffSpecularInstrumentItem(InstrumentItems* model,
-                                                           const OffSpecularSimulation& simulation,
-                                                           const QString& name)
+OffspecInstrumentItem* createOffspecInstrumentItem(InstrumentItems* model,
+                                                   const OffspecSimulation& simulation,
+                                                   const QString& name)
 {
-    auto* result = model->addInstrument<OffSpecularInstrumentItem>();
+    auto* result = model->addInstrument<OffspecInstrumentItem>();
     result->setInstrumentName(name);
-    GUI::Transform::FromDomain::setOffSpecularBeamItem(result->beamItem(), simulation);
+    GUI::Transform::FromDomain::setOffspecBeamItem(result->beamItem(), simulation);
     GUI::Transform::FromDomain::updateDetector(result, simulation);
     GUI::Transform::FromDomain::setBackground(result, simulation);
 
@@ -81,9 +81,8 @@ void GUI::Transform::FromDomain::populateInstrumentItems(InstrumentItems* instru
 
     if (const auto* gisasSimulation = dynamic_cast<const ScatteringSimulation*>(&simulation))
         createGISASInstrumentItem(instrumentItems, *gisasSimulation, instrument_name);
-    else if (const auto* offSpecSimulation =
-                 dynamic_cast<const OffSpecularSimulation*>(&simulation))
-        createOffSpecularInstrumentItem(instrumentItems, *offSpecSimulation, instrument_name);
+    else if (const auto* offspecSimulation = dynamic_cast<const OffspecSimulation*>(&simulation))
+        createOffspecInstrumentItem(instrumentItems, *offspecSimulation, instrument_name);
     else if (const auto* spec_simulation = dynamic_cast<const SpecularSimulation*>(&simulation))
         createSpecularInstrumentItem(instrumentItems, *spec_simulation, instrument_name);
     else
diff --git a/GUI/View/Import/ImportDataView.cpp b/GUI/View/Import/ImportDataView.cpp
index 00ccf9a7d05..9905b5b4d73 100644
--- a/GUI/View/Import/ImportDataView.cpp
+++ b/GUI/View/Import/ImportDataView.cpp
@@ -81,6 +81,6 @@ void ImportDataView::updateFunctionalityNarrowing()
 
     m_selectorWidget->m_import2dDataAction->setVisible(
         m_document->functionalities().testFlag(ProjectDocument::Gisas)
-        || m_document->functionalities().testFlag(ProjectDocument::OffSpecular)
+        || m_document->functionalities().testFlag(ProjectDocument::Offspec)
         || m_document->functionalities().testFlag(ProjectDocument::DepthProbe));
 }
diff --git a/GUI/View/Import/RealDataSelectorWidget.cpp b/GUI/View/Import/RealDataSelectorWidget.cpp
index 4eb583dd117..1b831cfe0d6 100644
--- a/GUI/View/Import/RealDataSelectorWidget.cpp
+++ b/GUI/View/Import/RealDataSelectorWidget.cpp
@@ -355,7 +355,7 @@ void RealDataSelectorWidget::updateFunctionalities()
     if (m_document->functionalities().testFlag(ProjectDocument::Specular))
         visibleRanks << 1;
     if (m_document->functionalities().testFlag(ProjectDocument::Gisas)
-        || m_document->functionalities().testFlag(ProjectDocument::OffSpecular)
+        || m_document->functionalities().testFlag(ProjectDocument::Offspec)
         || m_document->functionalities().testFlag(ProjectDocument::DepthProbe))
         visibleRanks << 2;
 
diff --git a/GUI/View/Instrument/InstrumentLibraryEditor.cpp b/GUI/View/Instrument/InstrumentLibraryEditor.cpp
index ade8d6ee622..9de3e78e7a2 100644
--- a/GUI/View/Instrument/InstrumentLibraryEditor.cpp
+++ b/GUI/View/Instrument/InstrumentLibraryEditor.cpp
@@ -78,9 +78,9 @@ void InstrumentLibraryEditor::setGisasEnabled(bool b)
     m_treeModel->setTypeEnabled(InstrumentsTreeModel::Gisas, b);
 }
 
-void InstrumentLibraryEditor::setOffSpecEnabled(bool b)
+void InstrumentLibraryEditor::setOffspecEnabled(bool b)
 {
-    m_treeModel->setTypeEnabled(InstrumentsTreeModel::OffSpecular, b);
+    m_treeModel->setTypeEnabled(InstrumentsTreeModel::Offspec, b);
 }
 
 void InstrumentLibraryEditor::setSpecularEnabled(bool b)
@@ -225,9 +225,9 @@ void InstrumentLibraryEditor::createWidgetsForCurrentInstrument()
         connect(editor, &SpecularInstrumentEditor::dataChanged, this,
                 &InstrumentLibraryEditor::onInstrumentChangedByEditor);
         layout->addWidget(editor);
-    } else if (auto* os = dynamic_cast<OffSpecularInstrumentItem*>(currentInstrument)) {
-        auto* editor = new OffSpecularInstrumentEditor(m_ui->scrollArea, os);
-        connect(editor, &OffSpecularInstrumentEditor::dataChanged, this,
+    } else if (auto* os = dynamic_cast<OffspecInstrumentItem*>(currentInstrument)) {
+        auto* editor = new OffspecInstrumentEditor(m_ui->scrollArea, os);
+        connect(editor, &OffspecInstrumentEditor::dataChanged, this,
                 &InstrumentLibraryEditor::onInstrumentChangedByEditor);
         layout->addWidget(editor);
     } else if (auto* gisas = dynamic_cast<GISASInstrumentItem*>(currentInstrument)) {
@@ -303,7 +303,7 @@ QVariant InstrumentLibraryEditor::TreeModel::data(const QModelIndex& index, int
             switch (instrumentType(item)) {
             case Gisas:
                 return QIcon(":/images/gisas_instrument_new.svg");
-            case OffSpecular:
+            case Offspec:
                 return QIcon(":/images/offspec_instrument_new.svg");
             case Specular:
                 return QIcon(":/images/specular_instrument_new.svg");
diff --git a/GUI/View/Instrument/InstrumentLibraryEditor.h b/GUI/View/Instrument/InstrumentLibraryEditor.h
index e0bc72c2bc0..c13ac6a0ae5 100644
--- a/GUI/View/Instrument/InstrumentLibraryEditor.h
+++ b/GUI/View/Instrument/InstrumentLibraryEditor.h
@@ -33,7 +33,7 @@ public:
     ~InstrumentLibraryEditor() override;
 
     void setGisasEnabled(bool b);
-    void setOffSpecEnabled(bool b);
+    void setOffspecEnabled(bool b);
     void setSpecularEnabled(bool b);
     void setDepthProbeEnabled(bool b);
 
diff --git a/GUI/View/Instrument/InstrumentListModel.cpp b/GUI/View/Instrument/InstrumentListModel.cpp
index de34b4d301b..f8b5a79ae59 100644
--- a/GUI/View/Instrument/InstrumentListModel.cpp
+++ b/GUI/View/Instrument/InstrumentListModel.cpp
@@ -44,9 +44,9 @@ QString defaultInstrumentName<GISASInstrumentItem>()
 }
 
 template <>
-QString defaultInstrumentName<OffSpecularInstrumentItem>()
+QString defaultInstrumentName<OffspecInstrumentItem>()
 {
-    return "OffSpecular";
+    return "Offspec";
 }
 
 } // namespace
@@ -58,8 +58,8 @@ InstrumentListModel::InstrumentListModel(QObject* parent, InstrumentsEditControl
 {
     m_gisasIcon.addPixmap(QPixmap(":/images/gisas_instrument.svg"), QIcon::Selected);
     m_gisasIcon.addPixmap(QPixmap(":/images/gisas_instrument_shaded.svg"), QIcon::Normal);
-    m_offSpecularIcon.addPixmap(QPixmap(":/images/offspec_instrument.svg"), QIcon::Selected);
-    m_offSpecularIcon.addPixmap(QPixmap(":/images/offspec_instrument_shaded.svg"), QIcon::Normal);
+    m_offspecIcon.addPixmap(QPixmap(":/images/offspec_instrument.svg"), QIcon::Selected);
+    m_offspecIcon.addPixmap(QPixmap(":/images/offspec_instrument_shaded.svg"), QIcon::Normal);
     m_specularIcon.addPixmap(QPixmap(":/images/specular_instrument.svg"), QIcon::Selected);
     m_specularIcon.addPixmap(QPixmap(":/images/specular_instrument_shaded.svg"), QIcon::Normal);
     m_depthProbeIcon.addPixmap(QPixmap(":/images/depth_instrument.svg"), QIcon::Selected);
@@ -84,8 +84,8 @@ QVariant InstrumentListModel::data(const QModelIndex& index, int role) const
     if (role == Qt::DecorationRole) {
         if (dynamic_cast<const GISASInstrumentItem*>(item))
             return m_gisasIcon;
-        if (dynamic_cast<const OffSpecularInstrumentItem*>(item))
-            return m_offSpecularIcon;
+        if (dynamic_cast<const OffspecInstrumentItem*>(item))
+            return m_offspecIcon;
         if (dynamic_cast<const SpecularInstrumentItem*>(item))
             return m_specularIcon;
         if (dynamic_cast<const DepthProbeInstrumentItem*>(item))
@@ -115,9 +115,9 @@ QModelIndex InstrumentListModel::addNewGISASInstrument()
     return addNewInstrument<GISASInstrumentItem>();
 }
 
-QModelIndex InstrumentListModel::addNewOffSpecularInstrument()
+QModelIndex InstrumentListModel::addNewOffspecInstrument()
 {
-    return addNewInstrument<OffSpecularInstrumentItem>();
+    return addNewInstrument<OffspecInstrumentItem>();
 }
 
 QModelIndex InstrumentListModel::addNewSpecularInstrument()
diff --git a/GUI/View/Instrument/InstrumentListModel.h b/GUI/View/Instrument/InstrumentListModel.h
index acca1ba9198..f3483d1ecb4 100644
--- a/GUI/View/Instrument/InstrumentListModel.h
+++ b/GUI/View/Instrument/InstrumentListModel.h
@@ -38,7 +38,7 @@ public:
     InstrumentItem* instrumentForIndex(const QModelIndex& index) const;
 
     QModelIndex addNewGISASInstrument();
-    QModelIndex addNewOffSpecularInstrument();
+    QModelIndex addNewOffspecInstrument();
     QModelIndex addNewSpecularInstrument();
     QModelIndex addNewDepthProbeInstrument();
 
@@ -55,7 +55,7 @@ private:
 private:
     InstrumentsEditController* m_ec;
     QIcon m_gisasIcon;
-    QIcon m_offSpecularIcon;
+    QIcon m_offspecIcon;
     QIcon m_specularIcon;
     QIcon m_depthProbeIcon;
 };
diff --git a/GUI/View/Instrument/InstrumentListView.cpp b/GUI/View/Instrument/InstrumentListView.cpp
index 646a593dc45..610ac0bd1c9 100644
--- a/GUI/View/Instrument/InstrumentListView.cpp
+++ b/GUI/View/Instrument/InstrumentListView.cpp
@@ -61,12 +61,11 @@ InstrumentListView::InstrumentListView(ProjectDocument* document, QWidget* paren
     connect(m_newGisasAction, &QAction::triggered, this, &InstrumentListView::onNewGisas);
     addAction(m_newGisasAction);
 
-    m_newOffSpecularAction = new QAction("New off-specular", this);
-    m_newOffSpecularAction->setIcon(QIcon(":/images/shape-square-plus.svg"));
-    m_newOffSpecularAction->setToolTip("Add new off-specular instrument with default settings");
-    connect(m_newOffSpecularAction, &QAction::triggered, this,
-            &InstrumentListView::onNewOffSpecular);
-    addAction(m_newOffSpecularAction);
+    m_newOffspecAction = new QAction("New off-specular", this);
+    m_newOffspecAction->setIcon(QIcon(":/images/shape-square-plus.svg"));
+    m_newOffspecAction->setToolTip("Add new off-specular instrument with default settings");
+    connect(m_newOffspecAction, &QAction::triggered, this, &InstrumentListView::onNewOffspec);
+    addAction(m_newOffspecAction);
 
     m_newSpecularAction = new QAction("New specular", this);
     m_newSpecularAction->setIcon(QIcon(":/images/shape-square-plus.svg"));
@@ -140,9 +139,9 @@ QSize InstrumentListView::minimumSizeHint() const
 
 QList<QAction*> InstrumentListView::toolbarActions() const
 {
-    return {m_newGisasAction,       m_newOffSpecularAction, m_newSpecularAction,
-            m_newDepthProbeAction,  m_separatorAction1,     m_removeAction,
-            m_copyAction,           m_separatorAction2,     m_storeInLibraryAction,
+    return {m_newGisasAction,       m_newOffspecAction, m_newSpecularAction,
+            m_newDepthProbeAction,  m_separatorAction1, m_removeAction,
+            m_copyAction,           m_separatorAction2, m_storeInLibraryAction,
             m_loadFromLibraryAction};
 }
 
@@ -171,9 +170,9 @@ void InstrumentListView::onNewGisas()
     m_listView->selectionModel()->select(idx, QItemSelectionModel::ClearAndSelect);
 }
 
-void InstrumentListView::onNewOffSpecular()
+void InstrumentListView::onNewOffspec()
 {
-    QModelIndex idx = m_model->addNewOffSpecularInstrument();
+    QModelIndex idx = m_model->addNewOffspecInstrument();
     m_listView->selectionModel()->select(idx, QItemSelectionModel::ClearAndSelect);
 }
 
@@ -220,7 +219,7 @@ void InstrumentListView::onStoreInLibrary()
 
     InstrumentLibraryEditor dlg(GUI::Global::mainWindow);
     dlg.setGisasEnabled(m_document->functionalities().testFlag(ProjectDocument::Gisas));
-    dlg.setOffSpecEnabled(m_document->functionalities().testFlag(ProjectDocument::OffSpecular));
+    dlg.setOffspecEnabled(m_document->functionalities().testFlag(ProjectDocument::Offspec));
     dlg.setSpecularEnabled(m_document->functionalities().testFlag(ProjectDocument::Specular));
     dlg.setDepthProbeEnabled(m_document->functionalities().testFlag(ProjectDocument::DepthProbe));
     dlg.execAdd(*instrument);
@@ -236,7 +235,7 @@ void InstrumentListView::onLoadFromLibrary()
 
     InstrumentLibraryEditor dlg(GUI::Global::mainWindow);
     dlg.setGisasEnabled(m_document->functionalities().testFlag(ProjectDocument::Gisas));
-    dlg.setOffSpecEnabled(m_document->functionalities().testFlag(ProjectDocument::OffSpecular));
+    dlg.setOffspecEnabled(m_document->functionalities().testFlag(ProjectDocument::Offspec));
     dlg.setSpecularEnabled(m_document->functionalities().testFlag(ProjectDocument::Specular));
     dlg.setDepthProbeEnabled(m_document->functionalities().testFlag(ProjectDocument::DepthProbe));
 
@@ -253,7 +252,7 @@ void InstrumentListView::updateFunctionalityNarrowing()
     const auto f = m_document->functionalities();
 
     m_newGisasAction->setVisible(f.testFlag(ProjectDocument::Gisas));
-    m_newOffSpecularAction->setVisible(f.testFlag(ProjectDocument::OffSpecular));
+    m_newOffspecAction->setVisible(f.testFlag(ProjectDocument::Offspec));
     m_newSpecularAction->setVisible(f.testFlag(ProjectDocument::Specular));
     m_newDepthProbeAction->setVisible(f.testFlag(ProjectDocument::DepthProbe));
     m_copyAction->setVisible(!m_document->singleInstrumentMode());
diff --git a/GUI/View/Instrument/InstrumentListView.h b/GUI/View/Instrument/InstrumentListView.h
index 748c94d3863..b9455828a50 100644
--- a/GUI/View/Instrument/InstrumentListView.h
+++ b/GUI/View/Instrument/InstrumentListView.h
@@ -46,7 +46,7 @@ signals:
 private slots:
     void onItemSelectionChanged();
     void onNewGisas();
-    void onNewOffSpecular();
+    void onNewOffspec();
     void onNewSpecular();
     void onNewDepthProbe();
 
@@ -68,7 +68,7 @@ private:
     QListView* m_listView;
     InstrumentListModel* m_model;
     QAction* m_newGisasAction;
-    QAction* m_newOffSpecularAction;
+    QAction* m_newOffspecAction;
     QAction* m_newSpecularAction;
     QAction* m_newDepthProbeAction;
     QAction* m_separatorAction1;
diff --git a/GUI/View/Instrument/InstrumentView.cpp b/GUI/View/Instrument/InstrumentView.cpp
index 769c9882b22..d3b5a4cd724 100644
--- a/GUI/View/Instrument/InstrumentView.cpp
+++ b/GUI/View/Instrument/InstrumentView.cpp
@@ -129,9 +129,9 @@ void InstrumentView::createWidgetsForCurrentInstrument()
         connect(editor, &SpecularInstrumentEditor::dataChanged, this,
                 &InstrumentView::onInstrumentChangedByEditor);
         layout->addWidget(editor);
-    } else if (auto* os = dynamic_cast<OffSpecularInstrumentItem*>(currentInstrument)) {
-        auto* editor = new OffSpecularInstrumentEditor(m_scrollArea, os);
-        connect(editor, &OffSpecularInstrumentEditor::dataChanged, this,
+    } else if (auto* os = dynamic_cast<OffspecInstrumentItem*>(currentInstrument)) {
+        auto* editor = new OffspecInstrumentEditor(m_scrollArea, os);
+        connect(editor, &OffspecInstrumentEditor::dataChanged, this,
                 &InstrumentView::onInstrumentChangedByEditor);
         layout->addWidget(editor);
     } else if (auto* gisas = dynamic_cast<GISASInstrumentItem*>(currentInstrument)) {
diff --git a/GUI/View/Instrument/InstrumentsTreeModel.cpp b/GUI/View/Instrument/InstrumentsTreeModel.cpp
index 23d92240664..b2628b4a8aa 100644
--- a/GUI/View/Instrument/InstrumentsTreeModel.cpp
+++ b/GUI/View/Instrument/InstrumentsTreeModel.cpp
@@ -76,7 +76,7 @@ QList<InstrumentsTreeModel::InstrumentType> InstrumentsTreeModel::visibleTypes()
     };
 
     forType(Gisas);
-    forType(OffSpecular);
+    forType(Offspec);
     forType(Specular);
     forType(DepthProbe);
 
@@ -90,9 +90,9 @@ QVector<InstrumentItem*> InstrumentsTreeModel::instruments(InstrumentType type)
         return m_model->instrumentItems([](const InstrumentItem* p) {
             return dynamic_cast<const GISASInstrumentItem*>(p) != nullptr;
         });
-    case OffSpecular:
+    case Offspec:
         return m_model->instrumentItems([](const InstrumentItem* p) {
-            return dynamic_cast<const OffSpecularInstrumentItem*>(p) != nullptr;
+            return dynamic_cast<const OffspecInstrumentItem*>(p) != nullptr;
         });
     case Specular:
         return m_model->instrumentItems([](const InstrumentItem* p) {
@@ -183,8 +183,8 @@ QVariant InstrumentsTreeModel::data(const QModelIndex& index, int role) const
         QString title;
         if (index == indexOfHeadline(Gisas))
             title = "GISAS";
-        else if (index == indexOfHeadline(OffSpecular))
-            title = "OffSpecular";
+        else if (index == indexOfHeadline(Offspec))
+            title = "Offspec";
         else if (index == indexOfHeadline(Specular))
             title = "Specular";
         else if (index == indexOfHeadline(DepthProbe))
@@ -241,7 +241,7 @@ QVariant InstrumentsTreeModel::data(const QModelIndex& index, int role) const
         switch (instrumentType(item)) {
         case Gisas:
             return QIcon(":/images/gisas_instrument.svg");
-        case OffSpecular:
+        case Offspec:
             return QIcon(":/images/offspec_instrument.svg");
         case Specular:
             return QIcon(":/images/specular_instrument.svg");
@@ -332,8 +332,8 @@ InstrumentsTreeModel::InstrumentType InstrumentsTreeModel::instrumentType(Instru
     if (item->is<GISASInstrumentItem>())
         return Gisas;
 
-    if (item->is<OffSpecularInstrumentItem>())
-        return OffSpecular;
+    if (item->is<OffspecInstrumentItem>())
+        return Offspec;
 
     if (item->is<SpecularInstrumentItem>())
         return Specular;
diff --git a/GUI/View/Instrument/InstrumentsTreeModel.h b/GUI/View/Instrument/InstrumentsTreeModel.h
index a67bc0da9f0..b843b64999b 100644
--- a/GUI/View/Instrument/InstrumentsTreeModel.h
+++ b/GUI/View/Instrument/InstrumentsTreeModel.h
@@ -29,10 +29,10 @@ public:
     enum InstrumentType {
         None = 0x0,
         Gisas = 0x1,
-        OffSpecular = 0x2,
+        Offspec = 0x2,
         Specular = 0x4,
         DepthProbe = 0x8,
-        All = Gisas | OffSpecular | Specular | DepthProbe
+        All = Gisas | Offspec | Specular | DepthProbe
     };
     Q_DECLARE_FLAGS(VisibleInstrumentTypes, InstrumentType)
 
diff --git a/GUI/View/Instrument/OffspecBeamEditor.cpp b/GUI/View/Instrument/OffspecBeamEditor.cpp
index a11c660f652..c51581854ec 100644
--- a/GUI/View/Instrument/OffspecBeamEditor.cpp
+++ b/GUI/View/Instrument/OffspecBeamEditor.cpp
@@ -3,7 +3,7 @@
 //  BornAgain: simulate and fit reflection and scattering
 //
 //! @file      GUI/View/Instrument/OffspecBeamEditor.cpp
-//! @brief     Implements class OffSpecularBeamEditor
+//! @brief     Implements class OffspecBeamEditor
 //!
 //! @homepage  http://www.bornagainproject.org
 //! @license   GNU General Public License v3 or higher (see COPYING)
@@ -26,7 +26,7 @@
 #include <QGridLayout>
 #include <QLineEdit>
 
-OffSpecularBeamEditor::OffSpecularBeamEditor(QWidget* parent, OffSpecularInstrumentItem* item)
+OffspecBeamEditor::OffspecBeamEditor(QWidget* parent, OffspecInstrumentItem* item)
     : QGroupBox("Beam parameters", parent)
 {
     ASSERT(item);
@@ -62,11 +62,11 @@ OffSpecularBeamEditor::OffSpecularBeamEditor(QWidget* parent, OffSpecularInstrum
     GroupBoxCollapser::installIntoGroupBox(this);
 
     connect(wavelengthEditor, &DistributionEditor::distributionChanged, this,
-            &OffSpecularBeamEditor::dataChanged);
+            &OffspecBeamEditor::dataChanged);
     connect(inclinationEditor, &AxisPropertyEditor::dataChanged, this,
-            &OffSpecularBeamEditor::dataChanged);
+            &OffspecBeamEditor::dataChanged);
     connect(azimuthalEditor, &DistributionEditor::distributionChanged, this,
-            &OffSpecularBeamEditor::dataChanged);
+            &OffspecBeamEditor::dataChanged);
 
     // validate value while typing
     connect(intensityEditor, &QLineEdit::textEdited, [=]() {
diff --git a/GUI/View/Instrument/OffspecBeamEditor.h b/GUI/View/Instrument/OffspecBeamEditor.h
index 81a30f57cb1..ee4d8c44718 100644
--- a/GUI/View/Instrument/OffspecBeamEditor.h
+++ b/GUI/View/Instrument/OffspecBeamEditor.h
@@ -3,7 +3,7 @@
 //  BornAgain: simulate and fit reflection and scattering
 //
 //! @file      GUI/View/Instrument/OffspecBeamEditor.h
-//! @brief     Defines class OffSpecularBeamEditor
+//! @brief     Defines class OffspecBeamEditor
 //!
 //! @homepage  http://www.bornagainproject.org
 //! @license   GNU General Public License v3 or higher (see COPYING)
@@ -17,15 +17,15 @@
 
 #include <QGroupBox>
 
-class OffSpecularInstrumentItem;
+class OffspecInstrumentItem;
 
-//! Off-specular beam editor. Operates on OffSpecularInstrumentItem
+//! Off-specular beam editor. Operates on OffspecInstrumentItem
 
-class OffSpecularBeamEditor : public QGroupBox {
+class OffspecBeamEditor : public QGroupBox {
     Q_OBJECT
 
 public:
-    OffSpecularBeamEditor(QWidget* parent, OffSpecularInstrumentItem* item);
+    OffspecBeamEditor(QWidget* parent, OffspecInstrumentItem* item);
 
 signals:
     void dataChanged();
diff --git a/GUI/View/Instrument/OffspecInstrumentEditor.cpp b/GUI/View/Instrument/OffspecInstrumentEditor.cpp
index df899ccde78..a35a00886e1 100644
--- a/GUI/View/Instrument/OffspecInstrumentEditor.cpp
+++ b/GUI/View/Instrument/OffspecInstrumentEditor.cpp
@@ -3,7 +3,7 @@
 //  BornAgain: simulate and fit reflection and scattering
 //
 //! @file      GUI/View/Instrument/OffspecInstrumentEditor.cpp
-//! @brief     Implements class OffSpecularInstrumentEditor
+//! @brief     Implements class OffspecInstrumentEditor
 //!
 //! @homepage  http://www.bornagainproject.org
 //! @license   GNU General Public License v3 or higher (see COPYING)
@@ -20,15 +20,14 @@
 
 #include <QVBoxLayout>
 
-OffSpecularInstrumentEditor::OffSpecularInstrumentEditor(QWidget* parent,
-                                                         OffSpecularInstrumentItem* instrument)
+OffspecInstrumentEditor::OffspecInstrumentEditor(QWidget* parent, OffspecInstrumentItem* instrument)
     : QWidget(parent)
 {
     ASSERT(instrument)
     auto* layout = new QVBoxLayout(this);
     layout->setContentsMargins(0, 0, 0, 0);
 
-    auto* beamEditor = new OffSpecularBeamEditor(this, instrument);
+    auto* beamEditor = new OffspecBeamEditor(this, instrument);
     layout->addWidget(beamEditor);
 
     auto* detectorEditor = new DetectorEditor(this, instrument);
@@ -39,10 +38,10 @@ OffSpecularInstrumentEditor::OffSpecularInstrumentEditor(QWidget* parent,
 
     layout->addStretch();
 
-    connect(beamEditor, &OffSpecularBeamEditor::dataChanged, this,
-            &OffSpecularInstrumentEditor::dataChanged);
+    connect(beamEditor, &OffspecBeamEditor::dataChanged, this,
+            &OffspecInstrumentEditor::dataChanged);
     connect(detectorEditor, &DetectorEditor::dataChanged, this,
-            &OffSpecularInstrumentEditor::dataChanged);
+            &OffspecInstrumentEditor::dataChanged);
     connect(polpairAnalysisEditor, &PolarizationAnalysisEditor::dataChanged, this,
-            &OffSpecularInstrumentEditor::dataChanged);
+            &OffspecInstrumentEditor::dataChanged);
 }
diff --git a/GUI/View/Instrument/OffspecInstrumentEditor.h b/GUI/View/Instrument/OffspecInstrumentEditor.h
index 35a6bf73ff8..dda3efdcdbf 100644
--- a/GUI/View/Instrument/OffspecInstrumentEditor.h
+++ b/GUI/View/Instrument/OffspecInstrumentEditor.h
@@ -3,7 +3,7 @@
 //  BornAgain: simulate and fit reflection and scattering
 //
 //! @file      GUI/View/Instrument/OffspecInstrumentEditor.h
-//! @brief     Defines class OffSpecularInstrumentEditor
+//! @brief     Defines class OffspecInstrumentEditor
 //!
 //! @homepage  http://www.bornagainproject.org
 //! @license   GNU General Public License v3 or higher (see COPYING)
@@ -17,13 +17,13 @@
 
 #include <QWidget>
 
-class OffSpecularInstrumentItem;
+class OffspecInstrumentItem;
 
-class OffSpecularInstrumentEditor : public QWidget {
+class OffspecInstrumentEditor : public QWidget {
     Q_OBJECT
 
 public:
-    OffSpecularInstrumentEditor(QWidget* parent, OffSpecularInstrumentItem* instrument);
+    OffspecInstrumentEditor(QWidget* parent, OffspecInstrumentItem* instrument);
 
 signals:
     void dataChanged();
diff --git a/GUI/View/Toplevel/ProjectSettingsView.cpp b/GUI/View/Toplevel/ProjectSettingsView.cpp
index 9822b39cafb..980f574ff7e 100644
--- a/GUI/View/Toplevel/ProjectSettingsView.cpp
+++ b/GUI/View/Toplevel/ProjectSettingsView.cpp
@@ -45,7 +45,7 @@ ProjectSettingsView::ProjectSettingsView(QWidget* parentWidget, ProjectDocument*
 
     connect(m_ui->gisasCheck, &QCheckBox::toggled, this,
             &ProjectSettingsView::onFunctionalityToggled);
-    connect(m_ui->offSpecCheck, &QCheckBox::toggled, this,
+    connect(m_ui->offspecCheck, &QCheckBox::toggled, this,
             &ProjectSettingsView::onFunctionalityToggled);
     connect(m_ui->reflectometryCheck, &QCheckBox::toggled, this,
             &ProjectSettingsView::onFunctionalityToggled);
@@ -83,12 +83,12 @@ void ProjectSettingsView::writeFunctionalityToUI()
     const auto f = m_document->functionalities();
 
     QSignalBlocker b1(m_ui->gisasCheck);
-    QSignalBlocker b2(m_ui->offSpecCheck);
+    QSignalBlocker b2(m_ui->offspecCheck);
     QSignalBlocker b3(m_ui->reflectometryCheck);
     QSignalBlocker b4(m_ui->depthCheck);
 
     m_ui->gisasCheck->setChecked(f.testFlag(ProjectDocument::Gisas));
-    m_ui->offSpecCheck->setChecked(f.testFlag(ProjectDocument::OffSpecular));
+    m_ui->offspecCheck->setChecked(f.testFlag(ProjectDocument::Offspec));
     m_ui->reflectometryCheck->setChecked(f.testFlag(ProjectDocument::Specular));
     m_ui->depthCheck->setChecked(f.testFlag(ProjectDocument::DepthProbe));
 }
@@ -170,7 +170,7 @@ ProjectDocument::Functionalities ProjectSettingsView::functionalities() const
 {
     ProjectDocument::Functionalities f;
     f.setFlag(ProjectDocument::Gisas, m_ui->gisasCheck->isChecked());
-    f.setFlag(ProjectDocument::OffSpecular, m_ui->offSpecCheck->isChecked());
+    f.setFlag(ProjectDocument::Offspec, m_ui->offspecCheck->isChecked());
     f.setFlag(ProjectDocument::Specular, m_ui->reflectometryCheck->isChecked());
     f.setFlag(ProjectDocument::DepthProbe, m_ui->depthCheck->isChecked());
     return f;
diff --git a/GUI/View/Toplevel/ProjectSettingsView.ui b/GUI/View/Toplevel/ProjectSettingsView.ui
index 11689129f99..1e44c175d63 100644
--- a/GUI/View/Toplevel/ProjectSettingsView.ui
+++ b/GUI/View/Toplevel/ProjectSettingsView.ui
@@ -1,366 +1,366 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>ProjectSettingsView</class>
- <widget class="QWidget" name="ProjectSettingsView">
-  <property name="geometry">
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>866</width>
-    <height>835</height>
-   </rect>
-  </property>
-  <property name="windowTitle">
-   <string>Form</string>
-  </property>
-  <layout class="QVBoxLayout" name="mainLayout">
-   <property name="spacing">
-    <number>15</number>
-   </property>
-   <property name="sizeConstraint">
-    <enum>QLayout::SetNoConstraint</enum>
-   </property>
-   <property name="leftMargin">
-    <number>9</number>
-   </property>
-   <property name="topMargin">
-    <number>9</number>
-   </property>
-   <property name="rightMargin">
-    <number>9</number>
-   </property>
-   <property name="bottomMargin">
-    <number>9</number>
-   </property>
-   <item>
-    <widget class="QGroupBox" name="groupBox_3">
-     <property name="title">
-      <string>Information</string>
-     </property>
-     <layout class="QVBoxLayout" name="verticalLayout_8">
-      <item>
-       <layout class="QFormLayout" name="formLayout">
-        <property name="labelAlignment">
-         <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
-        </property>
-        <property name="formAlignment">
-         <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
-        </property>
-        <property name="leftMargin">
-         <number>0</number>
-        </property>
-        <item row="0" column="0">
-         <widget class="QLabel" name="label_4">
-          <property name="font">
-           <font>
-            <weight>75</weight>
-            <bold>true</bold>
-           </font>
-          </property>
-          <property name="text">
-           <string>Name:</string>
-          </property>
-         </widget>
-        </item>
-        <item row="0" column="1">
-         <widget class="QLabel" name="currentProjectName">
-          <property name="font">
-           <font>
-            <weight>75</weight>
-            <bold>true</bold>
-           </font>
-          </property>
-          <property name="text">
-           <string>&lt;Name&gt;</string>
-          </property>
-         </widget>
-        </item>
-        <item row="1" column="0">
-         <widget class="QLabel" name="label_5">
-          <property name="text">
-           <string>Location:</string>
-          </property>
-         </widget>
-        </item>
-        <item row="1" column="1">
-         <widget class="QLabel" name="currentProjectLocation">
-          <property name="text">
-           <string>&lt;Location&gt;</string>
-          </property>
-         </widget>
-        </item>
-        <item row="2" column="0">
-         <widget class="QLabel" name="label_6">
-          <property name="text">
-           <string>Description:</string>
-          </property>
-         </widget>
-        </item>
-        <item row="2" column="1">
-         <widget class="QTextEdit" name="textEdit"/>
-        </item>
-       </layout>
-      </item>
-     </layout>
-    </widget>
-   </item>
-   <item>
-    <widget class="QGroupBox" name="groupBox">
-     <property name="title">
-      <string>Functionality</string>
-     </property>
-     <layout class="QHBoxLayout" name="horizontalLayout">
-      <item>
-       <layout class="QVBoxLayout" name="verticalLayout_2">
-        <property name="spacing">
-         <number>6</number>
-        </property>
-        <property name="sizeConstraint">
-         <enum>QLayout::SetMinimumSize</enum>
-        </property>
-        <item>
-         <widget class="QCheckBox" name="gisasCheck">
-          <property name="text">
-           <string>GISAS</string>
-          </property>
-          <property name="checked">
-           <bool>true</bool>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QCheckBox" name="offSpecCheck">
-          <property name="text">
-           <string>Off-Specular</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QCheckBox" name="reflectometryCheck">
-          <property name="text">
-           <string>Reflectometry</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QCheckBox" name="depthCheck">
-          <property name="text">
-           <string>Depth Probe</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <spacer name="verticalSpacer_3">
-          <property name="orientation">
-           <enum>Qt::Vertical</enum>
-          </property>
-          <property name="sizeType">
-           <enum>QSizePolicy::MinimumExpanding</enum>
-          </property>
-          <property name="sizeHint" stdset="0">
-           <size>
-            <width>20</width>
-            <height>0</height>
-           </size>
-          </property>
-         </spacer>
-        </item>
-       </layout>
-      </item>
-      <item>
-       <widget class="QLabel" name="label">
-        <property name="sizePolicy">
-         <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
-          <horstretch>0</horstretch>
-          <verstretch>0</verstretch>
-         </sizepolicy>
-        </property>
-        <property name="text">
-         <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Define which types of simulation/analysis you want to use in this project. According to your selection, irrelevant menus and information will be hidden. Use this to narrow down the given possibilities to what you really need.&lt;/p&gt;&lt;p&gt;You can always come back and change these selection if you need more (or less) functionalities of BornAgain.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
-        </property>
-        <property name="alignment">
-         <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
-        </property>
-        <property name="wordWrap">
-         <bool>true</bool>
-        </property>
-       </widget>
-      </item>
-     </layout>
-    </widget>
-   </item>
-   <item>
-    <widget class="QGroupBox" name="groupBox_1">
-     <property name="title">
-      <string>Instruments</string>
-     </property>
-     <layout class="QHBoxLayout" name="horizontalLayout_2">
-      <property name="spacing">
-       <number>6</number>
-      </property>
-      <item>
-       <layout class="QVBoxLayout" name="verticalLayout_3">
-        <property name="spacing">
-         <number>6</number>
-        </property>
-        <item>
-         <widget class="QRadioButton" name="singleInstrumentModeRadio">
-          <property name="text">
-           <string>Use only one instrument</string>
-          </property>
-          <property name="checked">
-           <bool>true</bool>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QRadioButton" name="multipleInstrumentModeRadio">
-          <property name="text">
-           <string>Use multiple instruments</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <spacer name="verticalSpacer_2">
-          <property name="orientation">
-           <enum>Qt::Vertical</enum>
-          </property>
-          <property name="sizeHint" stdset="0">
-           <size>
-            <width>20</width>
-            <height>0</height>
-           </size>
-          </property>
-         </spacer>
-        </item>
-       </layout>
-      </item>
-      <item>
-       <widget class="QLabel" name="label_2">
-        <property name="text">
-         <string>Define whether you want to use only one ore more instruments within this project. According to your selection, irrelevant menus and information will be hidden. Use this to narrow down the given possibilities to what you really need.
-
-You can always come back and change these selection if you need more (or less) functionalities of BornAgain.
-
-Note that if your above selection contains more than one type of functionality, the single instrument view is not possible any more.</string>
-        </property>
-        <property name="alignment">
-         <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
-        </property>
-        <property name="wordWrap">
-         <bool>true</bool>
-        </property>
-       </widget>
-      </item>
-     </layout>
-    </widget>
-   </item>
-   <item>
-    <widget class="QGroupBox" name="groupBox_2">
-     <property name="title">
-      <string>Sample models</string>
-     </property>
-     <layout class="QHBoxLayout" name="horizontalLayout_3">
-      <property name="spacing">
-       <number>6</number>
-      </property>
-      <item>
-       <layout class="QVBoxLayout" name="verticalLayout_4">
-        <property name="spacing">
-         <number>6</number>
-        </property>
-        <item>
-         <widget class="QRadioButton" name="singleSampleModeRadio">
-          <property name="text">
-           <string>Use only one sample model</string>
-          </property>
-          <property name="checked">
-           <bool>true</bool>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <widget class="QRadioButton" name="multipleSampleModeRadio">
-          <property name="text">
-           <string>Use multiple sample models</string>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <spacer name="verticalSpacer_4">
-          <property name="orientation">
-           <enum>Qt::Vertical</enum>
-          </property>
-          <property name="sizeHint" stdset="0">
-           <size>
-            <width>20</width>
-            <height>0</height>
-           </size>
-          </property>
-         </spacer>
-        </item>
-       </layout>
-      </item>
-      <item>
-       <widget class="QLabel" name="label_3">
-        <property name="text">
-         <string>Define whether you want to use one ore more sample models within this project. According to your selection, irrelevant menus and information will be hidden. Use this to narrow down the given possibilities to what you really need.
-
-You can always come back and change these selection if you need more (or less) functionalities of BornAgain.</string>
-        </property>
-        <property name="alignment">
-         <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
-        </property>
-        <property name="wordWrap">
-         <bool>true</bool>
-        </property>
-       </widget>
-      </item>
-     </layout>
-    </widget>
-   </item>
-   <item>
-    <layout class="QHBoxLayout" name="horizontalLayout_4">
-     <item>
-      <widget class="QPushButton" name="storeAsDefaultsButton">
-       <property name="toolTip">
-        <string>Store the current values as the default settings for the next times you create a new project</string>
-       </property>
-       <property name="text">
-        <string>Store as default values</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <spacer name="horizontalSpacer">
-       <property name="orientation">
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="sizeHint" stdset="0">
-        <size>
-         <width>40</width>
-         <height>20</height>
-        </size>
-       </property>
-      </spacer>
-     </item>
-    </layout>
-   </item>
-   <item>
-    <spacer name="verticalSpacer">
-     <property name="orientation">
-      <enum>Qt::Vertical</enum>
-     </property>
-     <property name="sizeHint" stdset="0">
-      <size>
-       <width>20</width>
-       <height>488</height>
-      </size>
-     </property>
-    </spacer>
-   </item>
-  </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ProjectSettingsView</class>
+ <widget class="QWidget" name="ProjectSettingsView">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>866</width>
+    <height>835</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QVBoxLayout" name="mainLayout">
+   <property name="spacing">
+    <number>15</number>
+   </property>
+   <property name="sizeConstraint">
+    <enum>QLayout::SetNoConstraint</enum>
+   </property>
+   <property name="leftMargin">
+    <number>9</number>
+   </property>
+   <property name="topMargin">
+    <number>9</number>
+   </property>
+   <property name="rightMargin">
+    <number>9</number>
+   </property>
+   <property name="bottomMargin">
+    <number>9</number>
+   </property>
+   <item>
+    <widget class="QGroupBox" name="groupBox_3">
+     <property name="title">
+      <string>Information</string>
+     </property>
+     <layout class="QVBoxLayout" name="verticalLayout_8">
+      <item>
+       <layout class="QFormLayout" name="formLayout">
+        <property name="labelAlignment">
+         <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+        </property>
+        <property name="formAlignment">
+         <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+        </property>
+        <property name="leftMargin">
+         <number>0</number>
+        </property>
+        <item row="0" column="0">
+         <widget class="QLabel" name="label_4">
+          <property name="font">
+           <font>
+            <weight>75</weight>
+            <bold>true</bold>
+           </font>
+          </property>
+          <property name="text">
+           <string>Name:</string>
+          </property>
+         </widget>
+        </item>
+        <item row="0" column="1">
+         <widget class="QLabel" name="currentProjectName">
+          <property name="font">
+           <font>
+            <weight>75</weight>
+            <bold>true</bold>
+           </font>
+          </property>
+          <property name="text">
+           <string>&lt;Name&gt;</string>
+          </property>
+         </widget>
+        </item>
+        <item row="1" column="0">
+         <widget class="QLabel" name="label_5">
+          <property name="text">
+           <string>Location:</string>
+          </property>
+         </widget>
+        </item>
+        <item row="1" column="1">
+         <widget class="QLabel" name="currentProjectLocation">
+          <property name="text">
+           <string>&lt;Location&gt;</string>
+          </property>
+         </widget>
+        </item>
+        <item row="2" column="0">
+         <widget class="QLabel" name="label_6">
+          <property name="text">
+           <string>Description:</string>
+          </property>
+         </widget>
+        </item>
+        <item row="2" column="1">
+         <widget class="QTextEdit" name="textEdit"/>
+        </item>
+       </layout>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <widget class="QGroupBox" name="groupBox">
+     <property name="title">
+      <string>Functionality</string>
+     </property>
+     <layout class="QHBoxLayout" name="horizontalLayout">
+      <item>
+       <layout class="QVBoxLayout" name="verticalLayout_2">
+        <property name="spacing">
+         <number>6</number>
+        </property>
+        <property name="sizeConstraint">
+         <enum>QLayout::SetMinimumSize</enum>
+        </property>
+        <item>
+         <widget class="QCheckBox" name="gisasCheck">
+          <property name="text">
+           <string>GISAS</string>
+          </property>
+          <property name="checked">
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QCheckBox" name="offspecCheck">
+          <property name="text">
+           <string>Off-Specular</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QCheckBox" name="reflectometryCheck">
+          <property name="text">
+           <string>Reflectometry</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QCheckBox" name="depthCheck">
+          <property name="text">
+           <string>Depth Probe</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <spacer name="verticalSpacer_3">
+          <property name="orientation">
+           <enum>Qt::Vertical</enum>
+          </property>
+          <property name="sizeType">
+           <enum>QSizePolicy::MinimumExpanding</enum>
+          </property>
+          <property name="sizeHint" stdset="0">
+           <size>
+            <width>20</width>
+            <height>0</height>
+           </size>
+          </property>
+         </spacer>
+        </item>
+       </layout>
+      </item>
+      <item>
+       <widget class="QLabel" name="label">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text">
+         <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Define which types of simulation/analysis you want to use in this project. According to your selection, irrelevant menus and information will be hidden. Use this to narrow down the given possibilities to what you really need.&lt;/p&gt;&lt;p&gt;You can always come back and change these selection if you need more (or less) functionalities of BornAgain.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+        </property>
+        <property name="alignment">
+         <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+        </property>
+        <property name="wordWrap">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <widget class="QGroupBox" name="groupBox_1">
+     <property name="title">
+      <string>Instruments</string>
+     </property>
+     <layout class="QHBoxLayout" name="horizontalLayout_2">
+      <property name="spacing">
+       <number>6</number>
+      </property>
+      <item>
+       <layout class="QVBoxLayout" name="verticalLayout_3">
+        <property name="spacing">
+         <number>6</number>
+        </property>
+        <item>
+         <widget class="QRadioButton" name="singleInstrumentModeRadio">
+          <property name="text">
+           <string>Use only one instrument</string>
+          </property>
+          <property name="checked">
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QRadioButton" name="multipleInstrumentModeRadio">
+          <property name="text">
+           <string>Use multiple instruments</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <spacer name="verticalSpacer_2">
+          <property name="orientation">
+           <enum>Qt::Vertical</enum>
+          </property>
+          <property name="sizeHint" stdset="0">
+           <size>
+            <width>20</width>
+            <height>0</height>
+           </size>
+          </property>
+         </spacer>
+        </item>
+       </layout>
+      </item>
+      <item>
+       <widget class="QLabel" name="label_2">
+        <property name="text">
+         <string>Define whether you want to use only one ore more instruments within this project. According to your selection, irrelevant menus and information will be hidden. Use this to narrow down the given possibilities to what you really need.
+
+You can always come back and change these selection if you need more (or less) functionalities of BornAgain.
+
+Note that if your above selection contains more than one type of functionality, the single instrument view is not possible any more.</string>
+        </property>
+        <property name="alignment">
+         <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+        </property>
+        <property name="wordWrap">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <widget class="QGroupBox" name="groupBox_2">
+     <property name="title">
+      <string>Sample models</string>
+     </property>
+     <layout class="QHBoxLayout" name="horizontalLayout_3">
+      <property name="spacing">
+       <number>6</number>
+      </property>
+      <item>
+       <layout class="QVBoxLayout" name="verticalLayout_4">
+        <property name="spacing">
+         <number>6</number>
+        </property>
+        <item>
+         <widget class="QRadioButton" name="singleSampleModeRadio">
+          <property name="text">
+           <string>Use only one sample model</string>
+          </property>
+          <property name="checked">
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <widget class="QRadioButton" name="multipleSampleModeRadio">
+          <property name="text">
+           <string>Use multiple sample models</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <spacer name="verticalSpacer_4">
+          <property name="orientation">
+           <enum>Qt::Vertical</enum>
+          </property>
+          <property name="sizeHint" stdset="0">
+           <size>
+            <width>20</width>
+            <height>0</height>
+           </size>
+          </property>
+         </spacer>
+        </item>
+       </layout>
+      </item>
+      <item>
+       <widget class="QLabel" name="label_3">
+        <property name="text">
+         <string>Define whether you want to use one ore more sample models within this project. According to your selection, irrelevant menus and information will be hidden. Use this to narrow down the given possibilities to what you really need.
+
+You can always come back and change these selection if you need more (or less) functionalities of BornAgain.</string>
+        </property>
+        <property name="alignment">
+         <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+        </property>
+        <property name="wordWrap">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_4">
+     <item>
+      <widget class="QPushButton" name="storeAsDefaultsButton">
+       <property name="toolTip">
+        <string>Store the current values as the default settings for the next times you create a new project</string>
+       </property>
+       <property name="text">
+        <string>Store as default values</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="horizontalSpacer">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <spacer name="verticalSpacer">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>488</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/Sim/Export/SimulationToPython.cpp b/Sim/Export/SimulationToPython.cpp
index 67c60ed35ef..d47a577da3b 100644
--- a/Sim/Export/SimulationToPython.cpp
+++ b/Sim/Export/SimulationToPython.cpp
@@ -296,7 +296,7 @@ std::string defineGISASBeam(const ScatteringSimulation& simulation)
     return result.str();
 }
 
-std::string defineOffSpecularBeam(const OffSpecularSimulation& simulation)
+std::string defineOffspecBeam(const OffspecSimulation& simulation)
 {
     std::ostringstream result;
     const Beam& beam = simulation.beam();
@@ -420,14 +420,14 @@ std::string defineScatteringSimulation(const ScatteringSimulation* simulation)
     return result.str();
 }
 
-std::string defineOffSpecularSimulation(const OffSpecularSimulation* simulation)
+std::string defineOffspecSimulation(const OffspecSimulation* simulation)
 {
     std::ostringstream result;
-    result << indent() << "simulation = ba.OffSpecularSimulation()\n";
+    result << indent() << "simulation = ba.OffspecSimulation()\n";
     result << defineDetector(simulation);
     result << defineDetectorResolutionFunction(simulation);
     result << defineDetectorPolarizationAnalysis(simulation);
-    result << defineOffSpecularBeam(*simulation);
+    result << defineOffspecBeam(*simulation);
     result << defineParameterDistributions(simulation);
     result << defineMasks(simulation);
     result << defineSimulationOptions(simulation);
@@ -455,8 +455,8 @@ std::string defineSimulate(const ISimulation* simulation)
     result << "def get_simulation(sample):\n";
     if (const auto* gisas = dynamic_cast<const ScatteringSimulation*>(simulation))
         result << defineScatteringSimulation(gisas);
-    else if (const auto* offspec = dynamic_cast<const OffSpecularSimulation*>(simulation))
-        result << defineOffSpecularSimulation(offspec);
+    else if (const auto* offspec = dynamic_cast<const OffspecSimulation*>(simulation))
+        result << defineOffspecSimulation(offspec);
     else if (const auto* spec = dynamic_cast<const SpecularSimulation*>(simulation))
         result << defineSpecularSimulation(spec);
     else
diff --git a/Sim/Simulation/ISimulation2D.h b/Sim/Simulation/ISimulation2D.h
index c80a6c6b836..a92f2006443 100644
--- a/Sim/Simulation/ISimulation2D.h
+++ b/Sim/Simulation/ISimulation2D.h
@@ -25,7 +25,7 @@ class IShape2D;
 
 //! Abstract base class of simulations that generate 2D patterns.
 //!
-//! Base class of OffSpecularSimulation and ScatteringSimulation.
+//! Base class of OffspecSimulation and ScatteringSimulation.
 //!
 //! Holds the common implementations for simulations with a 2D detector.
 
diff --git a/Sim/Simulation/OffspecSimulation.cpp b/Sim/Simulation/OffspecSimulation.cpp
index 5d0fbcae583..3e8877d2c73 100644
--- a/Sim/Simulation/OffspecSimulation.cpp
+++ b/Sim/Simulation/OffspecSimulation.cpp
@@ -3,7 +3,7 @@
 //  BornAgain: simulate and fit reflection and scattering
 //
 //! @file      Sim/Simulation/OffspecSimulation.cpp
-//! @brief     Implements class OffSpecularSimulation.
+//! @brief     Implements class OffspecSimulation.
 //!
 //! @homepage  http://www.bornagainproject.org
 //! @license   GNU General Public License v3 or higher (see COPYING)
@@ -25,30 +25,30 @@
 #include "Param/Distrib/Distributions.h"
 #include "Resample/Element/DiffuseElement.h"
 
-OffSpecularSimulation::OffSpecularSimulation(const Beam& beam, const MultiLayer& sample,
-                                             const IDetector2D& detector)
+OffspecSimulation::OffspecSimulation(const Beam& beam, const MultiLayer& sample,
+                                     const IDetector2D& detector)
     : ISimulation2D(beam, sample, detector)
 {
 }
 
-OffSpecularSimulation::OffSpecularSimulation()
+OffspecSimulation::OffspecSimulation()
 {
     initialize();
 }
 
-void OffSpecularSimulation::prepareSimulation()
+void OffspecSimulation::prepareSimulation()
 {
     checkInitialization();
     ISimulation2D::prepareSimulation();
 }
 
-size_t OffSpecularSimulation::numberOfElements() const
+size_t OffspecSimulation::numberOfElements() const
 {
     checkInitialization();
     return ISimulation2D::numberOfElements() * m_alpha_i_axis->size();
 }
 
-SimulationResult OffSpecularSimulation::pack_result()
+SimulationResult OffspecSimulation::pack_result()
 {
     checkInitialization();
     const IAxis& phi_axis = detector().axis(0);
@@ -62,12 +62,11 @@ SimulationResult OffSpecularSimulation::pack_result()
     return {*data, *coordsSystem};
 }
 
-void OffSpecularSimulation::setBeamParameters(double wavelength, const IAxis& alpha_axis,
-                                              double phi_i)
+void OffspecSimulation::setBeamParameters(double wavelength, const IAxis& alpha_axis, double phi_i)
 {
     m_alpha_i_axis.reset(alpha_axis.clone());
     if (alpha_axis.size() < 1)
-        throw std::runtime_error("OffSpecularSimulation::prepareSimulation() "
+        throw std::runtime_error("OffspecSimulation::prepareSimulation() "
                                  "-> Error. Incoming alpha range size < 1.");
     const double alpha_zero = alpha_axis.min();
     beam().setWavelength(wavelength);
@@ -75,26 +74,26 @@ void OffSpecularSimulation::setBeamParameters(double wavelength, const IAxis& al
     updateIntensityMap();
 }
 
-const IAxis* OffSpecularSimulation::beamAxis() const
+const IAxis* OffspecSimulation::beamAxis() const
 {
     return m_alpha_i_axis.get();
 }
 
 #ifndef SWIG
-ICoordSystem* OffSpecularSimulation::createCoordSystem() const
+ICoordSystem* OffspecSimulation::createCoordSystem() const
 {
     ASSERT(beamAxis());
     return detector2D().offspecCoords(beamAxis()->clone(), beam().direction());
 }
 #endif
 
-size_t OffSpecularSimulation::intensityMapSize() const
+size_t OffspecSimulation::intensityMapSize() const
 {
     checkInitialization();
     return m_alpha_i_axis->size() * detector().axis(1).size();
 }
 
-void OffSpecularSimulation::initElementVector()
+void OffspecSimulation::initElementVector()
 {
     m_eles.clear();
     Beam beam2 = beam();
@@ -108,19 +107,19 @@ void OffSpecularSimulation::initElementVector()
         m_cache.resize(m_eles.size(), 0.0);
 }
 
-void OffSpecularSimulation::validateParametrization(const ParameterDistribution& par_distr) const
+void OffspecSimulation::validateParametrization(const ParameterDistribution& par_distr) const
 {
     const bool zero_mean = par_distr.getDistribution()->mean() == 0.0;
     if (zero_mean)
         return;
     /* TODO come back to this after refactoring of distribution handling
     if (par_distr.whichParameter() == ParameterDistribution::BeamInclinationAngle)
-        throw std::runtime_error("Error in OffSpecularSimulation: parameter distribution of "
+        throw std::runtime_error("Error in OffspecSimulation: parameter distribution of "
                                  "beam inclination angle should have zero mean.");
     */
 }
 
-void OffSpecularSimulation::updateIntensityMap()
+void OffspecSimulation::updateIntensityMap()
 {
     ASSERT(m_alpha_i_axis);
     if (detector().rank() == 1)
@@ -132,7 +131,7 @@ void OffSpecularSimulation::updateIntensityMap()
     m_intensity_map->setAllTo(0.);
 }
 
-void OffSpecularSimulation::transferDetectorImage(size_t index)
+void OffspecSimulation::transferDetectorImage(size_t index)
 {
     std::unique_ptr<Powerfield<double>> detector_image;
     if (detector().rank() == 1)
@@ -151,11 +150,11 @@ void OffSpecularSimulation::transferDetectorImage(size_t index)
         (*m_intensity_map)[index * y_axis_size + i % y_axis_size] += (*detector_image)[i];
 }
 
-void OffSpecularSimulation::checkInitialization() const
+void OffspecSimulation::checkInitialization() const
 {
     ASSERT(m_alpha_i_axis);
     ASSERT(m_alpha_i_axis->size() >= 1);
     ASSERT(detector().rank() == 2);
 }
 
-void OffSpecularSimulation::initialize() {}
+void OffspecSimulation::initialize() {}
diff --git a/Sim/Simulation/OffspecSimulation.h b/Sim/Simulation/OffspecSimulation.h
index 6f9513029db..83153406c49 100644
--- a/Sim/Simulation/OffspecSimulation.h
+++ b/Sim/Simulation/OffspecSimulation.h
@@ -3,7 +3,7 @@
 //  BornAgain: simulate and fit reflection and scattering
 //
 //! @file      Sim/Simulation/OffspecSimulation.h
-//! @brief     Defines class OffSpecularSimulation.
+//! @brief     Defines class OffspecSimulation.
 //!
 //! @homepage  http://www.bornagainproject.org
 //! @license   GNU General Public License v3 or higher (see COPYING)
@@ -28,13 +28,13 @@ class Powerfield;
 //! Computes reflected and scattered intensity as function of incident and final glancing angle.
 //! @ingroup simulation
 
-class OffSpecularSimulation : public ISimulation2D {
+class OffspecSimulation : public ISimulation2D {
 public:
-    OffSpecularSimulation(const Beam& beam, const MultiLayer& sample, const IDetector2D& detector);
-    OffSpecularSimulation();
-    ~OffSpecularSimulation() override = default;
+    OffspecSimulation(const Beam& beam, const MultiLayer& sample, const IDetector2D& detector);
+    OffspecSimulation();
+    ~OffspecSimulation() override = default;
 
-    std::string className() const final { return "OffSpecularSimulation"; }
+    std::string className() const final { return "OffspecSimulation"; }
 
     //! Sets beam parameters from here (forwarded to Instrument)
     void setBeamParameters(double wavelength, const IAxis& alpha_axis, double phi_i);
diff --git a/Sim/Simulation/SpecularSimulation.cpp b/Sim/Simulation/SpecularSimulation.cpp
index 70a34710c12..b3fb4c14c66 100644
--- a/Sim/Simulation/SpecularSimulation.cpp
+++ b/Sim/Simulation/SpecularSimulation.cpp
@@ -3,7 +3,7 @@
 //  BornAgain: simulate and fit reflection and scattering
 //
 //! @file      Sim/Simulation/SpecularSimulation.cpp
-//! @brief     Implements class OffSpecularSimulation.
+//! @brief     Implements class OffspecSimulation.
 //!
 //! @homepage  http://www.bornagainproject.org
 //! @license   GNU General Public License v3 or higher (see COPYING)
diff --git a/Tests/Functional/Core/Fitting/FitTests.cpp b/Tests/Functional/Core/Fitting/FitTests.cpp
index d481085f3f8..03fcb1f382e 100644
--- a/Tests/Functional/Core/Fitting/FitTests.cpp
+++ b/Tests/Functional/Core/Fitting/FitTests.cpp
@@ -98,7 +98,7 @@ const auto build_AlternatingLayers_SpecularQ =
 
 const auto build_Resonator_Offspec =
     [](const mumufit::Parameters& params) -> std::unique_ptr<ISimulation> {
-    return test::makeSimulation::MiniOffSpecular(*build_Resonator(params));
+    return test::makeSimulation::MiniOffspec(*build_Resonator(params));
 };
 
 
@@ -226,7 +226,7 @@ TEST_F(Fitting, MultipleSpecFittingTest)
     EXPECT_TRUE(runFitTest("Minuit2", "Migrad", multispecPlan));
 }
 
-TEST_F(Fitting, OffSpecularFitTest)
+TEST_F(Fitting, OffspecFitTest)
 {
     EXPECT_TRUE(runFitTest("Minuit2", "Migrad", offspecPlan));
 }
diff --git a/Tests/Functional/Suite/MakeSimulations.cpp b/Tests/Functional/Suite/MakeSimulations.cpp
index cf594b2aa0b..76e9822a3c9 100644
--- a/Tests/Functional/Suite/MakeSimulations.cpp
+++ b/Tests/Functional/Suite/MakeSimulations.cpp
@@ -326,10 +326,9 @@ std::unique_ptr<ScatteringSimulation> test::makeSimulation::MiniGISASFit(const M
 //  off-specular simulations
 //  ************************************************************************************************
 
-std::unique_ptr<OffSpecularSimulation>
-test::makeSimulation::MiniOffSpecular(const MultiLayer& sample)
+std::unique_ptr<OffspecSimulation> test::makeSimulation::MiniOffspec(const MultiLayer& sample)
 {
-    auto result = std::make_unique<OffSpecularSimulation>();
+    auto result = std::make_unique<OffspecSimulation>();
     result->setSample(sample);
 
     const int n_alpha(19);
diff --git a/Tests/Functional/Suite/MakeSimulations.h b/Tests/Functional/Suite/MakeSimulations.h
index 2a701f3e3b3..20d9e7ff01e 100644
--- a/Tests/Functional/Suite/MakeSimulations.h
+++ b/Tests/Functional/Suite/MakeSimulations.h
@@ -26,7 +26,7 @@
 class DepthProbeSimulation;
 class ScatteringSimulation;
 class SpecularSimulation;
-class OffSpecularSimulation;
+class OffspecSimulation;
 class MultiLayer;
 
 //! Simulations for standard tests.
@@ -56,7 +56,7 @@ std::unique_ptr<ScatteringSimulation> RectDetWithRoi(const MultiLayer& sample);
 std::unique_ptr<ScatteringSimulation> MiniGISASFit(const MultiLayer& sample);
 std::unique_ptr<ScatteringSimulation> ExtraLongWavelengthGISAS(const MultiLayer& sample);
 
-std::unique_ptr<OffSpecularSimulation> MiniOffSpecular(const MultiLayer& sample);
+std::unique_ptr<OffspecSimulation> MiniOffspec(const MultiLayer& sample);
 
 std::unique_ptr<SpecularSimulation> BasicSpecular(const MultiLayer& sample, bool vsQ);
 std::unique_ptr<SpecularSimulation> BasicYPolarizedSpecular(const MultiLayer& sample,
diff --git a/Tests/Functional/Suite/TestSuite.h b/Tests/Functional/Suite/TestSuite.h
index 0278d519a33..1e8b9b7fa7f 100644
--- a/Tests/Functional/Suite/TestSuite.h
+++ b/Tests/Functional/Suite/TestSuite.h
@@ -555,11 +555,11 @@ TEST_F(Suite, RelativeResolutionTOF)
 
 #ifndef PYTHON_STD_TEST
 
-TEST_F(Suite, OffSpecularResonator)
+TEST_F(Suite, OffspecResonator)
 {
     auto* sample = ExemplarySamples::createResonator();
-    auto sim = test::makeSimulation::MiniOffSpecular(*sample);
-    EXPECT_TRUE(runTest("OffSpecularResonator", *sim, 1e-10));
+    auto sim = test::makeSimulation::MiniOffspec(*sample);
+    EXPECT_TRUE(runTest("OffspecResonator", *sim, 1e-10));
 }
 
 TEST_F(Suite, FormFactorsWithAbsorption)
diff --git a/Tests/ReferenceData/Suite/OffSpecularResonator.int.gz b/Tests/ReferenceData/Suite/OffspecResonator.int.gz
similarity index 100%
rename from Tests/ReferenceData/Suite/OffSpecularResonator.int.gz
rename to Tests/ReferenceData/Suite/OffspecResonator.int.gz
diff --git a/Tests/Unit/Device/OffspecConverterTest.cpp b/Tests/Unit/Device/OffspecConverterTest.cpp
index 13676d530b4..02594ebd592 100644
--- a/Tests/Unit/Device/OffspecConverterTest.cpp
+++ b/Tests/Unit/Device/OffspecConverterTest.cpp
@@ -5,16 +5,16 @@
 #include "Device/Detector/SphericalDetector.h"
 #include "Tests/GTestWrapper/google_test.h"
 
-class OffSpecularCoordinatesTest : public ::testing::Test {
+class OffspecCoordinatesTest : public ::testing::Test {
 public:
-    OffSpecularCoordinatesTest();
+    OffspecCoordinatesTest();
 
-    OffSpecularCoordinates* createCoords()
+    OffspecCoordinates* createCoords()
     {
         const auto axes = m_detector.axesClippedToRegionOfInterest();
 
         OwningVector<IAxis> axes2({m_alpha_i_axis.clone(), axes[1]->clone()});
-        return new OffSpecularCoordinates(axes2, m_beam.direction());
+        return new OffspecCoordinates(axes2, m_beam.direction());
     }
 
 protected:
@@ -23,16 +23,16 @@ protected:
     Beam m_beam;
 };
 
-OffSpecularCoordinatesTest::OffSpecularCoordinatesTest()
+OffspecCoordinatesTest::OffspecCoordinatesTest()
     : m_detector(100, 0.0, 5.0 * Units::deg, 70, -2.0 * Units::deg, 1.5)
     , m_alpha_i_axis("alpha_i", 51, 0.0, 7.0 * Units::deg)
     , m_beam(1.0, 1.0, {1.0 * Units::deg, 0.0})
 {
 }
 
-TEST_F(OffSpecularCoordinatesTest, OffSpecularCoordinates)
+TEST_F(OffspecCoordinatesTest, OffspecCoordinates)
 {
-    std::unique_ptr<OffSpecularCoordinates> coords(createCoords());
+    std::unique_ptr<OffspecCoordinates> coords(createCoords());
 
     EXPECT_EQ(coords->rank(), 2u);
 
@@ -83,10 +83,10 @@ TEST_F(OffSpecularCoordinatesTest, OffSpecularCoordinates)
     EXPECT_FAILED_ASSERT(coords->createConvertedAxis(1, Coords::QSPACE));
 }
 
-TEST_F(OffSpecularCoordinatesTest, OffSpecularCoordinatesClone)
+TEST_F(OffspecCoordinatesTest, OffspecCoordinatesClone)
 {
-    std::unique_ptr<OffSpecularCoordinates> coords(createCoords());
-    std::unique_ptr<OffSpecularCoordinates> P_clone(coords->clone());
+    std::unique_ptr<OffspecCoordinates> coords(createCoords());
+    std::unique_ptr<OffspecCoordinates> P_clone(coords->clone());
 
     EXPECT_EQ(P_clone->rank(), 2u);
 
diff --git a/Tests/Unit/GUI/TestInstrumentItems.cpp b/Tests/Unit/GUI/TestInstrumentItems.cpp
index 6c69852ba6c..f5ba4cdf44f 100644
--- a/Tests/Unit/GUI/TestInstrumentItems.cpp
+++ b/Tests/Unit/GUI/TestInstrumentItems.cpp
@@ -62,7 +62,7 @@ TEST_F(TestInstrumentItems, instrumentChanged)
 
     // Add another instrument
     auto* instrument3 =
-        document.instrumentsEditController()->addInstrument<OffSpecularInstrumentItem>();
+        document.instrumentsEditController()->addInstrument<OffspecInstrumentItem>();
 
     // Change instrument2
     document.instrumentsEditController()->setInstrumentName(instrument2, "BB");
diff --git a/Tests/Unit/GUI/TestSessionXML.cpp b/Tests/Unit/GUI/TestSessionXML.cpp
index 32aa5630fa7..608d8efd1f1 100644
--- a/Tests/Unit/GUI/TestSessionXML.cpp
+++ b/Tests/Unit/GUI/TestSessionXML.cpp
@@ -122,12 +122,12 @@ TEST_F(TestSessionXML, GISASInstrumentItem)
     EXPECT_EQ(a1, a2);
 }
 
-TEST_F(TestSessionXML, OffSpecularInstrumentItem)
+TEST_F(TestSessionXML, OffspecInstrumentItem)
 {
-    OffSpecularInstrumentItem instrument;
+    OffspecInstrumentItem instrument;
     const auto a1 = serialize(instrument);
 
-    OffSpecularInstrumentItem target;
+    OffspecInstrumentItem target;
     deserialize(target, a1);
 
     // checking top items in source and target models
diff --git a/Wrap/Python/ba_plot.py b/Wrap/Python/ba_plot.py
index 16062e3f78f..490b5c408c6 100644
--- a/Wrap/Python/ba_plot.py
+++ b/Wrap/Python/ba_plot.py
@@ -203,7 +203,7 @@ def plot_histogram(hist, **kwargs):
 def plot_heatmap(result, **kwargs):
     """
     Plots intensity data as heat map
-    :param result: SimulationResult from GISAS/OffSpecularSimulation
+    :param result: SimulationResult from GISAS/OffspecSimulation
     """
 
     units = kwargs.pop('units', ba.Coords_UNDEFINED)
diff --git a/auto/Wrap/doxygenDevice.i b/auto/Wrap/doxygenDevice.i
index d62d9b57eda..2f4eb212659 100644
--- a/auto/Wrap/doxygenDevice.i
+++ b/auto/Wrap/doxygenDevice.i
@@ -1642,21 +1642,21 @@ C++ includes: LLData.h
 ";
 
 
-// File: classOffSpecularCoordinates.xml
-%feature("docstring") OffSpecularCoordinates "
+// File: classOffspecCoordinates.xml
+%feature("docstring") OffspecCoordinates "
 
 ICoordSystem class that handles the unit translations for off-specular simulations with a spherical detector Its default units are radians for both axes
 
 C++ includes: CoordSystem2D.h
 ";
 
-%feature("docstring")  OffSpecularCoordinates::OffSpecularCoordinates "OffSpecularCoordinates::OffSpecularCoordinates(const OwningVector< IAxis > &axes, const Direction &direction)
+%feature("docstring")  OffspecCoordinates::OffspecCoordinates "OffspecCoordinates::OffspecCoordinates(const OwningVector< IAxis > &axes, const Direction &direction)
 ";
 
-%feature("docstring")  OffSpecularCoordinates::clone "OffSpecularCoordinates * OffSpecularCoordinates::clone() const override
+%feature("docstring")  OffspecCoordinates::clone "OffspecCoordinates * OffspecCoordinates::clone() const override
 ";
 
-%feature("docstring")  OffSpecularCoordinates::defaultUnits "Coords OffSpecularCoordinates::defaultUnits() const override
+%feature("docstring")  OffspecCoordinates::defaultUnits "Coords OffspecCoordinates::defaultUnits() const override
 ";
 
 
diff --git a/auto/Wrap/doxygenSim.i b/auto/Wrap/doxygenSim.i
index 5602be2cf77..a8539ac1c74 100644
--- a/auto/Wrap/doxygenSim.i
+++ b/auto/Wrap/doxygenSim.i
@@ -961,7 +961,7 @@ Returns the total number of the intensity values in the simulation result.
 
 Abstract base class of simulations that generate 2D patterns.
 
-Base class of  OffSpecularSimulation and  ScatteringSimulation.
+Base class of  OffspecSimulation and  ScatteringSimulation.
 
 Holds the common implementations for simulations with a 2D detector.
 
@@ -1285,44 +1285,44 @@ Returns a copy of the normalization function used.
 // File: classFitObserver_1_1ObserverData.xml
 
 
-// File: classOffSpecularSimulation.xml
-%feature("docstring") OffSpecularSimulation "
+// File: classOffspecSimulation.xml
+%feature("docstring") OffspecSimulation "
 
 Off-specular scattering simulation.
 
 Holds an instrument and sample model. Computes reflected and scattered intensity as function of incident and final glancing angle.
 
-C++ includes: OffSpecularSimulation.h
+C++ includes: OffspecSimulation.h
 ";
 
-%feature("docstring")  OffSpecularSimulation::OffSpecularSimulation "OffSpecularSimulation::OffSpecularSimulation(const Beam &beam, const MultiLayer &sample, const IDetector2D &detector)
+%feature("docstring")  OffspecSimulation::OffspecSimulation "OffspecSimulation::OffspecSimulation(const Beam &beam, const MultiLayer &sample, const IDetector2D &detector)
 ";
 
-%feature("docstring")  OffSpecularSimulation::OffSpecularSimulation "OffSpecularSimulation::OffSpecularSimulation()
+%feature("docstring")  OffspecSimulation::OffspecSimulation "OffspecSimulation::OffspecSimulation()
 ";
 
-%feature("docstring")  OffSpecularSimulation::~OffSpecularSimulation "OffSpecularSimulation::~OffSpecularSimulation() override=default
+%feature("docstring")  OffspecSimulation::~OffspecSimulation "OffspecSimulation::~OffspecSimulation() override=default
 ";
 
-%feature("docstring")  OffSpecularSimulation::className "std::string OffSpecularSimulation::className() const final
+%feature("docstring")  OffspecSimulation::className "std::string OffspecSimulation::className() const final
 ";
 
-%feature("docstring")  OffSpecularSimulation::setBeamParameters "void OffSpecularSimulation::setBeamParameters(double wavelength, const IAxis &alpha_axis, double phi_i)
+%feature("docstring")  OffspecSimulation::setBeamParameters "void OffspecSimulation::setBeamParameters(double wavelength, const IAxis &alpha_axis, double phi_i)
 
 Sets beam parameters from here (forwarded to Instrument) 
 ";
 
-%feature("docstring")  OffSpecularSimulation::beamAxis "const IAxis * OffSpecularSimulation::beamAxis() const
+%feature("docstring")  OffspecSimulation::beamAxis "const IAxis * OffspecSimulation::beamAxis() const
 
 Returns axis of the beam. 
 ";
 
-%feature("docstring")  OffSpecularSimulation::intensityMapSize "size_t OffSpecularSimulation::intensityMapSize() const override
+%feature("docstring")  OffspecSimulation::intensityMapSize "size_t OffspecSimulation::intensityMapSize() const override
 
 Returns the total number of the intensity values in the simulation result. 
 ";
 
-%feature("docstring")  OffSpecularSimulation::createCoordSystem "ICoordSystem * OffSpecularSimulation::createCoordSystem() const override
+%feature("docstring")  OffspecSimulation::createCoordSystem "ICoordSystem * OffspecSimulation::createCoordSystem() const override
 ";
 
 
@@ -2332,10 +2332,10 @@ Prints an axis.
 // File: ISimulation2D_8h.xml
 
 
-// File: OffSpecularSimulation_8cpp.xml
+// File: OffspecSimulation_8cpp.xml
 
 
-// File: OffSpecularSimulation_8h.xml
+// File: OffspecSimulation_8h.xml
 
 
 // File: ScatteringSimulation_8cpp.xml
diff --git a/auto/Wrap/libBornAgainSim.py b/auto/Wrap/libBornAgainSim.py
index 3b249549a63..d1bdac02df5 100644
--- a/auto/Wrap/libBornAgainSim.py
+++ b/auto/Wrap/libBornAgainSim.py
@@ -3451,7 +3451,7 @@ class ISimulation2D(ISimulation):
 
     Abstract base class of simulations that generate 2D patterns.
 
-    Base class of  OffSpecularSimulation and  ScatteringSimulation.
+    Base class of  OffspecSimulation and  ScatteringSimulation.
 
     Holds the common implementations for simulations with a 2D detector.
 
@@ -3745,7 +3745,7 @@ class SpecularSimulation(ISimulation):
 # Register SpecularSimulation in _libBornAgainSim:
 _libBornAgainSim.SpecularSimulation_swigregister(SpecularSimulation)
 
-class OffSpecularSimulation(ISimulation2D):
+class OffspecSimulation(ISimulation2D):
     r"""
 
 
@@ -3753,7 +3753,7 @@ class OffSpecularSimulation(ISimulation2D):
 
     Holds an instrument and sample model. Computes reflected and scattered intensity as function of incident and final glancing angle.
 
-    C++ includes: OffSpecularSimulation.h
+    C++ includes: OffspecSimulation.h
 
     """
 
@@ -3762,54 +3762,54 @@ class OffSpecularSimulation(ISimulation2D):
 
     def __init__(self, *args):
         r"""
-        __init__(OffSpecularSimulation self, Beam const & beam, MultiLayer const & sample, IDetector2D const & detector) -> OffSpecularSimulation
-        __init__(OffSpecularSimulation self) -> OffSpecularSimulation
-        OffSpecularSimulation::OffSpecularSimulation()
+        __init__(OffspecSimulation self, Beam const & beam, MultiLayer const & sample, IDetector2D const & detector) -> OffspecSimulation
+        __init__(OffspecSimulation self) -> OffspecSimulation
+        OffspecSimulation::OffspecSimulation()
 
         """
-        _libBornAgainSim.OffSpecularSimulation_swiginit(self, _libBornAgainSim.new_OffSpecularSimulation(*args))
-    __swig_destroy__ = _libBornAgainSim.delete_OffSpecularSimulation
+        _libBornAgainSim.OffspecSimulation_swiginit(self, _libBornAgainSim.new_OffspecSimulation(*args))
+    __swig_destroy__ = _libBornAgainSim.delete_OffspecSimulation
 
     def className(self):
         r"""
-        className(OffSpecularSimulation self) -> std::string
-        std::string OffSpecularSimulation::className() const final
+        className(OffspecSimulation self) -> std::string
+        std::string OffspecSimulation::className() const final
 
         """
-        return _libBornAgainSim.OffSpecularSimulation_className(self)
+        return _libBornAgainSim.OffspecSimulation_className(self)
 
     def setBeamParameters(self, wavelength, alpha_axis, phi_i):
         r"""
-        setBeamParameters(OffSpecularSimulation self, double wavelength, IAxis alpha_axis, double phi_i)
-        void OffSpecularSimulation::setBeamParameters(double wavelength, const IAxis &alpha_axis, double phi_i)
+        setBeamParameters(OffspecSimulation self, double wavelength, IAxis alpha_axis, double phi_i)
+        void OffspecSimulation::setBeamParameters(double wavelength, const IAxis &alpha_axis, double phi_i)
 
         Sets beam parameters from here (forwarded to Instrument) 
 
         """
-        return _libBornAgainSim.OffSpecularSimulation_setBeamParameters(self, wavelength, alpha_axis, phi_i)
+        return _libBornAgainSim.OffspecSimulation_setBeamParameters(self, wavelength, alpha_axis, phi_i)
 
     def beamAxis(self):
         r"""
-        beamAxis(OffSpecularSimulation self) -> IAxis
-        const IAxis * OffSpecularSimulation::beamAxis() const
+        beamAxis(OffspecSimulation self) -> IAxis
+        const IAxis * OffspecSimulation::beamAxis() const
 
         Returns axis of the beam. 
 
         """
-        return _libBornAgainSim.OffSpecularSimulation_beamAxis(self)
+        return _libBornAgainSim.OffspecSimulation_beamAxis(self)
 
     def intensityMapSize(self):
         r"""
-        intensityMapSize(OffSpecularSimulation self) -> size_t
-        size_t OffSpecularSimulation::intensityMapSize() const override
+        intensityMapSize(OffspecSimulation self) -> size_t
+        size_t OffspecSimulation::intensityMapSize() const override
 
         Returns the total number of the intensity values in the simulation result. 
 
         """
-        return _libBornAgainSim.OffSpecularSimulation_intensityMapSize(self)
+        return _libBornAgainSim.OffspecSimulation_intensityMapSize(self)
 
-# Register OffSpecularSimulation in _libBornAgainSim:
-_libBornAgainSim.OffSpecularSimulation_swigregister(OffSpecularSimulation)
+# Register OffspecSimulation in _libBornAgainSim:
+_libBornAgainSim.OffspecSimulation_swigregister(OffspecSimulation)
 
 class IBackground(libBornAgainBase.ICloneable, libBornAgainParam.INode):
     r"""
diff --git a/auto/Wrap/libBornAgainSim_wrap.cpp b/auto/Wrap/libBornAgainSim_wrap.cpp
index aa8aeac7ae9..eab6ceb271c 100644
--- a/auto/Wrap/libBornAgainSim_wrap.cpp
+++ b/auto/Wrap/libBornAgainSim_wrap.cpp
@@ -3125,7 +3125,7 @@ namespace Swig {
 #define SWIGTYPE_p_IntensityFunctionSqrt swig_types[25]
 #define SWIGTYPE_p_IterationInfo swig_types[26]
 #define SWIGTYPE_p_MultiLayer swig_types[27]
-#define SWIGTYPE_p_OffSpecularSimulation swig_types[28]
+#define SWIGTYPE_p_OffspecSimulation swig_types[28]
 #define SWIGTYPE_p_ParameterDistribution swig_types[29]
 #define SWIGTYPE_p_PoissonBackground swig_types[30]
 #define SWIGTYPE_p_PyBuilderCallback swig_types[31]
@@ -6707,7 +6707,7 @@ SWIGINTERN void std_vector_Sl_std_pair_Sl_double_Sc_double_Sg__Sg__insert__SWIG_
 #include "Sim/Scan/ScanResolution.h"
 #include "Sim/Simulation/DepthProbeSimulation.h"
 #include "Sim/Simulation/ScatteringSimulation.h"
-#include "Sim/Simulation/OffSpecularSimulation.h"
+#include "Sim/Simulation/OffspecSimulation.h"
 #include "Sim/Simulation/SpecularSimulation.h"
 
 SWIGINTERN Vec3< double > Vec3_Sl_double_Sg____add__(Vec3< double > const *self,Vec3< double > const &rhs){
@@ -38862,7 +38862,7 @@ SWIGINTERN PyObject *SpecularSimulation_swiginit(PyObject *SWIGUNUSEDPARM(self),
   return SWIG_Python_InitShadowInstance(args);
 }
 
-SWIGINTERN PyObject *_wrap_new_OffSpecularSimulation__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) {
+SWIGINTERN PyObject *_wrap_new_OffspecSimulation__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) {
   PyObject *resultobj = 0;
   Beam *arg1 = 0 ;
   MultiLayer *arg2 = 0 ;
@@ -38873,64 +38873,64 @@ SWIGINTERN PyObject *_wrap_new_OffSpecularSimulation__SWIG_0(PyObject *SWIGUNUSE
   int res2 = 0 ;
   void *argp3 = 0 ;
   int res3 = 0 ;
-  OffSpecularSimulation *result = 0 ;
+  OffspecSimulation *result = 0 ;
   
   if ((nobjs < 3) || (nobjs > 3)) SWIG_fail;
   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1, SWIGTYPE_p_Beam,  0  | 0);
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_OffSpecularSimulation" "', argument " "1"" of type '" "Beam const &""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_OffspecSimulation" "', argument " "1"" of type '" "Beam const &""'"); 
   }
   if (!argp1) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_OffSpecularSimulation" "', argument " "1"" of type '" "Beam const &""'"); 
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_OffspecSimulation" "', argument " "1"" of type '" "Beam const &""'"); 
   }
   arg1 = reinterpret_cast< Beam * >(argp1);
   res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_MultiLayer,  0  | 0);
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_OffSpecularSimulation" "', argument " "2"" of type '" "MultiLayer const &""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_OffspecSimulation" "', argument " "2"" of type '" "MultiLayer const &""'"); 
   }
   if (!argp2) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_OffSpecularSimulation" "', argument " "2"" of type '" "MultiLayer const &""'"); 
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_OffspecSimulation" "', argument " "2"" of type '" "MultiLayer const &""'"); 
   }
   arg2 = reinterpret_cast< MultiLayer * >(argp2);
   res3 = SWIG_ConvertPtr(swig_obj[2], &argp3, SWIGTYPE_p_IDetector2D,  0  | 0);
   if (!SWIG_IsOK(res3)) {
-    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "new_OffSpecularSimulation" "', argument " "3"" of type '" "IDetector2D const &""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "new_OffspecSimulation" "', argument " "3"" of type '" "IDetector2D const &""'"); 
   }
   if (!argp3) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_OffSpecularSimulation" "', argument " "3"" of type '" "IDetector2D const &""'"); 
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_OffspecSimulation" "', argument " "3"" of type '" "IDetector2D const &""'"); 
   }
   arg3 = reinterpret_cast< IDetector2D * >(argp3);
-  result = (OffSpecularSimulation *)new OffSpecularSimulation((Beam const &)*arg1,(MultiLayer const &)*arg2,(IDetector2D const &)*arg3);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OffSpecularSimulation, SWIG_POINTER_NEW |  0 );
+  result = (OffspecSimulation *)new OffspecSimulation((Beam const &)*arg1,(MultiLayer const &)*arg2,(IDetector2D const &)*arg3);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OffspecSimulation, SWIG_POINTER_NEW |  0 );
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_new_OffSpecularSimulation__SWIG_1(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **SWIGUNUSEDPARM(swig_obj)) {
+SWIGINTERN PyObject *_wrap_new_OffspecSimulation__SWIG_1(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **SWIGUNUSEDPARM(swig_obj)) {
   PyObject *resultobj = 0;
-  OffSpecularSimulation *result = 0 ;
+  OffspecSimulation *result = 0 ;
   
   if ((nobjs < 0) || (nobjs > 0)) SWIG_fail;
-  result = (OffSpecularSimulation *)new OffSpecularSimulation();
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OffSpecularSimulation, SWIG_POINTER_NEW |  0 );
+  result = (OffspecSimulation *)new OffspecSimulation();
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_OffspecSimulation, SWIG_POINTER_NEW |  0 );
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_new_OffSpecularSimulation(PyObject *self, PyObject *args) {
+SWIGINTERN PyObject *_wrap_new_OffspecSimulation(PyObject *self, PyObject *args) {
   Py_ssize_t argc;
   PyObject *argv[4] = {
     0
   };
   
-  if (!(argc = SWIG_Python_UnpackTuple(args, "new_OffSpecularSimulation", 0, 3, argv))) SWIG_fail;
+  if (!(argc = SWIG_Python_UnpackTuple(args, "new_OffspecSimulation", 0, 3, argv))) SWIG_fail;
   --argc;
   if (argc == 0) {
-    return _wrap_new_OffSpecularSimulation__SWIG_1(self, argc, argv);
+    return _wrap_new_OffspecSimulation__SWIG_1(self, argc, argv);
   }
   if (argc == 3) {
     int _v;
@@ -38943,35 +38943,35 @@ SWIGINTERN PyObject *_wrap_new_OffSpecularSimulation(PyObject *self, PyObject *a
         int res = SWIG_ConvertPtr(argv[2], 0, SWIGTYPE_p_IDetector2D, SWIG_POINTER_NO_NULL | 0);
         _v = SWIG_CheckState(res);
         if (_v) {
-          return _wrap_new_OffSpecularSimulation__SWIG_0(self, argc, argv);
+          return _wrap_new_OffspecSimulation__SWIG_0(self, argc, argv);
         }
       }
     }
   }
   
 fail:
-  SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'new_OffSpecularSimulation'.\n"
+  SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'new_OffspecSimulation'.\n"
     "  Possible C/C++ prototypes are:\n"
-    "    OffSpecularSimulation::OffSpecularSimulation(Beam const &,MultiLayer const &,IDetector2D const &)\n"
-    "    OffSpecularSimulation::OffSpecularSimulation()\n");
+    "    OffspecSimulation::OffspecSimulation(Beam const &,MultiLayer const &,IDetector2D const &)\n"
+    "    OffspecSimulation::OffspecSimulation()\n");
   return 0;
 }
 
 
-SWIGINTERN PyObject *_wrap_delete_OffSpecularSimulation(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_delete_OffspecSimulation(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  OffSpecularSimulation *arg1 = (OffSpecularSimulation *) 0 ;
+  OffspecSimulation *arg1 = (OffspecSimulation *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject *swig_obj[1] ;
   
   if (!args) SWIG_fail;
   swig_obj[0] = args;
-  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_OffSpecularSimulation, SWIG_POINTER_DISOWN |  0 );
+  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_OffspecSimulation, SWIG_POINTER_DISOWN |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_OffSpecularSimulation" "', argument " "1"" of type '" "OffSpecularSimulation *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_OffspecSimulation" "', argument " "1"" of type '" "OffspecSimulation *""'"); 
   }
-  arg1 = reinterpret_cast< OffSpecularSimulation * >(argp1);
+  arg1 = reinterpret_cast< OffspecSimulation * >(argp1);
   delete arg1;
   resultobj = SWIG_Py_Void();
   return resultobj;
@@ -38980,9 +38980,9 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_OffSpecularSimulation_className(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_OffspecSimulation_className(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  OffSpecularSimulation *arg1 = (OffSpecularSimulation *) 0 ;
+  OffspecSimulation *arg1 = (OffspecSimulation *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject *swig_obj[1] ;
@@ -38990,12 +38990,12 @@ SWIGINTERN PyObject *_wrap_OffSpecularSimulation_className(PyObject *SWIGUNUSEDP
   
   if (!args) SWIG_fail;
   swig_obj[0] = args;
-  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_OffSpecularSimulation, 0 |  0 );
+  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_OffspecSimulation, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OffSpecularSimulation_className" "', argument " "1"" of type '" "OffSpecularSimulation const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OffspecSimulation_className" "', argument " "1"" of type '" "OffspecSimulation const *""'"); 
   }
-  arg1 = reinterpret_cast< OffSpecularSimulation * >(argp1);
-  result = ((OffSpecularSimulation const *)arg1)->className();
+  arg1 = reinterpret_cast< OffspecSimulation * >(argp1);
+  result = ((OffspecSimulation const *)arg1)->className();
   resultobj = SWIG_From_std_string(static_cast< std::string >(result));
   return resultobj;
 fail:
@@ -39003,9 +39003,9 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_OffSpecularSimulation_setBeamParameters(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_OffspecSimulation_setBeamParameters(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  OffSpecularSimulation *arg1 = (OffSpecularSimulation *) 0 ;
+  OffspecSimulation *arg1 = (OffspecSimulation *) 0 ;
   double arg2 ;
   IAxis *arg3 = 0 ;
   double arg4 ;
@@ -39019,28 +39019,28 @@ SWIGINTERN PyObject *_wrap_OffSpecularSimulation_setBeamParameters(PyObject *SWI
   int ecode4 = 0 ;
   PyObject *swig_obj[4] ;
   
-  if (!SWIG_Python_UnpackTuple(args, "OffSpecularSimulation_setBeamParameters", 4, 4, swig_obj)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_OffSpecularSimulation, 0 |  0 );
+  if (!SWIG_Python_UnpackTuple(args, "OffspecSimulation_setBeamParameters", 4, 4, swig_obj)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_OffspecSimulation, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OffSpecularSimulation_setBeamParameters" "', argument " "1"" of type '" "OffSpecularSimulation *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OffspecSimulation_setBeamParameters" "', argument " "1"" of type '" "OffspecSimulation *""'"); 
   }
-  arg1 = reinterpret_cast< OffSpecularSimulation * >(argp1);
+  arg1 = reinterpret_cast< OffspecSimulation * >(argp1);
   ecode2 = SWIG_AsVal_double(swig_obj[1], &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "OffSpecularSimulation_setBeamParameters" "', argument " "2"" of type '" "double""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "OffspecSimulation_setBeamParameters" "', argument " "2"" of type '" "double""'");
   } 
   arg2 = static_cast< double >(val2);
   res3 = SWIG_ConvertPtr(swig_obj[2], &argp3, SWIGTYPE_p_IAxis,  0  | 0);
   if (!SWIG_IsOK(res3)) {
-    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "OffSpecularSimulation_setBeamParameters" "', argument " "3"" of type '" "IAxis const &""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "OffspecSimulation_setBeamParameters" "', argument " "3"" of type '" "IAxis const &""'"); 
   }
   if (!argp3) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "OffSpecularSimulation_setBeamParameters" "', argument " "3"" of type '" "IAxis const &""'"); 
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "OffspecSimulation_setBeamParameters" "', argument " "3"" of type '" "IAxis const &""'"); 
   }
   arg3 = reinterpret_cast< IAxis * >(argp3);
   ecode4 = SWIG_AsVal_double(swig_obj[3], &val4);
   if (!SWIG_IsOK(ecode4)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "OffSpecularSimulation_setBeamParameters" "', argument " "4"" of type '" "double""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "OffspecSimulation_setBeamParameters" "', argument " "4"" of type '" "double""'");
   } 
   arg4 = static_cast< double >(val4);
   (arg1)->setBeamParameters(arg2,(IAxis const &)*arg3,arg4);
@@ -39051,9 +39051,9 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_OffSpecularSimulation_beamAxis(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_OffspecSimulation_beamAxis(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  OffSpecularSimulation *arg1 = (OffSpecularSimulation *) 0 ;
+  OffspecSimulation *arg1 = (OffspecSimulation *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject *swig_obj[1] ;
@@ -39061,12 +39061,12 @@ SWIGINTERN PyObject *_wrap_OffSpecularSimulation_beamAxis(PyObject *SWIGUNUSEDPA
   
   if (!args) SWIG_fail;
   swig_obj[0] = args;
-  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_OffSpecularSimulation, 0 |  0 );
+  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_OffspecSimulation, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OffSpecularSimulation_beamAxis" "', argument " "1"" of type '" "OffSpecularSimulation const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OffspecSimulation_beamAxis" "', argument " "1"" of type '" "OffspecSimulation const *""'"); 
   }
-  arg1 = reinterpret_cast< OffSpecularSimulation * >(argp1);
-  result = (IAxis *)((OffSpecularSimulation const *)arg1)->beamAxis();
+  arg1 = reinterpret_cast< OffspecSimulation * >(argp1);
+  result = (IAxis *)((OffspecSimulation const *)arg1)->beamAxis();
   resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_IAxis, 0 |  0 );
   return resultobj;
 fail:
@@ -39074,9 +39074,9 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_OffSpecularSimulation_intensityMapSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_OffspecSimulation_intensityMapSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  OffSpecularSimulation *arg1 = (OffSpecularSimulation *) 0 ;
+  OffspecSimulation *arg1 = (OffspecSimulation *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject *swig_obj[1] ;
@@ -39084,12 +39084,12 @@ SWIGINTERN PyObject *_wrap_OffSpecularSimulation_intensityMapSize(PyObject *SWIG
   
   if (!args) SWIG_fail;
   swig_obj[0] = args;
-  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_OffSpecularSimulation, 0 |  0 );
+  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_OffspecSimulation, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OffSpecularSimulation_intensityMapSize" "', argument " "1"" of type '" "OffSpecularSimulation const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OffspecSimulation_intensityMapSize" "', argument " "1"" of type '" "OffspecSimulation const *""'"); 
   }
-  arg1 = reinterpret_cast< OffSpecularSimulation * >(argp1);
-  result = ((OffSpecularSimulation const *)arg1)->intensityMapSize();
+  arg1 = reinterpret_cast< OffspecSimulation * >(argp1);
+  result = ((OffspecSimulation const *)arg1)->intensityMapSize();
   resultobj = SWIG_From_size_t(static_cast< size_t >(result));
   return resultobj;
 fail:
@@ -39097,14 +39097,14 @@ fail:
 }
 
 
-SWIGINTERN PyObject *OffSpecularSimulation_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *OffspecSimulation_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *obj;
   if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL;
-  SWIG_TypeNewClientData(SWIGTYPE_p_OffSpecularSimulation, SWIG_NewClientData(obj));
+  SWIG_TypeNewClientData(SWIGTYPE_p_OffspecSimulation, SWIG_NewClientData(obj));
   return SWIG_Py_Void();
 }
 
-SWIGINTERN PyObject *OffSpecularSimulation_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *OffspecSimulation_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   return SWIG_Python_InitShadowInstance(args);
 }
 
@@ -42172,45 +42172,45 @@ static PyMethodDef SwigMethods[] = {
 		""},
 	 { "SpecularSimulation_swigregister", SpecularSimulation_swigregister, METH_O, NULL},
 	 { "SpecularSimulation_swiginit", SpecularSimulation_swiginit, METH_VARARGS, NULL},
-	 { "new_OffSpecularSimulation", _wrap_new_OffSpecularSimulation, METH_VARARGS, "\n"
-		"OffSpecularSimulation(Beam const & beam, MultiLayer const & sample, IDetector2D const & detector)\n"
-		"new_OffSpecularSimulation() -> OffSpecularSimulation\n"
-		"OffSpecularSimulation::OffSpecularSimulation()\n"
+	 { "new_OffspecSimulation", _wrap_new_OffspecSimulation, METH_VARARGS, "\n"
+		"OffspecSimulation(Beam const & beam, MultiLayer const & sample, IDetector2D const & detector)\n"
+		"new_OffspecSimulation() -> OffspecSimulation\n"
+		"OffspecSimulation::OffspecSimulation()\n"
 		"\n"
 		""},
-	 { "delete_OffSpecularSimulation", _wrap_delete_OffSpecularSimulation, METH_O, "\n"
-		"delete_OffSpecularSimulation(OffSpecularSimulation self)\n"
-		"OffSpecularSimulation::~OffSpecularSimulation() override=default\n"
+	 { "delete_OffspecSimulation", _wrap_delete_OffspecSimulation, METH_O, "\n"
+		"delete_OffspecSimulation(OffspecSimulation self)\n"
+		"OffspecSimulation::~OffspecSimulation() override=default\n"
 		"\n"
 		""},
-	 { "OffSpecularSimulation_className", _wrap_OffSpecularSimulation_className, METH_O, "\n"
-		"OffSpecularSimulation_className(OffSpecularSimulation self) -> std::string\n"
-		"std::string OffSpecularSimulation::className() const final\n"
+	 { "OffspecSimulation_className", _wrap_OffspecSimulation_className, METH_O, "\n"
+		"OffspecSimulation_className(OffspecSimulation self) -> std::string\n"
+		"std::string OffspecSimulation::className() const final\n"
 		"\n"
 		""},
-	 { "OffSpecularSimulation_setBeamParameters", _wrap_OffSpecularSimulation_setBeamParameters, METH_VARARGS, "\n"
-		"OffSpecularSimulation_setBeamParameters(OffSpecularSimulation self, double wavelength, IAxis alpha_axis, double phi_i)\n"
-		"void OffSpecularSimulation::setBeamParameters(double wavelength, const IAxis &alpha_axis, double phi_i)\n"
+	 { "OffspecSimulation_setBeamParameters", _wrap_OffspecSimulation_setBeamParameters, METH_VARARGS, "\n"
+		"OffspecSimulation_setBeamParameters(OffspecSimulation self, double wavelength, IAxis alpha_axis, double phi_i)\n"
+		"void OffspecSimulation::setBeamParameters(double wavelength, const IAxis &alpha_axis, double phi_i)\n"
 		"\n"
 		"Sets beam parameters from here (forwarded to Instrument) \n"
 		"\n"
 		""},
-	 { "OffSpecularSimulation_beamAxis", _wrap_OffSpecularSimulation_beamAxis, METH_O, "\n"
-		"OffSpecularSimulation_beamAxis(OffSpecularSimulation self) -> IAxis\n"
-		"const IAxis * OffSpecularSimulation::beamAxis() const\n"
+	 { "OffspecSimulation_beamAxis", _wrap_OffspecSimulation_beamAxis, METH_O, "\n"
+		"OffspecSimulation_beamAxis(OffspecSimulation self) -> IAxis\n"
+		"const IAxis * OffspecSimulation::beamAxis() const\n"
 		"\n"
 		"Returns axis of the beam. \n"
 		"\n"
 		""},
-	 { "OffSpecularSimulation_intensityMapSize", _wrap_OffSpecularSimulation_intensityMapSize, METH_O, "\n"
-		"OffSpecularSimulation_intensityMapSize(OffSpecularSimulation self) -> size_t\n"
-		"size_t OffSpecularSimulation::intensityMapSize() const override\n"
+	 { "OffspecSimulation_intensityMapSize", _wrap_OffspecSimulation_intensityMapSize, METH_O, "\n"
+		"OffspecSimulation_intensityMapSize(OffspecSimulation self) -> size_t\n"
+		"size_t OffspecSimulation::intensityMapSize() const override\n"
 		"\n"
 		"Returns the total number of the intensity values in the simulation result. \n"
 		"\n"
 		""},
-	 { "OffSpecularSimulation_swigregister", OffSpecularSimulation_swigregister, METH_O, NULL},
-	 { "OffSpecularSimulation_swiginit", OffSpecularSimulation_swiginit, METH_VARARGS, NULL},
+	 { "OffspecSimulation_swigregister", OffspecSimulation_swigregister, METH_O, NULL},
+	 { "OffspecSimulation_swiginit", OffspecSimulation_swiginit, METH_VARARGS, NULL},
 	 { "delete_IBackground", _wrap_delete_IBackground, METH_O, "\n"
 		"delete_IBackground(IBackground self)\n"
 		"IBackground::~IBackground() override\n"
@@ -42517,8 +42517,8 @@ static void *_p_DepthProbeSimulationTo_p_ISimulation(void *x, int *SWIGUNUSEDPAR
 static void *_p_SpecularSimulationTo_p_ISimulation(void *x, int *SWIGUNUSEDPARM(newmemory)) {
     return (void *)((ISimulation *)  ((SpecularSimulation *) x));
 }
-static void *_p_OffSpecularSimulationTo_p_ISimulation(void *x, int *SWIGUNUSEDPARM(newmemory)) {
-    return (void *)((ISimulation *) (ISimulation2D *) ((OffSpecularSimulation *) x));
+static void *_p_OffspecSimulationTo_p_ISimulation(void *x, int *SWIGUNUSEDPARM(newmemory)) {
+    return (void *)((ISimulation *) (ISimulation2D *) ((OffspecSimulation *) x));
 }
 static void *_p_AlphaScanTo_p_ISpecularScan(void *x, int *SWIGUNUSEDPARM(newmemory)) {
     return (void *)((ISpecularScan *)  ((AlphaScan *) x));
@@ -42553,8 +42553,8 @@ static void *_p_DepthProbeSimulationTo_p_INode(void *x, int *SWIGUNUSEDPARM(newm
 static void *_p_SpecularSimulationTo_p_INode(void *x, int *SWIGUNUSEDPARM(newmemory)) {
     return (void *)((INode *) (ISimulation *) ((SpecularSimulation *) x));
 }
-static void *_p_OffSpecularSimulationTo_p_INode(void *x, int *SWIGUNUSEDPARM(newmemory)) {
-    return (void *)((INode *) (ISimulation *)(ISimulation2D *) ((OffSpecularSimulation *) x));
+static void *_p_OffspecSimulationTo_p_INode(void *x, int *SWIGUNUSEDPARM(newmemory)) {
+    return (void *)((INode *) (ISimulation *)(ISimulation2D *) ((OffspecSimulation *) x));
 }
 static void *_p_IBackgroundTo_p_INode(void *x, int *SWIGUNUSEDPARM(newmemory)) {
     return (void *)((INode *)  ((IBackground *) x));
@@ -42571,8 +42571,8 @@ static void *_p_ISampleNodeTo_p_INode(void *x, int *SWIGUNUSEDPARM(newmemory)) {
 static void *_p_ScatteringSimulationTo_p_ISimulation2D(void *x, int *SWIGUNUSEDPARM(newmemory)) {
     return (void *)((ISimulation2D *)  ((ScatteringSimulation *) x));
 }
-static void *_p_OffSpecularSimulationTo_p_ISimulation2D(void *x, int *SWIGUNUSEDPARM(newmemory)) {
-    return (void *)((ISimulation2D *)  ((OffSpecularSimulation *) x));
+static void *_p_OffspecSimulationTo_p_ISimulation2D(void *x, int *SWIGUNUSEDPARM(newmemory)) {
+    return (void *)((ISimulation2D *)  ((OffspecSimulation *) x));
 }
 static void *_p_ScanResolutionTo_p_ICloneable(void *x, int *SWIGUNUSEDPARM(newmemory)) {
     return (void *)((ICloneable *)  ((ScanResolution *) x));
@@ -42632,7 +42632,7 @@ static swig_type_info _swigt__p_IntensityFunctionLog = {"_p_IntensityFunctionLog
 static swig_type_info _swigt__p_IntensityFunctionSqrt = {"_p_IntensityFunctionSqrt", "IntensityFunctionSqrt *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_IterationInfo = {"_p_IterationInfo", "IterationInfo *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_MultiLayer = {"_p_MultiLayer", "MultiLayer *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_OffSpecularSimulation = {"_p_OffSpecularSimulation", "OffSpecularSimulation *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_OffspecSimulation = {"_p_OffspecSimulation", "OffspecSimulation *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_ParameterDistribution = {"_p_ParameterDistribution", "ParameterDistribution *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_PoissonBackground = {"_p_PoissonBackground", "PoissonBackground *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_PyBuilderCallback = {"_p_PyBuilderCallback", "PyBuilderCallback *", 0, 0, (void*)0, 0};
@@ -42731,7 +42731,7 @@ static swig_type_info *swig_type_initial[] = {
   &_swigt__p_IntensityFunctionSqrt,
   &_swigt__p_IterationInfo,
   &_swigt__p_MultiLayer,
-  &_swigt__p_OffSpecularSimulation,
+  &_swigt__p_OffspecSimulation,
   &_swigt__p_ParameterDistribution,
   &_swigt__p_PoissonBackground,
   &_swigt__p_PyBuilderCallback,
@@ -42819,18 +42819,18 @@ static swig_cast_info _swigc__p_IDetector2D[] = {  {&_swigt__p_IDetector2D, 0, 0
 static swig_cast_info _swigc__p_IDistribution1D[] = {  {&_swigt__p_IDistribution1D, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_IFootprintFactor[] = {  {&_swigt__p_IFootprintFactor, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_IIntensityFunction[] = {  {&_swigt__p_IntensityFunctionSqrt, _p_IntensityFunctionSqrtTo_p_IIntensityFunction, 0, 0},  {&_swigt__p_IIntensityFunction, 0, 0, 0},  {&_swigt__p_IntensityFunctionLog, _p_IntensityFunctionLogTo_p_IIntensityFunction, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_INode[] = {  {&_swigt__p_INode, 0, 0, 0},  {&_swigt__p_ISimulation2D, _p_ISimulation2DTo_p_INode, 0, 0},  {&_swigt__p_ScatteringSimulation, _p_ScatteringSimulationTo_p_INode, 0, 0},  {&_swigt__p_OffSpecularSimulation, _p_OffSpecularSimulationTo_p_INode, 0, 0},  {&_swigt__p_ISimulation, _p_ISimulationTo_p_INode, 0, 0},  {&_swigt__p_DepthProbeSimulation, _p_DepthProbeSimulationTo_p_INode, 0, 0},  {&_swigt__p_SpecularSimulation, _p_SpecularSimulationTo_p_INode, 0, 0},  {&_swigt__p_IBackground, _p_IBackgroundTo_p_INode, 0, 0},  {&_swigt__p_ConstantBackground, _p_ConstantBackgroundTo_p_INode, 0, 0},  {&_swigt__p_PoissonBackground, _p_PoissonBackgroundTo_p_INode, 0, 0},  {&_swigt__p_ISampleNode, _p_ISampleNodeTo_p_INode, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_INode[] = {  {&_swigt__p_INode, 0, 0, 0},  {&_swigt__p_ISimulation2D, _p_ISimulation2DTo_p_INode, 0, 0},  {&_swigt__p_ScatteringSimulation, _p_ScatteringSimulationTo_p_INode, 0, 0},  {&_swigt__p_OffspecSimulation, _p_OffspecSimulationTo_p_INode, 0, 0},  {&_swigt__p_ISimulation, _p_ISimulationTo_p_INode, 0, 0},  {&_swigt__p_DepthProbeSimulation, _p_DepthProbeSimulationTo_p_INode, 0, 0},  {&_swigt__p_SpecularSimulation, _p_SpecularSimulationTo_p_INode, 0, 0},  {&_swigt__p_IBackground, _p_IBackgroundTo_p_INode, 0, 0},  {&_swigt__p_ConstantBackground, _p_ConstantBackgroundTo_p_INode, 0, 0},  {&_swigt__p_PoissonBackground, _p_PoissonBackgroundTo_p_INode, 0, 0},  {&_swigt__p_ISampleNode, _p_ISampleNodeTo_p_INode, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_IRangedDistribution[] = {  {&_swigt__p_IRangedDistribution, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_IShape2D[] = {  {&_swigt__p_IShape2D, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_ISimulation[] = {  {&_swigt__p_ISimulation2D, _p_ISimulation2DTo_p_ISimulation, 0, 0},  {&_swigt__p_ISimulation, 0, 0, 0},  {&_swigt__p_ScatteringSimulation, _p_ScatteringSimulationTo_p_ISimulation, 0, 0},  {&_swigt__p_OffSpecularSimulation, _p_OffSpecularSimulationTo_p_ISimulation, 0, 0},  {&_swigt__p_DepthProbeSimulation, _p_DepthProbeSimulationTo_p_ISimulation, 0, 0},  {&_swigt__p_SpecularSimulation, _p_SpecularSimulationTo_p_ISimulation, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_ISimulation2D[] = {  {&_swigt__p_ISimulation2D, 0, 0, 0},  {&_swigt__p_ScatteringSimulation, _p_ScatteringSimulationTo_p_ISimulation2D, 0, 0},  {&_swigt__p_OffSpecularSimulation, _p_OffSpecularSimulationTo_p_ISimulation2D, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_ISimulation[] = {  {&_swigt__p_ISimulation2D, _p_ISimulation2DTo_p_ISimulation, 0, 0},  {&_swigt__p_ISimulation, 0, 0, 0},  {&_swigt__p_ScatteringSimulation, _p_ScatteringSimulationTo_p_ISimulation, 0, 0},  {&_swigt__p_OffspecSimulation, _p_OffspecSimulationTo_p_ISimulation, 0, 0},  {&_swigt__p_DepthProbeSimulation, _p_DepthProbeSimulationTo_p_ISimulation, 0, 0},  {&_swigt__p_SpecularSimulation, _p_SpecularSimulationTo_p_ISimulation, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_ISimulation2D[] = {  {&_swigt__p_ISimulation2D, 0, 0, 0},  {&_swigt__p_ScatteringSimulation, _p_ScatteringSimulationTo_p_ISimulation2D, 0, 0},  {&_swigt__p_OffspecSimulation, _p_OffspecSimulationTo_p_ISimulation2D, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_ISpecularScan[] = {  {&_swigt__p_QzScan, _p_QzScanTo_p_ISpecularScan, 0, 0},  {&_swigt__p_AlphaScan, _p_AlphaScanTo_p_ISpecularScan, 0, 0},  {&_swigt__p_ISpecularScan, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_IVarianceFunction[] = {  {&_swigt__p_IVarianceFunction, 0, 0, 0},  {&_swigt__p_VarianceConstantFunction, _p_VarianceConstantFunctionTo_p_IVarianceFunction, 0, 0},  {&_swigt__p_VarianceSimFunction, _p_VarianceSimFunctionTo_p_IVarianceFunction, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_IntensityFunctionLog[] = {  {&_swigt__p_IntensityFunctionLog, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_IntensityFunctionSqrt[] = {  {&_swigt__p_IntensityFunctionSqrt, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_IterationInfo[] = {  {&_swigt__p_IterationInfo, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_MultiLayer[] = {  {&_swigt__p_MultiLayer, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_OffSpecularSimulation[] = {  {&_swigt__p_OffSpecularSimulation, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_OffspecSimulation[] = {  {&_swigt__p_OffspecSimulation, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_ParameterDistribution[] = {  {&_swigt__p_ParameterDistribution, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_PoissonBackground[] = {  {&_swigt__p_PoissonBackground, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_PyBuilderCallback[] = {  {&_swigt__p_PyBuilderCallback, 0, 0, 0},{0, 0, 0, 0}};
@@ -42929,7 +42929,7 @@ static swig_cast_info *swig_cast_initial[] = {
   _swigc__p_IntensityFunctionSqrt,
   _swigc__p_IterationInfo,
   _swigc__p_MultiLayer,
-  _swigc__p_OffSpecularSimulation,
+  _swigc__p_OffspecSimulation,
   _swigc__p_ParameterDistribution,
   _swigc__p_PoissonBackground,
   _swigc__p_PyBuilderCallback,
-- 
GitLab


From 874ae8103216b72f316b0dfd30a3fd01ffb274e1 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Tue, 24 May 2022 12:07:36 +0200
Subject: [PATCH 62/63] rename py example

---
 ...ffSpecularSimulation.py => OffspecSimulation.py} |   0
 Tests/Examples/CMakeLists.txt                       |   2 +-
 ...arSimulation.int.gz => OffspecSimulation.int.gz} | Bin
 3 files changed, 1 insertion(+), 1 deletion(-)
 rename Examples/varia/{OffSpecularSimulation.py => OffspecSimulation.py} (100%)
 rename Tests/ReferenceData/ExamplesMini/varia/{OffSpecularSimulation.int.gz => OffspecSimulation.int.gz} (100%)

diff --git a/Examples/varia/OffSpecularSimulation.py b/Examples/varia/OffspecSimulation.py
similarity index 100%
rename from Examples/varia/OffSpecularSimulation.py
rename to Examples/varia/OffspecSimulation.py
diff --git a/Tests/Examples/CMakeLists.txt b/Tests/Examples/CMakeLists.txt
index f107e467b55..57101300ec9 100644
--- a/Tests/Examples/CMakeLists.txt
+++ b/Tests/Examples/CMakeLists.txt
@@ -190,7 +190,7 @@ run_example(specular/PolarizedSpinAsymmetry)
 run_example(specular/PolarizedSpinFlip)
 
 test_example(varia/DepthProbe 2e-10)
-test_example(varia/OffSpecularSimulation 2e-10)
+test_example(varia/OffspecSimulation 2e-10)
 test_example(varia/AccessingSimulationResults 2e-10)
 run_example(varia/MaterialProfile)
 run_example(varia/MaterialProfileWithParticles)
diff --git a/Tests/ReferenceData/ExamplesMini/varia/OffSpecularSimulation.int.gz b/Tests/ReferenceData/ExamplesMini/varia/OffspecSimulation.int.gz
similarity index 100%
rename from Tests/ReferenceData/ExamplesMini/varia/OffSpecularSimulation.int.gz
rename to Tests/ReferenceData/ExamplesMini/varia/OffspecSimulation.int.gz
-- 
GitLab


From f000fb1e597eaa7935764d50aba39b1a39ddd542 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Tue, 24 May 2022 12:49:52 +0200
Subject: [PATCH 63/63] CI disable Win

---
 .gitlab-ci.yml | 88 +++++++++++++++++++++++++-------------------------
 1 file changed, 44 insertions(+), 44 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 5b2f57f8be0..1b61cdf3969 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -83,50 +83,50 @@ mac12_2:
 # go to the root Git directory, and run:
 # C:\GitLab-Runner\gitlab-runner.exe exec shell --shell pwsh --builds-dir <gitlab build-dir> <job-name>
 
-windows:
-  tags:
-    - Windows
-  stage: build
-  cache:
-  #  key: build-cache
-  #  paths:
-  #    - build/
-  script:
-    - $OPT_DIR = "C:/opt/x64"
-    - $BOOST_DIR = "$OPT_DIR/boost_current"
-    - $BOOST_INCLUDE_DIR = "$BOOST_DIR/include"
-    - $BOOST_LIB_DIR = "$BOOST_DIR/lib"
-    - $QT_MSVC_DIR = "C:/Qt/msvc"
-    - $QTCMake_DIR = "$QT_MSVC_DIR/lib/cmake"
-    - $BUILD_DIR = "build"
-    - echo "# Pythonpath1 <$Env:PYTHONPATH>"
-    - echo "# CI_PRJ_DIR <$Env:CI_PROJECT_DIR>"
-    - $env:PYTHONPATH += "$CI_PROJECT_DIR/build/lib"
-    - echo "# Pythonpath2 <$Env:PYTHONPATH>"
-    # list powershell properties
-    - echo "# Path <$Env:Path>"
-    - echo "# Powershell <$PSHOME>`n  PS Profile <$PROFILE>`n  PS Command-Path <$PSCOMMANDPATH>"
-    # list all environmental variables
-    - 'dir Env:'
-    # make the CMake build directory
-    - if($CI_PIPELINE_SOURCE -eq "schedule") { mkdir -Force $BUILD_DIR; echo "scheduled build" }
-    - if(!(Test-Path -path $BUILD_DIR)) { mkdir -Force $BUILD_DIR; echo "build from scratch" }
-    - cd $BUILD_DIR
-    - Remove-Item CM* -Recurse
-    - pwd
-    # configure, make, test, pack
-    - cmake --version
-    - cmake -G "Visual Studio 16 2019" -A x64 -T host=x64 -DCMAKE_PREFIX_PATH="$OPT_DIR" -DQTDIR="$QT_MSVC_DIR" -DQt5_DIR="$QTCMake_DIR/Qt5" -DQt5Test_DIR="$QTCMake_DIR/Qt5Test" -DCMAKE_INCLUDE_PATH="$BOOST_INCLUDE_DIR" -DCMAKE_LIBRARY_PATH="$BOOST_LIB_DIR" -DBA_PY_PACKAGE=ON -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_CXX_COMPILER="cl.exe" -B. ..
-    - pwd
-    - if($CI_PIPELINE_SOURCE -eq "schedule") { cmake --build . --target clean; echo "redundant target purge done" }
-    - cmake --build . --config Release
-    - ctest -C Release --parallel 8 --output-on-failure
-    - cpack -C Release -B ./winpackage
-  artifacts:
-    paths:
-    - build/winpackage/BornAgain*.exe
-    - build/PythonPackage/py*/wheel/*.whl
-    expire_in: 10 days
+#windows:
+#  tags:
+#    - Windows
+#  stage: build
+#  cache:
+#  #  key: build-cache
+#  #  paths:
+#  #    - build/
+#  script:
+#    - $OPT_DIR = "C:/opt/x64"
+#    - $BOOST_DIR = "$OPT_DIR/boost_current"
+#    - $BOOST_INCLUDE_DIR = "$BOOST_DIR/include"
+#    - $BOOST_LIB_DIR = "$BOOST_DIR/lib"
+#    - $QT_MSVC_DIR = "C:/Qt/msvc"
+#    - $QTCMake_DIR = "$QT_MSVC_DIR/lib/cmake"
+#    - $BUILD_DIR = "build"
+#    - echo "# Pythonpath1 <$Env:PYTHONPATH>"
+#    - echo "# CI_PRJ_DIR <$Env:CI_PROJECT_DIR>"
+#    - $env:PYTHONPATH += "$CI_PROJECT_DIR/build/lib"
+#    - echo "# Pythonpath2 <$Env:PYTHONPATH>"
+#    # list powershell properties
+#    - echo "# Path <$Env:Path>"
+#    - echo "# Powershell <$PSHOME>`n  PS Profile <$PROFILE>`n  PS Command-Path <$PSCOMMANDPATH>"
+#    # list all environmental variables
+#    - 'dir Env:'
+#    # make the CMake build directory
+#    - if($CI_PIPELINE_SOURCE -eq "schedule") { mkdir -Force $BUILD_DIR; echo "scheduled build" }
+#    - if(!(Test-Path -path $BUILD_DIR)) { mkdir -Force $BUILD_DIR; echo "build from scratch" }
+#    - cd $BUILD_DIR
+#    - Remove-Item CM* -Recurse
+#    - pwd
+#    # configure, make, test, pack
+#    - cmake --version
+#    - cmake -G "Visual Studio 16 2019" -A x64 -T host=x64 -DCMAKE_PREFIX_PATH="$OPT_DIR" -DQTDIR="$QT_MSVC_DIR" -DQt5_DIR="$QTCMake_DIR/Qt5" -DQt5Test_DIR="$QTCMake_DIR/Qt5Test" -DCMAKE_INCLUDE_PATH="$BOOST_INCLUDE_DIR" -DCMAKE_LIBRARY_PATH="$BOOST_LIB_DIR" -DBA_PY_PACKAGE=ON -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_CXX_COMPILER="cl.exe" -B. ..
+#    - pwd
+#    - if($CI_PIPELINE_SOURCE -eq "schedule") { cmake --build . --target clean; echo "redundant target purge done" }
+#    - cmake --build . --config Release
+#    - ctest -C Release --parallel 8 --output-on-failure
+#    - cpack -C Release -B ./winpackage
+#  artifacts:
+#    paths:
+#    - build/winpackage/BornAgain*.exe
+#    - build/PythonPackage/py*/wheel/*.whl
+#    expire_in: 10 days
 
 webdoc:
   rules:
-- 
GitLab