Newer
Older
// create a suitable environment
using IModelInterface =
IRefractiveIndexModel<IMediumPropertyModel<IMagneticFieldModel<IMediumModel>>>;
using AtmModel = UniformRefractiveIndex<
MediumPropertyModel<UniformMagneticField<HomogeneousMedium<IModelInterface>>>>;
using EnvType = Environment<AtmModel>;
EnvType env;
CoordinateSystemPtr const& rootCS = env.getCoordinateSystem();
// get the center point
Point const center{rootCS, 0_m, 0_m, 0_m};
// a refractive index for the vacuum
const double ri_{1};
// the constant density
const auto density{19.2_g / cube(1_cm)};
// the composition we use for the homogeneous medium
NuclearComposition const Composition({Code::Nitrogen}, {1.});
// create magnetic field vector
Vector B1(rootCS, 0_T, 0_T, 0.3809_T);
// create a Sphere for the medium
auto Medium = EnvType::createNode<Sphere>(
center, 1_km * std::numeric_limits<double>::infinity());
// set the environment properties
auto const props = Medium->setModelProperties<AtmModel>(ri_, Medium::AirDry1Atm, B1,
density, Composition);
// bind things together
env.getUniverse()->addChild(std::move(Medium));
// get some points

Nikos Karastathis
committed
Point const p0(rootCS, {0_m, 0_m, 0_m});
Point const p1(rootCS, {0_m, 0_m, 1_m});
Point const p2(rootCS, {0_m, 0_m, 2_m});
Point const p3(rootCS, {0_m, 0_m, 3_m});
Point const p4(rootCS, {0_m, 0_m, 4_m});
Point const p5(rootCS, {0_m, 0_m, 5_m});
Point const p6(rootCS, {0_m, 0_m, 6_m});
Point const p7(rootCS, {0_m, 0_m, 7_m});
Point const p8(rootCS, {0_m, 0_m, 8_m});
Point const p9(rootCS, {0_m, 0_m, 9_m});
Point const p10(rootCS, {0_m, 0_m, 10_m});
Point const p30(rootCS, {0_m, 0_m, 30000_m});
// get a unit vector

Nikos Karastathis
committed
Vector<dimensionless_d> const v1(rootCS, {0, 0, 1});
Vector<dimensionless_d> const v2(rootCS, {0, 0, -1});
// get a geometrical path of points

Nikos Karastathis
committed
Path const P1({p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10});
// construct a Straight Propagator given the uniform refractive index environment

Nikos Karastathis
committed
StraightPropagator const SP(env);
// store the outcome of the Propagate method to paths_
auto const paths_ = SP.propagate(p0, p10, 1_m);
// perform checks to paths_ components
for (auto const& path : paths_) {
CHECK((path.propagation_time_ / 1_s) -
(((p10 - p0).getNorm() / constants::c) / 1_s) ==
Approx(0).margin(absMargin));
CHECK(path.average_refractive_index_ == Approx(1));
CHECK(path.refractive_index_source_ == Approx(1));
CHECK(path.refractive_index_destination_ == Approx(1));
CHECK(path.emit_.getComponents() == v1.getComponents());
CHECK(path.receive_.getComponents() == v2.getComponents());
CHECK(path.R_distance_ == 10_m);
CHECK(std::equal(
P1.begin(), P1.end(), path.begin(),
[](Point const& a, Point const& b) { return (a - b).getNorm() / 1_m < 1e-5; }));
}
// get another path to different points
for (auto const& path : paths2_) {
CHECK((path.propagation_time_ / 1_s) -
(((p30 - p0).getNorm() / constants::c) / 1_s) ==
Approx(0).margin(absMargin));
CHECK(path.average_refractive_index_ == Approx(1));
CHECK(path.refractive_index_source_ == Approx(1));
CHECK(path.refractive_index_destination_ == Approx(1));
CHECK(path.R_distance_ == 30000_m);
}
// get a third path using a weird stepsize
for (auto const& path : paths3_) {
CHECK((path.propagation_time_ / 1_s) -
(((p30 - p0).getNorm() / constants::c) / 1_s) ==
Approx(0).margin(absMargin));
CHECK(path.average_refractive_index_ == Approx(1));
CHECK(path.refractive_index_source_ == Approx(1));
CHECK(path.refractive_index_destination_ == Approx(1));
CHECK(path.R_distance_ == 30000_m);
}
CHECK(paths_.size() == 1);
CHECK(paths2_.size() == 1);
CHECK(paths3_.size() == 1);
} // END: SECTION("Straight Propagator w/ Uniform Refractive Index")
SECTION("Straight Propagator w/ Exponential Refractive Index") {
// create an environment with exponential refractive index (n_0 = 1 & lambda = 0)
using ExpoRIndex = ExponentialRefractiveIndex<
HomogeneousMedium<IRefractiveIndexModel<IMediumModel>>>;
using EnvType = Environment<IRefractiveIndexModel<IMediumModel>>;
EnvType env1;
// get another coordinate system
const CoordinateSystemPtr rootCS1 = env1.getCoordinateSystem();
// the center of the earth
Point const center1_{rootCS1, 0_m, 0_m, 0_m};
LengthType const radius_{0_m};
auto Medium1 = EnvType::createNode<Sphere>(
Point{rootCS1, 0_m, 0_m, 0_m}, 1_km * std::numeric_limits<double>::infinity());
auto const props1 = Medium1->setModelProperties<ExpoRIndex>(
1, 0 / 1_m, center1_, radius_, 1_kg / (1_m * 1_m * 1_m),
NuclearComposition({Code::Nitrogen}, {1.}));

Nikos Karastathis
committed
Point const pp0(rootCS1, {0_m, 0_m, 0_m});
Point const pp1(rootCS1, {0_m, 0_m, 1_m});
Point const pp2(rootCS1, {0_m, 0_m, 2_m});
Point const pp3(rootCS1, {0_m, 0_m, 3_m});
Point const pp4(rootCS1, {0_m, 0_m, 4_m});
Point const pp5(rootCS1, {0_m, 0_m, 5_m});
Point const pp6(rootCS1, {0_m, 0_m, 6_m});
Point const pp7(rootCS1, {0_m, 0_m, 7_m});
Point const pp8(rootCS1, {0_m, 0_m, 8_m});
Point const pp9(rootCS1, {0_m, 0_m, 9_m});
Point const pp10(rootCS1, {0_m, 0_m, 10_m});
// get a unit vector
Vector<dimensionless_d> vv1(rootCS1, {0, 0, 1});
Vector<dimensionless_d> vv2(rootCS1, {0, 0, -1});

Nikos Karastathis
committed
Path const PP1({pp0, pp1, pp2, pp3, pp4, pp5, pp6, pp7, pp8, pp9, pp10});
// construct a Straight Propagator given the exponential refractive index environment

Nikos Karastathis
committed
StraightPropagator const SP1(env1);
// store the outcome of Propagate method to paths1_
auto const paths1_ = SP1.propagate(pp0, pp10, 1_m);
// perform checks to paths1_ components (this is just a sketch for now)
for (auto const& path : paths1_) {
CHECK((path.propagation_time_ / 1_s) -
(((pp10 - pp0).getNorm() / constants::c) / 1_s) ==
Approx(0).margin(absMargin));
CHECK(path.average_refractive_index_ == Approx(1));
CHECK(path.refractive_index_source_ == Approx(1));
CHECK(path.refractive_index_destination_ == Approx(1));
CHECK(path.emit_.getComponents() == vv1.getComponents());
CHECK(path.receive_.getComponents() == vv2.getComponents());
CHECK(path.R_distance_ == 10_m);
CHECK(std::equal(
PP1.begin(), PP1.end(), path.begin(),
[](Point const& a, Point const& b) { return (a - b).getNorm() / 1_m < 1e-5; }));
/*
* A second environment with another exponential refractive index
*/
// create an environment with exponential refractive index (n_0 = 2 & lambda = 2)
using ExpoRIndex = ExponentialRefractiveIndex<
HomogeneousMedium<IRefractiveIndexModel<IMediumModel>>>;
using EnvType = Environment<IRefractiveIndexModel<IMediumModel>>;
EnvType env2;
// get another coordinate system
const CoordinateSystemPtr rootCS2 = env2.getCoordinateSystem();
// the center of the earth
Point const center2_{rootCS2, 0_m, 0_m, 0_m};
auto Medium2 = EnvType::createNode<Sphere>(
Point{rootCS2, 0_m, 0_m, 0_m}, 1_km * std::numeric_limits<double>::infinity());
auto const props2 = Medium2->setModelProperties<ExpoRIndex>(
2, 2 / 1_m, center2_, radius_, 1_kg / (1_m * 1_m * 1_m),
NuclearComposition({Code::Nitrogen}, {1.}));
env2.getUniverse()->addChild(std::move(Medium2));
// get some points

Nikos Karastathis
committed
Point const ppp0(rootCS2, {0_m, 0_m, 0_m});
Point const ppp10(rootCS2, {0_m, 0_m, 10_m});

Nikos Karastathis
committed
Vector<dimensionless_d> const vvv1(rootCS2, {0, 0, 1});
Vector<dimensionless_d> const vvv2(rootCS2, {0, 0, -1});
// construct a Straight Propagator given the exponential refractive index environment

Nikos Karastathis
committed
StraightPropagator const SP2(env2);
// store the outcome of Propagate method to paths1_
auto const paths2_ = SP2.propagate(ppp0, ppp10, 1_m);
// perform checks to paths1_ components (this is just a sketch for now)
for (auto const& path : paths2_) {
CHECK((path.propagation_time_ / 1_s) -
((3.177511688_m / (3 * constants::c)) / 1_s) ==
Approx(0).margin(absMargin));
CHECK(path.average_refractive_index_ == Approx(0.210275935));
CHECK(path.refractive_index_source_ == Approx(2));
CHECK(path.refractive_index_destination_ == Approx(4.12231e-09));
CHECK(path.emit_.getComponents() == vvv1.getComponents());
CHECK(path.receive_.getComponents() == vvv2.getComponents());
CHECK(path.R_distance_ == 10_m);
}
CHECK(paths2_.size() == 1);
} // END: SECTION("Straight Propagator w/ Exponential Refractive Index")
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
SECTION("Flat Earth Propagator w/ Uniform Refractive Index") {
// create a suitable environment
using IModelInterface =
IRefractiveIndexModel<IMediumPropertyModel<IMagneticFieldModel<IMediumModel>>>;
using AtmModel = UniformRefractiveIndex<
MediumPropertyModel<UniformMagneticField<HomogeneousMedium<IModelInterface>>>>;
using EnvType = Environment<AtmModel>;
EnvType env;
CoordinateSystemPtr const& rootCS = env.getCoordinateSystem();
// get the center point
Point const center{rootCS, 0_m, 0_m, 0_m};
// a refractive index for the vacuum
const double ri_{1};
// the constant density
const auto density{19.2_g / cube(1_cm)};
// the composition we use for the homogeneous medium
NuclearComposition const Composition({Code::Nitrogen}, {1.});
// create magnetic field vector
Vector B1(rootCS, 0_T, 0_T, 0.3809_T);
// create a Sphere for the medium
auto Medium = EnvType::createNode<Sphere>(center, 1_km);
// set the environment properties
auto const props = Medium->setModelProperties<AtmModel>(ri_, Medium::AirDry1Atm, B1,
density, Composition);
// bind things together
env.getUniverse()->addChild(std::move(Medium));
// get some points
Point const upperBoundary_(rootCS, {0_m, 0_m, 1_km});
Point const p0(rootCS, {0_m, 0_m, 0_m});
Point const p10(rootCS, {0_m, 0_m, 10_m});
// get a unit vector
Vector<dimensionless_d> const v1(rootCS, {0, 0, 1});
Vector<dimensionless_d> const v2(rootCS, {0, 0, -1});
// get a geometrical path of points
Path const P1({p0, p10});
LengthType const step_{1_m};
// construct a Straight Propagator given the uniform refractive index environment
FlatEarthPropagator const SP(env, upperBoundary_, p0, step_);
// store the outcome of the Propagate method to paths_
auto const paths_ = SP.propagate(p0, p10, 1_m);
// perform checks to paths_ components
for (auto const& path : paths_) {
CHECK((path.propagation_time_ / 1_s) -
(((p10 - p0).getNorm() / constants::c) / 1_s) ==
Approx(0));
CHECK(path.average_refractive_index_ == Approx(1));
CHECK(path.refractive_index_source_ == Approx(1));
CHECK(path.refractive_index_destination_ == Approx(1));
CHECK(path.emit_.getComponents() == v1.getComponents());
CHECK(path.receive_.getComponents() == v2.getComponents());
CHECK(path.R_distance_ == 10_m);
CHECK(std::equal(
P1.begin(), P1.end(), path.begin(),
[](Point const& a, Point const& b) { return (a - b).getNorm() / 1_m < 1e-5; }));
}
} // END: SECTION("Flat Earth Propagator w/ Uniform Refractive Index")
} // END: TEST_CASE("Propagators")