Compare commits
22
Commits
jrupp
..
divB_mover
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
71dc3f4ada | ||
|
|
83eb37cfb2 | ||
|
|
83fd2e5d7e | ||
|
|
acc55cf003 | ||
|
|
c5a5218b5a | ||
|
|
cb2dfc5b80 | ||
|
|
48a9582016 | ||
|
|
a542af36ea | ||
|
|
1c6f02a5ee | ||
|
|
3223da11ba | ||
|
|
15ed6d9b4f | ||
|
|
adb17e03ad | ||
|
|
6da1418692 | ||
|
|
e22616bd0e | ||
|
|
5d49391dcc | ||
|
|
1e007e7f95 | ||
|
|
b5a84938b1 | ||
|
|
f7a060effc | ||
|
|
64437af0ad | ||
|
|
bb8fa25117 | ||
|
|
d1ca162676 | ||
|
|
9928388830 |
@@ -0,0 +1 @@
|
||||
.vscode
|
||||
@@ -0,0 +1,40 @@
|
||||
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, 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.
|
||||
|
||||
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. The default
|
||||
directory for this is /tmp which only works for simulations on a single node.
|
||||
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.
|
||||
@@ -0,0 +1,7 @@
|
||||
build-essential
|
||||
libopenmpi-dev
|
||||
openmpi-bin
|
||||
libhdf5-openmpi-dev
|
||||
libblitz0-dev
|
||||
libjansson-dev
|
||||
pkg-config
|
||||
Executable
+302
@@ -0,0 +1,302 @@
|
||||
#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):
|
||||
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()
|
||||
|
||||
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^{-3}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)
|
||||
Executable
+89
@@ -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
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
# Compiler
|
||||
SCXX = g++
|
||||
MPICXX = mpic++
|
||||
|
||||
COMPILER=$(MPICXX)
|
||||
|
||||
# Compiler Flags
|
||||
COMPILER_FLAGS = -std=c++11 -O3 -march=native
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
# Debugging
|
||||
DO_DEBUGGING = true
|
||||
DEBUG_LEVEL = 3
|
||||
|
||||
# Timer
|
||||
USE_TIMER = true
|
||||
|
||||
# Catch
|
||||
CATCH_DIR = $(HOMEBASE)/external/catch
|
||||
CATCH_INCLUDES = -I$(CATCH_DIR)
|
||||
|
||||
# Blitz
|
||||
MAKE_BLITZ = false
|
||||
|
||||
BLITZ_DIR = $(HOMEBASE)/external/blitz/build/
|
||||
BLITZ_INC_DIR = $(BLITZ_DIR)include/
|
||||
BLITZ_LIB_DIR = $(BLITZ_DIR)lib/
|
||||
|
||||
BLITZ_INCLUDES = -I$(BLITZ_INC_DIR)
|
||||
BLITZ_LIBS = -L$(BLITZ_LIB_DIR) -lblitz -lm
|
||||
|
||||
# HDF5
|
||||
MAKE_H5 = false
|
||||
|
||||
#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
|
||||
|
||||
# Janson
|
||||
MAKE_JANSSON = false
|
||||
|
||||
JANSON_DIR = $(HOMEBASE)/external/jansson/
|
||||
JANSON_INC_DIR = $(JANSON_DIR)
|
||||
JANSSON_LIBRARIES = -ljansson
|
||||
JANSSON_INCLUDES = -I$(JANSON_INC_DIR)
|
||||
|
||||
|
||||
|
||||
|
||||
+77
@@ -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)
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
-1
@@ -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
|
||||
Regular → Executable
BIN
Binary file not shown.
+58
@@ -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.
Executable
+1000000
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)
|
||||
+117
File diff suppressed because one or more lines are too long
Regular → Executable
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -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)
|
||||
+15935
File diff suppressed because it is too large
Load Diff
+25
@@ -0,0 +1,25 @@
|
||||
dummy: all
|
||||
# Auf Solaris muss blitz mit dem Sun Studio Compiler gebaut werden
|
||||
# der ist zwar scheisse, funktioniert mit blitz aber. :)
|
||||
ZIP = tar
|
||||
|
||||
|
||||
NAME_TAR = blitz-1.0.2.tar.gz
|
||||
NAME = blitz-1.0.2
|
||||
|
||||
BLITZ_FOLDER=/external/blitz/
|
||||
|
||||
all:
|
||||
$(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)blitz-1.0.2
|
||||
-rm -rf $(HOMEBASE)$(BLITZ_FOLDER)build
|
||||
BIN
Binary file not shown.
+4322
-1311
File diff suppressed because it is too large
Load Diff
+24
@@ -0,0 +1,24 @@
|
||||
dummy: all
|
||||
# Auf Solaris muss blitz mit dem Sun Studio Compiler gebaut werden
|
||||
# der ist zwar scheisse, funktioniert mit blitz aber. :)
|
||||
ZIP = tar
|
||||
|
||||
|
||||
NAME_TAR = jansson-2.13.tar.gz
|
||||
NAME = jansson-2.13
|
||||
|
||||
JANSSON_FOLDER=/external/jansson/
|
||||
|
||||
all:
|
||||
$(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
|
||||
BIN
Binary file not shown.
Executable
+20
@@ -0,0 +1,20 @@
|
||||
#ifndef HDF5_READER_H
|
||||
#define HDF5_READER_H
|
||||
|
||||
#include <string>
|
||||
#include "blitz/array.h"
|
||||
|
||||
class Hdf5Reader {
|
||||
public:
|
||||
Hdf5Reader(std::string directory, std::string filename);
|
||||
Hdf5Reader(std::string absolute_filename);
|
||||
|
||||
blitz::Array<double, 3> readD3Double(std::string path);
|
||||
blitz::Array<double, 2> readD2Double(std::string path);
|
||||
blitz::Array<double, 1> readD1Double(std::string path);
|
||||
|
||||
private:
|
||||
std::string absolute_filename_;
|
||||
};
|
||||
|
||||
#endif /* HDF5_READER_H */
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#ifndef HDF5_WRITER_H
|
||||
#define HDF5_WRITER_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "blitz/array.h"
|
||||
|
||||
class Hdf5Writer {
|
||||
public:
|
||||
Hdf5Writer(std::string directory = "./output",
|
||||
std::string filename = "output");
|
||||
|
||||
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 */
|
||||
Executable
+94
@@ -0,0 +1,94 @@
|
||||
#ifndef SIMULATION_OUTPUT_H
|
||||
#define SIMULATION_OUTPUT_H
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "IO/hdf5_writer.h"
|
||||
|
||||
class DynamicDensityField;
|
||||
class CurrentBorder;
|
||||
class Parameter;
|
||||
class CurrentCollector;
|
||||
class DeletionLogger;
|
||||
|
||||
namespace species {
|
||||
class TrackedSpecie;
|
||||
enum class ImplementedSpecies;
|
||||
}; // namespace species
|
||||
|
||||
struct OutputTask {
|
||||
std::string specie_name;
|
||||
bool overwrite_last;
|
||||
int intervall;
|
||||
// selector if each or only first cpu should write can be added here
|
||||
};
|
||||
|
||||
class SimulationOutput {
|
||||
public:
|
||||
SimulationOutput(const std::string& output_folder,
|
||||
const std::string& output_filename);
|
||||
|
||||
void addDensityFieldOutput(OutputTask task);
|
||||
void addCurrentBorderOutput(OutputTask task);
|
||||
void addDeletionLoggerOutput(OutputTask task);
|
||||
|
||||
void writeMetaData(
|
||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>& species);
|
||||
|
||||
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;
|
||||
|
||||
void writeSimulationData(DynamicDensityField* density_field,
|
||||
std::string species_path,
|
||||
int cpu_sync,
|
||||
bool overwrite_last);
|
||||
|
||||
void writeSpectrum(DynamicDensityField* density_field, std::string path);
|
||||
void writeDensity(DynamicDensityField* density_field, std::string path);
|
||||
void writeTimeInBin(DynamicDensityField* density_field, std::string path);
|
||||
void writeDeletedParticles(DynamicDensityField* density_field,
|
||||
std::string path);
|
||||
void writePhysicalTime(DynamicDensityField* density_field, std::string path);
|
||||
|
||||
void writeSimulationData(CurrentCollector* current_collector,
|
||||
std::string species_path,
|
||||
int cpu_sync,
|
||||
bool overwrite_last);
|
||||
void writeCurrentCrossings(CurrentCollector* current_collector,
|
||||
std::string path);
|
||||
void writeCurrent(CurrentCollector* current_collector, std::string path);
|
||||
void writePhysicalTime(CurrentCollector* current_collector, std::string path);
|
||||
|
||||
void writeSimulationData(DeletionLogger* logger,
|
||||
std::string species_path,
|
||||
int cpu_sync,
|
||||
bool overwrite_last);
|
||||
void writeNumDeletions(DeletionLogger* logger, std::string path);
|
||||
|
||||
void writeMetaData(species::TrackedSpecie* specie);
|
||||
void writeMetaData(DynamicDensityField* density_field, std::string path);
|
||||
void writeMetaData(CurrentCollector* current_collector, std::string path);
|
||||
// void writeParameterFile(Parameter* parameter);
|
||||
|
||||
void writeCollectorAreas(CurrentCollector* current_collector,
|
||||
std::string path);
|
||||
|
||||
void writeBinVolumes(DynamicDensityField* density_field,
|
||||
std::string path_to_field);
|
||||
void writeNumBins(DynamicDensityField* density_field,
|
||||
std::string path_to_field);
|
||||
void writeBinBorders(DynamicDensityField* density_field,
|
||||
std::string path_to_field);
|
||||
};
|
||||
|
||||
#endif /* SIMULATION_OUTPUT_H */
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
#ifndef T2_BETA_DECAY_H
|
||||
#define T2_BETA_DECAY_H
|
||||
|
||||
namespace T2BetaDecay {
|
||||
static const double lambda_T2 = 1.78405E-9; // tritium decay constant (1/s)
|
||||
static const double E0_T = 18.573e3; // Tritium endpoint energy (eV)
|
||||
static const double spectrum_prefactor = 1.2072343416696292E-47; // beta decay constant
|
||||
static const double spectrum_maximum = 1.5E-28;
|
||||
}
|
||||
|
||||
|
||||
#endif /* T2_BETA_DECAY_H */
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#ifndef IONIZATION_CONSTANTS_H
|
||||
#define IONIZATION_CONSTANTS_H
|
||||
|
||||
namespace ionization {
|
||||
static const double ionization_energy_janev_non_diss = 15.42; // (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 */
|
||||
Executable
+74
@@ -0,0 +1,74 @@
|
||||
#ifndef PHYSICAL_CONSTANTS_H
|
||||
#define PHYSICAL_CONSTANTS_H
|
||||
|
||||
// The default is (Gaussian) 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
|
||||
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
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#ifndef SIM_CONSTANTS_H
|
||||
#define SIM_CONSTANTS_H
|
||||
|
||||
#include <limits>
|
||||
|
||||
namespace SimConstants {
|
||||
static const double minimal_cross_section =
|
||||
std::numeric_limits<double>::min() * 1E5;
|
||||
static const double minimal_macroscopic_cross_section =
|
||||
std::numeric_limits<double>::min() * 1E5;
|
||||
static const double random_lower_limit = 1E-15;
|
||||
static const double compare_epsilon = 1E-10;
|
||||
|
||||
} // namespace SimConstants
|
||||
|
||||
#endif /* SIM_CONSTANTS_H */
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#ifndef FUNCTIONS_H
|
||||
#define FUNCTIONS_H
|
||||
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
namespace D1ToD1 {
|
||||
std::function<double(double)> PiecewiseLinear(std::vector<double> positions,
|
||||
std::vector<double> values);
|
||||
|
||||
std::function<double(double)> Constant(double constant);
|
||||
|
||||
std::function<double(double)> Product(
|
||||
std::vector<std::function<double(double)>> functions);
|
||||
}; // namespace D1ToD1
|
||||
|
||||
namespace D3ToD1 {
|
||||
std::function<double(double, double, double)> Constant(double value);
|
||||
|
||||
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 */
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
#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 {
|
||||
CylinderBinning buildPositionBinning(json_t* object);
|
||||
CylinderBinning buildPositionBinningIncludingRedirection(
|
||||
Parameter& parameter,
|
||||
json_path& path_to_binning);
|
||||
|
||||
EnergyBinning buildEnergyBinning(json_t* object);
|
||||
EnergyBinning buildEnergyBinningIncludingRedirection(
|
||||
Parameter& parameter,
|
||||
json_path& path_to_binning);
|
||||
|
||||
}; // namespace generator
|
||||
|
||||
#endif /* BINNING_GENERATOR_H */
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
#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 {
|
||||
std::shared_ptr<CurrentCollector> buildCurrentCollector(
|
||||
Parameter& parameter,
|
||||
const json_path& path_to_collector,
|
||||
std::shared_ptr<Timer>& timer);
|
||||
};
|
||||
#endif /* CURRENT_COLLECTOR_GENERATOR_H */
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
#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 {
|
||||
|
||||
std::shared_ptr<ConstantDensityField> buildConstantDensityField(json_t* object);
|
||||
|
||||
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 */
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
#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 {
|
||||
|
||||
std::shared_ptr<DriftVelocity> buildDriftVelocity(
|
||||
Parameter& parameter,
|
||||
const json_path& path_to_drift_velocity);
|
||||
|
||||
};
|
||||
|
||||
#endif /* DRIFT_VELOCITY_GENERATOR_H */
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
#ifndef ELECTRIC_FIELD_GENERATOR_H
|
||||
#define ELECTRIC_FIELD_GENERATOR_H
|
||||
|
||||
#include "simulation/electromagnetic_field.h"
|
||||
#include "simulation/parameter.h"
|
||||
|
||||
namespace generator {
|
||||
|
||||
std::shared_ptr<ElectricField> electricField(json_t* object);
|
||||
|
||||
std::shared_ptr<ElectricField> electricField(Parameter& parameter);
|
||||
}; // namespace generator
|
||||
|
||||
#endif /* ELECTRIC_FIELD_GENERATOR_H */
|
||||
@@ -0,0 +1,17 @@
|
||||
#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 {
|
||||
|
||||
std::shared_ptr<EnergyDistributionFunction> buildEnergyDistributionFunction(
|
||||
Parameter& parameter,
|
||||
const json_path& path_to_function);
|
||||
};
|
||||
|
||||
#endif /* ENERGY_DISTRIBUTION_FUNCTION_GENERATOR_H */
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#ifndef FUNCTION_GENERATOR_H
|
||||
#define FUNCTION_GENERATOR_H
|
||||
|
||||
#include <functional>
|
||||
#include "functions/functions.h"
|
||||
#include "jansson.h"
|
||||
|
||||
namespace generator {
|
||||
|
||||
std::function<double(double)> function1D(json_t* object);
|
||||
std::function<double(double, double, double)> function3D(json_t* object);
|
||||
|
||||
}; // namespace generator
|
||||
|
||||
#endif /* FUNCTION_GENERATOR_H */
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#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 {
|
||||
|
||||
std::shared_ptr<Geometry> buildGeometry(Parameter& parameter,
|
||||
const json_path& path_to_geometry);
|
||||
|
||||
};
|
||||
|
||||
#endif /* GEOMETRY_GENERATOR_H */
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#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 {
|
||||
|
||||
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 */
|
||||
Executable
+49
@@ -0,0 +1,49 @@
|
||||
#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 {
|
||||
|
||||
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);
|
||||
|
||||
std::function<double(double)> buildTotalCrossSection(json_t* object);
|
||||
|
||||
std::function<double(double, double)> build2DCrossSection(json_t* object);
|
||||
|
||||
std::shared_ptr<ScatteringAngleDistribution> buildScatteringAngleDistribution(
|
||||
json_t* object);
|
||||
|
||||
double buildExcitationEnergy(std::string excitation_state);
|
||||
std::function<double(double)> buildExcitationCrossSection(
|
||||
std::string excitation_state);
|
||||
|
||||
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);
|
||||
|
||||
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 */
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#ifndef LOGGER_GENERATOR_H
|
||||
#define LOGGER_GENERATOR_H
|
||||
|
||||
#include <memory>
|
||||
#include "simulation/logger.h"
|
||||
#include "simulation/parameter.h"
|
||||
|
||||
namespace generator {
|
||||
|
||||
std::shared_ptr<DeletionLogger> buildDeletionLogger(json_t* object);
|
||||
std::shared_ptr<DeletionLogger> buildDeletionLogger(
|
||||
Parameter& parameter,
|
||||
const json_path& path_to_logger);
|
||||
|
||||
} // namespace generator
|
||||
|
||||
#endif /* LOGGER_GENERATOR_H */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user