Version 2, position dependent E/B, kinetic ions, boris mover, terminator
This commit is contained in:
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#include "blitz/array.h"
|
||||
#include "catch.hpp"
|
||||
#include "generators/binning_generator.h"
|
||||
#include "simulation/parameter.h"
|
||||
|
||||
TEST_CASE("Binning Generator", "[BinningGenerator]") {
|
||||
SECTION("EnergyBinning") {
|
||||
std::string filename = "simulation_config/test_parameter.json";
|
||||
Parameter p(filename);
|
||||
|
||||
GIVEN("An parameter file") {
|
||||
json_path path_to_binning = {"Binning"};
|
||||
EnergyBinning energy =
|
||||
generator::buildEnergyBinningIncludingRedirection(p, path_to_binning);
|
||||
|
||||
THEN("The correct lower bin is set") {
|
||||
REQUIRE(energy.bin(1.1E-6) == 0);
|
||||
REQUIRE(energy.bin(1.0E-7) == -1);
|
||||
}
|
||||
THEN("The correct upper bin is set") {
|
||||
REQUIRE(energy.bin(16000) == energy.numBins() - 1);
|
||||
REQUIRE(energy.bin(21E4) == energy.numBins());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+66
@@ -0,0 +1,66 @@
|
||||
#include "catch.hpp"
|
||||
#include "simulation/coordinates.h"
|
||||
|
||||
TEST_CASE("Coordinates", "[Coordinates]") {
|
||||
SECTION("Cartesian Coordinates") {
|
||||
WHEN("A cartesian Cordinate is created") {
|
||||
blitz::TinyVector<double, 3> c_blitz(0., 1., 3.);
|
||||
CartesianCoordinate c(c_blitz);
|
||||
|
||||
THEN("The correct cartesian entries can be reported") {
|
||||
REQUIRE(c.cartesianEntries()[0] == c_blitz(0));
|
||||
REQUIRE(c.cartesianEntries()[1] == c_blitz(1));
|
||||
REQUIRE(c.cartesianEntries()[2] == c_blitz(2));
|
||||
}
|
||||
|
||||
THEN("The correct cylinder entries can be reported") {
|
||||
REQUIRE(c.cylinderEntries()[0] == 1.);
|
||||
REQUIRE(c.cylinderEntries()[1] == M_PI / 2.);
|
||||
REQUIRE(c.cylinderEntries()[2] == c_blitz(2));
|
||||
}
|
||||
}
|
||||
WHEN("A cordinate is added to itself") {
|
||||
blitz::TinyVector<double, 3> c_blitz(0., 1., 3.);
|
||||
CartesianCoordinate c(c_blitz);
|
||||
c.add(c);
|
||||
|
||||
THEN("double the original cartesian entries are reported") {
|
||||
REQUIRE(c.cartesianEntries()[0] == 2 * c_blitz(0));
|
||||
REQUIRE(c.cartesianEntries()[1] == 2 * c_blitz(1));
|
||||
REQUIRE(c.cartesianEntries()[2] == 2 * c_blitz(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("Cylinder Coordinates") {
|
||||
WHEN("A cylinder Cordinate is created") {
|
||||
blitz::TinyVector<double, 3> c_blitz(1., M_PI / 2., 3.);
|
||||
CylinderCoordinate c(c_blitz);
|
||||
|
||||
THEN("The correct cylinder entries can be reported") {
|
||||
REQUIRE(c.cylinderEntries()[0] == c_blitz(0));
|
||||
REQUIRE(c.cylinderEntries()[1] == c_blitz(1));
|
||||
REQUIRE(c.cylinderEntries()[2] == c_blitz(2));
|
||||
}
|
||||
|
||||
THEN("The correct cartesian entries can be reported") {
|
||||
REQUIRE(c.cartesianEntries()[0] == Approx(0).margin(0.0001));
|
||||
REQUIRE(c.cartesianEntries()[1] == Approx(1.));
|
||||
REQUIRE(c.cartesianEntries()[2] == c_blitz(2));
|
||||
}
|
||||
}
|
||||
|
||||
WHEN("A cordinate is added to itself") {
|
||||
blitz::TinyVector<double, 3> c_blitz(1., 3 * M_PI / 2., 3.);
|
||||
CylinderCoordinate c(c_blitz);
|
||||
c.add(c);
|
||||
THEN(
|
||||
"double the original cartesian entries are reported, exept in "
|
||||
"angle") {
|
||||
REQUIRE(c.cylinderEntries()[0] == 2 * c_blitz(0));
|
||||
REQUIRE(c.cylinderEntries()[1] == Approx(M_PI));
|
||||
REQUIRE(c.cylinderEntries()[2] == 2 * c_blitz(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+67
@@ -0,0 +1,67 @@
|
||||
#include "catch.hpp"
|
||||
#include "generators/function_generator.h"
|
||||
#include "simulation/parameter.h"
|
||||
|
||||
TEST_CASE("Function Generator", "[FunctionGenerator]") {
|
||||
SECTION("function1D") {
|
||||
std::string filename = "simulation_config/test_parameter.json";
|
||||
Parameter p(filename);
|
||||
|
||||
GIVEN("An parameter file and a path to a piecewise linear function") {
|
||||
json_t* obj = p.jsonObjectFromBase({"Functions", "1Dto1D", "f1"});
|
||||
THEN("the correct function is created") {
|
||||
std::function<double(double)> pw = generator::function1D(obj);
|
||||
|
||||
REQUIRE(pw(-1) == 5E-4);
|
||||
REQUIRE(pw(3) == 0.02);
|
||||
}
|
||||
}
|
||||
|
||||
GIVEN("An parameter file and a path to a constant function") {
|
||||
json_t* obj = p.jsonObjectFromBase({"Functions", "1Dto1D", "f2"});
|
||||
THEN("the correct function is created") {
|
||||
std::function<double(double)> co = generator::function1D(obj);
|
||||
|
||||
REQUIRE(co(-1) == 1.);
|
||||
REQUIRE(co(3) == 1.);
|
||||
}
|
||||
}
|
||||
|
||||
GIVEN("An parameter file and a path to a product function") {
|
||||
json_t* obj = p.jsonObjectFromBase({"Functions", "1Dto1D", "f3"});
|
||||
THEN("the correct function is created") {
|
||||
std::function<double(double)> product = generator::function1D(obj);
|
||||
|
||||
REQUIRE(product(-1) == 6);
|
||||
REQUIRE(product(3) == 6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("function3D") {
|
||||
std::string filename = "simulation_config/test_parameter.json";
|
||||
Parameter p(filename);
|
||||
|
||||
GIVEN("An parameter file and a path to a Constant function") {
|
||||
json_t* obj = p.jsonObjectFromBase({"Functions", "3dto1D", "f1"});
|
||||
THEN("the correct function is created") {
|
||||
std::function<double(double, double, double)> co =
|
||||
generator::function3D(obj);
|
||||
|
||||
REQUIRE(co(-1., 1., 0.) == 2.);
|
||||
REQUIRE(co(0., 2., -1.) == 2);
|
||||
}
|
||||
}
|
||||
|
||||
GIVEN("An parameter file and a path to a Product function") {
|
||||
json_t* obj = p.jsonObjectFromBase({"Functions", "3dto1D", "f2"});
|
||||
THEN("the correct function is created") {
|
||||
std::function<double(double, double, double)> product =
|
||||
generator::function3D(obj);
|
||||
|
||||
REQUIRE(product(-1., 1., 0.) == 20E-4);
|
||||
REQUIRE(product(0., 2., 3.) == 0.08);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+56
@@ -0,0 +1,56 @@
|
||||
#include "catch.hpp"
|
||||
#include "functions/functions.h"
|
||||
|
||||
TEST_CASE("Functions Generator", "[Functions]") {
|
||||
SECTION("D1ToD1") {
|
||||
SECTION("PiecewiseLinear") {
|
||||
GIVEN("A piecewise linear function") {
|
||||
std::vector<double> positions = {0, 1, 2, 3};
|
||||
std::vector<double> values = {-1, 1, 1, 2};
|
||||
std::function<double(double)> pw =
|
||||
D1ToD1::PiecewiseLinear(positions, values);
|
||||
|
||||
THEN("Positions below give last value") { REQUIRE(pw(-1) == -1); }
|
||||
THEN("Positions above gile last value") { REQUIRE(pw(5) == 2); }
|
||||
THEN("Positions at given values give given values") {
|
||||
for (int i = 0; i < positions.size(); i++) {
|
||||
REQUIRE(pw(positions[i]) == values[i]);
|
||||
}
|
||||
}
|
||||
THEN("The points in between are calculated correctly") {
|
||||
REQUIRE(pw(0.5) == 0);
|
||||
REQUIRE(pw(1.5) == 1);
|
||||
REQUIRE(pw(2.5) == 1.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
SECTION("Constant") {
|
||||
GIVEN("A constant function") {
|
||||
const double constant = 1.;
|
||||
std::function<double(double)> co = D1ToD1::Constant(constant);
|
||||
THEN("The constant is given back for all values") {
|
||||
REQUIRE(co(1.) == constant);
|
||||
REQUIRE(co(0.4) == constant);
|
||||
REQUIRE(co(-11.) == constant);
|
||||
REQUIRE(co(1E4) == constant);
|
||||
}
|
||||
}
|
||||
}
|
||||
SECTION("Product") {
|
||||
GIVEN("A function product") {
|
||||
std::vector<double> positions = {0, 1, 2, 3};
|
||||
std::vector<double> values = {-1, 1, 1, 2};
|
||||
std::function<double(double)> pw =
|
||||
D1ToD1::PiecewiseLinear(positions, values);
|
||||
|
||||
std::function<double(double)> prod = D1ToD1::Product({pw, pw});
|
||||
|
||||
THEN("The product of the functions is returned") {
|
||||
for (int i = 0; i < positions.size(); i++) {
|
||||
REQUIRE(prod(positions[i]) == pw(positions[i]) * pw(positions[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#include "catch.hpp"
|
||||
|
||||
#include "IO/hdf5_reader.h"
|
||||
#include "IO/hdf5_writer.h"
|
||||
#include "simulation/homebase.h"
|
||||
|
||||
TEST_CASE("Hdf5", "[Hdf5]") {
|
||||
SECTION("Reader and Writing the same data") {
|
||||
std::string directory = BUILD_HOMEBASE_STRING + std::string("/test");
|
||||
std::string filename = "test_output";
|
||||
std::string absolute_filename = directory + filename;
|
||||
|
||||
Hdf5Writer writer(directory, filename);
|
||||
Hdf5Reader reader(directory, filename);
|
||||
|
||||
SECTION("1d data") {
|
||||
blitz::Array<double, 1> data(4);
|
||||
data = 0.1, -0.1, 1.2, 3.0;
|
||||
std::string path_1d = "/1d_double";
|
||||
|
||||
writer.write(data, path_1d);
|
||||
|
||||
blitz::Array<double, 1> read_data = reader.readD1Double(path_1d);
|
||||
|
||||
REQUIRE(read_data.size() == 4);
|
||||
REQUIRE(read_data(0) == data(0));
|
||||
REQUIRE(read_data(1) == data(1));
|
||||
REQUIRE(read_data(2) == data(2));
|
||||
REQUIRE(read_data(3) == data(3));
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include "catch.hpp"
|
||||
|
||||
TEST_CASE("1: All tests cases reside in other .cpp files (empty)",
|
||||
"[multi-file:1]") {}
|
||||
Executable
+434
@@ -0,0 +1,434 @@
|
||||
{
|
||||
"GlobalPositionBinning": {
|
||||
"CylinderBinning": {
|
||||
"Radial": {
|
||||
"NumberOfBins": 15,
|
||||
"MaxRadius": {
|
||||
"value": 4.5,
|
||||
"unit": "cm"
|
||||
}
|
||||
},
|
||||
"Longitudinal": {
|
||||
"NumberOfBins": 160,
|
||||
"MaxLength": {
|
||||
"value": 1600,
|
||||
"unit": "cm"
|
||||
}
|
||||
},
|
||||
"Azimuthal": {
|
||||
"NumberOfBins": 4
|
||||
}
|
||||
}
|
||||
},
|
||||
"SourceGeometry": {
|
||||
"Cylinder": {
|
||||
"Radius": {
|
||||
"value": 4.5,
|
||||
"unit": "cm"
|
||||
},
|
||||
"Height": {
|
||||
"value": 1600,
|
||||
"unit": "cm"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Species": {
|
||||
"Tracked": {
|
||||
"e-": {
|
||||
"ParticleType": "electron",
|
||||
"Mover": {
|
||||
"Boris": {
|
||||
"BorisStepsPerMovementCylce": 10,
|
||||
"MaximalTimestepLength": {
|
||||
"value": 1E-12,
|
||||
"unit": "s"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Terminator": {
|
||||
"MaximumInteractions": 1E6,
|
||||
"MaxTimeAlive": {
|
||||
"value": 1,
|
||||
"unit": "s"
|
||||
},
|
||||
"BoundaryGeometry": {
|
||||
"Cylinder": {
|
||||
"Radius": {
|
||||
"value": 4.5,
|
||||
"unit": "cm"
|
||||
},
|
||||
"Height": {
|
||||
"value": 1600,
|
||||
"unit": "cm"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Reflector": {
|
||||
"ReflectorDPS": {
|
||||
"position_z": {
|
||||
"value": 1600,
|
||||
"unit": "cm"
|
||||
}
|
||||
}
|
||||
},
|
||||
"DensityField": {
|
||||
"DynamicDensityField": {
|
||||
"PositionBinning": {
|
||||
"CreateSameAs": [
|
||||
"GlobalPositionBinning"
|
||||
]
|
||||
},
|
||||
"EnergyBinning": {
|
||||
"Type": "Logarithmic",
|
||||
"NumberOfBins": 100,
|
||||
"MinEnergy": {
|
||||
"value": 1E-6,
|
||||
"unit": "eV"
|
||||
},
|
||||
"MaxEnergy": {
|
||||
"value": 20E3,
|
||||
"unit": "eV"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"VelocityDistribution": {
|
||||
"null": {}
|
||||
},
|
||||
"DriftVelocity": {
|
||||
"null": {}
|
||||
},
|
||||
"Loggers": {
|
||||
"Deletion": {
|
||||
"Type": "all"
|
||||
}
|
||||
},
|
||||
"CurrentCollector": {
|
||||
"PositionBinning": {
|
||||
"CreateSameAs": [
|
||||
"GlobalPositionBinning"
|
||||
]
|
||||
}
|
||||
},
|
||||
"Interactions": {
|
||||
"free": {
|
||||
"Type": "FreeMovement"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Injector": {
|
||||
"CreatedSpecies": {
|
||||
"specie1": {
|
||||
"TrackedSpecieName": "e-",
|
||||
"CreationVelocityDistribution": {
|
||||
"VelocityDistributionFromFunction": {
|
||||
"VelocityDistributionFunction": {
|
||||
"DirectedDistribution": {
|
||||
"EnergyDistributionFunction": {
|
||||
"Constant": {
|
||||
"constant": {
|
||||
"value": 1,
|
||||
"unit": "eV"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Mass": {
|
||||
"FromParticleType": "electron"
|
||||
},
|
||||
"Direction": {
|
||||
"vector": [0,0,1]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"EventPositionDistribution": {
|
||||
"ScalarField": {
|
||||
"ScalarFieldFunctionInZ": {
|
||||
"zFunction": {
|
||||
"Product": {
|
||||
"fi": {
|
||||
"Constant": {
|
||||
"constant": 1
|
||||
}
|
||||
},
|
||||
"fj": {
|
||||
"Constant": {
|
||||
"constant": 1
|
||||
}
|
||||
},
|
||||
"fk": {
|
||||
"PiecewiseLinear": {
|
||||
"xValues": [
|
||||
0,
|
||||
1.43,
|
||||
3,
|
||||
8,
|
||||
13,
|
||||
14.57,
|
||||
16
|
||||
],
|
||||
"yValues": [
|
||||
5E-4,
|
||||
0.002,
|
||||
0.02,
|
||||
1,
|
||||
0.02,
|
||||
0.002,
|
||||
5E-4
|
||||
],
|
||||
"prefactor": 1E15
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"DensityLimit": {
|
||||
"min": 0,
|
||||
"max": 1E15
|
||||
},
|
||||
"PositionLimits": {
|
||||
"rPosition": {
|
||||
"min": 0,
|
||||
"max": 0.045
|
||||
},
|
||||
"phiPosition": {
|
||||
"min": 0,
|
||||
"max": 6.28318530718
|
||||
},
|
||||
"zPosition": {
|
||||
"min": 8,
|
||||
"max": 8.01
|
||||
}
|
||||
}
|
||||
},
|
||||
"MotherDriftVelocity": {
|
||||
"VectorField": {
|
||||
"VectorFieldConstant": {
|
||||
"constant": {
|
||||
"vector": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
"unit": "m/s"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Activity": {
|
||||
"value": 1E15,
|
||||
"unit": "Bq"
|
||||
}
|
||||
},
|
||||
"ElectricField": {
|
||||
"Background": {
|
||||
"VectorField": {
|
||||
"VectorFieldConstant": {
|
||||
"constant": {
|
||||
"vector": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
"unit": "V/m"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Dynamic": {
|
||||
"VectorField": {
|
||||
"VectorFieldConstant": {
|
||||
"constant": {
|
||||
"vector": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
"unit": "V/m"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"MagneticField": {
|
||||
"VectorField": {
|
||||
"VectorFieldFunctionInZ": {
|
||||
"zFunction": {
|
||||
"Constant3D": {
|
||||
"constant": 2.5
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"PoissonSolver": {
|
||||
"UseInSimulation": "false"
|
||||
},
|
||||
"Simulation": {
|
||||
"SimulatedEvents": 1,
|
||||
"EventStride": 1
|
||||
},
|
||||
"Output": {
|
||||
"folder": "output",
|
||||
"filename": "test",
|
||||
"DensityFields": {
|
||||
"Species": "all",
|
||||
"Intervall": 1,
|
||||
"OverwriteLast": "true"
|
||||
},
|
||||
"CurrentBorders": {
|
||||
"Species": [
|
||||
"e-",
|
||||
"T2+"
|
||||
],
|
||||
"Intervall": "EachSync",
|
||||
"OverwriteLast": "true"
|
||||
},
|
||||
"DeletionLogger": {
|
||||
"Species": [
|
||||
"all"
|
||||
],
|
||||
"Intervall": "EachSync",
|
||||
"OverwriteLast": "true"
|
||||
}
|
||||
},
|
||||
"RandomNumbers": {
|
||||
"Seed": 1337
|
||||
},
|
||||
"Functions": {
|
||||
"1Dto1D": {
|
||||
"f1": {
|
||||
"PiecewiseLinear": {
|
||||
"xValues": [
|
||||
0,
|
||||
1.43,
|
||||
3,
|
||||
8,
|
||||
13,
|
||||
14.57,
|
||||
16
|
||||
],
|
||||
"yValues": [
|
||||
5E-4,
|
||||
0.002,
|
||||
0.02,
|
||||
1,
|
||||
0.02,
|
||||
0.002,
|
||||
5E-4
|
||||
],
|
||||
"prefactor": 1
|
||||
}
|
||||
},
|
||||
"f2": {
|
||||
"Constant": {
|
||||
"constant": 1
|
||||
}
|
||||
},
|
||||
"f3": {
|
||||
"Product": [
|
||||
{
|
||||
"Constant": {
|
||||
"constant": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"Constant": {
|
||||
"constant": 3
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"3dto1D": {
|
||||
"f1": {
|
||||
"Constant3D": {
|
||||
"constant": 2
|
||||
}
|
||||
},
|
||||
"f2": {
|
||||
"Product": {
|
||||
"fi": {
|
||||
"Constant": {
|
||||
"constant": 2
|
||||
}
|
||||
},
|
||||
"fj": {
|
||||
"Constant": {
|
||||
"constant": 2
|
||||
}
|
||||
},
|
||||
"fk": {
|
||||
"PiecewiseLinear": {
|
||||
"xValues": [
|
||||
0,
|
||||
1.43,
|
||||
3,
|
||||
8,
|
||||
13,
|
||||
14.57,
|
||||
16
|
||||
],
|
||||
"yValues": [
|
||||
5E-4,
|
||||
0.002,
|
||||
0.02,
|
||||
1,
|
||||
0.02,
|
||||
0.002,
|
||||
5E-4
|
||||
],
|
||||
"prefactor": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"VectorFields": {
|
||||
"field1": {
|
||||
"VectorFieldConstant": {
|
||||
"Constant": {
|
||||
"vector": [
|
||||
1,
|
||||
2,
|
||||
3
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"field2": {
|
||||
"VectorFieldFunctionInZ": {
|
||||
"zFunction": {
|
||||
"Constant3D": {
|
||||
"constant": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"field3": {
|
||||
"VectorFieldFromArray": {},
|
||||
"stepSize": {
|
||||
"SameAs": "Binning"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ScalarFields": {
|
||||
"field1": {
|
||||
"ScalarFieldFunctionInZ": {
|
||||
"zFunction": {
|
||||
"Constant3D": {
|
||||
"constant": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user