54 Commits
Author SHA1 Message Date
csendlinger 375ab23008 Adjusted preprocessor debug stuff 2025-07-09 14:04:30 +02:00
csendlinger 532bdf7979 reduction of calls to atan2, sin and cos 2025-06-04 10:43:39 +02:00
csendlinger 2439f4fca9 debug statements in preprocessor clause 2025-06-04 09:39:50 +02:00
csendlinger 90d19b0cb7 Fix in timestep calculation in Drift Mover 2025-02-05 14:27:22 +01:00
csendlinger 6c1dd8887b vel dist funct isotropic drawing fix 2025-01-28 09:45:15 +01:00
csendlinger 14c203c2f2 Adjusted activity in katrin example;
updated some comments
2025-01-22 14:41:50 +01:00
csendlinger bd867fb788 Corrected errors in Movers; added number of
mpi procs to output
2025-01-22 14:40:38 +01:00
csendlinger 6d5f18222a update KATRIN parameter file 2025-01-13 17:08:43 +01:00
csendlinger 32f882a2c5 changes README 2025-01-13 10:11:57 +01:00
csendlinger fb19d9ae83 changes in error output and adjustment comments 2025-01-13 10:09:40 +01:00
csendlinger f01ff652c9 corrected comments for ionization; changed
non-diss ion. energy to fit with value used
in cross section calc
2025-01-13 10:05:56 +01:00
csendlinger 9c999dabbb Added class for tertiary association process,
(i.e. class for density dependent cross section),
corrected some comments
2024-12-18 15:18:18 +01:00
csendlinger 0902d3d7ac Corrections in the comments;
Small code fixes
2024-12-18 15:07:19 +01:00
csendlinger 903423da61 Changes to README concerning json files 2024-12-18 15:03:21 +01:00
csendlinger 03854339ca Many, many more comments 2024-12-04 17:15:04 +01:00
csendlinger 8696517336 Removed recalculation of the cross sections
in the interaction step; reuse the ones from
the mfp calculation
2024-11-13 09:19:59 +01:00
Evil Dr. Xilef 36f85ea79f Changed README to reflect changes in the handling of external
libraries
2024-10-23 20:29:32 +00:00
Evil Dr. Xilef 2114b93f89 Deleted Jansson TGZ 2024-10-23 14:40:27 +00:00
Evil Dr. Xilef dcad5b1e61 Jansson Makefile changed 2024-10-23 14:40:05 +00:00
Evil Dr. Xilef 57b90ddbc8 Blitz Makefile changed 2024-10-23 13:31:23 +00:00
Evil Dr. Xilef 863110a281 Changed Blitz-Makefile to automatically download the defined verison 2024-10-23 13:17:28 +00:00
csendlinger 59acd0c1c3 small changes in config.mk 2024-10-23 10:12:19 +02:00
csendlinger d399706159 minor fixes 2024-10-22 10:55:37 +02:00
csendlinger cbf95aceb6 Added Mover for zero magnetic field 2024-10-18 15:37:01 +02:00
csendlinger 9e50d8bdcf bug fix for unbalanced cpu loads 2024-09-04 10:59:16 +02:00
csendlinger 3d3eff1bca update README 2024-07-29 18:00:53 +02:00
csendlinger f5e278281c Added compilation stuff for blitz++ and
jansson.
Adjusted makefile and jansson Makefile.
Updated config/config.mk
2024-07-29 17:40:01 +02:00
csendlinger ca4fb23423 README layout update 2024-07-24 10:34:14 +02:00
csendlinger b3bf076c1d added to README, updated example config.mk 2024-07-24 10:23:14 +02:00
csendlinger b9ad0ce666 quick fix for reading vector fields from a file 2024-05-16 10:26:32 +02:00
csendlinger faedddb328 fixed sign error in drift velocity 2024-04-08 16:58:12 +02:00
csendlinger 4849667211 small correction in ionization (slower electron -> ejected) 2024-03-20 10:02:48 +01:00
csendlinger 6486cf9da4 develop config file included 2024-03-15 10:32:49 +01:00
csendlinger 53a2f90d5f fixed guard against very low energies in drift mover 2024-03-13 11:05:13 +01:00
csendlinger d48f917dac Included possibility for electron as
target for recombination;
Added energy dependent deletions in recombination
2024-03-11 17:06:52 +01:00
csendlinger 30982bd4f6 Included redirection in drift velocity generator 2024-03-11 17:02:57 +01:00
csendlinger 93aa336ec9 Changed CPU synchronization from averaging to
communicating changes
2024-03-11 16:59:25 +01:00
csendlinger e291b3f880 included guard against very large (or inf) timesteps 2024-03-06 11:17:37 +01:00
csendlinger 5ac64c4da8 Fixed bug of max Interactions not getting logged,
Added functionality to cluster_formation entry,
added logging of recombination
2024-03-05 16:23:01 +01:00
csendlinger 80fdfb6dc5 small bugfix 2024-03-01 16:01:15 +01:00
csendlinger e0c0b19b69 (hopefully) fixed error in drawing decay positions 2024-02-28 11:18:54 +01:00
csendlinger b8f8110aca bugfix in zero gyro radius guard 2024-02-27 11:34:21 +01:00
csendlinger 4cfc7d51c2 minor bug fixes 2024-02-26 17:40:03 +01:00
csendlinger 4afc3382a1 included averaging in CPUsync for double valued stuff 2024-02-23 16:23:16 +01:00
csendlinger 26e96df5df fixed bug in driftmover 2024-02-22 15:49:06 +01:00
csendlinger ad313d25a2 fixed spelling 2024-02-22 15:39:59 +01:00
kellerer 5f08b9775c feat: add example script for analysis 2023-04-13 21:05:03 +02:00
Jonas Kellerer f79172b454 Add guard against zero gyro radius in drift mover 2022-11-22 18:12:10 +01:00
Jonas Kellerer 45d4556394 Add limits to plots 2022-11-21 13:53:46 +01:00
Jonas Kellerer f2d4ad3525 Removed comments and added examples 2022-11-21 13:44:24 +01:00
Jonas Kellerer b7a65dd8fe Prepare code for publication 2022-11-11 13:48:04 +01:00
Jonas Kellerer 71dc3f4ada Merge branch 'develop' 2022-11-11 13:42:46 +01:00
Jonas Kellerer 83eb37cfb2 short bugfix: missing include 2022-11-11 13:36:34 +01:00
Jonas Kellerer 83fd2e5d7e Version 2, position dependent E/B, kinetic ions, boris mover, terminator 2022-10-21 10:09:19 +02:00
865 changed files with 1034806 additions and 3634436 deletions
+6
View File
@@ -0,0 +1,6 @@
.vscode
.idea
build
bin
output
Executable
+97
View File
@@ -0,0 +1,97 @@
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?
Executable
+7
View File
@@ -0,0 +1,7 @@
build-essential
libopenmpi-dev
openmpi-bin
libhdf5-openmpi-dev
libblitz0-dev
libjansson-dev
pkg-config
+307
View File
@@ -0,0 +1,307 @@
#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)
+10
View File
@@ -0,0 +1,10 @@
import plot_densities as pd
if __name__ == '__main__':
filename_simulation_output = input("Enter filename of simulation output: ")
output_folder = input("Enter output folder: ")
species = pd.getSpecies(filename_simulation_output)
pd.plotAllDensityVsZ(filename_simulation_output, "LastSyncPeriod", species, output_folder)
pd.plotAllSpectrumAtZ(filename_simulation_output, 8, "LastSyncPeriod", species, output_folder)
+89
View File
@@ -0,0 +1,89 @@
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
+8
View File
@@ -0,0 +1,8 @@
# Compiler
SCXX = g++
MPICXX = mpic++
COMPILER=$(MPICXX)
# Compiler Flags
COMPILER_FLAGS = -std=c++11 -O3 -march=native
+49
View File
@@ -0,0 +1,49 @@
# 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)
@@ -0,0 +1,77 @@
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)
@@ -0,0 +1,86 @@
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)
@@ -1,7 +1,6 @@
# Total Elastic Scattering Cross Section from
# Yoon et al, Cross Sections for Electron Collisions with Hydrogen Molecules, 2008
# Energy (eV) Cross section (m^2)
0.02 7.41e-20
0.03 7.71e-20
0.04 8.08e-20
+58
View File
@@ -0,0 +1,58 @@
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.
+1000000
View File
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,42 @@
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
@@ -0,0 +1,64 @@
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 Executable
+35
View File
@@ -0,0 +1,35 @@
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
+4322 -1311
View File
File diff suppressed because it is too large Load Diff
Vendored Executable
+32
View File
@@ -0,0 +1,32 @@
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
+30
View File
@@ -0,0 +1,30 @@
#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 */
+37
View File
@@ -0,0 +1,37 @@
#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 */
+162
View File
@@ -0,0 +1,162 @@
#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 */
+16
View File
@@ -0,0 +1,16 @@
#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 */
+10
View File
@@ -0,0 +1,10 @@
#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 */
+74
View File
@@ -0,0 +1,74 @@
#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
+21
View File
@@ -0,0 +1,21 @@
#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 */
+40
View File
@@ -0,0 +1,40 @@
#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 */
+75
View File
@@ -0,0 +1,75 @@
#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 */
+22
View File
@@ -0,0 +1,22 @@
#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 */
+28
View File
@@ -0,0 +1,28 @@
#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 */
+29
View File
@@ -0,0 +1,29 @@
#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 */
+21
View File
@@ -0,0 +1,21 @@
#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 */
@@ -0,0 +1,33 @@
#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 */
+44
View File
@@ -0,0 +1,44 @@
#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 */
+21
View File
@@ -0,0 +1,21 @@
#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 */
+45
View File
@@ -0,0 +1,45 @@
#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 */
+155
View File
@@ -0,0 +1,155 @@
#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 */
+26
View File
@@ -0,0 +1,26 @@
#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 */
+21
View File
@@ -0,0 +1,21 @@
#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 */

Some files were not shown because too many files have changed in this diff Show More