GOAT (Geometrical optics application tool) 0.1
Loading...
Searching...
No Matches
inel_calc.h
Go to the documentation of this file.
1
2#pragma once
3#include <complex>
4#include <math.h>
5#include "vector.h"
6#ifdef WITH_SUPERGITTER
7#include "superarray.h"
8#endif
9#include "grid.h"
10#include "plane.h"
11#include <cfloat>
12namespace GOAT
13{
14 namespace raytracing
15 {
16 // Berechnet den Punkt ix,iy eines Einstrahlgrids, welches sich im Abstand r
17 // unter einem Winkel theta,phi vor dem Partikel befindet
18 maths::Vector<double> startpunkt(int ix, int iy, grid& git,
19 double r, double theta, double phi);
20
21 // Berechnet den Punkt ix,iy eines Einstrahlgrids, welches sich
22 // unter einem Winkel theta,phi direkt vor dem Partikel befindet
24 double theta, double phi);
25
26 // Dreht den Vektor vein um theta und um phi
28
29 // Dreht den Vektor vein um phi
31
32 // Gibt den Ursprung eines Einstrahlgrids wieder, dessen Mittelpunkt um
33 // Winkel theta,phi gedreht wurde und das urspr�nglich um dr �ber der Ebene
34 // z = git.zmax lag. Wird in der Routine startpunkt benoetigt
35 maths::Vector<double> ursprungrot(double dr, double theta, double phi,
37 grid &git);
38
39 // Berechnet die eigentliche Strahlverfolgung im grid git bei Einstrahlung
40 // an dem Startpunkt p0 in Richtung k0
41
42
43 #ifdef WITH_SUPERGITTER
44#define SGN(x) (x<0) ? -1 : (x>0)
46
47 //
48
49
51
53 #endif
61 // maths::Vector<double> pnext(maths::Vector<double> p0, maths::Vector<double> k0, maths::Vector<double> d);
62
63
64 /* ------------------------------ IMPLEMENTATION ---------------------------- */
65
66#define NUM_EPS 1E-10
67
69 {
70 double lambdax, lambday, lambdaz, lambda;
71 // double signx, signy, signz;
72 double sx, sy, sz;
74
75 if (currentIndex[0] == -1)
76 {
77
78 INDEX_TYPE nx = (p0[0] + git.r0) / git.d[0];
79 INDEX_TYPE ny = (p0[1] + git.r0) / git.d[1];
80 INDEX_TYPE nz = (p0[2] + git.r0) / git.d[2];
81
82 currentIndex = GOAT::maths::Vector<INDEX_TYPE>(nx, ny, nz);
83 }
84
85 int signx = SGN(k0[0]);
86 int signy = SGN(k0[1]);
87 int signz = SGN(k0[2]);
88 index[0] = currentIndex[0] + signx;
89 index[1] = currentIndex[1] + signy;
90 index[2] = currentIndex[2] + signz;
91
92 lambdax = (index[0] * git.d[0] - p0[0] - git.r0) / k0[0];
93 lambday = (index[1] * git.d[1] - p0[1] - git.r0) / k0[1];
94 lambdaz = (index[2] * git.d[2] - p0[2] - git.r0) / k0[2];
95
96 // fabs avoids question after k0[i]=0 which can result into -inf !
97 int i = 0;
98 if (fabs(lambdax) < fabs(lambday))
99 lambda = lambdax;
100 else
101 {
102 lambda = lambday;
103 i = 1;
104 }
105 if (fabs(lambdaz) < lambda)
106 {
107 lambda = lambdaz;
108 i = 2;
109
110 }
111 currentIndex[i] = index[i];
112 return p0 + lambda * k0;
113
114 }
115
117 {
118 double lambdax = DBL_MAX;
119 double lambday = DBL_MAX;
120 double lambdaz = DBL_MAX, lambda;
121 // double signx, signy, signz;
122 double sx, sy, sz;
124
125 // if (currentIndex[0] == -1)
126 {
127
128 INDEX_TYPE nx = (p0[0] + git.r0) / git.d[0];
129 INDEX_TYPE ny = (p0[1] + git.r0) / git.d[1];
130 INDEX_TYPE nz = (p0[2] + git.r0) / git.d[2];
131
132 currentIndex = GOAT::maths::Vector<INDEX_TYPE>(nx, ny, nz);
133 }
134
135 int signx = SGN(k0[0]);
136 int signy = SGN(k0[1]);
137 int signz = SGN(k0[2]);
138 index[0] = currentIndex[0] + signx;
139 index[1] = currentIndex[1] + signy;
140 index[2] = currentIndex[2] + signz;
141
142 if (k0[0] != 0) lambdax = ((double)index[0] * git.d[0] - p0[0] - git.r0) / k0[0];
143 if (k0[1] != 0) lambday = ((double)index[1] * git.d[1] - p0[1] - git.r0) / k0[1];
144 if (k0[2] != 0) lambdaz = ((double)index[2] * git.d[2] - p0[2] - git.r0) / k0[2];
145
146 // std::cout << "pnext: " << p0<< ":" << k0 << "/" << lambdax << "," << lambday << "," << lambdaz << std::endl;
147 int i = 0;
148 if ((lambdax < lambday) && (lambdax > 10.0*DBL_MIN))
149 lambda = lambdax;
150 else
151 {
152 lambda = lambday;
153 i = 1;
154 }
155 if ((lambdaz < lambda) && (lambdaz > 10.0 * DBL_MIN) || lambda < 10.0 * DBL_MIN)
156 {
157 lambda = lambdaz;
158 i = 2;
159
160 }
161 currentIndex[i] = index[i];
162 //std::cout << "currentIndex=" << currentIndex << std::endl;
163 return p0 + lambda * k0;
164 }
165 /*
166 maths::Vector<double> pnext(maths::Vector<double> p0, maths::Vector<double> k0, maths::Vector<double> d)
167 {
168 double lambdax, lambday, lambdaz, lambda;
169 double signx, signy, signz;
170 double sx, sy, sz;
171
172 signx = SGN(k0[0]);
173 signy = SGN(k0[1]);
174 signz = SGN(k0[2]);
175
176 int nx = floor(p0[0] / d[0]) + signx;
177 int ny = floor(p0[1] / d[1]) + signy;
178 int nz = floor(p0[2] / d[2]) + signz;
179
180 lambdax = (nx * d[0] - p0[0] ) / k0[0];
181 lambday = (ny * d[1] - p0[1] ) / k0[1];
182 lambdaz = (nz * d[2] - p0[2] ) / k0[2];
183
184 // fabs avoids question after k0[i]=0 which can result into -inf !
185 if (fabs(lambdax) < fabs(lambday))
186 lambda = lambdax;
187 else
188 lambda = lambday;
189 if (fabs(lambdaz) < lambda)
190 lambda = lambdaz;
191 return p0 + lambda * k0;
192 }*/
193
194 }
195}
Template class for threedimensional vectors.
Definition vector.h:57
Template class to store arbitrary information in a 3D-grid This template class provides a virtual 3D-...
Definition superarray.h:26
double r0
Radius of the calculation sphere.
Definition superarray.h:159
maths::Vector< double > d
Edge length of one cell in x-, y- and z-direction.
Definition superarray.h:158
This class provides a grid used for inelastic scattering calculation.
Definition grid.h:23
Raytracer used for ultrashort pulse calculation with raytracing only.
Definition asphericLens.h:6
maths::Vector< double > ursprungrot(double dr, double theta, double phi, maths::Vector< double > &exrot, maths::Vector< double > &eyrot, grid &git)
long long int INDEX_TYPE
Definition superarray.h:16
maths::Vector< double > drehvektor(maths::Vector< double > vein, double theta, double phi)
maths::Vector< double > startpunkt(int ix, int iy, grid &git, double r, double theta, double phi)
maths::Vector< double > pnext(maths::Vector< double > p0, maths::Vector< double > k0, maths::Vector< double > d, double eps=1E-50)
maths::Vector< double > drehphivektor(maths::Vector< double > vein, double phi)
This class is used for the iray class. This class is intended for internal use only....
Definition fresnel.h:7
This file contains the Vector template class and some useful functions around this class.