Compare commits
52
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
375ab23008 | ||
|
|
532bdf7979 | ||
|
|
2439f4fca9 | ||
|
|
90d19b0cb7 | ||
|
|
6c1dd8887b | ||
|
|
14c203c2f2 | ||
|
|
bd867fb788 | ||
|
|
6d5f18222a | ||
|
|
32f882a2c5 | ||
|
|
fb19d9ae83 | ||
|
|
f01ff652c9 | ||
|
|
9c999dabbb | ||
|
|
0902d3d7ac | ||
|
|
903423da61 | ||
|
|
03854339ca | ||
|
|
8696517336 | ||
|
|
36f85ea79f | ||
|
|
2114b93f89 | ||
|
|
dcad5b1e61 | ||
|
|
57b90ddbc8 | ||
|
|
863110a281 | ||
|
|
59acd0c1c3 | ||
|
|
d399706159 | ||
|
|
cbf95aceb6 | ||
|
|
9e50d8bdcf | ||
|
|
3d3eff1bca | ||
|
|
f5e278281c | ||
|
|
ca4fb23423 | ||
|
|
b3bf076c1d | ||
|
|
b9ad0ce666 | ||
|
|
faedddb328 | ||
|
|
4849667211 | ||
|
|
6486cf9da4 | ||
|
|
53a2f90d5f | ||
|
|
d48f917dac | ||
|
|
30982bd4f6 | ||
|
|
93aa336ec9 | ||
|
|
e291b3f880 | ||
|
|
5ac64c4da8 | ||
|
|
80fdfb6dc5 | ||
|
|
e0c0b19b69 | ||
|
|
b8f8110aca | ||
|
|
4cfc7d51c2 | ||
|
|
4afc3382a1 | ||
|
|
26e96df5df | ||
|
|
ad313d25a2 | ||
|
|
5f08b9775c | ||
|
|
f79172b454 | ||
|
|
45d4556394 | ||
|
|
f2d4ad3525 | ||
|
|
b7a65dd8fe | ||
|
|
71dc3f4ada |
@@ -1 +1,6 @@
|
|||||||
.vscode
|
.vscode
|
||||||
|
.idea
|
||||||
|
|
||||||
|
build
|
||||||
|
bin
|
||||||
|
output
|
||||||
@@ -6,7 +6,7 @@ listed with package names in the file REQUIRED. Other distributions might have
|
|||||||
slightly different package names. After installing all external dependencies
|
slightly different package names. After installing all external dependencies
|
||||||
using the package manager of your distribution the compilation of KARL is
|
using the package manager of your distribution the compilation of KARL is
|
||||||
straight forward. First provide the path of the current working directory as an
|
straight forward. First provide the path of the current working directory as an
|
||||||
environment variable, eg. through:
|
environment variable named "HOMEBASE", eg. through:
|
||||||
|
|
||||||
$ export HOMEBASE=$(pwd)
|
$ export HOMEBASE=$(pwd)
|
||||||
|
|
||||||
@@ -19,22 +19,79 @@ in the current working directory. If any library is not available in the system
|
|||||||
wide include or library path you might have to edit the settings in
|
wide include or library path you might have to edit the settings in
|
||||||
config/config.mk.
|
config/config.mk.
|
||||||
|
|
||||||
|
If either Jansson or Blitz++ are not available via packages the config/config.mk
|
||||||
|
file includes the option for those libraries to be built on their own.
|
||||||
|
To do that, the MAKE_* (e.g. MAKE_BLITZ) variable has to be set to "true" before the
|
||||||
|
make call. Depending on the status of MAKE_BLITZ and MAKE_JANSSON the include
|
||||||
|
and lib paths are set automatically to the self-built libraries or the system
|
||||||
|
libraries.
|
||||||
|
|
||||||
|
Compiling the libraries requires autoconf, automake, libtool and python
|
||||||
|
|
||||||
START OF A SIMULATION:
|
START OF A SIMULATION:
|
||||||
|
|
||||||
The simulation needs a JSON file that describes the physical and numerical
|
The simulation needs a JSON file that describes the physical and numerical
|
||||||
parameters of the simulation. One such file is provided with the source code
|
parameters of the simulation. One such file is provided with the source code
|
||||||
(simulation_config/test_parameter.json).
|
(simulation_config/test_parameter.json).
|
||||||
The JSON file also contains the location for the simulation output. The default
|
The JSON file also contains the location for the simulation output. Before
|
||||||
directory for this is /tmp which only works for simulations on a single node.
|
running on a cluster you should
|
||||||
Before running on a cluster you should
|
|
||||||
|
|
||||||
edit the JSON file, adjust "folder" and "filename" in the "Output" section.
|
edit the JSON file, adjust "folder" and "filename" in the "Output" section.
|
||||||
|
|
||||||
You can then start the simulation using
|
You can then start the simulation using
|
||||||
|
|
||||||
$ mpiexec -n 4 bin/karl --parameter_file=simulation_config/test_parameter.json
|
$ mpiexec -n 4 bin/karl --parameter_file simulation_config/test_parameter.json
|
||||||
|
|
||||||
You can of course specify some other number of MPI threads or use a different
|
You can of course specify some other number of MPI threads or use a different
|
||||||
JSON file. If you have to use some non-standard method to start MPI programs
|
JSON file. If you have to use some non-standard method to start MPI programs
|
||||||
(such as poe) instead of mpiexec you might need to check the relevant
|
(such as poe) instead of mpiexec you might need to check the relevant
|
||||||
documentation.
|
documentation.
|
||||||
|
|
||||||
|
ANALYSIS OF THE SIMULATION OUTPUT:
|
||||||
|
Python scripts are provided to analyze the output of the simulation. They can be
|
||||||
|
found in the folder "analysis". The script require the python packages
|
||||||
|
numpy, matplotlib, scipy and h5py.
|
||||||
|
|
||||||
|
An example of how to use the analysis scripts is provided in the file "analysis/plot_example.py".
|
||||||
|
|
||||||
|
INPUT OF THE SIMULATION (JSON files):
|
||||||
|
In the simulation_config/ subdirectory some example files for the general input of
|
||||||
|
a simulation are given.
|
||||||
|
|
||||||
|
The two files "parameter_katrin_example.json" and "test_parameter.json" are two
|
||||||
|
complete examples, that can be used to start a simulation.
|
||||||
|
The "parameter_katrin_example.json" file describes the setup for the
|
||||||
|
simulation of the KATRIN WGTS and "test_parameter.json" is a generic test case example.
|
||||||
|
|
||||||
|
The other provided JSON files are meant to explain the structure and show the possible
|
||||||
|
options that can be chosen for some of the more complex elements required in a parameter
|
||||||
|
file and can not be used as input for a simulation.
|
||||||
|
E.g. "scattering_angle_example.json" shows the four different types of
|
||||||
|
scattering angle distributions that can be used in the code and how they are to be
|
||||||
|
structured in a working parameter file.
|
||||||
|
|
||||||
|
INPUT OF THE SIMULATION (HDF5 files):
|
||||||
|
For several groups in the JSON input file it is possible to read data from an external
|
||||||
|
HDF5 file, these groups are those that specify a Vector Field, Function or a Scattering Angle Distribution.
|
||||||
|
|
||||||
|
For the Scattering Angle Distribution it is necessary that the HDF5 files contain the
|
||||||
|
three objects "energies(eV)", "angles(rad)" and "cross_sections(m-2)". The first two
|
||||||
|
both have to be one dimensional arrays, containing the energies in eV and angles in rad
|
||||||
|
where the cross sections are defined respectivley. The thrid key has to contain a
|
||||||
|
two-dimensional array containing the actual values of the cross section in m^2, with the
|
||||||
|
first dimension being the energy and the second dimension being the angle.
|
||||||
|
|
||||||
|
In case of the Vector Field or the Function the structure of the input HDF5 file
|
||||||
|
is not as rigid, since the keys to the specific objects in the file have to be provided
|
||||||
|
in the JSON object.
|
||||||
|
The necessary structure in the JSON file for these two types types
|
||||||
|
of objects can either be found in the provided example JSON files or in the comments
|
||||||
|
in the corresponding generator files (i.e. "include/generators/vector_field_generator.h"
|
||||||
|
and "include/generators/function_generator.h").
|
||||||
|
|
||||||
|
|
||||||
|
NOTES:
|
||||||
|
Kommentare in den files: position_binning.*, current_collector.*, kinematic.*, sim_constants.h, mover.*, simulation_output.*, functions.*, injector_generator.h, ionization.h, recombination.cpp und species_generator überprüfen lassen
|
||||||
|
|
||||||
|
für interactions.cpp: mehr Kommentare zum source code (i.e. zur Berechnung?)
|
||||||
|
für cross_sections.h: Referenzen mit reinschreiben?
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ def tubeCurrentVsZ(filename, path_to_species, output_period="LastSyncPeriod"):
|
|||||||
areas_in_r = radialAreas(filename, path_to_species)
|
areas_in_r = radialAreas(filename, path_to_species)
|
||||||
current_in_r = radialCurrent(filename, path_to_species, output_period)
|
current_in_r = radialCurrent(filename, path_to_species, output_period)
|
||||||
particles = current_in_r * areas_in_r
|
particles = current_in_r * areas_in_r
|
||||||
return (np.sum(particles, axis=(1)) / np.sum(areas_in_r, axis=(1)))[-1, :]
|
return (np.sum(particles, axis=(1)) / np.sum(areas_in_r, axis=(1)))[-2, :]
|
||||||
|
|
||||||
|
|
||||||
def densityVsZ(filename, path_to_species, output_period="LastSyncPeriod"):
|
def densityVsZ(filename, path_to_species, output_period="LastSyncPeriod"):
|
||||||
@@ -261,7 +261,7 @@ def plotLongitudinalParticleCurrentVsZ(filename, path_to_species, plot_axis, out
|
|||||||
z_bins = zBinsDensityField(filename, path_to_species)
|
z_bins = zBinsDensityField(filename, path_to_species)
|
||||||
plot_axis.plot(z_bins, current_in_z, label=str(path_to_species))
|
plot_axis.plot(z_bins, current_in_z, label=str(path_to_species))
|
||||||
plot_axis.set_xlabel(r"Distance to rear wall $z$ (m)")
|
plot_axis.set_xlabel(r"Distance to rear wall $z$ (m)")
|
||||||
plot_axis.set_ylabel(r"Particle current $j$ ($m^{-3}s^{-1}$)")
|
plot_axis.set_ylabel(r"Particle current $j$ ($m^{-2}s^{-1}$)")
|
||||||
|
|
||||||
|
|
||||||
def plotAllLongitudinalParticleCurrentVsZ(filename, output_period, specie_keys, output_folder):
|
def plotAllLongitudinalParticleCurrentVsZ(filename, output_period, specie_keys, output_folder):
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import plot_densities as pd
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
filename_simulation_output = input("Enter filename of simulation output: ")
|
||||||
|
output_folder = input("Enter output folder: ")
|
||||||
|
|
||||||
|
species = pd.getSpecies(filename_simulation_output)
|
||||||
|
|
||||||
|
pd.plotAllDensityVsZ(filename_simulation_output, "LastSyncPeriod", species, output_folder)
|
||||||
|
pd.plotAllSpectrumAtZ(filename_simulation_output, 8, "LastSyncPeriod", species, output_folder)
|
||||||
+24
-17
@@ -1,27 +1,32 @@
|
|||||||
# Debugging
|
# Debugging
|
||||||
DO_DEBUGGING = true
|
DO_DEBUGGING = false
|
||||||
DEBUG_LEVEL = 3
|
DEBUG_LEVEL = 0
|
||||||
|
|
||||||
# Timer
|
# Timer
|
||||||
USE_TIMER = true
|
USE_TIMER = false
|
||||||
|
|
||||||
# Catch
|
# Catch
|
||||||
CATCH_DIR = $(HOMEBASE)/external/catch
|
CATCH_DIR = $(HOMEBASE)/external/catch
|
||||||
CATCH_INCLUDES = -I$(CATCH_DIR)
|
CATCH_INCLUDES = -I$(CATCH_DIR)
|
||||||
|
|
||||||
|
|
||||||
# Blitz
|
# Blitz
|
||||||
MAKE_BLITZ = false
|
MAKE_BLITZ = false
|
||||||
|
|
||||||
BLITZ_DIR = $(HOMEBASE)/external/blitz/build/
|
ifeq ($(MAKE_BLITZ), true)
|
||||||
BLITZ_INC_DIR = $(BLITZ_DIR)include/
|
BLITZ_DIR = $(HOMEBASE)/external/blitz/build
|
||||||
BLITZ_LIB_DIR = $(BLITZ_DIR)lib/
|
BLITZ_INC_DIR = $(BLITZ_DIR)/include
|
||||||
|
BLITZ_LIB_DIR = $(BLITZ_DIR)/lib
|
||||||
|
else
|
||||||
|
BLITZ_INC_DIR = /usr/include
|
||||||
|
BLITZ_LIB_DIR = /usr/lib/x86_64-linux-gnu
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
BLITZ_INCLUDES = -I$(BLITZ_INC_DIR)
|
BLITZ_INCLUDES = -I$(BLITZ_INC_DIR)
|
||||||
BLITZ_LIBS = -L$(BLITZ_LIB_DIR) -lblitz -lm
|
BLITZ_LIBS = -lblitz -lm -L$(BLITZ_LIB_DIR)
|
||||||
|
|
||||||
# HDF5
|
# HDF5
|
||||||
MAKE_H5 = false
|
|
||||||
|
|
||||||
#HDF5_DIR = /usr/include/hdf5/
|
#HDF5_DIR = /usr/include/hdf5/
|
||||||
HDF5P_INC_DIR = /usr/include/hdf5/openmpi/
|
HDF5P_INC_DIR = /usr/include/hdf5/openmpi/
|
||||||
HDF5P_LIB_DIR = /usr/lib/x86_64-linux-gnu/hdf5/openmpi/
|
HDF5P_LIB_DIR = /usr/lib/x86_64-linux-gnu/hdf5/openmpi/
|
||||||
@@ -29,14 +34,16 @@ HDF5P_LIB_DIR = /usr/lib/x86_64-linux-gnu/hdf5/openmpi/
|
|||||||
HDF5P_INCLUDES = -I$(HDF5P_INC_DIR)
|
HDF5P_INCLUDES = -I$(HDF5P_INC_DIR)
|
||||||
HDF5P_LIBRARIES = -L$(HDF5P_LIB_DIR) -lz -lhdf5_hl -lhdf5
|
HDF5P_LIBRARIES = -L$(HDF5P_LIB_DIR) -lz -lhdf5_hl -lhdf5
|
||||||
|
|
||||||
# Janson
|
# Jansson
|
||||||
MAKE_JANSSON = false
|
MAKE_JANSSON = false
|
||||||
|
|
||||||
JANSON_DIR = $(HOMEBASE)/external/jansson/
|
ifeq ($(MAKE_JANSSON), true)
|
||||||
JANSON_INC_DIR = $(JANSON_DIR)
|
JANSSON_INC_DIR = $(HOMEBASE)/external/jansson/build/include
|
||||||
JANSSON_LIBRARIES = -ljansson
|
JANSSON_LIB_DIR = $(HOMEBASE)/external/jansson/build/lib
|
||||||
JANSSON_INCLUDES = -I$(JANSON_INC_DIR)
|
else
|
||||||
|
JANSSON_INC_DIR = /usr/include
|
||||||
|
JANSSON_LIB_DIR = /usr/lib/x86_64-linux-gnu
|
||||||
|
endif
|
||||||
|
|
||||||
|
JANSSON_LIBRARIES = -L$(JANSSON_LIB_DIR) -ljansson
|
||||||
|
JANSSON_INCLUDES = -I$(JANSSON_INC_DIR)
|
||||||
|
|||||||
Vendored
+16
-6
@@ -4,22 +4,32 @@ dummy: all
|
|||||||
ZIP = tar
|
ZIP = tar
|
||||||
|
|
||||||
|
|
||||||
NAME_TAR = blitz-1.0.2.tar.gz
|
BLITZ_VERSION = 1.0.2
|
||||||
NAME = blitz-1.0.2
|
|
||||||
|
NAME_TAR = blitz-$(BLITZ_VERSION).tar.gz
|
||||||
|
NAME = blitz-$(BLITZ_VERSION)
|
||||||
|
|
||||||
|
BLITZ_FOLDER=external/blitz
|
||||||
|
|
||||||
BLITZ_FOLDER=/external/blitz/
|
|
||||||
|
|
||||||
all:
|
all:
|
||||||
|
ifneq ("$(wildcard $(NAME_TAR))","")
|
||||||
|
@echo "Archive already present"
|
||||||
|
else
|
||||||
|
@echo "Downloading"
|
||||||
|
wget https://github.com/blitzpp/blitz/archive/refs/tags/$(BLITZ_VERSION).tar.gz
|
||||||
|
mv $(BLITZ_VERSION).tar.gz $(NAME_TAR)
|
||||||
|
endif
|
||||||
$(ZIP) -xf $(NAME_TAR)
|
$(ZIP) -xf $(NAME_TAR)
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
mkdir -p build/include
|
mkdir -p build/include
|
||||||
mkdir -p build/lib
|
mkdir -p build/lib
|
||||||
cd $(NAME) && autoreconf -fiv && autoconf && automake --add-missing
|
cd $(NAME) && autoreconf -fiv && autoconf && automake --add-missing
|
||||||
cd $(NAME) && ./configure --prefix=$(HOMEBASE)$(BLITZ_FOLDER)build/ --includedir=$(HOMEBASE)$(BLITZ_FOLDER)build/include/ --libdir=$(HOMEBASE)$(BLITZ_FOLDER)build/lib/
|
cd $(NAME) && ./configure --prefix=$(HOMEBASE)/$(BLITZ_FOLDER)/build/ --includedir=$(HOMEBASE)/$(BLITZ_FOLDER)/build/include/ --libdir=$(HOMEBASE)/$(BLITZ_FOLDER)/build/lib/
|
||||||
cd $(NAME) && $(MAKE)
|
cd $(NAME) && $(MAKE)
|
||||||
cd $(NAME) && $(MAKE) lib
|
cd $(NAME) && $(MAKE) lib
|
||||||
cd $(NAME) && $(MAKE) install
|
cd $(NAME) && $(MAKE) install
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-rm -rf $(HOMEBASE)$(BLITZ_FOLDER)blitz-1.0.2
|
-rm -rf $(HOMEBASE)/$(BLITZ_FOLDER)/$(NAME)
|
||||||
-rm -rf $(HOMEBASE)$(BLITZ_FOLDER)build
|
-rm -rf $(HOMEBASE)/$(BLITZ_FOLDER)/build
|
||||||
|
|||||||
Vendored
BIN
Binary file not shown.
Vendored
+21
-13
@@ -4,21 +4,29 @@ dummy: all
|
|||||||
ZIP = tar
|
ZIP = tar
|
||||||
|
|
||||||
|
|
||||||
NAME_TAR = jansson-2.13.tar.gz
|
JANSSON_VERSION = 2.14
|
||||||
NAME = jansson-2.13
|
|
||||||
|
|
||||||
JANSSON_FOLDER=/external/jansson/
|
NAME = jansson-$(JANSSON_VERSION)
|
||||||
|
NAME_TAR = $(NAME).tar.gz
|
||||||
|
|
||||||
|
JANSSON_FOLDER=external/jansson
|
||||||
|
|
||||||
all:
|
all:
|
||||||
$(ZIP) -xf $(NAME_TAR)
|
ifneq ("$(wildcard $(NAME_TAR))","")
|
||||||
mkdir -p build
|
@echo "Archive already present"
|
||||||
mkdir -p build/include
|
else
|
||||||
mkdir -p build/lib
|
@echo "Downloading"
|
||||||
#cd $(NAME) && autoreconf -fiv && automake --add-missing
|
wget https://github.com/akheron/jansson/releases/download/v$(JANSSON_VERSION)/$(NAME_TAR)
|
||||||
cd $(NAME) && ./configure --prefix=$(HOMEBASE)$(JANSSON_FOLDER)build/ --includedir=$(HOMEBASE)$(JANSSON_FOLDER)build/include/ --libdir=$(HOMEBASE)$(JANSSON_FOLDER)build/lib/
|
endif
|
||||||
cd $(NAME) && $(MAKE)
|
$(ZIP) -xf $(NAME_TAR)
|
||||||
cd $(NAME) && $(MAKE) install
|
mkdir -p build
|
||||||
|
mkdir -p build/include
|
||||||
|
mkdir -p build/lib
|
||||||
|
#cd $(NAME) && autoreconf -fiv && automake --add-missing
|
||||||
|
cd $(NAME) && ./configure --prefix=$(HOMEBASE)/$(JANSSON_FOLDER)/build/ --includedir=$(HOMEBASE)/$(JANSSON_FOLDER)/build/include/ --libdir=$(HOMEBASE)/$(JANSSON_FOLDER)/build/lib/
|
||||||
|
cd $(NAME) && $(MAKE)
|
||||||
|
cd $(NAME) && $(MAKE) install
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-rm -rf $(HOMEBASE)$(JANSSON_FOLDER)$(NAME)
|
-rm -rf $(HOMEBASE)/$(JANSSON_FOLDER)/$(NAME)
|
||||||
-rm -rf $(HOMEBASE)$(JANSSON_FOLDER)build
|
-rm -rf $(HOMEBASE)/$(JANSSON_FOLDER)/build
|
||||||
|
|||||||
Vendored
BIN
Binary file not shown.
@@ -4,13 +4,23 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "blitz/array.h"
|
#include "blitz/array.h"
|
||||||
|
|
||||||
|
// class for reading data from a hdf5-file
|
||||||
class Hdf5Reader {
|
class Hdf5Reader {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: taking a string with the path to the directory and
|
||||||
|
// a string with the name of the file to be read (without the ".h5", which is appended by default)
|
||||||
Hdf5Reader(std::string directory, std::string filename);
|
Hdf5Reader(std::string directory, std::string filename);
|
||||||
|
// Constructor: taking a string of the absolute path to the file (string is not changed)
|
||||||
Hdf5Reader(std::string absolute_filename);
|
Hdf5Reader(std::string absolute_filename);
|
||||||
|
|
||||||
|
// read a 3-dimensional array from the hdf5-file specified at construction of the reader
|
||||||
|
// object at the hdf5-path "path" and return it as a blitz::Array
|
||||||
blitz::Array<double, 3> readD3Double(std::string path);
|
blitz::Array<double, 3> readD3Double(std::string path);
|
||||||
|
// read a 2-dimensional array from the hdf5-file specified at construction of the reader
|
||||||
|
// object at the hdf5-path "path" and return it as a blitz::Array
|
||||||
blitz::Array<double, 2> readD2Double(std::string path);
|
blitz::Array<double, 2> readD2Double(std::string path);
|
||||||
|
// read a 1-dimensional array from the hdf5-file specified at construction of the reader
|
||||||
|
// object at the hdf5-path "path" and return it as a blitz::Array
|
||||||
blitz::Array<double, 1> readD1Double(std::string path);
|
blitz::Array<double, 1> readD1Double(std::string path);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -5,11 +5,16 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include "blitz/array.h"
|
#include "blitz/array.h"
|
||||||
|
|
||||||
|
// Class to handle hdf5 output
|
||||||
class Hdf5Writer {
|
class Hdf5Writer {
|
||||||
public:
|
public:
|
||||||
|
// the ".h5" is appened to the filename by default
|
||||||
Hdf5Writer(std::string directory = "./output",
|
Hdf5Writer(std::string directory = "./output",
|
||||||
std::string filename = "output");
|
std::string filename = "output");
|
||||||
|
|
||||||
|
// writing functions to write data to a HDF dataset specified by the path
|
||||||
|
// variable (format: path = "/Group1/Group2/.../GroupN/NameOfDataset")
|
||||||
|
// into the file specified by directory and filename
|
||||||
void write(const blitz::Array<double, 1>& data, std::string path);
|
void write(const blitz::Array<double, 1>& data, std::string path);
|
||||||
void write(const blitz::Array<double, 2>& data, std::string path);
|
void write(const blitz::Array<double, 2>& data, std::string path);
|
||||||
void write(const blitz::Array<double, 3>& data, std::string path);
|
void write(const blitz::Array<double, 3>& data, std::string path);
|
||||||
|
|||||||
@@ -7,36 +7,57 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include "IO/hdf5_writer.h"
|
#include "IO/hdf5_writer.h"
|
||||||
|
|
||||||
|
// defined in "simulation/density_field.h"
|
||||||
class DynamicDensityField;
|
class DynamicDensityField;
|
||||||
class CurrentBorder;
|
//class CurrentBorder;
|
||||||
|
// defined in "simulation/parameter.h"
|
||||||
class Parameter;
|
class Parameter;
|
||||||
|
// defined in "simulation/current_collector.h"
|
||||||
class CurrentCollector;
|
class CurrentCollector;
|
||||||
|
// defined in "simulation/logger.h"
|
||||||
class DeletionLogger;
|
class DeletionLogger;
|
||||||
|
|
||||||
|
// defined in "simulation/species.h"
|
||||||
namespace species {
|
namespace species {
|
||||||
class TrackedSpecie;
|
class TrackedSpecie;
|
||||||
enum class ImplementedSpecies;
|
enum class ImplementedSpecies;
|
||||||
}; // namespace species
|
}; // namespace species
|
||||||
|
|
||||||
|
// structure to store information about output types
|
||||||
struct OutputTask {
|
struct OutputTask {
|
||||||
|
// name of the particle species that output should be performed for
|
||||||
std::string specie_name;
|
std::string specie_name;
|
||||||
|
// if true earlier output is overwritten
|
||||||
bool overwrite_last;
|
bool overwrite_last;
|
||||||
|
// how many cpu synchronization steps are inbetween two output steps
|
||||||
int intervall;
|
int intervall;
|
||||||
// selector if each or only first cpu should write can be added here
|
// selector if each or only first cpu should write can be added here
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class to handle output from the simulation
|
||||||
class SimulationOutput {
|
class SimulationOutput {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: takes the name of the output directory and
|
||||||
|
// the name of the output file (".h5" appended by default)
|
||||||
|
// directory is created if it does not exist
|
||||||
SimulationOutput(const std::string& output_folder,
|
SimulationOutput(const std::string& output_folder,
|
||||||
const std::string& output_filename);
|
const std::string& output_filename);
|
||||||
|
|
||||||
|
// add OutputTask for the output of the (dynamic) density field
|
||||||
void addDensityFieldOutput(OutputTask task);
|
void addDensityFieldOutput(OutputTask task);
|
||||||
|
// add OutputTask for the output of the current collector
|
||||||
void addCurrentBorderOutput(OutputTask task);
|
void addCurrentBorderOutput(OutputTask task);
|
||||||
|
// add OutputTask for the output of the deletion logger
|
||||||
void addDeletionLoggerOutput(OutputTask task);
|
void addDeletionLoggerOutput(OutputTask task);
|
||||||
|
|
||||||
|
// write data that is initialized once at the beginning of the simulation
|
||||||
|
// for all TrackedSpecies (mass (kg), charge (C), bin volumes, bin borders, number of bins
|
||||||
|
// bin areas)
|
||||||
void writeMetaData(
|
void writeMetaData(
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>& species);
|
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>& species);
|
||||||
|
|
||||||
|
// write data that changes during the simulation, output intervalls are defined
|
||||||
|
// wrt the number of cpu synchronization steps cpu_sync
|
||||||
void writeSimulationData(
|
void writeSimulationData(
|
||||||
int cpu_sync,
|
int cpu_sync,
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>& species);
|
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>& species);
|
||||||
@@ -48,45 +69,92 @@ class SimulationOutput {
|
|||||||
|
|
||||||
Hdf5Writer writer;
|
Hdf5Writer writer;
|
||||||
|
|
||||||
|
// function for writing simulated data in the dynamic density field
|
||||||
|
// takes the path to the hdf group of the specie the dynamic density field is defined for
|
||||||
|
// takes the number of cpu synchronization steps that have been performed
|
||||||
|
// takes whether earlier output should be overwritten
|
||||||
void writeSimulationData(DynamicDensityField* density_field,
|
void writeSimulationData(DynamicDensityField* density_field,
|
||||||
std::string species_path,
|
std::string species_path,
|
||||||
int cpu_sync,
|
int cpu_sync,
|
||||||
bool overwrite_last);
|
bool overwrite_last);
|
||||||
|
|
||||||
|
// write the 4d density array of the dynamic density field
|
||||||
|
// in the hdf group defined by string (has to be a total hdf path)
|
||||||
void writeSpectrum(DynamicDensityField* density_field, std::string path);
|
void writeSpectrum(DynamicDensityField* density_field, std::string path);
|
||||||
|
// write the 3d density array of the dynamic density field
|
||||||
|
// in the hdf group defined by string (has to be a total hdf path)
|
||||||
void writeDensity(DynamicDensityField* density_field, std::string path);
|
void writeDensity(DynamicDensityField* density_field, std::string path);
|
||||||
|
// write the 4d time in bin array (i.e. the raw data) of the dynamic density field
|
||||||
|
// in the hdf group defined by string (has to be a total hdf path)
|
||||||
void writeTimeInBin(DynamicDensityField* density_field, std::string path);
|
void writeTimeInBin(DynamicDensityField* density_field, std::string path);
|
||||||
|
// write the 4d density array of the deleted particles array
|
||||||
|
// in the hdf group defined by string (has to be a total hdf path)
|
||||||
void writeDeletedParticles(DynamicDensityField* density_field,
|
void writeDeletedParticles(DynamicDensityField* density_field,
|
||||||
std::string path);
|
std::string path);
|
||||||
|
// write the time of the Timer member object
|
||||||
|
// in the hdf group defined by string (has to be a total hdf path)
|
||||||
void writePhysicalTime(DynamicDensityField* density_field, std::string path);
|
void writePhysicalTime(DynamicDensityField* density_field, std::string path);
|
||||||
|
|
||||||
|
// function for writing simulated data in the current collector
|
||||||
|
// takes the path to the hdf group of the specie the dynamic density field is defined for
|
||||||
|
// takes the number of cpu synchronization steps that have been performed
|
||||||
|
// takes whether earlier output should be overwritten
|
||||||
void writeSimulationData(CurrentCollector* current_collector,
|
void writeSimulationData(CurrentCollector* current_collector,
|
||||||
std::string species_path,
|
std::string species_path,
|
||||||
int cpu_sync,
|
int cpu_sync,
|
||||||
bool overwrite_last);
|
bool overwrite_last);
|
||||||
|
// write all positive and negative crossing arrays (i.e. raw data)
|
||||||
|
// in the hdf group defined by string (has to be a total hdf path)
|
||||||
void writeCurrentCrossings(CurrentCollector* current_collector,
|
void writeCurrentCrossings(CurrentCollector* current_collector,
|
||||||
std::string path);
|
std::string path);
|
||||||
|
// write all physical particle current arrays (i.e. raw data)
|
||||||
|
// in the hdf group defined by string (has to be a total hdf path)
|
||||||
void writeCurrent(CurrentCollector* current_collector, std::string path);
|
void writeCurrent(CurrentCollector* current_collector, std::string path);
|
||||||
|
// write the time of the Timer member object
|
||||||
|
// in the hdf group defined by string (has to be a total hdf path)
|
||||||
void writePhysicalTime(CurrentCollector* current_collector, std::string path);
|
void writePhysicalTime(CurrentCollector* current_collector, std::string path);
|
||||||
|
|
||||||
|
// function for writing simulated data in the deletion logger
|
||||||
|
// takes the path to the hdf group of the specie the dynamic density field is defined for
|
||||||
|
// takes the number of cpu synchronization steps that have been performed
|
||||||
|
// takes whether earlier output should be overwritten
|
||||||
void writeSimulationData(DeletionLogger* logger,
|
void writeSimulationData(DeletionLogger* logger,
|
||||||
std::string species_path,
|
std::string species_path,
|
||||||
int cpu_sync,
|
int cpu_sync,
|
||||||
bool overwrite_last);
|
bool overwrite_last);
|
||||||
|
// write the deletion trakced by the DeletionLogger
|
||||||
|
// in the hdf group defined by string (has to be a total hdf path)
|
||||||
void writeNumDeletions(DeletionLogger* logger, std::string path);
|
void writeNumDeletions(DeletionLogger* logger, std::string path);
|
||||||
|
|
||||||
|
// write the not simulated aspects of the TrackedSpecie
|
||||||
|
// (mass (kg), charge (C))
|
||||||
|
// in the hdf group defined by string (has to be a total hdf path)
|
||||||
void writeMetaData(species::TrackedSpecie* specie);
|
void writeMetaData(species::TrackedSpecie* specie);
|
||||||
|
// write the not simulated aspects of the DynamicDensityField
|
||||||
|
// (bin volumes, bin borders)
|
||||||
|
// in the hdf group defined by string (has to be a total hdf path)
|
||||||
void writeMetaData(DynamicDensityField* density_field, std::string path);
|
void writeMetaData(DynamicDensityField* density_field, std::string path);
|
||||||
|
// write the not simulated aspects of the CurrentCollector
|
||||||
|
// (bin areas)
|
||||||
|
// in the hdf group defined by string (has to be a total hdf path)
|
||||||
void writeMetaData(CurrentCollector* current_collector, std::string path);
|
void writeMetaData(CurrentCollector* current_collector, std::string path);
|
||||||
// void writeParameterFile(Parameter* parameter);
|
// void writeParameterFile(Parameter* parameter);
|
||||||
|
|
||||||
|
// write the areas of the bins used by the current collector
|
||||||
|
// in the hdf group defined by string (has to be a total hdf path)
|
||||||
void writeCollectorAreas(CurrentCollector* current_collector,
|
void writeCollectorAreas(CurrentCollector* current_collector,
|
||||||
std::string path);
|
std::string path);
|
||||||
|
|
||||||
|
// write the volumes of the bins used by the dynamic density field
|
||||||
|
// in the hdf group defined by string (has to be a total hdf path)
|
||||||
void writeBinVolumes(DynamicDensityField* density_field,
|
void writeBinVolumes(DynamicDensityField* density_field,
|
||||||
std::string path_to_field);
|
std::string path_to_field);
|
||||||
|
// write the number of bins used by the dynamic density field
|
||||||
|
// in the hdf group defined by string (has to be a total hdf path)
|
||||||
void writeNumBins(DynamicDensityField* density_field,
|
void writeNumBins(DynamicDensityField* density_field,
|
||||||
std::string path_to_field);
|
std::string path_to_field);
|
||||||
|
// write the borders of the bins used by the dynamic density field
|
||||||
|
// in the hdf group defined by string (has to be a total hdf path)
|
||||||
void writeBinBorders(DynamicDensityField* density_field,
|
void writeBinBorders(DynamicDensityField* density_field,
|
||||||
std::string path_to_field);
|
std::string path_to_field);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,9 +2,13 @@
|
|||||||
#define T2_BETA_DECAY_H
|
#define T2_BETA_DECAY_H
|
||||||
|
|
||||||
namespace T2BetaDecay {
|
namespace T2BetaDecay {
|
||||||
static const double lambda_T2 = 1.78405E-9; // tritium decay constant (1/s)
|
// tritium decay constant (1/s)
|
||||||
static const double E0_T = 18.573e3; // Tritium endpoint energy (eV)
|
static const double lambda_T2 = 1.78405E-9;
|
||||||
static const double spectrum_prefactor = 1.2072343416696292E-47; // beta decay constant
|
// Tritium endpoint energy (eV)
|
||||||
|
static const double E0_T = 18.573e3;
|
||||||
|
// beta decay constant used in the fermi spectrum
|
||||||
|
static const double spectrum_prefactor = 1.2072343416696292E-47;
|
||||||
|
// maximum value of the fermi spectrum
|
||||||
static const double spectrum_maximum = 1.5E-28;
|
static const double spectrum_maximum = 1.5E-28;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#define IONIZATION_CONSTANTS_H
|
#define IONIZATION_CONSTANTS_H
|
||||||
|
|
||||||
namespace ionization {
|
namespace ionization {
|
||||||
static const double ionization_energy_janev_non_diss = 15.42; // (eV)
|
static const double ionization_energy_janev_non_diss = 15.43; // (eV)
|
||||||
static const double ionization_energy_janev_diss_first = 30.6; // (eV)
|
static const double ionization_energy_janev_diss_first = 30.6; // (eV)
|
||||||
static const double ionization_energy_janev_diss_ground = 18.15; // (eV)
|
static const double ionization_energy_janev_diss_ground = 18.15; // (eV)
|
||||||
} // namespace ionization
|
} // namespace ionization
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef PHYSICAL_CONSTANTS_H
|
#ifndef PHYSICAL_CONSTANTS_H
|
||||||
#define PHYSICAL_CONSTANTS_H
|
#define PHYSICAL_CONSTANTS_H
|
||||||
|
|
||||||
// The default is (Gaussian) CGS units
|
// Constants in CGS units
|
||||||
namespace CGS {
|
namespace CGS {
|
||||||
static const double me = 9.1094e-28; // Electron mass (g)
|
static const double me = 9.1094e-28; // Electron mass (g)
|
||||||
static const double mp = 1.6726231e-24; // Proton mass (g)
|
static const double mp = 1.6726231e-24; // Proton mass (g)
|
||||||
@@ -21,7 +21,7 @@ static const double G = 6.67428e-8; // Gravitational constant cm^3/(g sec^2)
|
|||||||
|
|
||||||
}; // namespace CGS
|
}; // namespace CGS
|
||||||
|
|
||||||
// Constants in SI
|
// Constants in SI (default)
|
||||||
namespace SI {
|
namespace SI {
|
||||||
static const double me = 9.1094e-31; // Electron mass (kg)
|
static const double me = 9.1094e-31; // Electron mass (kg)
|
||||||
static const double mp = 1.6726e-27; // Proton mass (kg)
|
static const double mp = 1.6726e-27; // Proton mass (kg)
|
||||||
|
|||||||
@@ -3,12 +3,17 @@
|
|||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
// constants due to numercial accuracy
|
||||||
namespace SimConstants {
|
namespace SimConstants {
|
||||||
|
// minimal value for a cross section
|
||||||
static const double minimal_cross_section =
|
static const double minimal_cross_section =
|
||||||
std::numeric_limits<double>::min() * 1E5;
|
std::numeric_limits<double>::min() * 1E5;
|
||||||
|
// minimal value for a cross section scaled by density
|
||||||
static const double minimal_macroscopic_cross_section =
|
static const double minimal_macroscopic_cross_section =
|
||||||
std::numeric_limits<double>::min() * 1E5;
|
std::numeric_limits<double>::min() * 1E5;
|
||||||
|
// arbitrarily chosen value to serve as the lowest value possible (to exclude 0)
|
||||||
static const double random_lower_limit = 1E-15;
|
static const double random_lower_limit = 1E-15;
|
||||||
|
// double1 == double2 <=> abs(double1 - double2) <= compare_epsilon
|
||||||
static const double compare_epsilon = 1E-10;
|
static const double compare_epsilon = 1E-10;
|
||||||
|
|
||||||
} // namespace SimConstants
|
} // namespace SimConstants
|
||||||
|
|||||||
@@ -4,19 +4,32 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
// R^1 -> R^1 mappings
|
||||||
namespace D1ToD1 {
|
namespace D1ToD1 {
|
||||||
|
// return a function defined at the vector positions with the vector values
|
||||||
|
// which interpolates linearly between those values
|
||||||
|
// both vectors have to be sorted according to the values in positions
|
||||||
std::function<double(double)> PiecewiseLinear(std::vector<double> positions,
|
std::function<double(double)> PiecewiseLinear(std::vector<double> positions,
|
||||||
std::vector<double> values);
|
std::vector<double> values);
|
||||||
|
|
||||||
|
// return a function, that always returns the constant value "constant"
|
||||||
std::function<double(double)> Constant(double constant);
|
std::function<double(double)> Constant(double constant);
|
||||||
|
|
||||||
|
// return a function returning the product of the values defined by the functions
|
||||||
|
// in the vector "functions"
|
||||||
std::function<double(double)> Product(
|
std::function<double(double)> Product(
|
||||||
std::vector<std::function<double(double)>> functions);
|
std::vector<std::function<double(double)>> functions);
|
||||||
}; // namespace D1ToD1
|
}; // namespace D1ToD1
|
||||||
|
|
||||||
|
// R^3 -> R^1 mappings
|
||||||
namespace D3ToD1 {
|
namespace D3ToD1 {
|
||||||
|
// return a function, that always returns the constant value "constant"
|
||||||
std::function<double(double, double, double)> Constant(double value);
|
std::function<double(double, double, double)> Constant(double value);
|
||||||
|
|
||||||
|
// return a function that returns the product of the values of the functions fi, fj and fk
|
||||||
|
// fi calculates its value from the first parameter the function "Product" returns gets,
|
||||||
|
// fj from the second parameter and
|
||||||
|
// fk from the third
|
||||||
std::function<double(double, double, double)> Product(
|
std::function<double(double, double, double)> Product(
|
||||||
std::function<double(double)> fi,
|
std::function<double(double)> fi,
|
||||||
std::function<double(double)> fj,
|
std::function<double(double)> fj,
|
||||||
|
|||||||
@@ -9,12 +9,63 @@
|
|||||||
#include "simulation/position_binning.h"
|
#include "simulation/position_binning.h"
|
||||||
|
|
||||||
namespace generator {
|
namespace generator {
|
||||||
|
// return a CylinderBinning object as described in the json-object object
|
||||||
|
// object has to contain a json-object "CylinderBinning"
|
||||||
|
// "CylinderBinning" has to consist of:
|
||||||
|
// - json-object "Radial" consisting of a json-double (later cast to an integer) "NumberOfBins"
|
||||||
|
// and a json-object "MaxRadius", which has to follow the form described in "json_read_length"
|
||||||
|
// ("simulation/jansson_additionals.h")
|
||||||
|
// - json-object "Longitudinal" consisting of a json-double (later cast to an integer) "NumberOfBins"
|
||||||
|
// and a json-object "MaxLength", which has to follow the form described in "json_read_length"
|
||||||
|
// ("simulation/jansson_additionals.h")
|
||||||
|
// - json-object "Azimuthal" consisting of a json-double (later cast to an integer) "NumberOfBins"
|
||||||
|
// example:
|
||||||
|
// "object" : {
|
||||||
|
// "CylinderBinning": {
|
||||||
|
// "Radial": {"NumberOfBins": 1, "MaxRadius" : {...}},
|
||||||
|
// "Azimuthal": {"NumberOfBins": 1},
|
||||||
|
// "Longitudinal": {"NumberOfBins": 1, "MaxLength" : {...}}
|
||||||
|
// }
|
||||||
|
// }
|
||||||
CylinderBinning buildPositionBinning(json_t* object);
|
CylinderBinning buildPositionBinning(json_t* object);
|
||||||
|
// return a CylinderBinning object described by the json-object in parameter at the
|
||||||
|
// path "path_to_binning"
|
||||||
|
// if a json-array called "CreateSameAs" exists: has to consist of the path to the PositionBinning
|
||||||
|
// json-object that should be used (e.g. ["Object1", "Object2", ..., "PositionBinning"],
|
||||||
|
// "Object1" has to be located in the root object)
|
||||||
|
// otherwise same specifications as "buildPositionBinning"
|
||||||
CylinderBinning buildPositionBinningIncludingRedirection(
|
CylinderBinning buildPositionBinningIncludingRedirection(
|
||||||
Parameter& parameter,
|
Parameter& parameter,
|
||||||
json_path& path_to_binning);
|
json_path& path_to_binning);
|
||||||
|
|
||||||
|
// return a EnergyBinning object as defined in the json-object object
|
||||||
|
// object has to contain:
|
||||||
|
// - a json-string "Type", defining the type of the EnergyBinning (right now only "Logarithmic" is valid)
|
||||||
|
// - a json-double "NumberOfBins", defining the number of bins for the binning (will be cast to an int)
|
||||||
|
// - a json-object "MinEnergy" and a json-object "MaxEnergy", defining the lower and upper
|
||||||
|
// value for the binning. Both objects have to follow the structure described in
|
||||||
|
// "json_read_energy" ("simulation/jansson_additionals.h")
|
||||||
|
//
|
||||||
|
// example:
|
||||||
|
// "object": {
|
||||||
|
// "Type": "Logarithmic",
|
||||||
|
// "NumberOfBins": 3,
|
||||||
|
// "MinEnergy": {
|
||||||
|
// "value": 1,
|
||||||
|
// "unit": eV
|
||||||
|
// },
|
||||||
|
// "MaxEnergy": {
|
||||||
|
// "value": 1000,
|
||||||
|
// "unit": eV
|
||||||
|
// }
|
||||||
|
// }
|
||||||
EnergyBinning buildEnergyBinning(json_t* object);
|
EnergyBinning buildEnergyBinning(json_t* object);
|
||||||
|
// return a EnergyBinning object described by the json-object in parameter at the
|
||||||
|
// path "path_to_binning"
|
||||||
|
// if a json-array called "CreateSameAs" exists: has to consist of the path to the EnergyBinning
|
||||||
|
// json-object that should be used (e.g. ["Object1", "Object2", ..., "EnergyBinning"],
|
||||||
|
// "Object1" has to be located in the root object)
|
||||||
|
// otherwise same specifications as "buildEnergy"
|
||||||
EnergyBinning buildEnergyBinningIncludingRedirection(
|
EnergyBinning buildEnergyBinningIncludingRedirection(
|
||||||
Parameter& parameter,
|
Parameter& parameter,
|
||||||
json_path& path_to_binning);
|
json_path& path_to_binning);
|
||||||
|
|||||||
@@ -9,6 +9,11 @@
|
|||||||
#include "simulation/timer.h"
|
#include "simulation/timer.h"
|
||||||
|
|
||||||
namespace generator {
|
namespace generator {
|
||||||
|
// return a shared_ptr to a CurrentCollector object, defined by the json-object
|
||||||
|
// at "path_to_collector" in the Parameter file using the provied Timer object
|
||||||
|
// the json-object has to contain a json-object called "PositionBinning",
|
||||||
|
// wich has to follow the structure described in "buildPositionBinning"
|
||||||
|
// (in "generators/binning_generator.h")
|
||||||
std::shared_ptr<CurrentCollector> buildCurrentCollector(
|
std::shared_ptr<CurrentCollector> buildCurrentCollector(
|
||||||
Parameter& parameter,
|
Parameter& parameter,
|
||||||
const json_path& path_to_collector,
|
const json_path& path_to_collector,
|
||||||
|
|||||||
@@ -8,8 +8,16 @@
|
|||||||
|
|
||||||
namespace generator {
|
namespace generator {
|
||||||
|
|
||||||
|
// return a shared_ptr to a ConstantDensityField object described by the give json-object
|
||||||
|
// object has to contain a json-object "ScalarField", that has to follow the form
|
||||||
|
// described in "buildScalarField" (defined in "generators/scalar_field_generator.h")
|
||||||
std::shared_ptr<ConstantDensityField> buildConstantDensityField(json_t* object);
|
std::shared_ptr<ConstantDensityField> buildConstantDensityField(json_t* object);
|
||||||
|
|
||||||
|
// return a shared_ptr to a DynamicDensityField object described by the json-object
|
||||||
|
// at the give path in the Parameter object which uses the given Timer object
|
||||||
|
// the json-object at path_to_field has to contain two json-objects called
|
||||||
|
// "PositionBinning" and "EnergyBinning", which are described in "buildPositionBinning"
|
||||||
|
// and "buildEnergyBinning" respectivley (both defined in "generators/binning_generator.h")
|
||||||
std::shared_ptr<DynamicDensityField> buildDynamicDensityField(
|
std::shared_ptr<DynamicDensityField> buildDynamicDensityField(
|
||||||
Parameter& parameter,
|
Parameter& parameter,
|
||||||
const json_path& path_to_field,
|
const json_path& path_to_field,
|
||||||
|
|||||||
@@ -7,10 +7,23 @@
|
|||||||
|
|
||||||
namespace generator {
|
namespace generator {
|
||||||
|
|
||||||
|
// create a shared_ptr to a DriftVelocity object described by the json-object in parameter at the
|
||||||
|
// path "path_to_drift_velocity"
|
||||||
|
// has to consist of a json-object "VectorField" or "null"
|
||||||
|
// if "VectorField" is specified: has to follow the form described by "buildVectorField" (in "generators/vector_field_generator.h")
|
||||||
|
// if "null" is specified: nothing more has to be specified, simply returns a nullptr
|
||||||
|
// (examples in "simulation_config/drift_velocity_examples.json")
|
||||||
std::shared_ptr<DriftVelocity> buildDriftVelocity(
|
std::shared_ptr<DriftVelocity> buildDriftVelocity(
|
||||||
Parameter& parameter,
|
Parameter& parameter,
|
||||||
const json_path& path_to_drift_velocity);
|
const json_path& path_to_drift_velocity);
|
||||||
|
|
||||||
|
// create a shared_ptr to a DriftVelocity object described by the json-object in parameter at the
|
||||||
|
// path "path_to_drift_velocity"
|
||||||
|
// if a json-array called "CreateSameAs" exists: has to consist of the path to the DriftVelocity
|
||||||
|
// json-object that should be used (e.g. ["Object1", "Object2", ..., "DriftVelocity"], has to start at the root)
|
||||||
|
// otherwise same specifications as "buildDriftVelocity"
|
||||||
|
std::shared_ptr<DriftVelocity> buildDriftVelocityIncludingRedirection(
|
||||||
|
Parameter& parameter, const json_path& path_to_drift_velocity);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* DRIFT_VELOCITY_GENERATOR_H */
|
#endif /* DRIFT_VELOCITY_GENERATOR_H */
|
||||||
|
|||||||
@@ -6,8 +6,15 @@
|
|||||||
|
|
||||||
namespace generator {
|
namespace generator {
|
||||||
|
|
||||||
|
// create an ElectricField object from a json_t pointer to an json object
|
||||||
|
// defining the electric field
|
||||||
|
// has to consist of two json-objects "Background" and "Dynamic" defining the vector fields
|
||||||
|
// as described in "generators/vector_field_generator.h" (function: "buildVectorField")
|
||||||
std::shared_ptr<ElectricField> electricField(json_t* object);
|
std::shared_ptr<ElectricField> electricField(json_t* object);
|
||||||
|
|
||||||
|
// create an ElectricField object from the given Parameter object
|
||||||
|
// json file has to have a json object called "ElectricField" directly in the json root object
|
||||||
|
// of the parameter file
|
||||||
std::shared_ptr<ElectricField> electricField(Parameter& parameter);
|
std::shared_ptr<ElectricField> electricField(Parameter& parameter);
|
||||||
}; // namespace generator
|
}; // namespace generator
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,22 @@
|
|||||||
|
|
||||||
namespace generator {
|
namespace generator {
|
||||||
|
|
||||||
|
// return a shared_ptr to an EnergyDistributionFunction object at the json-object
|
||||||
|
// with path "path_to_function" (from root) in the Parameter object
|
||||||
|
// has to consist of a json-object called either "TritiumBetaDecay", "MaxwellBoltzmann" or "Constant"
|
||||||
|
// if "TritiumBetaDecay" is specified:
|
||||||
|
// - does not have to contain anything (returns a TritiumBetaDecay object)
|
||||||
|
//
|
||||||
|
// if "MaxwellBoltzmann" is specified:
|
||||||
|
// - has to contain a json-object "Temperature", which has to contain a json-double "value"
|
||||||
|
// that specified the temperature (in K) for the Maxwell-Boltzmann distribution (returns a MaxwellBoltzmann object)
|
||||||
|
//
|
||||||
|
// if "Constant" is specified:
|
||||||
|
// - has to contain a json-object "constant", which has to contain a json-double "value", which
|
||||||
|
// specifies the constant energy in eV (returns a Constant object)
|
||||||
|
//
|
||||||
|
// (examples in "simulation_config_energy_distribution_function_examples.json"; definition of the
|
||||||
|
// objects in "simulatoin/energy_distribution.h")
|
||||||
std::shared_ptr<EnergyDistributionFunction> buildEnergyDistributionFunction(
|
std::shared_ptr<EnergyDistributionFunction> buildEnergyDistributionFunction(
|
||||||
Parameter& parameter,
|
Parameter& parameter,
|
||||||
const json_path& path_to_function);
|
const json_path& path_to_function);
|
||||||
|
|||||||
@@ -6,8 +6,37 @@
|
|||||||
#include "jansson.h"
|
#include "jansson.h"
|
||||||
|
|
||||||
namespace generator {
|
namespace generator {
|
||||||
|
// return a function1D specified by the json object "object"
|
||||||
|
// consists of a json-object called either "Constant", "PiecewiseLinear", "PiecewiseLinearFromFile" or an json-array called "Product"
|
||||||
|
// if "Constant" is specified:
|
||||||
|
// - has to contain a json-double called "constant" specifying the value of the constant the function should return
|
||||||
|
//
|
||||||
|
// if "PiecewiseLinear" is specified:
|
||||||
|
// - has to contain two json_arrays "xValues" and "yValues" specifying the point between which should be linearly interpolated
|
||||||
|
// - has to contain a json-double "prefactor", with which "yValues" will be scaled
|
||||||
|
//
|
||||||
|
// if "PiecewiseLinearFromFile" is specified:
|
||||||
|
// - has to contain a json-object "PathToH5" as described in "generators/vector_field_generator.h"
|
||||||
|
// - two json-strings "xValuesKey" and "yValuesKey" specifying the path of the x- and y-values in the hdf5 file
|
||||||
|
// - a json-double "prefactor" which scales the read y-values
|
||||||
|
//
|
||||||
|
// if "Product" is specified:
|
||||||
|
// - has to consist of an arbitrary number of json-objects following the format described for this function
|
||||||
|
//
|
||||||
|
// (examples can be found in "simulation_config/function_examples.json")
|
||||||
std::function<double(double)> function1D(json_t* object);
|
std::function<double(double)> function1D(json_t* object);
|
||||||
|
// return a function3D specified by the json object "object"
|
||||||
|
// has to consist of a json-object called either "Constant3D" or "Product"
|
||||||
|
//
|
||||||
|
// if "Constant3D" is specified:
|
||||||
|
// - has to contain a json-double "constant", defining the constant value that should be returned
|
||||||
|
//
|
||||||
|
// if "Product" is specified:
|
||||||
|
// - has to contain three json-objects called "fi", "fk" and "fj" defining the
|
||||||
|
// functional form in x,y and z direction; objects have to follow the description
|
||||||
|
// of "function1D"
|
||||||
|
//
|
||||||
|
// (examples can be found in "simulation_config/function_examples.json")
|
||||||
std::function<double(double, double, double)> function3D(json_t* object);
|
std::function<double(double, double, double)> function3D(json_t* object);
|
||||||
|
|
||||||
}; // namespace generator
|
}; // namespace generator
|
||||||
|
|||||||
@@ -9,6 +9,10 @@
|
|||||||
|
|
||||||
namespace generator {
|
namespace generator {
|
||||||
|
|
||||||
|
// return a shared_ptr to a Geometry object described by the json-object at the given path in the Parameter object
|
||||||
|
// the json-object at the path has to contain a json-object "Cylinder". This json-object has to contain:
|
||||||
|
// two json-objects "Radius" and "Height", which have to follow the form described in "json_read_length"
|
||||||
|
// ("simulation/jansson_additionals.h")
|
||||||
std::shared_ptr<Geometry> buildGeometry(Parameter& parameter,
|
std::shared_ptr<Geometry> buildGeometry(Parameter& parameter,
|
||||||
const json_path& path_to_geometry);
|
const json_path& path_to_geometry);
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,29 @@
|
|||||||
|
|
||||||
namespace generator {
|
namespace generator {
|
||||||
|
|
||||||
|
// return a shared_ptr to an Injector object described in the Parameter object
|
||||||
|
// the tracked_species should contain all TrackedSpecie objects that are considered in the simulation
|
||||||
|
// (background_species is not used)
|
||||||
|
// Parameter has to have a json-object "Injector" in the root object
|
||||||
|
// - in "Injector" a json-object "CreatedSpecies" has to exist, which
|
||||||
|
// consists of one more arbitrarily named json-objects
|
||||||
|
// these json-objects have to contain:
|
||||||
|
// - a json-string "TrackedSpecieName", which has to correspond to one
|
||||||
|
// of the strings used to describe the TrackedSpecies in the "Tracked" json-object of the same Paramter file
|
||||||
|
// - a json-object "CreationVelocityDistribution" following the description in "generators/velocity_distribution_generator.h"
|
||||||
|
// - a json-object "EventPositionDistribution" has to exit
|
||||||
|
// - therein a json-object "ScalarField" has to exist, which describes the distribution from which positions will be drawn (following the
|
||||||
|
// description in "generators/scalar_field_generator.h")
|
||||||
|
// - a json-object "DensityLimit", which has to contain
|
||||||
|
// - a json-double "min", which described the minimal density value of the used density distribution
|
||||||
|
// - a json-double "max", which described the maximal density value of the used density distribution
|
||||||
|
// - a json-object "PositionLimits" consisting of three json-object "rPosition", "phiPosition" and "zPosition", which
|
||||||
|
// all have the same sturcture:
|
||||||
|
// - a json-double "min", describing the minimum value that a drawn position should have
|
||||||
|
// - a json-double "max", describing the maximum value that a drawn position should have
|
||||||
|
// - a json-object "MotherDriftVelocity", which has a form as described in "generators/drift_velocity_generator.h"
|
||||||
|
//
|
||||||
|
// (example in "simulation_config/parameter_katrin_example.json")
|
||||||
std::shared_ptr<Injector> buildInjector(
|
std::shared_ptr<Injector> buildInjector(
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>&
|
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>&
|
||||||
tracked_species,
|
tracked_species,
|
||||||
|
|||||||
@@ -12,6 +12,64 @@
|
|||||||
|
|
||||||
namespace generator {
|
namespace generator {
|
||||||
|
|
||||||
|
// create the interactions specified at the "path_to_insteractions" in the Parameter
|
||||||
|
// and add them to the given TrackedSpecie specie
|
||||||
|
// the json-object at "path_to_interactions" has to consist of an arbitrary number
|
||||||
|
// of arbitrarily named json-objects describing the interaction. These objects have to contain:
|
||||||
|
// - a json-string "Type" with a value of either: "ElasticScattering", "FreeMovement", "ElectronIonization", "Excitation"
|
||||||
|
// "Clustering", "ChargeExchange" or "Recombination"
|
||||||
|
//
|
||||||
|
// if the Type "ElasticScattering" is specified (for elastic scattering interactions) the additional elements have to be present:
|
||||||
|
// - a json-object "CrossSection" (as described in "buildTotalCrossSection" function)
|
||||||
|
// - a json-object "ScatteringAngleDistribution" (as described in "buildScatteringAngleDistribution")
|
||||||
|
// - a json-string "Target", containing the interaction partner (has to be the name given in the json file
|
||||||
|
// of either a TrackedSpecie or a BackgroundSpecie)
|
||||||
|
//
|
||||||
|
// if the Type "FreeMovement" is specified (for a dummy interaction that does nothing) no additional elements have to be present
|
||||||
|
//
|
||||||
|
// if the Type is "ElectronIonization" the additional elements have to be provided:
|
||||||
|
// - a json-string "Target", containing the interaction partner (has to be the name given in the json file
|
||||||
|
// of either a TrackedSpecie or a BackgroundSpecie)
|
||||||
|
// - a json-string "OutgoingElectron", containing the name (given in the json parameter file) of
|
||||||
|
// a TrackedSpecie
|
||||||
|
// - a json-string "OutgoingIon", containing the name (given in the json parameter file) of
|
||||||
|
// a TrackedSpecie
|
||||||
|
// - a json-string "IonizationModel" with a value of either "JanevNonDiss", "JanevDissToGround" or "JanevDissToFirstExcited"
|
||||||
|
// - if the value is "IonizationModel": the "eT2_ionization_janev_non_diss" function for the cross section is used, "OutgoingElectron" has to be an electron ImplementedSpecies
|
||||||
|
// and "OutgoingIon" has to be a T2plus ImplementedSpecies, the scattering angle distribution is "IonizationScatteringAngleDistribution" and
|
||||||
|
// the energy distribution of the ionization electrons produced in the ionization is defined in "eT2_ionization_bed" (functions defined in "interations/cross_sections.h" and "interactions/ionization.h")
|
||||||
|
// - if the value is "JanevDissToGround": the "eT2_ionization_janev_diss_ground" function for the cross section is used, "OutgoingElectron" has to be an electron ImplementedSpecies
|
||||||
|
// and "OutgoingIon" has to be a Tplus ImplementedSpecies, the scattering angle distribution is "IonizationScatteringAngleDistribution" and
|
||||||
|
// the energy distribution of the ionization electrons produced in the ionization is defined in "eT2_ionization_bed" (functions defined in "interations/cross_sections.h" and "interactions/ionization.h")
|
||||||
|
// - if the value is "JanevDissToFirstExcited": the "eT2_ionization_janev_diss_first" function for the cross section is used, "OutgoingElectron" has to be an electron ImplementedSpecies
|
||||||
|
// and "OutgoingIon" has to be a Tplus ImplementedSpecies, the scattering angle distribution is "IonizationScatteringAngleDistribution" and
|
||||||
|
// the energy distribution of the ionization electrons produced in the ionization is defined in "eT2_ionization_bed" (functions defined in "interations/cross_sections.h" and "interactions/ionization.h")
|
||||||
|
//
|
||||||
|
// if the Type is "Excitation" the additiona elements have to be provided:
|
||||||
|
// - a json-string "Target", containing the interaction partner (has to be the name given in the json file
|
||||||
|
// of either a TrackedSpecie or a BackgroundSpecie)
|
||||||
|
// - a json-string "ExcitationState" being one of the names defined in "buildExcitationCrossSection"
|
||||||
|
//
|
||||||
|
// if the Type is "Clustering":
|
||||||
|
// - a json-string "Target", containing the interaction partner (has to be the name given in the json file
|
||||||
|
// of either a TrackedSpecie or a BackgroundSpecie)
|
||||||
|
// - a json-string "Product" (being a name of a tracked specie as defined in the json parameter file)
|
||||||
|
// - a json-object "CrossSection" (as described in the "buildTotalCrossSection" function)
|
||||||
|
// - a json-string "ClusteringType" specifying if the clustering is either a tertiary or radiative process
|
||||||
|
// (if tertiary is chosen the specifed cross section function is only the rate coefficient diveded by the velocity (units: m^6/s / (m/s)))
|
||||||
|
// otherwise it is handled as a "normal" cross section (m^2)
|
||||||
|
//
|
||||||
|
// if the Type is "ChargeExchange" (right now only if the species for which it's defined is the target with a charge of +1):
|
||||||
|
// - a json-string "Target", containing the interaction partner (has to be the name given in the json file
|
||||||
|
// of either a TrackedSpecie or a BackgroundSpecie)
|
||||||
|
// - a json-object "CrossSection" (as described in the "buildTotalCrossSection" function)
|
||||||
|
//
|
||||||
|
// if the Type is "Recombination" the additional elements have to be present as well:
|
||||||
|
// - a json-string "Target", containing the interaction partner (has to be the name given in the json file
|
||||||
|
// of a TrackedSpecie)
|
||||||
|
// - a json-object "CrossSection" (as described in the "buildTotalCrossSection" function)
|
||||||
|
//
|
||||||
|
// examples for the usage in a json-file can be found in simulation_config/interactions_examples.json
|
||||||
void addInteractions(
|
void addInteractions(
|
||||||
std::shared_ptr<species::TrackedSpecie> specie,
|
std::shared_ptr<species::TrackedSpecie> specie,
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>&
|
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>&
|
||||||
@@ -21,17 +79,62 @@ void addInteractions(
|
|||||||
Parameter& parameter,
|
Parameter& parameter,
|
||||||
json_path& path_to_interactions);
|
json_path& path_to_interactions);
|
||||||
|
|
||||||
|
|
||||||
|
// returns the cross section function defined in the given json-object
|
||||||
|
// the json-object has to either contain a json-string "PredefinedFunction", a json-object "1dFunction" or a json-object "ExcitationFunction"
|
||||||
|
// if the json-string "PredefinedFunction" is defined it has to have a value of one of the following strings:
|
||||||
|
// - "eT2_elastic_scattering_constant", "eT2_elastic_scattering", "TpT2_elastic_scattering_tabata", "T3pT2_elastic_scattering_tabata",
|
||||||
|
// "eT2_ionization_janev_diss_ground", "eT2_ionization_janev_diss_first", "TpT2_clustering_radiative_ascendion_pasil",
|
||||||
|
// "TpT2_clustering_tertiary_ascendion_pasil", "T2pT2_clustering_janev", "T2pT2_charge_exchange_janev", "eT2p_recombination_janev", "eT3p_recombination_janev"
|
||||||
|
// (further explanations can be found in "interactions/cross_sections.h"; the functions have the same name as the corresponding string listed above)
|
||||||
|
//
|
||||||
|
// if the json-object "1dFunction" exists, it has to follow the structure described in "generators/function_generator.h" for function1D
|
||||||
|
//
|
||||||
|
// if the json-object "ExcitationFunction" has to exist, this object has to contain a json-string called "ExcitationState",
|
||||||
|
// which has to be one of the strings defined in "buildExcitationCrossSection"
|
||||||
std::function<double(double)> buildTotalCrossSection(json_t* object);
|
std::function<double(double)> buildTotalCrossSection(json_t* object);
|
||||||
|
|
||||||
|
// return a cross section function depending on two variables (e.g. in-going and out-going particle energies in an ionization)
|
||||||
|
// has to contain a json-string "PredefinedFunction" with a value of "eT2_ionization_bed"
|
||||||
|
// (right now the function is only defined but never used)
|
||||||
std::function<double(double, double)> build2DCrossSection(json_t* object);
|
std::function<double(double, double)> build2DCrossSection(json_t* object);
|
||||||
|
|
||||||
|
// return a shared_ptr to a ScatteringAngleDistribution object that is defined by the given json-object
|
||||||
|
// has to contain a json-object called:
|
||||||
|
// "Isotropic". This object does not need any elements.
|
||||||
|
//
|
||||||
|
// "AngleDistributionFromFile". Has to contain a json-object "PathToH5" following the format as described in "readAbsoluteFilename"
|
||||||
|
// (defined in "generators/vector_field_generator.h")
|
||||||
|
//
|
||||||
|
// "CompositeAngleDistribution". Has to contain a
|
||||||
|
// - json-object "DeciderEnergy" following the description of "json_read_energy" (defined in "simulation/jansson_additionals.h")
|
||||||
|
// - two json-objects "LowerDistribution" and "HigherDisribuiton" as defined for this function
|
||||||
std::shared_ptr<ScatteringAngleDistribution> buildScatteringAngleDistribution(
|
std::shared_ptr<ScatteringAngleDistribution> buildScatteringAngleDistribution(
|
||||||
json_t* object);
|
json_t* object);
|
||||||
|
|
||||||
|
// return the value of the excitation energy for the given string defining the final excitation state of the target particle
|
||||||
|
// possible values for the excitation_state are (the numerical values can be found in the interaction_generatior.cpp file):
|
||||||
|
// - janev_singlet_B1, janev_singlet_B1prime, janev_singlet_B1primeprime, janev_singlet_C1, janev_singlet_D1,
|
||||||
|
// janev_singlet_D1prime, janev_singlet_symmetry_forbidden_EF1, janev_singlet_symmetry_forbidden_HHb,
|
||||||
|
// janev_singlet_symmetry_forbidden_GK1, janev_singlet_symmetry_forbidden_I1, janev_triplet_A3, janev_triplet_B3,
|
||||||
|
// janev_triplet_C3, janev_triplet_D3, janev_triplet_E3, janev_vibrational_first, janev_vibrational_second,
|
||||||
|
// england_rotational_j0_to_j2, england_rotational_j1_to_j3
|
||||||
double buildExcitationEnergy(std::string excitation_state);
|
double buildExcitationEnergy(std::string excitation_state);
|
||||||
|
|
||||||
|
// return the function for a predefined excitation cross section (see simulation/cross_sections.h)
|
||||||
|
// defined by the string "excitation_state"
|
||||||
|
// possible values for the excitation_state are:
|
||||||
|
// - janev_singlet_B1, janev_singlet_B1prime, janev_singlet_B1primeprime, janev_singlet_C1, janev_singlet_D1,
|
||||||
|
// janev_singlet_D1prime, janev_singlet_symmetry_forbidden_EF1, janev_singlet_symmetry_forbidden_HHb,
|
||||||
|
// janev_singlet_symmetry_forbidden_GK1, janev_singlet_symmetry_forbidden_I1, janev_triplet_A3, janev_triplet_B3,
|
||||||
|
// janev_triplet_C3, janev_triplet_D3, janev_triplet_E3, janev_vibrational_first, janev_vibrational_second,
|
||||||
|
// england_rotational_j0_to_j2, england_rotational_j1_to_j3
|
||||||
std::function<double(double)> buildExcitationCrossSection(
|
std::function<double(double)> buildExcitationCrossSection(
|
||||||
std::string excitation_state);
|
std::string excitation_state);
|
||||||
|
|
||||||
|
// if the string target_name is used as a key in either the map for the TrackedSpecies or
|
||||||
|
// the map for the BackgroundSpecies returns the corresponding Species
|
||||||
|
// (the keys in the map are defined by the name given in the json parameter file)
|
||||||
std::shared_ptr<species::Specie> findTarget(
|
std::shared_ptr<species::Specie> findTarget(
|
||||||
std::string& target_name,
|
std::string& target_name,
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>&
|
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>&
|
||||||
@@ -39,6 +142,9 @@ std::shared_ptr<species::Specie> findTarget(
|
|||||||
std::map<std::string, std::shared_ptr<species::BackgroundSpecie>>&
|
std::map<std::string, std::shared_ptr<species::BackgroundSpecie>>&
|
||||||
background_species);
|
background_species);
|
||||||
|
|
||||||
|
// if the string target_name is used as a key in either the map for the TrackedSpecies
|
||||||
|
// returns the corresponding TrackedSpecie
|
||||||
|
// (the keys in the map are defined by the name given in the json parameter file)
|
||||||
std::shared_ptr<species::TrackedSpecie> findTracked(
|
std::shared_ptr<species::TrackedSpecie> findTracked(
|
||||||
std::string& target_name,
|
std::string& target_name,
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>&
|
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>&
|
||||||
|
|||||||
@@ -7,7 +7,16 @@
|
|||||||
|
|
||||||
namespace generator {
|
namespace generator {
|
||||||
|
|
||||||
|
// return a shared_ptr to a DeletionLogger object described by the given json-object
|
||||||
|
// can contain a json-array or a json-string "Type"
|
||||||
|
// - if it's a json-array: list the DeletionTypes that should be counted
|
||||||
|
// during the simulation (json-strings: "wall", "recombination", "max_interactions", "max_time_alive" and "cluster_formation")
|
||||||
|
// - if it's a json-string: has to have the value "all" and then all DeletionTypes are tracked (see list above)
|
||||||
|
// - if not present: no DeletionTypes are tracked
|
||||||
std::shared_ptr<DeletionLogger> buildDeletionLogger(json_t* object);
|
std::shared_ptr<DeletionLogger> buildDeletionLogger(json_t* object);
|
||||||
|
// return a shared_ptr to a DeletionLogger object described at the given path
|
||||||
|
// in the Parameter object, this object has to contain a json-object "Deletion"
|
||||||
|
// following the structure in the overload of this function
|
||||||
std::shared_ptr<DeletionLogger> buildDeletionLogger(
|
std::shared_ptr<DeletionLogger> buildDeletionLogger(
|
||||||
Parameter& parameter,
|
Parameter& parameter,
|
||||||
const json_path& path_to_logger);
|
const json_path& path_to_logger);
|
||||||
|
|||||||
@@ -6,8 +6,15 @@
|
|||||||
|
|
||||||
namespace generator {
|
namespace generator {
|
||||||
|
|
||||||
|
// create an MagneticField object from a json_t pointer to an json object
|
||||||
|
// defining the magnetic field
|
||||||
|
// has to consist of a json-objects called "VectorField"
|
||||||
|
// as described in "generators/vector_field_generator.h" (function: "buildVectorField")
|
||||||
std::shared_ptr<MagneticField> magneticField(json_t* object);
|
std::shared_ptr<MagneticField> magneticField(json_t* object);
|
||||||
|
|
||||||
|
// create an MagneticField object from the given Parameter object
|
||||||
|
// json file has to have a json object called "MagneticField" directly in the root object
|
||||||
|
// of the parameter file
|
||||||
std::shared_ptr<MagneticField> magneticField(Parameter& parameter);
|
std::shared_ptr<MagneticField> magneticField(Parameter& parameter);
|
||||||
}; // namespace generator
|
}; // namespace generator
|
||||||
|
|
||||||
|
|||||||
@@ -4,20 +4,27 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include "jansson.h"
|
#include "jansson.h"
|
||||||
|
|
||||||
|
// defined in "simulation/species.h"
|
||||||
namespace species {
|
namespace species {
|
||||||
enum class ImplementedSpecies;
|
enum class ImplementedSpecies;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace generator {
|
namespace generator {
|
||||||
|
|
||||||
|
// class containing a map of the masses (in kg) to the respective ImplementedSpecies
|
||||||
class SpeciesMasses {
|
class SpeciesMasses {
|
||||||
public:
|
public:
|
||||||
|
// return the mass of the ImplementedSpecies
|
||||||
static double mass(const species::ImplementedSpecies& species);
|
static double mass(const species::ImplementedSpecies& species);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::map<species::ImplementedSpecies, double> mass_;
|
static std::map<species::ImplementedSpecies, double> mass_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// return the mass of the specie at the json-object
|
||||||
|
// has to contain either a json-string "FromParticleType" or a json-double "value"
|
||||||
|
// if "FromParticleType" is specified, it has to be one of the strings defined in the SpecieAlias class in "generators/species_generator.h"
|
||||||
|
// if "value" is specified, it has to be the value in (kg)
|
||||||
double buildMass(json_t* object);
|
double buildMass(json_t* object);
|
||||||
|
|
||||||
}; // namespace generator
|
}; // namespace generator
|
||||||
|
|||||||
@@ -7,6 +7,22 @@
|
|||||||
|
|
||||||
namespace generator {
|
namespace generator {
|
||||||
|
|
||||||
|
// return a shared_ptr to a Mover object described at the given path in the Parameter file
|
||||||
|
// the json-object at path_to_mover has to consist of a json-object called either "Boris", "Drift" or "Euler"
|
||||||
|
// if "Boris" exists:
|
||||||
|
// - has to contain a json-object "MaximalTimestepLength", which has to contain
|
||||||
|
// a json-double called "value" giving the maximum allowed timestep for the BorisMover
|
||||||
|
// in seconds
|
||||||
|
//
|
||||||
|
// if "Drift" is specified:
|
||||||
|
// - has to contain a json-object "MaximalMovedDistance" which has to follow the form
|
||||||
|
// described in json_read_length ("simulation/jansson_additionals.h")
|
||||||
|
// specifies the maximal distance a particle is allowed to move in one timestep
|
||||||
|
//
|
||||||
|
// if "Euler" is specified:
|
||||||
|
// - has to contain a json-object "MaximalMovedDistance" which has to follow the form
|
||||||
|
// described in json_read_length ("simulation/jansson_additionals.h")
|
||||||
|
// specifies the maximal distance a particle is allowed to move in one timestep
|
||||||
std::shared_ptr<Mover> buildMover(Parameter& parameter,
|
std::shared_ptr<Mover> buildMover(Parameter& parameter,
|
||||||
const json_path& path_to_mover);
|
const json_path& path_to_mover);
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,10 @@
|
|||||||
|
|
||||||
namespace generator {
|
namespace generator {
|
||||||
|
|
||||||
|
// return a shared_ptr to a RandomNumbers object
|
||||||
|
// parameter has to have a json-object "RandomNumbers" in its root object
|
||||||
|
// "RandomNumbers" has to contain a json-double "Seed" which specifies the seed
|
||||||
|
// on mpi-process 0 (a different seed is calculated for all other mpi-processes)
|
||||||
std::shared_ptr<RandomNumbers> buildRandomNumbers(Parameter& parameter);
|
std::shared_ptr<RandomNumbers> buildRandomNumbers(Parameter& parameter);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,6 +9,12 @@
|
|||||||
|
|
||||||
namespace generator {
|
namespace generator {
|
||||||
|
|
||||||
|
// return a shared_ptr to a Reflector object described at the given path in the Parameter object
|
||||||
|
// the object at the path has to consist of a json-object called either "ReflectorDPS"
|
||||||
|
// or "NoReflector"
|
||||||
|
// if "ReflectorDPS" exists, a json-object "position_z" has to exist following the structure
|
||||||
|
// described in json_read_length ("simulation/jansson_additionals.h")
|
||||||
|
// if "NoReflector" is specified, it can be an empty object
|
||||||
std::shared_ptr<Reflector> buildReflector(Parameter& parameter,
|
std::shared_ptr<Reflector> buildReflector(Parameter& parameter,
|
||||||
const json_path& path_to_reflector);
|
const json_path& path_to_reflector);
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,10 @@
|
|||||||
#include "simulation/scalar_field.h"
|
#include "simulation/scalar_field.h"
|
||||||
|
|
||||||
namespace generator {
|
namespace generator {
|
||||||
|
// return a shared_ptr to a ScalarField object described in the json-object "object"
|
||||||
|
// has to contain a json-object "ScalarFieldFunctionInZ"
|
||||||
|
// - has to contain a json-object "zFunction" defined as in "function3D" (in "generators/function_generator.h")
|
||||||
|
// (example in "simulation_config/scalar_fields_examples.json")
|
||||||
std::shared_ptr<ScalarField> buildScalarField(json_t* object);
|
std::shared_ptr<ScalarField> buildScalarField(json_t* object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,13 +6,33 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "jansson.h"
|
#include "jansson.h"
|
||||||
|
|
||||||
|
// defined in "IO/simulation_output.h"
|
||||||
class SimulationOutput;
|
class SimulationOutput;
|
||||||
|
|
||||||
|
// defined in "simulation/species.h"
|
||||||
namespace species {
|
namespace species {
|
||||||
class TrackedSpecie;
|
class TrackedSpecie;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace generator {
|
namespace generator {
|
||||||
|
// return a shared_ptr to a SimulationOutput object defined in the given json-object
|
||||||
|
// the json-object has to consist of:
|
||||||
|
// - a json-string "folder" containing the path to where the ouput file is supposed to be written
|
||||||
|
// (relative to where the program was started from)
|
||||||
|
// - a json-string "filename": with the name of the file (a ".h5" is always appended)
|
||||||
|
// - a json-object "DensityFields", which has to contain:
|
||||||
|
// - a json-double (interpreted as an int) or a json-string called "Intervall":
|
||||||
|
// - if it's a json_double it has to > 0
|
||||||
|
// - if it's a json_string it has to have the value "EachSync", which means that after each cpu-synchronization step
|
||||||
|
// the ouput is written
|
||||||
|
// - a json-string "OverwriteLast" with value either "true" or "false" (defaults to false)
|
||||||
|
// if "true" old data is overwritten each step
|
||||||
|
// - a json-array or a json-string "Species":
|
||||||
|
// - if its a json-string it has to have the value "all" (density information is written for each tracked specie)
|
||||||
|
// - if its a json-array has to be an array of the names used in the "Tracked" object for which
|
||||||
|
// density output should be written
|
||||||
|
// - two more json-objects "CurrentBorders" and "DeletionLogger", which follow the same structure
|
||||||
|
// as the "DensityFields" object
|
||||||
std::shared_ptr<SimulationOutput> buildSimulationOutput(
|
std::shared_ptr<SimulationOutput> buildSimulationOutput(
|
||||||
json_t* object,
|
json_t* object,
|
||||||
const std::map<std::string, std::shared_ptr<species::TrackedSpecie>>&
|
const std::map<std::string, std::shared_ptr<species::TrackedSpecie>>&
|
||||||
|
|||||||
@@ -11,10 +11,13 @@
|
|||||||
#include "simulation/parameter.h"
|
#include "simulation/parameter.h"
|
||||||
#include "simulation/species.h"
|
#include "simulation/species.h"
|
||||||
|
|
||||||
|
// defined in "simulation/timer.h"
|
||||||
class Timer;
|
class Timer;
|
||||||
|
|
||||||
namespace generator {
|
namespace generator {
|
||||||
|
|
||||||
|
// structure to store various variables neccessary for the creation
|
||||||
|
// of TrackedSpecies objects
|
||||||
struct TrackedSpeciesBuilderInfo {
|
struct TrackedSpeciesBuilderInfo {
|
||||||
public:
|
public:
|
||||||
std::shared_ptr<Mover> mover;
|
std::shared_ptr<Mover> mover;
|
||||||
@@ -23,6 +26,7 @@ struct TrackedSpeciesBuilderInfo {
|
|||||||
std::shared_ptr<DynamicDensityField> density_field;
|
std::shared_ptr<DynamicDensityField> density_field;
|
||||||
std::shared_ptr<VelocityDistribution> velocity_distribution;
|
std::shared_ptr<VelocityDistribution> velocity_distribution;
|
||||||
std::shared_ptr<DriftVelocity> drift_velocity;
|
std::shared_ptr<DriftVelocity> drift_velocity;
|
||||||
|
std::shared_ptr<DynamicDensityField> last_sync_density_field;
|
||||||
|
|
||||||
double mass_kg;
|
double mass_kg;
|
||||||
double charge_C;
|
double charge_C;
|
||||||
@@ -31,6 +35,8 @@ struct TrackedSpeciesBuilderInfo {
|
|||||||
json_path path_in_json;
|
json_path path_in_json;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// structure to store various variables neccessary for the creation
|
||||||
|
// of BackgroundSpecies objects
|
||||||
struct BackgroundSpeciesBuilderInfo {
|
struct BackgroundSpeciesBuilderInfo {
|
||||||
public:
|
public:
|
||||||
BackgroundSpeciesBuilderInfo()
|
BackgroundSpeciesBuilderInfo()
|
||||||
@@ -48,65 +54,179 @@ struct BackgroundSpeciesBuilderInfo {
|
|||||||
json_path path_in_json;
|
json_path path_in_json;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class for mapping between certain strings and ImplementedSpecies enums
|
||||||
class SpeciesAlias {
|
class SpeciesAlias {
|
||||||
public:
|
public:
|
||||||
|
// return the ImplementedSpecies enum for the given string. If the
|
||||||
|
// name is not defined as an alias an error is thrown
|
||||||
static species::ImplementedSpecies alias(const std::string& name);
|
static species::ImplementedSpecies alias(const std::string& name);
|
||||||
|
// return the string defined as an alias for the given ImplemetedSpecies enum
|
||||||
|
// if no alias has been defined returns an empty string
|
||||||
|
// (if it were to be defined multiple times return the first found instance)
|
||||||
static std::string name(species::ImplementedSpecies specie);
|
static std::string name(species::ImplementedSpecies specie);
|
||||||
|
// check if the string name is defined as an alias
|
||||||
static bool isAlias(const std::string& name);
|
static bool isAlias(const std::string& name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// mapping between the string and enum
|
||||||
static std::map<std::string, species::ImplementedSpecies> specie_aliases;
|
static std::map<std::string, species::ImplementedSpecies> specie_aliases;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class mapping between ImplementedSpecies enum and the charge corresponding to
|
||||||
|
// the physical particle
|
||||||
class SpeciesCharges {
|
class SpeciesCharges {
|
||||||
public:
|
public:
|
||||||
|
// return the charge of the ImplementedSpecies enum
|
||||||
static double charge(species::ImplementedSpecies species);
|
static double charge(species::ImplementedSpecies species);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::map<species::ImplementedSpecies, double> charge_;
|
static std::map<species::ImplementedSpecies, double> charge_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class for creation of the TrackedSpecies map and the BackgroudSpecies map
|
||||||
class SpeciesBuilder {
|
class SpeciesBuilder {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: takes the Parameter object created by the input json file
|
||||||
SpeciesBuilder(Parameter& parameter);
|
SpeciesBuilder(Parameter& parameter);
|
||||||
|
|
||||||
|
// function to create a map of TrackedSpecies and an arbitrary string used to
|
||||||
|
// identify the TrackedSpecies within the map
|
||||||
|
// description for the json-object structure can be found in the private functions of
|
||||||
|
// this class (examples e.g. in "simulation_config/parameter_katrin_example")
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>
|
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>
|
||||||
trackedSpecies();
|
trackedSpecies();
|
||||||
|
// function to create a map of BackgroundSpecies and an arbitrary string used to
|
||||||
|
// identify the BackgroundSpecies within the map
|
||||||
|
// description for the json-object structure can be found in the private functions of
|
||||||
|
// this class (examples e.g. in "simulation_config/parameter_katrin_example")
|
||||||
std::map<std::string, std::shared_ptr<species::BackgroundSpecie>>
|
std::map<std::string, std::shared_ptr<species::BackgroundSpecie>>
|
||||||
backgroundSpecies();
|
backgroundSpecies();
|
||||||
|
// function to create a shared_ptr to a Timer object
|
||||||
std::shared_ptr<Timer> timer();
|
std::shared_ptr<Timer> timer();
|
||||||
|
// function to create a shared_ptr to a Timer object (to be used as a copy of the
|
||||||
|
// main timer object during cpu synchronization)
|
||||||
|
std::shared_ptr<Timer> lastSyncTimer();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<std::string, BackgroundSpeciesBuilderInfo> background_species_info;
|
std::map<std::string, BackgroundSpeciesBuilderInfo> background_species_info;
|
||||||
std::map<std::string, TrackedSpeciesBuilderInfo> tracked_species_info;
|
std::map<std::string, TrackedSpeciesBuilderInfo> tracked_species_info;
|
||||||
std::shared_ptr<Timer> timer_;
|
std::shared_ptr<Timer> timer_;
|
||||||
|
std::shared_ptr<Timer> last_sync_timer_;
|
||||||
|
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>
|
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>
|
||||||
tracked_species;
|
tracked_species;
|
||||||
std::map<std::string, std::shared_ptr<species::BackgroundSpecie>>
|
std::map<std::string, std::shared_ptr<species::BackgroundSpecie>>
|
||||||
background_species;
|
background_species;
|
||||||
|
|
||||||
|
// checks all json-objects (with an aribtrary name used as the name of the corresponding
|
||||||
|
// BackgroundSpecie) in the json-object "Background", which is located in the json-object
|
||||||
|
// "Species" (which is in the root) and creates new entries in the background_species_info
|
||||||
|
// map (and sets the name and path_in_json members)
|
||||||
|
//
|
||||||
|
// example:
|
||||||
|
// {
|
||||||
|
// "Species":{
|
||||||
|
// "Background": {
|
||||||
|
// "background1": {...},
|
||||||
|
// ...
|
||||||
|
// }
|
||||||
|
// ...
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// in this example the name is set to "background1" and path_in_json to ["Species", "Background", "background1"]
|
||||||
void initBackgroundSpecies(Parameter& parameter);
|
void initBackgroundSpecies(Parameter& parameter);
|
||||||
|
// checks all json-objects (with an aribtrary name used as the name of the corresponding
|
||||||
|
// BackgroundSpecie) in the json-object "Tracked", which is located in the json-object
|
||||||
|
// "Species" (which is in the root) and creates new entries in the background_species_info
|
||||||
|
// map (and sets the name and path_in_json members)
|
||||||
|
//
|
||||||
|
// example:
|
||||||
|
// {
|
||||||
|
// "Species":{
|
||||||
|
// "Tracked": {
|
||||||
|
// "tracked1": {...},
|
||||||
|
// ...
|
||||||
|
// }
|
||||||
|
// ...
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// in this example the name is set to "tracked1" and path_in_json to ["Species", "Tracked", "tracked1"]
|
||||||
void initTrackedSpecies(Parameter& parameter);
|
void initTrackedSpecies(Parameter& parameter);
|
||||||
|
|
||||||
|
// for each element of the background_species_info element and for each tracked_species_info element
|
||||||
|
// fill the velocity_distribution member with a VelocityDistribution object
|
||||||
|
// described in a json-object called "VelocityDistribution", that has to follow the
|
||||||
|
// format described in "buildVelocityDistribution" (generators/velocity_distribution_generator.h)
|
||||||
void fillVelocityDistribution(Parameter& parameter);
|
void fillVelocityDistribution(Parameter& parameter);
|
||||||
|
// for each element of the background_species_info element and for each tracked_species_info element
|
||||||
|
// fill the drift_velocity member with a DirftVelocity object
|
||||||
|
// described in a json-object called "DriftVelocity", that has to follow the
|
||||||
|
// format described in "buildDriftVelocity" (generators/drift_velocity_generator.h)
|
||||||
void fillDriftVelocity(Parameter& parameter);
|
void fillDriftVelocity(Parameter& parameter);
|
||||||
|
// for each element of the background_species_info element and for each tracked_species_info element
|
||||||
|
// fill the mass_kg member with the value defined in the SpeciesMasses class (defined in
|
||||||
|
// "generators/mass_generator.h")
|
||||||
void fillMass();
|
void fillMass();
|
||||||
|
// for each element of the background_species_info element and for each tracked_species_info element
|
||||||
|
// fill the charge_C member with the value defined in the SpeciesCharges class (defined here in
|
||||||
|
// "generators/species_generator.h")
|
||||||
void fillCharge();
|
void fillCharge();
|
||||||
|
// for all elements in the tracked_species map add the defined interactions
|
||||||
|
// in the path stored in the corresponding tracked_species_info element (i.e. ["Species", "Tracked", name of the tracked specie])
|
||||||
|
// a json-object "Interactions" has to exist, this object has to follow the
|
||||||
|
// format described for the "addInteractions" function (defined in "generators/interaction_generator.h")
|
||||||
void fillInteractions(Parameter& parameter);
|
void fillInteractions(Parameter& parameter);
|
||||||
|
|
||||||
|
// read the json-string "ParticleType" in the json-object at the path stored in
|
||||||
|
// path_in_json in the BackgroundSpeciesBuilderInfo map for all elements
|
||||||
|
// "ParticleType" has to be one of the strings defined as an alias in
|
||||||
|
// the SpeciesAlias class ("generators/species_generator.h")
|
||||||
void fillBackgroundSpecieType(Parameter& parameter);
|
void fillBackgroundSpecieType(Parameter& parameter);
|
||||||
|
// for all elements in the BackgroundSpeciesBuilderInfo map create the
|
||||||
|
// density member with the density field described in the json-object "ConstantDensityField"
|
||||||
|
// (in the json-object at path_in_json)
|
||||||
|
// "ConstantDensityField" has to follow the structure described in "buildConstantDensityField"
|
||||||
|
// (defined in "generators/density_field_generator.h")
|
||||||
void fillBackgroundDensity(Parameter& parameter);
|
void fillBackgroundDensity(Parameter& parameter);
|
||||||
|
|
||||||
|
// read the json-string "ParticleType" in the json-object at the path stored in
|
||||||
|
// path_in_json in the TrackedSpeciesBuilderInfo map for all elements
|
||||||
|
// "ParticleType" has to be one of the strings defined as an alias in
|
||||||
|
// the SpeciesAlias class ("generators/species_generator.h")
|
||||||
void fillTrackedSpecieType(Parameter& parameter);
|
void fillTrackedSpecieType(Parameter& parameter);
|
||||||
|
// fill current_collector and last_sync_current_collector members of the
|
||||||
|
// TrackedSpecies map, created according to the json-object
|
||||||
|
// "CurrentCollector" (located in at the path_in_json member)
|
||||||
|
// has to follow the form described in "buildCurrentCollector" ("generators/current_collector_generator.h")
|
||||||
void fillCurrentCollector(Parameter& parameter);
|
void fillCurrentCollector(Parameter& parameter);
|
||||||
|
// fill deletion_logger and last_sync_deletion_logger members of the
|
||||||
|
// TrackedSpecies map, created according to the json-object
|
||||||
|
// "Loggers" (located in at the path_in_json member)
|
||||||
|
// has to follow the form described in "buildDeletionLogger" ("generators/logger_generator.h")
|
||||||
void fillLoggers(Parameter& parameter);
|
void fillLoggers(Parameter& parameter);
|
||||||
|
// fill mover member of the TrackedSpeciesBuilderInfo map,
|
||||||
|
// created according to the json-object "Mover" (located in at the path_in_json member)
|
||||||
|
// has to follow the form described in "buildMover" ("generators/mover_generator.h")
|
||||||
void fillMover(Parameter& parameter);
|
void fillMover(Parameter& parameter);
|
||||||
|
// fill terminator member of the TrackedSpeciesBuilderInfo map,
|
||||||
|
// created according to the json-object "Terminator" (located in at the path_in_json member)
|
||||||
|
// has to follow the form described in "buildTerminator" ("generators/mover_generator.h")
|
||||||
void fillTerminator(Parameter& parameter);
|
void fillTerminator(Parameter& parameter);
|
||||||
|
// fill reflector member of the TrackedSpeciesBuilderInfo map,
|
||||||
|
// created according to the json-object "Reflector" (located in at the path_in_json member)
|
||||||
|
// has to follow the form described in "buildReflector" ("generators/mover_generator.h")
|
||||||
void fillReflector(Parameter& parameter);
|
void fillReflector(Parameter& parameter);
|
||||||
|
// fill density_field and last_sync_density_field members of the
|
||||||
|
// TrackedSpeciesBuilderInfo map, created according to the json-object
|
||||||
|
// "DynamicDensityField" (located in at the path_in_json member)
|
||||||
|
// has to follow the form described in "buildDyamicDensityField"
|
||||||
void fillTrackedDensity(Parameter& parameter);
|
void fillTrackedDensity(Parameter& parameter);
|
||||||
|
|
||||||
|
// fill timer_ and last_sync_timer_ objects (no json-specifications needed)
|
||||||
void initTimer();
|
void initTimer();
|
||||||
|
// create the TrackedSpecies and BackgroundSpecies maps from the data contained in
|
||||||
|
// the corresponding entries of the TrackedSpeciesBuilderInfo and BackgroundSpeciesBuilderInfo
|
||||||
|
// maps
|
||||||
void buildSpecies();
|
void buildSpecies();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,13 @@
|
|||||||
|
|
||||||
namespace generator {
|
namespace generator {
|
||||||
|
|
||||||
|
// return a shared_ptr to a Terminator object described by the given json-object in the Parameter object
|
||||||
|
// the object at the path has to contain:
|
||||||
|
// - a json-double (later cast to an integer) "MaximumInteractions"
|
||||||
|
// - a json-object "MaxTimeAlive", which has to contain a json-double "value", giving the
|
||||||
|
// maximum time a particle is allowed to live in seconds
|
||||||
|
// - a json-object "BoundaryGeometry", which has to follow the structure given in buildGeometry
|
||||||
|
// ("generators/geometry_generator.h")
|
||||||
std::shared_ptr<Terminator> buildTerminator(
|
std::shared_ptr<Terminator> buildTerminator(
|
||||||
Parameter& parameter,
|
Parameter& parameter,
|
||||||
const json_path& path_to_terminator);
|
const json_path& path_to_terminator);
|
||||||
|
|||||||
@@ -8,9 +8,57 @@
|
|||||||
#include "simulation/vector_field.h"
|
#include "simulation/vector_field.h"
|
||||||
|
|
||||||
namespace generator {
|
namespace generator {
|
||||||
|
// create an VectorField object from a json_t pointer to an json object
|
||||||
|
// defining the vector field:
|
||||||
|
// has to contain a json-object with key either: "VectorFieldConstant", "VectorFieldFunctionInZ" or "VectorFieldFromArray"
|
||||||
|
// if neither of those is specified an error is thrown
|
||||||
|
// if "VectorFieldConstant" is specified:
|
||||||
|
// - has to contain a json-object called "constant" containing a json-array of size 3 (r,phi and z component in this ordering)
|
||||||
|
// with an arbitrary key
|
||||||
|
// if "VectorFieldFunctionInZ" is specifid:
|
||||||
|
// - has to contain a json-object with key "zFunction", that defines a function3D (see "generators/function_generator.h")
|
||||||
|
// if "VectorFieldFromArray" is specified:
|
||||||
|
// - has to contain a json-object called "ReadArrayFromFile" (see readComponentFromFile)
|
||||||
|
// - a json-double "Radius" specifying the radial extent for which the read in vector field is defined
|
||||||
|
// - a json-double "Length" specifying the longitudinal extent for which the read in vector field is defined
|
||||||
|
// examples for the look in a json file can be found in "simulation_config/vector_field_examples.json"
|
||||||
std::shared_ptr<VectorField> buildVectorField(json_t* object);
|
std::shared_ptr<VectorField> buildVectorField(json_t* object);
|
||||||
|
|
||||||
|
// read a path to a file from a json-object consisting of three json-string objects:
|
||||||
|
// - "Type": acceptable value either "AbsolutePath" or "RelativeToHomebase", if neither is specified throw an error
|
||||||
|
// - if "Type" is "AbsolutePath", the json-string with key "AbsoluteFolderPath" has to be defined, containing
|
||||||
|
// the absolute path to the directory the file that should be read is located in
|
||||||
|
// - if "Type" is "RelativeToHomebase", the json-string with key "RelativePath" has to be defined, containing
|
||||||
|
// the path relative (wrt the shell variable "HOMEBASE") to the directory the file that should be read is located in
|
||||||
|
// - the json-string with key "Filename", containing the name of the file to be read
|
||||||
|
//
|
||||||
|
// "key_of_object": {
|
||||||
|
// "Type": "RelativeToHomebase" or "AbsolutePath",
|
||||||
|
// "RelativePath" or "AbsoluteFolderPath": path to directory
|
||||||
|
// "Filename": name of file in the path to the directory
|
||||||
|
// }
|
||||||
std::string readAbsoluteFilename(json_t* object);
|
std::string readAbsoluteFilename(json_t* object);
|
||||||
|
|
||||||
|
// read a single component (radial, azimuthal or longitudinal) into a blitz::Array
|
||||||
|
// has to consist of:
|
||||||
|
// - a json_object called "PathToH5" in the format described for the function "readAbsoluteFilename"
|
||||||
|
// - a json_array "Keys" consisting of the keys of the absolute path to groups that should be read from the given hdf5 file
|
||||||
|
//
|
||||||
|
// "key_to_object": {
|
||||||
|
// "PathToH5" : { ... },
|
||||||
|
// "Keys": [path to component of vector field in r-dir, path to component of vector field in phi-dir, path to component of vector field in z-dir]
|
||||||
|
// }
|
||||||
blitz::Array<double, 3> readComponentFromFile(json_t* object, int component);
|
blitz::Array<double, 3> readComponentFromFile(json_t* object, int component);
|
||||||
|
|
||||||
|
// read a single 3d array into a blitz::Array
|
||||||
|
// has to consist of:
|
||||||
|
// - a json_object called "PathToH5" in the format described for the function "readAbsoluteFilename"
|
||||||
|
// - a json_string "Key" specifying the path to the array within the hdf5 file
|
||||||
|
//
|
||||||
|
// "key_to_object": {
|
||||||
|
// "PathToH5" : { ... },
|
||||||
|
// "Key": path within hdf5 file
|
||||||
|
// }
|
||||||
blitz::Array<double, 3> readFromFile(json_t* object);
|
blitz::Array<double, 3> readFromFile(json_t* object);
|
||||||
} // namespace generator
|
} // namespace generator
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,21 @@
|
|||||||
|
|
||||||
namespace generator {
|
namespace generator {
|
||||||
|
|
||||||
|
// return a shared_ptr to a VelocityDistributionFunction object described by the json-object
|
||||||
|
// at the given json_path in the Parameter object
|
||||||
|
// has to contain a json-object called either "IsotropicDistribution" or "DirectedDistribution"
|
||||||
|
// if "IsotropicDistribution" is specified:
|
||||||
|
// - has to include a json-object "EnergyDistributionFunction" as defined in "generators/energy_distribtion_function_generator.h"
|
||||||
|
// - has to include a json-object "Mass" as defined in "generators/mass_generator.h"
|
||||||
|
// - returns a IsotropicDistribution object (see simulation/energy_distribtion.h)
|
||||||
|
//
|
||||||
|
// if "DirectedDistribution" is specified:
|
||||||
|
// - has to include a json-object "EnergyDistributionFunction" as defined in "generators/energy_distribtion_function_generator.h"
|
||||||
|
// - has to include a json-object "Mass" as defined in "generators/mass_generator.h"
|
||||||
|
// - has to include a json-object "Direction", including a json-array "vector" containing the direction in cartesian coordinates
|
||||||
|
// - returns a DirectedDistribution object (see simulation/energy_distribtion.h)
|
||||||
|
//
|
||||||
|
// (example in "simulation_config/velocity_distribution_function_examples.json")
|
||||||
std::shared_ptr<VelocityDistributionFunction> buildVelocityDistributionFunction(
|
std::shared_ptr<VelocityDistributionFunction> buildVelocityDistributionFunction(
|
||||||
Parameter& parameter,
|
Parameter& parameter,
|
||||||
const json_path& path_to_distribution);
|
const json_path& path_to_distribution);
|
||||||
|
|||||||
@@ -8,6 +8,25 @@
|
|||||||
|
|
||||||
namespace generator {
|
namespace generator {
|
||||||
|
|
||||||
|
// return a shared_ptr to a VelocityDistribution object described by the json-object
|
||||||
|
// at the path "path_to_distribution" (from root object) in the Parameter object
|
||||||
|
// consisting of a json-object either called "VelocityDistributionFromFunction" or "null"
|
||||||
|
// if "VelocityDistributionFromFunction" is specified:
|
||||||
|
// - has to consist of a json-object "VelocityDistributionFunction", as defined in "generators/velocity_distribution_function_generator.h"
|
||||||
|
//
|
||||||
|
// if "null" is specified:
|
||||||
|
// - no further information has to be specified
|
||||||
|
//
|
||||||
|
// example:
|
||||||
|
// "path_to_distribution" : {
|
||||||
|
// "VelocityDistributionFromFunction": {
|
||||||
|
// "VelocityDistributionFunction" : { ... }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// or
|
||||||
|
// "path_to_distribution" : {
|
||||||
|
// "null": {}
|
||||||
|
// }
|
||||||
std::shared_ptr<VelocityDistribution> buildVelocityDistribution(
|
std::shared_ptr<VelocityDistribution> buildVelocityDistribution(
|
||||||
Parameter& parameter,
|
Parameter& parameter,
|
||||||
const json_path& path_to_distribution);
|
const json_path& path_to_distribution);
|
||||||
|
|||||||
@@ -4,17 +4,23 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include "simulation/interaction.h"
|
#include "simulation/interaction.h"
|
||||||
|
|
||||||
|
// defined in "simulation/species.h"
|
||||||
namespace species {
|
namespace species {
|
||||||
class Specie;
|
class Specie;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace interaction {
|
namespace interaction {
|
||||||
|
|
||||||
|
// class for charge exchange interactions e.g. T2+ + T2 --> T2 + T2+
|
||||||
|
// only for symmetric charge exchange processes (i.e. A+ + A --> A + A+)
|
||||||
class ChargeExchange : public Interaction {
|
class ChargeExchange : public Interaction {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: takes the function describing the cross section (dependent on the energy of the incident particle)
|
||||||
|
// and a shared_ptr to the Species that is the target in the interaction
|
||||||
ChargeExchange(std::function<double(double)> cross_section,
|
ChargeExchange(std::function<double(double)> cross_section,
|
||||||
std::shared_ptr<species::Specie> target);
|
std::shared_ptr<species::Specie> target);
|
||||||
|
|
||||||
|
// return the result of the interaction as an InteractionOutput object
|
||||||
InteractionOutput performInteraction(particle::Particle& particle,
|
InteractionOutput performInteraction(particle::Particle& particle,
|
||||||
RandomNumbers* generator);
|
RandomNumbers* generator);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,24 +4,46 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include "simulation/interaction.h"
|
#include "simulation/interaction.h"
|
||||||
|
|
||||||
|
// defined in "simulation/species.h"
|
||||||
namespace species {
|
namespace species {
|
||||||
class Specie;
|
class Specie;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace interaction {
|
namespace interaction {
|
||||||
|
|
||||||
|
// class for cluster formation interactions (A + B --> AB) or (A + BC --> AB + C)
|
||||||
class ClusterFormation : public Interaction {
|
class ClusterFormation : public Interaction {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: takes the function describing the cross section (dependent on the energy of the incident particle)
|
||||||
|
// and a shared_ptr to the Species that is the target in the interaction
|
||||||
|
// and a shared_ptr to the TrackedSpecie that is the product of the interaction
|
||||||
ClusterFormation(std::function<double(double)> cross_section,
|
ClusterFormation(std::function<double(double)> cross_section,
|
||||||
std::shared_ptr<species::Specie> target,
|
std::shared_ptr<species::Specie> target,
|
||||||
std::shared_ptr<species::TrackedSpecie> product);
|
std::shared_ptr<species::TrackedSpecie> product);
|
||||||
|
// return an InteractionOutput object with the results of the interaction
|
||||||
InteractionOutput performInteraction(particle::Particle& particle,
|
InteractionOutput performInteraction(particle::Particle& particle,
|
||||||
RandomNumbers* generator);
|
RandomNumbers* generator);
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
std::shared_ptr<species::TrackedSpecie> product_;
|
std::shared_ptr<species::TrackedSpecie> product_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class for tertiary association (A + B + B --> AB + B)
|
||||||
|
class ClusterFormationTertiary : public ClusterFormation {
|
||||||
|
public:
|
||||||
|
// Constructor: takes the function describing the cross section (dependent on the energy of the incident particle)
|
||||||
|
// and a shared_ptr to the Species that is the target in the interaction
|
||||||
|
// and a shared_ptr to the TrackedSpecie that is the product of the interaction
|
||||||
|
ClusterFormationTertiary(std::function<double(double)> cross_section,
|
||||||
|
std::shared_ptr<species::Specie> target,
|
||||||
|
std::shared_ptr<species::TrackedSpecie> product);
|
||||||
|
|
||||||
|
// due to only the rate coefficients being available the cross section is
|
||||||
|
// approximated as sigma = rate_coefficient * density / velocity
|
||||||
|
// (units of the tertiary rate coefficient m^6/s)
|
||||||
|
double microscopicCrossSection(double energy_eV, const Coordinate& position);
|
||||||
|
};
|
||||||
|
|
||||||
}; // namespace interaction
|
}; // namespace interaction
|
||||||
|
|
||||||
#endif /* CLUSTER_FORMATION_H */
|
#endif /* CLUSTER_FORMATION_H */
|
||||||
|
|||||||
@@ -7,43 +7,102 @@
|
|||||||
namespace interaction {
|
namespace interaction {
|
||||||
|
|
||||||
namespace d2CrossSection {
|
namespace d2CrossSection {
|
||||||
|
// returns a function dependent on the initial energy of the electron ionization
|
||||||
|
// of T2 and the final energy of (one of) the resulting electrons
|
||||||
|
// function defines the energy distribution of the energy distribution of
|
||||||
|
// the secondary electron
|
||||||
|
// (functional form from Kim and Rudd 1994)
|
||||||
std::function<double(double, double)> eT2_ionization_bed();
|
std::function<double(double, double)> eT2_ionization_bed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ? mention how data was obtained ?
|
||||||
namespace totalCrossSection {
|
namespace totalCrossSection {
|
||||||
|
|
||||||
|
// returns function that returns a constant value of 1.4e-19 m²
|
||||||
std::function<double(double)> eT2_elastic_scattering_constant();
|
std::function<double(double)> eT2_elastic_scattering_constant();
|
||||||
|
// returns a function that linearly interpolates between the values
|
||||||
|
// defined in the file "data/crossSections/eT2_elastic_scattering/eT2_elastic_cross_section_total.h5"
|
||||||
|
// (relative to the HOMEBASE variable)
|
||||||
|
// data for e + T2 elastic scattering
|
||||||
std::function<double(double)> eT2_elastic_scattering();
|
std::function<double(double)> eT2_elastic_scattering();
|
||||||
std::function<double(double)> TpT2_elasitc_scattering_tabata();
|
// return function that describes the total elastic scattering cross section
|
||||||
std::function<double(double)> T3pT2_elasitc_scattering_tabata();
|
// for T⁺ + T₂
|
||||||
|
std::function<double(double)> TpT2_elastic_scattering_tabata();
|
||||||
|
// return function that describes the total elastic scattering cross section
|
||||||
|
// for T₃⁺ + T₂
|
||||||
|
std::function<double(double)> T3pT2_elastic_scattering_tabata();
|
||||||
|
|
||||||
|
// return a function that describes the cross section for charge exchange
|
||||||
|
// T₂⁺ + T₂ --> T₂ + T₂⁺
|
||||||
std::function<double(double)> T2pT2_charge_exchange_janev();
|
std::function<double(double)> T2pT2_charge_exchange_janev();
|
||||||
|
|
||||||
|
// return a function describing the cross section for electron ionization of
|
||||||
|
// T₂: T₂ + e¯ --> T₂⁺ + 2e¯ (?)
|
||||||
std::function<double(double)> eT2_ionization_bed();
|
std::function<double(double)> eT2_ionization_bed();
|
||||||
|
// return a function describing the non-dissociative cross section for electron ionization of
|
||||||
|
// T₂: T₂ + e¯ --> T₂⁺ + 2e¯
|
||||||
std::function<double(double)> eT2_ionization_janev_non_diss();
|
std::function<double(double)> eT2_ionization_janev_non_diss();
|
||||||
|
// return a function describing the cross section for dissociative electron ionization of
|
||||||
|
// T₂, where the products are in the ground state: T₂ + e¯ --> T⁺ + T + 2e¯ (?)
|
||||||
std::function<double(double)> eT2_ionization_janev_diss_ground();
|
std::function<double(double)> eT2_ionization_janev_diss_ground();
|
||||||
|
// return a function describing the cross section for dissociative electron ionization of
|
||||||
|
// T₂, where the products are in the first excited state: T₂ + e¯ --> T⁺ + T* + 2e¯ (?)
|
||||||
std::function<double(double)> eT2_ionization_janev_diss_first();
|
std::function<double(double)> eT2_ionization_janev_diss_first();
|
||||||
|
|
||||||
|
// return a function describing the cross section for radiative clustering of T⁺ and T₂:
|
||||||
|
// T⁺ + T₂ --> T₃⁺ + h\nu
|
||||||
std::function<double(double)> TpT2_clustering_radiative_ascendion_pasil();
|
std::function<double(double)> TpT2_clustering_radiative_ascendion_pasil();
|
||||||
|
// return a function describing the cross section up to the density of the T₂ at
|
||||||
|
// the position of the interaction for tertiary clustering of T⁺ and T₂:
|
||||||
|
// T⁺ + 2T₂ --> T₃⁺ + T₂
|
||||||
|
// cross section = k_tertiary / velocity * density_target
|
||||||
|
// return only a function calculating k_tertiary / velocity (k_tertiary: tertiary rate coefficient)
|
||||||
std::function<double(double)> TpT2_clustering_tertiary_ascendion_pasil();
|
std::function<double(double)> TpT2_clustering_tertiary_ascendion_pasil();
|
||||||
|
// return a function describing the cross section for clustering of T₂⁺ and T₂:
|
||||||
|
// T₂⁺ + T₂ --> T₃⁺ + T
|
||||||
std::function<double(double)> T2pT2_clustering_janev();
|
std::function<double(double)> T2pT2_clustering_janev();
|
||||||
|
|
||||||
|
// return a function describing the cross section for electronic excitation of T₂ by
|
||||||
|
// the impact of an electron from the singlet ground state to the final state
|
||||||
|
// specified in the string "final_state". final_state has to have one of the following
|
||||||
|
// values: "B1", "B1prime", "B1primeprime", "C1", "D1", "D1prime"
|
||||||
std::function<double(double)>
|
std::function<double(double)>
|
||||||
eT2_excitation_electric_janev_from_singlet_ground_state(
|
eT2_excitation_electric_janev_from_singlet_ground_state(
|
||||||
std::string final_state);
|
std::string final_state);
|
||||||
|
// return a function describing the cross section for electronic excitation of T₂ by
|
||||||
|
// the impact of an electron from the singlet ground state to the final state that is
|
||||||
|
// forbidden by the symmetry of the system specified in the string "final_state".
|
||||||
|
// final_state has to have one of the following values:
|
||||||
|
// "EF1", "HHb", "GK1", "I1"
|
||||||
std::function<double(double)>
|
std::function<double(double)>
|
||||||
eT2_excitation_electric_janev_from_singlet_ground_state_symmetry_forbidden(
|
eT2_excitation_electric_janev_from_singlet_ground_state_symmetry_forbidden(
|
||||||
std::string final_state);
|
std::string final_state);
|
||||||
|
// return a function describing the cross section for electronic excitation of T₂ by
|
||||||
|
// the impact of an electron from the triplet ground state to the final state
|
||||||
|
// specified in the string "final_state". final_state has to have one of the following
|
||||||
|
// values: "A3", "B3", "C3", "D3", "E3"
|
||||||
std::function<double(double)>
|
std::function<double(double)>
|
||||||
eT2_excitation_electric_janev_from_triplet_ground_state(
|
eT2_excitation_electric_janev_from_triplet_ground_state(
|
||||||
std::string final_state);
|
std::string final_state);
|
||||||
|
|
||||||
|
// return a function describing the cross section for vibrational excitation of T₂
|
||||||
|
// from ground to first excited state by electron impact.
|
||||||
std::function<double(double)> eT2_excitation_vibrational_janev_first();
|
std::function<double(double)> eT2_excitation_vibrational_janev_first();
|
||||||
|
// return a function describing the cross section for vibrational excitation of T₂
|
||||||
|
// from ground to second excited state by electron impact.
|
||||||
std::function<double(double)> eT2_excitation_vibrational_janev_second();
|
std::function<double(double)> eT2_excitation_vibrational_janev_second();
|
||||||
|
// return a function describing the cross section for rotational excitation of T₂
|
||||||
|
// from ground to second excited state by electron impact.
|
||||||
std::function<double(double)> eT2_excitation_rotational_j0_to_j2_england();
|
std::function<double(double)> eT2_excitation_rotational_j0_to_j2_england();
|
||||||
|
// return a function describing the cross section for rotational excitation of T₂
|
||||||
|
// from first to third excited state by electron impact.
|
||||||
std::function<double(double)> eT2_excitation_rotational_j1_to_j3_england();
|
std::function<double(double)> eT2_excitation_rotational_j1_to_j3_england();
|
||||||
|
|
||||||
|
// return a function describing the cross section for recombination of T₂⁺ with an
|
||||||
|
// electron: T₂⁺ + e⁼ --> T₂
|
||||||
std::function<double(double)> eT2p_recombination_janev();
|
std::function<double(double)> eT2p_recombination_janev();
|
||||||
|
// return a function describing the cross section for recombination of T₃⁺ with an
|
||||||
|
// electron: T₃⁺ + e⁼ --> T₂ + T
|
||||||
std::function<double(double)> eT3p_recombination_janev();
|
std::function<double(double)> eT3p_recombination_janev();
|
||||||
|
|
||||||
}; // namespace totalCrossSection
|
}; // namespace totalCrossSection
|
||||||
|
|||||||
@@ -7,12 +7,16 @@ class ScatteringAngleDistribution;
|
|||||||
|
|
||||||
namespace interaction {
|
namespace interaction {
|
||||||
|
|
||||||
|
// class for handling elastic scattering interactions (A + B --> A + B)
|
||||||
class ElasticScattering : public Interaction {
|
class ElasticScattering : public Interaction {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: takes a function for the cross section, a shared_ptr with the Specie of the target of the interaction
|
||||||
|
// and a shared_ptr to a scatteringAngleDistribution object
|
||||||
ElasticScattering(std::function<double(double)> cross_section,
|
ElasticScattering(std::function<double(double)> cross_section,
|
||||||
std::shared_ptr<species::Specie> target,
|
std::shared_ptr<species::Specie> target,
|
||||||
std::shared_ptr<ScatteringAngleDistribution> theta_distrib);
|
std::shared_ptr<ScatteringAngleDistribution> theta_distrib);
|
||||||
|
|
||||||
|
// return the interaction outcome as an InteractionOutput object
|
||||||
InteractionOutput performInteraction(particle::Particle& particle,
|
InteractionOutput performInteraction(particle::Particle& particle,
|
||||||
RandomNumbers* generator);
|
RandomNumbers* generator);
|
||||||
|
|
||||||
|
|||||||
@@ -6,18 +6,24 @@
|
|||||||
#include "simulation/particle.h"
|
#include "simulation/particle.h"
|
||||||
#include "simulation/random_numbers.h"
|
#include "simulation/random_numbers.h"
|
||||||
|
|
||||||
|
// defined in "simulation/species.h"
|
||||||
namespace species {
|
namespace species {
|
||||||
class Specie;
|
class Specie;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace interaction {
|
namespace interaction {
|
||||||
|
|
||||||
|
// class for handling processes consisting of the excitation (rotational, vibrational or
|
||||||
|
// electronic) of the target particle (e.g. A + B --> A + B*)
|
||||||
class Excitation : public Interaction {
|
class Excitation : public Interaction {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: takes the function for the cross section, a shared_ptr to the Specie of the
|
||||||
|
// the threshold energy of the specific excitation type
|
||||||
Excitation(std::function<double(double)> cross_section,
|
Excitation(std::function<double(double)> cross_section,
|
||||||
std::shared_ptr<species::Specie> target,
|
std::shared_ptr<species::Specie> target,
|
||||||
double excitation_energy_eV);
|
double excitation_energy_eV);
|
||||||
|
|
||||||
|
// return the output of the interaction as an InteractionOutput object
|
||||||
InteractionOutput performInteraction(particle::Particle& particle,
|
InteractionOutput performInteraction(particle::Particle& particle,
|
||||||
RandomNumbers* generator);
|
RandomNumbers* generator);
|
||||||
|
|
||||||
|
|||||||
@@ -7,13 +7,19 @@
|
|||||||
|
|
||||||
namespace interaction {
|
namespace interaction {
|
||||||
|
|
||||||
|
// class for dummy interaction "free movement" (i.e. no interaction)
|
||||||
class FreeMovement : public Interaction {
|
class FreeMovement : public Interaction {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: does not need anything
|
||||||
FreeMovement();
|
FreeMovement();
|
||||||
|
// return the result of the interaction as an InteractionOutput object
|
||||||
InteractionOutput performInteraction(particle::Particle& particle,
|
InteractionOutput performInteraction(particle::Particle& particle,
|
||||||
RandomNumbers* generator);
|
RandomNumbers* generator);
|
||||||
|
|
||||||
double microscopicCrossSection(double energy_eV);
|
// return the value of the cross section at the given energy (eV) (units: m^2)
|
||||||
|
double microscopicCrossSection(double energy_eV, const Coordinate& position);
|
||||||
|
// return the density scaled cross section value for the energy of the
|
||||||
|
// Particle (units m^{-1})
|
||||||
double macroscopicCrossSection(particle::Particle& particle);
|
double macroscopicCrossSection(particle::Particle& particle);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -5,11 +5,18 @@
|
|||||||
|
|
||||||
namespace interaction {
|
namespace interaction {
|
||||||
|
|
||||||
|
// class for drawing the energy of the outgoing electron (i.e. the slower one of the
|
||||||
|
// two electrons that exist after the interaction)
|
||||||
class IonizationEnergyDistribution {
|
class IonizationEnergyDistribution {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: takes a function dependent on the energy of the incident particle
|
||||||
|
// and the energy of the ejected electron. Function should describe
|
||||||
|
// the energy distribution of the ejected electron.
|
||||||
|
// takes the ionization threshold energy in eV
|
||||||
IonizationEnergyDistribution(
|
IonizationEnergyDistribution(
|
||||||
std::function<double(double, double)> d2_cross_section,
|
std::function<double(double, double)> d2_cross_section,
|
||||||
double ionization_energy_eV);
|
double ionization_energy_eV);
|
||||||
|
// draw the energy (always < (impact_energy - ionization_energy)/2) of the ejected particle
|
||||||
double rollImpactParticleEnergyAfterCollision(double impact_energy,
|
double rollImpactParticleEnergyAfterCollision(double impact_energy,
|
||||||
RandomNumbers* generator);
|
RandomNumbers* generator);
|
||||||
|
|
||||||
@@ -18,20 +25,37 @@ class IonizationEnergyDistribution {
|
|||||||
const double ionization_energy_eV_;
|
const double ionization_energy_eV_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// function handling the azimuthal angle distribution for
|
||||||
|
// electron ionization
|
||||||
class IonizationScatteringAngleDistribution {
|
class IonizationScatteringAngleDistribution {
|
||||||
public:
|
public:
|
||||||
|
// draw the azimuthal angle of the faster electron after collision
|
||||||
|
// impact_energy is the kinetic energy of the particle in the rest frame of the target in eV before the collision
|
||||||
|
// impact_energy is the kinetic energy of the particle (the faster of the two electrons) in the rest frame of the target in eV after the collision
|
||||||
double rollAzimuthImpactParticleAfterCollision(
|
double rollAzimuthImpactParticleAfterCollision(
|
||||||
double impact_energy,
|
double impact_energy,
|
||||||
double energy_impact_particle_new,
|
double energy_impact_particle_new,
|
||||||
RandomNumbers* generator);
|
RandomNumbers* generator);
|
||||||
|
// draw the azimuthal angle of the slower electron after collision
|
||||||
|
// impact_energy is the kinetic energy of the particle in the rest frame of the target in eV before the collision
|
||||||
|
// impact_energy is the kinetic energy of the particle (the slower of the two electrons) in the rest frame of the target in eV after the collision
|
||||||
double rollAzimuthEjectedParticleAfterCollision(
|
double rollAzimuthEjectedParticleAfterCollision(
|
||||||
double impact_energy,
|
double impact_energy,
|
||||||
double energy_impactParticle_new,
|
double energy_impactParticle_new,
|
||||||
RandomNumbers* generator);
|
RandomNumbers* generator);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class for handling electron impact ionization
|
||||||
class ElectronIonization : public Interaction {
|
class ElectronIonization : public Interaction {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: takes a function describing the cross section for the interaction
|
||||||
|
// a shared_ptr to the Specie of the target particle
|
||||||
|
// a shared_ptr to the TrackedSpecie electron describing the incident electron
|
||||||
|
// a shared_ptr to the TrackedSpecie ion describing the positive ion type that is created
|
||||||
|
// a shared_ptr to the IonizationEnergyDistribution, descibing the energy distribution of either
|
||||||
|
// of the two electrons after the interaction
|
||||||
|
// a shared_ptr to the IonizationScatterinAngleDistribution, which describes the
|
||||||
|
// azimuthal angle distribution of both final electrons
|
||||||
ElectronIonization(
|
ElectronIonization(
|
||||||
std::function<double(double)> cross_section,
|
std::function<double(double)> cross_section,
|
||||||
std::shared_ptr<species::Specie> target,
|
std::shared_ptr<species::Specie> target,
|
||||||
@@ -41,6 +65,8 @@ class ElectronIonization : public Interaction {
|
|||||||
std::shared_ptr<IonizationScatteringAngleDistribution> angle_distribution,
|
std::shared_ptr<IonizationScatteringAngleDistribution> angle_distribution,
|
||||||
double ionization_energy_eV);
|
double ionization_energy_eV);
|
||||||
|
|
||||||
|
// perform the interaction and return an InteractionOutput object
|
||||||
|
// containing the corresponding information (new particles)
|
||||||
InteractionOutput performInteraction(particle::Particle& particle,
|
InteractionOutput performInteraction(particle::Particle& particle,
|
||||||
RandomNumbers* generator);
|
RandomNumbers* generator);
|
||||||
|
|
||||||
|
|||||||
@@ -5,15 +5,23 @@
|
|||||||
|
|
||||||
namespace interaction {
|
namespace interaction {
|
||||||
|
|
||||||
|
// class for handling recombination between two simulated species (TrackedSpecies)
|
||||||
class Recombination : public Interaction {
|
class Recombination : public Interaction {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: takes a function describing the energy dependent cross section
|
||||||
|
// and a shared_ptr to the TrackedSpecie that is the target in the interaction
|
||||||
Recombination(std::function<double(double)> cross_section,
|
Recombination(std::function<double(double)> cross_section,
|
||||||
std::shared_ptr<species::TrackedSpecie> target);
|
std::shared_ptr<species::TrackedSpecie> target);
|
||||||
|
|
||||||
|
// return the result of the interaction as an InteractionOutput object
|
||||||
InteractionOutput performInteraction(particle::Particle& particle,
|
InteractionOutput performInteraction(particle::Particle& particle,
|
||||||
RandomNumbers* generator);
|
RandomNumbers* generator);
|
||||||
|
// return the cross section scaled by the density of the target at the position
|
||||||
|
// of the incident particle (units: m^{-1})
|
||||||
|
double macroscopicCrossSection(particle::Particle& particle);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
double macroscopicCrossSection(const Coordinate& position, const int bin_index);
|
||||||
std::shared_ptr<species::TrackedSpecie> recombination_target_;
|
std::shared_ptr<species::TrackedSpecie> recombination_target_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#include "constants/sim_constants.h"
|
#include "constants/sim_constants.h"
|
||||||
|
|
||||||
|
// check if a and b are the same up to an accuracy eps defined in constants/sim_constants.h
|
||||||
|
// isEqual(a,b) = true <=> abs(a - b) < eps
|
||||||
bool isEqual(double a, double b) {
|
bool isEqual(double a, double b) {
|
||||||
return std::abs(a - b) < SimConstants::compare_epsilon;
|
return std::abs(a - b) < SimConstants::compare_epsilon;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,41 +3,72 @@
|
|||||||
|
|
||||||
#include "blitz/array.h"
|
#include "blitz/array.h"
|
||||||
|
|
||||||
|
// Note: seems to be deprecated
|
||||||
|
// structure to store a coordinate wrt the binning of the simulation domain
|
||||||
struct BinCoordinate {
|
struct BinCoordinate {
|
||||||
|
// Constructor using a blitz::TinyVector<int,3> containing the values defining a bin
|
||||||
|
// and the position frac within that bin
|
||||||
BinCoordinate(const blitz::TinyVector<int, 3>& bin,
|
BinCoordinate(const blitz::TinyVector<int, 3>& bin,
|
||||||
const blitz::TinyVector<double, 3>& frac);
|
const blitz::TinyVector<double, 3>& frac);
|
||||||
|
|
||||||
|
// Constructor using a blitz::TinyVector<double,3> containing the position and the spacing
|
||||||
|
// to calculate the bin and frac values
|
||||||
BinCoordinate(blitz::TinyVector<double, 3> position,
|
BinCoordinate(blitz::TinyVector<double, 3> position,
|
||||||
blitz::TinyVector<double, 3> spacing);
|
blitz::TinyVector<double, 3> spacing);
|
||||||
|
|
||||||
blitz::TinyVector<int, 3> bin;
|
blitz::TinyVector<int, 3> bin;
|
||||||
blitz::TinyVector<double, 3> frac;
|
blitz::TinyVector<double, 3> frac;
|
||||||
|
|
||||||
|
// return the blitz::TinyVector<int, 3> containing the bin of the variable
|
||||||
|
// position using the specified "spacing"
|
||||||
static blitz::TinyVector<int, 3> binValue(
|
static blitz::TinyVector<int, 3> binValue(
|
||||||
blitz::TinyVector<double, 3> position,
|
blitz::TinyVector<double, 3> position,
|
||||||
blitz::TinyVector<double, 3> spacing);
|
blitz::TinyVector<double, 3> spacing);
|
||||||
|
|
||||||
|
// return the blitz::TinyVector<int, 3> containing the fractional value within a bin
|
||||||
|
// of the variable position using the specified "spacing"
|
||||||
static blitz::TinyVector<double, 3> binFrac(
|
static blitz::TinyVector<double, 3> binFrac(
|
||||||
blitz::TinyVector<double, 3> position,
|
blitz::TinyVector<double, 3> position,
|
||||||
blitz::TinyVector<double, 3> spacing);
|
blitz::TinyVector<double, 3> spacing);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// parent class for different Coordinate types (cartesian, cylinder)
|
||||||
|
// cannot be instantiated
|
||||||
class Coordinate {
|
class Coordinate {
|
||||||
public:
|
public:
|
||||||
|
// return the value of the stored coordinate transformed to Cartesian space
|
||||||
virtual blitz::TinyVector<double, 3> cartesianEntries() const = 0;
|
virtual blitz::TinyVector<double, 3> cartesianEntries() const = 0;
|
||||||
|
// return the value of the stored coordinate transformed to Cylinder space
|
||||||
virtual blitz::TinyVector<double, 3> cylinderEntries() const = 0;
|
virtual blitz::TinyVector<double, 3> cylinderEntries() const = 0;
|
||||||
|
|
||||||
|
// return cos(phi) with phi the second variable of the coordinate in cylinder
|
||||||
|
// coordinates
|
||||||
|
virtual double cosAzimuth() const = 0;
|
||||||
|
// return cos(phi) with phi the second variable of the coordinate in cylinder
|
||||||
|
// coordinates
|
||||||
|
virtual double sinAzimuth() const = 0;
|
||||||
|
|
||||||
|
// add the values of the parameter coordinate to the value stored in this variable
|
||||||
virtual void add(const Coordinate& coordinate) = 0;
|
virtual void add(const Coordinate& coordinate) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class for storing and handling of coordinates in cartesian space
|
||||||
class CartesianCoordinate : public Coordinate {
|
class CartesianCoordinate : public Coordinate {
|
||||||
public:
|
public:
|
||||||
|
// Constructor using a blitz::TinyVector that holds the values of a cartesian coordinate (x,y,z)
|
||||||
CartesianCoordinate(const blitz::TinyVector<double, 3>& cartesian_position);
|
CartesianCoordinate(const blitz::TinyVector<double, 3>& cartesian_position);
|
||||||
|
// Constructor using an arbitrary Coordinate object
|
||||||
CartesianCoordinate(const Coordinate& coordinate);
|
CartesianCoordinate(const Coordinate& coordinate);
|
||||||
|
|
||||||
|
// return the value of the stored coordinate transformed to Cartesian space
|
||||||
blitz::TinyVector<double, 3> cartesianEntries() const;
|
blitz::TinyVector<double, 3> cartesianEntries() const;
|
||||||
|
// return the value of the stored coordinate transformed to Cylider space
|
||||||
blitz::TinyVector<double, 3> cylinderEntries() const;
|
blitz::TinyVector<double, 3> cylinderEntries() const;
|
||||||
|
|
||||||
|
double cosAzimuth() const;
|
||||||
|
double sinAzimuth() const;
|
||||||
|
|
||||||
|
// add the values of the parameter coordinate to the value stored in this variable
|
||||||
void add(const Coordinate& coordinate);
|
void add(const Coordinate& coordinate);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -46,62 +77,107 @@ class CartesianCoordinate : public Coordinate {
|
|||||||
|
|
||||||
class CylinderCoordinate : public Coordinate {
|
class CylinderCoordinate : public Coordinate {
|
||||||
public:
|
public:
|
||||||
|
// Constructor using a blitz::TinyVector that holds the values of a cylinder coordinate (r,phi,z)
|
||||||
CylinderCoordinate(const blitz::TinyVector<double, 3>& cylinder_position);
|
CylinderCoordinate(const blitz::TinyVector<double, 3>& cylinder_position);
|
||||||
|
// Constructor using an arbitrary Coordinate object
|
||||||
CylinderCoordinate(const Coordinate& coordinate);
|
CylinderCoordinate(const Coordinate& coordinate);
|
||||||
|
|
||||||
|
// return the value of the stored coordinate transformed to Cartesian space
|
||||||
blitz::TinyVector<double, 3> cartesianEntries() const;
|
blitz::TinyVector<double, 3> cartesianEntries() const;
|
||||||
|
// return the value of the stored coordinate transformed to Cylinder space
|
||||||
blitz::TinyVector<double, 3> cylinderEntries() const;
|
blitz::TinyVector<double, 3> cylinderEntries() const;
|
||||||
|
|
||||||
|
double cosAzimuth() const;
|
||||||
|
double sinAzimuth() const;
|
||||||
|
|
||||||
|
// add the values of the parameter coordinate to the value stored in this variable
|
||||||
void add(const Coordinate& coordinate);
|
void add(const Coordinate& coordinate);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// transform phi to be in the interval [0, 2pi]
|
||||||
void limitPhi();
|
void limitPhi();
|
||||||
blitz::TinyVector<double, 3> cylinder_position;
|
blitz::TinyVector<double, 3> cylinder_position;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// parent class for different types of vectors (cartesian vector, cylinder vector)
|
||||||
class Vector {
|
class Vector {
|
||||||
public:
|
public:
|
||||||
|
// return the stored value as a cartesian vector, the transformation depends on
|
||||||
|
// the Coordinate, where the Vector is defined
|
||||||
virtual blitz::TinyVector<double, 3> cartesianEntries(
|
virtual blitz::TinyVector<double, 3> cartesianEntries(
|
||||||
const Coordinate& coordinate) const = 0;
|
const Coordinate& coordinate) const = 0;
|
||||||
|
// return the stored value as a cylinder vector, the transformation depends on
|
||||||
|
// the Coordinate, where the Vector is defined
|
||||||
virtual blitz::TinyVector<double, 3> cylinderEntries(
|
virtual blitz::TinyVector<double, 3> cylinderEntries(
|
||||||
const Coordinate& coordinate) const = 0;
|
const Coordinate& coordinate) const = 0;
|
||||||
|
|
||||||
|
// Add the Vector vector to the value stored in this object; for the addition both
|
||||||
|
// Vectors have to be in the same space (i.e. Cartesian or Cylinder) therefore
|
||||||
|
// the Coordinate is necessary for potential transformations
|
||||||
virtual void add(const Vector& vector, const Coordinate& coordinate) = 0;
|
virtual void add(const Vector& vector, const Coordinate& coordinate) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class for storing and handling of Cylinder Vectors (v_r, v_phi, v_z)
|
||||||
class CylinderVector : public Vector {
|
class CylinderVector : public Vector {
|
||||||
public:
|
public:
|
||||||
|
// copy constructor
|
||||||
CylinderVector(const CylinderVector& vector);
|
CylinderVector(const CylinderVector& vector);
|
||||||
|
// constructor using a blitz::TinyVector containing the cylinder vector components
|
||||||
|
// of a vector
|
||||||
CylinderVector(const blitz::TinyVector<double, 3> cylinder_vector);
|
CylinderVector(const blitz::TinyVector<double, 3> cylinder_vector);
|
||||||
|
// constructor using an arbitrary vector, needs the Coordinate of the vector
|
||||||
|
// to transform into cylinder space
|
||||||
CylinderVector(const Vector& vector, const Coordinate& coordinate);
|
CylinderVector(const Vector& vector, const Coordinate& coordinate);
|
||||||
|
|
||||||
|
// overwrite the "+"-Operator for the addtion of two CylinderVector objects
|
||||||
CylinderVector operator+(const CylinderVector& coordinate);
|
CylinderVector operator+(const CylinderVector& coordinate);
|
||||||
|
|
||||||
|
// return the stored value as a cartesian vector, the transformation depends on
|
||||||
|
// the Coordinate, where the CylinderVector is defined
|
||||||
blitz::TinyVector<double, 3> cartesianEntries(
|
blitz::TinyVector<double, 3> cartesianEntries(
|
||||||
const Coordinate& coordinate) const;
|
const Coordinate& coordinate) const;
|
||||||
|
// return the stored values as a cylinder vector; overwrite of the pure virtual
|
||||||
|
// function in the Vector class
|
||||||
blitz::TinyVector<double, 3> cylinderEntries(
|
blitz::TinyVector<double, 3> cylinderEntries(
|
||||||
const Coordinate& coordinate) const;
|
const Coordinate& coordinate) const;
|
||||||
|
// returns the entries of the CylinderVector without the need for the Coordinate
|
||||||
blitz::TinyVector<double, 3> cylinderEntries() const;
|
blitz::TinyVector<double, 3> cylinderEntries() const;
|
||||||
|
|
||||||
|
// Add the Vector vector to the value stored in this object; for the addition both
|
||||||
|
// Vectors have to be in the same space (i.e. Cartesian or Cylinder) therefore
|
||||||
|
// the Coordinate is necessary for potential transformations
|
||||||
void add(const Vector& vector, const Coordinate& coordinate);
|
void add(const Vector& vector, const Coordinate& coordinate);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
blitz::TinyVector<double, 3> cylinder_vector;
|
blitz::TinyVector<double, 3> cylinder_vector;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class for storing and handling of Cylinder Vectors (v_x, v_y, v_z)
|
||||||
class CartesianVector : public Vector {
|
class CartesianVector : public Vector {
|
||||||
public:
|
public:
|
||||||
|
// constructor using a blitz::TinyVector containing the cartesian vector components
|
||||||
|
// of a vector
|
||||||
CartesianVector(const blitz::TinyVector<double, 3> cartesian_vector);
|
CartesianVector(const blitz::TinyVector<double, 3> cartesian_vector);
|
||||||
|
// copy constructor
|
||||||
CartesianVector(const CartesianVector& vector);
|
CartesianVector(const CartesianVector& vector);
|
||||||
|
// constructor using an arbitrary vector, needs the Coordinate of the vector
|
||||||
|
// to transform into cartesian space
|
||||||
CartesianVector(const Vector& vector, const Coordinate& coordinate);
|
CartesianVector(const Vector& vector, const Coordinate& coordinate);
|
||||||
|
|
||||||
|
// return the stored values as a cartesian vector; overwrite of the pure virtual
|
||||||
|
// function in the Vector class
|
||||||
blitz::TinyVector<double, 3> cartesianEntries(
|
blitz::TinyVector<double, 3> cartesianEntries(
|
||||||
const Coordinate& coordinate) const;
|
const Coordinate& coordinate) const;
|
||||||
|
// returns the entries of the CartesianVector without the need for the Coordinate
|
||||||
blitz::TinyVector<double, 3> cartesianEntries() const;
|
blitz::TinyVector<double, 3> cartesianEntries() const;
|
||||||
|
// return the stored value as a cylinder vector, the transformation depends on
|
||||||
|
// the Coordinate, where the CartesianVector is defined
|
||||||
blitz::TinyVector<double, 3> cylinderEntries(
|
blitz::TinyVector<double, 3> cylinderEntries(
|
||||||
const Coordinate& coordinate) const;
|
const Coordinate& coordinate) const;
|
||||||
|
|
||||||
|
// Add the Vector vector to the value stored in this object; for the addition both
|
||||||
|
// Vectors have to be in the same space (i.e. Cartesian or Cylinder) therefore
|
||||||
|
// the Coordinate is necessary for potential transformations
|
||||||
void add(const Vector& vector, const Coordinate& coordinate);
|
void add(const Vector& vector, const Coordinate& coordinate);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -6,33 +6,86 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "blitz/array.h"
|
#include "blitz/array.h"
|
||||||
|
|
||||||
|
// defined in "simulation/density_field.h"
|
||||||
class DynamicDensityField;
|
class DynamicDensityField;
|
||||||
|
// defined in "simulation/timer.h"
|
||||||
class Timer;
|
class Timer;
|
||||||
|
// defined in "simulation/current_collector.h"
|
||||||
class CurrentCollector;
|
class CurrentCollector;
|
||||||
|
// defined in "simulation/logger.h"
|
||||||
class DeletionLogger;
|
class DeletionLogger;
|
||||||
|
|
||||||
|
// defined in "simulation/species.h"
|
||||||
namespace species {
|
namespace species {
|
||||||
class TrackedSpecie;
|
class TrackedSpecie;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class to synchronize states between mpi-processes
|
||||||
class CpuSynchronizer {
|
class CpuSynchronizer {
|
||||||
public:
|
public:
|
||||||
// CpuSynchronizer();
|
// CpuSynchronizer();
|
||||||
|
|
||||||
|
// function to handle synchronization of the map of TrackedSpecie
|
||||||
|
// synchronizes the timer, all CurrentCollectors, DynamicDensityFields and DeletionLoggers
|
||||||
void synchronize(
|
void synchronize(
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>&
|
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>&
|
||||||
tracked_species);
|
tracked_species);
|
||||||
|
|
||||||
void synchronize(DynamicDensityField* field);
|
// function to synchronize a DynamicDensityField;
|
||||||
void synchronize(CurrentCollector* collector);
|
// last_sync_field includes the state of the DynamicDensityField after the last
|
||||||
void synchronize(DeletionLogger* logger);
|
// synchronization, neccessary to calculate changes that have to be communicated
|
||||||
void synchronize(Timer* timer);
|
// after the synchronization both field and last_sync_field contain the same data
|
||||||
|
// but are different objects
|
||||||
|
void synchronize(DynamicDensityField* field,
|
||||||
|
DynamicDensityField* last_sync_field);
|
||||||
|
// function to synchronize a CurrentCollector;
|
||||||
|
// last_sync_collector includes the state of the CurrentCollector after the last
|
||||||
|
// synchronization, neccessary to calculate changes that have to be communicated
|
||||||
|
// after the synchronization both collector and last_sync_collector contain the same data
|
||||||
|
// but are different objects
|
||||||
|
void synchronize(CurrentCollector* collector,
|
||||||
|
CurrentCollector* last_sync_collector);
|
||||||
|
// function to synchronize a DeletionLogger;
|
||||||
|
// last_sync_logger includes the state of the DeletionLogger after the last
|
||||||
|
// synchronization, neccessary to calculate changes that have to be communicated
|
||||||
|
// after the synchronization both logger and last_sync_logger contain the same data
|
||||||
|
// but are different objects
|
||||||
|
void synchronize(DeletionLogger* logger,
|
||||||
|
DeletionLogger* last_sync_logger);
|
||||||
|
// function to synchronize a Timer;
|
||||||
|
// last_sync_timer includes the state of the Timer after the last
|
||||||
|
// synchronization, neccessary to calculate changes that have to be communicated
|
||||||
|
// after the synchronization both timer and last_sync_timer contain the same data
|
||||||
|
// but are different objects
|
||||||
|
void synchronize(Timer* timer, Timer* last_sync_timer);
|
||||||
|
|
||||||
void sumToAll(blitz::Array<double, 4>& array);
|
|
||||||
void sumToAll(blitz::Array<double, 3>& array);
|
// calculates delta = array - last_sync_array, then collects all deltas of all
|
||||||
void sumToAll(blitz::Array<long int, 4>& array);
|
// mpi-processes and adds them to last_sync_array (i.e. array does not get modified)
|
||||||
void sumToAll(double& value);
|
void sumToAll(blitz::Array<double, 4>& array,
|
||||||
void sumToAll(long int& value);
|
blitz::Array<double, 4>& last_sync_array);
|
||||||
|
// calculates delta = array - last_sync_array, then collects all deltas of all
|
||||||
|
// mpi-processes and adds them to last_sync_array so that
|
||||||
|
// afterwards last_sync_array has the same values on each mpi-process
|
||||||
|
// (i.e. array does not get modified)
|
||||||
|
void sumToAll(blitz::Array<double, 3>& array,
|
||||||
|
blitz::Array<double, 3>& last_sync_array);
|
||||||
|
// calculates delta = array - last_sync_array, then collects all deltas of all
|
||||||
|
// mpi-processes and adds them to last_sync_array so that
|
||||||
|
// afterwards last_sync_array has the same values on each mpi-process
|
||||||
|
// (i.e. array does not get modified)
|
||||||
|
void sumToAll(blitz::Array<long int, 4>& array,
|
||||||
|
blitz::Array<long int, 4>& last_sync_array);
|
||||||
|
// calculates delta = value - last_sync_value, then collects all deltas of all
|
||||||
|
// mpi-processes and adds them to last_sync_value so that
|
||||||
|
// afterwards last_sync_value has the same value on each mpi-process
|
||||||
|
// (i.e. array does not get modified)
|
||||||
|
void sumToAll(double& value, double& last_sync_value);
|
||||||
|
// calculates delta = array - last_sync_array, then collects all deltas of all
|
||||||
|
// mpi-processes and adds them to last_sync_value so that
|
||||||
|
// afterwards last_sync_value has the same value on each mpi-process
|
||||||
|
// (i.e. array does not get modified)
|
||||||
|
void sumToAll(long int& value, long int& last_sync_value);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* CPU_SYNCHRONIZER_H */
|
#endif /* CPU_SYNCHRONIZER_H */
|
||||||
|
|||||||
@@ -7,55 +7,117 @@
|
|||||||
#include "simulation/position_binning.h"
|
#include "simulation/position_binning.h"
|
||||||
#include "simulation/timer.h"
|
#include "simulation/timer.h"
|
||||||
|
|
||||||
|
// class to store and calculate particle currents
|
||||||
class CurrentCollector {
|
class CurrentCollector {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: takes a CylinderBinning object to create the crossing and area arrays
|
||||||
|
// a shared_ptr of a timer object (object be shared between all
|
||||||
|
// CurrentCollectors and DensityFields regardless of specie)
|
||||||
CurrentCollector(const CylinderBinning& position_binning,
|
CurrentCollector(const CylinderBinning& position_binning,
|
||||||
std::shared_ptr<Timer> timer);
|
std::shared_ptr<Timer> timer);
|
||||||
|
|
||||||
|
// from the pointer to the particle and the Coordinate of an old position (e.g. before movement)
|
||||||
|
// crossings over bin boundaries are determined and stored
|
||||||
void collect(particle::Particle* particle, const Coordinate& old_position);
|
void collect(particle::Particle* particle, const Coordinate& old_position);
|
||||||
|
|
||||||
|
// returns the blitz::Array containing the crossings out of the bins in radial direction
|
||||||
blitz::Array<double, 3> negativeCrossingsInR() const;
|
blitz::Array<double, 3> negativeCrossingsInR() const;
|
||||||
|
// returns the blitz::Array containing the crossins into the bins in radial direction
|
||||||
blitz::Array<double, 3> positiveCrossingsInR() const;
|
blitz::Array<double, 3> positiveCrossingsInR() const;
|
||||||
|
// return a blitz::Array with the areas of the bin borders in radial direction
|
||||||
blitz::Array<double, 3> areaInR() const;
|
blitz::Array<double, 3> areaInR() const;
|
||||||
|
// return a blitz::Array with the particle current in radial direction (in m^-2s^-1)
|
||||||
blitz::Array<double, 3> currentInR() const;
|
blitz::Array<double, 3> currentInR() const;
|
||||||
|
|
||||||
|
// returns the blitz::Array containing the crossings out of the bins in azimuthal direction
|
||||||
blitz::Array<double, 3> negativeCrossingsInPhi() const;
|
blitz::Array<double, 3> negativeCrossingsInPhi() const;
|
||||||
|
// returns the blitz::Array containing the crossins into the bins in azimuthal direction
|
||||||
blitz::Array<double, 3> positiveCrossingsInPhi() const;
|
blitz::Array<double, 3> positiveCrossingsInPhi() const;
|
||||||
|
// return a blitz::Array with the areas of the bin borders in azimuthal direction
|
||||||
blitz::Array<double, 3> areaInPhi() const;
|
blitz::Array<double, 3> areaInPhi() const;
|
||||||
|
// return a blitz::Array with the particle current in azimuthal direction (in m^-2s^-1)
|
||||||
blitz::Array<double, 3> currentInPhi() const;
|
blitz::Array<double, 3> currentInPhi() const;
|
||||||
|
|
||||||
|
// returns the blitz::Array containing the crossings out of the bins in longitudinal direction
|
||||||
blitz::Array<double, 3> negativeCrossingsInZ() const;
|
blitz::Array<double, 3> negativeCrossingsInZ() const;
|
||||||
|
// returns the blitz::Array containing the crossins into the bins in longitudinal direction
|
||||||
blitz::Array<double, 3> positiveCrossingsInZ() const;
|
blitz::Array<double, 3> positiveCrossingsInZ() const;
|
||||||
|
// return a blitz::Array with the areas of the bin borders in longitudinal direction
|
||||||
blitz::Array<double, 3> areaInZ() const;
|
blitz::Array<double, 3> areaInZ() const;
|
||||||
|
// return a blitz::Array with the particle current in longitudinal direction (in m^-2s^-1)
|
||||||
blitz::Array<double, 3> currentInZ() const;
|
blitz::Array<double, 3> currentInZ() const;
|
||||||
|
|
||||||
|
// return the time from the Timer object
|
||||||
double physicalTime() const;
|
double physicalTime() const;
|
||||||
|
|
||||||
|
// give the CpuSynchronizer class access to the private member variables to
|
||||||
|
// make synchronization between processes simpler
|
||||||
friend class CpuSynchronizer;
|
friend class CpuSynchronizer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// determine whether the particle moves out of or into a bin in radial direction from two TinyVectors containing
|
||||||
|
// the indices of two bins of the CylinderBinning, the corresponding crossings member array
|
||||||
|
// is then updated at the closest boundary position of the new bin; if multiple bins would
|
||||||
|
// be crossed only the boundary described above will receive an update
|
||||||
void collectRadialMovement(const blitz::TinyVector<int, 3>& bin_old,
|
void collectRadialMovement(const blitz::TinyVector<int, 3>& bin_old,
|
||||||
const blitz::TinyVector<int, 3>& bin_new);
|
const blitz::TinyVector<int, 3>& bin_new);
|
||||||
|
// determine whether the particle moves out of or into a bin in longitudinal direction from two TinyVectors containing
|
||||||
|
// the indices of two bins of the CylinderBinning, the corresponding crossings member array
|
||||||
|
// is then updated at the closest boundary position of the new bin; if multiple bins would
|
||||||
|
// be crossed only the boundary described above will receive an update
|
||||||
void collectLongitudinalMovement(const blitz::TinyVector<int, 3>& bin_old,
|
void collectLongitudinalMovement(const blitz::TinyVector<int, 3>& bin_old,
|
||||||
const blitz::TinyVector<int, 3>& bin_new);
|
const blitz::TinyVector<int, 3>& bin_new);
|
||||||
|
// determine whether the particle moves out of or into a bin in azimuthal direction from two TinyVectors containing
|
||||||
|
// the indices of two bins of the CylinderBinning, the corresponding crossings member array
|
||||||
|
// is then updated at the closest boundary position of the new bin (periodic nature is accouted for); if multiple bins would
|
||||||
|
// be crossed only the boundary described above will receive an update
|
||||||
void collectAzimuthalMovement(const blitz::TinyVector<int, 3>& bin_old,
|
void collectAzimuthalMovement(const blitz::TinyVector<int, 3>& bin_old,
|
||||||
const blitz::TinyVector<int, 3>& bin_new);
|
const blitz::TinyVector<int, 3>& bin_new);
|
||||||
|
|
||||||
|
/*
|
||||||
|
schematics for the numbering of the bins and the corresponding borders
|
||||||
|
|
||||||
|
longitudinal:
|
||||||
|
underflow bin 0 bin 1 bin 2 ... bin N-1 overflow
|
||||||
|
---------|------------|------------|------------| ... |------------|--------
|
||||||
|
border_0 border_1 border_2 border_3 ... border_N-1 border_N
|
||||||
|
|
||||||
|
radial:
|
||||||
|
bin 0 bin 1 bin 2 ... bin N-1 overflow
|
||||||
|
----------|------------|------------| ... |------------|--------
|
||||||
|
border_0 border_1 border_2 ... border_N-2 border_N-1
|
||||||
|
|
||||||
|
azimuthal:
|
||||||
|
bin N-1 bin 0 bin 1 bin 2 ... bin N-1 bin 0
|
||||||
|
---------|------------|------------|------------| ... |------------|--------
|
||||||
|
border_0 border_1 border_2 border_3 ... border_N-1 border_0
|
||||||
|
*/
|
||||||
|
|
||||||
|
// create the array containing the areas of the different boundary sections between bins in longitudinal direction
|
||||||
|
// uses the provided CylinderBinning for the spacings of the bins
|
||||||
blitz::Array<double, 3> createAreaLongitudinal(
|
blitz::Array<double, 3> createAreaLongitudinal(
|
||||||
const CylinderBinning& position_binning);
|
const CylinderBinning& position_binning);
|
||||||
|
// return an array for the counting of crossings across the bin borders in longitudinal direction
|
||||||
blitz::Array<double, 3> createCrossingsLongitudinal(
|
blitz::Array<double, 3> createCrossingsLongitudinal(
|
||||||
const CylinderBinning& position_binning);
|
const CylinderBinning& position_binning);
|
||||||
|
|
||||||
|
// return an array containing the areas of the different boundary sections between bins in radial direction
|
||||||
|
// uses the provided CylinderBinning for the spacings of the bins
|
||||||
blitz::Array<double, 3> createAreaRadial(
|
blitz::Array<double, 3> createAreaRadial(
|
||||||
const CylinderBinning& position_binning);
|
const CylinderBinning& position_binning);
|
||||||
|
// return an array for the counting of crossings across the bin borders in radial direction
|
||||||
blitz::Array<double, 3> createCrossingsRadial(
|
blitz::Array<double, 3> createCrossingsRadial(
|
||||||
const CylinderBinning& position_binning);
|
const CylinderBinning& position_binning);
|
||||||
|
|
||||||
|
// create the array containing the areas of the different boundary sections between bins in azimuthal direction
|
||||||
|
// uses the provided CylinderBinning for the spacings of the bins
|
||||||
blitz::Array<double, 3> createAreaAzimuthal(
|
blitz::Array<double, 3> createAreaAzimuthal(
|
||||||
const CylinderBinning& position_binning);
|
const CylinderBinning& position_binning);
|
||||||
|
// return an array for the counting of crossings across the bin borders in azimuthal direction
|
||||||
blitz::Array<double, 3> createCrossingsAzimuthal(
|
blitz::Array<double, 3> createCrossingsAzimuthal(
|
||||||
const CylinderBinning& position_binning);
|
const CylinderBinning& position_binning);
|
||||||
|
|
||||||
|
// Arrays for the storage of boundary crossings
|
||||||
blitz::Array<double, 3> z_negative_crossings;
|
blitz::Array<double, 3> z_negative_crossings;
|
||||||
blitz::Array<double, 3> z_positive_crossings;
|
blitz::Array<double, 3> z_positive_crossings;
|
||||||
|
|
||||||
@@ -65,6 +127,7 @@ class CurrentCollector {
|
|||||||
blitz::Array<double, 3> r_negative_crossings;
|
blitz::Array<double, 3> r_negative_crossings;
|
||||||
blitz::Array<double, 3> r_positive_crossings;
|
blitz::Array<double, 3> r_positive_crossings;
|
||||||
|
|
||||||
|
// Arrays with the size area of the boundary segments
|
||||||
blitz::Array<double, 3> collector_areas_r;
|
blitz::Array<double, 3> collector_areas_r;
|
||||||
blitz::Array<double, 3> collector_areas_phi;
|
blitz::Array<double, 3> collector_areas_phi;
|
||||||
blitz::Array<double, 3> collector_areas_z;
|
blitz::Array<double, 3> collector_areas_z;
|
||||||
|
|||||||
@@ -9,46 +9,79 @@
|
|||||||
#include "simulation/position_binning.h"
|
#include "simulation/position_binning.h"
|
||||||
#include "simulation/timer.h"
|
#include "simulation/timer.h"
|
||||||
|
|
||||||
|
// defined in "simulation/scalar_field.h"
|
||||||
class ScalarField;
|
class ScalarField;
|
||||||
|
// defined in "simulation/event_position_dirstribution.h"
|
||||||
class EventPositionDistribution;
|
class EventPositionDistribution;
|
||||||
|
|
||||||
|
// class for a generic density field, specifying the minimum requirements
|
||||||
class DensityField {
|
class DensityField {
|
||||||
public:
|
public:
|
||||||
|
// pure virtual function requiring that a function to obtain the density (m^-3) at
|
||||||
|
// the Coordinate position is returned
|
||||||
virtual double density(const Coordinate& position) = 0;
|
virtual double density(const Coordinate& position) = 0;
|
||||||
|
// pure virtual function requiring that a function to obtain the density (m^-3) at
|
||||||
|
// the Coordinate position and energy energy_eV is returned
|
||||||
virtual double density(const Coordinate& position, double energy_eV) = 0;
|
virtual double density(const Coordinate& position, double energy_eV) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class for the density field for TrackedSpecies, i.e. simulated species
|
||||||
class DynamicDensityField : public DensityField {
|
class DynamicDensityField : public DensityField {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: create the necessary array storing the time particles (4d r,phi,z,E) have spent in a bin,
|
||||||
|
// a corresponding array that stores the number of deletions (4d r,phi,z,E) in a bin
|
||||||
|
// as well as the 4d array for the actual density (in m^-3) and the
|
||||||
|
// array with the volumes of the individual bins from the CylinderBinning and EnergyBinnig
|
||||||
DynamicDensityField(const CylinderBinning& position_binning,
|
DynamicDensityField(const CylinderBinning& position_binning,
|
||||||
const EnergyBinning& energy_binning,
|
const EnergyBinning& energy_binning,
|
||||||
std::shared_ptr<Timer> timer);
|
std::shared_ptr<Timer> timer);
|
||||||
|
|
||||||
|
// returns true if the bin of the old_position Coordinate and the bin of the
|
||||||
|
// new_position Coordinate are different otherwise returns false
|
||||||
bool changedPositionBin(const Coordinate& old_position,
|
bool changedPositionBin(const Coordinate& old_position,
|
||||||
const Coordinate& new_position) const;
|
const Coordinate& new_position) const;
|
||||||
|
|
||||||
|
// returns true if the bin of old_energy_eV is different than the bin of new_energy_eV
|
||||||
|
// otherwise returns false
|
||||||
bool changedEnergyBin(double old_energy_eV, double new_energy_eV) const;
|
bool changedEnergyBin(double old_energy_eV, double new_energy_eV) const;
|
||||||
|
|
||||||
|
// increases the value of the time_in_bin array by time_in_bin_s at the bin index
|
||||||
|
// determined by the Coordinate position and energy_eV
|
||||||
void logMovement(const Coordinate& position,
|
void logMovement(const Coordinate& position,
|
||||||
double energy_eV,
|
double energy_eV,
|
||||||
double time_in_bin_s);
|
double time_in_bin_s);
|
||||||
|
|
||||||
|
// increases the value of the deleted_particles array by 1 at the bin index determined
|
||||||
|
// by position and energy_eV
|
||||||
void logDeletion(const Coordinate& position, double energy_eV);
|
void logDeletion(const Coordinate& position, double energy_eV);
|
||||||
|
|
||||||
|
// return the value of the density_per_m3 array at the bin index
|
||||||
|
// determined by the Coordinate position summed over all energy bins
|
||||||
double density(const Coordinate& position);
|
double density(const Coordinate& position);
|
||||||
|
// return the value of the density_per_m3 array at the bin index
|
||||||
|
// determined by the Coordinate position and energy_eV
|
||||||
double density(const Coordinate& position, double energy_eV);
|
double density(const Coordinate& position, double energy_eV);
|
||||||
|
|
||||||
|
// calculate and return the 3d density array (m^-3), no resolution in the energy direction
|
||||||
blitz::Array<double, 3> densityArray();
|
blitz::Array<double, 3> densityArray();
|
||||||
|
// calculate and return the 4d density array (m^-3), with a resolution in energy direction
|
||||||
blitz::Array<double, 4> spectrumArray();
|
blitz::Array<double, 4> spectrumArray();
|
||||||
|
// getter for the time_in_bin array
|
||||||
blitz::Array<double, 4> timeInBinArray() const;
|
blitz::Array<double, 4> timeInBinArray() const;
|
||||||
|
// getter for the deleted_particles array
|
||||||
blitz::Array<long int, 4> deletedParticlesArray() const;
|
blitz::Array<long int, 4> deletedParticlesArray() const;
|
||||||
|
// getter for the bin_volume_m3 array
|
||||||
blitz::Array<double, 3> binVolumeArray() const;
|
blitz::Array<double, 3> binVolumeArray() const;
|
||||||
|
|
||||||
|
// return a raw pointer to the EnergyBinning member object
|
||||||
const EnergyBinning* energyBinning() const;
|
const EnergyBinning* energyBinning() const;
|
||||||
|
// return a raw pointer to the CylinderBinning member object
|
||||||
const CylinderBinning* positionBinning() const;
|
const CylinderBinning* positionBinning() const;
|
||||||
|
|
||||||
|
// return the time from the timer member
|
||||||
double physicalTime() const;
|
double physicalTime() const;
|
||||||
|
|
||||||
|
// make the private member variables accessable by the CpuSynchronizer
|
||||||
friend class CpuSynchronizer;
|
friend class CpuSynchronizer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -66,11 +99,17 @@ class DynamicDensityField : public DensityField {
|
|||||||
// 0, ..., num_bin_z-1: 0 <= z < z_max
|
// 0, ..., num_bin_z-1: 0 <= z < z_max
|
||||||
// num_bin_z: z >= z_max
|
// num_bin_z: z >= z_max
|
||||||
BinCoordinate densityBin(const CylinderCoordinate& position) const;
|
BinCoordinate densityBin(const CylinderCoordinate& position) const;
|
||||||
|
// uses time_in_bin, deleted_particles (4d), bin_volume_m3 (3d) and the timer to
|
||||||
|
// recalculate the density_per_m3 array (4d)
|
||||||
void recalculateDensityArray();
|
void recalculateDensityArray();
|
||||||
|
|
||||||
|
// array storing the cumulative time particles of a species have spent in certain bins
|
||||||
blitz::Array<double, 4> time_in_bin_s_;
|
blitz::Array<double, 4> time_in_bin_s_;
|
||||||
|
// array storing the cumulative time particles of a species have been deleted due to recombination
|
||||||
blitz::Array<long int, 4> deleted_particles_;
|
blitz::Array<long int, 4> deleted_particles_;
|
||||||
|
// array storing the physical density (units: m^-3), histogram in energy dimension
|
||||||
blitz::Array<double, 4> density_per_m3_;
|
blitz::Array<double, 4> density_per_m3_;
|
||||||
|
// arrya storing the volumes of the individual bins of the time_in_bin array (or rather the CylinderBinning object)
|
||||||
blitz::Array<double, 3> bin_volume_m3_;
|
blitz::Array<double, 3> bin_volume_m3_;
|
||||||
|
|
||||||
const CylinderBinning position_binning_;
|
const CylinderBinning position_binning_;
|
||||||
@@ -79,11 +118,16 @@ class DynamicDensityField : public DensityField {
|
|||||||
std::shared_ptr<Timer> timer_;
|
std::shared_ptr<Timer> timer_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class for the density field for BackgroundSpecies, i.e. non-simulated species
|
||||||
class ConstantDensityField : public DensityField {
|
class ConstantDensityField : public DensityField {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: making the shared_ptr density a member variable
|
||||||
ConstantDensityField(std::shared_ptr<ScalarField> density);
|
ConstantDensityField(std::shared_ptr<ScalarField> density);
|
||||||
|
|
||||||
|
// return the value of the of the ScalarField density at the position Coordinate position
|
||||||
double density(const Coordinate& position);
|
double density(const Coordinate& position);
|
||||||
|
// return the value of the of the ScalarField density at the position Coordinate position
|
||||||
|
// (energy_eV is ignored, since ScalarField does not have an energy resolution)
|
||||||
double density(const Coordinate& position, double energy_eV);
|
double density(const Coordinate& position, double energy_eV);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -6,11 +6,17 @@
|
|||||||
#include "simulation/coordinates.h"
|
#include "simulation/coordinates.h"
|
||||||
#include "simulation/vector_field.h"
|
#include "simulation/vector_field.h"
|
||||||
|
|
||||||
|
// class to handle the drift veloctiy
|
||||||
class DriftVelocity {
|
class DriftVelocity {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: takes a VectorField that describes the direction of the drift velocity
|
||||||
DriftVelocity(std::shared_ptr<VectorField> drift_velocity);
|
DriftVelocity(std::shared_ptr<VectorField> drift_velocity);
|
||||||
|
|
||||||
|
// returns the drift velocity value at the Coordinate position as a CartesianVector
|
||||||
CartesianVector driftVelocity(const Coordinate& position);
|
CartesianVector driftVelocity(const Coordinate& position);
|
||||||
|
// overload using both the cartesian and cylinder coordinate version of the position
|
||||||
|
CartesianVector driftVelocity(const CartesianCoordinate& cartpos,
|
||||||
|
const CylinderCoordinate& cylpos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<VectorField> drift_velocity_;
|
std::shared_ptr<VectorField> drift_velocity_;
|
||||||
|
|||||||
@@ -7,13 +7,20 @@
|
|||||||
#include "simulation/scalar_field.h"
|
#include "simulation/scalar_field.h"
|
||||||
#include "simulation/vector_field.h"
|
#include "simulation/vector_field.h"
|
||||||
|
|
||||||
|
// class for an electric field; consists of two VectorField objects
|
||||||
|
// one for the dynamic electric field, i.e. calculated during the simulation (not yet implemented, right now behaves the same as the background field)
|
||||||
|
// one for the background field, i.e. a field read in from an input file
|
||||||
class ElectricField {
|
class ElectricField {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: setting the background and dynamic field to the provided VectorFields
|
||||||
ElectricField(std::shared_ptr<VectorField> background,
|
ElectricField(std::shared_ptr<VectorField> background,
|
||||||
std::shared_ptr<VectorField> dynamic);
|
std::shared_ptr<VectorField> dynamic);
|
||||||
|
|
||||||
|
// return the value of the electric field at the Coordinate position (sum of the background and dynamic field values)
|
||||||
|
// as a CylinderVector
|
||||||
CylinderVector value(const Coordinate& position) const;
|
CylinderVector value(const Coordinate& position) const;
|
||||||
|
|
||||||
|
// set the dynamic field to the provided field
|
||||||
void updateDynamicField(std::shared_ptr<VectorField> field);
|
void updateDynamicField(std::shared_ptr<VectorField> field);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -21,10 +28,13 @@ class ElectricField {
|
|||||||
std::shared_ptr<VectorField> dynamic_;
|
std::shared_ptr<VectorField> dynamic_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class for a magnetic field
|
||||||
class MagneticField {
|
class MagneticField {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: takes the VectorField describing the magnetic field
|
||||||
MagneticField(std::shared_ptr<VectorField> field);
|
MagneticField(std::shared_ptr<VectorField> field);
|
||||||
|
|
||||||
|
// return the value of the magnetic field at Coordinate position as a CylinderVector
|
||||||
CylinderVector value(const Coordinate& position) const;
|
CylinderVector value(const Coordinate& position) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -3,18 +3,34 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
// class defining the grid for the energy-direction (includes an over- and underflow bin)
|
||||||
class EnergyBinning {
|
class EnergyBinning {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: create the EnergyBinning by using the minimal_energy (has to be positive and in eV units)
|
||||||
|
// as the lower boundary and the maximal_energy (in eV) as the upper boundary with num_bins bins
|
||||||
|
// the bin borders are created using a log10-spacing
|
||||||
EnergyBinning(double minimal_energy, double maximal_energy, int num_bins);
|
EnergyBinning(double minimal_energy, double maximal_energy, int num_bins);
|
||||||
|
// Constructor: create an EnergyBinning with the bin borders being defined in the
|
||||||
|
// vector energy_bin_borders (has to contain the values of the edges of the energy-bins;
|
||||||
|
// for the lowest energy bin the left boundary has to be given as well, similar for the
|
||||||
|
// highest energy bin the upper boundary value has to be given as well)
|
||||||
EnergyBinning(std::vector<double> energy_bin_borders);
|
EnergyBinning(std::vector<double> energy_bin_borders);
|
||||||
|
|
||||||
|
// return the index of the energy bin that contains the given energy_eV (in eV)
|
||||||
|
// if energy_eV < minimal_energy then -1 is returned (underflow bin)
|
||||||
|
// if energy_eV > maximal_energy then numBins is returned (overflow bin)
|
||||||
int bin(double energy_eV) const;
|
int bin(double energy_eV) const;
|
||||||
|
// returns the number of bins (not the number of bin borders!)
|
||||||
int numBins() const;
|
int numBins() const;
|
||||||
|
// returns the vector containing the energy bin borders
|
||||||
std::vector<double> binBorders() const;
|
std::vector<double> binBorders() const;
|
||||||
|
// return the index of the underflow bin
|
||||||
int binIndexMin() const;
|
int binIndexMin() const;
|
||||||
|
// return the index of the overflow bin
|
||||||
int binIndexMax() const;
|
int binIndexMax() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// vector containing the values of the bin edges
|
||||||
const std::vector<double> energy_bin_borders_;
|
const std::vector<double> energy_bin_borders_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -4,14 +4,20 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
||||||
|
// class defining the minimum requirements of an EnergyDistributionFunction child class
|
||||||
class EnergyDistributionFunction {
|
class EnergyDistributionFunction {
|
||||||
public:
|
public:
|
||||||
virtual double rollEnergy(std::mt19937* engine) = 0; // eV
|
// draw an energy value using the provided engine in eV
|
||||||
|
virtual double rollEnergy(std::mt19937* engine) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class for drawing an energy value from the Fermi spectrum of the Tritium beta decay
|
||||||
|
// using the rejection method
|
||||||
class TritiumBetaDecay : public EnergyDistributionFunction {
|
class TritiumBetaDecay : public EnergyDistributionFunction {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: initializes the random distributions
|
||||||
TritiumBetaDecay();
|
TritiumBetaDecay();
|
||||||
|
// draw an energy (eV) from the Fermi spectrum of the Tritium beta decay
|
||||||
double rollEnergy(std::mt19937* engine);
|
double rollEnergy(std::mt19937* engine);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -20,18 +26,24 @@ class TritiumBetaDecay : public EnergyDistributionFunction {
|
|||||||
std::uniform_real_distribution<double> y_distribution_;
|
std::uniform_real_distribution<double> y_distribution_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class for drawing an energy value from the Maxwell Boltzmann energy distribution
|
||||||
class MaxwellBoltzmann : public EnergyDistributionFunction {
|
class MaxwellBoltzmann : public EnergyDistributionFunction {
|
||||||
public:
|
public:
|
||||||
|
// initialize the distribution with the temperature (in K)
|
||||||
MaxwellBoltzmann(double temperature_K);
|
MaxwellBoltzmann(double temperature_K);
|
||||||
double rollEnergy(std::mt19937* engine); // eV
|
// draw an energy (in eV) from the Maxwell Boltzmann energy distribtion
|
||||||
|
double rollEnergy(std::mt19937* engine);
|
||||||
private:
|
private:
|
||||||
std::gamma_distribution<double> distribution_;
|
std::gamma_distribution<double> distribution_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class for returnig a constant energy value
|
||||||
class Constant : public EnergyDistributionFunction {
|
class Constant : public EnergyDistributionFunction {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: takes the energy value (in eV) that will be returned later
|
||||||
Constant(double constant_eV);
|
Constant(double constant_eV);
|
||||||
double rollEnergy(std::mt19937* engine); // eV
|
// return the energy (in eV) set at construction of the object
|
||||||
|
double rollEnergy(std::mt19937* engine);
|
||||||
private:
|
private:
|
||||||
const double constant_eV_;
|
const double constant_eV_;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include "simulation/mpi_communication.h"
|
#include "simulation/mpi_communication.h"
|
||||||
|
|
||||||
|
// if any debug is defined, define the main function to print the debugging message
|
||||||
#if defined debug_level3 || defined debug_level2 || defined debug_level1 || \
|
#if defined debug_level3 || defined debug_level2 || defined debug_level1 || \
|
||||||
defined debug_level0
|
defined debug_level0
|
||||||
inline void DEBUG(const std::string& message) {
|
inline void DEBUG(const std::string& message) {
|
||||||
@@ -16,45 +17,78 @@ inline void DEBUG(const std::string& message) {
|
|||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// depending on the debug level, activate the corresponding debugging function
|
||||||
#if defined debug_level0
|
#if defined debug_level0
|
||||||
|
// prints the message string to stdout if the code has been compiled with a
|
||||||
|
// DEBUG_LEVEL > 0
|
||||||
inline void DEBUG_LEVEL_0(const std::string& message) {
|
inline void DEBUG_LEVEL_0(const std::string& message) {
|
||||||
DEBUG(message);
|
DEBUG(message);
|
||||||
}
|
}
|
||||||
|
// prints the message string to stdout if the code has been compiled with a
|
||||||
|
// DEBUG_LEVEL > 1
|
||||||
inline void DEBUG_LEVEL_1(const std::string& message) {}
|
inline void DEBUG_LEVEL_1(const std::string& message) {}
|
||||||
|
// prints the message string to stdout if the code has been compiled with a
|
||||||
|
// DEBUG_LEVEL > 2
|
||||||
inline void DEBUG_LEVEL_2(const std::string& message) {}
|
inline void DEBUG_LEVEL_2(const std::string& message) {}
|
||||||
|
// prints the message string to stdout if the code has been compiled with a
|
||||||
|
// DEBUG_LEVEL > 3
|
||||||
inline void DEBUG_LEVEL_3(const std::string& message) {}
|
inline void DEBUG_LEVEL_3(const std::string& message) {}
|
||||||
#elif defined debug_level1
|
#elif defined debug_level1
|
||||||
|
// prints the message string to stdout if the code has been compiled with a
|
||||||
|
// DEBUG_LEVEL > 0
|
||||||
inline void DEBUG_LEVEL_0(const std::string& message) {
|
inline void DEBUG_LEVEL_0(const std::string& message) {
|
||||||
DEBUG(message);
|
DEBUG(message);
|
||||||
}
|
}
|
||||||
|
// prints the message string to stdout if the code has been compiled with a
|
||||||
|
// DEBUG_LEVEL > 1
|
||||||
inline void DEBUG_LEVEL_1(const std::string& message) {
|
inline void DEBUG_LEVEL_1(const std::string& message) {
|
||||||
DEBUG(message);
|
DEBUG(message);
|
||||||
}
|
}
|
||||||
|
// prints the message string to stdout if the code has been compiled with a
|
||||||
|
// DEBUG_LEVEL > 2
|
||||||
inline void DEBUG_LEVEL_2(const std::string& message) {}
|
inline void DEBUG_LEVEL_2(const std::string& message) {}
|
||||||
|
// prints the message string to stdout if the code has been compiled with a
|
||||||
|
// DEBUG_LEVEL > 3
|
||||||
inline void DEBUG_LEVEL_3(const std::string& message) {}
|
inline void DEBUG_LEVEL_3(const std::string& message) {}
|
||||||
|
|
||||||
#elif defined debug_level2
|
#elif defined debug_level2
|
||||||
|
// prints the message string to stdout if the code has been compiled with a
|
||||||
|
// DEBUG_LEVEL > 0
|
||||||
inline void DEBUG_LEVEL_0(const std::string& message) {
|
inline void DEBUG_LEVEL_0(const std::string& message) {
|
||||||
DEBUG(message);
|
DEBUG(message);
|
||||||
}
|
}
|
||||||
|
// prints the message string to stdout if the code has been compiled with a
|
||||||
|
// DEBUG_LEVEL > 1
|
||||||
inline void DEBUG_LEVEL_1(const std::string& message) {
|
inline void DEBUG_LEVEL_1(const std::string& message) {
|
||||||
DEBUG(message);
|
DEBUG(message);
|
||||||
}
|
}
|
||||||
|
// prints the message string to stdout if the code has been compiled with a
|
||||||
|
// DEBUG_LEVEL > 2
|
||||||
inline void DEBUG_LEVEL_2(const std::string& message) {
|
inline void DEBUG_LEVEL_2(const std::string& message) {
|
||||||
DEBUG(message);
|
DEBUG(message);
|
||||||
}
|
}
|
||||||
|
// prints the message string to stdout if the code has been compiled with a
|
||||||
|
// DEBUG_LEVEL > 3
|
||||||
inline void DEBUG_LEVEL_3(const std::string& message) {}
|
inline void DEBUG_LEVEL_3(const std::string& message) {}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
// prints the message string to stdout if the code has been compiled with a
|
||||||
|
// DEBUG_LEVEL > 0
|
||||||
inline void DEBUG_LEVEL_0(const std::string& message) {
|
inline void DEBUG_LEVEL_0(const std::string& message) {
|
||||||
DEBUG(message);
|
DEBUG(message);
|
||||||
}
|
}
|
||||||
|
// prints the message string to stdout if the code has been compiled with a
|
||||||
|
// DEBUG_LEVEL > 1
|
||||||
inline void DEBUG_LEVEL_1(const std::string& message) {
|
inline void DEBUG_LEVEL_1(const std::string& message) {
|
||||||
DEBUG(message);
|
DEBUG(message);
|
||||||
}
|
}
|
||||||
|
// prints the message string to stdout if the code has been compiled with a
|
||||||
|
// DEBUG_LEVEL > 2
|
||||||
inline void DEBUG_LEVEL_2(const std::string& message) {
|
inline void DEBUG_LEVEL_2(const std::string& message) {
|
||||||
DEBUG(message);
|
DEBUG(message);
|
||||||
}
|
}
|
||||||
|
// prints the message string to stdout if the code has been compiled with a
|
||||||
|
// DEBUG_LEVEL > 3
|
||||||
inline void DEBUG_LEVEL_3(const std::string& message) {
|
inline void DEBUG_LEVEL_3(const std::string& message) {
|
||||||
DEBUG(message);
|
DEBUG(message);
|
||||||
}
|
}
|
||||||
@@ -62,18 +96,28 @@ inline void DEBUG_LEVEL_3(const std::string& message) {
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
inline void DEBUG(const std::string& message) {}
|
inline void DEBUG(const std::string& message) {}
|
||||||
|
// prints the message string to stdout if the code has been compiled with a
|
||||||
|
// DEBUG_LEVEL > 0
|
||||||
inline void DEBUG_LEVEL_0(const std::string& message) {}
|
inline void DEBUG_LEVEL_0(const std::string& message) {}
|
||||||
|
// prints the message string to stdout if the code has been compiled with a
|
||||||
|
// DEBUG_LEVEL > 1
|
||||||
inline void DEBUG_LEVEL_1(const std::string& message) {}
|
inline void DEBUG_LEVEL_1(const std::string& message) {}
|
||||||
|
// prints the message string to stdout if the code has been compiled with a
|
||||||
|
// DEBUG_LEVEL > 2
|
||||||
inline void DEBUG_LEVEL_2(const std::string& message) {}
|
inline void DEBUG_LEVEL_2(const std::string& message) {}
|
||||||
|
// prints the message string to stdout if the code has been compiled with a
|
||||||
|
// DEBUG_LEVEL > 3
|
||||||
inline void DEBUG_LEVEL_3(const std::string& message) {}
|
inline void DEBUG_LEVEL_3(const std::string& message) {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// for MPI process 0 print the message string to stdout
|
||||||
inline void SIM_INFO(const std::string& message) {
|
inline void SIM_INFO(const std::string& message) {
|
||||||
if (MpiCommunication::mpi_rank == 0) {
|
if (MpiCommunication::mpi_rank == 0) {
|
||||||
std::cout << "#INFO: " << message << std::endl;
|
std::cout << "#INFO: " << message << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// writes message string to stderr and exits the program with an EXIT_FAILURE
|
||||||
inline void ERROR(const std::string& message) {
|
inline void ERROR(const std::string& message) {
|
||||||
fprintf(stderr, "ERROR <%d> %s\n", MpiCommunication::mpi_rank,
|
fprintf(stderr, "ERROR <%d> %s\n", MpiCommunication::mpi_rank,
|
||||||
message.c_str());
|
message.c_str());
|
||||||
@@ -81,6 +125,7 @@ inline void ERROR(const std::string& message) {
|
|||||||
// throw std::runtime_error(message);
|
// throw std::runtime_error(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// assert if value is positive otherwise exit the program and print the message to stderr
|
||||||
template <class T>
|
template <class T>
|
||||||
void ASSERT_POSITIVE(T* value, const std::string& message) {
|
void ASSERT_POSITIVE(T* value, const std::string& message) {
|
||||||
if (!(*value > 0)) {
|
if (!(*value > 0)) {
|
||||||
@@ -88,6 +133,7 @@ void ASSERT_POSITIVE(T* value, const std::string& message) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// assert if value is not negative otherwise exit the program and print the message to stderr
|
||||||
template <class T>
|
template <class T>
|
||||||
void ASSERT_NOTNEGATIVE(T* value, const std::string& message) {
|
void ASSERT_NOTNEGATIVE(T* value, const std::string& message) {
|
||||||
if (!(*value >= 0)) {
|
if (!(*value >= 0)) {
|
||||||
@@ -95,6 +141,7 @@ void ASSERT_NOTNEGATIVE(T* value, const std::string& message) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// assert if value exists otherwise exit the program and print the message to stderr
|
||||||
template <class T>
|
template <class T>
|
||||||
void ASSERT_EXISTS(T* value, const std::string& message) {
|
void ASSERT_EXISTS(T* value, const std::string& message) {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
@@ -102,12 +149,15 @@ void ASSERT_EXISTS(T* value, const std::string& message) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// assert if value is finite otherwise exit the program and print the message to stderr
|
||||||
inline void ASSERT_FINITE(double value, const std::string& message) {
|
inline void ASSERT_FINITE(double value, const std::string& message) {
|
||||||
if (!std::isfinite(value)) {
|
if (!std::isfinite(value)) {
|
||||||
ERROR(message);
|
ERROR(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// assert if the blitz::TinyVector is finite otherwise
|
||||||
|
// exit the program and print the message to stderr
|
||||||
inline void ASSERT_FINITE(const blitz::TinyVector<double, 3>& value,
|
inline void ASSERT_FINITE(const blitz::TinyVector<double, 3>& value,
|
||||||
const std::string& message) {
|
const std::string& message) {
|
||||||
if (!std::isfinite(value(0)) || !std::isfinite(value(1)) ||
|
if (!std::isfinite(value(0)) || !std::isfinite(value(1)) ||
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "simulation/coordinates.h"
|
#include "simulation/coordinates.h"
|
||||||
#include "simulation/scalar_field.h"
|
#include "simulation/scalar_field.h"
|
||||||
|
|
||||||
|
// structure for storing a minimum and maximum value
|
||||||
struct Limit {
|
struct Limit {
|
||||||
Limit() : min(0), max(0){};
|
Limit() : min(0), max(0){};
|
||||||
Limit(double min, double max) : min(min), max(max){};
|
Limit(double min, double max) : min(min), max(max){};
|
||||||
@@ -14,19 +15,28 @@ struct Limit {
|
|||||||
double max;
|
double max;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class for drawing positions
|
||||||
class EventPositionDistribution {
|
class EventPositionDistribution {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: takes a shared_ptr to a ScalarField used as the distribution to be drawn from
|
||||||
|
// a Limit density containing the maximum value of the mother_density within the position limits (used for rejection method)
|
||||||
|
// a Limit r_position defining the region in r-direction, where positions are drawn from
|
||||||
|
// a Limit z_position defining the region in z-direction, where positions are drawn from
|
||||||
|
// a Limit phi_position defining the region in phi-direction, where positions are drawn from
|
||||||
EventPositionDistribution(std::shared_ptr<ScalarField> mother_density,
|
EventPositionDistribution(std::shared_ptr<ScalarField> mother_density,
|
||||||
Limit density,
|
Limit density,
|
||||||
Limit r_position,
|
Limit r_position,
|
||||||
Limit phi_position,
|
Limit phi_position,
|
||||||
Limit z_position);
|
Limit z_position);
|
||||||
|
// draw a position from the ScalarField using the given mt19937 engine pointer as a CylinderCoordinate
|
||||||
|
// using the rejection method
|
||||||
CylinderCoordinate rollPosition(std::mt19937* engine);
|
CylinderCoordinate rollPosition(std::mt19937* engine);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// ScalarField defining the distribution
|
||||||
std::shared_ptr<ScalarField> mother_density_;
|
std::shared_ptr<ScalarField> mother_density_;
|
||||||
|
|
||||||
// for Rejection method
|
// distribution functions drawn to be drawn from in the rejection method
|
||||||
std::uniform_real_distribution<double> r_values;
|
std::uniform_real_distribution<double> r_values;
|
||||||
std::uniform_real_distribution<double> z_values;
|
std::uniform_real_distribution<double> z_values;
|
||||||
std::uniform_real_distribution<double> phi_values;
|
std::uniform_real_distribution<double> phi_values;
|
||||||
|
|||||||
@@ -3,14 +3,21 @@
|
|||||||
|
|
||||||
#include "simulation/coordinates.h"
|
#include "simulation/coordinates.h"
|
||||||
|
|
||||||
|
// class defining the miminmum requirement of a Geometry class
|
||||||
class Geometry {
|
class Geometry {
|
||||||
public:
|
public:
|
||||||
|
// check if Coordinate position is contained in the Geometry
|
||||||
virtual bool isInside(const Coordinate& position) const = 0;
|
virtual bool isInside(const Coordinate& position) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Geometry class for a cylinder
|
||||||
class Cylinder : public Geometry {
|
class Cylinder : public Geometry {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: takes the radius and height of the cylinder
|
||||||
|
// z always starts at 0
|
||||||
Cylinder(double radius, double height);
|
Cylinder(double radius, double height);
|
||||||
|
// check whether Coordinate position lies within the Cylinder
|
||||||
|
// i.e. z in (0,height), r in (0,radius)
|
||||||
bool isInside(const Coordinate& position) const;
|
bool isInside(const Coordinate& position) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#ifndef HOMEBASE_H
|
#ifndef HOMEBASE_H
|
||||||
#define HOMEBASE_H
|
#define HOMEBASE_H
|
||||||
|
|
||||||
|
// BUILD_HOMEBASE_STRING returns the string of the path stored in the HOMEBASE shell variable
|
||||||
#define STRINGIZER(arg) #arg
|
#define STRINGIZER(arg) #arg
|
||||||
#define STR_VALUE(arg) STRINGIZER(arg)
|
#define STR_VALUE(arg) STRINGIZER(arg)
|
||||||
#define BUILD_HOMEBASE_STRING STR_VALUE(HOMEBASE)
|
#define BUILD_HOMEBASE_STRING STR_VALUE(HOMEBASE)
|
||||||
|
|||||||
@@ -8,34 +8,48 @@
|
|||||||
|
|
||||||
#include "simulation/coordinates.h"
|
#include "simulation/coordinates.h"
|
||||||
|
|
||||||
|
// defined in "simulation/drift_velocity.h"
|
||||||
class DriftVelocity;
|
class DriftVelocity;
|
||||||
|
// defined in "simulation/veloctiy_distribution.h"
|
||||||
class VelocityDistribution;
|
class VelocityDistribution;
|
||||||
|
|
||||||
|
// defined in "simulation/particle.h"
|
||||||
namespace particle {
|
namespace particle {
|
||||||
class Particle;
|
class Particle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// defined in "simulation/species.h"
|
||||||
namespace species {
|
namespace species {
|
||||||
class Specie;
|
class Specie;
|
||||||
class TrackedSpecie;
|
class TrackedSpecie;
|
||||||
} // namespace species
|
} // namespace species
|
||||||
|
|
||||||
|
// defined in "simulation/event_position_distribution.h"
|
||||||
class EventPositionDistribution;
|
class EventPositionDistribution;
|
||||||
|
|
||||||
|
// structure storing information about particles that are injected by the injector
|
||||||
|
// conains the TrackedSpecie of the particle and its veloctiy distribution
|
||||||
struct InjectorInfo {
|
struct InjectorInfo {
|
||||||
public:
|
public:
|
||||||
std::shared_ptr<species::TrackedSpecie> created_specie;
|
std::shared_ptr<species::TrackedSpecie> created_specie;
|
||||||
std::shared_ptr<VelocityDistribution> creation_velocity_distribution;
|
std::shared_ptr<VelocityDistribution> creation_velocity_distribution;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class handling injection of event particles (i.e. particles from the tritium beta decay)
|
||||||
class Injector {
|
class Injector {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: takes a vector of InjectorInfo objects defining the particles that are supposed to be injected at invocation of the Injector object
|
||||||
|
// the activity of the simulation volume (units 1/s) defines the "timestep" (i.e. 1/activity)
|
||||||
|
// an EventPositionDistribution defining the valid space of the simulation domain where particles can be created
|
||||||
|
// a DriftVelocity object defining the bulk motion the injected particles are created with (regardless of specie), can be null
|
||||||
Injector(std::vector<InjectorInfo>& injector_info,
|
Injector(std::vector<InjectorInfo>& injector_info,
|
||||||
double activity,
|
double activity,
|
||||||
std::shared_ptr<EventPositionDistribution> position_distribution,
|
std::shared_ptr<EventPositionDistribution> position_distribution,
|
||||||
std::shared_ptr<DriftVelocity> mother_drift_velocity);
|
std::shared_ptr<DriftVelocity> mother_drift_velocity);
|
||||||
|
|
||||||
|
// return a vector with the particles defined in the InjectorInfo vector using the random engine object
|
||||||
std::vector<particle::Particle> rollNewParticles(std::mt19937* engine);
|
std::vector<particle::Particle> rollNewParticles(std::mt19937* engine);
|
||||||
|
// return average time between events (1/activity)
|
||||||
double timePassed() const;
|
double timePassed() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -44,6 +58,8 @@ class Injector {
|
|||||||
std::shared_ptr<EventPositionDistribution> position_distribution_;
|
std::shared_ptr<EventPositionDistribution> position_distribution_;
|
||||||
std::shared_ptr<DriftVelocity> mother_drift_velocity_;
|
std::shared_ptr<DriftVelocity> mother_drift_velocity_;
|
||||||
|
|
||||||
|
// draw a single particle of species created_specie with a velocity distribution creation_velocity_distribution
|
||||||
|
// at the Coordinate position using the random engine engine
|
||||||
particle::Particle rollNewParticle(
|
particle::Particle rollNewParticle(
|
||||||
std::mt19937* engine,
|
std::mt19937* engine,
|
||||||
const Coordinate& position,
|
const Coordinate& position,
|
||||||
|
|||||||
@@ -11,28 +11,48 @@
|
|||||||
|
|
||||||
namespace interaction {
|
namespace interaction {
|
||||||
|
|
||||||
|
// class to define the output of an interaction
|
||||||
class InteractionOutput {
|
class InteractionOutput {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: incident particle is not flagged for deletion
|
||||||
InteractionOutput();
|
InteractionOutput();
|
||||||
|
|
||||||
|
// if new_decider is true then the incident particle of the interaction is
|
||||||
|
// flagged for deletion
|
||||||
void deleteCurrentParticle(bool new_decider);
|
void deleteCurrentParticle(bool new_decider);
|
||||||
|
// return if the incident particle is flagged for deletion
|
||||||
bool deleteCurrentParticle();
|
bool deleteCurrentParticle();
|
||||||
|
// add particles that are created (not the incident) particles to the InteractionOutput
|
||||||
void add(const particle::Particle& new_particle);
|
void add(const particle::Particle& new_particle);
|
||||||
|
// return the vector of particles that have been created by an interactoin
|
||||||
std::vector<particle::Particle> newParticles();
|
std::vector<particle::Particle> newParticles();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// flag if the incident particle should be deleted
|
||||||
bool delete_current_particle_;
|
bool delete_current_particle_;
|
||||||
|
// vector for the interaction products (no including the incident particle even if it's not
|
||||||
|
// destroyed by the interaction)
|
||||||
std::vector<particle::Particle> new_particles_;
|
std::vector<particle::Particle> new_particles_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// parent class for all interactions (cannot be instantiated)
|
||||||
class Interaction {
|
class Interaction {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: takes a function describing the cross section of used for the interaction as a function of energy (in eV)
|
||||||
|
// a shared_ptr to the Specie of the target species
|
||||||
Interaction(std::function<double(double)> cross_section,
|
Interaction(std::function<double(double)> cross_section,
|
||||||
std::shared_ptr<species::Specie> target);
|
std::shared_ptr<species::Specie> target);
|
||||||
|
|
||||||
virtual double microscopicCrossSection(double energy_eV);
|
// return the value of the cross section at the energy (in eV) energy_eV in m^2
|
||||||
|
// Coordinate position necessary for three body processes in which the
|
||||||
|
// cross section depends on the density at the position (see "interactions/cluster_formation.h")
|
||||||
|
virtual double microscopicCrossSection(double energy_eV, const Coordinate& position);
|
||||||
|
// calculate the density scaled cross section for the Particle particle
|
||||||
|
// interacting with the defined target Specie (returns cross section * target density) (units: m^-1)
|
||||||
|
// assumes that v_particle >> v_target
|
||||||
virtual double macroscopicCrossSection(particle::Particle& particle);
|
virtual double macroscopicCrossSection(particle::Particle& particle);
|
||||||
|
|
||||||
|
// pure virtual function defining the specifics of the actual interaction
|
||||||
virtual InteractionOutput performInteraction(particle::Particle& particle,
|
virtual InteractionOutput performInteraction(particle::Particle& particle,
|
||||||
RandomNumbers* generator) = 0;
|
RandomNumbers* generator) = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,12 @@
|
|||||||
#include "simulation/errors.h"
|
#include "simulation/errors.h"
|
||||||
#include "simulation/unit_converter.h"
|
#include "simulation/unit_converter.h"
|
||||||
|
|
||||||
|
// define the json_path type; contains the keys of the nested json-objects
|
||||||
|
// as the elements in the vector e.g. ["Root", "Group1", "Group2", ..., "GroupN"]
|
||||||
typedef std::vector<std::string> json_path;
|
typedef std::vector<std::string> json_path;
|
||||||
|
|
||||||
|
// return the value specified by "path" as a json_t pointer
|
||||||
|
// (can point to a json-object, json-array, etc.)
|
||||||
inline json_t* json_object_by_path(json_t* object, const json_path& path) {
|
inline json_t* json_object_by_path(json_t* object, const json_path& path) {
|
||||||
json_t* j_obj = object;
|
json_t* j_obj = object;
|
||||||
for (auto str : path) {
|
for (auto str : path) {
|
||||||
@@ -20,6 +24,7 @@ inline json_t* json_object_by_path(json_t* object, const json_path& path) {
|
|||||||
return j_obj;
|
return j_obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// return the value of the json_t pointer "object" as an double; defaults "default value"
|
||||||
inline double json_double(json_t* object, double default_value = 0.) {
|
inline double json_double(json_t* object, double default_value = 0.) {
|
||||||
if (object) {
|
if (object) {
|
||||||
return json_real_value(object);
|
return json_real_value(object);
|
||||||
@@ -28,6 +33,8 @@ inline double json_double(json_t* object, double default_value = 0.) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// return the value of the json_t pointer "object" as an int; defaults to "default value"
|
||||||
|
// if the pointer is not a json-real value
|
||||||
inline int json_int(json_t* object, int default_value = 0) {
|
inline int json_int(json_t* object, int default_value = 0) {
|
||||||
if (object) {
|
if (object) {
|
||||||
return std::floor(json_real_value(object));
|
return std::floor(json_real_value(object));
|
||||||
@@ -36,6 +43,8 @@ inline int json_int(json_t* object, int default_value = 0) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// return the value of the json_t pointer "object" as a string; defaults "default value"
|
||||||
|
// if the pointer is not a json-string
|
||||||
inline std::string json_string(json_t* object, std::string default_value = "") {
|
inline std::string json_string(json_t* object, std::string default_value = "") {
|
||||||
if (object) {
|
if (object) {
|
||||||
return std::string(json_string_value(object));
|
return std::string(json_string_value(object));
|
||||||
@@ -44,6 +53,8 @@ inline std::string json_string(json_t* object, std::string default_value = "") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// return the value of the json_t pointer "object" as a bool; defaults to default_value
|
||||||
|
// if the pointer is not a json-string or the string has a value different from "true" or "false"
|
||||||
inline bool json_bool(json_t* object, bool default_value = false) {
|
inline bool json_bool(json_t* object, bool default_value = false) {
|
||||||
if (object) {
|
if (object) {
|
||||||
return (json_string(object) == "true");
|
return (json_string(object) == "true");
|
||||||
@@ -52,6 +63,9 @@ inline bool json_bool(json_t* object, bool default_value = false) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// return the json-array "vector" in the given json-object object as a blitz::TinyVector
|
||||||
|
// if the "vector" json-array does not exist or does not contain the same number of elements as
|
||||||
|
// specified in the template parameter s an error is thrown
|
||||||
template <int s>
|
template <int s>
|
||||||
blitz::TinyVector<double, s> json_blitz_vector(json_t* object) {
|
blitz::TinyVector<double, s> json_blitz_vector(json_t* object) {
|
||||||
blitz::TinyVector<double, s> vector;
|
blitz::TinyVector<double, s> vector;
|
||||||
@@ -73,6 +87,8 @@ blitz::TinyVector<double, s> json_blitz_vector(json_t* object) {
|
|||||||
return vector;
|
return vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// returns a vector<double> containing the values of a json-array pointed to by
|
||||||
|
// json_t* object; if json_t* object is not a json-array returns an empty vector
|
||||||
inline std::vector<double> json_vector(json_t* object) {
|
inline std::vector<double> json_vector(json_t* object) {
|
||||||
std::vector<double> vector;
|
std::vector<double> vector;
|
||||||
size_t index;
|
size_t index;
|
||||||
@@ -83,6 +99,7 @@ inline std::vector<double> json_vector(json_t* object) {
|
|||||||
return vector;
|
return vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// return the json-array in "object" as a json_path variable
|
||||||
inline json_path json_path_get(json_t* object) {
|
inline json_path json_path_get(json_t* object) {
|
||||||
json_path path;
|
json_path path;
|
||||||
|
|
||||||
@@ -94,6 +111,8 @@ inline json_path json_path_get(json_t* object) {
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// returns a json_path variable, that consists of the path appended by the
|
||||||
|
// json_path append
|
||||||
inline json_path json_path_append(const json_path& path,
|
inline json_path json_path_append(const json_path& path,
|
||||||
const json_path& append) {
|
const json_path& append) {
|
||||||
json_path result = path;
|
json_path result = path;
|
||||||
@@ -103,12 +122,24 @@ inline json_path json_path_append(const json_path& path,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// returns the value of a json-object, which should consist of a json-real with the key
|
||||||
|
// "value" and a json-string with the key "unit" transformed to the specified length
|
||||||
|
// "output_unit" (supported units: "mm", "cm", "m"). If the key "unit" does not exist or is not
|
||||||
|
// a json-string an error will be thrown and the program will terminate. If the key "value"
|
||||||
|
// does not exist or not a json-real it will default to 0.0
|
||||||
inline double json_read_length(json_t* object, std::string output_unit = "m") {
|
inline double json_read_length(json_t* object, std::string output_unit = "m") {
|
||||||
double value = json_double(json_object_by_path(object, {"value"}));
|
double value = json_double(json_object_by_path(object, {"value"}));
|
||||||
std::string unit = json_string(json_object_by_path(object, {"unit"}));
|
std::string unit = json_string(json_object_by_path(object, {"unit"}));
|
||||||
return unitConvertion::length(value, unit, output_unit);
|
return unitConvertion::length(value, unit, output_unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
returns the value of a json-object, which should consist of a json-real with the key
|
||||||
|
"value" and a json-string with the key "unit" transformed to the specified energy
|
||||||
|
"output_unit" (supported units: "eV", "J"). If the key "unit" does not exist or is not
|
||||||
|
a json-string an error will be thrown and the program will terminate. If the key "value"
|
||||||
|
does not exist or not a json-real it will default to 0.0
|
||||||
|
*/
|
||||||
inline double json_read_energy(json_t* object, std::string output_unit = "eV") {
|
inline double json_read_energy(json_t* object, std::string output_unit = "eV") {
|
||||||
double value = json_double(json_object_by_path(object, {"value"}));
|
double value = json_double(json_object_by_path(object, {"value"}));
|
||||||
std::string unit = json_string(json_object_by_path(object, {"unit"}));
|
std::string unit = json_string(json_object_by_path(object, {"unit"}));
|
||||||
|
|||||||
@@ -4,22 +4,38 @@
|
|||||||
#include "simulation/coordinates.h"
|
#include "simulation/coordinates.h"
|
||||||
|
|
||||||
namespace kinematic {
|
namespace kinematic {
|
||||||
|
// calculate the velocity of the center off mass, where velocity_1 (cartesian vector, m/s) and
|
||||||
|
// mass_1 (kg) belong to the same particle and velocity_2 (cartesian vector, m/s) and mass_2 (kg) belong
|
||||||
|
// to the same particle
|
||||||
blitz::TinyVector<double, 3> velocityOfCenterOfMass(
|
blitz::TinyVector<double, 3> velocityOfCenterOfMass(
|
||||||
const blitz::TinyVector<double, 3>& velocity_1,
|
const blitz::TinyVector<double, 3>& velocity_1,
|
||||||
const blitz::TinyVector<double, 3>& velocity_2,
|
const blitz::TinyVector<double, 3>& velocity_2,
|
||||||
double mass_1,
|
double mass_1,
|
||||||
double mass_2);
|
double mass_2);
|
||||||
|
|
||||||
|
// Galileo transformation to the rest frame of the second particle
|
||||||
|
// both velocities are in m/s and both masses in kg
|
||||||
blitz::TinyVector<double, 3> velocityTargetFixed(
|
blitz::TinyVector<double, 3> velocityTargetFixed(
|
||||||
const blitz::TinyVector<double, 3>& velocity_1,
|
const blitz::TinyVector<double, 3>& velocity_1,
|
||||||
const blitz::TinyVector<double, 3>& velocity_2,
|
const blitz::TinyVector<double, 3>& velocity_2,
|
||||||
double mass_1,
|
double mass_1,
|
||||||
double mass_2);
|
double mass_2);
|
||||||
|
|
||||||
|
// rotates the vector (cartesian) v by the polar angle theta and the azimuthal angle phi
|
||||||
|
// in the frame where v is aligned with the z-axis
|
||||||
|
// returns the rotated vector as a blitz::TinyVector in cartesian coordinates in the
|
||||||
|
// original frame where v is not (not neccessarily) aligned with the z-axis (all in SI units)
|
||||||
blitz::TinyVector<double, 3> rotateVector(const blitz::TinyVector<double, 3>& v,
|
blitz::TinyVector<double, 3> rotateVector(const blitz::TinyVector<double, 3>& v,
|
||||||
double theta,
|
double theta,
|
||||||
double phi);
|
double phi);
|
||||||
|
|
||||||
|
// transform velocity_1 into the center of mass frame defined by
|
||||||
|
// velocity_1, mass_1 and velocity_2 and mass_2 (vectors are cartesian)
|
||||||
|
// velocity_1_centerOfMass is then rotated by the polar angle theta and the
|
||||||
|
// azimuthal angle phi in the frame in which velocity_1_centerOfMass is aligned with
|
||||||
|
// the z-axis
|
||||||
|
// returns the rotated velocity_1 vector in the original non-center of mass frame (cartesian coordinates)
|
||||||
|
// (all in SI units)
|
||||||
blitz::TinyVector<double, 3> rotateVelocityInCenterOfMassFrame(
|
blitz::TinyVector<double, 3> rotateVelocityInCenterOfMassFrame(
|
||||||
const blitz::TinyVector<double, 3>& velocity_1,
|
const blitz::TinyVector<double, 3>& velocity_1,
|
||||||
const blitz::TinyVector<double, 3>& velocity_2,
|
const blitz::TinyVector<double, 3>& velocity_2,
|
||||||
@@ -28,38 +44,73 @@ blitz::TinyVector<double, 3> rotateVelocityInCenterOfMassFrame(
|
|||||||
double theta,
|
double theta,
|
||||||
double phi);
|
double phi);
|
||||||
|
|
||||||
|
// return the non-relativistic kinetic energy (J) defined by the cartesian velocity (m/s)
|
||||||
|
// and the mass (kg)
|
||||||
double kineticEnergy(const blitz::TinyVector<double, 3>& velocity, double mass);
|
double kineticEnergy(const blitz::TinyVector<double, 3>& velocity, double mass);
|
||||||
|
// transform the temperature (K) into an energy in eV
|
||||||
double thermalEnergy(double temperature_K);
|
double thermalEnergy(double temperature_K);
|
||||||
|
|
||||||
|
// returns the modulus of the velocity (m/s) of the kinetic energy (eV)
|
||||||
|
// and the mass (kg) (non-relativistic)
|
||||||
double velocity(double energy_eV, double mass_kg);
|
double velocity(double energy_eV, double mass_kg);
|
||||||
|
|
||||||
|
// transform the cartesian velocity v2 in the frame moving with cartesian velocity v1
|
||||||
|
// into the laboratory frame (both velocities in m/s)
|
||||||
|
// returns the boosted vector in cartesian coordinates
|
||||||
blitz::TinyVector<double, 3> relativisticBoost(
|
blitz::TinyVector<double, 3> relativisticBoost(
|
||||||
const blitz::TinyVector<double, 3>& v1,
|
const blitz::TinyVector<double, 3>& v1,
|
||||||
const blitz::TinyVector<double, 3>& v2);
|
const blitz::TinyVector<double, 3>& v2);
|
||||||
|
|
||||||
|
// calculate gamma from velocity from the given cartesian velocity (in SI units)
|
||||||
|
// where the velocity is the realtivistic 3 momentum divided by the rest mass of the particle
|
||||||
double relativisticGamma(const blitz::TinyVector<double, 3>& velocity);
|
double relativisticGamma(const blitz::TinyVector<double, 3>& velocity);
|
||||||
|
// calculates the Lorentz factor given the kinetic energy in eV and the
|
||||||
|
// rest mass of the particle transformed to eV
|
||||||
double relativisticGamma(double kin_energy_eV, double mass_eV);
|
double relativisticGamma(double kin_energy_eV, double mass_eV);
|
||||||
|
// return the cartesian velocity (m/s) devided by the speed of light
|
||||||
double relativisticBeta(double velocity_ms);
|
double relativisticBeta(double velocity_ms);
|
||||||
|
// calculates the relativistic beta (velocity/speed of light) given the kinetic energy in eV and the
|
||||||
|
// rest mass of the particle transformed to eV
|
||||||
double relativisticBeta(double kin_energy_eV, double mass_eV);
|
double relativisticBeta(double kin_energy_eV, double mass_eV);
|
||||||
|
|
||||||
|
// Note: what units does the relativisitvMomentum function "return"?
|
||||||
|
|
||||||
|
// calculate the modulus of the realtivistic momentum from the kinetic energy in eV
|
||||||
|
// and the mass in eV
|
||||||
double relativisticMomentum(double energy_eV, double mass_eV);
|
double relativisticMomentum(double energy_eV, double mass_eV);
|
||||||
|
|
||||||
|
// returns the norm of the vector
|
||||||
double norm(const blitz::TinyVector<double, 3>& vector);
|
double norm(const blitz::TinyVector<double, 3>& vector);
|
||||||
|
|
||||||
|
// calculates the distance between the two points position_1 and position_2
|
||||||
|
// which are both in cylinder coordinates (r, phi, z)
|
||||||
double distanceInCylinder(const blitz::TinyVector<double, 3>& position_1,
|
double distanceInCylinder(const blitz::TinyVector<double, 3>& position_1,
|
||||||
const blitz::TinyVector<double, 3>& position_2);
|
const blitz::TinyVector<double, 3>& position_2);
|
||||||
|
|
||||||
|
|
||||||
|
// calculate v_perp, s.t. vector = v_perp + v_parallel, with
|
||||||
|
// v_perp perpendicular to the vector direction and v_parallel parallel to the vector direction
|
||||||
|
// (both vectors cartesian)
|
||||||
blitz::TinyVector<double, 3> perpendicularVector(
|
blitz::TinyVector<double, 3> perpendicularVector(
|
||||||
const blitz::TinyVector<double, 3>& vector,
|
const blitz::TinyVector<double, 3>& vector,
|
||||||
const blitz::TinyVector<double, 3>& direction);
|
const blitz::TinyVector<double, 3>& direction);
|
||||||
|
// calculate v_parallel, s.t. vector = v_perp + v_parallel, with
|
||||||
|
// v_perp perpendicular to the vector direction and v_parallel parallel to the vector direction
|
||||||
|
// (both vectors cartesian)
|
||||||
blitz::TinyVector<double, 3> parallelVector(
|
blitz::TinyVector<double, 3> parallelVector(
|
||||||
const blitz::TinyVector<double, 3>& vector,
|
const blitz::TinyVector<double, 3>& vector,
|
||||||
const blitz::TinyVector<double, 3>& direction);
|
const blitz::TinyVector<double, 3>& direction);
|
||||||
|
|
||||||
|
// rotate vector around rotation_axis about the angle angle
|
||||||
|
// (vectors cartesian) according to the right hand rule
|
||||||
|
// using Rogrigues' formula
|
||||||
blitz::TinyVector<double, 3> rotateVector(
|
blitz::TinyVector<double, 3> rotateVector(
|
||||||
const blitz::TinyVector<double, 3>& vector,
|
const blitz::TinyVector<double, 3>& vector,
|
||||||
const blitz::TinyVector<double, 3>& rotation_axis,
|
const blitz::TinyVector<double, 3>& rotation_axis,
|
||||||
double angle);
|
double angle);
|
||||||
|
|
||||||
|
// return the random_unit_vector scaled by the modulus of the non-relativistic velocity
|
||||||
|
// defined by the kinetic energy energy_eV (eV) and mass mass_kg (kg)
|
||||||
blitz::TinyVector<double, 3> velocityVector(
|
blitz::TinyVector<double, 3> velocityVector(
|
||||||
double energy_eV,
|
double energy_eV,
|
||||||
const blitz::TinyVector<double, 3>& random_unit_vector,
|
const blitz::TinyVector<double, 3>& random_unit_vector,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include "simulation/coordinates.h"
|
#include "simulation/coordinates.h"
|
||||||
|
|
||||||
|
// enum that defines the different types of deletions that can be counted
|
||||||
enum class DeletionType {
|
enum class DeletionType {
|
||||||
wall,
|
wall,
|
||||||
recombination,
|
recombination,
|
||||||
@@ -13,19 +14,35 @@ enum class DeletionType {
|
|||||||
cluster_formation
|
cluster_formation
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class that keeps track of the DeletionType that caused a particle to be deleted
|
||||||
class DeletionLogger {
|
class DeletionLogger {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: vector used_types defines for which DeletionType elements the
|
||||||
|
// deletion is supposed to be tracked (i.e. if recombination is not
|
||||||
|
// specified in the used_types vector, then particles that are
|
||||||
|
// removed due to recombination are not counted)
|
||||||
DeletionLogger(std::vector<DeletionType> used_types);
|
DeletionLogger(std::vector<DeletionType> used_types);
|
||||||
|
|
||||||
|
// increase the count corresponding to DeletionType by 1
|
||||||
|
// Coordinate coordinate is not used (i.e. can be chosen arbitrarily)
|
||||||
virtual void logDeletion(const Coordinate& coordinate, DeletionType type);
|
virtual void logDeletion(const Coordinate& coordinate, DeletionType type);
|
||||||
|
|
||||||
|
// returns the map with the keys being the tracked DeletionTypes and the
|
||||||
|
// value the long int count of how many particles have been logged by the
|
||||||
|
// corresponding key
|
||||||
std::map<DeletionType, long int> numDeletions() const;
|
std::map<DeletionType, long int> numDeletions() const;
|
||||||
|
// set the count for DeletionType type to new_value
|
||||||
void numDeletions(long int new_value, DeletionType type);
|
void numDeletions(long int new_value, DeletionType type);
|
||||||
|
// return the count for DeletionType type; if the type was not specified
|
||||||
|
// as used in the creation of the object return 0
|
||||||
long int numDeletions(DeletionType type) const;
|
long int numDeletions(DeletionType type) const;
|
||||||
|
|
||||||
|
// make private member variable accessable for the cpu synchronization
|
||||||
friend class CpuSynchronizer;
|
friend class CpuSynchronizer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// map with keys being the used DeletionTypes and the value being the count
|
||||||
|
// of how many particles have been deleted due to the DeletionType of the key
|
||||||
std::map<DeletionType, long int> num_deletions;
|
std::map<DeletionType, long int> num_deletions;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "simulation/electromagnetic_field.h"
|
#include "simulation/electromagnetic_field.h"
|
||||||
#include "simulation/particle.h"
|
#include "simulation/particle.h"
|
||||||
|
|
||||||
|
// class defining the minimum requirements of a mover class
|
||||||
class Mover {
|
class Mover {
|
||||||
public:
|
public:
|
||||||
virtual void move(particle::Particle* particle,
|
virtual void move(particle::Particle* particle,
|
||||||
@@ -12,10 +13,18 @@ class Mover {
|
|||||||
MagneticField* magnetic_field) = 0;
|
MagneticField* magnetic_field) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Mover class using the Boris push algorithm for propagation
|
||||||
class BorisMover : public Mover {
|
class BorisMover : public Mover {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: sets the maximal timestep acceptable for the Boris puhs algorithm
|
||||||
|
// (should at the very least resolve the gyro timescale of the particle)
|
||||||
BorisMover(double maximal_time_step_s);
|
BorisMover(double maximal_time_step_s);
|
||||||
|
|
||||||
|
// propagate the Particle particle using the electric and magnetic fields
|
||||||
|
// until the particle has moved a distance of mfp_m or until it changes
|
||||||
|
// either its energy or position bin or it reaches the maximal time the
|
||||||
|
// particle is allowed to live
|
||||||
|
// also updates the density, deletion logger and current collector of the particle species
|
||||||
void move(particle::Particle* particle,
|
void move(particle::Particle* particle,
|
||||||
double mfp_m,
|
double mfp_m,
|
||||||
ElectricField* electric_field,
|
ElectricField* electric_field,
|
||||||
@@ -24,16 +33,29 @@ class BorisMover : public Mover {
|
|||||||
private:
|
private:
|
||||||
const double maximal_time_step_s_;
|
const double maximal_time_step_s_;
|
||||||
|
|
||||||
|
// single update step of the Boris push algorithm
|
||||||
|
// updates moved_distance by the distance the particle moved during the update step
|
||||||
|
// the electric_field and magnetic_field TinyVectors have to contain the electric and
|
||||||
|
// magnetic fields in Cartesian coordinates
|
||||||
void movementStep(particle::Particle* particle,
|
void movementStep(particle::Particle* particle,
|
||||||
const blitz::TinyVector<double, 3>& electric_field,
|
const blitz::TinyVector<double, 3>& electric_field,
|
||||||
const blitz::TinyVector<double, 3>& magnetic_field,
|
const blitz::TinyVector<double, 3>& magnetic_field,
|
||||||
|
const double timestep,
|
||||||
double& moved_distance) const;
|
double& moved_distance) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Mover class using the drift approximation for propagation
|
||||||
class DriftMover : public Mover {
|
class DriftMover : public Mover {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: takes the maximal distance the particle is allowed to move during one step
|
||||||
|
// (should be smaller than the length scale defined by the gradient of the modulus of the magnetic field)
|
||||||
DriftMover(double maximal_distance);
|
DriftMover(double maximal_distance);
|
||||||
|
|
||||||
|
// propagate the Particle particle using the electric and magnetic fields
|
||||||
|
// until the particle has moved a distance of mfp_m or until it changes
|
||||||
|
// either its energy or position bin or it reaches the maximal time the
|
||||||
|
// particle is allowed to live
|
||||||
|
// also updates the density, deletion logger and current collector of the particle species
|
||||||
void move(particle::Particle* particle,
|
void move(particle::Particle* particle,
|
||||||
double mfp_m,
|
double mfp_m,
|
||||||
ElectricField* electric_field,
|
ElectricField* electric_field,
|
||||||
@@ -42,9 +64,28 @@ class DriftMover : public Mover {
|
|||||||
private:
|
private:
|
||||||
const double maximal_distance_m_;
|
const double maximal_distance_m_;
|
||||||
|
|
||||||
|
// single update step using the drift approximation
|
||||||
|
// updates moved_distance by the distance the particle moved during the update step
|
||||||
blitz::TinyVector<double, 3> driftVelocity(
|
blitz::TinyVector<double, 3> driftVelocity(
|
||||||
const blitz::TinyVector<double, 3>& magnetic_field,
|
const blitz::TinyVector<double, 3>& magnetic_field,
|
||||||
const blitz::TinyVector<double, 3>& electric_field) const;
|
const blitz::TinyVector<double, 3>& electric_field) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Mover for the case of no magnetic field. Simply ignores electric and magnetic field
|
||||||
|
// for the movement step, i.e. velocity doesn't change.
|
||||||
|
class EulerMover : public Mover {
|
||||||
|
public:
|
||||||
|
// Constructor: takes the maxium distance the particle is allowed to move during
|
||||||
|
// one update step (used to limit the distance a particle can move
|
||||||
|
// into a neighboring bin before the check can be performed if the bin has been changed)
|
||||||
|
EulerMover(double maximal_distance);
|
||||||
|
|
||||||
|
void move(particle::Particle* particle,
|
||||||
|
double mfp_m,
|
||||||
|
ElectricField* electric_field,
|
||||||
|
MagneticField* magnetic_field);
|
||||||
|
private:
|
||||||
|
const double maximal_distance_m_;
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* MOVER_H */
|
#endif /* MOVER_H */
|
||||||
|
|||||||
@@ -1,15 +1,20 @@
|
|||||||
#ifndef MPI_COMMUNICATION_H
|
#ifndef MPI_COMMUNICATION_H
|
||||||
#define MPI_COMMUNICATION_H
|
#define MPI_COMMUNICATION_H
|
||||||
|
|
||||||
|
// class to handle MPI communication
|
||||||
class MpiCommunication {
|
class MpiCommunication {
|
||||||
public:
|
public:
|
||||||
static int mpi_rank;
|
static int mpi_rank;
|
||||||
static int mpi_size;
|
static int mpi_size;
|
||||||
|
|
||||||
|
// returns the MPI-rank of the process
|
||||||
static int mpiRank();
|
static int mpiRank();
|
||||||
|
// returns the number of MPI processes
|
||||||
static int mpiSize();
|
static int mpiSize();
|
||||||
|
|
||||||
|
// initialize the two member variables
|
||||||
static void init(int argc, char* argv[]);
|
static void init(int argc, char* argv[]);
|
||||||
|
// wrapper for MPI_Finalize()
|
||||||
static void finalize();
|
static void finalize();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
#ifndef NEUTRAL_GAS_H
|
|
||||||
#define NEUTRAL_GAS_H
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* NEUTRAL_GAS_H */
|
|
||||||
@@ -7,23 +7,37 @@
|
|||||||
#include "jansson.h"
|
#include "jansson.h"
|
||||||
#include "simulation/jansson_additionals.h"
|
#include "simulation/jansson_additionals.h"
|
||||||
|
|
||||||
|
// class to handle the json-parameter file and read it's data
|
||||||
class Parameter {
|
class Parameter {
|
||||||
public:
|
public:
|
||||||
Parameter(std::string filename);
|
Parameter(std::string filename);
|
||||||
~Parameter();
|
~Parameter();
|
||||||
|
|
||||||
|
// read the value at the json path and return it as a double; defaults to 0.0
|
||||||
double doubleValue(const json_path& path) const;
|
double doubleValue(const json_path& path) const;
|
||||||
|
// read the value at the json path and return it as a double; defaults to the default value
|
||||||
double doubleValue(const json_path& path, double default_value) const;
|
double doubleValue(const json_path& path, double default_value) const;
|
||||||
|
// read the value at the json path and return it as a int; defaults to 0
|
||||||
int intValue(const json_path& path) const;
|
int intValue(const json_path& path) const;
|
||||||
|
// read the value at the json path and return it as a int; defaults to default value
|
||||||
int intValue(const json_path& path, int default_value) const;
|
int intValue(const json_path& path, int default_value) const;
|
||||||
|
// read the value at the json path and return it as a string; defaults to the empty string
|
||||||
std::string stringValue(const json_path& path) const;
|
std::string stringValue(const json_path& path) const;
|
||||||
|
// read the value at the json path and return it as a string; defaults to the default value
|
||||||
std::string stringValue(const json_path& path,
|
std::string stringValue(const json_path& path,
|
||||||
const std::string& default_value) const;
|
const std::string& default_value) const;
|
||||||
|
// read the value at the json path and return it as a string;
|
||||||
|
// the string "true" in the json file results in true, everything else in false
|
||||||
bool boolValue(const json_path& path) const;
|
bool boolValue(const json_path& path) const;
|
||||||
|
// read the value at the json path and return it as a string;
|
||||||
|
// the string "true" in the json file results in true, everything else in the default value
|
||||||
bool boolValue(const json_path& path, bool default_value) const;
|
bool boolValue(const json_path& path, bool default_value) const;
|
||||||
|
|
||||||
|
// check if "path" exists in the json-parameter file
|
||||||
bool pathExists(const json_path& path) const;
|
bool pathExists(const json_path& path) const;
|
||||||
|
// return a pointer to the json_t object of the json-parameter_file
|
||||||
json_t* jsonFile() const;
|
json_t* jsonFile() const;
|
||||||
|
// return a pointer to the json_t object of the group specified by "path"
|
||||||
json_t* jsonObjectFromBase(const json_path& path) const;
|
json_t* jsonObjectFromBase(const json_path& path) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -7,48 +7,79 @@
|
|||||||
|
|
||||||
namespace particle {
|
namespace particle {
|
||||||
|
|
||||||
|
// class for the simulated particles
|
||||||
class Particle {
|
class Particle {
|
||||||
public:
|
public:
|
||||||
// Particle(std::shared_ptr<species::TrackedSpecie> specie,
|
// Constructor: takes shared_ptr to the TrackedSpecies object that describes the particle
|
||||||
// Coordinate* position,
|
// the Coordinate containing the position the particle should be created at
|
||||||
// Vector* velocity);
|
// the Vector containing the velocity the particle should be created with
|
||||||
Particle(std::shared_ptr<species::TrackedSpecie> specie,
|
Particle(std::shared_ptr<species::TrackedSpecie> specie,
|
||||||
const Coordinate& position,
|
const Coordinate& position,
|
||||||
const Vector& velocity);
|
const Vector& velocity);
|
||||||
|
|
||||||
|
// set the position of the particle to the provided Coordinate new_position
|
||||||
void position(const Coordinate& new_position);
|
void position(const Coordinate& new_position);
|
||||||
|
// return the position of the particle as a CartesianCoordinate
|
||||||
CartesianCoordinate position() const;
|
CartesianCoordinate position() const;
|
||||||
|
// return the cylinder position of the particle
|
||||||
|
CylinderCoordinate cylinderPosition() const;
|
||||||
|
|
||||||
|
// set the velocity of the particle to the provided CartesianVector new_velocity
|
||||||
void velocity(const CartesianVector& new_velocity);
|
void velocity(const CartesianVector& new_velocity);
|
||||||
|
// return the velocity of the particle as a CartesianVector
|
||||||
CartesianVector velocity() const;
|
CartesianVector velocity() const;
|
||||||
|
|
||||||
|
// ads the Coordinate distance to the position of the particle
|
||||||
|
// x_new = x_old + distance
|
||||||
void move(const Coordinate& distance);
|
void move(const Coordinate& distance);
|
||||||
|
|
||||||
|
// return the kinetic energy of the particle in eV
|
||||||
double kineticEnergy_eV() const;
|
double kineticEnergy_eV() const;
|
||||||
|
// return the modulus of the particle velocity in m/s
|
||||||
double absoluteVelocity() const;
|
double absoluteVelocity() const;
|
||||||
|
// return the squared modulus of the particle velocity in (m/s)^2
|
||||||
double absoluteVelocitySquared() const;
|
double absoluteVelocitySquared() const;
|
||||||
|
|
||||||
|
// return the mass of the particle in kg (i.e. the mass of the particles specie)
|
||||||
double mass_kg() const;
|
double mass_kg() const;
|
||||||
|
// return the charge of the particle in C (i.e. the charge of the particles specie)
|
||||||
double charge_C() const;
|
double charge_C() const;
|
||||||
|
|
||||||
|
// get a raw pointer to the TrackedSpecie object of the particle
|
||||||
species::TrackedSpecie* specie() const;
|
species::TrackedSpecie* specie() const;
|
||||||
|
|
||||||
|
// set the static variable (only local to the mpi process) from which
|
||||||
|
// the particle ids are generated
|
||||||
static void lastId(long int id);
|
static void lastId(long int id);
|
||||||
static long int lastId(); // only local on this cpu
|
// get the static variable (only local to the mpi process) from which
|
||||||
|
// the particle ids are generated
|
||||||
|
static long int lastId();
|
||||||
|
|
||||||
|
// increase member variable that counts the number of interactions performed
|
||||||
|
// by the particle by 1
|
||||||
void increaseInteractionCounter();
|
void increaseInteractionCounter();
|
||||||
|
// return the value of the number of interactions performed by the particle
|
||||||
long int interactionCounter() const;
|
long int interactionCounter() const;
|
||||||
|
|
||||||
|
// increase member variable counting the total time (in s) that the
|
||||||
|
// particle has been alive
|
||||||
void increaseTimeAlive(double time_s);
|
void increaseTimeAlive(double time_s);
|
||||||
|
// return the time the particle has been alive (in s)
|
||||||
double timeAlive() const;
|
double timeAlive() const;
|
||||||
|
|
||||||
|
// increase member variable counting the time the particle has bin alive
|
||||||
|
// without chaingin any bin (i.e. spatial or energy) by the given time (in s).
|
||||||
|
// equivalent to the time the particle has spent in its current bin
|
||||||
void increaseTimeInBin(double time_s);
|
void increaseTimeInBin(double time_s);
|
||||||
|
// reset the time in bin variable (i.e. set to 0)
|
||||||
void resetTimeInBin();
|
void resetTimeInBin();
|
||||||
|
// return the time the particle has not changed any bin
|
||||||
double timeInBin() const;
|
double timeInBin() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CartesianVector velocity_;
|
CartesianVector velocity_;
|
||||||
CartesianCoordinate position_;
|
CartesianCoordinate position_;
|
||||||
|
CylinderCoordinate position_cyl_;
|
||||||
|
|
||||||
double time_alive_s_;
|
double time_alive_s_;
|
||||||
double time_in_bin_s_;
|
double time_in_bin_s_;
|
||||||
|
|||||||
@@ -4,15 +4,25 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include "blitz/array.h"
|
#include "blitz/array.h"
|
||||||
|
|
||||||
|
// class for a linear binning without under- or overflow bins
|
||||||
class LowerAndUpperBoundBinning {
|
class LowerAndUpperBoundBinning {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: create binning with num_bins bins and
|
||||||
|
// an upper boundary of maximum (the lower boundary is always chosen as 0)
|
||||||
|
// the spacing between bins is always linear
|
||||||
LowerAndUpperBoundBinning(int num_bins, double maximum);
|
LowerAndUpperBoundBinning(int num_bins, double maximum);
|
||||||
|
|
||||||
|
// return the bin index, that includes the value position
|
||||||
int bin(double position) const;
|
int bin(double position) const;
|
||||||
|
// return the spacing between the bin borders
|
||||||
double stepsize() const;
|
double stepsize() const;
|
||||||
|
// getter for the number of bins
|
||||||
int numBins() const;
|
int numBins() const;
|
||||||
|
// returns the index for the first bin (0)
|
||||||
int binIndexMin() const;
|
int binIndexMin() const;
|
||||||
|
// returns the index for the last bin (num_bins - 1)
|
||||||
int binIndexMax() const;
|
int binIndexMax() const;
|
||||||
|
// return a vector containing the edges of the bins
|
||||||
std::vector<double> binBorders() const;
|
std::vector<double> binBorders() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -20,17 +30,27 @@ class LowerAndUpperBoundBinning {
|
|||||||
double stepsize_;
|
double stepsize_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class for a linear binning with an overflow but no underflow bin
|
||||||
class LowerBoundBinningWithOverflow {
|
class LowerBoundBinningWithOverflow {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: creates a linear binning between 0 and maximum with num_bins_excluding_overflow
|
||||||
|
// (number of bins without the overflow bin)
|
||||||
LowerBoundBinningWithOverflow(int num_bins_excluding_overflow,
|
LowerBoundBinningWithOverflow(int num_bins_excluding_overflow,
|
||||||
double maximum);
|
double maximum);
|
||||||
|
|
||||||
|
// return the bin index, that includes the value position
|
||||||
int bin(double position) const;
|
int bin(double position) const;
|
||||||
|
// return the spacing between the bin borders
|
||||||
double stepsize() const;
|
double stepsize() const;
|
||||||
|
// returns the number of bins including the overflow bin
|
||||||
int numBinsWithOverflow() const;
|
int numBinsWithOverflow() const;
|
||||||
|
// returns the number of bins excluding the overflow bin
|
||||||
int numBinsWithoutOverflow() const;
|
int numBinsWithoutOverflow() const;
|
||||||
|
// returns the index for the first bin (0)
|
||||||
int binIndexMin() const;
|
int binIndexMin() const;
|
||||||
|
// returns the index for the last bin (i.e. the overflow bin)
|
||||||
int binIndexMax() const;
|
int binIndexMax() const;
|
||||||
|
// return the values of the borders of the bins (the overflow bin does not have an upper boundary)
|
||||||
std::vector<double> binBorders() const;
|
std::vector<double> binBorders() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -38,17 +58,28 @@ class LowerBoundBinningWithOverflow {
|
|||||||
double stepsize_;
|
double stepsize_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class for a linear binning with an under- and overflow bin
|
||||||
class BinningWithOverAndUnderflow {
|
class BinningWithOverAndUnderflow {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: creates a linear binning between 0 and maximum with num_bins_excluding_overflow
|
||||||
|
// (number of bins without the overflow and underflow bin)
|
||||||
BinningWithOverAndUnderflow(int num_bins_excluding_overunderflow,
|
BinningWithOverAndUnderflow(int num_bins_excluding_overunderflow,
|
||||||
double maximum);
|
double maximum);
|
||||||
|
|
||||||
|
// return the bin index, that includes the value position
|
||||||
int bin(double position) const;
|
int bin(double position) const;
|
||||||
|
// return the spacing between the bin borders
|
||||||
double stepsize() const;
|
double stepsize() const;
|
||||||
|
// returns the number of bins including both the overflow and underflow bin
|
||||||
int numBinsWithOverUnderflow() const;
|
int numBinsWithOverUnderflow() const;
|
||||||
|
// returns the number of bins excluding both the overflow and underflow bin
|
||||||
int numBinsWithoutOverUnderflow() const;
|
int numBinsWithoutOverUnderflow() const;
|
||||||
|
// returns the index for the first (underflow) bin (-1)
|
||||||
int binIndexMin() const;
|
int binIndexMin() const;
|
||||||
|
// returns the index for the last bin (i.e. the overflow bin)
|
||||||
int binIndexMax() const;
|
int binIndexMax() const;
|
||||||
|
// return the values of the borders of the bins (the overflow bin does not have an upper
|
||||||
|
// and the underflow bin does not have a lower boundary)
|
||||||
std::vector<double> binBorders() const;
|
std::vector<double> binBorders() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -56,23 +87,48 @@ class BinningWithOverAndUnderflow {
|
|||||||
double stepsize_;
|
double stepsize_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class for handling the segmentation of a cylindrical domain
|
||||||
class CylinderBinning {
|
class CylinderBinning {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: takes the number of bins for the radial direction,
|
||||||
|
// the radius of the cylinder,
|
||||||
|
// the number of bins in azimuthal direction,
|
||||||
|
// the number of bins in longitudinal (i.e. z) direction,
|
||||||
|
// the height of the cylinder
|
||||||
|
// creates a LowerBoundBinninigWithOverflow for the radial direction (no boundary at r=0),
|
||||||
|
// a LowerAndUpperBoundBinning for the azimuthal direction (no boundary at all),
|
||||||
|
// and a BinningWithOverAndUnderflow in longitudinal direction
|
||||||
CylinderBinning(int num_bins_radial,
|
CylinderBinning(int num_bins_radial,
|
||||||
double radius,
|
double radius,
|
||||||
int num_bins_azimuthal,
|
int num_bins_azimuthal,
|
||||||
int num_bins_longitudinal,
|
int num_bins_longitudinal,
|
||||||
double height);
|
double height);
|
||||||
|
|
||||||
|
// return a blitz::TinyVector containing the indeces for each of the three binnings
|
||||||
|
// (bin_r, bin_azimuthal, bin_longitudinal), in which the blitz::TinyVector cylinder_position
|
||||||
|
// (containing (r, phi,z)) is contained in
|
||||||
blitz::TinyVector<int, 3> bin(
|
blitz::TinyVector<int, 3> bin(
|
||||||
const blitz::TinyVector<double, 3>& cylinder_position) const;
|
const blitz::TinyVector<double, 3>& cylinder_position) const;
|
||||||
|
// return a blitz::TinyVector with the spacings of the three binnings
|
||||||
|
// (spacing_radial, spacing_azimuthal, spacing_longitudinal)
|
||||||
blitz::TinyVector<double, 3> stepsize() const;
|
blitz::TinyVector<double, 3> stepsize() const;
|
||||||
|
|
||||||
|
// return a blitz::TinyVector with the number of bins of each binning (excludes all over- and underflow bins)
|
||||||
|
// (numBins_radial, numBins_azimuthal, numBins_longitudinal)
|
||||||
blitz::TinyVector<int, 3> numBins() const;
|
blitz::TinyVector<int, 3> numBins() const;
|
||||||
|
// return a blitz::TinyVector with the number of bins of each binning (includes all over- and underflow bins)
|
||||||
|
// (numBins_radial, numBins_azimuthal, numBins_longitudinal)
|
||||||
blitz::TinyVector<int, 3> numBinsIncludingOverUnderflow() const;
|
blitz::TinyVector<int, 3> numBinsIncludingOverUnderflow() const;
|
||||||
|
// return a blitz::TinyVector with the indices of the first bins of each binning
|
||||||
|
// (binIndexMin_radial, binIndexMin_azimuthal, binIndexMin_longitudinal)
|
||||||
|
// includes the underflow bin in longitudinal direction
|
||||||
blitz::TinyVector<int, 3> binIndexMin() const;
|
blitz::TinyVector<int, 3> binIndexMin() const;
|
||||||
|
// return a blitz::TinyVector with the indices of the last bins of each binning
|
||||||
|
// (binIndexMin_radial, binIndexMin_azimuthal, binIndexMin_longitudinal)
|
||||||
|
// includes the overflow bin in radial and longitudinal direction
|
||||||
blitz::TinyVector<int, 3> binIndexMax() const;
|
blitz::TinyVector<int, 3> binIndexMax() const;
|
||||||
|
|
||||||
|
// binnings for each of the three directions (radial, azimuthal, longitudinal)
|
||||||
const LowerBoundBinningWithOverflow radial_binning;
|
const LowerBoundBinningWithOverflow radial_binning;
|
||||||
const LowerAndUpperBoundBinning azimuth_binning;
|
const LowerAndUpperBoundBinning azimuth_binning;
|
||||||
const BinningWithOverAndUnderflow longitudinal_binning;
|
const BinningWithOverAndUnderflow longitudinal_binning;
|
||||||
|
|||||||
@@ -5,13 +5,18 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
||||||
|
// class to handle a random generator object
|
||||||
class RandomNumbers {
|
class RandomNumbers {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: takes the seed for the random engine
|
||||||
RandomNumbers(int seed);
|
RandomNumbers(int seed);
|
||||||
|
|
||||||
|
// draw a uniformly distributed integer number between min, max
|
||||||
int rollUniform(int min, int max);
|
int rollUniform(int min, int max);
|
||||||
|
// draw a uniformly distributed double number between min, max
|
||||||
double rollUniform(double min, double max);
|
double rollUniform(double min, double max);
|
||||||
|
|
||||||
|
// getter for the pointer to the mersenne twister 19937 engine
|
||||||
std::mt19937* engine();
|
std::mt19937* engine();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "simulation/particle.h"
|
#include "simulation/particle.h"
|
||||||
|
|
||||||
|
// class defining the minimum requirements of a Reflector class
|
||||||
class Reflector {
|
class Reflector {
|
||||||
public:
|
public:
|
||||||
virtual bool needsReflectionBackToDomain(
|
virtual bool needsReflectionBackToDomain(
|
||||||
@@ -10,18 +11,27 @@ class Reflector {
|
|||||||
virtual void reflectBackToDomain(particle::Particle* particle) const = 0;
|
virtual void reflectBackToDomain(particle::Particle* particle) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class for Reflectrion at the DPS section of KATRIN
|
||||||
|
// (i.e. reflection at the z=L end of the cylinder)
|
||||||
class ReflectorDPS : public Reflector {
|
class ReflectorDPS : public Reflector {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: takes the position in longitudinal direction where particles should
|
||||||
|
// be reflected at (reflects particles back to lower z values)
|
||||||
ReflectorDPS(double z_position_dps);
|
ReflectorDPS(double z_position_dps);
|
||||||
|
// check if Particle particle needs to be reflected
|
||||||
bool needsReflectionBackToDomain(const particle::Particle* particle) const;
|
bool needsReflectionBackToDomain(const particle::Particle* particle) const;
|
||||||
|
// perform the reflection of the particle back to the left
|
||||||
void reflectBackToDomain(particle::Particle* particle) const;
|
void reflectBackToDomain(particle::Particle* particle) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const double z_position_dps_;
|
const double z_position_dps_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class for particles that are not reflected anywhere
|
||||||
class NoReflector : public Reflector {
|
class NoReflector : public Reflector {
|
||||||
|
// always returns false
|
||||||
bool needsReflectionBackToDomain(const particle::Particle* particle) const;
|
bool needsReflectionBackToDomain(const particle::Particle* particle) const;
|
||||||
|
// does nothing
|
||||||
void reflectBackToDomain(particle::Particle* particle) const;
|
void reflectBackToDomain(particle::Particle* particle) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -6,15 +6,22 @@
|
|||||||
|
|
||||||
#include "simulation/coordinates.h"
|
#include "simulation/coordinates.h"
|
||||||
|
|
||||||
|
// class for a scalar field
|
||||||
class ScalarField {
|
class ScalarField {
|
||||||
public:
|
public:
|
||||||
|
// returns the value of the scalar field at the Coordinate coordinate
|
||||||
virtual double value(const Coordinate& coordinate) const = 0;
|
virtual double value(const Coordinate& coordinate) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class for a scalar field that has an arbitrary form in longitudinal direction
|
||||||
|
// and is constant in radial in azimuthal directoin
|
||||||
class ScalarFieldFunctionInZ : public ScalarField {
|
class ScalarFieldFunctionInZ : public ScalarField {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: gets the function F_z defining the form of the scalar field
|
||||||
|
// in longitudinal direction
|
||||||
ScalarFieldFunctionInZ(std::function<double(double, double, double)> F_z);
|
ScalarFieldFunctionInZ(std::function<double(double, double, double)> F_z);
|
||||||
|
|
||||||
|
// return the value of the scalar field at Coordinate coordinate
|
||||||
double value(const Coordinate& coordinate) const;
|
double value(const Coordinate& coordinate) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -9,23 +9,33 @@
|
|||||||
|
|
||||||
#include "simulation/energy_binning.h"
|
#include "simulation/energy_binning.h"
|
||||||
|
|
||||||
|
// class defining the minimum requirements of a scattering angle distribution
|
||||||
class ScatteringAngleDistribution {
|
class ScatteringAngleDistribution {
|
||||||
public:
|
public:
|
||||||
|
// draw a value for the scattering angle depending on the energy (in eV) and
|
||||||
|
// the random engine
|
||||||
virtual double roll(std::mt19937* engine, double energy_eV) = 0;
|
virtual double roll(std::mt19937* engine, double energy_eV) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class for an isotropic scattering angle distribution
|
||||||
class IsotropicAngleDistribution : public ScatteringAngleDistribution {
|
class IsotropicAngleDistribution : public ScatteringAngleDistribution {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: initializes a uniform distribution between (o,2pi)
|
||||||
IsotropicAngleDistribution();
|
IsotropicAngleDistribution();
|
||||||
|
// draw from a uniform distribution
|
||||||
double roll(std::mt19937* engine, double energy_eV = 0.);
|
double roll(std::mt19937* engine, double energy_eV = 0.);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::uniform_real_distribution<double> distribution_;
|
std::uniform_real_distribution<double> distribution_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class for drawing from a piecewise linear scattering angle distribution
|
||||||
class AngleDistributionFromFile : public ScatteringAngleDistribution {
|
class AngleDistributionFromFile : public ScatteringAngleDistribution {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: takes string containing the absolute path (including the file)
|
||||||
|
// that contains the data of the scattering angle distribution
|
||||||
AngleDistributionFromFile(std::string absolute_filepath);
|
AngleDistributionFromFile(std::string absolute_filepath);
|
||||||
|
// draw a value from the distribution
|
||||||
double roll(std::mt19937* engine, double energy_eV);
|
double roll(std::mt19937* engine, double energy_eV);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -33,12 +43,17 @@ class AngleDistributionFromFile : public ScatteringAngleDistribution {
|
|||||||
std::vector<std::piecewise_linear_distribution<double>> angle_distributions_;
|
std::vector<std::piecewise_linear_distribution<double>> angle_distributions_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class for a composition of two scattering angle distibutions
|
||||||
class CompositeAngleDistribution : public ScatteringAngleDistribution {
|
class CompositeAngleDistribution : public ScatteringAngleDistribution {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: takes two ScatteringAngleDistributions and a decider energy (eV)
|
||||||
|
// if energy_eV < decider energy use lower_distribution
|
||||||
|
// otherwise use the higher_distribution
|
||||||
CompositeAngleDistribution(
|
CompositeAngleDistribution(
|
||||||
std::shared_ptr<ScatteringAngleDistribution> lower_distribution,
|
std::shared_ptr<ScatteringAngleDistribution> lower_distribution,
|
||||||
std::shared_ptr<ScatteringAngleDistribution> higher_distribution,
|
std::shared_ptr<ScatteringAngleDistribution> higher_distribution,
|
||||||
double decider_energy);
|
double decider_energy);
|
||||||
|
// draw a value from the distribution
|
||||||
double roll(std::mt19937* engine, double energy_eV);
|
double roll(std::mt19937* engine, double energy_eV);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -8,42 +8,73 @@
|
|||||||
#include "simulation/parameter.h"
|
#include "simulation/parameter.h"
|
||||||
#include "simulation/particle.h"
|
#include "simulation/particle.h"
|
||||||
|
|
||||||
|
// defined in "simulation/random_numbers.h"
|
||||||
class RandomNumbers;
|
class RandomNumbers;
|
||||||
|
// defined in "simulation/interaction.h"
|
||||||
class InteractionOutput;
|
class InteractionOutput;
|
||||||
|
// defined in "simulation/electromagnetic_field.h"
|
||||||
class MagneticField;
|
class MagneticField;
|
||||||
class ElectricField;
|
class ElectricField;
|
||||||
|
// defined in "simulation/timer.h"
|
||||||
class Timer;
|
class Timer;
|
||||||
|
// defined in "simulation/injector.h"
|
||||||
class Injector;
|
class Injector;
|
||||||
|
// defined in "IO/simulation_output.h"
|
||||||
class SimulationOutput;
|
class SimulationOutput;
|
||||||
|
// defined in "simulation/cpu_synchronizer.h"
|
||||||
class CpuSynchronizer;
|
class CpuSynchronizer;
|
||||||
|
|
||||||
|
// defined in "simulation/species.h"
|
||||||
namespace species {
|
namespace species {
|
||||||
class Specie;
|
class Specie;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// defined in "simulation/interaction.h"
|
||||||
namespace interaction {
|
namespace interaction {
|
||||||
class InteractionOutput;
|
class InteractionOutput;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Simulation {
|
class Simulation {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: initialize everything using the json file at the path in parameter_filename
|
||||||
Simulation(std::string parameter_filename);
|
Simulation(std::string parameter_filename);
|
||||||
|
|
||||||
|
// function for initialization from Parameter object
|
||||||
void init(Parameter& parameter);
|
void init(Parameter& parameter);
|
||||||
|
// function for main simulation loop
|
||||||
void start();
|
void start();
|
||||||
|
// function to finalize simulation
|
||||||
void finalize();
|
void finalize();
|
||||||
|
// process events until "events" number of beta decay chains have been
|
||||||
|
// simulated until completion
|
||||||
void processEvents(int events);
|
void processEvents(int events);
|
||||||
|
// process the Particle particle until it is terminated
|
||||||
|
// any interaction product created during the interactions during the propagation of
|
||||||
|
// particle are appened to the vector particle_queue
|
||||||
void processUntilTermination(particle::Particle& particle,
|
void processUntilTermination(particle::Particle& particle,
|
||||||
std::vector<particle::Particle>& particle_queue);
|
std::vector<particle::Particle>& particle_queue);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// function to create particles from the injector (i.e. the event particles)
|
||||||
|
// also increases the time in the Timer object
|
||||||
std::vector<particle::Particle> determineInjectedParticles(
|
std::vector<particle::Particle> determineInjectedParticles(
|
||||||
RandomNumbers* random);
|
RandomNumbers* random);
|
||||||
|
|
||||||
double meanFreePath(particle::Particle& particle, RandomNumbers* random);
|
// calculate the mean free path for the Particle particle
|
||||||
|
// the calculated target density scaled cross sections are then
|
||||||
|
// appened to the vector macroscopic_cross_sections_m to be used
|
||||||
|
// later in the interact function (to avoid an unneccessary recalculation)
|
||||||
|
double meanFreePath(particle::Particle& particle, RandomNumbers* random,
|
||||||
|
std::vector<double>& macroscopic_cross_sections_m);
|
||||||
|
|
||||||
|
// randomly chooses the interaction the particle will experience by
|
||||||
|
// using the values in the macroscopic_cross_sections_m vector (does NOT have to be normalized)
|
||||||
|
// as the relative weight for the corresponding interaction to occur
|
||||||
|
// afterwards perform the interaction and return the
|
||||||
|
// output of the as an InteractionOutput object
|
||||||
interaction::InteractionOutput interact(particle::Particle& particle,
|
interaction::InteractionOutput interact(particle::Particle& particle,
|
||||||
RandomNumbers* random);
|
RandomNumbers* random,
|
||||||
|
std::vector<double>& macroscopic_cross_sections_m);
|
||||||
|
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>
|
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>
|
||||||
tracked_species_;
|
tracked_species_;
|
||||||
|
|||||||
@@ -7,51 +7,91 @@
|
|||||||
|
|
||||||
#include "simulation/parameter.h"
|
#include "simulation/parameter.h"
|
||||||
|
|
||||||
|
// defined in "simulation/mover.h"
|
||||||
class Mover;
|
class Mover;
|
||||||
|
// defined in "simulation/terminator.h"
|
||||||
class Terminator;
|
class Terminator;
|
||||||
|
// defined in "simulation/reflector.h"
|
||||||
class Reflector;
|
class Reflector;
|
||||||
|
// defined in "simulation/injector.h"
|
||||||
class Injector;
|
class Injector;
|
||||||
|
// defined in "simulation/density_field.h"
|
||||||
class DensityField;
|
class DensityField;
|
||||||
class DynamicDensityField;
|
class DynamicDensityField;
|
||||||
class ConstantDensityField;
|
class ConstantDensityField;
|
||||||
|
// defined in "simulation/logger.h"
|
||||||
class DeletionLogger;
|
class DeletionLogger;
|
||||||
|
// defined in "simulation/current_collector.h"
|
||||||
class CurrentCollector;
|
class CurrentCollector;
|
||||||
|
// defined in "simulation/velocity_distribution.h"
|
||||||
class VelocityDistribution;
|
class VelocityDistribution;
|
||||||
|
// defined in "simulation/drift_velocity.h"
|
||||||
class DriftVelocity;
|
class DriftVelocity;
|
||||||
|
|
||||||
|
// defined in "simulation/interaction.h"
|
||||||
namespace interaction {
|
namespace interaction {
|
||||||
class Interaction;
|
class Interaction;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace species {
|
namespace species {
|
||||||
|
|
||||||
|
// enum that lists all implemented specie types (Tritium molecule T2, electron,
|
||||||
|
// Tritium ion T+, Tritium molecule ion T2+ and Trtitium cluster ion T3+)
|
||||||
enum class ImplementedSpecies { T2, electron, Tplus, T2plus, T3plus };
|
enum class ImplementedSpecies { T2, electron, Tplus, T2plus, T3plus };
|
||||||
|
|
||||||
|
// general specie, defining the minimum requirements for all other specie classes
|
||||||
class Specie {
|
class Specie {
|
||||||
public:
|
public:
|
||||||
|
// Constructor, taking one of the implemented speices in the ImplementedSpecies enum,
|
||||||
|
// an arbitrary string defining the name of the species (e.g. if multiple electron species
|
||||||
|
// are required), the mass of the particle type in kg and it's charge in Coulomb
|
||||||
Specie(ImplementedSpecies type,
|
Specie(ImplementedSpecies type,
|
||||||
std::string name,
|
std::string name,
|
||||||
double mass_kg,
|
double mass_kg,
|
||||||
double charge_C);
|
double charge_C);
|
||||||
|
|
||||||
|
// getter for the mass of the species (in kg)
|
||||||
double mass_kg() const;
|
double mass_kg() const;
|
||||||
|
// getter for the charge of the species (in Coulomb)
|
||||||
double charge_C() const;
|
double charge_C() const;
|
||||||
|
// getter for the type of the species (ImplementedSpecies enum)
|
||||||
ImplementedSpecies type() const;
|
ImplementedSpecies type() const;
|
||||||
|
// getter for the name of the species
|
||||||
std::string name() const;
|
std::string name() const;
|
||||||
|
|
||||||
|
// getter for the DensityField pointer
|
||||||
virtual DensityField* densityField() = 0;
|
virtual DensityField* densityField() = 0;
|
||||||
|
// getter for the VelocityDistribution pointer
|
||||||
virtual VelocityDistribution* velocityDistibution() = 0;
|
virtual VelocityDistribution* velocityDistibution() = 0;
|
||||||
|
// getter for the DriftVelocity pointer
|
||||||
virtual DriftVelocity* driftVelocity() = 0;
|
virtual DriftVelocity* driftVelocity() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
// mass of species in kg
|
||||||
const double mass_kg_;
|
const double mass_kg_;
|
||||||
|
// charge of species in C
|
||||||
const double charge_C_;
|
const double charge_C_;
|
||||||
|
// type of species defined by ImplementedSpecies enum
|
||||||
const ImplementedSpecies type_;
|
const ImplementedSpecies type_;
|
||||||
|
// arbitrary name of the species
|
||||||
const std::string name_;
|
const std::string name_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class for particle species that are simulated
|
||||||
class TrackedSpecie : public Specie {
|
class TrackedSpecie : public Specie {
|
||||||
public:
|
public:
|
||||||
|
// Constructor; takes an ImplemetedSpecies enum to define the type of the species,
|
||||||
|
// an arbitrary string to name the species,
|
||||||
|
// the mass of the particles of the species in kg,
|
||||||
|
// the charge of the particles of the species in C,
|
||||||
|
// a shared_ptr of a Mover object (defines the propagation algorithm),
|
||||||
|
// a shared_ptr of a Terminator object (defines when a particle is deleted),
|
||||||
|
// a shared_ptr of a Reflector object (defines if, where and how a particle of the specie is reflected),
|
||||||
|
// a shared_ptr of a DynamicDensityField object (collects the density of the species),
|
||||||
|
// a shared_ptr of a DriftVelocity object (can be a nullptr but only if no interactions between simulated species are present),
|
||||||
|
// a shared_ptr of a second DynamicDensityField object (essentially a copy of the first DynamicDensityField; necessary for cpu-synchronization)
|
||||||
|
// the deletion logger and the current collector (as well as their synchronization equivalents) are initialized
|
||||||
|
// with a null pointer
|
||||||
TrackedSpecie(ImplementedSpecies type,
|
TrackedSpecie(ImplementedSpecies type,
|
||||||
std::string name,
|
std::string name,
|
||||||
double mass_kg,
|
double mass_kg,
|
||||||
@@ -61,24 +101,53 @@ class TrackedSpecie : public Specie {
|
|||||||
std::shared_ptr<Reflector> reflector,
|
std::shared_ptr<Reflector> reflector,
|
||||||
std::shared_ptr<DynamicDensityField> density_field,
|
std::shared_ptr<DynamicDensityField> density_field,
|
||||||
std::shared_ptr<VelocityDistribution> velocity_distribution,
|
std::shared_ptr<VelocityDistribution> velocity_distribution,
|
||||||
std::shared_ptr<DriftVelocity> drift_velocity);
|
std::shared_ptr<DriftVelocity> drift_velocity,
|
||||||
|
std::shared_ptr<DynamicDensityField> last_sync_density_field);
|
||||||
|
|
||||||
|
// getter for a raw pointer to the DynamicDensityField member as its parent class DensityField
|
||||||
DensityField* densityField();
|
DensityField* densityField();
|
||||||
|
// getter for a raw pointer to the VelocityDistribution member
|
||||||
VelocityDistribution* velocityDistibution();
|
VelocityDistribution* velocityDistibution();
|
||||||
|
// getter for a raw pointer to the driftVelocity member
|
||||||
DriftVelocity* driftVelocity();
|
DriftVelocity* driftVelocity();
|
||||||
|
|
||||||
|
// getter for a raw pointer to the DynamicDensityField member
|
||||||
DynamicDensityField* dynamicDensityField();
|
DynamicDensityField* dynamicDensityField();
|
||||||
|
// getter for a raw pointer to the DynamicDensityField member used for the synchronization between processes
|
||||||
|
DynamicDensityField* lastSyncDensityField();
|
||||||
|
// getter for a raw pointer to the Mover member
|
||||||
Mover* mover();
|
Mover* mover();
|
||||||
|
// getter for a raw pointer to the Terminator member
|
||||||
Terminator* terminator();
|
Terminator* terminator();
|
||||||
|
// getter for a raw pointer to the Reflector member
|
||||||
Reflector* reflector();
|
Reflector* reflector();
|
||||||
|
// getter for a raw pointer to the DeletionLogger member
|
||||||
DeletionLogger* deletionLogger();
|
DeletionLogger* deletionLogger();
|
||||||
|
|
||||||
|
// setter for the DeletionLogger member
|
||||||
void deletionLogger(std::shared_ptr<DeletionLogger> new_logger);
|
void deletionLogger(std::shared_ptr<DeletionLogger> new_logger);
|
||||||
|
|
||||||
|
// getter for a raw pointer to the DeletionLogger member used for cpu-synchronization
|
||||||
|
DeletionLogger* lastSyncDeletionLogger();
|
||||||
|
// setter for the DeletionLogger member used for cpu-synchronization
|
||||||
|
void lastSyncDeletionLogger(std::shared_ptr<DeletionLogger> new_logger);
|
||||||
|
|
||||||
|
// getter for a raw pointer to the CurrentCollector member
|
||||||
CurrentCollector* currentCollector();
|
CurrentCollector* currentCollector();
|
||||||
|
// setter for the CurrentCollector member
|
||||||
void currentCollector(std::shared_ptr<CurrentCollector> new_collector);
|
void currentCollector(std::shared_ptr<CurrentCollector> new_collector);
|
||||||
|
|
||||||
|
// getter for a raw pointer to the CurrentCollector member used for cpu-synchronization
|
||||||
|
CurrentCollector* lastSyncCurrentCollector();
|
||||||
|
// setter for the CurrentCollector member used for cpu-synchronization
|
||||||
|
void lastSyncCurrentCollector(
|
||||||
|
std::shared_ptr<CurrentCollector> new_collector);
|
||||||
|
|
||||||
|
// vector of shared_ptr to Interaction objects, defines the different types
|
||||||
|
// of interactions that the specie can take part in
|
||||||
std::vector<std::shared_ptr<interaction::Interaction>> interactions();
|
std::vector<std::shared_ptr<interaction::Interaction>> interactions();
|
||||||
|
// adds the shared_ptr of the Interaction object "interaction" to the vector
|
||||||
|
// of possible interactions
|
||||||
void addInteraction(std::shared_ptr<interaction::Interaction> interaction);
|
void addInteraction(std::shared_ptr<interaction::Interaction> interaction);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -90,13 +159,29 @@ class TrackedSpecie : public Specie {
|
|||||||
std::shared_ptr<Terminator> terminator_;
|
std::shared_ptr<Terminator> terminator_;
|
||||||
std::shared_ptr<Reflector> reflector_;
|
std::shared_ptr<Reflector> reflector_;
|
||||||
|
|
||||||
|
// object to keep track of how particles of the specie are removed from the simulation
|
||||||
std::shared_ptr<DeletionLogger> deletion_logger_;
|
std::shared_ptr<DeletionLogger> deletion_logger_;
|
||||||
std::shared_ptr<CurrentCollector> current_collector_;
|
std::shared_ptr<CurrentCollector> current_collector_;
|
||||||
std::vector<std::shared_ptr<interaction::Interaction>> interactions_;
|
std::vector<std::shared_ptr<interaction::Interaction>> interactions_;
|
||||||
|
|
||||||
|
// fields to store the data of the last synchronization
|
||||||
|
// (immediately after a synchronization the last_sync field and the non-last_sync field
|
||||||
|
// contain the same data)
|
||||||
|
std::shared_ptr<DynamicDensityField> last_sync_density_field_;
|
||||||
|
std::shared_ptr<DeletionLogger> last_sync_deletion_logger_;
|
||||||
|
std::shared_ptr<CurrentCollector> last_sync_current_collector_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class for particle types that are not simulated
|
||||||
class BackgroundSpecie : public Specie {
|
class BackgroundSpecie : public Specie {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: takes the type of the species as one of the implemented species defined in the ImplementedSpecies enum,
|
||||||
|
// an arbirtary name for the species,
|
||||||
|
// the mass of the particles of the species in kg,
|
||||||
|
// the charge of the particles of the species in C,
|
||||||
|
// a shared_ptr to a ConstantDensityField object,
|
||||||
|
// a shared_ptr to a VelocityDistribution object (defines the velocity distribution of the particles realtive to their drift veloctiy)
|
||||||
|
// a shared_ptr to a DriftVelocity object (defines the drift velocity of the particles)
|
||||||
BackgroundSpecie(ImplementedSpecies type,
|
BackgroundSpecie(ImplementedSpecies type,
|
||||||
std::string name,
|
std::string name,
|
||||||
double mass_kg,
|
double mass_kg,
|
||||||
@@ -105,8 +190,11 @@ class BackgroundSpecie : public Specie {
|
|||||||
std::shared_ptr<VelocityDistribution> velocity_distribution,
|
std::shared_ptr<VelocityDistribution> velocity_distribution,
|
||||||
std::shared_ptr<DriftVelocity> drift_velocity);
|
std::shared_ptr<DriftVelocity> drift_velocity);
|
||||||
|
|
||||||
|
// getter for a raw pointer to the ConstantDensityField member as its parent type
|
||||||
DensityField* densityField();
|
DensityField* densityField();
|
||||||
|
// getter for a raw pointer to the VelocityDistribution member
|
||||||
VelocityDistribution* velocityDistibution();
|
VelocityDistribution* velocityDistibution();
|
||||||
|
// getter for a raw pointer to the driftVelocity member
|
||||||
DriftVelocity* driftVelocity();
|
DriftVelocity* driftVelocity();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -3,18 +3,31 @@
|
|||||||
|
|
||||||
#include "simulation/particle.h"
|
#include "simulation/particle.h"
|
||||||
|
|
||||||
|
// defined in "simulation/geometry.h"
|
||||||
class Geometry;
|
class Geometry;
|
||||||
|
|
||||||
|
// class for checking if a paricle has to be terminated due to
|
||||||
|
// any reason except interaction effects
|
||||||
class Terminator {
|
class Terminator {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: takes the maximum number of interactions a particle is allowed to perform
|
||||||
|
// the maximum amount of time a paticle is allowed to live
|
||||||
|
// a Geometry object defining the boundaries of the volume particles are allowed to exist in
|
||||||
Terminator(long int max_interactions,
|
Terminator(long int max_interactions,
|
||||||
double max_time_alive,
|
double max_time_alive,
|
||||||
std::shared_ptr<Geometry> geometry);
|
std::shared_ptr<Geometry> geometry);
|
||||||
|
|
||||||
|
// check if particle has not reached the maximum interaction count, the maximal time its allowed to live
|
||||||
|
// and that it has not reached a geometry boundary
|
||||||
bool isAlive(const particle::Particle* particle) const;
|
bool isAlive(const particle::Particle* particle) const;
|
||||||
|
// check if particle has crossed any boundary of the Geometry
|
||||||
bool leftSimulationDomain(const particle::Particle* particle) const;
|
bool leftSimulationDomain(const particle::Particle* particle) const;
|
||||||
|
// check if particle has reached the maximum interaction count
|
||||||
bool reachedMaxInteractions(const particle::Particle* particle) const;
|
bool reachedMaxInteractions(const particle::Particle* particle) const;
|
||||||
|
// check if the particle has reached its maximum lifetime
|
||||||
bool reachedMaxTimeAlive(const particle::Particle* particle) const;
|
bool reachedMaxTimeAlive(const particle::Particle* particle) const;
|
||||||
|
// return the maximum lifetime
|
||||||
|
double maxTimeAlive() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const long int max_interactions_;
|
const long int max_interactions_;
|
||||||
|
|||||||
@@ -3,12 +3,17 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
// class to keep track of the "simulation time" (i.e. number of processed events * Activity)
|
||||||
class Timer {
|
class Timer {
|
||||||
public:
|
public:
|
||||||
|
// Constructor; initializes time to 0
|
||||||
Timer();
|
Timer();
|
||||||
|
|
||||||
|
// getter for the time
|
||||||
double time() const;
|
double time() const;
|
||||||
|
// increase the time by time_s (time in s)
|
||||||
void increaseTimestep(double time_s);
|
void increaseTimestep(double time_s);
|
||||||
|
// set time to time_s
|
||||||
void setTime(double time_s);
|
void setTime(double time_s);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
|
// return a function calculating the fermi distribution with the given prefactor
|
||||||
std::function<double(double)> tritiumDecayEnergySpectrum(double prefactor);
|
std::function<double(double)> tritiumDecayEnergySpectrum(double prefactor);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,15 +5,26 @@
|
|||||||
|
|
||||||
namespace unitConvertion {
|
namespace unitConvertion {
|
||||||
|
|
||||||
|
// transforms the value from current lenght unit "unit_from" to "unit_to"
|
||||||
|
// possible values for both "unit_from" and "unit_to": "mm", "cm", "m" otherwise
|
||||||
|
// an error is thrown and the program terminates
|
||||||
double length(double value,
|
double length(double value,
|
||||||
const std::string& unit_from,
|
const std::string& unit_from,
|
||||||
const std::string& unit_to);
|
const std::string& unit_to);
|
||||||
|
|
||||||
|
// returns the value of unit/meter, supports "mm", "cm", "m" for any other value
|
||||||
|
// an error is thrown and the program terminates
|
||||||
double lengthPrefactor(const std::string& unit);
|
double lengthPrefactor(const std::string& unit);
|
||||||
|
|
||||||
|
// transforms the value from current energy unit "unit_from" to "unit_to"
|
||||||
|
// possible values for both "unit_from" and "unit_to": "eV", "J" otherwise
|
||||||
|
// an error is thrown and the program terminates
|
||||||
double energy(double value,
|
double energy(double value,
|
||||||
const std::string& unit_from,
|
const std::string& unit_from,
|
||||||
const std::string& unit_to);
|
const std::string& unit_to);
|
||||||
|
|
||||||
|
// returns the value of unit/eV, supports "eV", "J" for any other value
|
||||||
|
// an error is thrown and the program terminates
|
||||||
double energyPrefactor(const std::string& unit);
|
double energyPrefactor(const std::string& unit);
|
||||||
|
|
||||||
}; // namespace unitConvertion
|
}; // namespace unitConvertion
|
||||||
|
|||||||
@@ -7,43 +7,61 @@
|
|||||||
#include "simulation/coordinates.h"
|
#include "simulation/coordinates.h"
|
||||||
#include "simulation/position_binning.h"
|
#include "simulation/position_binning.h"
|
||||||
|
|
||||||
|
// class for vector fields
|
||||||
class VectorField {
|
class VectorField {
|
||||||
public:
|
public:
|
||||||
|
// return the value of the vector field at the Coordinate coordinate as a
|
||||||
|
// CylinderVector object
|
||||||
virtual CylinderVector value(const Coordinate& coordinate) const = 0;
|
virtual CylinderVector value(const Coordinate& coordinate) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class for vector fields that are defined by an array (e.g. from data that was used as input)
|
||||||
class VectorFieldFromArray : public VectorField {
|
class VectorFieldFromArray : public VectorField {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: takes the radial, azimuthal and longitudinal component of the vector field
|
||||||
|
// as 3d arrays; all three arrays have to have the same size (not checked)
|
||||||
|
// also takes the radius and length of the domain, where the vector field is defined
|
||||||
VectorFieldFromArray(const blitz::Array<double, 3>& radial_component,
|
VectorFieldFromArray(const blitz::Array<double, 3>& radial_component,
|
||||||
const blitz::Array<double, 3>& azimuthal_component,
|
const blitz::Array<double, 3>& azimuthal_component,
|
||||||
const blitz::Array<double, 3>& longitudial_component,
|
const blitz::Array<double, 3>& longitudial_component,
|
||||||
double radius,
|
double radius,
|
||||||
double length);
|
double length);
|
||||||
|
|
||||||
|
// return the value at the Coordinate coordinate, if the coordinate does not fall into
|
||||||
|
// the region where the vector field is defined in return (0,0,0)
|
||||||
CylinderVector value(const Coordinate& coordinate) const;
|
CylinderVector value(const Coordinate& coordinate) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// todo: make sure we use fast axis on z to reduce acess time
|
|
||||||
const blitz::Array<double, 3> Fr_;
|
const blitz::Array<double, 3> Fr_;
|
||||||
const blitz::Array<double, 3> Fphi_;
|
const blitz::Array<double, 3> Fphi_;
|
||||||
const blitz::Array<double, 3> Fz_;
|
const blitz::Array<double, 3> Fz_;
|
||||||
|
|
||||||
|
// used to determine which array element is neccessary in the value() function
|
||||||
CylinderBinning binning_;
|
CylinderBinning binning_;
|
||||||
CylinderVector value(const blitz::TinyVector<int, 3>& bin) const;
|
CylinderVector value(const blitz::TinyVector<int, 3>& bin) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// class for spatially constant vector fields
|
||||||
class VectorFieldConstant : public VectorField {
|
class VectorFieldConstant : public VectorField {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: takes the value of the constant cylinder vector for the vector field
|
||||||
VectorFieldConstant(const CylinderVector& constant);
|
VectorFieldConstant(const CylinderVector& constant);
|
||||||
|
// return the value of the vector field at the Coordinate coordinate as a CylinderVector
|
||||||
CylinderVector value(const Coordinate& coordinate) const;
|
CylinderVector value(const Coordinate& coordinate) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const CylinderVector constant_;
|
const CylinderVector constant_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class for a vector field that has a z-dependence that can be described by an
|
||||||
|
// analytic function and is 0 for the radial and azimuthal component
|
||||||
class VectorFieldFunctionInZ : public VectorField {
|
class VectorFieldFunctionInZ : public VectorField {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: takes a function that describes the value of the longitudinal
|
||||||
|
// component as a function of r,phi,z
|
||||||
VectorFieldFunctionInZ(std::function<double(double, double, double)> v_z);
|
VectorFieldFunctionInZ(std::function<double(double, double, double)> v_z);
|
||||||
|
// return the value of the vector field at the Coordinate coordinate as a CylinderVector
|
||||||
CylinderVector value(const Coordinate& coordinate) const;
|
CylinderVector value(const Coordinate& coordinate) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -5,19 +5,30 @@
|
|||||||
#include <random>
|
#include <random>
|
||||||
#include "simulation/coordinates.h"
|
#include "simulation/coordinates.h"
|
||||||
|
|
||||||
|
// defined in "velocity_distribution_function.h"
|
||||||
class VelocityDistributionFunction;
|
class VelocityDistributionFunction;
|
||||||
|
|
||||||
|
// class to define the minimum requirements of a velocity distribution function
|
||||||
|
// (in the frame center of mass frame)
|
||||||
class VelocityDistribution {
|
class VelocityDistribution {
|
||||||
public:
|
public:
|
||||||
|
// draw a randomly oriented Cartesian velocity vector at the Coordinate position
|
||||||
|
// using the random engine
|
||||||
virtual CartesianVector rollVelocity(const Coordinate& position,
|
virtual CartesianVector rollVelocity(const Coordinate& position,
|
||||||
std::mt19937* engine) = 0;
|
std::mt19937* engine) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class that defines a velocity distribution by the usage of a VelocityDistributionFunction
|
||||||
|
// object
|
||||||
class VelocityDistributionFromFunction : public VelocityDistribution {
|
class VelocityDistributionFromFunction : public VelocityDistribution {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: takes a shared_ptr to the VelocityDistributionFunction, that defines the
|
||||||
|
// distribution to be drawn from
|
||||||
VelocityDistributionFromFunction(
|
VelocityDistributionFromFunction(
|
||||||
std::shared_ptr<VelocityDistributionFunction> fv);
|
std::shared_ptr<VelocityDistributionFunction> fv);
|
||||||
|
|
||||||
|
// returns a radnomly oriented CartesianVector drawn from the VelocityDistribution
|
||||||
|
// given at creation of the object
|
||||||
CartesianVector rollVelocity(const Coordinate& position,
|
CartesianVector rollVelocity(const Coordinate& position,
|
||||||
std::mt19937* engine);
|
std::mt19937* engine);
|
||||||
|
|
||||||
@@ -25,22 +36,4 @@ class VelocityDistributionFromFunction : public VelocityDistribution {
|
|||||||
std::shared_ptr<VelocityDistributionFunction> fv_;
|
std::shared_ptr<VelocityDistributionFunction> fv_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
todo: implement this for direct interactions of simulated particles
|
|
||||||
|
|
||||||
class DensityField;
|
|
||||||
|
|
||||||
class VelocityDistributionFromDensityField : public VelocityDistribution {
|
|
||||||
public:
|
|
||||||
VelocityDistributionFromDensityField(
|
|
||||||
std::shared_ptr<DensityField> density_field);
|
|
||||||
CartesianVector driftVelocity_ms(const CylinderVector& position);
|
|
||||||
CartesianVector rollVelocity_ms(
|
|
||||||
const CylinderVector& position, std::mt19937* engine);
|
|
||||||
private:
|
|
||||||
std::shared_ptr<DensityField> density_field_;
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif /* VELOCITY_DISTRIBUTION_H */
|
#endif /* VELOCITY_DISTRIBUTION_H */
|
||||||
|
|||||||
@@ -6,17 +6,27 @@
|
|||||||
|
|
||||||
#include "simulation/coordinates.h"
|
#include "simulation/coordinates.h"
|
||||||
|
|
||||||
|
// defined in "simulation/energy_distribution.h"
|
||||||
class EnergyDistributionFunction;
|
class EnergyDistributionFunction;
|
||||||
|
|
||||||
|
// class to define minimum requirements for a VelocityDistributionFunction child class
|
||||||
class VelocityDistributionFunction {
|
class VelocityDistributionFunction {
|
||||||
public:
|
public:
|
||||||
virtual CartesianVector rollVelocity(std::mt19937* engine) = 0;
|
virtual CartesianVector rollVelocity(std::mt19937* engine) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class for a velocity distribution, that has a isotropically distributed
|
||||||
|
// direction of the velocity vector and an modulus that is inferred from
|
||||||
|
// an energy distribution
|
||||||
class IsotropicDistribution : public VelocityDistributionFunction {
|
class IsotropicDistribution : public VelocityDistributionFunction {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: takes a shared_ptr to an EnergyDistributionFunction that describes
|
||||||
|
// the distribution of the energy and the mass of the particle
|
||||||
|
// to transform the drawn energy to the corresponding velocity
|
||||||
IsotropicDistribution(std::shared_ptr<EnergyDistributionFunction> f_E,
|
IsotropicDistribution(std::shared_ptr<EnergyDistributionFunction> f_E,
|
||||||
double mass_kg);
|
double mass_kg);
|
||||||
|
// draw an isotropically directed velocity vector with a modulus determined by the
|
||||||
|
// EnergyDistributionFunction given at construction of the object
|
||||||
CartesianVector rollVelocity(std::mt19937* engine);
|
CartesianVector rollVelocity(std::mt19937* engine);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -24,11 +34,19 @@ class IsotropicDistribution : public VelocityDistributionFunction {
|
|||||||
const double mass_kg_;
|
const double mass_kg_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class for a velocity distribution, that has a fixed direction of the velocity vector
|
||||||
|
// and an modulus that is inferred from an energy distribution
|
||||||
class DirectedDistribution : public VelocityDistributionFunction {
|
class DirectedDistribution : public VelocityDistributionFunction {
|
||||||
public:
|
public:
|
||||||
|
// Constructor: takes a shared_ptr to an EnergyDistributionFunction that describes
|
||||||
|
// the distribution of the energy and the mass of the particle
|
||||||
|
// to transform the drawn energy to the corresponding velocity
|
||||||
|
// and the direction of the velocity vector
|
||||||
DirectedDistribution(std::shared_ptr<EnergyDistributionFunction> f_E,
|
DirectedDistribution(std::shared_ptr<EnergyDistributionFunction> f_E,
|
||||||
double mass_kg,
|
double mass_kg,
|
||||||
const CartesianVector& direction);
|
const CartesianVector& direction);
|
||||||
|
// draw a directed velocity vector with a modulus determined by the
|
||||||
|
// EnergyDistributionFunction given at construction of the object
|
||||||
CartesianVector rollVelocity(std::mt19937* engine);
|
CartesianVector rollVelocity(std::mt19937* engine);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -5,19 +5,30 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
// structure to measure a timing (stores begin and endpoint and the corresponding timespan)
|
||||||
struct TimerEvent {
|
struct TimerEvent {
|
||||||
std::chrono::time_point<std::chrono::high_resolution_clock> start;
|
std::chrono::time_point<std::chrono::high_resolution_clock> start;
|
||||||
std::chrono::time_point<std::chrono::high_resolution_clock> stop;
|
std::chrono::time_point<std::chrono::high_resolution_clock> stop;
|
||||||
std::chrono::duration<double, std::nano> total_timespan;
|
std::chrono::duration<double, std::nano> total_timespan;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// class to time between a start and endpoint if the code has been compiled with
|
||||||
|
// USE_TIMER = true, otherwise does nothing
|
||||||
class SimulationTimer {
|
class SimulationTimer {
|
||||||
public:
|
public:
|
||||||
|
// if first invocation of eventStartPoint with a specific event_name, adds a
|
||||||
|
// TimerEvent at the time it was called; otherwise sets the value to
|
||||||
|
// the time it has been invoked
|
||||||
static void eventStartPoint(std::string event_name);
|
static void eventStartPoint(std::string event_name);
|
||||||
|
// sets the endpoint in the TimerEvent struct to the time the function was called
|
||||||
|
// the event_name has to match with an eventStartPoint invocation (not checked)
|
||||||
|
// calculates the timedifference
|
||||||
static void eventStopPoint(std::string event_name);
|
static void eventStopPoint(std::string event_name);
|
||||||
|
// print a formatted string containing all event_names and their respective timing to stdout
|
||||||
static void printDurations();
|
static void printDurations();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// map to store all event_names with their TimerEvent structs
|
||||||
static std::map<std::string, TimerEvent> timed_events_;
|
static std::map<std::string, TimerEvent> timed_events_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ dummy: all
|
|||||||
|
|
||||||
# Directories
|
# Directories
|
||||||
PROJECT_DIR = $(HOMEBASE)
|
PROJECT_DIR = $(HOMEBASE)
|
||||||
|
|
||||||
TEST_DIR = $(PROJECT_DIR)/test
|
|
||||||
CONFIG_DIR = $(PROJECT_DIR)/config
|
CONFIG_DIR = $(PROJECT_DIR)/config
|
||||||
BUILD_DIR = $(PROJECT_DIR)/build
|
BUILD_DIR = $(PROJECT_DIR)/build
|
||||||
BIN_DIR = $(PROJECT_DIR)/bin
|
BIN_DIR = $(PROJECT_DIR)/bin
|
||||||
@@ -47,20 +45,18 @@ LIBS += $(HDF5P_LIBRARIES)
|
|||||||
CXXFLAGS += $(JANSSON_INCLUDES)
|
CXXFLAGS += $(JANSSON_INCLUDES)
|
||||||
LIBS += $(JANSSON_LIBRARIES)
|
LIBS += $(JANSSON_LIBRARIES)
|
||||||
|
|
||||||
|
CXXFLAGS += -g
|
||||||
|
|
||||||
ifeq ($(DO_DEBUGGING),true)
|
ifeq ($(DO_DEBUGGING),true)
|
||||||
CXXFLAGS += -ftemplate-depth-30 -g -DBZ_DEBUG
|
CXXFLAGS += -ftemplate-depth-30 #-DBZ_DEBUG
|
||||||
CXXFLAGS += -Ddebug
|
CXXFLAGS += -Ddebug
|
||||||
CXXFLAGS += -Ddebug_level$(DEBUG_LEVEL)
|
CXXFLAGS += -Ddebug_level$(DEBUG_LEVEL)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Catch2
|
|
||||||
CXXFLAGS += $(CATCH_INCLUDES)
|
|
||||||
|
|
||||||
ifeq ($(USE_TIMER),true)
|
ifeq ($(USE_TIMER),true)
|
||||||
CXXFLAGS += -DTIMER
|
CXXFLAGS += -DTIMER
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CXXFLAGS_TEST = $(CXXFLAGS)
|
|
||||||
|
|
||||||
# Sources
|
# Sources
|
||||||
SRC_SUBDIRS = $(foreach sdir, $(SUB_DIRS), $(wildcard $(sdir)/*.cpp))
|
SRC_SUBDIRS = $(foreach sdir, $(SUB_DIRS), $(wildcard $(sdir)/*.cpp))
|
||||||
@@ -68,20 +64,16 @@ SRC_SUBDIRS = $(foreach sdir, $(SUB_DIRS), $(wildcard $(sdir)/*.cpp))
|
|||||||
SOURCES = $(SRC_DIR)/main.cpp
|
SOURCES = $(SRC_DIR)/main.cpp
|
||||||
SOURCES += $(SRC_SUBDIRS)
|
SOURCES += $(SRC_SUBDIRS)
|
||||||
|
|
||||||
SOURCES_TEST = $(wildcard $(TEST_DIR)/*.cpp) $(SRC_SUBDIRS)
|
|
||||||
|
|
||||||
# Objects
|
# Objects
|
||||||
OBJECTS=$(addprefix $(BUILD_DIR)/, $(notdir $(SOURCES:.cpp=.o)) )
|
OBJECTS=$(addprefix $(BUILD_DIR)/, $(notdir $(SOURCES:.cpp=.o)) )
|
||||||
OBJECTS_TEST=$(addprefix $(BUILD_DIR)/, $(notdir $(SOURCES_TEST:.cpp=.o)) )
|
|
||||||
|
|
||||||
# Target
|
# Target
|
||||||
# put the exe file in bin/
|
# put the exe file in bin/
|
||||||
TARGET=$(BIN_DIR)/karl
|
TARGET=$(BIN_DIR)/karl
|
||||||
TARGET_TEST=$(BIN_DIR)/karl_test
|
|
||||||
|
|
||||||
# Compile logic
|
# Compile logic
|
||||||
|
|
||||||
all: blitz hdf5 jansson karl
|
all: blitz jansson karl
|
||||||
|
|
||||||
check_homebase:
|
check_homebase:
|
||||||
ifeq ($(HOMEBASE),)
|
ifeq ($(HOMEBASE),)
|
||||||
@@ -99,12 +91,6 @@ endif
|
|||||||
blitz: check_homebase
|
blitz: check_homebase
|
||||||
ifeq ($(MAKE_BLITZ), true)
|
ifeq ($(MAKE_BLITZ), true)
|
||||||
$(MAKE) -C external/blitz
|
$(MAKE) -C external/blitz
|
||||||
$(MAKE) -C external/blitz install
|
|
||||||
endif
|
|
||||||
|
|
||||||
hdf5: check_homebase
|
|
||||||
ifeq ($(MAKE_H5), true)
|
|
||||||
$(MAKE) -C external/h5
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
jansson: check_homebase
|
jansson: check_homebase
|
||||||
@@ -112,9 +98,7 @@ ifeq ($(MAKE_JANSSON), true)
|
|||||||
$(MAKE) -C external/jansson
|
$(MAKE) -C external/jansson
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
karl: check_abspath check_homebase $(TARGET)
|
karl: check_abspath check_homebase $(TARGET)
|
||||||
test: check_abspath check_homebase $(TARGET_TEST)
|
|
||||||
|
|
||||||
$(TARGET): $(BUILD_DIR) $(BIN_DIR) $(OBJECTS)
|
$(TARGET): $(BUILD_DIR) $(BIN_DIR) $(OBJECTS)
|
||||||
$(CXX) $(OBJECTS) $(LIBS) -o $(TARGET)
|
$(CXX) $(OBJECTS) $(LIBS) -o $(TARGET)
|
||||||
@@ -122,12 +106,6 @@ $(TARGET): $(BUILD_DIR) $(BIN_DIR) $(OBJECTS)
|
|||||||
@echo "Linking done"
|
@echo "Linking done"
|
||||||
@echo
|
@echo
|
||||||
|
|
||||||
$(TARGET_TEST): $(BUILD_DIR) $(BIN_DIR) $(OBJECTS_TEST)
|
|
||||||
@echo "Start linking"
|
|
||||||
$(CXX) $(OBJECTS_TEST) $(LIBS) -o $(TARGET_TEST)
|
|
||||||
@echo
|
|
||||||
@echo "Linking done"
|
|
||||||
@echo
|
|
||||||
|
|
||||||
$(BIN_DIR):
|
$(BIN_DIR):
|
||||||
@mkdir -p $(BIN_DIR)
|
@mkdir -p $(BIN_DIR)
|
||||||
@@ -176,9 +154,6 @@ $(BUILD_DIR)/%.o : $(SRC_DIR)/tools/%.cpp
|
|||||||
@echo
|
@echo
|
||||||
$(CXX) $(CXXFLAGS) $< -c -o $@
|
$(CXX) $(CXXFLAGS) $< -c -o $@
|
||||||
|
|
||||||
$(BUILD_DIR)/%.o : $(TEST_DIR)/%.cpp
|
|
||||||
@echo "Create $@ from $<"
|
|
||||||
$(CXX) $(CXXFLAGS_TEST) $< -c -o $@
|
|
||||||
|
|
||||||
# All build instructions for all src cpp are put here
|
# All build instructions for all src cpp are put here
|
||||||
$(BUILD_DIR)/main.o : $(SRC_DIR)/main.cpp
|
$(BUILD_DIR)/main.o : $(SRC_DIR)/main.cpp
|
||||||
@@ -189,4 +164,4 @@ clean:
|
|||||||
|
|
||||||
clean_all: clean
|
clean_all: clean
|
||||||
-$(MAKE) -C external/blitz clean
|
-$(MAKE) -C external/blitz clean
|
||||||
|
-$(MAKE) -C external/jansson clean
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"e- standart interactions":
|
"e- standard interactions":
|
||||||
{
|
{
|
||||||
"elastic_example1": {
|
"elastic_example1": {
|
||||||
"Type": "ElasticScattering",
|
"Type": "ElasticScattering",
|
||||||
@@ -141,26 +141,16 @@
|
|||||||
"Target": "T2",
|
"Target": "T2",
|
||||||
"ExcitationState": "england_rotational_j1_to_j3"
|
"ExcitationState": "england_rotational_j1_to_j3"
|
||||||
},
|
},
|
||||||
"recombination_example1": {
|
|
||||||
"Type": "Recombination",
|
|
||||||
"Target": "T2+",
|
|
||||||
"CrossSection": "eT2p_recombination_janev"
|
|
||||||
},
|
|
||||||
"recombination_example2": {
|
|
||||||
"Type": "Recombination",
|
|
||||||
"Target": "T3+",
|
|
||||||
"CrossSection": "eT3p_recombination_janev"
|
|
||||||
},
|
|
||||||
"free_movement_example": {
|
"free_movement_example": {
|
||||||
"Type": "FreeMovement"
|
"Type": "FreeMovement"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"T+ standart interactions": {
|
"T+ standard interactions": {
|
||||||
"elasitc scattering": {
|
"elastic scattering": {
|
||||||
"Type": "ElasticScattering",
|
"Type": "ElasticScattering",
|
||||||
"Target": "T2",
|
"Target": "T2",
|
||||||
"CrossSection": {
|
"CrossSection": {
|
||||||
"PredefinedFunction": "TpT2_elasitc_scattering_tabata"
|
"PredefinedFunction": "TpT2_elastic_scattering_tabata"
|
||||||
},
|
},
|
||||||
"ScatteringAngleDistribution": {
|
"ScatteringAngleDistribution": {
|
||||||
"Isotropic": {}
|
"Isotropic": {}
|
||||||
@@ -170,6 +160,7 @@
|
|||||||
"Type": "Clustering",
|
"Type": "Clustering",
|
||||||
"Target": "T2",
|
"Target": "T2",
|
||||||
"Product": "T3+",
|
"Product": "T3+",
|
||||||
|
"ClusteringType": "radiative",
|
||||||
"CrossSection": {
|
"CrossSection": {
|
||||||
"PredefinedFunction": "TpT2_clustering_radiative_ascendion_pasil"
|
"PredefinedFunction": "TpT2_clustering_radiative_ascendion_pasil"
|
||||||
}
|
}
|
||||||
@@ -178,20 +169,16 @@
|
|||||||
"Type": "Clustering",
|
"Type": "Clustering",
|
||||||
"Target": "T2",
|
"Target": "T2",
|
||||||
"Product": "T3+",
|
"Product": "T3+",
|
||||||
|
"ClusteringType": "tertiary",
|
||||||
"CrossSection": {
|
"CrossSection": {
|
||||||
"PredefinedFunction": "TpT2_clustering_tertiary_ascendion_pasil"
|
"PredefinedFunction": "TpT2_clustering_tertiary_ascendion_pasil"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"recombination_example1": {
|
|
||||||
"Type": "Recombination",
|
|
||||||
"Target": "e-",
|
|
||||||
"CrossSection": "eT2p_recombination_janev"
|
|
||||||
},
|
|
||||||
"free_movement_example": {
|
"free_movement_example": {
|
||||||
"Type": "FreeMovement"
|
"Type": "FreeMovement"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"T2+ standart interactions": {
|
"T2+ standard interactions": {
|
||||||
"charge exchange": {
|
"charge exchange": {
|
||||||
"Type": "ChargeExchange",
|
"Type": "ChargeExchange",
|
||||||
"Target": "T2",
|
"Target": "T2",
|
||||||
@@ -203,6 +190,7 @@
|
|||||||
"Type": "Clustering",
|
"Type": "Clustering",
|
||||||
"Target": "T2",
|
"Target": "T2",
|
||||||
"Product": "T3+",
|
"Product": "T3+",
|
||||||
|
"ClusteringType": "radiative",
|
||||||
"CrossSection": {
|
"CrossSection": {
|
||||||
"PredefinedFunction": "T2pT2_clustering_janev"
|
"PredefinedFunction": "T2pT2_clustering_janev"
|
||||||
}
|
}
|
||||||
@@ -211,22 +199,17 @@
|
|||||||
"Type": "FreeMovement"
|
"Type": "FreeMovement"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"T3+ standart interactions":{
|
"T3+ standard interactions":{
|
||||||
"elastic scattering": {
|
"elastic scattering": {
|
||||||
"Type": "ElasticScattering",
|
"Type": "ElasticScattering",
|
||||||
"Target": "T2",
|
"Target": "T2",
|
||||||
"CrossSection": {
|
"CrossSection": {
|
||||||
"PredefinedFunction": "T3pT2_elasitc_scattering_tabata"
|
"PredefinedFunction": "T3pT2_elastic_scattering_tabata"
|
||||||
},
|
},
|
||||||
"ScatteringAngleDistribution": {
|
"ScatteringAngleDistribution": {
|
||||||
"Isotropic": {}
|
"Isotropic": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"recombination_example1": {
|
|
||||||
"Type": "Recombination",
|
|
||||||
"Target": "e-",
|
|
||||||
"CrossSection": "eT3p_recombination_janev"
|
|
||||||
},
|
|
||||||
"free_movement_example": {
|
"free_movement_example": {
|
||||||
"Type": "FreeMovement"
|
"Type": "FreeMovement"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -426,6 +426,7 @@
|
|||||||
"clustering": {
|
"clustering": {
|
||||||
"Type": "Clustering",
|
"Type": "Clustering",
|
||||||
"Target": "TritiumGas",
|
"Target": "TritiumGas",
|
||||||
|
"ClusteringType": "radiative",
|
||||||
"Product": "T3+",
|
"Product": "T3+",
|
||||||
"CrossSection": {
|
"CrossSection": {
|
||||||
"PredefinedFunction": "T2pT2_clustering_janev"
|
"PredefinedFunction": "T2pT2_clustering_janev"
|
||||||
@@ -508,11 +509,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Interactions": {
|
"Interactions": {
|
||||||
"elasitc scattering": {
|
"elastic scattering": {
|
||||||
"Type": "ElasticScattering",
|
"Type": "ElasticScattering",
|
||||||
"Target": "TritiumGas",
|
"Target": "TritiumGas",
|
||||||
"CrossSection": {
|
"CrossSection": {
|
||||||
"PredefinedFunction": "TpT2_elasitc_scattering_tabata"
|
"PredefinedFunction": "TpT2_elastic_scattering_tabata"
|
||||||
},
|
},
|
||||||
"ScatteringAngleDistribution": {
|
"ScatteringAngleDistribution": {
|
||||||
"Isotropic": {}
|
"Isotropic": {}
|
||||||
@@ -521,6 +522,7 @@
|
|||||||
"clustering1": {
|
"clustering1": {
|
||||||
"Type": "Clustering",
|
"Type": "Clustering",
|
||||||
"Target": "TritiumGas",
|
"Target": "TritiumGas",
|
||||||
|
"ClusteringType": "radiative",
|
||||||
"Product": "T3+",
|
"Product": "T3+",
|
||||||
"CrossSection": {
|
"CrossSection": {
|
||||||
"PredefinedFunction": "TpT2_clustering_radiative_ascendion_pasil"
|
"PredefinedFunction": "TpT2_clustering_radiative_ascendion_pasil"
|
||||||
@@ -529,6 +531,7 @@
|
|||||||
"clustering2": {
|
"clustering2": {
|
||||||
"Type": "Clustering",
|
"Type": "Clustering",
|
||||||
"Target": "TritiumGas",
|
"Target": "TritiumGas",
|
||||||
|
"ClusteringType": "tertiary",
|
||||||
"Product": "T3+",
|
"Product": "T3+",
|
||||||
"CrossSection": {
|
"CrossSection": {
|
||||||
"PredefinedFunction": "TpT2_clustering_tertiary_ascendion_pasil"
|
"PredefinedFunction": "TpT2_clustering_tertiary_ascendion_pasil"
|
||||||
@@ -615,7 +618,7 @@
|
|||||||
"Type": "ElasticScattering",
|
"Type": "ElasticScattering",
|
||||||
"Target": "TritiumGas",
|
"Target": "TritiumGas",
|
||||||
"CrossSection": {
|
"CrossSection": {
|
||||||
"PredefinedFunction": "T3pT2_elasitc_scattering_tabata"
|
"PredefinedFunction": "T3pT2_elastic_scattering_tabata"
|
||||||
},
|
},
|
||||||
"ScatteringAngleDistribution": {
|
"ScatteringAngleDistribution": {
|
||||||
"Isotropic": {}
|
"Isotropic": {}
|
||||||
@@ -753,7 +756,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Activity": {
|
"Activity": {
|
||||||
"value": 1E14,
|
"value": 3.7e9,
|
||||||
"unit": "Bq"
|
"unit": "Bq"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"VectorfieldExample1": {
|
"VectorfieldExample1": {
|
||||||
"VectorFieldConstant": {
|
"VectorFieldConstant": {
|
||||||
"Constant": {
|
"constant": {
|
||||||
"vector": [ 1, 2, 3]
|
"vector": [ 1, 2, 3]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,14 +74,12 @@ blitz::Array<double, 2> Hdf5Reader::readD2Double(std::string path) {
|
|||||||
blitz::Array<double, 1> Hdf5Reader::readD1Double(std::string path) {
|
blitz::Array<double, 1> Hdf5Reader::readD1Double(std::string path) {
|
||||||
hid_t file = H5Fopen(absolute_filename_.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
|
hid_t file = H5Fopen(absolute_filename_.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
|
||||||
|
|
||||||
// H5Eset_auto(H5E_DEFAULT, NULL, NULL);
|
|
||||||
hid_t dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
|
hid_t dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
|
||||||
hid_t dataspace = H5Dget_space(dataset);
|
hid_t dataspace = H5Dget_space(dataset);
|
||||||
if (dataset < 0) {
|
if (dataset < 0) {
|
||||||
ERROR("The given dataset could not be opened");
|
ERROR("The given dataset could not be opened");
|
||||||
}
|
}
|
||||||
// turn error report back onby hdf5 because of check H5Dopen2
|
// turn error report back onby hdf5 because of check H5Dopen2
|
||||||
// H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
|
|
||||||
|
|
||||||
const int ndims = H5Sget_simple_extent_ndims(dataspace);
|
const int ndims = H5Sget_simple_extent_ndims(dataspace);
|
||||||
hsize_t dims[ndims];
|
hsize_t dims[ndims];
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ void SimulationOutput::addDeletionLoggerOutput(OutputTask task) {
|
|||||||
void SimulationOutput::writeMetaData(
|
void SimulationOutput::writeMetaData(
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>& species) {
|
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>& species) {
|
||||||
if (MpiCommunication::mpi_rank == 0) {
|
if (MpiCommunication::mpi_rank == 0) {
|
||||||
|
// write number of processes that have been used in the simulation
|
||||||
|
writer.write(MpiCommunication::mpiSize(), "/NumberProcesses");
|
||||||
|
|
||||||
for (auto& pair : species) {
|
for (auto& pair : species) {
|
||||||
writeMetaData(pair.second.get());
|
writeMetaData(pair.second.get());
|
||||||
}
|
}
|
||||||
@@ -48,7 +51,9 @@ void SimulationOutput::writeSimulationData(
|
|||||||
int cpu_sync,
|
int cpu_sync,
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>& species) {
|
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>& species) {
|
||||||
if (MpiCommunication::mpi_rank == 0) {
|
if (MpiCommunication::mpi_rank == 0) {
|
||||||
|
#if defined(debug_level2) || defined(debug_level3)
|
||||||
DEBUG_LEVEL_2("Write density field data.");
|
DEBUG_LEVEL_2("Write density field data.");
|
||||||
|
#endif
|
||||||
for (auto& task : tasks_density_fields_) {
|
for (auto& task : tasks_density_fields_) {
|
||||||
if (cpu_sync % task.intervall == 0) {
|
if (cpu_sync % task.intervall == 0) {
|
||||||
std::string specie_path = "/" + task.specie_name;
|
std::string specie_path = "/" + task.specie_name;
|
||||||
@@ -56,7 +61,9 @@ void SimulationOutput::writeSimulationData(
|
|||||||
specie_path, cpu_sync, task.overwrite_last);
|
specie_path, cpu_sync, task.overwrite_last);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if defined(debug_level2) || defined(debug_level3)
|
||||||
DEBUG_LEVEL_2("Write current collector data.");
|
DEBUG_LEVEL_2("Write current collector data.");
|
||||||
|
#endif
|
||||||
for (auto& task : tasks_current_collector_) {
|
for (auto& task : tasks_current_collector_) {
|
||||||
if (cpu_sync % task.intervall == 0) {
|
if (cpu_sync % task.intervall == 0) {
|
||||||
std::string specie_path = "/" + task.specie_name;
|
std::string specie_path = "/" + task.specie_name;
|
||||||
@@ -64,7 +71,9 @@ void SimulationOutput::writeSimulationData(
|
|||||||
specie_path, cpu_sync, task.overwrite_last);
|
specie_path, cpu_sync, task.overwrite_last);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if defined(debug_level2) || defined(debug_level3)
|
||||||
DEBUG_LEVEL_2("Write deletion logger data.");
|
DEBUG_LEVEL_2("Write deletion logger data.");
|
||||||
|
#endif
|
||||||
for (auto& task : tasks_deletion_logger_) {
|
for (auto& task : tasks_deletion_logger_) {
|
||||||
if (cpu_sync % task.intervall == 0) {
|
if (cpu_sync % task.intervall == 0) {
|
||||||
std::string specie_path = "/" + task.specie_name;
|
std::string specie_path = "/" + task.specie_name;
|
||||||
@@ -85,15 +94,25 @@ void SimulationOutput::writeSimulationData(DynamicDensityField* density_field,
|
|||||||
}
|
}
|
||||||
std::string path = species_path + "/DensityField/SimulationData/" + sync_path;
|
std::string path = species_path + "/DensityField/SimulationData/" + sync_path;
|
||||||
|
|
||||||
|
#if defined(debug_level3)
|
||||||
DEBUG_LEVEL_3("Write spectrum.");
|
DEBUG_LEVEL_3("Write spectrum.");
|
||||||
|
#endif
|
||||||
writeSpectrum(density_field, path);
|
writeSpectrum(density_field, path);
|
||||||
|
#if defined(debug_level3)
|
||||||
DEBUG_LEVEL_3("Write density.");
|
DEBUG_LEVEL_3("Write density.");
|
||||||
|
#endif
|
||||||
writeDensity(density_field, path);
|
writeDensity(density_field, path);
|
||||||
|
#if defined(debug_level3)
|
||||||
DEBUG_LEVEL_3("Write time in bin.");
|
DEBUG_LEVEL_3("Write time in bin.");
|
||||||
|
#endif
|
||||||
writeTimeInBin(density_field, path);
|
writeTimeInBin(density_field, path);
|
||||||
|
#if defined(debug_level3)
|
||||||
DEBUG_LEVEL_3("Write deleted particles.");
|
DEBUG_LEVEL_3("Write deleted particles.");
|
||||||
|
#endif
|
||||||
writeDeletedParticles(density_field, path);
|
writeDeletedParticles(density_field, path);
|
||||||
|
#if defined(debug_level3)
|
||||||
DEBUG_LEVEL_3("Write physical time.");
|
DEBUG_LEVEL_3("Write physical time.");
|
||||||
|
#endif
|
||||||
writePhysicalTime(density_field, path);
|
writePhysicalTime(density_field, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,11 +126,17 @@ void SimulationOutput::writeSimulationData(CurrentCollector* current_collector,
|
|||||||
}
|
}
|
||||||
std::string path =
|
std::string path =
|
||||||
species_path + "/CurrentCollector/SimulationData/" + sync_path;
|
species_path + "/CurrentCollector/SimulationData/" + sync_path;
|
||||||
|
#if defined(debug_level3)
|
||||||
DEBUG_LEVEL_3("Write current crossings.");
|
DEBUG_LEVEL_3("Write current crossings.");
|
||||||
|
#endif
|
||||||
writeCurrentCrossings(current_collector, path);
|
writeCurrentCrossings(current_collector, path);
|
||||||
|
#if defined(debug_level3)
|
||||||
DEBUG_LEVEL_3("Write current.");
|
DEBUG_LEVEL_3("Write current.");
|
||||||
|
#endif
|
||||||
writeCurrent(current_collector, path);
|
writeCurrent(current_collector, path);
|
||||||
|
#if defined(debug_level3)
|
||||||
DEBUG_LEVEL_3("Write physical time.");
|
DEBUG_LEVEL_3("Write physical time.");
|
||||||
|
#endif
|
||||||
writePhysicalTime(current_collector, path);
|
writePhysicalTime(current_collector, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,7 +149,9 @@ void SimulationOutput::writeSimulationData(DeletionLogger* logger,
|
|||||||
sync_path = "LastSyncPeriod";
|
sync_path = "LastSyncPeriod";
|
||||||
}
|
}
|
||||||
std::string path = species_path + "/DeletionLogger/" + sync_path;
|
std::string path = species_path + "/DeletionLogger/" + sync_path;
|
||||||
|
#if defined(debug_level3)
|
||||||
DEBUG_LEVEL_3("Write number of deletions.");
|
DEBUG_LEVEL_3("Write number of deletions.");
|
||||||
|
#endif
|
||||||
writeNumDeletions(logger, path);
|
writeNumDeletions(logger, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,6 +168,8 @@ void SimulationOutput::writeNumDeletions(DeletionLogger* logger,
|
|||||||
writer.write(pair.second, path_to_deletions + "/MaxInteractions");
|
writer.write(pair.second, path_to_deletions + "/MaxInteractions");
|
||||||
} else if (pair.first == DeletionType::max_time_alive) {
|
} else if (pair.first == DeletionType::max_time_alive) {
|
||||||
writer.write(pair.second, path_to_deletions + "/MaxTimeAlive");
|
writer.write(pair.second, path_to_deletions + "/MaxTimeAlive");
|
||||||
|
} else if (pair.first == DeletionType::cluster_formation) {
|
||||||
|
writer.write(pair.second, path_to_deletions + "/ClusterFormation");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ std::function<double(double)> PiecewiseLinear(std::vector<double> positions,
|
|||||||
|
|
||||||
return [=](double x) {
|
return [=](double x) {
|
||||||
const auto lb = coordinates.lower_bound(x);
|
const auto lb = coordinates.lower_bound(x);
|
||||||
const auto ub = coordinates.upper_bound(x);
|
const auto ub = coordinates.upper_bound(x); // i think superfluous
|
||||||
|
|
||||||
if (lb == coordinates.end()) {
|
if (lb == coordinates.end()) {
|
||||||
return coordinates.rbegin()->second;
|
return coordinates.rbegin()->second;
|
||||||
|
|||||||
@@ -23,4 +23,23 @@ std::shared_ptr<DriftVelocity> buildDriftVelocity(
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<DriftVelocity> buildDriftVelocityIncludingRedirection(
|
||||||
|
Parameter& parameter, const json_path& path_to_drift_velocity) {
|
||||||
|
std::stringstream cpath;
|
||||||
|
if (parameter.jsonObjectFromBase(
|
||||||
|
json_path_append(path_to_drift_velocity, {"CreateSameAs"}))) {
|
||||||
|
DEBUG_LEVEL_2("Creating Drift velocity: CreateSameAs.");
|
||||||
|
json_path path_to_same = json_path_get(parameter.jsonObjectFromBase(
|
||||||
|
json_path_append(path_to_drift_velocity, {"CreateSameAs"})));
|
||||||
|
std::stringstream path;
|
||||||
|
for (auto& p : path_to_same) {
|
||||||
|
path << p << " ";
|
||||||
|
}
|
||||||
|
DEBUG_LEVEL_3("From path: " + path.str());
|
||||||
|
return buildDriftVelocityIncludingRedirection(parameter, path_to_same);
|
||||||
|
} else {
|
||||||
|
return buildDriftVelocity(parameter, path_to_drift_velocity);
|
||||||
|
}
|
||||||
|
}
|
||||||
}; // namespace generator
|
}; // namespace generator
|
||||||
@@ -41,12 +41,10 @@ std::function<double(double)> function1D(json_t* object) {
|
|||||||
std::string x_values_key = json_string(
|
std::string x_values_key = json_string(
|
||||||
json_object_by_path(object, {"PiecewiseLinearFromFile", "xValuesKey"}));
|
json_object_by_path(object, {"PiecewiseLinearFromFile", "xValuesKey"}));
|
||||||
blitz::Array<double, 1> x_values_array = reader.readD1Double(x_values_key);
|
blitz::Array<double, 1> x_values_array = reader.readD1Double(x_values_key);
|
||||||
// DEBUG_LEVEL_3("with x values: " + x_values_array);
|
|
||||||
|
|
||||||
std::string y_values_key = json_string(
|
std::string y_values_key = json_string(
|
||||||
json_object_by_path(object, {"PiecewiseLinearFromFile", "yValuesKey"}));
|
json_object_by_path(object, {"PiecewiseLinearFromFile", "yValuesKey"}));
|
||||||
blitz::Array<double, 1> y_values_array = reader.readD1Double(y_values_key);
|
blitz::Array<double, 1> y_values_array = reader.readD1Double(y_values_key);
|
||||||
// DEBUG_LEVEL_3("with y values: " + y_values_array);
|
|
||||||
|
|
||||||
std::vector<double> x_values(x_values_array.begin(), x_values_array.end());
|
std::vector<double> x_values(x_values_array.begin(), x_values_array.end());
|
||||||
std::vector<double> y_values(y_values_array.begin(), y_values_array.end());
|
std::vector<double> y_values(y_values_array.begin(), y_values_array.end());
|
||||||
|
|||||||
@@ -187,10 +187,26 @@ void addInteractions(
|
|||||||
std::shared_ptr<species::TrackedSpecie> product =
|
std::shared_ptr<species::TrackedSpecie> product =
|
||||||
findTracked(product_name, tracked_species);
|
findTracked(product_name, tracked_species);
|
||||||
|
|
||||||
|
std::string clustering_type =
|
||||||
|
json_string(json_object_by_path(value, {"ClusteringType"}));
|
||||||
|
|
||||||
std::function<double(double)> cross_section =
|
std::function<double(double)> cross_section =
|
||||||
buildTotalCrossSection(json_object_by_path(value, {"CrossSection"}));
|
buildTotalCrossSection(json_object_by_path(value, {"CrossSection"}));
|
||||||
specie->addInteraction(std::shared_ptr<interaction::Interaction>(
|
|
||||||
new interaction::ClusterFormation(cross_section, target, product)));
|
if(clustering_type == "radiative") {
|
||||||
|
specie->addInteraction(std::shared_ptr<interaction::Interaction>(
|
||||||
|
new interaction::ClusterFormation(cross_section, target, product)));
|
||||||
|
} else if (clustering_type == "tertiary") {
|
||||||
|
SIM_INFO("Warning: tertiary clustering has been chosen. Be warned "
|
||||||
|
"that the cross section function is scaled by the density "
|
||||||
|
"of the target specie at the position of the interaction "
|
||||||
|
"(cross section function assumed to have the units m^5)");
|
||||||
|
specie->addInteraction(std::shared_ptr<interaction::Interaction>(
|
||||||
|
new interaction::ClusterFormationTertiary(cross_section, target, product)));
|
||||||
|
} else {
|
||||||
|
ERROR("ClusteringType " + clustering_type +
|
||||||
|
": not known, choose either 'radiative' or 'tertiary'.");
|
||||||
|
}
|
||||||
} else if (type == "ChargeExchange") {
|
} else if (type == "ChargeExchange") {
|
||||||
DEBUG_LEVEL_2("Adding interactions: ChargeExchange");
|
DEBUG_LEVEL_2("Adding interactions: ChargeExchange");
|
||||||
std::string target_name =
|
std::string target_name =
|
||||||
@@ -232,10 +248,10 @@ std::function<double(double)> buildTotalCrossSection(json_t* object) {
|
|||||||
return interaction::totalCrossSection::eT2_elastic_scattering();
|
return interaction::totalCrossSection::eT2_elastic_scattering();
|
||||||
} else if (function_name == "eT2_elastic_scattering") {
|
} else if (function_name == "eT2_elastic_scattering") {
|
||||||
return interaction::totalCrossSection::eT2_elastic_scattering();
|
return interaction::totalCrossSection::eT2_elastic_scattering();
|
||||||
} else if (function_name == "TpT2_elasitc_scattering_tabata") {
|
} else if (function_name == "TpT2_elastic_scattering_tabata") {
|
||||||
return interaction::totalCrossSection::TpT2_elasitc_scattering_tabata();
|
return interaction::totalCrossSection::TpT2_elastic_scattering_tabata();
|
||||||
} else if (function_name == "T3pT2_elasitc_scattering_tabata") {
|
} else if (function_name == "T3pT2_elastic_scattering_tabata") {
|
||||||
return interaction::totalCrossSection::T3pT2_elasitc_scattering_tabata();
|
return interaction::totalCrossSection::T3pT2_elastic_scattering_tabata();
|
||||||
} else if (function_name == "eT2_ionization_janev_diss_ground") {
|
} else if (function_name == "eT2_ionization_janev_diss_ground") {
|
||||||
return interaction::totalCrossSection::eT2_ionization_janev_diss_ground();
|
return interaction::totalCrossSection::eT2_ionization_janev_diss_ground();
|
||||||
} else if (function_name == "eT2_ionization_janev_diss_first") {
|
} else if (function_name == "eT2_ionization_janev_diss_first") {
|
||||||
@@ -312,8 +328,8 @@ double buildExcitationEnergy(std::string excitation_state) {
|
|||||||
} else if (excitation_state == "england_rotational_j1_to_j3") {
|
} else if (excitation_state == "england_rotational_j1_to_j3") {
|
||||||
return 0.0727;
|
return 0.0727;
|
||||||
} else {
|
} else {
|
||||||
ERROR(
|
ERROR( excitation_state +
|
||||||
"This type of cross section ExcitationState is not implemented in "
|
": This type of cross section ExcitationState is not implemented in "
|
||||||
"buildExcitationEnergy.");
|
"buildExcitationEnergy.");
|
||||||
return 0.;
|
return 0.;
|
||||||
}
|
}
|
||||||
@@ -383,8 +399,8 @@ std::function<double(double)> buildExcitationCrossSection(
|
|||||||
return interaction::totalCrossSection::
|
return interaction::totalCrossSection::
|
||||||
eT2_excitation_rotational_j1_to_j3_england();
|
eT2_excitation_rotational_j1_to_j3_england();
|
||||||
} else {
|
} else {
|
||||||
ERROR(
|
ERROR( excitation_state +
|
||||||
"This type of cross section ExcitationState is not implemented in "
|
": This type of cross section ExcitationState is not implemented in "
|
||||||
"buildExcitationCrossSection.");
|
"buildExcitationCrossSection.");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -397,7 +413,7 @@ std::function<double(double, double)> build2DCrossSection(json_t* object) {
|
|||||||
if (function_name == "eT2_ionization_bed") {
|
if (function_name == "eT2_ionization_bed") {
|
||||||
return interaction::d2CrossSection::eT2_ionization_bed();
|
return interaction::d2CrossSection::eT2_ionization_bed();
|
||||||
} else {
|
} else {
|
||||||
ERROR("This predefined function does not exist");
|
ERROR(function_name + ": This predefined function does not exist");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -452,7 +468,7 @@ std::shared_ptr<species::Specie> findTarget(
|
|||||||
} else if (tracked_species.count(target_name)) {
|
} else if (tracked_species.count(target_name)) {
|
||||||
return tracked_species.at(target_name);
|
return tracked_species.at(target_name);
|
||||||
} else {
|
} else {
|
||||||
ERROR("The specified target does not exist.");
|
ERROR(target_name + ": The specified target does not exist.");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -464,7 +480,7 @@ std::shared_ptr<species::TrackedSpecie> findTracked(
|
|||||||
if (tracked_species.count(target_name)) {
|
if (tracked_species.count(target_name)) {
|
||||||
return tracked_species.at(target_name);
|
return tracked_species.at(target_name);
|
||||||
} else {
|
} else {
|
||||||
ERROR("The specified target does not exist.");
|
ERROR(target_name + ": The specified target does not exist.");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ std::shared_ptr<DeletionLogger> buildDeletionLogger(json_t* object) {
|
|||||||
used_types.push_back(DeletionType::max_interactions);
|
used_types.push_back(DeletionType::max_interactions);
|
||||||
} else if (type_alias == "max_time_alive") {
|
} else if (type_alias == "max_time_alive") {
|
||||||
used_types.push_back(DeletionType::max_time_alive);
|
used_types.push_back(DeletionType::max_time_alive);
|
||||||
|
} else if (type_alias == "cluster_formation") {
|
||||||
|
used_types.push_back(DeletionType::cluster_formation);
|
||||||
} else {
|
} else {
|
||||||
ERROR("This deletion type is not known");
|
ERROR("This deletion type is not known");
|
||||||
}
|
}
|
||||||
@@ -32,6 +34,7 @@ std::shared_ptr<DeletionLogger> buildDeletionLogger(json_t* object) {
|
|||||||
used_types.push_back(DeletionType::recombination);
|
used_types.push_back(DeletionType::recombination);
|
||||||
used_types.push_back(DeletionType::max_interactions);
|
used_types.push_back(DeletionType::max_interactions);
|
||||||
used_types.push_back(DeletionType::max_time_alive);
|
used_types.push_back(DeletionType::max_time_alive);
|
||||||
|
used_types.push_back(DeletionType::cluster_formation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
namespace generator {
|
namespace generator {
|
||||||
|
|
||||||
|
// map for the implemented species to their masses in kg
|
||||||
std::map<species::ImplementedSpecies, double> SpeciesMasses::mass_ = {
|
std::map<species::ImplementedSpecies, double> SpeciesMasses::mass_ = {
|
||||||
{species::ImplementedSpecies::electron, SI::me},
|
{species::ImplementedSpecies::electron, SI::me},
|
||||||
{species::ImplementedSpecies::T2, 6 * SI::mp + 2 * SI::me},
|
{species::ImplementedSpecies::T2, 6 * SI::mp + 2 * SI::me},
|
||||||
|
|||||||
@@ -18,6 +18,14 @@ std::shared_ptr<Mover> buildMover(Parameter& parameter,
|
|||||||
json_read_length(parameter.jsonObjectFromBase(json_path_append(
|
json_read_length(parameter.jsonObjectFromBase(json_path_append(
|
||||||
path_to_mover, {"Drift", "MaximalMovedDistance"})));
|
path_to_mover, {"Drift", "MaximalMovedDistance"})));
|
||||||
return std::make_shared<DriftMover>(maximal_moved_distance);
|
return std::make_shared<DriftMover>(maximal_moved_distance);
|
||||||
|
} else if (parameter.jsonObjectFromBase(
|
||||||
|
json_path_append(path_to_mover, {"Euler"}))) {
|
||||||
|
DEBUG_LEVEL_3("Creating mover: Euler.");
|
||||||
|
SIM_INFO("Warning: any magnetic or electric field are going to be ignored.");
|
||||||
|
double maximal_moved_distance =
|
||||||
|
json_read_length(parameter.jsonObjectFromBase(json_path_append(
|
||||||
|
path_to_mover, {"Euler", "MaximalMovedDistance"})));
|
||||||
|
return std::make_shared<EulerMover>(maximal_moved_distance);
|
||||||
} else {
|
} else {
|
||||||
ERROR("This mover is not implemented");
|
ERROR("This mover is not implemented");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|||||||
@@ -100,9 +100,14 @@ std::shared_ptr<Timer> SpeciesBuilder::timer() {
|
|||||||
return timer_;
|
return timer_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<Timer> SpeciesBuilder::lastSyncTimer() {
|
||||||
|
return last_sync_timer_;
|
||||||
|
}
|
||||||
|
|
||||||
void SpeciesBuilder::initTimer() {
|
void SpeciesBuilder::initTimer() {
|
||||||
DEBUG_LEVEL_2("Init timer.");
|
DEBUG_LEVEL_2("Init timer.");
|
||||||
timer_ = std::shared_ptr<Timer>(new Timer());
|
timer_ = std::shared_ptr<Timer>(new Timer());
|
||||||
|
last_sync_timer_ = std::shared_ptr<Timer>(new Timer());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpeciesBuilder::initBackgroundSpecies(Parameter& parameter) {
|
void SpeciesBuilder::initBackgroundSpecies(Parameter& parameter) {
|
||||||
@@ -184,11 +189,11 @@ void SpeciesBuilder::fillVelocityDistribution(Parameter& parameter) {
|
|||||||
void SpeciesBuilder::fillDriftVelocity(Parameter& parameter) {
|
void SpeciesBuilder::fillDriftVelocity(Parameter& parameter) {
|
||||||
DEBUG_LEVEL_2("Fill drift velocity.");
|
DEBUG_LEVEL_2("Fill drift velocity.");
|
||||||
for (auto& b : background_species_info) {
|
for (auto& b : background_species_info) {
|
||||||
b.second.drift_velocity = buildDriftVelocity(
|
b.second.drift_velocity = buildDriftVelocityIncludingRedirection(
|
||||||
parameter, json_path_append(b.second.path_in_json, {"DriftVelocity"}));
|
parameter, json_path_append(b.second.path_in_json, {"DriftVelocity"}));
|
||||||
}
|
}
|
||||||
for (auto& b : tracked_species_info) {
|
for (auto& b : tracked_species_info) {
|
||||||
b.second.drift_velocity = buildDriftVelocity(
|
b.second.drift_velocity = buildDriftVelocityIncludingRedirection(
|
||||||
parameter, json_path_append(b.second.path_in_json, {"DriftVelocity"}));
|
parameter, json_path_append(b.second.path_in_json, {"DriftVelocity"}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -251,6 +256,12 @@ void SpeciesBuilder::fillTrackedDensity(Parameter& parameter) {
|
|||||||
json_path_append(b.second.path_in_json,
|
json_path_append(b.second.path_in_json,
|
||||||
{"DensityField", "DynamicDensityField"}),
|
{"DensityField", "DynamicDensityField"}),
|
||||||
timer_);
|
timer_);
|
||||||
|
|
||||||
|
b.second.last_sync_density_field = buildDynamicDensityField(
|
||||||
|
parameter,
|
||||||
|
json_path_append(b.second.path_in_json,
|
||||||
|
{"DensityField", "DynamicDensityField"}),
|
||||||
|
last_sync_timer_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,7 +281,7 @@ void SpeciesBuilder::buildSpecies() {
|
|||||||
b.second.type, b.second.name, b.second.mass_kg, b.second.charge_C,
|
b.second.type, b.second.name, b.second.mass_kg, b.second.charge_C,
|
||||||
b.second.mover, b.second.terminator, b.second.reflector,
|
b.second.mover, b.second.terminator, b.second.reflector,
|
||||||
b.second.density_field, b.second.velocity_distribution,
|
b.second.density_field, b.second.velocity_distribution,
|
||||||
b.second.drift_velocity));
|
b.second.drift_velocity, b.second.last_sync_density_field));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,7 +293,15 @@ void SpeciesBuilder::fillCurrentCollector(Parameter& parameter) {
|
|||||||
json_path_append(tracked_species_info.at(b.first).path_in_json,
|
json_path_append(tracked_species_info.at(b.first).path_in_json,
|
||||||
{"CurrentCollector"}),
|
{"CurrentCollector"}),
|
||||||
timer_);
|
timer_);
|
||||||
|
// has to be recreated, if it would be copied the timer_ pointer would
|
||||||
|
// point to the same object -> could not get updated during synchronization
|
||||||
|
auto last_sync_current_collector = buildCurrentCollector(
|
||||||
|
parameter,
|
||||||
|
json_path_append(tracked_species_info.at(b.first).path_in_json,
|
||||||
|
{"CurrentCollector"}),
|
||||||
|
last_sync_timer_);
|
||||||
b.second->currentCollector(current_collector);
|
b.second->currentCollector(current_collector);
|
||||||
|
b.second->lastSyncCurrentCollector(last_sync_current_collector);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,6 +313,8 @@ void SpeciesBuilder::fillLoggers(Parameter& parameter) {
|
|||||||
json_path_append(tracked_species_info.at(b.first).path_in_json,
|
json_path_append(tracked_species_info.at(b.first).path_in_json,
|
||||||
{"Loggers"}));
|
{"Loggers"}));
|
||||||
b.second->deletionLogger(deletion_logger);
|
b.second->deletionLogger(deletion_logger);
|
||||||
|
b.second->lastSyncDeletionLogger(
|
||||||
|
std::make_shared<DeletionLogger>(*deletion_logger));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user