-
Notifications
You must be signed in to change notification settings - Fork 0
/
simulationthread.h
105 lines (87 loc) · 3.23 KB
/
simulationthread.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#ifndef SIMULATIONTHREAD_H
#define SIMULATIONTHREAD_H
#include <QMutex>
#include <QMutexLocker>
#include <QThread>
#include <QWaitCondition>
#include <cmath>
#include <complex>
#include <random>
#include <vector>
#include <utility>
#include <QSlider>
#include <collideableobject.h>
#include <kerrrotationgraph.h>
#include <pem.h>
#include <polarisingfilter.h>
#include <ray.h>
#include <sampleobject.h>
#include <threedimentionalvisualisation.h>
#include <Loop_graph.h>
typedef std::vector<Eigen::Matrix<std::complex<double>, 2, 2, 0, 2, 2>>
ListMatrix4cd;
/*!
* \brief The SimulationThread class
*
* This defines the thread that the simulation will run in and the core simulatation's
* method, without implementation.
*/
class SimulationThread : public QThread {
Q_OBJECT
public:
SimulationThread(QObject *parent = nullptr);
~SimulationThread() override;
void simulate(double Q_r, double Q_i, double n0_r, double n0_i,
kerrRotationGraph &graph, ThreeDimentionalVisualisation &rep, Loop_graph &loop_graph);
void safeAbort();
protected:
void run() override;
public slots:
void incrementPEMTimeProgression();
void fireNextRay();
void angleOfIncidenceChanged(double angle);
void newLaserNoise(std::normal_distribution<> d, std::mt19937 gen);
void newLaserNoiseState(int state);
void newPemState(int state);
void newPolariserState(int state);
void newPemNoise(std::normal_distribution<> d, std::mt19937 gen);
void newPemNoiseState(int state);
void newHValue(double my);
void newPolarisationTarget(Eigen::Vector2d target);
private:
int laserNoise = 0;
QMutex mutex;
QWaitCondition condition;
bool restart, abort;
Eigen::Vector3d emissionPosition = Eigen::Vector3d(0.0, -5.0, 0.0);
Eigen::Vector3d emissionDirection = Eigen::Vector3d(1.0, 1.0, 0.0);
std::normal_distribution<> emissionNoiseDist;
std::mt19937 emissionNoiseGen;
std::complex<double> m_q, m_n_1;
SampleObject *sample = nullptr;
PEM *pem = nullptr;
PolarisingFilter *polarisingFilter = nullptr;
std::vector<CollideableObject *> m_objectsInScene;
SampleObject *setupSample(std::complex<double> n1, std::complex<double> q,
kerrRotationGraph &graph,
ThreeDimentionalVisualisation &rep);
PolarisingFilter *setupPolariser(Eigen::Vector2d targetPolarisation,
ThreeDimentionalVisualisation &rep,
Loop_graph &loop_graph);
PEM *setupPEM(std::complex<double> amplitude, std::complex<double> phase,
ThreeDimentionalVisualisation &rep);
Matrix4cd generateInitalPolarisation();
void trace(ListMatrix4cd &outputList,
std::vector<CollideableObject *> &objectsInScene, int &rayCount);
void castRay(Ray &ray, std::vector<CollideableObject *> &objectsInScene,
int &depth);
signals:
void emittedNewRay(Matrix4cd polarisation);
void emittedNewRayFromAnalyiser(Matrix4cd polarisation);
void emittedNewRayFromLaser(Ray ray);
void newPositions(Eigen::Vector3d analyiserPosition,
Eigen::Vector3d rayDirection,
std::vector<CollideableObject *> objectsInScene);
void simComplete(ListMatrix4cd &polarisations);
};
#endif // SIMULATIONTHREAD_H