24 static constexpr
double INCLINATION_LIMIT = M_PI_2 + 1e-10;
26 Beam::Beam(
double wavelength,
double alpha,
double phi,
double intensity)
27 : m_wavelength(wavelength), m_alpha(alpha), m_phi(phi), m_intensity(intensity)
30 registerParameter(
"Wavelength", &m_wavelength).setUnit(
"nm").setNonnegative();
31 registerParameter(
"InclinationAngle", &m_alpha).setUnit(
"rad").setLimited(0, INCLINATION_LIMIT);
32 registerParameter(
"AzimuthalAngle", &m_phi).setUnit(
"rad").setLimited(-M_PI_2, M_PI_2);
33 registerParameter(
"Intensity", &m_intensity).setNonnegative();
34 registerVector(
"BlochVector", &m_bloch_vector,
"");
37 Beam Beam::horizontalBeam()
39 return Beam(1.0, 0.0, 0.0, 1.0);
42 Beam::Beam(
const Beam& other)
43 :
Beam(other.m_wavelength, other.m_alpha, other.m_phi, other.m_intensity)
45 m_bloch_vector = other.m_bloch_vector;
46 setName(other.getName());
47 if (other.m_shape_factor) {
48 m_shape_factor.reset(other.m_shape_factor->clone());
49 registerChild(m_shape_factor.get());
53 Beam& Beam::operator=(
const Beam& other)
55 m_wavelength = other.m_wavelength;
56 m_alpha = other.m_alpha;
58 m_intensity = other.m_intensity;
59 m_bloch_vector = other.m_bloch_vector;
60 setName(other.getName());
61 if (other.m_shape_factor) {
62 m_shape_factor.reset(other.m_shape_factor->clone());
63 registerChild(m_shape_factor.get());
65 m_shape_factor.release();
69 Beam::~Beam() =
default;
78 if (wavelength <= 0.0)
80 "Beam::setCentralK() -> Error. Wavelength can't be negative or zero.");
83 "Beam::setCentralK() -> Error. Inclination angle alpha_i can't be negative.");
84 m_wavelength = wavelength;
91 return m_shape_factor.get();
96 m_shape_factor.reset(shape_factor.clone());
97 registerChild(m_shape_factor.get());
103 throw std::runtime_error(
"Error in Beam::setWidthRatio: footprint factor is nullptr. "
104 "Probably, you have forgotten to initialize it.");
105 m_shape_factor->setWidthRatio(width_ratio);
110 if (bloch_vector.
mag() > 1.0) {
112 "Beam::setPolarization: "
113 "The given Bloch vector cannot represent a real physical ensemble");
115 m_bloch_vector = bloch_vector;
120 return m_bloch_vector;
125 Eigen::Matrix2cd result;
126 double x = m_bloch_vector.
x();
127 double y = m_bloch_vector.
y();
128 double z = m_bloch_vector.
z();
129 result(0, 0) = (1.0 + z) / 2.0;
130 result(0, 1) = complex_t(x, -y) / 2.0;
131 result(1, 0) = complex_t(x, y) / 2.0;
132 result(1, 1) = (1.0 - z) / 2.0;
139 return {m_shape_factor.get()};
Defines the macro ASSERT.
BasicVector3D< double > vecOfLambdaAlphaPhi(double _lambda, double _alpha, double _phi)
Creates a vector<double> as a wavevector with given wavelength and angles.
Defines complex_t, and a few elementary functions.
Defines many exception classes in namespace Exceptionss.
Defines M_PI and some more mathematical constants.
Defines class RealParameter.
double mag() const
Returns magnitude of the vector.
T z() const
Returns z-component in cartesian coordinate system.
T y() const
Returns y-component in cartesian coordinate system.
T x() const
Returns x-component in cartesian coordinate system.
Beam defined by wavelength, direction and intensity.
void setWidthRatio(double width_ratio)
Sets beam to sample width ratio in footprint factor.
void setPolarization(const kvector_t bloch_vector)
Sets the polarization density matrix according to the given Bloch vector.
Eigen::Matrix2cd getPolarization() const
Returns the polarization density matrix (in spin basis along z-axis)
const IFootprintFactor * footprintFactor() const
Returns footprint factor.
void setFootprintFactor(const IFootprintFactor &shape_factor)
Sets footprint factor to the beam.
kvector_t getCentralK() const
Returns the wavevector.
std::vector< const INode * > getChildren() const override
Returns a vector of children (const).
void setCentralK(double wavelength, double alpha_i, double phi_i)
Sets the wavevector in terms of wavelength and incoming angles.