From 0f7c4a1596d4df3bfa7a19c5eb09484654b57391 Mon Sep 17 00:00:00 2001
From: Walter Van Herck <w.van.herck@fz-juelich.de>
Date: Wed, 20 Jun 2012 17:16:08 +0200
Subject: [PATCH] Added some classes for experiment description

---
 Core/Algorithms/inc/Experiment.h            | 47 +++++++++++++++++++++
 Core/Algorithms/inc/ISimulation.h           |  3 --
 Core/Algorithms/src/Experiment.cpp          | 25 +++++++++++
 Core/Core.pro                               |  3 ++
 Core/Samples/inc/InterferenceFunctionNone.h | 30 +++++++++++++
 Core/Samples/inc/NanoParticleDecorator.h    | 13 +++++-
 Core/Samples/src/NanoParticleDecorator.cpp  | 27 ++++++++++++
 Core/Tools/inc/INamed.h                     |  2 +-
 8 files changed, 145 insertions(+), 5 deletions(-)
 create mode 100644 Core/Algorithms/inc/Experiment.h
 create mode 100644 Core/Algorithms/src/Experiment.cpp
 create mode 100644 Core/Samples/inc/InterferenceFunctionNone.h

diff --git a/Core/Algorithms/inc/Experiment.h b/Core/Algorithms/inc/Experiment.h
new file mode 100644
index 00000000000..07fbac6e75a
--- /dev/null
+++ b/Core/Algorithms/inc/Experiment.h
@@ -0,0 +1,47 @@
+#ifndef EXPERIMENT_H_
+#define EXPERIMENT_H_
+// ********************************************************************
+// * The BornAgain project                                            *
+// * Simulation of neutron and x-ray scattering at grazing incidence  *
+// *                                                                  *
+// * LICENSE AND DISCLAIMER                                           *
+// * Lorem ipsum dolor sit amet, consectetur adipiscing elit.  Mauris *
+// * eget quam orci. Quisque  porta  varius  dui,  quis  posuere nibh *
+// * mollis quis. Mauris commodo rhoncus porttitor.                   *
+// ********************************************************************
+//! @file   ISimulation.h
+//! @brief  Definition of ISimulation class
+//! @author Scientific Computing Group at FRM II
+//! @date   01.04.2012
+
+#include "ISample.h"
+#include "OutputData.h"
+
+class Experiment
+{
+public:
+	Experiment();
+	Experiment(ISample *p_sample);
+    virtual ~Experiment() {}
+
+    /// Run a simulation with the current parameter settings
+    void runSimulation();
+
+    /// Set the sample to be tested
+    void setSample(ISample *p_sample);
+
+    /// Set data structure that will contain the intensity map on the detector
+    void setOutputData(OutputData<double> *p_data);
+
+protected:
+    ISample *mp_sample;
+//    Detector *mp_detector;
+//    Beam *mp_beam;
+    OutputData<double> *mp_intensity_map;
+};
+
+
+
+
+
+#endif /* EXPERIMENT_H_ */
diff --git a/Core/Algorithms/inc/ISimulation.h b/Core/Algorithms/inc/ISimulation.h
index 2b75991087e..f7aeb336a11 100644
--- a/Core/Algorithms/inc/ISimulation.h
+++ b/Core/Algorithms/inc/ISimulation.h
@@ -20,10 +20,7 @@ class ISimulation
 public:
     virtual ~ISimulation() {}
     void run();
- //    void setOutputData(OutputData* p_data) { mp_output_data = p_data; }
 
-protected:
-//     OutputData* mp_output_data;
 };
 
 #endif // ISIMULATION_H
diff --git a/Core/Algorithms/src/Experiment.cpp b/Core/Algorithms/src/Experiment.cpp
new file mode 100644
index 00000000000..806adbfbdf0
--- /dev/null
+++ b/Core/Algorithms/src/Experiment.cpp
@@ -0,0 +1,25 @@
+#include "Experiment.h"
+
+Experiment::Experiment()
+: mp_sample(0)
+{
+}
+
+Experiment::Experiment(ISample* p_sample)
+: mp_sample(p_sample)
+{
+}
+
+void Experiment::runSimulation()
+{
+}
+
+void Experiment::setSample(ISample* p_sample)
+{
+	mp_sample = p_sample;  ///< Not owned by Experiment
+}
+
+void Experiment::setOutputData(OutputData<double>* p_data)
+{
+	mp_intensity_map = p_data;  ///< Not owned by Experiment
+}
diff --git a/Core/Core.pro b/Core/Core.pro
index beae65e3c5d..3df2ceaa6c4 100644
--- a/Core/Core.pro
+++ b/Core/Core.pro
@@ -13,6 +13,7 @@ SOURCES += \
     Algorithms/src/DWBADiffuseReflection.cpp \
     Algorithms/src/DWBAFormFactor.cpp \
     Algorithms/src/DWBAFormFactorConstZ.cpp \
+    Algorithms/src/Experiment.cpp \
     Algorithms/src/OpticalFresnel.cpp \
     \
     Samples/src/FormFactorCylinder.cpp \
@@ -48,6 +49,7 @@ HEADERS += \
     Algorithms/inc/DWBADiffuseReflection.h \
     Algorithms/inc/DWBAFormFactor.h \
     Algorithms/inc/DWBAFormFactorConstZ.h \
+    Algorithms/inc/Experiment.h \
     Algorithms/inc/ISimulation.h \
     Algorithms/inc/OpticalFresnel.h \
     \
@@ -60,6 +62,7 @@ HEADERS += \
     Samples/inc/IInterferenceFunction.h \
     Samples/inc/IMaterial.h \
     Samples/inc/InterferenceFunction1DParaCrystal.h \
+    Samples/inc/InterferenceFunctionNone.h \
     Samples/inc/IRoughness.h \
     Samples/inc/ISample.h \
     Samples/inc/Layer.h \
diff --git a/Core/Samples/inc/InterferenceFunctionNone.h b/Core/Samples/inc/InterferenceFunctionNone.h
new file mode 100644
index 00000000000..1053b74e08a
--- /dev/null
+++ b/Core/Samples/inc/InterferenceFunctionNone.h
@@ -0,0 +1,30 @@
+#ifndef INTERFERENCEFUNCTIONNONE_H_
+#define INTERFERENCEFUNCTIONNONE_H_
+// ********************************************************************
+// * The BornAgain project                                            *
+// * Simulation of neutron and x-ray scattering at grazing incidence  *
+// *                                                                  *
+// * LICENSE AND DISCLAIMER                                           *
+// * Lorem ipsum dolor sit amet, consectetur adipiscing elit.  Mauris *
+// * eget quam orci. Quisque  porta  varius  dui,  quis  posuere nibh *
+// * mollis quis. Mauris commodo rhoncus porttitor.                   *
+// ********************************************************************
+//! @file   InterferenceFunctionNone.h
+//! @brief  Definition of InterferenceFunctionNone class
+//! @author herck
+//! @date   19.06.2012
+
+#include "IInterferenceFunction.h"
+
+class InterferenceFunctionNone : public IInterferenceFunction
+{
+public:
+	InterferenceFunctionNone() {}
+	virtual ~InterferenceFunctionNone() {}
+
+	virtual double evaluate(kvector_t q) const { return 1.0; }
+};
+
+
+
+#endif /* INTERFERENCEFUNCTIONNONE_H_ */
diff --git a/Core/Samples/inc/NanoParticleDecorator.h b/Core/Samples/inc/NanoParticleDecorator.h
index fe6184197b6..0af6bda02b1 100644
--- a/Core/Samples/inc/NanoParticleDecorator.h
+++ b/Core/Samples/inc/NanoParticleDecorator.h
@@ -15,6 +15,7 @@
 //! @date   23.05.2012
 
 #include "NanoParticle.h"
+#include "IInterferenceFunction.h"
 
 //- -------------------------------------------------------------------
 //! @class NanoParticleDecorator
@@ -24,15 +25,25 @@ class NanoParticleDecorator : public ISample
 {
 public:
 	NanoParticleDecorator(ISample *p_sub_sample);
+	NanoParticleDecorator(ISample *p_sub_sample, NanoParticle *p_particle);
+	NanoParticleDecorator(ISample *p_sub_sample, NanoParticle *p_particle, IInterferenceFunction *p_interference_function);
 	virtual ~NanoParticleDecorator() {}
 
 	/// Return decorated sample
 	ISample* getSubSample() const { return mp_sub_sample; }
 
+	/// Add nano particle
+	void addNanoParticle(NanoParticle *p_particle) { m_particles.push_back(p_particle); }
+
+	/// Get number of particles
+	size_t getNumberOfParticles() { return m_particles.size(); }
+
+	/// Set interference function
+	void setInterferenceFunction(IInterferenceFunction *p_interference_function);
 private:
 	std::vector<NanoParticle *> m_particles;  ///< Vector of the types of nano particles
+	IInterferenceFunction *mp_interference_function;  ///< Currently only a scalar interference function (instead of matrix)
     ISample* mp_sub_sample;                   ///< Decorated ISample object
-
 };
 
 
diff --git a/Core/Samples/src/NanoParticleDecorator.cpp b/Core/Samples/src/NanoParticleDecorator.cpp
index f5a63804bc7..65ff484a16c 100644
--- a/Core/Samples/src/NanoParticleDecorator.cpp
+++ b/Core/Samples/src/NanoParticleDecorator.cpp
@@ -6,4 +6,31 @@ NanoParticleDecorator::NanoParticleDecorator(ISample *p_sub_sample)
 {
 }
 
+NanoParticleDecorator::NanoParticleDecorator(ISample* p_sub_sample,
+		NanoParticle* p_particle)
+: mp_sub_sample(p_sub_sample)
+{
+	addNanoParticle(p_particle);
+}
+
+NanoParticleDecorator::NanoParticleDecorator(ISample* p_sub_sample,
+		NanoParticle* p_particle,
+		IInterferenceFunction* p_interference_function)
+: mp_sub_sample(p_sub_sample)
+{
+	addNanoParticle(p_particle);
+	setInterferenceFunction(p_interference_function);
+}
+
+void NanoParticleDecorator::setInterferenceFunction(
+		IInterferenceFunction* p_interference_function)
+{
+	if (mp_interference_function!=p_interference_function) {
+		delete mp_interference_function;
+		mp_interference_function = p_interference_function;
+	}
+}
+
+
+
 /* ************************************************************************* */
diff --git a/Core/Tools/inc/INamed.h b/Core/Tools/inc/INamed.h
index 92491845d65..73b7d2e2622 100644
--- a/Core/Tools/inc/INamed.h
+++ b/Core/Tools/inc/INamed.h
@@ -19,7 +19,7 @@
 
 //- -------------------------------------------------------------------
 //! @class INamed
-//! @brief Definition of INamed class for all objects havint the name
+//! @brief Definition of INamed class for all objects having a name
 //- -------------------------------------------------------------------
 class INamed
 {
-- 
GitLab