Compare commits
1
Commits
karl_paper
..
jrupp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
561131906b |
@@ -1,6 +0,0 @@
|
|||||||
.vscode
|
|
||||||
.idea
|
|
||||||
|
|
||||||
build
|
|
||||||
bin
|
|
||||||
output
|
|
||||||
@@ -1,97 +0,0 @@
|
|||||||
COMPILATION OF THE CODE:
|
|
||||||
|
|
||||||
The code requires a C++ compiler (e.g. gcc) and few external libraries (MPI,
|
|
||||||
HDF5, Jansson, Blitz++). All of them are available in Debian and are
|
|
||||||
listed with package names in the file REQUIRED. Other distributions might have
|
|
||||||
slightly different package names. After installing all external dependencies
|
|
||||||
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
|
|
||||||
environment variable named "HOMEBASE", eg. through:
|
|
||||||
|
|
||||||
$ export HOMEBASE=$(pwd)
|
|
||||||
|
|
||||||
Then simply run
|
|
||||||
|
|
||||||
$ make
|
|
||||||
|
|
||||||
which should build and link all files to produce the binary file "bin/karl"
|
|
||||||
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
|
|
||||||
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:
|
|
||||||
|
|
||||||
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
|
|
||||||
(simulation_config/test_parameter.json).
|
|
||||||
The JSON file also contains the location for the simulation output. Before
|
|
||||||
running on a cluster you should
|
|
||||||
|
|
||||||
edit the JSON file, adjust "folder" and "filename" in the "Output" section.
|
|
||||||
|
|
||||||
You can then start the simulation using
|
|
||||||
|
|
||||||
$ 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
|
|
||||||
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
|
|
||||||
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?
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
build-essential
|
|
||||||
libopenmpi-dev
|
|
||||||
openmpi-bin
|
|
||||||
libhdf5-openmpi-dev
|
|
||||||
libblitz0-dev
|
|
||||||
libjansson-dev
|
|
||||||
pkg-config
|
|
||||||
@@ -1,307 +0,0 @@
|
|||||||
#from asyncio import open_unix_connection
|
|
||||||
import numpy as np
|
|
||||||
import h5py as h5py
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import matplotlib
|
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
import plot_standards as pst
|
|
||||||
|
|
||||||
|
|
||||||
def getSpecies(filename):
|
|
||||||
file = h5py.File(filename, 'r')
|
|
||||||
return list(file.keys())
|
|
||||||
|
|
||||||
|
|
||||||
def outputPeriodKey(output_period):
|
|
||||||
if (output_period == "LastSyncPeriod"):
|
|
||||||
return "/LastSyncPeriod"
|
|
||||||
else:
|
|
||||||
return "/" + output_period
|
|
||||||
|
|
||||||
|
|
||||||
def mass(filename, path_to_species):
|
|
||||||
file = h5py.File(filename, 'r')
|
|
||||||
path_to_mass = path_to_species + "/Mass"
|
|
||||||
return np.array(file[path_to_mass])[0]
|
|
||||||
|
|
||||||
|
|
||||||
def charge(filename, path_to_species):
|
|
||||||
file = h5py.File(filename, 'r')
|
|
||||||
path_to_charge = path_to_species + "/Charge"
|
|
||||||
return np.array(file[path_to_charge])[0]
|
|
||||||
|
|
||||||
|
|
||||||
def zBinsDensityField(filename, path_to_species):
|
|
||||||
file = h5py.File(filename, 'r')
|
|
||||||
path_to_border = path_to_species + "/DensityField/BinBorders/longitudinal"
|
|
||||||
return np.array(file[path_to_border])
|
|
||||||
|
|
||||||
|
|
||||||
def energyBinsDensityfield(filename, path_to_species):
|
|
||||||
file = h5py.File(filename, 'r')
|
|
||||||
path_to_border = path_to_species + "/DensityField/BinBorders/energy"
|
|
||||||
return np.array(file[path_to_border])
|
|
||||||
|
|
||||||
|
|
||||||
def binVolumes(filename, path_to_species):
|
|
||||||
file = h5py.File(filename, 'r')
|
|
||||||
path_to_volumes = path_to_species + "/DensityField/BinVolumes"
|
|
||||||
return np.array(file[path_to_volumes])
|
|
||||||
|
|
||||||
|
|
||||||
def deletionsMaxInteractions(filename, path_to_species, output_period):
|
|
||||||
file = h5py.File(filename, 'r')
|
|
||||||
path = path_to_species + "/DeletionLogger" + \
|
|
||||||
outputPeriodKey(output_period) + "/NumDeletions/MaxInteractions"
|
|
||||||
return np.array(file[path])[0]
|
|
||||||
|
|
||||||
|
|
||||||
def deletionsMaxTimeAlive(filename, path_to_species, output_period):
|
|
||||||
file = h5py.File(filename, 'r')
|
|
||||||
path = path_to_species + "/DeletionLogger" + \
|
|
||||||
outputPeriodKey(output_period) + "/NumDeletions/MaxTimeAlive"
|
|
||||||
return np.array(file[path])[0]
|
|
||||||
|
|
||||||
|
|
||||||
def deletionsRecombination(filename, path_to_species, output_period):
|
|
||||||
file = h5py.File(filename, 'r')
|
|
||||||
path = path_to_species + "/DeletionLogger" + \
|
|
||||||
outputPeriodKey(output_period) + "/NumDeletions/Recombination"
|
|
||||||
return np.array(file[path])[0]
|
|
||||||
|
|
||||||
|
|
||||||
def deletionsWall(filename, path_to_species, output_period):
|
|
||||||
file = h5py.File(filename, 'r')
|
|
||||||
path = path_to_species + "/DeletionLogger" + \
|
|
||||||
outputPeriodKey(output_period) + "/NumDeletions/Wall"
|
|
||||||
return np.array(file[path])[0]
|
|
||||||
|
|
||||||
|
|
||||||
def timeInBin(filename, path_to_species, output_period):
|
|
||||||
file = h5py.File(filename, 'r')
|
|
||||||
path_to_time = path_to_species + "/DensityField/SimulationData" + \
|
|
||||||
outputPeriodKey(output_period) + "/TimeInBin"
|
|
||||||
return np.array(file[path_to_time])
|
|
||||||
|
|
||||||
|
|
||||||
def physicalTime(filename, path_to_species, output_period):
|
|
||||||
file = h5py.File(filename, 'r')
|
|
||||||
path_to_time = path_to_species + "/DensityField/SimulationData" + \
|
|
||||||
outputPeriodKey(output_period) + "/PhysicalTime"
|
|
||||||
return np.array(file[path_to_time])[0]
|
|
||||||
|
|
||||||
|
|
||||||
def spectrum(filename, path_to_species, output_period):
|
|
||||||
file = h5py.File(filename, 'r')
|
|
||||||
path_to_spectrum = path_to_species + "/DensityField/SimulationData" + \
|
|
||||||
outputPeriodKey(output_period) + "/Spectrum"
|
|
||||||
return np.array(file[path_to_spectrum])
|
|
||||||
|
|
||||||
|
|
||||||
def density(filename, path_to_species, output_period):
|
|
||||||
file = h5py.File(filename, 'r')
|
|
||||||
path_to_density = path_to_species + "/DensityField/SimulationData" + \
|
|
||||||
outputPeriodKey(output_period) + "/Density"
|
|
||||||
return np.array(file[path_to_density])
|
|
||||||
|
|
||||||
|
|
||||||
def longitudinalCurrent(filename, path_to_species, output_period):
|
|
||||||
file = h5py.File(filename, 'r')
|
|
||||||
path_to_current = path_to_species + "/CurrentCollector/SimulationData" + \
|
|
||||||
outputPeriodKey(output_period) + "/CurrentInZ"
|
|
||||||
return np.array(file[path_to_current])
|
|
||||||
|
|
||||||
|
|
||||||
def longitudinalNegativeCrossings(filename, path_to_species, output_period):
|
|
||||||
file = h5py.File(filename, 'r')
|
|
||||||
path_to_current = path_to_species + "/CurrentCollector/SimulationData" + \
|
|
||||||
outputPeriodKey(output_period) + "/NegativeCrossingsInZ"
|
|
||||||
return np.array(file[path_to_current])
|
|
||||||
|
|
||||||
|
|
||||||
def longitudinalPositiveCrossings(filename, path_to_species, output_period):
|
|
||||||
file = h5py.File(filename, 'r')
|
|
||||||
path_to_current = path_to_species + "/CurrentCollector/SimulationData" + \
|
|
||||||
outputPeriodKey(output_period) + "/PositiveCrossingsInZ"
|
|
||||||
return np.array(file[path_to_current])
|
|
||||||
|
|
||||||
|
|
||||||
def radialCurrent(filename, path_to_species, output_period):
|
|
||||||
file = h5py.File(filename, 'r')
|
|
||||||
path_to_current = path_to_species + "/CurrentCollector/SimulationData" + \
|
|
||||||
outputPeriodKey(output_period) + "/CurrentInR"
|
|
||||||
return np.array(file[path_to_current])
|
|
||||||
|
|
||||||
|
|
||||||
def longitudinalAreas(filename, path_to_species):
|
|
||||||
file = h5py.File(filename, 'r')
|
|
||||||
path_to_areas = path_to_species + "/CurrentCollector/AreaInZ"
|
|
||||||
return np.array(file[path_to_areas])
|
|
||||||
|
|
||||||
|
|
||||||
def radialAreas(filename, path_to_species):
|
|
||||||
file = h5py.File(filename, 'r')
|
|
||||||
path_to_areas = path_to_species + "/CurrentCollector/AreaInR"
|
|
||||||
return np.array(file[path_to_areas])
|
|
||||||
|
|
||||||
|
|
||||||
def longitudinalCurrentVsZ(filename, path_to_species, output_period="LastSyncPeriod"):
|
|
||||||
areas_in_z = longitudinalAreas(filename, path_to_species)
|
|
||||||
current_in_z = longitudinalCurrent(
|
|
||||||
filename, path_to_species, output_period)
|
|
||||||
particles = current_in_z * areas_in_z
|
|
||||||
return np.sum(particles, axis=(0, 1)) / np.sum(areas_in_z, axis=(0, 1))
|
|
||||||
|
|
||||||
|
|
||||||
def longitudinalNegativeCrossingsVsZ(filename, path_to_species, output_period="LastSyncPeriod"):
|
|
||||||
areas_in_z = longitudinalAreas(filename, path_to_species)
|
|
||||||
current_in_z = longitudinalCurrent(
|
|
||||||
filename, path_to_species, output_period)
|
|
||||||
particles = current_in_z * areas_in_z
|
|
||||||
return np.sum(particles, axis=(0, 1)) / np.sum(areas_in_z, axis=(0, 1))
|
|
||||||
|
|
||||||
|
|
||||||
def tubeCurrentVsZ(filename, path_to_species, output_period="LastSyncPeriod"):
|
|
||||||
areas_in_r = radialAreas(filename, path_to_species)
|
|
||||||
current_in_r = radialCurrent(filename, path_to_species, output_period)
|
|
||||||
particles = current_in_r * areas_in_r
|
|
||||||
return (np.sum(particles, axis=(1)) / np.sum(areas_in_r, axis=(1)))[-2, :]
|
|
||||||
|
|
||||||
|
|
||||||
def densityVsZ(filename, path_to_species, output_period="LastSyncPeriod"):
|
|
||||||
bin_volumes = binVolumes(filename, path_to_species)
|
|
||||||
densities = density(filename, path_to_species, output_period)
|
|
||||||
particles = densities*bin_volumes
|
|
||||||
return np.sum(particles, axis=(0, 1)) / np.sum(bin_volumes, axis=(0, 1))
|
|
||||||
|
|
||||||
|
|
||||||
def findClosestIndex(position, bin_borders):
|
|
||||||
return (np.abs(bin_borders - position)).argmin()
|
|
||||||
|
|
||||||
|
|
||||||
def spectrumAtZ(filename, path_to_species, z_position, output_period="LastSyncPeriod"):
|
|
||||||
bin_volumes = binVolumes(filename, path_to_species)
|
|
||||||
spectrums = spectrum(filename, path_to_species, output_period)
|
|
||||||
particles = spectrums
|
|
||||||
for i in np.arange(0, particles.shape[3]):
|
|
||||||
particles[:, :, :, i] = spectrums[:, :, :, i]*bin_volumes
|
|
||||||
z_index = findClosestIndex(
|
|
||||||
z_position, zBinsDensityField(filename, path_to_species))
|
|
||||||
volume = np.sum(bin_volumes, axis=(0, 1))[z_index]
|
|
||||||
return np.sum(particles, axis=(0, 1))[z_index, :]/volume
|
|
||||||
|
|
||||||
|
|
||||||
def makeBarPlotData(data, mins, maxs):
|
|
||||||
plot_bins = np.dstack((mins, maxs)).flatten()
|
|
||||||
plot_datas = np.dstack((data, data)).flatten()
|
|
||||||
return plot_bins, plot_datas
|
|
||||||
|
|
||||||
|
|
||||||
def plotSpectrumAtZ(filename, path_to_species, z_position, plot_axis, output_period="LastSyncPeriod"):
|
|
||||||
spectrum_at_z = spectrumAtZ(
|
|
||||||
filename, path_to_species, z_position, output_period)
|
|
||||||
E_bins = energyBinsDensityfield(filename, path_to_species)
|
|
||||||
plot_bins, plot_datas = makeBarPlotData(
|
|
||||||
spectrum_at_z[1:-1], E_bins[0:-1], E_bins[1:])
|
|
||||||
plot_axis.plot(plot_bins, plot_datas, label=str(path_to_species))
|
|
||||||
plot_axis.set_xscale("log")
|
|
||||||
plot_axis.set_yscale("log")
|
|
||||||
plot_axis.set_xlabel(r"Energy $E$ (eV)")
|
|
||||||
plot_axis.set_ylabel(
|
|
||||||
r"Diff. Density $\frac{\mathrm{d}n_e}{\mathrm{d}\log_{10}E}$ $\left(\frac{1}{\mathrm{m}^{3} \log_{10}(\mathrm{eV})}\right)$")
|
|
||||||
|
|
||||||
|
|
||||||
def plotAllSpectrumAtZ(filename, z_position, output_period, specie_keys, output_folder, plot_instructions={}):
|
|
||||||
pst.setRcParams()
|
|
||||||
fig, ax = plt.subplots(figsize=pst.set_size('thesis'))
|
|
||||||
for key in specie_keys:
|
|
||||||
plotSpectrumAtZ(filename, key, z_position, ax, output_period)
|
|
||||||
ax.set_facecolor('#e7e7e7ff')
|
|
||||||
ax.grid(color='white')
|
|
||||||
|
|
||||||
ax.legend()
|
|
||||||
if "xlim" in plot_instructions.keys():
|
|
||||||
ax.set_xlim(plot_instructions["xlim"])
|
|
||||||
if "ylim" in plot_instructions.keys():
|
|
||||||
ax.set_ylim(plot_instructions["ylim"])
|
|
||||||
|
|
||||||
fig.savefig(output_folder +
|
|
||||||
"/spectrum_at_z={}_at_period={}.pdf".format(z_position, output_period))
|
|
||||||
|
|
||||||
|
|
||||||
def plotDensityVsZ(filename, path_to_species, plot_axis, output_period="LastSyncPeriod"):
|
|
||||||
density = densityVsZ(filename, path_to_species, output_period)
|
|
||||||
z_bins = zBinsDensityField(filename, path_to_species)
|
|
||||||
|
|
||||||
plot_bins, plot_datas = makeBarPlotData(
|
|
||||||
density[1:-1], z_bins[0:-1], z_bins[1:])
|
|
||||||
plot_axis.plot(plot_bins, plot_datas, label=str(path_to_species))
|
|
||||||
plot_axis.set_yscale("log")
|
|
||||||
plot_axis.set_xlabel(r"Distance to rear wall $z$ (m)")
|
|
||||||
plot_axis.set_ylabel(r"Density $n$ ($m^{-3}$)")
|
|
||||||
|
|
||||||
|
|
||||||
def plotAllDensityVsZ(filename, output_period, specie_keys, output_folder):
|
|
||||||
pst.setRcParams()
|
|
||||||
fig, ax = plt.subplots(figsize=pst.set_size('thesis'))
|
|
||||||
for key in specie_keys:
|
|
||||||
plotDensityVsZ(filename, key, ax, output_period)
|
|
||||||
|
|
||||||
ax.set_facecolor('#e7e7e7ff')
|
|
||||||
ax.grid(color='white')
|
|
||||||
ax.legend()
|
|
||||||
fig.savefig(output_folder + "/density_vs_z_at_period={}.pdf".format(output_period),
|
|
||||||
format='pdf', bbox_inches='tight')
|
|
||||||
|
|
||||||
|
|
||||||
def plotLongitudinalParticleCurrentVsZ(filename, path_to_species, plot_axis, output_period="LastSyncPeriod"):
|
|
||||||
current_in_z = longitudinalCurrentVsZ(
|
|
||||||
filename, path_to_species, output_period)
|
|
||||||
z_bins = zBinsDensityField(filename, 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_ylabel(r"Particle current $j$ ($m^{-2}s^{-1}$)")
|
|
||||||
|
|
||||||
|
|
||||||
def plotAllLongitudinalParticleCurrentVsZ(filename, output_period, specie_keys, output_folder):
|
|
||||||
pst.setRcParams()
|
|
||||||
fig, ax = plt.subplots(figsize=pst.set_size('thesis'))
|
|
||||||
for key in specie_keys:
|
|
||||||
plotLongitudinalParticleCurrentVsZ(filename, key, ax, output_period)
|
|
||||||
|
|
||||||
ax.set_facecolor('#e7e7e7ff')
|
|
||||||
ax.grid(color='white')
|
|
||||||
ax.legend()
|
|
||||||
fig.savefig(output_folder + "/longitudinal_particle_current_vs_z_at_period={}.pdf".format(output_period),
|
|
||||||
format='pdf', bbox_inches='tight')
|
|
||||||
|
|
||||||
|
|
||||||
def plotLongitudinalElectricCurrentVsZ(filename, path_to_species, plot_axis, output_period="LastSyncPeriod"):
|
|
||||||
current_in_z = longitudinalCurrentVsZ(
|
|
||||||
filename, path_to_species, output_period)*charge(filename, path_to_species)
|
|
||||||
z_bins = zBinsDensityField(filename, path_to_species)
|
|
||||||
plot_axis.plot(z_bins, current_in_z)
|
|
||||||
plot_axis.set_xlabel(r"Distance to rear wall $z$ (m)")
|
|
||||||
plot_axis.set_ylabel(r"Electric current $I$ ($A$)")
|
|
||||||
|
|
||||||
|
|
||||||
def printDeletionLoggerStats(filename, path_to_species, output_period="LastSyncPeriod"):
|
|
||||||
max_interactions = deletionsMaxInteractions(
|
|
||||||
filename, path_to_species, output_period)
|
|
||||||
max_time_alive = deletionsMaxTimeAlive(
|
|
||||||
filename, path_to_species, output_period)
|
|
||||||
recombinations = deletionsRecombination(
|
|
||||||
filename, path_to_species, output_period)
|
|
||||||
wall = deletionsWall(filename, path_to_species, output_period)
|
|
||||||
|
|
||||||
print("Deletion Logger stats for: " + str(path_to_species))
|
|
||||||
print("MaxTimeAlive: {}".format(max_time_alive))
|
|
||||||
print("MaxInteractions: {}".format(max_interactions))
|
|
||||||
print("Recombinations: {}".format(recombinations))
|
|
||||||
print("Wall hits: {}".format(wall))
|
|
||||||
|
|
||||||
|
|
||||||
def printAllDeletionLoggerStats(filename, specie_keys, output_period):
|
|
||||||
for key in specie_keys:
|
|
||||||
printDeletionLoggerStats(filename, key, output_period)
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
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)
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
import matplotlib
|
|
||||||
import matplotlib.colors as clr
|
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
from cycler import cycler
|
|
||||||
from matplotlib.colors import ListedColormap, LinearSegmentedColormap
|
|
||||||
|
|
||||||
|
|
||||||
def set_size(width, fraction=1, subplots=(1, 1)):
|
|
||||||
"""Set figure dimensions to avoid scaling in LaTeX.
|
|
||||||
|
|
||||||
Parameters
|
|
||||||
----------
|
|
||||||
width: float or string
|
|
||||||
Document width in points, or string of predined document type
|
|
||||||
fraction: float, optional
|
|
||||||
Fraction of the width which you wish the figure to occupy
|
|
||||||
subplots: array-like, optional
|
|
||||||
The number of rows and columns of subplots.
|
|
||||||
Returns
|
|
||||||
-------
|
|
||||||
fig_dim: tuple
|
|
||||||
Dimensions of figure in inches
|
|
||||||
"""
|
|
||||||
if width == 'thesis':
|
|
||||||
width_pt = 426.79135
|
|
||||||
elif width == 'beamer':
|
|
||||||
width_pt = 307.28987
|
|
||||||
else:
|
|
||||||
width_pt = width
|
|
||||||
|
|
||||||
# Width of figure (in pts)
|
|
||||||
fig_width_pt = width_pt * fraction
|
|
||||||
# Convert from pt to inches
|
|
||||||
inches_per_pt = 1 / 72.27
|
|
||||||
|
|
||||||
# Golden ratio to set aesthetic figure height
|
|
||||||
# https://disq.us/p/2940ij3
|
|
||||||
golden_ratio = (5**.5 - 1) / 2
|
|
||||||
|
|
||||||
# Figure width in inches
|
|
||||||
fig_width_in = fig_width_pt * inches_per_pt
|
|
||||||
# Figure height in inches
|
|
||||||
fig_height_in = fig_width_in * golden_ratio * (subplots[0] / subplots[1])
|
|
||||||
|
|
||||||
return (fig_width_in, fig_height_in)
|
|
||||||
|
|
||||||
|
|
||||||
def setRcParams():
|
|
||||||
#matplotlib.rcParams['text.usetex'] = True
|
|
||||||
#matplotlib.rcParams['text.latex.preamble'] = r'\usepackage{amsmath}'
|
|
||||||
|
|
||||||
#matplotlib.rcParams['pcolor.shading'] = 'auto'
|
|
||||||
|
|
||||||
matplotlib.rcParams['font.family'] = "serif"
|
|
||||||
matplotlib.rcParams['font.size'] = 10
|
|
||||||
matplotlib.rcParams['axes.labelsize'] = 10
|
|
||||||
|
|
||||||
matplotlib.rcParams['legend.fontsize'] = 8
|
|
||||||
matplotlib.rcParams['xtick.labelsize'] = 8
|
|
||||||
matplotlib.rcParams['ytick.labelsize'] = 8
|
|
||||||
matplotlib.rcParams['figure.autolayout'] = True
|
|
||||||
matplotlib.rcParams['figure.titlesize'] = 4
|
|
||||||
matplotlib.rcParams['axes.titlesize'] = 4
|
|
||||||
matplotlib.rcParams['lines.markersize'] = 4
|
|
||||||
|
|
||||||
# matplotlib.rcParams['axes.facecolor'] = '#e7e7e7ff'
|
|
||||||
#matplotlib.rcParams['axes.grid'] = True
|
|
||||||
#matplotlib.rcParams['grid.color'] = 'white'
|
|
||||||
|
|
||||||
#matplotlib.rcParams['figure.dpi'] = 240
|
|
||||||
|
|
||||||
# lines for colorblind
|
|
||||||
colour_blind_cycle = ['#377eb8', '#ff7f00', '#4daf4a',
|
|
||||||
'#f781bf', '#a65628', '#984ea3',
|
|
||||||
'#999999', '#e41a1c', '#dede00']
|
|
||||||
matplotlib.rcParams['axes.prop_cycle'] = cycler(color=colour_blind_cycle)
|
|
||||||
|
|
||||||
# colorblind cmap
|
|
||||||
colorblind_diverging = ['#ca0020', '#f4a582',
|
|
||||||
'#f7f7f7', '#92c5de', '#0571b0']
|
|
||||||
Cmap_Name = "mymap"
|
|
||||||
try:
|
|
||||||
mymap = plt.get_cmap(name=Cmap_Name)
|
|
||||||
except:
|
|
||||||
mymap = LinearSegmentedColormap.from_list(
|
|
||||||
Cmap_Name, colorblind_diverging)
|
|
||||||
plt.register_cmap(name=Cmap_Name, cmap=mymap)
|
|
||||||
|
|
||||||
matplotlib.rcParams['image.cmap'] = Cmap_Name
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
# Compiler
|
|
||||||
SCXX = g++
|
|
||||||
MPICXX = mpic++
|
|
||||||
|
|
||||||
COMPILER=$(MPICXX)
|
|
||||||
|
|
||||||
# Compiler Flags
|
|
||||||
COMPILER_FLAGS = -std=c++11 -O3 -march=native
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
# Debugging
|
|
||||||
DO_DEBUGGING = false
|
|
||||||
DEBUG_LEVEL = 0
|
|
||||||
|
|
||||||
# Timer
|
|
||||||
USE_TIMER = false
|
|
||||||
|
|
||||||
# Catch
|
|
||||||
CATCH_DIR = $(HOMEBASE)/external/catch
|
|
||||||
CATCH_INCLUDES = -I$(CATCH_DIR)
|
|
||||||
|
|
||||||
|
|
||||||
# Blitz
|
|
||||||
MAKE_BLITZ = false
|
|
||||||
|
|
||||||
ifeq ($(MAKE_BLITZ), true)
|
|
||||||
BLITZ_DIR = $(HOMEBASE)/external/blitz/build
|
|
||||||
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_LIBS = -lblitz -lm -L$(BLITZ_LIB_DIR)
|
|
||||||
|
|
||||||
# HDF5
|
|
||||||
#HDF5_DIR = /usr/include/hdf5/
|
|
||||||
HDF5P_INC_DIR = /usr/include/hdf5/openmpi/
|
|
||||||
HDF5P_LIB_DIR = /usr/lib/x86_64-linux-gnu/hdf5/openmpi/
|
|
||||||
|
|
||||||
HDF5P_INCLUDES = -I$(HDF5P_INC_DIR)
|
|
||||||
HDF5P_LIBRARIES = -L$(HDF5P_LIB_DIR) -lz -lhdf5_hl -lhdf5
|
|
||||||
|
|
||||||
# Jansson
|
|
||||||
MAKE_JANSSON = false
|
|
||||||
|
|
||||||
ifeq ($(MAKE_JANSSON), true)
|
|
||||||
JANSSON_INC_DIR = $(HOMEBASE)/external/jansson/build/include
|
|
||||||
JANSSON_LIB_DIR = $(HOMEBASE)/external/jansson/build/lib
|
|
||||||
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)
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
import numpy as np
|
|
||||||
import pandas as pd
|
|
||||||
import glob
|
|
||||||
import h5py as h5py
|
|
||||||
|
|
||||||
from os.path import basename
|
|
||||||
|
|
||||||
|
|
||||||
def readElsepaFilenames(folder):
|
|
||||||
data_files = glob.glob(folder + "*.dat")
|
|
||||||
elsepa_files = []
|
|
||||||
for file in data_files:
|
|
||||||
begin_filename = len(folder)
|
|
||||||
if file[begin_filename:begin_filename+3] == "dcs":
|
|
||||||
elsepa_files.append(file)
|
|
||||||
return elsepa_files
|
|
||||||
|
|
||||||
|
|
||||||
def createEnergyFromElsepaFilename(filename):
|
|
||||||
base_name = basename(filename)
|
|
||||||
return float(base_name[4] + "." + base_name[6:12])
|
|
||||||
|
|
||||||
|
|
||||||
def readEnergiesFromElsepaFilenames(filenames):
|
|
||||||
energies = []
|
|
||||||
for filename in filenames:
|
|
||||||
energies.append(createEnergyFromElsepaFilename(filename))
|
|
||||||
return np.sort(energies)
|
|
||||||
|
|
||||||
|
|
||||||
def readAnglesFromElsepaFile(filename):
|
|
||||||
namelist = ["theta", "mu", "sig_tot", "sig_totincoh", "Sherman"]
|
|
||||||
dataframe = pd.read_csv(filename, delim_whitespace=True,
|
|
||||||
header=None, skiprows=24, names=namelist)
|
|
||||||
return dataframe.theta/360*2*np.pi
|
|
||||||
|
|
||||||
|
|
||||||
def readCrossSectionFromElsepaFile(filename):
|
|
||||||
namelist = ["Theta", "Mu", "sig_tot", "sig_totincoh", "Sherman"]
|
|
||||||
dataframe = pd.read_csv(filename, delim_whitespace=True,
|
|
||||||
header=None, skiprows=24, names=namelist)
|
|
||||||
return dataframe.sig_tot*1E-4
|
|
||||||
|
|
||||||
|
|
||||||
def readAllCrossSectionsFromElsepa(filenames, energies, angles):
|
|
||||||
cross_sections = np.zeros(shape=(energies.size, angles.size))
|
|
||||||
|
|
||||||
for filename in filenames:
|
|
||||||
energy = createEnergyFromElsepaFilename(filename)
|
|
||||||
energy_index = np.where(energies == energy)
|
|
||||||
cross_sections[energy_index,
|
|
||||||
:] = readCrossSectionFromElsepaFile(filename)
|
|
||||||
return cross_sections
|
|
||||||
|
|
||||||
|
|
||||||
def writeData(energies, angles, cross_sections, output_filename):
|
|
||||||
file = h5py.File(output_filename, "w")
|
|
||||||
|
|
||||||
file.create_dataset("energies(eV)", data=energies)
|
|
||||||
file.create_dataset("angles(rad)", data=angles)
|
|
||||||
file.create_dataset("cross_sections(m-2)", data=cross_sections)
|
|
||||||
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
|
|
||||||
elsepa_folder = "./elsepa/simulation_output/"
|
|
||||||
output_filename = "./eT2_elastic_cross_section_scattering_angle.h5"
|
|
||||||
|
|
||||||
filenames = readElsepaFilenames(elsepa_folder)
|
|
||||||
angles = readAnglesFromElsepaFile(filenames[0])
|
|
||||||
energies = readEnergiesFromElsepaFilenames(filenames)
|
|
||||||
cross_sections = readAllCrossSectionsFromElsepa(
|
|
||||||
filenames, energies, angles)
|
|
||||||
|
|
||||||
writeData(energies, angles, cross_sections, output_filename)
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
import numpy as np
|
|
||||||
import scipy.optimize as optimization
|
|
||||||
import pandas as pd
|
|
||||||
import h5py as h5py
|
|
||||||
|
|
||||||
|
|
||||||
def readElsepaData(filename):
|
|
||||||
namelist = ["E", "sig_tot", "sig_1", "sig_2",
|
|
||||||
"sig_tot,corr", "sig_1,corr", "sig_2,corr"]
|
|
||||||
TCS_elsepa = pd.read_csv(
|
|
||||||
filename, delim_whitespace=True, header=None, skiprows=12, names=namelist)
|
|
||||||
TCS_elsepa = TCS_elsepa.iloc[:, 0:2]
|
|
||||||
TCS_elsepa.iloc[:, 1] = TCS_elsepa.iloc[:, 1]*1e-4
|
|
||||||
return TCS_elsepa
|
|
||||||
|
|
||||||
|
|
||||||
def readYoonData(filename):
|
|
||||||
namelist = ["E", "sig_tot"]
|
|
||||||
TCS_yoon = pd.read_csv(filename, sep='\t',
|
|
||||||
header=None, skiprows=3, names=namelist)
|
|
||||||
return TCS_yoon
|
|
||||||
|
|
||||||
|
|
||||||
def fitExpoential(data, upper_energy_limit=1):
|
|
||||||
data = data[data.E < upper_energy_limit]
|
|
||||||
# y = A * x^B
|
|
||||||
# return (A, B)
|
|
||||||
px = np.log10(data.E)
|
|
||||||
py = np.log10(data.sig_tot)
|
|
||||||
par = np.polyfit(px, py, 1)
|
|
||||||
|
|
||||||
def fitted_function(energy):
|
|
||||||
return 10**par[1] * (energy**par[0])
|
|
||||||
|
|
||||||
return fitted_function
|
|
||||||
|
|
||||||
|
|
||||||
def generateEnergies(max_energy):
|
|
||||||
energies = []
|
|
||||||
prefactor = np.array([1, 1.2, 1.4, 1.6, 1.8, 2., 2.5,
|
|
||||||
3., 3.5, 4., 5., 6., 7., 8., 9.])
|
|
||||||
for exponent in range(-5, 3):
|
|
||||||
for x in prefactor:
|
|
||||||
energies.append(x*10**exponent)
|
|
||||||
energies = np.array(energies)
|
|
||||||
energies = energies[energies < max_energy]
|
|
||||||
return energies
|
|
||||||
|
|
||||||
|
|
||||||
def generateCrossSections(energies, fit_function):
|
|
||||||
cross_sections = fit_function(energies)
|
|
||||||
dataframe = {'E': energies, 'sig_tot': cross_sections}
|
|
||||||
return pd.DataFrame(data=dataframe)
|
|
||||||
|
|
||||||
|
|
||||||
def generateConcatinatedTCS(elsepa_filename, yoon_filename):
|
|
||||||
TCS_elsepa = readElsepaData(elsepa_filename)
|
|
||||||
TCS_yoon = readYoonData(yoon_filename)
|
|
||||||
|
|
||||||
yoon_fit = fitExpoential(TCS_yoon, upper_energy_limit=1)
|
|
||||||
|
|
||||||
yoon_fit_energies = generateEnergies(TCS_yoon.E.min())
|
|
||||||
TCS_yoon_extrapolated = generateCrossSections(yoon_fit_energies, yoon_fit)
|
|
||||||
|
|
||||||
TCS_concat = TCS_yoon_extrapolated
|
|
||||||
TCS_concat = TCS_concat.append(TCS_yoon)
|
|
||||||
TCS_concat = TCS_concat.append(TCS_elsepa[TCS_elsepa.E > TCS_yoon.E.max()])
|
|
||||||
return TCS_concat
|
|
||||||
|
|
||||||
|
|
||||||
def writeTCSData(TCS_concat, output_filename):
|
|
||||||
file = h5py.File(output_filename, "w")
|
|
||||||
|
|
||||||
file.create_dataset("energies(eV)", data=TCS_concat.E)
|
|
||||||
file.create_dataset("cross_sections(m-2)", data=TCS_concat.sig_tot)
|
|
||||||
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
|
|
||||||
elsepa_filename = "./elsepa/simulation_output/tcstable.dat"
|
|
||||||
yoon_filename = "./yoon/yoon_TCS_elastic.dat"
|
|
||||||
output_filename = "./eT2_elastic_cross_section_total.h5"
|
|
||||||
|
|
||||||
TCS_concat = generateConcatinatedTCS(elsepa_filename, yoon_filename)
|
|
||||||
writeTCSData(TCS_concat, output_filename)
|
|
||||||
BIN
Binary file not shown.
Binary file not shown.
@@ -1,58 +0,0 @@
|
|||||||
import numpy as np
|
|
||||||
import h5py as h5py
|
|
||||||
import pandas as pd
|
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
|
|
||||||
|
|
||||||
def writeData(data, output_filename):
|
|
||||||
file = h5py.File(output_filename, "w")
|
|
||||||
|
|
||||||
file.create_dataset("z_position(m)", data=data[:, 0])
|
|
||||||
file.create_dataset("n(m3)", data=data[:, 1])
|
|
||||||
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
|
|
||||||
def createApproximateDensity():
|
|
||||||
# katrin z position, n (approximate from Kuckert)
|
|
||||||
# "Modelling of gas dynamical properties of the KATRIN tritium source and
|
|
||||||
# implications for the neutrino mass measurement"
|
|
||||||
# Laura Kuckert, Florian Heizmann, Guido Drexlin, Ferenc Glück,
|
|
||||||
# Markus Hötzel, Marco Kleesiek, Felix Sharipov, Kathrin Valerius
|
|
||||||
|
|
||||||
data = [[-828.5, 2.698571014239288e+17]] # RW
|
|
||||||
# first pumpport left side
|
|
||||||
data = np.vstack([data, [-672.95, 1.0599125362642563e+18]])
|
|
||||||
data = np.vstack([data, [-645.55, 1.186476080774995e+18]]
|
|
||||||
) # first pumpport right side
|
|
||||||
# second pumpport left side
|
|
||||||
data = np.vstack([data, [-529.45, 1.1388358318927706e+19]])
|
|
||||||
# second pumpport right side
|
|
||||||
data = np.vstack([data, [-502.05, 1.6069200896901196e+19]])
|
|
||||||
data = np.vstack([data, [0, 6.382773464569297e+20]]) # Inlet
|
|
||||||
|
|
||||||
# mirrored on the other side
|
|
||||||
data = np.vstack([data, [828.5, 2.698571014239288e+17]]) # DPS
|
|
||||||
data = np.vstack([data, [672.95, 1.0599125362642563e+18]]
|
|
||||||
) # third pumpport left side
|
|
||||||
data = np.vstack([data, [645.55, 1.186476080774995e+18]]
|
|
||||||
) # third pumpport right side
|
|
||||||
data = np.vstack([data, [529.45, 1.1388358318927706e+19]]
|
|
||||||
) # fourth pumpport left side
|
|
||||||
data = np.vstack([data, [502.05, 1.6069200896901196e+19]]
|
|
||||||
) # fourth pumpport right side
|
|
||||||
|
|
||||||
z_rw = -828.5
|
|
||||||
|
|
||||||
data[:, 0] += np.abs(z_rw)
|
|
||||||
data[:, 0] /= 100
|
|
||||||
data[:, 1] /= 6.382773464569297e+20
|
|
||||||
|
|
||||||
data = data[data[:, 0].argsort()]
|
|
||||||
return data
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
|
|
||||||
output_filename = "./T2_n_vs_z_kuckert_approximated_relative.h5"
|
|
||||||
writeData(createApproximateDensity(), output_filename)
|
|
||||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -1,42 +0,0 @@
|
|||||||
import numpy as np
|
|
||||||
import h5py as h5py
|
|
||||||
import pandas as pd
|
|
||||||
|
|
||||||
|
|
||||||
def writeData(data, output_filename):
|
|
||||||
file = h5py.File(output_filename, "w")
|
|
||||||
|
|
||||||
file.create_dataset("z_position(m)", data=data[:, 0])
|
|
||||||
file.create_dataset("B(T)", data=data[:, 1])
|
|
||||||
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
|
|
||||||
def createApproximateMagneticField(filename_z_position, filename_B_field):
|
|
||||||
z = np.genfromtxt(filename_z_position, dtype=float,
|
|
||||||
delimiter=",", usecols=(0))
|
|
||||||
Bz = np.genfromtxt(filename_B_field, dtype=float,
|
|
||||||
delimiter=",", usecols=(0))
|
|
||||||
|
|
||||||
Bz *= -1
|
|
||||||
|
|
||||||
deltaz = 500 # use only every 500th datapoint
|
|
||||||
position_rw = 47.2
|
|
||||||
z_data = z[0::deltaz] + position_rw
|
|
||||||
Bz_data = Bz[0::deltaz]
|
|
||||||
|
|
||||||
Bz_data = Bz_data[z_data > 0]
|
|
||||||
z_data = z_data[z_data > 0]
|
|
||||||
|
|
||||||
data = np.column_stack((z_data, Bz_data))
|
|
||||||
|
|
||||||
return data
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
|
|
||||||
output_filename = "./B_vs_z_kassiopeia_approximated.h5"
|
|
||||||
filename_z_position = "./z_positions.dat"
|
|
||||||
filename_B_field = "./Bz.dat"
|
|
||||||
writeData(createApproximateMagneticField(
|
|
||||||
filename_z_position, filename_B_field), output_filename)
|
|
||||||
File diff suppressed because one or more lines are too long
Binary file not shown.
@@ -1,64 +0,0 @@
|
|||||||
import numpy as np
|
|
||||||
import h5py as h5py
|
|
||||||
import pandas as pd
|
|
||||||
|
|
||||||
|
|
||||||
def writeData(data, output_filename):
|
|
||||||
file = h5py.File(output_filename, "w")
|
|
||||||
|
|
||||||
file.create_dataset("z_position(m)", data=data[:, 0])
|
|
||||||
file.create_dataset("vz(ms)", data=data[:, 1])
|
|
||||||
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
|
|
||||||
def createApproximateVelocity():
|
|
||||||
# katrin z position, vz (approximate from Kuckert)
|
|
||||||
# "Modelling of gas dynamical properties of the KATRIN tritium source and
|
|
||||||
# implications for the neutrino mass measurement"
|
|
||||||
# Laura Kuckert, Florian Heizmann, Guido Drexlin, Ferenc Glück,
|
|
||||||
# Markus Hötzel, Marco Kleesiek, Felix Sharipov, Kathrin Valeriusa
|
|
||||||
|
|
||||||
data = [[-828.5, -5]] # RW
|
|
||||||
data = np.vstack([data, [-672.95, 0]]) # first pumpport left side
|
|
||||||
data = np.vstack([data, [-645.55, -100]]) # first pumpport right side
|
|
||||||
data = np.vstack([data, [-529.45, -5]]) # second pumpport left side
|
|
||||||
data = np.vstack([data, [-502.05, -100]]) # second pumpport right side
|
|
||||||
data = np.vstack([data, [-475, -71.32]])
|
|
||||||
data = np.vstack([data, [-450, -40.47]])
|
|
||||||
data = np.vstack([data, [-425, -29.75]])
|
|
||||||
data = np.vstack([data, [-400, -24.35]])
|
|
||||||
data = np.vstack([data, [-300, -15.680]])
|
|
||||||
data = np.vstack([data, [-200, -12.36]])
|
|
||||||
data = np.vstack([data, [-100, -10.5069]])
|
|
||||||
data = np.vstack([data, [-10, -9.2]])
|
|
||||||
data = np.vstack([data, [0, 0]]) # Inlet
|
|
||||||
|
|
||||||
# mirrored on the other side
|
|
||||||
data = np.vstack([data, [828.5, 5]]) # RW
|
|
||||||
data = np.vstack([data, [672.95, 0]]) # first pumpport left side
|
|
||||||
data = np.vstack([data, [645.55, 100]]) # first pumpport right side
|
|
||||||
data = np.vstack([data, [529.45, 5]]) # second pumpport left side
|
|
||||||
data = np.vstack([data, [502.05, 100]]) # second pumpport right side
|
|
||||||
data = np.vstack([data, [475, 71.32]])
|
|
||||||
data = np.vstack([data, [450, 40.47]])
|
|
||||||
data = np.vstack([data, [425, 29.75]])
|
|
||||||
data = np.vstack([data, [400, 24.35]])
|
|
||||||
data = np.vstack([data, [300, 15.680]])
|
|
||||||
data = np.vstack([data, [200, 12.36]])
|
|
||||||
data = np.vstack([data, [100, 10.5069]])
|
|
||||||
data = np.vstack([data, [10, 9.2]])
|
|
||||||
|
|
||||||
z_rw = -828.5
|
|
||||||
|
|
||||||
data[:, 0] += np.abs(z_rw)
|
|
||||||
data[:, 0] /= 100
|
|
||||||
|
|
||||||
data = data[data[:, 0].argsort()]
|
|
||||||
return data
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
|
|
||||||
output_filename = "./T2_vz_vs_z_kuckert_approximated.h5"
|
|
||||||
writeData(createApproximateVelocity(), output_filename)
|
|
||||||
File diff suppressed because it is too large
Load Diff
Vendored
-35
@@ -1,35 +0,0 @@
|
|||||||
dummy: all
|
|
||||||
# Auf Solaris muss blitz mit dem Sun Studio Compiler gebaut werden
|
|
||||||
# der ist zwar scheisse, funktioniert mit blitz aber. :)
|
|
||||||
ZIP = tar
|
|
||||||
|
|
||||||
|
|
||||||
BLITZ_VERSION = 1.0.2
|
|
||||||
|
|
||||||
NAME_TAR = blitz-$(BLITZ_VERSION).tar.gz
|
|
||||||
NAME = blitz-$(BLITZ_VERSION)
|
|
||||||
|
|
||||||
BLITZ_FOLDER=external/blitz
|
|
||||||
|
|
||||||
|
|
||||||
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)
|
|
||||||
mkdir -p build
|
|
||||||
mkdir -p build/include
|
|
||||||
mkdir -p build/lib
|
|
||||||
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) && $(MAKE)
|
|
||||||
cd $(NAME) && $(MAKE) lib
|
|
||||||
cd $(NAME) && $(MAKE) install
|
|
||||||
|
|
||||||
clean:
|
|
||||||
-rm -rf $(HOMEBASE)/$(BLITZ_FOLDER)/$(NAME)
|
|
||||||
-rm -rf $(HOMEBASE)/$(BLITZ_FOLDER)/build
|
|
||||||
Vendored
-32
@@ -1,32 +0,0 @@
|
|||||||
dummy: all
|
|
||||||
# Auf Solaris muss blitz mit dem Sun Studio Compiler gebaut werden
|
|
||||||
# der ist zwar scheisse, funktioniert mit blitz aber. :)
|
|
||||||
ZIP = tar
|
|
||||||
|
|
||||||
|
|
||||||
JANSSON_VERSION = 2.14
|
|
||||||
|
|
||||||
NAME = jansson-$(JANSSON_VERSION)
|
|
||||||
NAME_TAR = $(NAME).tar.gz
|
|
||||||
|
|
||||||
JANSSON_FOLDER=external/jansson
|
|
||||||
|
|
||||||
all:
|
|
||||||
ifneq ("$(wildcard $(NAME_TAR))","")
|
|
||||||
@echo "Archive already present"
|
|
||||||
else
|
|
||||||
@echo "Downloading"
|
|
||||||
wget https://github.com/akheron/jansson/releases/download/v$(JANSSON_VERSION)/$(NAME_TAR)
|
|
||||||
endif
|
|
||||||
$(ZIP) -xf $(NAME_TAR)
|
|
||||||
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:
|
|
||||||
-rm -rf $(HOMEBASE)/$(JANSSON_FOLDER)/$(NAME)
|
|
||||||
-rm -rf $(HOMEBASE)/$(JANSSON_FOLDER)/build
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
#ifndef HDF5_READER_H
|
|
||||||
#define HDF5_READER_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include "blitz/array.h"
|
|
||||||
|
|
||||||
// class for reading data from a hdf5-file
|
|
||||||
class Hdf5Reader {
|
|
||||||
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);
|
|
||||||
// Constructor: taking a string of the absolute path to the file (string is not changed)
|
|
||||||
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);
|
|
||||||
// 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);
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::string absolute_filename_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* HDF5_READER_H */
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
#ifndef HDF5_WRITER_H
|
|
||||||
#define HDF5_WRITER_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
#include "blitz/array.h"
|
|
||||||
|
|
||||||
// Class to handle hdf5 output
|
|
||||||
class Hdf5Writer {
|
|
||||||
public:
|
|
||||||
// the ".h5" is appened to the filename by default
|
|
||||||
Hdf5Writer(std::string directory = "./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, 2>& data, std::string path);
|
|
||||||
void write(const blitz::Array<double, 3>& data, std::string path);
|
|
||||||
void write(const blitz::Array<double, 4>& data, std::string path);
|
|
||||||
void write(const blitz::Array<long int, 4>& data, std::string path);
|
|
||||||
void write(const blitz::TinyVector<double, 3>& data, std::string path);
|
|
||||||
void write(const blitz::TinyVector<int, 3>& data, std::string path);
|
|
||||||
void write(const std::vector<double>& data, std::string path);
|
|
||||||
void write(int data, std::string path);
|
|
||||||
void write(long int data, std::string path);
|
|
||||||
void write(double data, std::string path);
|
|
||||||
void write(const std::string& data, std::string path);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::string absolute_filename_;
|
|
||||||
void createFolder(std::string directory);
|
|
||||||
void createFile(std::string absolute_filename);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* HDF5_WRITER_H */
|
|
||||||
@@ -1,162 +0,0 @@
|
|||||||
#ifndef SIMULATION_OUTPUT_H
|
|
||||||
#define SIMULATION_OUTPUT_H
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
#include "IO/hdf5_writer.h"
|
|
||||||
|
|
||||||
// defined in "simulation/density_field.h"
|
|
||||||
class DynamicDensityField;
|
|
||||||
//class CurrentBorder;
|
|
||||||
// defined in "simulation/parameter.h"
|
|
||||||
class Parameter;
|
|
||||||
// defined in "simulation/current_collector.h"
|
|
||||||
class CurrentCollector;
|
|
||||||
// defined in "simulation/logger.h"
|
|
||||||
class DeletionLogger;
|
|
||||||
|
|
||||||
// defined in "simulation/species.h"
|
|
||||||
namespace species {
|
|
||||||
class TrackedSpecie;
|
|
||||||
enum class ImplementedSpecies;
|
|
||||||
}; // namespace species
|
|
||||||
|
|
||||||
// structure to store information about output types
|
|
||||||
struct OutputTask {
|
|
||||||
// name of the particle species that output should be performed for
|
|
||||||
std::string specie_name;
|
|
||||||
// if true earlier output is overwritten
|
|
||||||
bool overwrite_last;
|
|
||||||
// how many cpu synchronization steps are inbetween two output steps
|
|
||||||
int intervall;
|
|
||||||
// selector if each or only first cpu should write can be added here
|
|
||||||
};
|
|
||||||
|
|
||||||
// class to handle output from the simulation
|
|
||||||
class SimulationOutput {
|
|
||||||
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,
|
|
||||||
const std::string& output_filename);
|
|
||||||
|
|
||||||
// add OutputTask for the output of the (dynamic) density field
|
|
||||||
void addDensityFieldOutput(OutputTask task);
|
|
||||||
// add OutputTask for the output of the current collector
|
|
||||||
void addCurrentBorderOutput(OutputTask task);
|
|
||||||
// add OutputTask for the output of the deletion logger
|
|
||||||
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(
|
|
||||||
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(
|
|
||||||
int cpu_sync,
|
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>& species);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::vector<OutputTask> tasks_density_fields_;
|
|
||||||
std::vector<OutputTask> tasks_current_collector_;
|
|
||||||
std::vector<OutputTask> tasks_deletion_logger_;
|
|
||||||
|
|
||||||
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,
|
|
||||||
std::string species_path,
|
|
||||||
int cpu_sync,
|
|
||||||
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);
|
|
||||||
// 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);
|
|
||||||
// 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);
|
|
||||||
// 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,
|
|
||||||
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);
|
|
||||||
|
|
||||||
// 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,
|
|
||||||
std::string species_path,
|
|
||||||
int cpu_sync,
|
|
||||||
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,
|
|
||||||
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);
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
// 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,
|
|
||||||
std::string species_path,
|
|
||||||
int cpu_sync,
|
|
||||||
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);
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
// 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);
|
|
||||||
// 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 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,
|
|
||||||
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,
|
|
||||||
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,
|
|
||||||
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,
|
|
||||||
std::string path_to_field);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* SIMULATION_OUTPUT_H */
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
#ifndef T2_BETA_DECAY_H
|
|
||||||
#define T2_BETA_DECAY_H
|
|
||||||
|
|
||||||
namespace T2BetaDecay {
|
|
||||||
// tritium decay constant (1/s)
|
|
||||||
static const double lambda_T2 = 1.78405E-9;
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* T2_BETA_DECAY_H */
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#ifndef IONIZATION_CONSTANTS_H
|
|
||||||
#define IONIZATION_CONSTANTS_H
|
|
||||||
|
|
||||||
namespace ionization {
|
|
||||||
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_ground = 18.15; // (eV)
|
|
||||||
} // namespace ionization
|
|
||||||
|
|
||||||
#endif /* IONIZATION_CONSTANTS_H */
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
#ifndef PHYSICAL_CONSTANTS_H
|
|
||||||
#define PHYSICAL_CONSTANTS_H
|
|
||||||
|
|
||||||
// Constants in CGS units
|
|
||||||
namespace CGS {
|
|
||||||
static const double me = 9.1094e-28; // Electron mass (g)
|
|
||||||
static const double mp = 1.6726231e-24; // Proton mass (g)
|
|
||||||
static const double mpi0 = 2.406175207e-25; // Mass of uncharged pion (g)
|
|
||||||
static const double e = 4.8032068e-10; // Elementary charge (statcoulomb)
|
|
||||||
static const double c = 29979245800.; // Speed of light (cm/s)
|
|
||||||
static const double eps0 = 1; // Permitivity of vacuum
|
|
||||||
static const double mu0 = 1; // Permeability of vacuum
|
|
||||||
static const double thomcs = 6.65245e-25; // Thomson cross section (cm^2)
|
|
||||||
static const double h = 6.6260755e-27; // Planck constant (erg sec)
|
|
||||||
static const double hbar =
|
|
||||||
1.054572669e-27; // reduced Planck constant (erg sec)
|
|
||||||
static const double k = 1.380658e-16; // Boltzmann constant (erg / K)
|
|
||||||
static const double r0 =
|
|
||||||
2.8179e-13; // Classical electron radius / Thomson scattering length (cm)
|
|
||||||
static const double G = 6.67428e-8; // Gravitational constant cm^3/(g sec^2)
|
|
||||||
|
|
||||||
}; // namespace CGS
|
|
||||||
|
|
||||||
// Constants in SI (default)
|
|
||||||
namespace SI {
|
|
||||||
static const double me = 9.1094e-31; // Electron mass (kg)
|
|
||||||
static const double mp = 1.6726e-27; // Proton mass (kg)
|
|
||||||
static const double mpi0 = 2.406176e-28; // Mass of uncharged pion (kg)
|
|
||||||
static const double e = 1.6022e-19; // Elementary charge (C)
|
|
||||||
static const double c = 299792458.; // Speed of light (m/s)
|
|
||||||
static const double eps0 = 8.854187817620e-12; // Permitivity of vacuum (F / m)
|
|
||||||
static const double mu0 = 1.2566370614e-6; // Permeability of vacuum (H / m)
|
|
||||||
static const double thomcs = 6.65245e-29; // Thomson cross section (m^2)
|
|
||||||
static const double h = 6.6260755e-34; // Planck constant (J s)
|
|
||||||
static const double hbar = 1.054572669e-34; // reduced Planck constant (J s)
|
|
||||||
static const double k = 1.380658e-23; // Boltzmann constant (J / K)
|
|
||||||
static const double r0 =
|
|
||||||
2.8179e-15; // Classical electron radius / Thomson scattering length (m)
|
|
||||||
static const double G = 6.67428e-11; // Gravitational constant m^3/(kg s^2)
|
|
||||||
static const double u = 1.66053906660E-27; // atomic mass unit (kg)
|
|
||||||
}; // namespace SI
|
|
||||||
|
|
||||||
// Natural Units with e = c = k = me = 1 (Stoney units)
|
|
||||||
namespace Naturalunits {
|
|
||||||
static const double me = 1; // Electron mass
|
|
||||||
static const double mp = 1836.15; // Proton mass
|
|
||||||
static const double mpi0 = 264.14; // Mass of uncharged pion
|
|
||||||
static const double e = 1; // Elementary charge
|
|
||||||
static const double c = 1; // Speed of light
|
|
||||||
static const double eps0 = .07957747154594766788; // Permitivity of vacuum
|
|
||||||
static const double mu0 = 12.56637061435917295376; // Permeability of vacuum
|
|
||||||
static const double thomcs = 3.488e43; // Thomson cross section
|
|
||||||
static const double h = 861.022579738; // Planck constant
|
|
||||||
static const double hbar = 137.035999679; // reduced Planck constant
|
|
||||||
static const double k = 1; // Boltzmann constant
|
|
||||||
static const double r0 = 2.0405e21; // Classical electron radius
|
|
||||||
static const double G = 1; // Gravitational constant
|
|
||||||
|
|
||||||
// l = e^2 / c^2 me
|
|
||||||
// t = e^2 / c^3 me
|
|
||||||
// T = = me c^2 / k
|
|
||||||
}; // namespace Naturalunits
|
|
||||||
|
|
||||||
namespace HEPunits {
|
|
||||||
static const double me = 511e3; // Electron mass (eV)
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace UnitConversion {
|
|
||||||
const double JouleToeV = 1. / SI::e;
|
|
||||||
const double eVToJoule = SI::e;
|
|
||||||
const double KToeV = 8.61732814974056E-05;
|
|
||||||
}; // namespace UnitConversion
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
#ifndef SIM_CONSTANTS_H
|
|
||||||
#define SIM_CONSTANTS_H
|
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
|
|
||||||
// constants due to numercial accuracy
|
|
||||||
namespace SimConstants {
|
|
||||||
// minimal value for a cross section
|
|
||||||
static const double minimal_cross_section =
|
|
||||||
std::numeric_limits<double>::min() * 1E5;
|
|
||||||
// minimal value for a cross section scaled by density
|
|
||||||
static const double minimal_macroscopic_cross_section =
|
|
||||||
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;
|
|
||||||
// double1 == double2 <=> abs(double1 - double2) <= compare_epsilon
|
|
||||||
static const double compare_epsilon = 1E-10;
|
|
||||||
|
|
||||||
} // namespace SimConstants
|
|
||||||
|
|
||||||
#endif /* SIM_CONSTANTS_H */
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
#ifndef FUNCTIONS_H
|
|
||||||
#define FUNCTIONS_H
|
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
// R^1 -> R^1 mappings
|
|
||||||
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::vector<double> values);
|
|
||||||
|
|
||||||
// return a function, that always returns the constant value "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::vector<std::function<double(double)>> functions);
|
|
||||||
}; // namespace D1ToD1
|
|
||||||
|
|
||||||
// R^3 -> R^1 mappings
|
|
||||||
namespace D3ToD1 {
|
|
||||||
// return a function, that always returns the constant value "constant"
|
|
||||||
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)> fi,
|
|
||||||
std::function<double(double)> fj,
|
|
||||||
std::function<double(double)> fk);
|
|
||||||
|
|
||||||
}; // namespace D3ToD1
|
|
||||||
|
|
||||||
#endif /* FUNCTIONS_H */
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
#ifndef BINNING_GENERATOR_H
|
|
||||||
#define BINNING_GENERATOR_H
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "blitz/array.h"
|
|
||||||
#include "simulation/energy_binning.h"
|
|
||||||
#include "simulation/parameter.h"
|
|
||||||
#include "simulation/position_binning.h"
|
|
||||||
|
|
||||||
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);
|
|
||||||
// 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(
|
|
||||||
Parameter& parameter,
|
|
||||||
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);
|
|
||||||
// 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(
|
|
||||||
Parameter& parameter,
|
|
||||||
json_path& path_to_binning);
|
|
||||||
|
|
||||||
}; // namespace generator
|
|
||||||
|
|
||||||
#endif /* BINNING_GENERATOR_H */
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
#ifndef CURRENT_COLLECTOR_GENERATOR_H
|
|
||||||
#define CURRENT_COLLECTOR_GENERATOR_H
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "simulation/current_collector.h"
|
|
||||||
#include "simulation/jansson_additionals.h"
|
|
||||||
#include "simulation/parameter.h"
|
|
||||||
#include "simulation/timer.h"
|
|
||||||
|
|
||||||
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(
|
|
||||||
Parameter& parameter,
|
|
||||||
const json_path& path_to_collector,
|
|
||||||
std::shared_ptr<Timer>& timer);
|
|
||||||
};
|
|
||||||
#endif /* CURRENT_COLLECTOR_GENERATOR_H */
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
#ifndef DENSITY_FIELD_GENERATOR_H
|
|
||||||
#define DENSITY_FIELD_GENERATOR_H
|
|
||||||
|
|
||||||
#include "simulation/density_field.h"
|
|
||||||
#include "simulation/jansson_additionals.h"
|
|
||||||
#include "simulation/parameter.h"
|
|
||||||
#include "simulation/timer.h"
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
// 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(
|
|
||||||
Parameter& parameter,
|
|
||||||
const json_path& path_to_field,
|
|
||||||
std::shared_ptr<Timer>& timer);
|
|
||||||
|
|
||||||
}; // namespace generator
|
|
||||||
|
|
||||||
#endif /* DENSITY_FIELD_GENERATOR_H */
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
#ifndef DRIFT_VELOCITY_GENERATOR_H
|
|
||||||
#define DRIFT_VELOCITY_GENERATOR_H
|
|
||||||
|
|
||||||
#include "simulation/drift_velocity.h"
|
|
||||||
#include "simulation/jansson_additionals.h"
|
|
||||||
#include "simulation/parameter.h"
|
|
||||||
|
|
||||||
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(
|
|
||||||
Parameter& parameter,
|
|
||||||
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 */
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
#ifndef ELECTRIC_FIELD_GENERATOR_H
|
|
||||||
#define ELECTRIC_FIELD_GENERATOR_H
|
|
||||||
|
|
||||||
#include "simulation/electromagnetic_field.h"
|
|
||||||
#include "simulation/parameter.h"
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
}; // namespace generator
|
|
||||||
|
|
||||||
#endif /* ELECTRIC_FIELD_GENERATOR_H */
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
#ifndef ENERGY_DISTRIBUTION_FUNCTION_GENERATOR_H
|
|
||||||
#define ENERGY_DISTRIBUTION_FUNCTION_GENERATOR_H
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "simulation/energy_distribution.h"
|
|
||||||
#include "simulation/jansson_additionals.h"
|
|
||||||
#include "simulation/parameter.h"
|
|
||||||
|
|
||||||
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(
|
|
||||||
Parameter& parameter,
|
|
||||||
const json_path& path_to_function);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* ENERGY_DISTRIBUTION_FUNCTION_GENERATOR_H */
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
#ifndef FUNCTION_GENERATOR_H
|
|
||||||
#define FUNCTION_GENERATOR_H
|
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
#include "functions/functions.h"
|
|
||||||
#include "jansson.h"
|
|
||||||
|
|
||||||
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);
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
}; // namespace generator
|
|
||||||
|
|
||||||
#endif /* FUNCTION_GENERATOR_H */
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
#ifndef GEOMETRY_GENERATOR_H
|
|
||||||
#define GEOMETRY_GENERATOR_H
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "simulation/geometry.h"
|
|
||||||
#include "simulation/jansson_additionals.h"
|
|
||||||
#include "simulation/parameter.h"
|
|
||||||
|
|
||||||
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,
|
|
||||||
const json_path& path_to_geometry);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* GEOMETRY_GENERATOR_H */
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
#ifndef INJECTOR_GENERATOR_H
|
|
||||||
#define INJECTOR_GENERATOR_H
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <memory>
|
|
||||||
#include "simulation/injector.h"
|
|
||||||
#include "simulation/jansson_additionals.h"
|
|
||||||
#include "simulation/parameter.h"
|
|
||||||
#include "simulation/species.h"
|
|
||||||
|
|
||||||
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::map<std::string, std::shared_ptr<species::TrackedSpecie>>&
|
|
||||||
tracked_species,
|
|
||||||
std::map<std::string, std::shared_ptr<species::BackgroundSpecie>>&
|
|
||||||
background_species,
|
|
||||||
Parameter& parameter);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* INJECTOR_GENERATOR_H */
|
|
||||||
@@ -1,155 +0,0 @@
|
|||||||
#ifndef INTERACTION_GENERATOR_H
|
|
||||||
#define INTERACTION_GENERATOR_H
|
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
#include <map>
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
#include "simulation/jansson_additionals.h"
|
|
||||||
#include "simulation/parameter.h"
|
|
||||||
#include "simulation/scattering_angle_distribution.h"
|
|
||||||
#include "simulation/species.h"
|
|
||||||
|
|
||||||
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(
|
|
||||||
std::shared_ptr<species::TrackedSpecie> specie,
|
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>&
|
|
||||||
tracked_species,
|
|
||||||
std::map<std::string, std::shared_ptr<species::BackgroundSpecie>>&
|
|
||||||
background_species,
|
|
||||||
Parameter& parameter,
|
|
||||||
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);
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
// 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(
|
|
||||||
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);
|
|
||||||
|
|
||||||
// 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::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::string& target_name,
|
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>&
|
|
||||||
tracked_species,
|
|
||||||
std::map<std::string, std::shared_ptr<species::BackgroundSpecie>>&
|
|
||||||
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::string& target_name,
|
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>&
|
|
||||||
tracked_species);
|
|
||||||
|
|
||||||
}; // namespace generator
|
|
||||||
|
|
||||||
#endif /* INTERACTION_GENERATOR_H */
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
#ifndef LOGGER_GENERATOR_H
|
|
||||||
#define LOGGER_GENERATOR_H
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include "simulation/logger.h"
|
|
||||||
#include "simulation/parameter.h"
|
|
||||||
|
|
||||||
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);
|
|
||||||
// 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(
|
|
||||||
Parameter& parameter,
|
|
||||||
const json_path& path_to_logger);
|
|
||||||
|
|
||||||
} // namespace generator
|
|
||||||
|
|
||||||
#endif /* LOGGER_GENERATOR_H */
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
#ifndef MAGNETIC_FIELD_GENERATOR_H
|
|
||||||
#define MAGNETIC_FIELD_GENERATOR_H
|
|
||||||
|
|
||||||
#include "simulation/electromagnetic_field.h"
|
|
||||||
#include "simulation/parameter.h"
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
}; // namespace generator
|
|
||||||
|
|
||||||
#endif /* MAGNETIC_FIELD_GENERATOR_H */
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#ifndef MASS_GENERATOR_H
|
|
||||||
#define MASS_GENERATOR_H
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include "jansson.h"
|
|
||||||
|
|
||||||
// defined in "simulation/species.h"
|
|
||||||
namespace species {
|
|
||||||
enum class ImplementedSpecies;
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace generator {
|
|
||||||
|
|
||||||
// class containing a map of the masses (in kg) to the respective ImplementedSpecies
|
|
||||||
class SpeciesMasses {
|
|
||||||
public:
|
|
||||||
// return the mass of the ImplementedSpecies
|
|
||||||
static double mass(const species::ImplementedSpecies& species);
|
|
||||||
|
|
||||||
private:
|
|
||||||
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);
|
|
||||||
|
|
||||||
}; // namespace generator
|
|
||||||
|
|
||||||
#endif /* MASS_GENERATOR_H */
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
#ifndef MOVER_GENERATOR_H
|
|
||||||
#define MOVER_GENERATOR_H
|
|
||||||
|
|
||||||
#include "simulation/jansson_additionals.h"
|
|
||||||
#include "simulation/mover.h"
|
|
||||||
#include "simulation/parameter.h"
|
|
||||||
|
|
||||||
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,
|
|
||||||
const json_path& path_to_mover);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* MOVER_GENERATOR_H */
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
#ifndef RANDOM_NUMBERS_GENERATOR_H
|
|
||||||
#define RANDOM_NUMBERS_GENERATOR_H
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include "simulation/parameter.h"
|
|
||||||
#include "simulation/random_numbers.h"
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* RANDOM_NUMBERS_GENERATOR_H */
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
#ifndef REFLECTOR_GENERATOR_H
|
|
||||||
#define REFLECTOR_GENERATOR_H
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "simulation/jansson_additionals.h"
|
|
||||||
#include "simulation/parameter.h"
|
|
||||||
#include "simulation/reflector.h"
|
|
||||||
|
|
||||||
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,
|
|
||||||
const json_path& path_to_reflector);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* REFLECTOR_GENERATOR_H */
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
#ifndef SCALAR_FIELD_GENERATOR_H
|
|
||||||
#define SCALAR_FIELD_GENERATOR_H
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "jansson.h"
|
|
||||||
#include "simulation/scalar_field.h"
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* SCALAR_FIELD_GENERATOR_H */
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
#ifndef SIMULATION_OUTPUT_GENERATOR_H
|
|
||||||
#define SIMULATION_OUTPUT_GENERATOR_H
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
#include "jansson.h"
|
|
||||||
|
|
||||||
// defined in "IO/simulation_output.h"
|
|
||||||
class SimulationOutput;
|
|
||||||
|
|
||||||
// defined in "simulation/species.h"
|
|
||||||
namespace species {
|
|
||||||
class TrackedSpecie;
|
|
||||||
};
|
|
||||||
|
|
||||||
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(
|
|
||||||
json_t* object,
|
|
||||||
const std::map<std::string, std::shared_ptr<species::TrackedSpecie>>&
|
|
||||||
tracked_species);
|
|
||||||
|
|
||||||
}; // namespace generator
|
|
||||||
|
|
||||||
#endif /* SIMULATION_OUTPUT_GENERATOR_H */
|
|
||||||
@@ -1,235 +0,0 @@
|
|||||||
#ifndef SPECIES_GENERATOR_H
|
|
||||||
#define SPECIES_GENERATOR_H
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "generators/interaction_generator.h"
|
|
||||||
#include "simulation/jansson_additionals.h"
|
|
||||||
#include "simulation/parameter.h"
|
|
||||||
#include "simulation/species.h"
|
|
||||||
|
|
||||||
// defined in "simulation/timer.h"
|
|
||||||
class Timer;
|
|
||||||
|
|
||||||
namespace generator {
|
|
||||||
|
|
||||||
// structure to store various variables neccessary for the creation
|
|
||||||
// of TrackedSpecies objects
|
|
||||||
struct TrackedSpeciesBuilderInfo {
|
|
||||||
public:
|
|
||||||
std::shared_ptr<Mover> mover;
|
|
||||||
std::shared_ptr<Terminator> terminator;
|
|
||||||
std::shared_ptr<Reflector> reflector;
|
|
||||||
std::shared_ptr<DynamicDensityField> density_field;
|
|
||||||
std::shared_ptr<VelocityDistribution> velocity_distribution;
|
|
||||||
std::shared_ptr<DriftVelocity> drift_velocity;
|
|
||||||
std::shared_ptr<DynamicDensityField> last_sync_density_field;
|
|
||||||
|
|
||||||
double mass_kg;
|
|
||||||
double charge_C;
|
|
||||||
species::ImplementedSpecies type;
|
|
||||||
std::string name;
|
|
||||||
json_path path_in_json;
|
|
||||||
};
|
|
||||||
|
|
||||||
// structure to store various variables neccessary for the creation
|
|
||||||
// of BackgroundSpecies objects
|
|
||||||
struct BackgroundSpeciesBuilderInfo {
|
|
||||||
public:
|
|
||||||
BackgroundSpeciesBuilderInfo()
|
|
||||||
: density(nullptr),
|
|
||||||
velocity_distribution(nullptr),
|
|
||||||
drift_velocity(nullptr){};
|
|
||||||
std::shared_ptr<ConstantDensityField> density;
|
|
||||||
std::shared_ptr<VelocityDistribution> velocity_distribution;
|
|
||||||
std::shared_ptr<DriftVelocity> drift_velocity;
|
|
||||||
|
|
||||||
double mass_kg;
|
|
||||||
double charge_C;
|
|
||||||
species::ImplementedSpecies type;
|
|
||||||
std::string name;
|
|
||||||
json_path path_in_json;
|
|
||||||
};
|
|
||||||
|
|
||||||
// class for mapping between certain strings and ImplementedSpecies enums
|
|
||||||
class SpeciesAlias {
|
|
||||||
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);
|
|
||||||
// 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);
|
|
||||||
// check if the string name is defined as an alias
|
|
||||||
static bool isAlias(const std::string& name);
|
|
||||||
|
|
||||||
private:
|
|
||||||
// mapping between the string and enum
|
|
||||||
static std::map<std::string, species::ImplementedSpecies> specie_aliases;
|
|
||||||
};
|
|
||||||
|
|
||||||
// class mapping between ImplementedSpecies enum and the charge corresponding to
|
|
||||||
// the physical particle
|
|
||||||
class SpeciesCharges {
|
|
||||||
public:
|
|
||||||
// return the charge of the ImplementedSpecies enum
|
|
||||||
static double charge(species::ImplementedSpecies species);
|
|
||||||
|
|
||||||
private:
|
|
||||||
static std::map<species::ImplementedSpecies, double> charge_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// class for creation of the TrackedSpecies map and the BackgroudSpecies map
|
|
||||||
class SpeciesBuilder {
|
|
||||||
public:
|
|
||||||
// Constructor: takes the Parameter object created by the input json file
|
|
||||||
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>>
|
|
||||||
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>>
|
|
||||||
backgroundSpecies();
|
|
||||||
// function to create a shared_ptr to a Timer object
|
|
||||||
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:
|
|
||||||
std::map<std::string, BackgroundSpeciesBuilderInfo> background_species_info;
|
|
||||||
std::map<std::string, TrackedSpeciesBuilderInfo> tracked_species_info;
|
|
||||||
std::shared_ptr<Timer> timer_;
|
|
||||||
std::shared_ptr<Timer> last_sync_timer_;
|
|
||||||
|
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>
|
|
||||||
tracked_species;
|
|
||||||
std::map<std::string, std::shared_ptr<species::BackgroundSpecie>>
|
|
||||||
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);
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
// 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);
|
|
||||||
// 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();
|
|
||||||
// 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();
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
// 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);
|
|
||||||
// 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);
|
|
||||||
// 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);
|
|
||||||
// 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);
|
|
||||||
// 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);
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
// fill timer_ and last_sync_timer_ objects (no json-specifications needed)
|
|
||||||
void initTimer();
|
|
||||||
// create the TrackedSpecies and BackgroundSpecies maps from the data contained in
|
|
||||||
// the corresponding entries of the TrackedSpeciesBuilderInfo and BackgroundSpeciesBuilderInfo
|
|
||||||
// maps
|
|
||||||
void buildSpecies();
|
|
||||||
};
|
|
||||||
|
|
||||||
}; // namespace generator
|
|
||||||
|
|
||||||
#endif /* SPECIES_GENERATOR_H */
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
#ifndef TERMINATOR_GENERATOR_H
|
|
||||||
#define TERMINATOR_GENERATOR_H
|
|
||||||
|
|
||||||
#include "simulation/jansson_additionals.h"
|
|
||||||
#include "simulation/parameter.h"
|
|
||||||
#include "simulation/terminator.h"
|
|
||||||
|
|
||||||
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(
|
|
||||||
Parameter& parameter,
|
|
||||||
const json_path& path_to_terminator);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* TERMINATOR_GENERATOR_H */
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
#ifndef VECTOR_FIELD_GENERATOR_H
|
|
||||||
#define VECTOR_FIELD_GENERATOR_H
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "jansson.h"
|
|
||||||
#include "simulation/parameter.h"
|
|
||||||
#include "simulation/vector_field.h"
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
} // namespace generator
|
|
||||||
|
|
||||||
#endif /* VECTOR_FIELD_GENERATOR_H */
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#ifndef VELOCITY_DISTRIBUTION_FUNCTION_GENERATOR_H
|
|
||||||
#define VELOCITY_DISTRIBUTION_FUNCTION_GENERATOR_H
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include "simulation/jansson_additionals.h"
|
|
||||||
#include "simulation/parameter.h"
|
|
||||||
#include "simulation/velocity_distribution_function.h"
|
|
||||||
|
|
||||||
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(
|
|
||||||
Parameter& parameter,
|
|
||||||
const json_path& path_to_distribution);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* VELOCITY_DISTRIBUTION_FUNCTION_GENERATOR_H */
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
#ifndef VELOCITY_DISTRIBUTION_GENERATOR_H
|
|
||||||
#define VELOCITY_DISTRIBUTION_GENERATOR_H
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include "simulation/jansson_additionals.h"
|
|
||||||
#include "simulation/parameter.h"
|
|
||||||
#include "simulation/velocity_distribution.h"
|
|
||||||
|
|
||||||
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(
|
|
||||||
Parameter& parameter,
|
|
||||||
const json_path& path_to_distribution);
|
|
||||||
|
|
||||||
}; // namespace generator
|
|
||||||
|
|
||||||
#endif /* VELOCITY_DISTRIBUTION_GENERATOR_H */
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
#ifndef CHARGE_EXCHANGE_H
|
|
||||||
#define CHARGE_EXCHANGE_H
|
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
#include "simulation/interaction.h"
|
|
||||||
|
|
||||||
// defined in "simulation/species.h"
|
|
||||||
namespace species {
|
|
||||||
class Specie;
|
|
||||||
};
|
|
||||||
|
|
||||||
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 {
|
|
||||||
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,
|
|
||||||
std::shared_ptr<species::Specie> target);
|
|
||||||
|
|
||||||
// return the result of the interaction as an InteractionOutput object
|
|
||||||
InteractionOutput performInteraction(particle::Particle& particle,
|
|
||||||
RandomNumbers* generator);
|
|
||||||
};
|
|
||||||
|
|
||||||
}; // namespace interaction
|
|
||||||
|
|
||||||
#endif /* CHARGE_EXCHANGE_H */
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
#ifndef CLUSTER_FORMATION_H
|
|
||||||
#define CLUSTER_FORMATION_H
|
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
#include "simulation/interaction.h"
|
|
||||||
|
|
||||||
// defined in "simulation/species.h"
|
|
||||||
namespace species {
|
|
||||||
class Specie;
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace interaction {
|
|
||||||
|
|
||||||
// class for cluster formation interactions (A + B --> AB) or (A + BC --> AB + C)
|
|
||||||
class ClusterFormation : public Interaction {
|
|
||||||
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,
|
|
||||||
std::shared_ptr<species::Specie> target,
|
|
||||||
std::shared_ptr<species::TrackedSpecie> product);
|
|
||||||
// return an InteractionOutput object with the results of the interaction
|
|
||||||
InteractionOutput performInteraction(particle::Particle& particle,
|
|
||||||
RandomNumbers* generator);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
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
|
|
||||||
|
|
||||||
#endif /* CLUSTER_FORMATION_H */
|
|
||||||
@@ -1,112 +0,0 @@
|
|||||||
#ifndef CROSS_SECTIONS_H
|
|
||||||
#define CROSS_SECTIONS_H
|
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace interaction {
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ? mention how data was obtained ?
|
|
||||||
namespace totalCrossSection {
|
|
||||||
|
|
||||||
// returns function that returns a constant value of 1.4e-19 m²
|
|
||||||
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();
|
|
||||||
// return function that describes the total elastic scattering cross section
|
|
||||||
// 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();
|
|
||||||
|
|
||||||
// return a function describing the cross section for electron ionization of
|
|
||||||
// T₂: T₂ + e¯ --> T₂⁺ + 2e¯ (?)
|
|
||||||
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();
|
|
||||||
// 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();
|
|
||||||
// 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();
|
|
||||||
|
|
||||||
// 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();
|
|
||||||
// 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();
|
|
||||||
// return a function describing the cross section for clustering of T₂⁺ and T₂:
|
|
||||||
// T₂⁺ + T₂ --> T₃⁺ + T
|
|
||||||
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)>
|
|
||||||
eT2_excitation_electric_janev_from_singlet_ground_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)>
|
|
||||||
eT2_excitation_electric_janev_from_singlet_ground_state_symmetry_forbidden(
|
|
||||||
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)>
|
|
||||||
eT2_excitation_electric_janev_from_triplet_ground_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();
|
|
||||||
// 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();
|
|
||||||
// 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();
|
|
||||||
// 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();
|
|
||||||
|
|
||||||
// return a function describing the cross section for recombination of T₂⁺ with an
|
|
||||||
// electron: T₂⁺ + e⁼ --> T₂
|
|
||||||
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();
|
|
||||||
|
|
||||||
}; // namespace totalCrossSection
|
|
||||||
|
|
||||||
}; // namespace interaction
|
|
||||||
|
|
||||||
#endif /* CROSS_SECTIONS_H */
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
#ifndef ELASTIC_SCATTERING_H
|
|
||||||
#define ELASTIC_SCATTERING_H
|
|
||||||
|
|
||||||
#include "simulation/interaction.h"
|
|
||||||
|
|
||||||
class ScatteringAngleDistribution;
|
|
||||||
|
|
||||||
namespace interaction {
|
|
||||||
|
|
||||||
// class for handling elastic scattering interactions (A + B --> A + B)
|
|
||||||
class ElasticScattering : public Interaction {
|
|
||||||
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,
|
|
||||||
std::shared_ptr<species::Specie> target,
|
|
||||||
std::shared_ptr<ScatteringAngleDistribution> theta_distrib);
|
|
||||||
|
|
||||||
// return the interaction outcome as an InteractionOutput object
|
|
||||||
InteractionOutput performInteraction(particle::Particle& particle,
|
|
||||||
RandomNumbers* generator);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::shared_ptr<ScatteringAngleDistribution> theta_distrib_;
|
|
||||||
};
|
|
||||||
|
|
||||||
}; // namespace interaction
|
|
||||||
|
|
||||||
#endif /* ELASTIC_SCATTERING_H */
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
#ifndef EXCITATION_H
|
|
||||||
#define EXCITATION_H
|
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
#include "simulation/interaction.h"
|
|
||||||
#include "simulation/particle.h"
|
|
||||||
#include "simulation/random_numbers.h"
|
|
||||||
|
|
||||||
// defined in "simulation/species.h"
|
|
||||||
namespace species {
|
|
||||||
class Specie;
|
|
||||||
};
|
|
||||||
|
|
||||||
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 {
|
|
||||||
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,
|
|
||||||
std::shared_ptr<species::Specie> target,
|
|
||||||
double excitation_energy_eV);
|
|
||||||
|
|
||||||
// return the output of the interaction as an InteractionOutput object
|
|
||||||
InteractionOutput performInteraction(particle::Particle& particle,
|
|
||||||
RandomNumbers* generator);
|
|
||||||
|
|
||||||
private:
|
|
||||||
const double excitation_energy_eV_;
|
|
||||||
};
|
|
||||||
|
|
||||||
}; // namespace interaction
|
|
||||||
|
|
||||||
#endif /* EXCITATION_H */
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
#ifndef FREE_MOVEMENT_H
|
|
||||||
#define FREE_MOVEMENT_H
|
|
||||||
|
|
||||||
#include "simulation/interaction.h"
|
|
||||||
#include "simulation/particle.h"
|
|
||||||
#include "simulation/random_numbers.h"
|
|
||||||
|
|
||||||
namespace interaction {
|
|
||||||
|
|
||||||
// class for dummy interaction "free movement" (i.e. no interaction)
|
|
||||||
class FreeMovement : public Interaction {
|
|
||||||
public:
|
|
||||||
// Constructor: does not need anything
|
|
||||||
FreeMovement();
|
|
||||||
// return the result of the interaction as an InteractionOutput object
|
|
||||||
InteractionOutput performInteraction(particle::Particle& particle,
|
|
||||||
RandomNumbers* generator);
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
};
|
|
||||||
|
|
||||||
}; // namespace interaction
|
|
||||||
|
|
||||||
#endif /* FREE_MOVEMENT_H */
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
#ifndef IONIZATION_H
|
|
||||||
#define IONIZATION_H
|
|
||||||
|
|
||||||
#include "simulation/interaction.h"
|
|
||||||
|
|
||||||
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 {
|
|
||||||
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(
|
|
||||||
std::function<double(double, double)> d2_cross_section,
|
|
||||||
double ionization_energy_eV);
|
|
||||||
// draw the energy (always < (impact_energy - ionization_energy)/2) of the ejected particle
|
|
||||||
double rollImpactParticleEnergyAfterCollision(double impact_energy,
|
|
||||||
RandomNumbers* generator);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::function<double(double, double)> d2_cross_section_;
|
|
||||||
const double ionization_energy_eV_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// function handling the azimuthal angle distribution for
|
|
||||||
// electron ionization
|
|
||||||
class IonizationScatteringAngleDistribution {
|
|
||||||
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 impact_energy,
|
|
||||||
double energy_impact_particle_new,
|
|
||||||
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 impact_energy,
|
|
||||||
double energy_impactParticle_new,
|
|
||||||
RandomNumbers* generator);
|
|
||||||
};
|
|
||||||
|
|
||||||
// class for handling electron impact ionization
|
|
||||||
class ElectronIonization : public Interaction {
|
|
||||||
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(
|
|
||||||
std::function<double(double)> cross_section,
|
|
||||||
std::shared_ptr<species::Specie> target,
|
|
||||||
std::shared_ptr<species::TrackedSpecie> electron,
|
|
||||||
std::shared_ptr<species::TrackedSpecie> ion,
|
|
||||||
std::shared_ptr<IonizationEnergyDistribution> distribution,
|
|
||||||
std::shared_ptr<IonizationScatteringAngleDistribution> angle_distribution,
|
|
||||||
double ionization_energy_eV);
|
|
||||||
|
|
||||||
// perform the interaction and return an InteractionOutput object
|
|
||||||
// containing the corresponding information (new particles)
|
|
||||||
InteractionOutput performInteraction(particle::Particle& particle,
|
|
||||||
RandomNumbers* generator);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::shared_ptr<IonizationEnergyDistribution> energy_distribution_;
|
|
||||||
std::shared_ptr<IonizationScatteringAngleDistribution> angle_distribution_;
|
|
||||||
const double ionization_energy_eV_;
|
|
||||||
|
|
||||||
std::shared_ptr<species::TrackedSpecie> electron_;
|
|
||||||
std::shared_ptr<species::TrackedSpecie> ion_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace interaction
|
|
||||||
|
|
||||||
#endif /* IONIZATION_H */
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
#ifndef RECOMBINATION_H
|
|
||||||
#define RECOMBINATION_H
|
|
||||||
|
|
||||||
#include "simulation/interaction.h"
|
|
||||||
|
|
||||||
namespace interaction {
|
|
||||||
|
|
||||||
// class for handling recombination between two simulated species (TrackedSpecies)
|
|
||||||
class Recombination : public Interaction {
|
|
||||||
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,
|
|
||||||
std::shared_ptr<species::TrackedSpecie> target);
|
|
||||||
|
|
||||||
// return the result of the interaction as an InteractionOutput object
|
|
||||||
InteractionOutput performInteraction(particle::Particle& particle,
|
|
||||||
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:
|
|
||||||
double macroscopicCrossSection(const Coordinate& position, const int bin_index);
|
|
||||||
std::shared_ptr<species::TrackedSpecie> recombination_target_;
|
|
||||||
};
|
|
||||||
|
|
||||||
}; // namespace interaction
|
|
||||||
|
|
||||||
#endif /* RECOMBINATION_H */
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
#ifndef COMPARE_H
|
|
||||||
#define COMPARE_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) {
|
|
||||||
return std::abs(a - b) < SimConstants::compare_epsilon;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* COMPARE_H */
|
|
||||||
@@ -1,187 +0,0 @@
|
|||||||
#ifndef COORDINATES_H
|
|
||||||
#define COORDINATES_H
|
|
||||||
|
|
||||||
#include "blitz/array.h"
|
|
||||||
|
|
||||||
// Note: seems to be deprecated
|
|
||||||
// structure to store a coordinate wrt the binning of the simulation domain
|
|
||||||
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,
|
|
||||||
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,
|
|
||||||
blitz::TinyVector<double, 3> spacing);
|
|
||||||
|
|
||||||
blitz::TinyVector<int, 3> bin;
|
|
||||||
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(
|
|
||||||
blitz::TinyVector<double, 3> position,
|
|
||||||
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(
|
|
||||||
blitz::TinyVector<double, 3> position,
|
|
||||||
blitz::TinyVector<double, 3> spacing);
|
|
||||||
};
|
|
||||||
|
|
||||||
// parent class for different Coordinate types (cartesian, cylinder)
|
|
||||||
// cannot be instantiated
|
|
||||||
class Coordinate {
|
|
||||||
public:
|
|
||||||
// return the value of the stored coordinate transformed to Cartesian space
|
|
||||||
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;
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
};
|
|
||||||
|
|
||||||
// class for storing and handling of coordinates in cartesian space
|
|
||||||
class CartesianCoordinate : public Coordinate {
|
|
||||||
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);
|
|
||||||
// Constructor using an arbitrary Coordinate object
|
|
||||||
CartesianCoordinate(const Coordinate& coordinate);
|
|
||||||
|
|
||||||
// return the value of the stored coordinate transformed to Cartesian space
|
|
||||||
blitz::TinyVector<double, 3> cartesianEntries() const;
|
|
||||||
// return the value of the stored coordinate transformed to Cylider space
|
|
||||||
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);
|
|
||||||
|
|
||||||
private:
|
|
||||||
blitz::TinyVector<double, 3> cartesian_position;
|
|
||||||
};
|
|
||||||
|
|
||||||
class CylinderCoordinate : public Coordinate {
|
|
||||||
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);
|
|
||||||
// Constructor using an arbitrary Coordinate object
|
|
||||||
CylinderCoordinate(const Coordinate& coordinate);
|
|
||||||
|
|
||||||
// return the value of the stored coordinate transformed to Cartesian space
|
|
||||||
blitz::TinyVector<double, 3> cartesianEntries() const;
|
|
||||||
// return the value of the stored coordinate transformed to Cylinder space
|
|
||||||
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);
|
|
||||||
|
|
||||||
private:
|
|
||||||
// transform phi to be in the interval [0, 2pi]
|
|
||||||
void limitPhi();
|
|
||||||
blitz::TinyVector<double, 3> cylinder_position;
|
|
||||||
};
|
|
||||||
|
|
||||||
// parent class for different types of vectors (cartesian vector, cylinder vector)
|
|
||||||
class Vector {
|
|
||||||
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(
|
|
||||||
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(
|
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|
||||||
// class for storing and handling of Cylinder Vectors (v_r, v_phi, v_z)
|
|
||||||
class CylinderVector : public Vector {
|
|
||||||
public:
|
|
||||||
// copy constructor
|
|
||||||
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);
|
|
||||||
// constructor using an arbitrary vector, needs the Coordinate of the vector
|
|
||||||
// to transform into cylinder space
|
|
||||||
CylinderVector(const Vector& vector, const Coordinate& coordinate);
|
|
||||||
|
|
||||||
// overwrite the "+"-Operator for the addtion of two CylinderVector objects
|
|
||||||
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(
|
|
||||||
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(
|
|
||||||
const Coordinate& coordinate) const;
|
|
||||||
// returns the entries of the CylinderVector without the need for the Coordinate
|
|
||||||
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);
|
|
||||||
|
|
||||||
private:
|
|
||||||
blitz::TinyVector<double, 3> cylinder_vector;
|
|
||||||
};
|
|
||||||
|
|
||||||
// class for storing and handling of Cylinder Vectors (v_x, v_y, v_z)
|
|
||||||
class CartesianVector : public Vector {
|
|
||||||
public:
|
|
||||||
// constructor using a blitz::TinyVector containing the cartesian vector components
|
|
||||||
// of a vector
|
|
||||||
CartesianVector(const blitz::TinyVector<double, 3> cartesian_vector);
|
|
||||||
// copy constructor
|
|
||||||
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);
|
|
||||||
|
|
||||||
// return the stored values as a cartesian vector; overwrite of the pure virtual
|
|
||||||
// function in the Vector class
|
|
||||||
blitz::TinyVector<double, 3> cartesianEntries(
|
|
||||||
const Coordinate& coordinate) const;
|
|
||||||
// returns the entries of the CartesianVector without the need for the Coordinate
|
|
||||||
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(
|
|
||||||
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);
|
|
||||||
|
|
||||||
private:
|
|
||||||
blitz::TinyVector<double, 3> cartesian_vector;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* COORDINATES_H */
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
#ifndef CPU_SYNCHRONIZER_H
|
|
||||||
#define CPU_SYNCHRONIZER_H
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
#include "blitz/array.h"
|
|
||||||
|
|
||||||
// defined in "simulation/density_field.h"
|
|
||||||
class DynamicDensityField;
|
|
||||||
// defined in "simulation/timer.h"
|
|
||||||
class Timer;
|
|
||||||
// defined in "simulation/current_collector.h"
|
|
||||||
class CurrentCollector;
|
|
||||||
// defined in "simulation/logger.h"
|
|
||||||
class DeletionLogger;
|
|
||||||
|
|
||||||
// defined in "simulation/species.h"
|
|
||||||
namespace species {
|
|
||||||
class TrackedSpecie;
|
|
||||||
};
|
|
||||||
|
|
||||||
// class to synchronize states between mpi-processes
|
|
||||||
class CpuSynchronizer {
|
|
||||||
public:
|
|
||||||
// CpuSynchronizer();
|
|
||||||
|
|
||||||
// function to handle synchronization of the map of TrackedSpecie
|
|
||||||
// synchronizes the timer, all CurrentCollectors, DynamicDensityFields and DeletionLoggers
|
|
||||||
void synchronize(
|
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>&
|
|
||||||
tracked_species);
|
|
||||||
|
|
||||||
// function to synchronize a DynamicDensityField;
|
|
||||||
// last_sync_field includes the state of the DynamicDensityField after the last
|
|
||||||
// synchronization, neccessary to calculate changes that have to be communicated
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
|
|
||||||
// calculates delta = array - last_sync_array, then collects all deltas of all
|
|
||||||
// mpi-processes and adds them to last_sync_array (i.e. array does not get modified)
|
|
||||||
void sumToAll(blitz::Array<double, 4>& array,
|
|
||||||
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 */
|
|
||||||
@@ -1,139 +0,0 @@
|
|||||||
#ifndef CURRENT_COLLECTOR_H
|
|
||||||
#define CURRENT_COLLECTOR_H
|
|
||||||
|
|
||||||
#include "simulation/coordinates.h"
|
|
||||||
#include "simulation/energy_binning.h"
|
|
||||||
#include "simulation/particle.h"
|
|
||||||
#include "simulation/position_binning.h"
|
|
||||||
#include "simulation/timer.h"
|
|
||||||
|
|
||||||
// class to store and calculate particle currents
|
|
||||||
class CurrentCollector {
|
|
||||||
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,
|
|
||||||
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);
|
|
||||||
|
|
||||||
// returns the blitz::Array containing the crossings out of the bins in radial direction
|
|
||||||
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;
|
|
||||||
// return a blitz::Array with the areas of the bin borders in radial direction
|
|
||||||
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;
|
|
||||||
|
|
||||||
// returns the blitz::Array containing the crossings out of the bins in azimuthal direction
|
|
||||||
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;
|
|
||||||
// return a blitz::Array with the areas of the bin borders in azimuthal direction
|
|
||||||
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;
|
|
||||||
|
|
||||||
// returns the blitz::Array containing the crossings out of the bins in longitudinal direction
|
|
||||||
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;
|
|
||||||
// return a blitz::Array with the areas of the bin borders in longitudinal direction
|
|
||||||
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;
|
|
||||||
|
|
||||||
// return the time from the Timer object
|
|
||||||
double physicalTime() const;
|
|
||||||
|
|
||||||
// give the CpuSynchronizer class access to the private member variables to
|
|
||||||
// make synchronization between processes simpler
|
|
||||||
friend class CpuSynchronizer;
|
|
||||||
|
|
||||||
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,
|
|
||||||
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,
|
|
||||||
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,
|
|
||||||
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(
|
|
||||||
const CylinderBinning& position_binning);
|
|
||||||
// return an array for the counting of crossings across the bin borders in longitudinal direction
|
|
||||||
blitz::Array<double, 3> createCrossingsLongitudinal(
|
|
||||||
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(
|
|
||||||
const CylinderBinning& position_binning);
|
|
||||||
// return an array for the counting of crossings across the bin borders in radial direction
|
|
||||||
blitz::Array<double, 3> createCrossingsRadial(
|
|
||||||
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(
|
|
||||||
const CylinderBinning& position_binning);
|
|
||||||
// return an array for the counting of crossings across the bin borders in azimuthal direction
|
|
||||||
blitz::Array<double, 3> createCrossingsAzimuthal(
|
|
||||||
const CylinderBinning& position_binning);
|
|
||||||
|
|
||||||
// Arrays for the storage of boundary crossings
|
|
||||||
blitz::Array<double, 3> z_negative_crossings;
|
|
||||||
blitz::Array<double, 3> z_positive_crossings;
|
|
||||||
|
|
||||||
blitz::Array<double, 3> phi_negative_crossings;
|
|
||||||
blitz::Array<double, 3> phi_positive_crossings;
|
|
||||||
|
|
||||||
blitz::Array<double, 3> r_negative_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_phi;
|
|
||||||
blitz::Array<double, 3> collector_areas_z;
|
|
||||||
|
|
||||||
CylinderBinning position_binning_;
|
|
||||||
std::shared_ptr<Timer> timer_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* CURRENT_COLLECTOR_H */
|
|
||||||
@@ -1,137 +0,0 @@
|
|||||||
#ifndef DENSITY_FIELD_H
|
|
||||||
#define DENSITY_FIELD_H
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "simulation/coordinates.h"
|
|
||||||
#include "simulation/cpu_synchronizer.h"
|
|
||||||
#include "simulation/energy_binning.h"
|
|
||||||
#include "simulation/position_binning.h"
|
|
||||||
#include "simulation/timer.h"
|
|
||||||
|
|
||||||
// defined in "simulation/scalar_field.h"
|
|
||||||
class ScalarField;
|
|
||||||
// defined in "simulation/event_position_dirstribution.h"
|
|
||||||
class EventPositionDistribution;
|
|
||||||
|
|
||||||
// class for a generic density field, specifying the minimum requirements
|
|
||||||
class DensityField {
|
|
||||||
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;
|
|
||||||
// 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;
|
|
||||||
};
|
|
||||||
|
|
||||||
// class for the density field for TrackedSpecies, i.e. simulated species
|
|
||||||
class DynamicDensityField : public DensityField {
|
|
||||||
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,
|
|
||||||
const EnergyBinning& energy_binning,
|
|
||||||
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,
|
|
||||||
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;
|
|
||||||
|
|
||||||
// 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,
|
|
||||||
double energy_eV,
|
|
||||||
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);
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
// calculate and return the 3d density array (m^-3), no resolution in the energy direction
|
|
||||||
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();
|
|
||||||
// getter for the time_in_bin array
|
|
||||||
blitz::Array<double, 4> timeInBinArray() const;
|
|
||||||
// getter for the deleted_particles array
|
|
||||||
blitz::Array<long int, 4> deletedParticlesArray() const;
|
|
||||||
// getter for the bin_volume_m3 array
|
|
||||||
blitz::Array<double, 3> binVolumeArray() const;
|
|
||||||
|
|
||||||
// return a raw pointer to the EnergyBinning member object
|
|
||||||
const EnergyBinning* energyBinning() const;
|
|
||||||
// return a raw pointer to the CylinderBinning member object
|
|
||||||
const CylinderBinning* positionBinning() const;
|
|
||||||
|
|
||||||
// return the time from the timer member
|
|
||||||
double physicalTime() const;
|
|
||||||
|
|
||||||
// make the private member variables accessable by the CpuSynchronizer
|
|
||||||
friend class CpuSynchronizer;
|
|
||||||
|
|
||||||
private:
|
|
||||||
// coordinate ordering: r, phi, z, E
|
|
||||||
// bin numbering
|
|
||||||
// radial:
|
|
||||||
// 0, ..., num_bin_r-1: r < r_max
|
|
||||||
// num_bin_r: r >= r_max
|
|
||||||
//
|
|
||||||
// azimuthal:
|
|
||||||
// 0, ..., num_bin_phi: all
|
|
||||||
//
|
|
||||||
// longitudinal:
|
|
||||||
// -1: z < 0
|
|
||||||
// 0, ..., num_bin_z-1: 0 <= z < z_max
|
|
||||||
// num_bin_z: z >= z_max
|
|
||||||
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();
|
|
||||||
|
|
||||||
// array storing the cumulative time particles of a species have spent in certain bins
|
|
||||||
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_;
|
|
||||||
// array storing the physical density (units: m^-3), histogram in energy dimension
|
|
||||||
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_;
|
|
||||||
|
|
||||||
const CylinderBinning position_binning_;
|
|
||||||
const EnergyBinning energy_binning_;
|
|
||||||
|
|
||||||
std::shared_ptr<Timer> timer_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// class for the density field for BackgroundSpecies, i.e. non-simulated species
|
|
||||||
class ConstantDensityField : public DensityField {
|
|
||||||
public:
|
|
||||||
// Constructor: making the shared_ptr density a member variable
|
|
||||||
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);
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::shared_ptr<ScalarField> density_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* DENSITY_FIELD_H */
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
#ifndef DRIFT_VELOCITY_H
|
|
||||||
#define DRIFT_VELOCITY_H
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "simulation/coordinates.h"
|
|
||||||
#include "simulation/vector_field.h"
|
|
||||||
|
|
||||||
// class to handle the drift veloctiy
|
|
||||||
class DriftVelocity {
|
|
||||||
public:
|
|
||||||
// Constructor: takes a VectorField that describes the direction of the 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);
|
|
||||||
// overload using both the cartesian and cylinder coordinate version of the position
|
|
||||||
CartesianVector driftVelocity(const CartesianCoordinate& cartpos,
|
|
||||||
const CylinderCoordinate& cylpos);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::shared_ptr<VectorField> drift_velocity_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* DRIFT_VELOCITY_H */
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
#ifndef ELECTROMAGNETIC_FIELD_H
|
|
||||||
#define ELECTROMAGNETIC_FIELD_H
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include "simulation/coordinates.h"
|
|
||||||
#include "simulation/scalar_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 {
|
|
||||||
public:
|
|
||||||
// Constructor: setting the background and dynamic field to the provided VectorFields
|
|
||||||
ElectricField(std::shared_ptr<VectorField> background,
|
|
||||||
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;
|
|
||||||
|
|
||||||
// set the dynamic field to the provided field
|
|
||||||
void updateDynamicField(std::shared_ptr<VectorField> field);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::shared_ptr<VectorField> background_;
|
|
||||||
std::shared_ptr<VectorField> dynamic_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// class for a magnetic field
|
|
||||||
class MagneticField {
|
|
||||||
public:
|
|
||||||
// Constructor: takes the VectorField describing the magnetic 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;
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::shared_ptr<VectorField> field_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* ELECTROMAGNETIC_FIELD_H */
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
#ifndef ENERGY_BINNING_H
|
|
||||||
#define ENERGY_BINNING_H
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
// class defining the grid for the energy-direction (includes an over- and underflow bin)
|
|
||||||
class EnergyBinning {
|
|
||||||
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);
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
// returns the number of bins (not the number of bin borders!)
|
|
||||||
int numBins() const;
|
|
||||||
// returns the vector containing the energy bin borders
|
|
||||||
std::vector<double> binBorders() const;
|
|
||||||
// return the index of the underflow bin
|
|
||||||
int binIndexMin() const;
|
|
||||||
// return the index of the overflow bin
|
|
||||||
int binIndexMax() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
// vector containing the values of the bin edges
|
|
||||||
const std::vector<double> energy_bin_borders_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* ENERGY_BINNING_H */
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
#ifndef ENERGY_DISTRIBUTION_H
|
|
||||||
#define ENERGY_DISTRIBUTION_H
|
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
#include <random>
|
|
||||||
|
|
||||||
// class defining the minimum requirements of an EnergyDistributionFunction child class
|
|
||||||
class EnergyDistributionFunction {
|
|
||||||
public:
|
|
||||||
// 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 {
|
|
||||||
public:
|
|
||||||
// Constructor: initializes the random distributions
|
|
||||||
TritiumBetaDecay();
|
|
||||||
// draw an energy (eV) from the Fermi spectrum of the Tritium beta decay
|
|
||||||
double rollEnergy(std::mt19937* engine);
|
|
||||||
|
|
||||||
private:
|
|
||||||
const std::function<double(double)> tritium_spectrum_;
|
|
||||||
std::uniform_real_distribution<double> x_distribution_;
|
|
||||||
std::uniform_real_distribution<double> y_distribution_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// class for drawing an energy value from the Maxwell Boltzmann energy distribution
|
|
||||||
class MaxwellBoltzmann : public EnergyDistributionFunction {
|
|
||||||
public:
|
|
||||||
// initialize the distribution with the temperature (in K)
|
|
||||||
MaxwellBoltzmann(double temperature_K);
|
|
||||||
// draw an energy (in eV) from the Maxwell Boltzmann energy distribtion
|
|
||||||
double rollEnergy(std::mt19937* engine);
|
|
||||||
private:
|
|
||||||
std::gamma_distribution<double> distribution_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// class for returnig a constant energy value
|
|
||||||
class Constant : public EnergyDistributionFunction {
|
|
||||||
public:
|
|
||||||
// Constructor: takes the energy value (in eV) that will be returned later
|
|
||||||
Constant(double constant_eV);
|
|
||||||
// return the energy (in eV) set at construction of the object
|
|
||||||
double rollEnergy(std::mt19937* engine);
|
|
||||||
private:
|
|
||||||
const double constant_eV_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* ENERGY_DISTRIBUTION_H */
|
|
||||||
@@ -1,169 +0,0 @@
|
|||||||
#ifndef ERRORS_H
|
|
||||||
#define ERRORS_H
|
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
#include <exception>
|
|
||||||
#include <iostream>
|
|
||||||
#include <string>
|
|
||||||
#include "blitz/array.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 || \
|
|
||||||
defined debug_level0
|
|
||||||
inline void DEBUG(const std::string& message) {
|
|
||||||
std::cout << "#DEBUG<" << MpiCommunication::mpi_rank << ">: " << message
|
|
||||||
<< std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
// depending on the debug level, activate the corresponding debugging function
|
|
||||||
#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) {
|
|
||||||
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) {}
|
|
||||||
// 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) {}
|
|
||||||
// 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) {}
|
|
||||||
#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) {
|
|
||||||
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) {
|
|
||||||
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) {}
|
|
||||||
// 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) {}
|
|
||||||
|
|
||||||
#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) {
|
|
||||||
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) {
|
|
||||||
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) {
|
|
||||||
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) {}
|
|
||||||
|
|
||||||
#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) {
|
|
||||||
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) {
|
|
||||||
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) {
|
|
||||||
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) {
|
|
||||||
DEBUG(message);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else
|
|
||||||
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) {}
|
|
||||||
// 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) {}
|
|
||||||
// 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) {}
|
|
||||||
// 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) {}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// for MPI process 0 print the message string to stdout
|
|
||||||
inline void SIM_INFO(const std::string& message) {
|
|
||||||
if (MpiCommunication::mpi_rank == 0) {
|
|
||||||
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) {
|
|
||||||
fprintf(stderr, "ERROR <%d> %s\n", MpiCommunication::mpi_rank,
|
|
||||||
message.c_str());
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
// throw std::runtime_error(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
// assert if value is positive otherwise exit the program and print the message to stderr
|
|
||||||
template <class T>
|
|
||||||
void ASSERT_POSITIVE(T* value, const std::string& message) {
|
|
||||||
if (!(*value > 0)) {
|
|
||||||
ERROR(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// assert if value is not negative otherwise exit the program and print the message to stderr
|
|
||||||
template <class T>
|
|
||||||
void ASSERT_NOTNEGATIVE(T* value, const std::string& message) {
|
|
||||||
if (!(*value >= 0)) {
|
|
||||||
ERROR(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// assert if value exists otherwise exit the program and print the message to stderr
|
|
||||||
template <class T>
|
|
||||||
void ASSERT_EXISTS(T* value, const std::string& message) {
|
|
||||||
if (!value) {
|
|
||||||
ERROR(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) {
|
|
||||||
if (!std::isfinite(value)) {
|
|
||||||
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,
|
|
||||||
const std::string& message) {
|
|
||||||
if (!std::isfinite(value(0)) || !std::isfinite(value(1)) ||
|
|
||||||
!std::isfinite(value(2))) {
|
|
||||||
ERROR(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* ERRORS_H */
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
#ifndef EVENT_POSITION_DISTRIBUTION_H
|
|
||||||
#define EVENT_POSITION_DISTRIBUTION_H
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <random>
|
|
||||||
|
|
||||||
#include "simulation/coordinates.h"
|
|
||||||
#include "simulation/scalar_field.h"
|
|
||||||
|
|
||||||
// structure for storing a minimum and maximum value
|
|
||||||
struct Limit {
|
|
||||||
Limit() : min(0), max(0){};
|
|
||||||
Limit(double min, double max) : min(min), max(max){};
|
|
||||||
double min;
|
|
||||||
double max;
|
|
||||||
};
|
|
||||||
|
|
||||||
// class for drawing positions
|
|
||||||
class EventPositionDistribution {
|
|
||||||
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,
|
|
||||||
Limit density,
|
|
||||||
Limit r_position,
|
|
||||||
Limit phi_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);
|
|
||||||
|
|
||||||
private:
|
|
||||||
// ScalarField defining the distribution
|
|
||||||
std::shared_ptr<ScalarField> mother_density_;
|
|
||||||
|
|
||||||
// distribution functions drawn to be drawn from in the rejection method
|
|
||||||
std::uniform_real_distribution<double> r_values;
|
|
||||||
std::uniform_real_distribution<double> z_values;
|
|
||||||
std::uniform_real_distribution<double> phi_values;
|
|
||||||
std::uniform_real_distribution<double> density_values;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* EVENT_POSITION_DISTRIBUTION_H */
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
#ifndef GEOMETRY_H
|
|
||||||
#define GEOMETRY_H
|
|
||||||
|
|
||||||
#include "simulation/coordinates.h"
|
|
||||||
|
|
||||||
// class defining the miminmum requirement of a Geometry class
|
|
||||||
class Geometry {
|
|
||||||
public:
|
|
||||||
// check if Coordinate position is contained in the Geometry
|
|
||||||
virtual bool isInside(const Coordinate& position) const = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Geometry class for a cylinder
|
|
||||||
class Cylinder : public Geometry {
|
|
||||||
public:
|
|
||||||
// Constructor: takes the radius and height of the cylinder
|
|
||||||
// z always starts at 0
|
|
||||||
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;
|
|
||||||
|
|
||||||
private:
|
|
||||||
const double radius_;
|
|
||||||
const double height_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* GEOMETRY_H */
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
#ifndef 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 STR_VALUE(arg) STRINGIZER(arg)
|
|
||||||
#define BUILD_HOMEBASE_STRING STR_VALUE(HOMEBASE)
|
|
||||||
|
|
||||||
#endif /* HOMEBASE_H */
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
#ifndef INJECTOR_H
|
|
||||||
#define INJECTOR_H
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <memory>
|
|
||||||
#include <random>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "simulation/coordinates.h"
|
|
||||||
|
|
||||||
// defined in "simulation/drift_velocity.h"
|
|
||||||
class DriftVelocity;
|
|
||||||
// defined in "simulation/veloctiy_distribution.h"
|
|
||||||
class VelocityDistribution;
|
|
||||||
|
|
||||||
// defined in "simulation/particle.h"
|
|
||||||
namespace particle {
|
|
||||||
class Particle;
|
|
||||||
}
|
|
||||||
|
|
||||||
// defined in "simulation/species.h"
|
|
||||||
namespace species {
|
|
||||||
class Specie;
|
|
||||||
class TrackedSpecie;
|
|
||||||
} // namespace species
|
|
||||||
|
|
||||||
// defined in "simulation/event_position_distribution.h"
|
|
||||||
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 {
|
|
||||||
public:
|
|
||||||
std::shared_ptr<species::TrackedSpecie> created_specie;
|
|
||||||
std::shared_ptr<VelocityDistribution> creation_velocity_distribution;
|
|
||||||
};
|
|
||||||
|
|
||||||
// class handling injection of event particles (i.e. particles from the tritium beta decay)
|
|
||||||
class Injector {
|
|
||||||
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,
|
|
||||||
double activity,
|
|
||||||
std::shared_ptr<EventPositionDistribution> position_distribution,
|
|
||||||
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);
|
|
||||||
// return average time between events (1/activity)
|
|
||||||
double timePassed() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::vector<InjectorInfo> injector_infos_;
|
|
||||||
const double activity_;
|
|
||||||
std::shared_ptr<EventPositionDistribution> position_distribution_;
|
|
||||||
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(
|
|
||||||
std::mt19937* engine,
|
|
||||||
const Coordinate& position,
|
|
||||||
std::shared_ptr<species::TrackedSpecie> created_specie,
|
|
||||||
std::shared_ptr<VelocityDistribution> creation_velocity_distribution);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* INJECTOR_H */
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
#ifndef INTERACTION_H
|
|
||||||
#define INTERACTION_H
|
|
||||||
|
|
||||||
#include "simulation/particle.h"
|
|
||||||
#include "simulation/random_numbers.h"
|
|
||||||
#include "simulation/species.h"
|
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
#include <memory>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace interaction {
|
|
||||||
|
|
||||||
// class to define the output of an interaction
|
|
||||||
class InteractionOutput {
|
|
||||||
public:
|
|
||||||
// Constructor: incident particle is not flagged for deletion
|
|
||||||
InteractionOutput();
|
|
||||||
|
|
||||||
// if new_decider is true then the incident particle of the interaction is
|
|
||||||
// flagged for deletion
|
|
||||||
void deleteCurrentParticle(bool new_decider);
|
|
||||||
// return if the incident particle is flagged for deletion
|
|
||||||
bool deleteCurrentParticle();
|
|
||||||
// add particles that are created (not the incident) particles to the InteractionOutput
|
|
||||||
void add(const particle::Particle& new_particle);
|
|
||||||
// return the vector of particles that have been created by an interactoin
|
|
||||||
std::vector<particle::Particle> newParticles();
|
|
||||||
|
|
||||||
private:
|
|
||||||
// flag if the incident particle should be deleted
|
|
||||||
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_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// parent class for all interactions (cannot be instantiated)
|
|
||||||
class Interaction {
|
|
||||||
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,
|
|
||||||
std::shared_ptr<species::Specie> target);
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
// pure virtual function defining the specifics of the actual interaction
|
|
||||||
virtual InteractionOutput performInteraction(particle::Particle& particle,
|
|
||||||
RandomNumbers* generator) = 0;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
std::function<double(double)> cross_section_;
|
|
||||||
std::shared_ptr<species::Specie> target_;
|
|
||||||
};
|
|
||||||
|
|
||||||
}; // namespace interaction
|
|
||||||
|
|
||||||
#endif /* INTERACTION_H */
|
|
||||||
@@ -1,149 +0,0 @@
|
|||||||
#ifndef JANSSON_ADDITIONALS_H
|
|
||||||
#define JANSSON_ADDITIONALS_H
|
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
#include <sstream>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
#include "blitz/array.h"
|
|
||||||
#include "jansson.h"
|
|
||||||
#include "simulation/errors.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;
|
|
||||||
|
|
||||||
// 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) {
|
|
||||||
json_t* j_obj = object;
|
|
||||||
for (auto str : path) {
|
|
||||||
j_obj = json_object_get(j_obj, str.c_str());
|
|
||||||
}
|
|
||||||
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.) {
|
|
||||||
if (object) {
|
|
||||||
return json_real_value(object);
|
|
||||||
} else {
|
|
||||||
return default_value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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) {
|
|
||||||
if (object) {
|
|
||||||
return std::floor(json_real_value(object));
|
|
||||||
} else {
|
|
||||||
return default_value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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 = "") {
|
|
||||||
if (object) {
|
|
||||||
return std::string(json_string_value(object));
|
|
||||||
} else {
|
|
||||||
return 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) {
|
|
||||||
if (object) {
|
|
||||||
return (json_string(object) == "true");
|
|
||||||
} else {
|
|
||||||
return default_value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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>
|
|
||||||
blitz::TinyVector<double, s> json_blitz_vector(json_t* object) {
|
|
||||||
blitz::TinyVector<double, s> vector;
|
|
||||||
size_t index;
|
|
||||||
json_t* value;
|
|
||||||
json_t* array = json_object_by_path(object, {"vector"});
|
|
||||||
size_t size = json_array_size(array);
|
|
||||||
if (size != s) {
|
|
||||||
std::stringstream error_message;
|
|
||||||
error_message << "The provided vector has size: " << size
|
|
||||||
<< ", but is stated as size " << s;
|
|
||||||
ERROR(error_message.str());
|
|
||||||
}
|
|
||||||
|
|
||||||
json_array_foreach(array, index, value) {
|
|
||||||
vector(index) = json_double(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
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) {
|
|
||||||
std::vector<double> vector;
|
|
||||||
size_t index;
|
|
||||||
json_t* value;
|
|
||||||
json_array_foreach(object, index, value) {
|
|
||||||
vector.push_back(json_double(value));
|
|
||||||
}
|
|
||||||
return vector;
|
|
||||||
}
|
|
||||||
|
|
||||||
// return the json-array in "object" as a json_path variable
|
|
||||||
inline json_path json_path_get(json_t* object) {
|
|
||||||
json_path path;
|
|
||||||
|
|
||||||
json_t* value;
|
|
||||||
size_t index;
|
|
||||||
json_array_foreach(object, index, value) {
|
|
||||||
path.push_back(json_string(value));
|
|
||||||
}
|
|
||||||
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,
|
|
||||||
const json_path& append) {
|
|
||||||
json_path result = path;
|
|
||||||
for (auto a : append) {
|
|
||||||
result.push_back(a);
|
|
||||||
}
|
|
||||||
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") {
|
|
||||||
double value = json_double(json_object_by_path(object, {"value"}));
|
|
||||||
std::string unit = json_string(json_object_by_path(object, {"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") {
|
|
||||||
double value = json_double(json_object_by_path(object, {"value"}));
|
|
||||||
std::string unit = json_string(json_object_by_path(object, {"unit"}));
|
|
||||||
return unitConvertion::energy(value, unit, output_unit);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* JANSSON_ADDITIONALS_H */
|
|
||||||
@@ -1,121 +0,0 @@
|
|||||||
#ifndef KINEMATIC_H
|
|
||||||
#define KINEMATIC_H
|
|
||||||
|
|
||||||
#include "simulation/coordinates.h"
|
|
||||||
|
|
||||||
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(
|
|
||||||
const blitz::TinyVector<double, 3>& velocity_1,
|
|
||||||
const blitz::TinyVector<double, 3>& velocity_2,
|
|
||||||
double mass_1,
|
|
||||||
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(
|
|
||||||
const blitz::TinyVector<double, 3>& velocity_1,
|
|
||||||
const blitz::TinyVector<double, 3>& velocity_2,
|
|
||||||
double mass_1,
|
|
||||||
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,
|
|
||||||
double theta,
|
|
||||||
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(
|
|
||||||
const blitz::TinyVector<double, 3>& velocity_1,
|
|
||||||
const blitz::TinyVector<double, 3>& velocity_2,
|
|
||||||
double mass_1,
|
|
||||||
double mass_2,
|
|
||||||
double theta,
|
|
||||||
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);
|
|
||||||
// transform the temperature (K) into an energy in eV
|
|
||||||
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);
|
|
||||||
|
|
||||||
// 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(
|
|
||||||
const blitz::TinyVector<double, 3>& v1,
|
|
||||||
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);
|
|
||||||
// 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);
|
|
||||||
// return the cartesian velocity (m/s) devided by the speed of light
|
|
||||||
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);
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
// returns the norm of the 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,
|
|
||||||
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(
|
|
||||||
const blitz::TinyVector<double, 3>& vector,
|
|
||||||
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(
|
|
||||||
const blitz::TinyVector<double, 3>& vector,
|
|
||||||
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(
|
|
||||||
const blitz::TinyVector<double, 3>& vector,
|
|
||||||
const blitz::TinyVector<double, 3>& rotation_axis,
|
|
||||||
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(
|
|
||||||
double energy_eV,
|
|
||||||
const blitz::TinyVector<double, 3>& random_unit_vector,
|
|
||||||
double mass_kg);
|
|
||||||
|
|
||||||
}; // namespace kinematic
|
|
||||||
|
|
||||||
#endif /* KINEMATIC_H */
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
#ifndef LOGGER_H
|
|
||||||
#define LOGGER_H
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <vector>
|
|
||||||
#include "simulation/coordinates.h"
|
|
||||||
|
|
||||||
// enum that defines the different types of deletions that can be counted
|
|
||||||
enum class DeletionType {
|
|
||||||
wall,
|
|
||||||
recombination,
|
|
||||||
max_interactions,
|
|
||||||
max_time_alive,
|
|
||||||
cluster_formation
|
|
||||||
};
|
|
||||||
|
|
||||||
// class that keeps track of the DeletionType that caused a particle to be deleted
|
|
||||||
class DeletionLogger {
|
|
||||||
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);
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
// set the count for DeletionType type to new_value
|
|
||||||
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;
|
|
||||||
|
|
||||||
// make private member variable accessable for the cpu synchronization
|
|
||||||
friend class CpuSynchronizer;
|
|
||||||
|
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* LOGGER_H */
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
#ifndef MOVER_H
|
|
||||||
#define MOVER_H
|
|
||||||
|
|
||||||
#include "simulation/electromagnetic_field.h"
|
|
||||||
#include "simulation/particle.h"
|
|
||||||
|
|
||||||
// class defining the minimum requirements of a mover class
|
|
||||||
class Mover {
|
|
||||||
public:
|
|
||||||
virtual void move(particle::Particle* particle,
|
|
||||||
double mfp_m,
|
|
||||||
ElectricField* electric_field,
|
|
||||||
MagneticField* magnetic_field) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Mover class using the Boris push algorithm for propagation
|
|
||||||
class BorisMover : public Mover {
|
|
||||||
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);
|
|
||||||
|
|
||||||
// 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,
|
|
||||||
double mfp_m,
|
|
||||||
ElectricField* electric_field,
|
|
||||||
MagneticField* magnetic_field);
|
|
||||||
|
|
||||||
private:
|
|
||||||
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,
|
|
||||||
const blitz::TinyVector<double, 3>& electric_field,
|
|
||||||
const blitz::TinyVector<double, 3>& magnetic_field,
|
|
||||||
const double timestep,
|
|
||||||
double& moved_distance) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Mover class using the drift approximation for propagation
|
|
||||||
class DriftMover : public Mover {
|
|
||||||
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);
|
|
||||||
|
|
||||||
// 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,
|
|
||||||
double mfp_m,
|
|
||||||
ElectricField* electric_field,
|
|
||||||
MagneticField* magnetic_field);
|
|
||||||
|
|
||||||
private:
|
|
||||||
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(
|
|
||||||
const blitz::TinyVector<double, 3>& magnetic_field,
|
|
||||||
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 */
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
#ifndef MPI_COMMUNICATION_H
|
|
||||||
#define MPI_COMMUNICATION_H
|
|
||||||
|
|
||||||
// class to handle MPI communication
|
|
||||||
class MpiCommunication {
|
|
||||||
public:
|
|
||||||
static int mpi_rank;
|
|
||||||
static int mpi_size;
|
|
||||||
|
|
||||||
// returns the MPI-rank of the process
|
|
||||||
static int mpiRank();
|
|
||||||
// returns the number of MPI processes
|
|
||||||
static int mpiSize();
|
|
||||||
|
|
||||||
// initialize the two member variables
|
|
||||||
static void init(int argc, char* argv[]);
|
|
||||||
// wrapper for MPI_Finalize()
|
|
||||||
static void finalize();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* MPI_COMMUNICATION_H */
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
#ifndef PARAMETER_H
|
|
||||||
#define PARAMETER_H
|
|
||||||
|
|
||||||
#include <array>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
#include "jansson.h"
|
|
||||||
#include "simulation/jansson_additionals.h"
|
|
||||||
|
|
||||||
// class to handle the json-parameter file and read it's data
|
|
||||||
class Parameter {
|
|
||||||
public:
|
|
||||||
Parameter(std::string filename);
|
|
||||||
~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;
|
|
||||||
// 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;
|
|
||||||
// read the value at the json path and return it as a int; defaults to 0
|
|
||||||
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;
|
|
||||||
// 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;
|
|
||||||
// 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,
|
|
||||||
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;
|
|
||||||
// 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;
|
|
||||||
|
|
||||||
// check if "path" exists in the json-parameter file
|
|
||||||
bool pathExists(const json_path& path) const;
|
|
||||||
// return a pointer to the json_t object of the json-parameter_file
|
|
||||||
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;
|
|
||||||
|
|
||||||
private:
|
|
||||||
json_error_t* j_error_;
|
|
||||||
json_t* j_file_;
|
|
||||||
|
|
||||||
json_t* openParameterFile(const std::string& filename) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* PARAMETER_H */
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
#ifndef PARTICLE_H
|
|
||||||
#define PARTICLE_H
|
|
||||||
|
|
||||||
#include "blitz/array.h"
|
|
||||||
#include "simulation/coordinates.h"
|
|
||||||
#include "simulation/species.h"
|
|
||||||
|
|
||||||
namespace particle {
|
|
||||||
|
|
||||||
// class for the simulated particles
|
|
||||||
class Particle {
|
|
||||||
public:
|
|
||||||
// Constructor: takes shared_ptr to the TrackedSpecies object that describes the particle
|
|
||||||
// the Coordinate containing the position the particle should be created at
|
|
||||||
// the Vector containing the velocity the particle should be created with
|
|
||||||
Particle(std::shared_ptr<species::TrackedSpecie> specie,
|
|
||||||
const Coordinate& position,
|
|
||||||
const Vector& velocity);
|
|
||||||
|
|
||||||
// set the position of the particle to the provided Coordinate new_position
|
|
||||||
void position(const Coordinate& new_position);
|
|
||||||
// return the position of the particle as a CartesianCoordinate
|
|
||||||
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);
|
|
||||||
// return the velocity of the particle as a CartesianVector
|
|
||||||
CartesianVector velocity() const;
|
|
||||||
|
|
||||||
// ads the Coordinate distance to the position of the particle
|
|
||||||
// x_new = x_old + distance
|
|
||||||
void move(const Coordinate& distance);
|
|
||||||
|
|
||||||
// return the kinetic energy of the particle in eV
|
|
||||||
double kineticEnergy_eV() const;
|
|
||||||
// return the modulus of the particle velocity in m/s
|
|
||||||
double absoluteVelocity() const;
|
|
||||||
// return the squared modulus of the particle velocity in (m/s)^2
|
|
||||||
double absoluteVelocitySquared() const;
|
|
||||||
|
|
||||||
// return the mass of the particle in kg (i.e. the mass of the particles specie)
|
|
||||||
double mass_kg() const;
|
|
||||||
// return the charge of the particle in C (i.e. the charge of the particles specie)
|
|
||||||
double charge_C() const;
|
|
||||||
|
|
||||||
// get a raw pointer to the TrackedSpecie object of the particle
|
|
||||||
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);
|
|
||||||
// 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();
|
|
||||||
// return the value of the number of interactions performed by the particle
|
|
||||||
long int interactionCounter() const;
|
|
||||||
|
|
||||||
// increase member variable counting the total time (in s) that the
|
|
||||||
// particle has been alive
|
|
||||||
void increaseTimeAlive(double time_s);
|
|
||||||
// return the time the particle has been alive (in s)
|
|
||||||
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);
|
|
||||||
// reset the time in bin variable (i.e. set to 0)
|
|
||||||
void resetTimeInBin();
|
|
||||||
// return the time the particle has not changed any bin
|
|
||||||
double timeInBin() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
CartesianVector velocity_;
|
|
||||||
CartesianCoordinate position_;
|
|
||||||
CylinderCoordinate position_cyl_;
|
|
||||||
|
|
||||||
double time_alive_s_;
|
|
||||||
double time_in_bin_s_;
|
|
||||||
long int interaction_counter_;
|
|
||||||
|
|
||||||
std::shared_ptr<species::TrackedSpecie> specie_;
|
|
||||||
long int id_;
|
|
||||||
|
|
||||||
static long int last_id_; // only local on this cpu
|
|
||||||
};
|
|
||||||
|
|
||||||
}; // namespace particle
|
|
||||||
|
|
||||||
#endif /* PARTICLE_H */
|
|
||||||
@@ -1,137 +0,0 @@
|
|||||||
#ifndef POSITION_BINNING_H
|
|
||||||
#define POSITION_BINNING_H
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include "blitz/array.h"
|
|
||||||
|
|
||||||
// class for a linear binning without under- or overflow bins
|
|
||||||
class LowerAndUpperBoundBinning {
|
|
||||||
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);
|
|
||||||
|
|
||||||
// return the bin index, that includes the value position
|
|
||||||
int bin(double position) const;
|
|
||||||
// return the spacing between the bin borders
|
|
||||||
double stepsize() const;
|
|
||||||
// getter for the number of bins
|
|
||||||
int numBins() const;
|
|
||||||
// returns the index for the first bin (0)
|
|
||||||
int binIndexMin() const;
|
|
||||||
// returns the index for the last bin (num_bins - 1)
|
|
||||||
int binIndexMax() const;
|
|
||||||
// return a vector containing the edges of the bins
|
|
||||||
std::vector<double> binBorders() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int num_bins_;
|
|
||||||
double stepsize_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// class for a linear binning with an overflow but no underflow bin
|
|
||||||
class LowerBoundBinningWithOverflow {
|
|
||||||
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,
|
|
||||||
double maximum);
|
|
||||||
|
|
||||||
// return the bin index, that includes the value position
|
|
||||||
int bin(double position) const;
|
|
||||||
// return the spacing between the bin borders
|
|
||||||
double stepsize() const;
|
|
||||||
// returns the number of bins including the overflow bin
|
|
||||||
int numBinsWithOverflow() const;
|
|
||||||
// returns the number of bins excluding the overflow bin
|
|
||||||
int numBinsWithoutOverflow() const;
|
|
||||||
// returns the index for the first bin (0)
|
|
||||||
int binIndexMin() const;
|
|
||||||
// returns the index for the last bin (i.e. the overflow bin)
|
|
||||||
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;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int num_bins_;
|
|
||||||
double stepsize_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// class for a linear binning with an under- and overflow bin
|
|
||||||
class BinningWithOverAndUnderflow {
|
|
||||||
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,
|
|
||||||
double maximum);
|
|
||||||
|
|
||||||
// return the bin index, that includes the value position
|
|
||||||
int bin(double position) const;
|
|
||||||
// return the spacing between the bin borders
|
|
||||||
double stepsize() const;
|
|
||||||
// returns the number of bins including both the overflow and underflow bin
|
|
||||||
int numBinsWithOverUnderflow() const;
|
|
||||||
// returns the number of bins excluding both the overflow and underflow bin
|
|
||||||
int numBinsWithoutOverUnderflow() const;
|
|
||||||
// returns the index for the first (underflow) bin (-1)
|
|
||||||
int binIndexMin() const;
|
|
||||||
// returns the index for the last bin (i.e. the overflow bin)
|
|
||||||
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;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int num_bins_;
|
|
||||||
double stepsize_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// class for handling the segmentation of a cylindrical domain
|
|
||||||
class CylinderBinning {
|
|
||||||
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,
|
|
||||||
double radius,
|
|
||||||
int num_bins_azimuthal,
|
|
||||||
int num_bins_longitudinal,
|
|
||||||
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(
|
|
||||||
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;
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
// 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;
|
|
||||||
// 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;
|
|
||||||
// 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;
|
|
||||||
|
|
||||||
// binnings for each of the three directions (radial, azimuthal, longitudinal)
|
|
||||||
const LowerBoundBinningWithOverflow radial_binning;
|
|
||||||
const LowerAndUpperBoundBinning azimuth_binning;
|
|
||||||
const BinningWithOverAndUnderflow longitudinal_binning;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* POSITION_BINNING_H */
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
#ifndef RANDOM_NUMBERS_H
|
|
||||||
#define RANDOM_NUMBERS_H
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <memory>
|
|
||||||
#include <random>
|
|
||||||
|
|
||||||
// class to handle a random generator object
|
|
||||||
class RandomNumbers {
|
|
||||||
public:
|
|
||||||
// Constructor: takes the seed for the random engine
|
|
||||||
RandomNumbers(int seed);
|
|
||||||
|
|
||||||
// draw a uniformly distributed integer number between min, max
|
|
||||||
int rollUniform(int min, int max);
|
|
||||||
// draw a uniformly distributed double number between min, max
|
|
||||||
double rollUniform(double min, double max);
|
|
||||||
|
|
||||||
// getter for the pointer to the mersenne twister 19937 engine
|
|
||||||
std::mt19937* engine();
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::shared_ptr<std::mt19937> engine_;
|
|
||||||
std::uniform_real_distribution<double> real_distribution_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* RANDOM_NUMBERS_H */
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
#ifndef REFLECTOR_H
|
|
||||||
#define REFLECTOR_H
|
|
||||||
|
|
||||||
#include "simulation/particle.h"
|
|
||||||
|
|
||||||
// class defining the minimum requirements of a Reflector class
|
|
||||||
class Reflector {
|
|
||||||
public:
|
|
||||||
virtual bool needsReflectionBackToDomain(
|
|
||||||
const 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 {
|
|
||||||
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);
|
|
||||||
// check if Particle particle needs to be reflected
|
|
||||||
bool needsReflectionBackToDomain(const particle::Particle* particle) const;
|
|
||||||
// perform the reflection of the particle back to the left
|
|
||||||
void reflectBackToDomain(particle::Particle* particle) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
const double z_position_dps_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// class for particles that are not reflected anywhere
|
|
||||||
class NoReflector : public Reflector {
|
|
||||||
// always returns false
|
|
||||||
bool needsReflectionBackToDomain(const particle::Particle* particle) const;
|
|
||||||
// does nothing
|
|
||||||
void reflectBackToDomain(particle::Particle* particle) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* REFLECTOR_H */
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
#ifndef SCALAR_FIELD_H
|
|
||||||
#define SCALAR_FIELD_H
|
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
#include "blitz/array.h"
|
|
||||||
|
|
||||||
#include "simulation/coordinates.h"
|
|
||||||
|
|
||||||
// class for a scalar field
|
|
||||||
class ScalarField {
|
|
||||||
public:
|
|
||||||
// returns the value of the scalar field at the Coordinate coordinate
|
|
||||||
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 {
|
|
||||||
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);
|
|
||||||
|
|
||||||
// return the value of the scalar field at Coordinate coordinate
|
|
||||||
double value(const Coordinate& coordinate) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::function<double(double, double, double)> F_z_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* SCALAR_FIELD_H */
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
#ifndef SCATTERING_ANGLE_DISTRIBUTION_H
|
|
||||||
#define SCATTERING_ANGLE_DISTRIBUTION_H
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <memory>
|
|
||||||
#include <random>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "simulation/energy_binning.h"
|
|
||||||
|
|
||||||
// class defining the minimum requirements of a scattering angle distribution
|
|
||||||
class ScatteringAngleDistribution {
|
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|
||||||
// class for an isotropic scattering angle distribution
|
|
||||||
class IsotropicAngleDistribution : public ScatteringAngleDistribution {
|
|
||||||
public:
|
|
||||||
// Constructor: initializes a uniform distribution between (o,2pi)
|
|
||||||
IsotropicAngleDistribution();
|
|
||||||
// draw from a uniform distribution
|
|
||||||
double roll(std::mt19937* engine, double energy_eV = 0.);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::uniform_real_distribution<double> distribution_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// class for drawing from a piecewise linear scattering angle distribution
|
|
||||||
class AngleDistributionFromFile : public ScatteringAngleDistribution {
|
|
||||||
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);
|
|
||||||
// draw a value from the distribution
|
|
||||||
double roll(std::mt19937* engine, double energy_eV);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::shared_ptr<EnergyBinning> energy_binning_;
|
|
||||||
std::vector<std::piecewise_linear_distribution<double>> angle_distributions_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// class for a composition of two scattering angle distibutions
|
|
||||||
class CompositeAngleDistribution : public ScatteringAngleDistribution {
|
|
||||||
public:
|
|
||||||
// Constructor: takes two ScatteringAngleDistributions and a decider energy (eV)
|
|
||||||
// if energy_eV < decider energy use lower_distribution
|
|
||||||
// otherwise use the higher_distribution
|
|
||||||
CompositeAngleDistribution(
|
|
||||||
std::shared_ptr<ScatteringAngleDistribution> lower_distribution,
|
|
||||||
std::shared_ptr<ScatteringAngleDistribution> higher_distribution,
|
|
||||||
double decider_energy);
|
|
||||||
// draw a value from the distribution
|
|
||||||
double roll(std::mt19937* engine, double energy_eV);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::shared_ptr<ScatteringAngleDistribution> lower_distribution_;
|
|
||||||
std::shared_ptr<ScatteringAngleDistribution> higher_distribution_;
|
|
||||||
const double decider_energy_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* SCATTERING_ANGLE_DISTRIBUTION_H */
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
#ifndef SIMULATION_H
|
|
||||||
#define SIMULATION_H
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <memory>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "simulation/parameter.h"
|
|
||||||
#include "simulation/particle.h"
|
|
||||||
|
|
||||||
// defined in "simulation/random_numbers.h"
|
|
||||||
class RandomNumbers;
|
|
||||||
// defined in "simulation/interaction.h"
|
|
||||||
class InteractionOutput;
|
|
||||||
// defined in "simulation/electromagnetic_field.h"
|
|
||||||
class MagneticField;
|
|
||||||
class ElectricField;
|
|
||||||
// defined in "simulation/timer.h"
|
|
||||||
class Timer;
|
|
||||||
// defined in "simulation/injector.h"
|
|
||||||
class Injector;
|
|
||||||
// defined in "IO/simulation_output.h"
|
|
||||||
class SimulationOutput;
|
|
||||||
// defined in "simulation/cpu_synchronizer.h"
|
|
||||||
class CpuSynchronizer;
|
|
||||||
|
|
||||||
// defined in "simulation/species.h"
|
|
||||||
namespace species {
|
|
||||||
class Specie;
|
|
||||||
};
|
|
||||||
|
|
||||||
// defined in "simulation/interaction.h"
|
|
||||||
namespace interaction {
|
|
||||||
class InteractionOutput;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Simulation {
|
|
||||||
public:
|
|
||||||
// Constructor: initialize everything using the json file at the path in parameter_filename
|
|
||||||
Simulation(std::string parameter_filename);
|
|
||||||
|
|
||||||
// function for initialization from Parameter object
|
|
||||||
void init(Parameter& parameter);
|
|
||||||
// function for main simulation loop
|
|
||||||
void start();
|
|
||||||
// function to finalize simulation
|
|
||||||
void finalize();
|
|
||||||
// process events until "events" number of beta decay chains have been
|
|
||||||
// simulated until completion
|
|
||||||
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,
|
|
||||||
std::vector<particle::Particle>& particle_queue);
|
|
||||||
|
|
||||||
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(
|
|
||||||
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,
|
|
||||||
RandomNumbers* random,
|
|
||||||
std::vector<double>& macroscopic_cross_sections_m);
|
|
||||||
|
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>
|
|
||||||
tracked_species_;
|
|
||||||
std::map<std::string, std::shared_ptr<species::BackgroundSpecie>>
|
|
||||||
background_species_;
|
|
||||||
|
|
||||||
std::shared_ptr<Injector> injector_;
|
|
||||||
|
|
||||||
std::shared_ptr<MagneticField> magnetic_field_;
|
|
||||||
std::shared_ptr<ElectricField> electric_field_;
|
|
||||||
|
|
||||||
Parameter parameter_;
|
|
||||||
std::shared_ptr<RandomNumbers> random_;
|
|
||||||
|
|
||||||
std::shared_ptr<Timer> timer_;
|
|
||||||
|
|
||||||
std::shared_ptr<SimulationOutput> output_;
|
|
||||||
std::shared_ptr<CpuSynchronizer> cpu_synchronizer_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* SIMULATION_H */
|
|
||||||
@@ -1,208 +0,0 @@
|
|||||||
#ifndef SPECIES_H
|
|
||||||
#define SPECIES_H
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "simulation/parameter.h"
|
|
||||||
|
|
||||||
// defined in "simulation/mover.h"
|
|
||||||
class Mover;
|
|
||||||
// defined in "simulation/terminator.h"
|
|
||||||
class Terminator;
|
|
||||||
// defined in "simulation/reflector.h"
|
|
||||||
class Reflector;
|
|
||||||
// defined in "simulation/injector.h"
|
|
||||||
class Injector;
|
|
||||||
// defined in "simulation/density_field.h"
|
|
||||||
class DensityField;
|
|
||||||
class DynamicDensityField;
|
|
||||||
class ConstantDensityField;
|
|
||||||
// defined in "simulation/logger.h"
|
|
||||||
class DeletionLogger;
|
|
||||||
// defined in "simulation/current_collector.h"
|
|
||||||
class CurrentCollector;
|
|
||||||
// defined in "simulation/velocity_distribution.h"
|
|
||||||
class VelocityDistribution;
|
|
||||||
// defined in "simulation/drift_velocity.h"
|
|
||||||
class DriftVelocity;
|
|
||||||
|
|
||||||
// defined in "simulation/interaction.h"
|
|
||||||
namespace interaction {
|
|
||||||
class Interaction;
|
|
||||||
};
|
|
||||||
|
|
||||||
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 };
|
|
||||||
|
|
||||||
// general specie, defining the minimum requirements for all other specie classes
|
|
||||||
class Specie {
|
|
||||||
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,
|
|
||||||
std::string name,
|
|
||||||
double mass_kg,
|
|
||||||
double charge_C);
|
|
||||||
|
|
||||||
// getter for the mass of the species (in kg)
|
|
||||||
double mass_kg() const;
|
|
||||||
// getter for the charge of the species (in Coulomb)
|
|
||||||
double charge_C() const;
|
|
||||||
// getter for the type of the species (ImplementedSpecies enum)
|
|
||||||
ImplementedSpecies type() const;
|
|
||||||
// getter for the name of the species
|
|
||||||
std::string name() const;
|
|
||||||
|
|
||||||
// getter for the DensityField pointer
|
|
||||||
virtual DensityField* densityField() = 0;
|
|
||||||
// getter for the VelocityDistribution pointer
|
|
||||||
virtual VelocityDistribution* velocityDistibution() = 0;
|
|
||||||
// getter for the DriftVelocity pointer
|
|
||||||
virtual DriftVelocity* driftVelocity() = 0;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// mass of species in kg
|
|
||||||
const double mass_kg_;
|
|
||||||
// charge of species in C
|
|
||||||
const double charge_C_;
|
|
||||||
// type of species defined by ImplementedSpecies enum
|
|
||||||
const ImplementedSpecies type_;
|
|
||||||
// arbitrary name of the species
|
|
||||||
const std::string name_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// class for particle species that are simulated
|
|
||||||
class TrackedSpecie : public Specie {
|
|
||||||
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,
|
|
||||||
std::string name,
|
|
||||||
double mass_kg,
|
|
||||||
double charge_C,
|
|
||||||
std::shared_ptr<Mover> mover,
|
|
||||||
std::shared_ptr<Terminator> terminator,
|
|
||||||
std::shared_ptr<Reflector> reflector,
|
|
||||||
std::shared_ptr<DynamicDensityField> density_field,
|
|
||||||
std::shared_ptr<VelocityDistribution> velocity_distribution,
|
|
||||||
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();
|
|
||||||
// getter for a raw pointer to the VelocityDistribution member
|
|
||||||
VelocityDistribution* velocityDistibution();
|
|
||||||
// getter for a raw pointer to the driftVelocity member
|
|
||||||
DriftVelocity* driftVelocity();
|
|
||||||
|
|
||||||
// getter for a raw pointer to the DynamicDensityField member
|
|
||||||
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();
|
|
||||||
// getter for a raw pointer to the Terminator member
|
|
||||||
Terminator* terminator();
|
|
||||||
// getter for a raw pointer to the Reflector member
|
|
||||||
Reflector* reflector();
|
|
||||||
// getter for a raw pointer to the DeletionLogger member
|
|
||||||
DeletionLogger* deletionLogger();
|
|
||||||
|
|
||||||
// setter for the DeletionLogger member
|
|
||||||
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();
|
|
||||||
// setter for the CurrentCollector member
|
|
||||||
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();
|
|
||||||
// adds the shared_ptr of the Interaction object "interaction" to the vector
|
|
||||||
// of possible interactions
|
|
||||||
void addInteraction(std::shared_ptr<interaction::Interaction> interaction);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::shared_ptr<DynamicDensityField> density_field_;
|
|
||||||
std::shared_ptr<VelocityDistribution> velocity_distribution_;
|
|
||||||
std::shared_ptr<DriftVelocity> drift_velocity_;
|
|
||||||
|
|
||||||
std::shared_ptr<Mover> mover_;
|
|
||||||
std::shared_ptr<Terminator> terminator_;
|
|
||||||
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<CurrentCollector> current_collector_;
|
|
||||||
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 {
|
|
||||||
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,
|
|
||||||
std::string name,
|
|
||||||
double mass_kg,
|
|
||||||
double charge_C,
|
|
||||||
std::shared_ptr<ConstantDensityField> density_field,
|
|
||||||
std::shared_ptr<VelocityDistribution> velocity_distribution,
|
|
||||||
std::shared_ptr<DriftVelocity> drift_velocity);
|
|
||||||
|
|
||||||
// getter for a raw pointer to the ConstantDensityField member as its parent type
|
|
||||||
DensityField* densityField();
|
|
||||||
// getter for a raw pointer to the VelocityDistribution member
|
|
||||||
VelocityDistribution* velocityDistibution();
|
|
||||||
// getter for a raw pointer to the driftVelocity member
|
|
||||||
DriftVelocity* driftVelocity();
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::shared_ptr<ConstantDensityField> density_field_;
|
|
||||||
std::shared_ptr<VelocityDistribution> velocity_distribution_;
|
|
||||||
std::shared_ptr<DriftVelocity> drift_velocity_;
|
|
||||||
};
|
|
||||||
|
|
||||||
}; // namespace species
|
|
||||||
|
|
||||||
#endif /* SPECIES_H */
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
#ifndef TERMINATOR_H
|
|
||||||
#define TERMINATOR_H
|
|
||||||
|
|
||||||
#include "simulation/particle.h"
|
|
||||||
|
|
||||||
// defined in "simulation/geometry.h"
|
|
||||||
class Geometry;
|
|
||||||
|
|
||||||
// class for checking if a paricle has to be terminated due to
|
|
||||||
// any reason except interaction effects
|
|
||||||
class Terminator {
|
|
||||||
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,
|
|
||||||
double max_time_alive,
|
|
||||||
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;
|
|
||||||
// check if particle has crossed any boundary of the Geometry
|
|
||||||
bool leftSimulationDomain(const particle::Particle* particle) const;
|
|
||||||
// check if particle has reached the maximum interaction count
|
|
||||||
bool reachedMaxInteractions(const particle::Particle* particle) const;
|
|
||||||
// check if the particle has reached its maximum lifetime
|
|
||||||
bool reachedMaxTimeAlive(const particle::Particle* particle) const;
|
|
||||||
// return the maximum lifetime
|
|
||||||
double maxTimeAlive() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
const long int max_interactions_;
|
|
||||||
const double max_time_alive_;
|
|
||||||
std::shared_ptr<Geometry> geometry_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* TERMINATOR_H */
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
#ifndef TIMER_H
|
|
||||||
#define TIMER_H
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
// class to keep track of the "simulation time" (i.e. number of processed events * Activity)
|
|
||||||
class Timer {
|
|
||||||
public:
|
|
||||||
// Constructor; initializes time to 0
|
|
||||||
Timer();
|
|
||||||
|
|
||||||
// getter for the time
|
|
||||||
double time() const;
|
|
||||||
// increase the time by time_s (time in s)
|
|
||||||
void increaseTimestep(double time_s);
|
|
||||||
// set time to time_s
|
|
||||||
void setTime(double time_s);
|
|
||||||
|
|
||||||
private:
|
|
||||||
double current_time_s_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* TIMER_H */
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#ifndef TRITIUM_SPECTRUM_H
|
|
||||||
#define TRITIUM_SPECTRUM_H
|
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
|
|
||||||
// return a function calculating the fermi distribution with the given prefactor
|
|
||||||
std::function<double(double)> tritiumDecayEnergySpectrum(double prefactor);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* TRITIUM_SPECTRUM_H */
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#ifndef UNIT_CONVERTER_H
|
|
||||||
#define UNIT_CONVERTER_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
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,
|
|
||||||
const std::string& unit_from,
|
|
||||||
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);
|
|
||||||
|
|
||||||
// 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,
|
|
||||||
const std::string& unit_from,
|
|
||||||
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);
|
|
||||||
|
|
||||||
}; // namespace unitConvertion
|
|
||||||
|
|
||||||
#endif /* UNIT_CONVERTER_H */
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
#ifndef VECTOR_FIELD_H
|
|
||||||
#define VECTOR_FIELD_H
|
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
#include "blitz/array.h"
|
|
||||||
|
|
||||||
#include "simulation/coordinates.h"
|
|
||||||
#include "simulation/position_binning.h"
|
|
||||||
|
|
||||||
// class for vector fields
|
|
||||||
class VectorField {
|
|
||||||
public:
|
|
||||||
// return the value of the vector field at the Coordinate coordinate as a
|
|
||||||
// CylinderVector object
|
|
||||||
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 {
|
|
||||||
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,
|
|
||||||
const blitz::Array<double, 3>& azimuthal_component,
|
|
||||||
const blitz::Array<double, 3>& longitudial_component,
|
|
||||||
double radius,
|
|
||||||
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;
|
|
||||||
|
|
||||||
private:
|
|
||||||
const blitz::Array<double, 3> Fr_;
|
|
||||||
const blitz::Array<double, 3> Fphi_;
|
|
||||||
const blitz::Array<double, 3> Fz_;
|
|
||||||
|
|
||||||
// used to determine which array element is neccessary in the value() function
|
|
||||||
CylinderBinning binning_;
|
|
||||||
CylinderVector value(const blitz::TinyVector<int, 3>& bin) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// class for spatially constant vector fields
|
|
||||||
class VectorFieldConstant : public VectorField {
|
|
||||||
public:
|
|
||||||
// Constructor: takes the value of the constant cylinder vector for the vector field
|
|
||||||
VectorFieldConstant(const CylinderVector& constant);
|
|
||||||
// return the value of the vector field at the Coordinate coordinate as a CylinderVector
|
|
||||||
CylinderVector value(const Coordinate& coordinate) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
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 {
|
|
||||||
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);
|
|
||||||
// return the value of the vector field at the Coordinate coordinate as a CylinderVector
|
|
||||||
CylinderVector value(const Coordinate& coordinate) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::function<double(double, double, double)> F_z_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* VECTOR_FIELD_H */
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
#ifndef VELOCITY_DISTRIBUTION_H
|
|
||||||
#define VELOCITY_DISTRIBUTION_H
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <random>
|
|
||||||
#include "simulation/coordinates.h"
|
|
||||||
|
|
||||||
// defined in "velocity_distribution_function.h"
|
|
||||||
class VelocityDistributionFunction;
|
|
||||||
|
|
||||||
// class to define the minimum requirements of a velocity distribution function
|
|
||||||
// (in the frame center of mass frame)
|
|
||||||
class VelocityDistribution {
|
|
||||||
public:
|
|
||||||
// draw a randomly oriented Cartesian velocity vector at the Coordinate position
|
|
||||||
// using the random engine
|
|
||||||
virtual CartesianVector rollVelocity(const Coordinate& position,
|
|
||||||
std::mt19937* engine) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
// class that defines a velocity distribution by the usage of a VelocityDistributionFunction
|
|
||||||
// object
|
|
||||||
class VelocityDistributionFromFunction : public VelocityDistribution {
|
|
||||||
public:
|
|
||||||
// Constructor: takes a shared_ptr to the VelocityDistributionFunction, that defines the
|
|
||||||
// distribution to be drawn from
|
|
||||||
VelocityDistributionFromFunction(
|
|
||||||
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,
|
|
||||||
std::mt19937* engine);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::shared_ptr<VelocityDistributionFunction> fv_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* VELOCITY_DISTRIBUTION_H */
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
#ifndef VELOCITY_DISTRIBUTION_FUNCTION_H
|
|
||||||
#define VELOCITY_DISTRIBUTION_FUNCTION_H
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <random>
|
|
||||||
|
|
||||||
#include "simulation/coordinates.h"
|
|
||||||
|
|
||||||
// defined in "simulation/energy_distribution.h"
|
|
||||||
class EnergyDistributionFunction;
|
|
||||||
|
|
||||||
// class to define minimum requirements for a VelocityDistributionFunction child class
|
|
||||||
class VelocityDistributionFunction {
|
|
||||||
public:
|
|
||||||
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 {
|
|
||||||
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,
|
|
||||||
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);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::shared_ptr<EnergyDistributionFunction> f_E_;
|
|
||||||
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 {
|
|
||||||
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,
|
|
||||||
double mass_kg,
|
|
||||||
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);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::shared_ptr<EnergyDistributionFunction> f_E_;
|
|
||||||
const blitz::TinyVector<double, 3> direction_normal_;
|
|
||||||
const double mass_kg_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* VELOCITY_DISTRIBUTION_FUNCTION_H */
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
#ifndef SIMULATION_TIME_H
|
|
||||||
#define SIMULATION_TIME_H
|
|
||||||
|
|
||||||
#include <chrono>
|
|
||||||
#include <map>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
// structure to measure a timing (stores begin and endpoint and the corresponding timespan)
|
|
||||||
struct TimerEvent {
|
|
||||||
std::chrono::time_point<std::chrono::high_resolution_clock> start;
|
|
||||||
std::chrono::time_point<std::chrono::high_resolution_clock> stop;
|
|
||||||
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 {
|
|
||||||
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);
|
|
||||||
// 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);
|
|
||||||
// print a formatted string containing all event_names and their respective timing to stdout
|
|
||||||
static void printDurations();
|
|
||||||
|
|
||||||
private:
|
|
||||||
// map to store all event_names with their TimerEvent structs
|
|
||||||
static std::map<std::string, TimerEvent> timed_events_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* SIMULATION_TIME_H */
|
|
||||||
@@ -1,167 +0,0 @@
|
|||||||
dummy: all
|
|
||||||
|
|
||||||
# Directories
|
|
||||||
PROJECT_DIR = $(HOMEBASE)
|
|
||||||
CONFIG_DIR = $(PROJECT_DIR)/config
|
|
||||||
BUILD_DIR = $(PROJECT_DIR)/build
|
|
||||||
BIN_DIR = $(PROJECT_DIR)/bin
|
|
||||||
INCLUDES_DIR = $(PROJECT_DIR)/include
|
|
||||||
|
|
||||||
SRC_DIR = $(PROJECT_DIR)/src
|
|
||||||
SUB_DIRS = $(SRC_DIR)/simulation $(SRC_DIR)/generators $(SRC_DIR)/functions $(SRC_DIR)/interactions $(SRC_DIR)/IO $(SRC_DIR)/tools
|
|
||||||
|
|
||||||
# Configs
|
|
||||||
ifndef CONFIG
|
|
||||||
CONFIG = $(CONFIG_DIR)/config.mk
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifndef COMPILER_CONFIG
|
|
||||||
COMPILER_CONFIG = $(CONFIG_DIR)/compiler.mk
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Includes
|
|
||||||
include $(CONFIG)
|
|
||||||
include $(COMPILER_CONFIG)
|
|
||||||
|
|
||||||
MAIN_INC = -I$(INCLUDES_DIR)
|
|
||||||
|
|
||||||
# Compiler instructions
|
|
||||||
CXX=$(COMPILER)
|
|
||||||
CXXFLAGS=$(COMPILER_FLAGS) $(MAIN_INC)
|
|
||||||
|
|
||||||
LIBS =#-static
|
|
||||||
|
|
||||||
CXXFLAGS += -DHOMEBASE=$(HOMEBASE)
|
|
||||||
|
|
||||||
# Blitz
|
|
||||||
CXXFLAGS += $(BLITZ_INCLUDES)
|
|
||||||
LIBS += $(BLITZ_LIBS)
|
|
||||||
|
|
||||||
# HDF5
|
|
||||||
CXXFLAGS += $(HDF5P_INCLUDES)
|
|
||||||
LIBS += $(HDF5P_LIBRARIES)
|
|
||||||
|
|
||||||
# Jansson
|
|
||||||
CXXFLAGS += $(JANSSON_INCLUDES)
|
|
||||||
LIBS += $(JANSSON_LIBRARIES)
|
|
||||||
|
|
||||||
CXXFLAGS += -g
|
|
||||||
|
|
||||||
ifeq ($(DO_DEBUGGING),true)
|
|
||||||
CXXFLAGS += -ftemplate-depth-30 #-DBZ_DEBUG
|
|
||||||
CXXFLAGS += -Ddebug
|
|
||||||
CXXFLAGS += -Ddebug_level$(DEBUG_LEVEL)
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(USE_TIMER),true)
|
|
||||||
CXXFLAGS += -DTIMER
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
# Sources
|
|
||||||
SRC_SUBDIRS = $(foreach sdir, $(SUB_DIRS), $(wildcard $(sdir)/*.cpp))
|
|
||||||
|
|
||||||
SOURCES = $(SRC_DIR)/main.cpp
|
|
||||||
SOURCES += $(SRC_SUBDIRS)
|
|
||||||
|
|
||||||
# Objects
|
|
||||||
OBJECTS=$(addprefix $(BUILD_DIR)/, $(notdir $(SOURCES:.cpp=.o)) )
|
|
||||||
|
|
||||||
# Target
|
|
||||||
# put the exe file in bin/
|
|
||||||
TARGET=$(BIN_DIR)/karl
|
|
||||||
|
|
||||||
# Compile logic
|
|
||||||
|
|
||||||
all: blitz jansson karl
|
|
||||||
|
|
||||||
check_homebase:
|
|
||||||
ifeq ($(HOMEBASE),)
|
|
||||||
@echo "### \$$HOMEBASE must be set! ###"
|
|
||||||
@exit 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
IS_ABSPATH := $(if $(patsubst /%,,$(HOMEBASE)),,yes)
|
|
||||||
check_abspath:
|
|
||||||
ifneq ($(IS_ABSPATH), yes)
|
|
||||||
$(info ### \$$HOMEBASE must be an absolute path! ###)
|
|
||||||
@exit 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
blitz: check_homebase
|
|
||||||
ifeq ($(MAKE_BLITZ), true)
|
|
||||||
$(MAKE) -C external/blitz
|
|
||||||
endif
|
|
||||||
|
|
||||||
jansson: check_homebase
|
|
||||||
ifeq ($(MAKE_JANSSON), true)
|
|
||||||
$(MAKE) -C external/jansson
|
|
||||||
endif
|
|
||||||
|
|
||||||
karl: check_abspath check_homebase $(TARGET)
|
|
||||||
|
|
||||||
$(TARGET): $(BUILD_DIR) $(BIN_DIR) $(OBJECTS)
|
|
||||||
$(CXX) $(OBJECTS) $(LIBS) -o $(TARGET)
|
|
||||||
@echo
|
|
||||||
@echo "Linking done"
|
|
||||||
@echo
|
|
||||||
|
|
||||||
|
|
||||||
$(BIN_DIR):
|
|
||||||
@mkdir -p $(BIN_DIR)
|
|
||||||
|
|
||||||
$(BUILD_DIR):
|
|
||||||
@mkdir -p $(BUILD_DIR)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
################
|
|
||||||
# KARL
|
|
||||||
################
|
|
||||||
|
|
||||||
$(BUILD_DIR)/%.o : $(SRC_DIR)/%.cpp
|
|
||||||
@echo "Create $(notdir $@) from $(notdir $<)"
|
|
||||||
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
||||||
@echo
|
|
||||||
|
|
||||||
$(BUILD_DIR)/%.o : $(SRC_DIR)/simulation/%.cpp
|
|
||||||
@echo "Create $(notdir $@) from $(notdir $<)"
|
|
||||||
@echo
|
|
||||||
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
||||||
|
|
||||||
$(BUILD_DIR)/%.o : $(SRC_DIR)/generators/%.cpp
|
|
||||||
@echo "Create $(notdir $@) from $(notdir $<)"
|
|
||||||
@echo
|
|
||||||
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
||||||
|
|
||||||
$(BUILD_DIR)/%.o : $(SRC_DIR)/functions/%.cpp
|
|
||||||
@echo "Create $(notdir $@) from $(notdir $<)"
|
|
||||||
@echo
|
|
||||||
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
||||||
|
|
||||||
$(BUILD_DIR)/%.o : $(SRC_DIR)/interactions/%.cpp
|
|
||||||
@echo "Create $(notdir $@) from $(notdir $<)"
|
|
||||||
@echo
|
|
||||||
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
||||||
|
|
||||||
$(BUILD_DIR)/%.o : $(SRC_DIR)/IO/%.cpp
|
|
||||||
@echo "Create $(notdir $@) from $(notdir $<)"
|
|
||||||
@echo
|
|
||||||
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
||||||
|
|
||||||
$(BUILD_DIR)/%.o : $(SRC_DIR)/tools/%.cpp
|
|
||||||
@echo "Create $(notdir $@) from $(notdir $<)"
|
|
||||||
@echo
|
|
||||||
$(CXX) $(CXXFLAGS) $< -c -o $@
|
|
||||||
|
|
||||||
|
|
||||||
# All build instructions for all src cpp are put here
|
|
||||||
$(BUILD_DIR)/main.o : $(SRC_DIR)/main.cpp
|
|
||||||
|
|
||||||
clean:
|
|
||||||
-rm -rf $(BUILD_DIR)
|
|
||||||
-rm -rf $(BIN_DIR)
|
|
||||||
|
|
||||||
clean_all: clean
|
|
||||||
-$(MAKE) -C external/blitz clean
|
|
||||||
-$(MAKE) -C external/jansson clean
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
{
|
|
||||||
"DriftVelocityExample1": {
|
|
||||||
"DriftVelocity": {
|
|
||||||
"VectorField": {
|
|
||||||
"VectorFieldFunctionInZ": {
|
|
||||||
"zFunction": {
|
|
||||||
"Product": {
|
|
||||||
"fi": {
|
|
||||||
"Constant": {
|
|
||||||
"constant": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"fj": {
|
|
||||||
"Constant": {
|
|
||||||
"constant": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"fk": {
|
|
||||||
"Constant": {
|
|
||||||
"constant": 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
"DriftVelocityExample2": {
|
|
||||||
"null": {}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user