Compare commits
13
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
18dc3d56bb | ||
|
|
cc7d57ba9c | ||
|
|
d8163516e7 | ||
|
|
f130274ea5 | ||
|
|
1e1c84a211 | ||
|
|
d98a14f9ea | ||
|
|
6c02cac31f | ||
|
|
12aeead76d | ||
|
|
4cf84d7f9d | ||
|
|
ba84963f96 | ||
|
|
dc226a8d53 | ||
|
|
1f4314c527 | ||
|
|
1efcb58d35 |
@@ -1,170 +0,0 @@
|
|||||||
import numpy as np
|
|
||||||
import matplotlib
|
|
||||||
matplotlib.use("agg")
|
|
||||||
import matplotlib.pyplot as plt
|
|
||||||
import h5py
|
|
||||||
import argparse
|
|
||||||
import glob
|
|
||||||
import re
|
|
||||||
import os
|
|
||||||
import plot_standards as pst
|
|
||||||
|
|
||||||
def get_time_and_total_charge_(files, considered_keys=['All'], exclude_underflow=False):
|
|
||||||
times = []
|
|
||||||
total_charges = []
|
|
||||||
for file in files:
|
|
||||||
with h5py.File(file, 'r') as cfile:
|
|
||||||
total_charge = 0
|
|
||||||
time = 0
|
|
||||||
for key in cfile.keys():
|
|
||||||
if(key == "PoissonSolver" or key == "RestartInfo" or key == 'NumberProcesses'):
|
|
||||||
continue
|
|
||||||
if (not considered_keys[0] == 'All') and (not key in considered_keys):
|
|
||||||
continue
|
|
||||||
charge = cfile[f'{key}/Charge'][()]
|
|
||||||
cfile_speciesDensity = cfile[key]['DensityField']
|
|
||||||
# binVolumes = cfile_speciesDensity['BinVolumes'][()]
|
|
||||||
cfile_simData = cfile_speciesDensity['SimulationData']
|
|
||||||
|
|
||||||
for time_key in cfile_simData.keys():
|
|
||||||
time = cfile_simData[time_key]['PhysicalTime'][()]
|
|
||||||
|
|
||||||
density = cfile_simData[time_key]['TimeInBin'][()]
|
|
||||||
if not exclude_underflow:
|
|
||||||
total_charge = np.sum(density)*charge
|
|
||||||
else:
|
|
||||||
total_charge = np.array([np.sum(density[:,:,:,:,1:-1])])*charge
|
|
||||||
# print(total_charge)
|
|
||||||
|
|
||||||
try:
|
|
||||||
index = times.index(time)
|
|
||||||
total_charges[index] += total_charge
|
|
||||||
except:
|
|
||||||
times.append(time)
|
|
||||||
total_charges.append(total_charge)
|
|
||||||
|
|
||||||
times = np.array(times)[:,0]
|
|
||||||
# print(total_charge)
|
|
||||||
total_charges = np.array(total_charges)[:,0]
|
|
||||||
|
|
||||||
sorting_mask = np.argsort(times)
|
|
||||||
times = times[sorting_mask]
|
|
||||||
total_charges = total_charges[sorting_mask]
|
|
||||||
|
|
||||||
return times, total_charges
|
|
||||||
|
|
||||||
def get_time_and_wall_losses(files, considered_keys=['All']):
|
|
||||||
times = []
|
|
||||||
phys_wall_loss = []
|
|
||||||
for file in files:
|
|
||||||
with h5py.File(file, 'r') as cfile:
|
|
||||||
time = 0
|
|
||||||
for key in cfile.keys():
|
|
||||||
if(key == "PoissonSolver" or key == "RestartInfo" or key == 'NumberProcesses'):
|
|
||||||
continue
|
|
||||||
if (not considered_keys[0] == 'All') and (not key in considered_keys):
|
|
||||||
continue
|
|
||||||
cfile_specieslogger = cfile[key]['DeletionLogger']
|
|
||||||
|
|
||||||
for time_key in cfile_specieslogger.keys():
|
|
||||||
time = cfile[key]['DensityField/SimulationData'][time_key]['PhysicalTime'][0]
|
|
||||||
deltat = cfile[key]['CurrentCollector/SimulationData'][time_key]['PhysicalTime'][0]
|
|
||||||
try:
|
|
||||||
index = times.index(time)
|
|
||||||
try:
|
|
||||||
phys_wall_loss[index] += cfile_specieslogger[time_key]\
|
|
||||||
['NumDeletions/Wall(physical)'][0]/deltat
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
except:
|
|
||||||
times.append(time)
|
|
||||||
try:
|
|
||||||
phys_wall_loss.append(cfile_specieslogger[time_key]\
|
|
||||||
['NumDeletions/Wall(physical)'][0]/deltat)
|
|
||||||
except:
|
|
||||||
phys_wall_loss.append(-1)
|
|
||||||
|
|
||||||
times = np.array(times)
|
|
||||||
phys_wall_loss = np.array(phys_wall_loss)
|
|
||||||
|
|
||||||
sorting_mask = np.argsort(times)
|
|
||||||
times = times[sorting_mask]
|
|
||||||
phys_wall_loss = phys_wall_loss[sorting_mask]
|
|
||||||
|
|
||||||
return times, phys_wall_loss
|
|
||||||
|
|
||||||
def getFiles(dir:str, base_name:str, pattern:str) :
|
|
||||||
if dir[-1] == '/':
|
|
||||||
pathname = dir + base_name
|
|
||||||
else:
|
|
||||||
pathname = dir + '/' + base_name
|
|
||||||
# print(glob.glob(pathname + "*.h5"))
|
|
||||||
return [file for file in glob.glob(pathname + "*.h5") if re.match(rf"{pathname}{pattern}+\.h5", str(file))]
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
parser = argparse.ArgumentParser(description="Program to create a plot of the charge against time from the output of KARL")
|
|
||||||
parser.add_argument("dir", type = str, help="directory where the files are stored in")
|
|
||||||
parser.add_argument("basename", type = str, help = 'identifying pattern of the files (i.e. basename[0-9]*\\.h5])')
|
|
||||||
parser.add_argument('--losses', action='store_true', help = 'create wall loss rate plot instead')
|
|
||||||
parser.add_argument("--pattern", type = str, nargs = '?', help = 'Regular expression pattern, that specifies the naming of the files (by default [0-9]*). Gets added to dir+basename+pattern+".h5".', default = '[0-9]*')
|
|
||||||
parser.add_argument("--width", type = str, nargs = '?', default="thesis", help = "Either \'thesis\' or \'beamer\' as defined in plot_standards.py")
|
|
||||||
parser.add_argument("--fraction", type = float, default=1, nargs="?", help= "the fraction of width that the plot should occupy, as defined in plot_standards.py")
|
|
||||||
parser.add_argument("species", action='extend', nargs='+', help = 'Names of the Species in the KARL output or \'All\' if all species should be summed. If name does not exist it will be ignored.')
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
# print(args.dir, args.basename, args.species)
|
|
||||||
|
|
||||||
files = getFiles(args.dir, args.basename, args.pattern)
|
|
||||||
print(files)
|
|
||||||
|
|
||||||
if(files == []):
|
|
||||||
print(f"No files found in {args.dir}, which match '{args.basename}{args.pattern}\\.h5'")
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
if (not args.width == 'thesis') and (not args.width == 'beamer'):
|
|
||||||
print(f"{args.width} is not a valid parameter for width; fall back to \'thesis\'")
|
|
||||||
args.width = 'thesis'
|
|
||||||
|
|
||||||
if args.losses:
|
|
||||||
times, charges = get_time_and_wall_losses(files, args.species)
|
|
||||||
else:
|
|
||||||
times, charges = get_time_and_total_charge_(files, args.species)
|
|
||||||
|
|
||||||
legstr = ''
|
|
||||||
for val in args.species:
|
|
||||||
legstr += val + " + "
|
|
||||||
legstr = legstr[:-3]
|
|
||||||
|
|
||||||
|
|
||||||
plt.rcParams.update({'font.size': 10})
|
|
||||||
fig = plt.figure(figsize=pst.set_size(args.width))
|
|
||||||
plt.plot(times, charges, marker = 'x', label = legstr)
|
|
||||||
if args.losses:
|
|
||||||
plt.ylabel('loss rate (1/s)')
|
|
||||||
else:
|
|
||||||
plt.ylabel('charge (C)')
|
|
||||||
plt.xlabel('time (s)')
|
|
||||||
plt.legend()
|
|
||||||
plt.grid()
|
|
||||||
plt.tight_layout()
|
|
||||||
|
|
||||||
outname = args.dir
|
|
||||||
if not outname[-1] == '/':
|
|
||||||
outname += '/'
|
|
||||||
|
|
||||||
outname += "plots/"
|
|
||||||
|
|
||||||
os.makedirs(outname, exist_ok=True)
|
|
||||||
|
|
||||||
if args.losses:
|
|
||||||
outname += args.basename + "_wallLossRateAgainstTime_species-"
|
|
||||||
else:
|
|
||||||
outname += args.basename + "_chargeAgainstTime_species-"
|
|
||||||
|
|
||||||
for value in args.species:
|
|
||||||
outname += value
|
|
||||||
outname += '_test.pdf'
|
|
||||||
|
|
||||||
# print(outname)
|
|
||||||
plt.savefig(outname, format='pdf', bbox_inches = 'tight')
|
|
||||||
# plt.show()
|
|
||||||
@@ -202,14 +202,18 @@ def plotSpectrumAtZ(filename, path_to_species, z_position, plot_axis, output_per
|
|||||||
spectrum_at_z = spectrumAtZ(
|
spectrum_at_z = spectrumAtZ(
|
||||||
filename, path_to_species, z_position, output_period)
|
filename, path_to_species, z_position, output_period)
|
||||||
E_bins = energyBinsDensityfield(filename, path_to_species)
|
E_bins = energyBinsDensityfield(filename, path_to_species)
|
||||||
|
# included to get dn/dE
|
||||||
|
E_bin_volumes = E_bins[1:] - E_bins[:-1]
|
||||||
plot_bins, plot_datas = makeBarPlotData(
|
plot_bins, plot_datas = makeBarPlotData(
|
||||||
spectrum_at_z[1:-1], E_bins[0:-1], E_bins[1:])
|
spectrum_at_z[1:-1]/E_bin_volumes, E_bins[0:-1], E_bins[1:])
|
||||||
plot_axis.plot(plot_bins, plot_datas, label=str(path_to_species))
|
plot_axis.plot(plot_bins, plot_datas, label=str(path_to_species))
|
||||||
plot_axis.set_xscale("log")
|
plot_axis.set_xscale("log")
|
||||||
plot_axis.set_yscale("log")
|
plot_axis.set_yscale("log")
|
||||||
plot_axis.set_xlabel(r"Energy $E$ (eV)")
|
plot_axis.set_xlabel(r"Energy $E$ (eV)")
|
||||||
plot_axis.set_ylabel(
|
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)$")
|
r"Diff. Density $\frac{\mathrm{d}n_e}{\mathrm{d}E}$ $\left(\frac{1}{\mathrm{m}^{3} \mathrm{eV}}\right)$")
|
||||||
|
# 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):
|
def plotAllSpectrumAtZ(filename, z_position, output_period, specie_keys, output_folder):
|
||||||
@@ -278,7 +282,7 @@ def plotLongitudinalElectricCurrentVsZ(filename, path_to_species, plot_axis, out
|
|||||||
z_bins = zBinsDensityField(filename, path_to_species)
|
z_bins = zBinsDensityField(filename, path_to_species)
|
||||||
plot_axis.plot(z_bins, current_in_z)
|
plot_axis.plot(z_bins, current_in_z)
|
||||||
plot_axis.set_xlabel(r"Distance to rear wall $z$ (m)")
|
plot_axis.set_xlabel(r"Distance to rear wall $z$ (m)")
|
||||||
plot_axis.set_ylabel(r"Electric current $I$ ($A$)")
|
plot_axis.set_ylabel(r"Electric current $I$ ($A$)") # unit should be wrong, think it should be A/m^2
|
||||||
|
|
||||||
|
|
||||||
def printDeletionLoggerStats(filename, path_to_species, output_period="LastSyncPeriod"):
|
def printDeletionLoggerStats(filename, path_to_species, output_period="LastSyncPeriod"):
|
||||||
@@ -300,3 +304,50 @@ def printDeletionLoggerStats(filename, path_to_species, output_period="LastSyncP
|
|||||||
def printAllDeletionLoggerStats(filename, specie_keys, output_period):
|
def printAllDeletionLoggerStats(filename, specie_keys, output_period):
|
||||||
for key in specie_keys:
|
for key in specie_keys:
|
||||||
printDeletionLoggerStats(filename, key, output_period)
|
printDeletionLoggerStats(filename, key, output_period)
|
||||||
|
|
||||||
|
def zBinsPoissonSolver(filename, path_to_poisson_solver):
|
||||||
|
file = h5py.File(filename, 'r')
|
||||||
|
path_to_border = path_to_poisson_solver + "/BinBorders/longitudinal"
|
||||||
|
return np.array(file[path_to_border])
|
||||||
|
|
||||||
|
def rBinsPoissonSolver(filename, path_to_poisson_solver):
|
||||||
|
file = h5py.File(filename, 'r')
|
||||||
|
path_to_border = path_to_poisson_solver + "/BinBorders/radial"
|
||||||
|
return np.array(file[path_to_border])
|
||||||
|
|
||||||
|
def potential(filename, path_to_poisson_solver, output_period):
|
||||||
|
file = h5py.File(filename, 'r')
|
||||||
|
path_to_density = path_to_poisson_solver + "/SimulationData" + \
|
||||||
|
outputPeriodKey(output_period) + "/Potential"
|
||||||
|
return np.array(file[path_to_density])
|
||||||
|
|
||||||
|
# returns potential averaged over r-direction; assumes only one azimuthal bin
|
||||||
|
def potentialVsZ(filename, path_to_poisson_solver, output_period="LastSyncPeriod"):
|
||||||
|
rbinBorders = rBinsPoissonSolver(filename, path_to_poisson_solver)
|
||||||
|
deltar = rbinBorders[1] - rbinBorders[0] #assumption of linear binning
|
||||||
|
weights = rbinBorders[1:]**2 - rbinBorders[:-1]**2 + deltar**2
|
||||||
|
weights = np.append(deltar**2/4, weights)
|
||||||
|
potentialValues = potential(filename, path_to_poisson_solver, output_period)
|
||||||
|
weightedPotential = potentialValues*weights[:, np.newaxis, np.newaxis]
|
||||||
|
return np.sum(weightedPotential, axis=(0,1)) / np.sum(weights)
|
||||||
|
|
||||||
|
def plotPotentialVsZ(filename, path_to_poisson_solver, plot_axis, output_period="LastSyncPeriod"):
|
||||||
|
potential_ = potentialVsZ(filename, path_to_poisson_solver, output_period)
|
||||||
|
z_bins = zBinsPoissonSolver(filename, path_to_poisson_solver)
|
||||||
|
plot_bins, plot_datas = makeBarPlotData(
|
||||||
|
potential_, z_bins, z_bins)
|
||||||
|
plot_axis.plot(plot_bins, plot_datas)
|
||||||
|
# plot_axis.set_yscale("log")
|
||||||
|
plot_axis.set_xlabel(r"Distance to rear wall $z$ (m)")
|
||||||
|
plot_axis.set_ylabel(r"Potential $\Phi$ ($V$)")
|
||||||
|
|
||||||
|
def plotAllPotentialVsZ(filename, output_period, output_folder):
|
||||||
|
pst.setRcParams()
|
||||||
|
fig, ax = plt.subplots(figsize=pst.set_size('thesis'))
|
||||||
|
key = "PoissonSolver"
|
||||||
|
plotPotentialVsZ(filename, key, ax, output_period)
|
||||||
|
|
||||||
|
ax.set_facecolor('#e7e7e7ff')
|
||||||
|
ax.grid(color='white')
|
||||||
|
fig.savefig(output_folder + "/potential_vs_z_at_period={}.pdf".format(output_period),
|
||||||
|
format='pdf', bbox_inches='tight')
|
||||||
+10
-18
@@ -12,15 +12,9 @@ CATCH_INCLUDES = -I$(CATCH_DIR)
|
|||||||
# Blitz
|
# Blitz
|
||||||
MAKE_BLITZ = false
|
MAKE_BLITZ = false
|
||||||
|
|
||||||
ifeq ($(MAKE_BLITZ), true)
|
BLITZ_DIR = $(HOMEBASE)/external/blitz/build/
|
||||||
BLITZ_DIR = $(HOMEBASE)/external/blitz/build
|
BLITZ_INC_DIR = $(BLITZ_DIR)include/
|
||||||
BLITZ_INC_DIR = $(BLITZ_DIR)/include
|
BLITZ_LIB_DIR = $(BLITZ_DIR)lib/
|
||||||
BLITZ_LIB_DIR = $(BLITZ_DIR)/lib
|
|
||||||
else
|
|
||||||
BLITZ_INC_DIR = /usr/include
|
|
||||||
BLITZ_LIB_DIR = /usr/lib/x86_64-linux-gnu
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
BLITZ_INCLUDES = -I$(BLITZ_INC_DIR)
|
BLITZ_INCLUDES = -I$(BLITZ_INC_DIR)
|
||||||
BLITZ_LIBS = -L$(BLITZ_LIB_DIR) -lblitz -lm
|
BLITZ_LIBS = -L$(BLITZ_LIB_DIR) -lblitz -lm
|
||||||
@@ -38,13 +32,11 @@ HDF5P_LIBRARIES = -L$(HDF5P_LIB_DIR) -lz -lhdf5_hl -lhdf5
|
|||||||
# Janson
|
# Janson
|
||||||
MAKE_JANSSON = false
|
MAKE_JANSSON = false
|
||||||
|
|
||||||
ifeq ($(MAKE_JANSSON), true)
|
JANSON_DIR = $(HOMEBASE)/external/jansson/
|
||||||
JANSSON_INC_DIR = $(HOMEBASE)/external/jansson/build/include
|
JANSON_INC_DIR = $(JANSON_DIR)
|
||||||
JANSSON_LIB_DIR = $(HOMEBASE)/external/jansson/build/lib
|
JANSSON_LIBRARIES = -ljansson
|
||||||
else
|
JANSSON_INCLUDES = -I$(JANSON_INC_DIR)
|
||||||
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)
|
|
||||||
|
|||||||
Binary file not shown.
Vendored
+6
-16
@@ -4,32 +4,22 @@ dummy: all
|
|||||||
ZIP = tar
|
ZIP = tar
|
||||||
|
|
||||||
|
|
||||||
BLITZ_VERSION = 1.0.2
|
NAME_TAR = blitz-1.0.2.tar.gz
|
||||||
|
NAME = blitz-1.0.2
|
||||||
NAME_TAR = blitz-$(BLITZ_VERSION).tar.gz
|
|
||||||
NAME = blitz-$(BLITZ_VERSION)
|
|
||||||
|
|
||||||
BLITZ_FOLDER=external/blitz
|
|
||||||
|
|
||||||
|
BLITZ_FOLDER=/external/blitz/
|
||||||
|
|
||||||
all:
|
all:
|
||||||
ifneq ("$(wildcard $(NAME_TAR))","")
|
|
||||||
@echo "Archive already present"
|
|
||||||
else
|
|
||||||
@echo "Downloading"
|
|
||||||
wget https://github.com/blitzpp/blitz/archive/refs/tags/$(BLITZ_VERSION).tar.gz
|
|
||||||
mv $(BLITZ_VERSION).tar.gz $(NAME_TAR)
|
|
||||||
endif
|
|
||||||
$(ZIP) -xf $(NAME_TAR)
|
$(ZIP) -xf $(NAME_TAR)
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
mkdir -p build/include
|
mkdir -p build/include
|
||||||
mkdir -p build/lib
|
mkdir -p build/lib
|
||||||
cd $(NAME) && autoreconf -fiv && autoconf && automake --add-missing
|
cd $(NAME) && autoreconf -fiv && autoconf && automake --add-missing
|
||||||
cd $(NAME) && ./configure --prefix=$(HOMEBASE)/$(BLITZ_FOLDER)/build/ --includedir=$(HOMEBASE)/$(BLITZ_FOLDER)/build/include/ --libdir=$(HOMEBASE)/$(BLITZ_FOLDER)/build/lib/
|
cd $(NAME) && ./configure --prefix=$(HOMEBASE)$(BLITZ_FOLDER)build/ --includedir=$(HOMEBASE)$(BLITZ_FOLDER)build/include/ --libdir=$(HOMEBASE)$(BLITZ_FOLDER)build/lib/
|
||||||
cd $(NAME) && $(MAKE)
|
cd $(NAME) && $(MAKE)
|
||||||
cd $(NAME) && $(MAKE) lib
|
cd $(NAME) && $(MAKE) lib
|
||||||
cd $(NAME) && $(MAKE) install
|
cd $(NAME) && $(MAKE) install
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-rm -rf $(HOMEBASE)/$(BLITZ_FOLDER)/$(NAME)
|
-rm -rf $(HOMEBASE)$(BLITZ_FOLDER)blitz-1.0.2
|
||||||
-rm -rf $(HOMEBASE)/$(BLITZ_FOLDER)/build
|
-rm -rf $(HOMEBASE)$(BLITZ_FOLDER)build
|
||||||
|
|||||||
BIN
Binary file not shown.
Vendored
+13
-21
@@ -4,29 +4,21 @@ dummy: all
|
|||||||
ZIP = tar
|
ZIP = tar
|
||||||
|
|
||||||
|
|
||||||
JANSSON_VERSION = 2.14
|
NAME_TAR = jansson-2.13.tar.gz
|
||||||
|
NAME = jansson-2.13
|
||||||
|
|
||||||
NAME = jansson-$(JANSSON_VERSION)
|
JANSSON_FOLDER=/external/jansson/
|
||||||
NAME_TAR = $(NAME).tar.gz
|
|
||||||
|
|
||||||
JANSSON_FOLDER=external/jansson
|
|
||||||
|
|
||||||
all:
|
all:
|
||||||
ifneq ("$(wildcard $(NAME_TAR))","")
|
$(ZIP) -xf $(NAME_TAR)
|
||||||
@echo "Archive already present"
|
mkdir -p build
|
||||||
else
|
mkdir -p build/include
|
||||||
@echo "Downloading"
|
mkdir -p build/lib
|
||||||
wget https://github.com/akheron/jansson/releases/download/v$(JANSSON_VERSION)/$(NAME_TAR)
|
#cd $(NAME) && autoreconf -fiv && automake --add-missing
|
||||||
endif
|
cd $(NAME) && ./configure --prefix=$(HOMEBASE)$(JANSSON_FOLDER)build/ --includedir=$(HOMEBASE)$(JANSSON_FOLDER)build/include/ --libdir=$(HOMEBASE)$(JANSSON_FOLDER)build/lib/
|
||||||
$(ZIP) -xf $(NAME_TAR)
|
cd $(NAME) && $(MAKE)
|
||||||
mkdir -p build
|
cd $(NAME) && $(MAKE) install
|
||||||
mkdir -p build/include
|
|
||||||
mkdir -p build/lib
|
|
||||||
#cd $(NAME) && autoreconf -fiv && automake --add-missing
|
|
||||||
cd $(NAME) && ./configure --prefix=$(HOMEBASE)/$(JANSSON_FOLDER)/build/ --includedir=$(HOMEBASE)/$(JANSSON_FOLDER)/build/include/ --libdir=$(HOMEBASE)/$(JANSSON_FOLDER)/build/lib/
|
|
||||||
cd $(NAME) && $(MAKE)
|
|
||||||
cd $(NAME) && $(MAKE) install
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-rm -rf $(HOMEBASE)/$(JANSSON_FOLDER)/$(NAME)
|
-rm -rf $(HOMEBASE)$(JANSSON_FOLDER)$(NAME)
|
||||||
-rm -rf $(HOMEBASE)/$(JANSSON_FOLDER)/build
|
-rm -rf $(HOMEBASE)$(JANSSON_FOLDER)build
|
||||||
BIN
Binary file not shown.
@@ -9,18 +9,9 @@ class Hdf5Reader {
|
|||||||
Hdf5Reader(std::string directory, std::string filename);
|
Hdf5Reader(std::string directory, std::string filename);
|
||||||
Hdf5Reader(std::string absolute_filename);
|
Hdf5Reader(std::string absolute_filename);
|
||||||
|
|
||||||
blitz::Array<double, 5> readD5Double(std::string path);
|
|
||||||
blitz::Array<double, 4> readD4Double(std::string path);
|
|
||||||
blitz::Array<double, 3> readD3Double(std::string path);
|
blitz::Array<double, 3> readD3Double(std::string path);
|
||||||
blitz::Array<double, 2> readD2Double(std::string path);
|
blitz::Array<double, 2> readD2Double(std::string path);
|
||||||
blitz::Array<double, 1> readD1Double(std::string path);
|
blitz::Array<double, 1> readD1Double(std::string path);
|
||||||
double readDouble(std::string path);
|
|
||||||
int readInt(std::string path);
|
|
||||||
|
|
||||||
blitz::Array<long int, 5> readD5LongInt(std::string path);
|
|
||||||
blitz::Array<long int, 4> readD4LongInt(std::string path);
|
|
||||||
|
|
||||||
std::stringstream readEngineString(std::string path);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string absolute_filename_;
|
std::string absolute_filename_;
|
||||||
|
|||||||
@@ -14,9 +14,7 @@ class Hdf5Writer {
|
|||||||
void write(const blitz::Array<double, 2>& data, std::string path);
|
void write(const blitz::Array<double, 2>& data, std::string path);
|
||||||
void write(const blitz::Array<double, 3>& data, std::string path);
|
void write(const blitz::Array<double, 3>& data, std::string path);
|
||||||
void write(const blitz::Array<double, 4>& data, std::string path);
|
void write(const blitz::Array<double, 4>& data, std::string path);
|
||||||
void write(const blitz::Array<double, 5>& data, std::string path);
|
|
||||||
void write(const blitz::Array<long int, 4>& data, std::string path);
|
void write(const blitz::Array<long int, 4>& data, std::string path);
|
||||||
void write(const blitz::Array<long int, 5>& data, std::string path);
|
|
||||||
void write(const blitz::TinyVector<double, 3>& 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 blitz::TinyVector<int, 3>& data, std::string path);
|
||||||
void write(const std::vector<double>& data, std::string path);
|
void write(const std::vector<double>& data, std::string path);
|
||||||
@@ -24,8 +22,6 @@ class Hdf5Writer {
|
|||||||
void write(long int data, std::string path);
|
void write(long int data, std::string path);
|
||||||
void write(double data, std::string path);
|
void write(double data, std::string path);
|
||||||
void write(const std::string& data, std::string path);
|
void write(const std::string& data, std::string path);
|
||||||
void writeRNG(const std::string& data, std::string path_base);
|
|
||||||
std::string AbsoluteFileName() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string absolute_filename_;
|
std::string absolute_filename_;
|
||||||
|
|||||||
@@ -1,123 +0,0 @@
|
|||||||
#ifndef MPI_PARTICLE_FORMAT_H
|
|
||||||
#define MPI_PARTICLE_FORMAT_H
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
#include "mpi.h"
|
|
||||||
/* File format (as in ACRONYM):
|
|
||||||
*
|
|
||||||
* mpi_io_header
|
|
||||||
* <padding>
|
|
||||||
* cpu_header[n_cpus]
|
|
||||||
* <padding>
|
|
||||||
* data_of_cpu_1 <padding>
|
|
||||||
* data_of_cpu_2 <padding>
|
|
||||||
* ...
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* file header*/
|
|
||||||
struct mpi_io_header_t {
|
|
||||||
std::uint64_t magic;
|
|
||||||
std::uint64_t cpu_header_offset;
|
|
||||||
std::uint32_t num_cpus;
|
|
||||||
double dt;
|
|
||||||
|
|
||||||
bool verify() {
|
|
||||||
// Sanity Check if file is the right format
|
|
||||||
if(magic != ((std::uint64_t)'KA'<<32) + 'RL') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(dt < 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/* per-CPU header */
|
|
||||||
struct cpu_header_t {
|
|
||||||
std::uint64_t num_particles;
|
|
||||||
std::uint64_t file_offset;
|
|
||||||
};
|
|
||||||
|
|
||||||
// seems to work only if alignment is a power of 2
|
|
||||||
static std::uint64_t pad_to_blocksize(std::uint64_t size, std::uint64_t alignment) {
|
|
||||||
size &= ~(alignment - 1);
|
|
||||||
size += alignment;
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef MPI_VERSION
|
|
||||||
|
|
||||||
#ifndef MPI_UINT32_T
|
|
||||||
#define MPI_UNIT32_T MPI_UNSIGNED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef MPI_UINT64_T
|
|
||||||
#define MPI_UNIT64_T MPI_UNSIGNED_LONG_LONG
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Custom MPI data types for the header structs */
|
|
||||||
static MPI_Datatype build_file_header_type() {
|
|
||||||
int status;
|
|
||||||
MPI_Datatype type;
|
|
||||||
int blocklengths[4];
|
|
||||||
MPI_Aint disps[4];
|
|
||||||
MPI_Datatype types[4];
|
|
||||||
|
|
||||||
disps[0] = offsetof(mpi_io_header_t, magic);
|
|
||||||
types[0] = MPI_UINT64_T;
|
|
||||||
blocklengths[0] = 1;
|
|
||||||
|
|
||||||
disps[1] = offsetof(mpi_io_header_t, cpu_header_offset);
|
|
||||||
types[1] = MPI_UINT64_T;
|
|
||||||
blocklengths[1] = 1;
|
|
||||||
|
|
||||||
disps[2] = offsetof(mpi_io_header_t, num_cpus);
|
|
||||||
types[2] = MPI_UINT32_T;
|
|
||||||
blocklengths[2] = 1;
|
|
||||||
|
|
||||||
disps[3] = offsetof(mpi_io_header_t, dt);
|
|
||||||
types[3] = MPI_DOUBLE;
|
|
||||||
blocklengths[3] = 1;
|
|
||||||
|
|
||||||
status = MPI_Type_create_struct(4, blocklengths, disps, types, &type);
|
|
||||||
status |= MPI_Type_commit(&type);
|
|
||||||
|
|
||||||
if(status) {
|
|
||||||
fprintf(stderr, "Creation of the data type \"file_header\" failed!\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
static MPI_Datatype build_cpu_header_type() {
|
|
||||||
int status;
|
|
||||||
MPI_Datatype type;
|
|
||||||
int blocklengths[2];
|
|
||||||
MPI_Aint disps[2];
|
|
||||||
MPI_Datatype types[2];
|
|
||||||
|
|
||||||
disps[0] = offsetof(cpu_header_t, num_particles);
|
|
||||||
types[0] = MPI_UINT64_T;
|
|
||||||
blocklengths[0] = 1;
|
|
||||||
|
|
||||||
disps[1] = offsetof(cpu_header_t, file_offset);
|
|
||||||
types[1] = MPI_UINT64_T;
|
|
||||||
blocklengths[1] = 1;
|
|
||||||
|
|
||||||
status = MPI_Type_create_struct(2, blocklengths, disps, types, &type);
|
|
||||||
status |= MPI_Type_commit(&type);
|
|
||||||
|
|
||||||
if(status) {
|
|
||||||
fprintf(stderr, "Creation of the data type \"cpu_header\" failed!\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* MPI_VERSION */
|
|
||||||
|
|
||||||
#endif /* MPI_PARTICLE_FORMAT_H */
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
#ifndef MPI_PARTICLE_READER_H
|
|
||||||
#define MPI_PARTICLE_READER_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace particle {
|
|
||||||
class SerializedParticle;
|
|
||||||
}
|
|
||||||
|
|
||||||
class MpiParticleReader {
|
|
||||||
public:
|
|
||||||
MpiParticleReader(std::string directory, std::string filename, int restart_at);
|
|
||||||
MpiParticleReader(std::string absolute_filename);
|
|
||||||
MpiParticleReader(std::string abs_filename_without_extension, int restart_at);
|
|
||||||
|
|
||||||
void readParticles(std::vector<particle::SerializedParticle>& storage_queue);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::string absolute_filename_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* MPI_PARTICLE_READER_H */
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
#ifndef MPI_PARTICLE_WRITER_H
|
|
||||||
#define MPI_PARTICLE_WRITER_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace particle {
|
|
||||||
class SerializedParticle;
|
|
||||||
}
|
|
||||||
|
|
||||||
class MpiParticleWriter {
|
|
||||||
public:
|
|
||||||
MpiParticleWriter(std::string directory = "./output",
|
|
||||||
std::string filename = "output",
|
|
||||||
int fs_blocksize = 4096);
|
|
||||||
|
|
||||||
void output_particles(std::vector<particle::SerializedParticle>& particles,
|
|
||||||
int cpu_sync, double dt);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::string directory_;
|
|
||||||
std::string filename_;
|
|
||||||
void createFolder(std::string directory);
|
|
||||||
int fs_blocksize_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* MPI_PARTICLE_WRITER_H */
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
#ifndef RESTART_H
|
|
||||||
#define RESTART_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <map>
|
|
||||||
#include <memory>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "IO/hdf5_reader.h"
|
|
||||||
#include "IO/mpi_particle_reader.h"
|
|
||||||
|
|
||||||
namespace species {
|
|
||||||
class TrackedSpecie;
|
|
||||||
enum class ImplementedSpecies;
|
|
||||||
}; // namespace species
|
|
||||||
|
|
||||||
namespace particle {
|
|
||||||
class SerializedParticle;
|
|
||||||
};
|
|
||||||
|
|
||||||
class DynamicDensityField;
|
|
||||||
class PoissonSolver;
|
|
||||||
class RandomNumbers;
|
|
||||||
|
|
||||||
// Note: The restarts for the DensityField and the PoissonSolver require that the
|
|
||||||
// partitioning of the simulation space does not change between the original and
|
|
||||||
// the restarted simulation
|
|
||||||
// Note: think if it's better (or more consistent) to set the dynamic electric field
|
|
||||||
// here after the potential is loaded; would need the electric field class to be included
|
|
||||||
class Restart {
|
|
||||||
public:
|
|
||||||
// Restart(bool do_restart, std::string absolute_filename,
|
|
||||||
// std::string restart_identifier);
|
|
||||||
Restart(bool do_restart, std::string absolute_filename_without_extension,
|
|
||||||
std::string restart_identifier, int particle_restart_at);
|
|
||||||
|
|
||||||
void restart(std::map<std::string, std::shared_ptr<species::TrackedSpecie>>& species,
|
|
||||||
PoissonSolver* poisson_solver, RandomNumbers* random_numbers,
|
|
||||||
std::vector<particle::SerializedParticle>& storage_queue,
|
|
||||||
int& injectionGroupOffset);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void restartTimer(species::TrackedSpecie* reference_specie);
|
|
||||||
// only necessary for densityfield that is drawn from
|
|
||||||
void restartDrawingDensityField(DynamicDensityField* field, std::string path);
|
|
||||||
// only load in the potential and calc the electric field
|
|
||||||
void restartPoissonSolver(PoissonSolver* solver);
|
|
||||||
void restartRandomNumbers(RandomNumbers* random);
|
|
||||||
void restartParticles(std::vector<particle::SerializedParticle>& storage_queue);
|
|
||||||
|
|
||||||
bool do_restart_;
|
|
||||||
std::string restart_identifier_; // i.e. "LastSyncPeriod" or "SyncPeriod_*"
|
|
||||||
Hdf5Reader reader_;
|
|
||||||
MpiParticleReader particle_reader_;
|
|
||||||
};
|
|
||||||
#endif /* RESTART_H */
|
|
||||||
@@ -5,9 +5,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <random>
|
|
||||||
#include "IO/hdf5_writer.h"
|
#include "IO/hdf5_writer.h"
|
||||||
#include "IO/mpi_particle_writer.h"
|
|
||||||
|
|
||||||
class DynamicDensityField;
|
class DynamicDensityField;
|
||||||
class CurrentBorder;
|
class CurrentBorder;
|
||||||
@@ -31,15 +29,12 @@ struct OutputTask {
|
|||||||
class SimulationOutput {
|
class SimulationOutput {
|
||||||
public:
|
public:
|
||||||
SimulationOutput(const std::string& output_folder,
|
SimulationOutput(const std::string& output_folder,
|
||||||
const std::string& output_filename,
|
const std::string& output_filename);
|
||||||
int fs_blocksize=4096);
|
|
||||||
|
|
||||||
void addDensityFieldOutput(OutputTask task);
|
void addDensityFieldOutput(OutputTask task);
|
||||||
void addCurrentBorderOutput(OutputTask task);
|
void addCurrentBorderOutput(OutputTask task);
|
||||||
void addDeletionLoggerOutput(OutputTask task);
|
void addDeletionLoggerOutput(OutputTask task);
|
||||||
void setPotentialOutput(OutputTask task);
|
void setPotentialOutput(OutputTask task);
|
||||||
void setRestartInfoOutput(OutputTask task);
|
|
||||||
void setParticleOutput(OutputTask task);
|
|
||||||
|
|
||||||
void writeMetaData(
|
void writeMetaData(
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>& species,
|
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>& species,
|
||||||
@@ -48,25 +43,15 @@ class SimulationOutput {
|
|||||||
void writeSimulationData(
|
void writeSimulationData(
|
||||||
int cpu_sync,
|
int cpu_sync,
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>& species,
|
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>& species,
|
||||||
PoissonSolver* poisson_solver, std::mt19937* engine,
|
PoissonSolver* poisson_solver);
|
||||||
std::vector<particle::SerializedParticle>& storage_queue,
|
|
||||||
int injectionGroupOffset);
|
|
||||||
|
|
||||||
#ifdef GENRICHCURRENT
|
|
||||||
void setResetCurrentCollector(int cpu_sync,
|
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>& species);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<OutputTask> tasks_density_fields_;
|
std::vector<OutputTask> tasks_density_fields_;
|
||||||
std::vector<OutputTask> tasks_current_collector_;
|
std::vector<OutputTask> tasks_current_collector_;
|
||||||
std::vector<OutputTask> tasks_deletion_logger_;
|
std::vector<OutputTask> tasks_deletion_logger_;
|
||||||
OutputTask task_potential_;
|
OutputTask task_potential_;
|
||||||
OutputTask task_rng_;
|
|
||||||
OutputTask task_particles_;
|
|
||||||
|
|
||||||
Hdf5Writer writer;
|
Hdf5Writer writer;
|
||||||
MpiParticleWriter particle_writer;
|
|
||||||
|
|
||||||
void writeSimulationData(DynamicDensityField* density_field,
|
void writeSimulationData(DynamicDensityField* density_field,
|
||||||
std::string species_path,
|
std::string species_path,
|
||||||
@@ -76,8 +61,8 @@ class SimulationOutput {
|
|||||||
void writeSpectrum(DynamicDensityField* density_field, std::string path);
|
void writeSpectrum(DynamicDensityField* density_field, std::string path);
|
||||||
void writeDensity(DynamicDensityField* density_field, std::string path);
|
void writeDensity(DynamicDensityField* density_field, std::string path);
|
||||||
void writeTimeInBin(DynamicDensityField* density_field, std::string path);
|
void writeTimeInBin(DynamicDensityField* density_field, std::string path);
|
||||||
// void writeDeletedParticles(DynamicDensityField* density_field,
|
void writeDeletedParticles(DynamicDensityField* density_field,
|
||||||
// std::string path);
|
std::string path);
|
||||||
void writePhysicalTime(DynamicDensityField* density_field, std::string path);
|
void writePhysicalTime(DynamicDensityField* density_field, std::string path);
|
||||||
|
|
||||||
void writeSimulationData(CurrentCollector* current_collector,
|
void writeSimulationData(CurrentCollector* current_collector,
|
||||||
@@ -117,13 +102,6 @@ class SimulationOutput {
|
|||||||
std::string path_to_field);
|
std::string path_to_field);
|
||||||
void writeBinBorders(DynamicDensityField* density_field,
|
void writeBinBorders(DynamicDensityField* density_field,
|
||||||
std::string path_to_field);
|
std::string path_to_field);
|
||||||
|
|
||||||
void writeRestartData(std::mt19937* engine, int cpu_sync,
|
|
||||||
bool overwrite_last, int injectionGroupOffset);
|
|
||||||
void writeRandomEngineState(std::mt19937* engine, std::string path);
|
|
||||||
|
|
||||||
void writeParticles(std::vector<particle::SerializedParticle>& particles,
|
|
||||||
int cpu_sync, double dt);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SIMULATION_OUTPUT_H */
|
#endif /* SIMULATION_OUTPUT_H */
|
||||||
|
|||||||
@@ -10,11 +10,6 @@ static const double minimal_macroscopic_cross_section =
|
|||||||
std::numeric_limits<double>::min() * 1E5;
|
std::numeric_limits<double>::min() * 1E5;
|
||||||
static const double random_lower_limit = 1E-15;
|
static const double random_lower_limit = 1E-15;
|
||||||
static const double compare_epsilon = 1E-10;
|
static const double compare_epsilon = 1E-10;
|
||||||
// engine state of mt19973 engine consists of 624 numbers (output seems to write 625)
|
|
||||||
// (assumed to be constant); each number is represented by a 32 bit word (2^32 = 4294967296)
|
|
||||||
// i.e. each number needs at most 10 digits; the numbers are seperated by whitespaces
|
|
||||||
// -> max length = 10*625 + 624 = 6874 (add one more digit to be on the safe side)
|
|
||||||
static const size_t engine_string_length_max = 6875;
|
|
||||||
|
|
||||||
} // namespace SimConstants
|
} // namespace SimConstants
|
||||||
|
|
||||||
|
|||||||
@@ -19,11 +19,6 @@ EnergyBinning buildEnergyBinningIncludingRedirection(
|
|||||||
Parameter& parameter,
|
Parameter& parameter,
|
||||||
json_path& path_to_binning);
|
json_path& path_to_binning);
|
||||||
|
|
||||||
PitchAngleBinning buildPitchAngleBinning(json_t* object);
|
|
||||||
PitchAngleBinning buildPitchAngleBinningIncludingRedirection(
|
|
||||||
Parameter& parameter,
|
|
||||||
json_path& path_to_binning);
|
|
||||||
|
|
||||||
}; // namespace generator
|
}; // namespace generator
|
||||||
|
|
||||||
#endif /* BINNING_GENERATOR_H */
|
#endif /* BINNING_GENERATOR_H */
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
#ifndef RESTART_GENERATOR_H
|
|
||||||
#define RESTART_GENERATOR_H
|
|
||||||
|
|
||||||
#include "jansson.h"
|
|
||||||
#include "simulation/parameter.h"
|
|
||||||
|
|
||||||
class Restart;
|
|
||||||
|
|
||||||
namespace generator{
|
|
||||||
Restart buildRestart(json_t* object);
|
|
||||||
|
|
||||||
Restart buildRestart(Parameter& parameter);
|
|
||||||
}; // namespace generator
|
|
||||||
|
|
||||||
#endif /* RESTART_GENERATOR_H */
|
|
||||||
@@ -27,7 +27,6 @@ struct TrackedSpeciesBuilderInfo {
|
|||||||
|
|
||||||
double mass_kg;
|
double mass_kg;
|
||||||
double charge_C;
|
double charge_C;
|
||||||
bool explicitly_stored;
|
|
||||||
species::ImplementedSpecies type;
|
species::ImplementedSpecies type;
|
||||||
std::string name;
|
std::string name;
|
||||||
json_path path_in_json;
|
json_path path_in_json;
|
||||||
|
|||||||
@@ -10,8 +10,8 @@
|
|||||||
namespace generator {
|
namespace generator {
|
||||||
std::shared_ptr<VectorField> buildVectorField(json_t* object);
|
std::shared_ptr<VectorField> buildVectorField(json_t* object);
|
||||||
std::string readAbsoluteFilename(json_t* object);
|
std::string readAbsoluteFilename(json_t* object);
|
||||||
blitz::Array<double, 2> readComponentFromFile(json_t* object, int component);
|
blitz::Array<double, 3> readComponentFromFile(json_t* object, int component);
|
||||||
blitz::Array<double, 2> readFromFile(json_t* object);
|
blitz::Array<double, 3> readFromFile(json_t* object);
|
||||||
} // namespace generator
|
} // namespace generator
|
||||||
|
|
||||||
#endif /* VECTOR_FIELD_GENERATOR_H */
|
#endif /* VECTOR_FIELD_GENERATOR_H */
|
||||||
|
|||||||
@@ -10,45 +10,18 @@ class Specie;
|
|||||||
|
|
||||||
namespace interaction {
|
namespace interaction {
|
||||||
|
|
||||||
// class for (radiative) cluster formation interactions (A + B --> AB)
|
|
||||||
class ClusterFormation : public Interaction {
|
class ClusterFormation : public Interaction {
|
||||||
public:
|
public:
|
||||||
ClusterFormation(std::function<double(double)> cross_section,
|
ClusterFormation(std::function<double(double)> cross_section,
|
||||||
std::shared_ptr<species::Specie> target,
|
std::shared_ptr<species::Specie> target,
|
||||||
std::shared_ptr<species::TrackedSpecie> product);
|
std::shared_ptr<species::TrackedSpecie> product);
|
||||||
virtual InteractionOutput performInteraction(particle::Particle& particle,
|
|
||||||
RandomNumbers* generator);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
std::shared_ptr<species::TrackedSpecie> product_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// class for tertiary association (A + B + B --> AB + B or A + B2 -> AB + B)
|
|
||||||
class ClusterFormationTertiary : public ClusterFormation {
|
|
||||||
public:
|
|
||||||
// Constructor: takes the function describing the cross section (dependent on the energy of the incident particle)
|
|
||||||
// and a shared_ptr to the Species that is the target in the interaction
|
|
||||||
// and a shared_ptr to the TrackedSpecie that is the product of the interaction
|
|
||||||
ClusterFormationTertiary(std::function<double(double)> cross_section,
|
|
||||||
std::shared_ptr<species::Specie> target,
|
|
||||||
std::shared_ptr<species::TrackedSpecie> product,
|
|
||||||
bool rate_coefficient = true);
|
|
||||||
|
|
||||||
// due to only the rate coefficients being available the cross section is
|
|
||||||
// approximated as sigma = rate_coefficient * density / velocity
|
|
||||||
// (units of the tertiary rate coefficient m^6/s)
|
|
||||||
double microscopicCrossSection(double energy_eV, const Coordinate& position);
|
|
||||||
|
|
||||||
InteractionOutput performInteraction(particle::Particle& particle,
|
InteractionOutput performInteraction(particle::Particle& particle,
|
||||||
RandomNumbers* generator);
|
RandomNumbers* generator);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// flag whether the "cross_section_" function is in truth calculated using a
|
std::shared_ptr<species::TrackedSpecie> product_;
|
||||||
// three body association rate
|
|
||||||
bool rate_coefficient_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}; // namespace interaction
|
}; // namespace interaction
|
||||||
|
|
||||||
#endif /* CLUSTER_FORMATION_H */
|
#endif /* CLUSTER_FORMATION_H */
|
||||||
|
|||||||
@@ -13,27 +13,11 @@ class ElasticScattering : public Interaction {
|
|||||||
std::shared_ptr<species::Specie> target,
|
std::shared_ptr<species::Specie> target,
|
||||||
std::shared_ptr<ScatteringAngleDistribution> theta_distrib);
|
std::shared_ptr<ScatteringAngleDistribution> theta_distrib);
|
||||||
|
|
||||||
virtual InteractionOutput performInteraction(particle::Particle& particle,
|
|
||||||
RandomNumbers* generator);
|
|
||||||
virtual double drawCollisionTime(particle::Particle& particle,
|
|
||||||
RandomNumbers* generator);
|
|
||||||
protected:
|
|
||||||
std::shared_ptr<ScatteringAngleDistribution> theta_distrib_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Full elastic scattering in the sense that both particles after scattering
|
|
||||||
// become tracked
|
|
||||||
class ElasticScatteringFull : public ElasticScattering {
|
|
||||||
public:
|
|
||||||
ElasticScatteringFull(std::function<double(double)> cross_section,
|
|
||||||
std::shared_ptr<species::Specie> target,
|
|
||||||
std::shared_ptr<ScatteringAngleDistribution> theta_distrib,
|
|
||||||
std::shared_ptr<species::TrackedSpecie> product);
|
|
||||||
|
|
||||||
InteractionOutput performInteraction(particle::Particle& particle,
|
InteractionOutput performInteraction(particle::Particle& particle,
|
||||||
RandomNumbers* generator);
|
RandomNumbers* generator);
|
||||||
protected:
|
|
||||||
std::shared_ptr<species::TrackedSpecie> product_;
|
private:
|
||||||
|
std::shared_ptr<ScatteringAngleDistribution> theta_distrib_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}; // namespace interaction
|
}; // namespace interaction
|
||||||
|
|||||||
@@ -13,10 +13,8 @@ class FreeMovement : public Interaction {
|
|||||||
InteractionOutput performInteraction(particle::Particle& particle,
|
InteractionOutput performInteraction(particle::Particle& particle,
|
||||||
RandomNumbers* generator);
|
RandomNumbers* generator);
|
||||||
|
|
||||||
double microscopicCrossSection(double energy_eV, const Coordinate& position);
|
double microscopicCrossSection(double energy_eV);
|
||||||
double macroscopicCrossSection(particle::Particle& particle);
|
double macroscopicCrossSection(particle::Particle& particle);
|
||||||
double drawCollisionTime(particle::Particle& particle,
|
|
||||||
RandomNumbers* generator);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}; // namespace interaction
|
}; // namespace interaction
|
||||||
|
|||||||
@@ -39,8 +39,7 @@ class ElectronIonization : public Interaction {
|
|||||||
std::shared_ptr<species::TrackedSpecie> ion,
|
std::shared_ptr<species::TrackedSpecie> ion,
|
||||||
std::shared_ptr<IonizationEnergyDistribution> distribution,
|
std::shared_ptr<IonizationEnergyDistribution> distribution,
|
||||||
std::shared_ptr<IonizationScatteringAngleDistribution> angle_distribution,
|
std::shared_ptr<IonizationScatteringAngleDistribution> angle_distribution,
|
||||||
double ionization_energy_eV,
|
double ionization_energy_eV);
|
||||||
double ion_energy);
|
|
||||||
|
|
||||||
InteractionOutput performInteraction(particle::Particle& particle,
|
InteractionOutput performInteraction(particle::Particle& particle,
|
||||||
RandomNumbers* generator);
|
RandomNumbers* generator);
|
||||||
@@ -49,7 +48,6 @@ class ElectronIonization : public Interaction {
|
|||||||
std::shared_ptr<IonizationEnergyDistribution> energy_distribution_;
|
std::shared_ptr<IonizationEnergyDistribution> energy_distribution_;
|
||||||
std::shared_ptr<IonizationScatteringAngleDistribution> angle_distribution_;
|
std::shared_ptr<IonizationScatteringAngleDistribution> angle_distribution_;
|
||||||
const double ionization_energy_eV_;
|
const double ionization_energy_eV_;
|
||||||
const double ion_energy_;
|
|
||||||
|
|
||||||
std::shared_ptr<species::TrackedSpecie> electron_;
|
std::shared_ptr<species::TrackedSpecie> electron_;
|
||||||
std::shared_ptr<species::TrackedSpecie> ion_;
|
std::shared_ptr<species::TrackedSpecie> ion_;
|
||||||
|
|||||||
@@ -15,8 +15,6 @@ class Recombination : public Interaction {
|
|||||||
|
|
||||||
double macroscopicCrossSection(particle::Particle& particle);
|
double macroscopicCrossSection(particle::Particle& particle);
|
||||||
|
|
||||||
double drawCollisionTime(particle::Particle& particle, RandomNumbers* generator);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double macroscopicCrossSection(const Coordinate& position, const int bin_index);
|
double macroscopicCrossSection(const Coordinate& position, const int bin_index);
|
||||||
std::shared_ptr<species::TrackedSpecie> recombination_target_;
|
std::shared_ptr<species::TrackedSpecie> recombination_target_;
|
||||||
|
|||||||
@@ -29,14 +29,11 @@ struct GlobalBoundary {
|
|||||||
BoundaryType type;
|
BoundaryType type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// only useful at the initialization of the PoissonSolver...
|
|
||||||
// (or if at later times a time dependent value is desired)
|
|
||||||
class Electrode {
|
class Electrode {
|
||||||
public:
|
public:
|
||||||
Electrode(double potential);
|
Electrode(double potential);
|
||||||
virtual bool isOnElectrode(const Coordinate& position) = 0;
|
virtual bool isOnElectrode(const Coordinate& position) = 0;
|
||||||
virtual double electrodePotential();
|
double electrodePotential();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const double potential_;
|
const double potential_;
|
||||||
@@ -48,21 +45,6 @@ class RearWall : public Electrode {
|
|||||||
bool isOnElectrode(const Coordinate& position);
|
bool isOnElectrode(const Coordinate& position);
|
||||||
};
|
};
|
||||||
|
|
||||||
class RingElectrode : public Electrode {
|
|
||||||
public:
|
|
||||||
RingElectrode(double potential, const double zPosition,
|
|
||||||
const double innerRadius,
|
|
||||||
const double outerRadius,
|
|
||||||
const blitz::TinyVector<double, 2> stepsize);
|
|
||||||
bool isOnElectrode(const Coordinate& position);
|
|
||||||
|
|
||||||
private:
|
|
||||||
// stores (rinner, router, zpos) in this order
|
|
||||||
blitz::TinyVector<double,3> specs_;
|
|
||||||
blitz::TinyVector<double,2> stepsize_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// for (r,z) axially density
|
|
||||||
class PoissonSolver {
|
class PoissonSolver {
|
||||||
public:
|
public:
|
||||||
PoissonSolver(GlobalBoundary bottom_boundary,
|
PoissonSolver(GlobalBoundary bottom_boundary,
|
||||||
@@ -73,15 +55,16 @@ class PoissonSolver {
|
|||||||
std::vector<std::shared_ptr<Electrode>> electrodes,
|
std::vector<std::shared_ptr<Electrode>> electrodes,
|
||||||
double target_accuracy,
|
double target_accuracy,
|
||||||
int num_cycles,
|
int num_cycles,
|
||||||
|
int solver_intervall,
|
||||||
|
int solver_offset,
|
||||||
bool do_solver);
|
bool do_solver);
|
||||||
|
|
||||||
void solvePotential(const blitz::Array<double, 2> charge_density);
|
void solvePotential(const blitz::Array<double, 3> charge_density,
|
||||||
blitz::Array<double, 2> potential();
|
int cpu_sync);
|
||||||
|
blitz::Array<double, 3> potential();
|
||||||
std::shared_ptr<VectorField> staticElectricField();
|
std::shared_ptr<VectorField> staticElectricField();
|
||||||
const CylinderBinning* densityBinning();
|
const CylinderBinning* densityBinning();
|
||||||
|
|
||||||
void setPotential(blitz::Array<double, 2>& potential);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GlobalBoundary bottom_boundary_;
|
GlobalBoundary bottom_boundary_;
|
||||||
GlobalBoundary top_boundary_;
|
GlobalBoundary top_boundary_;
|
||||||
@@ -91,18 +74,20 @@ class PoissonSolver {
|
|||||||
const CylinderBinning density_binning_;
|
const CylinderBinning density_binning_;
|
||||||
const double target_accuracy_;
|
const double target_accuracy_;
|
||||||
const int num_cycles_;
|
const int num_cycles_;
|
||||||
|
const int solver_intervall_;
|
||||||
|
const int solver_offset_;
|
||||||
const bool do_solver_;
|
const bool do_solver_;
|
||||||
|
|
||||||
// density binning defined on the cell centers, potential defined
|
// density binning defined on the cell centers, potential defined
|
||||||
// such that it exists on the cell edges so that the azimuthal
|
// such that it exists on the cell edges so that the azimuthal
|
||||||
// position is the same as the one of the density binning
|
// position is the same as the one of the density binning
|
||||||
blitz::Array<PotentialGridPoint, 2> potential_; //unit V
|
blitz::Array<PotentialGridPoint, 3> potential_; //unit V
|
||||||
|
|
||||||
blitz::Array<double, 2> interpolateDensityToPotentialGrid(
|
blitz::Array<double, 3> interpolateDensityToPotentialGrid(
|
||||||
const blitz::Array<double, 2> charge_density);
|
const blitz::Array<double, 3> charge_density);
|
||||||
|
|
||||||
void solverIteration(const blitz::Array<double, 2>& interpolated_density);
|
void solverIteration(const blitz::Array<double, 3>& interpolated_density);
|
||||||
bool converged(const blitz::Array<double, 2>& interpolated_density);
|
bool converged(const blitz::Array<double, 3>& interpolated_density);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Electrodes can only be dirichlet boundary conditions
|
// Electrodes can only be dirichlet boundary conditions
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "constants/sim_constants.h"
|
#include "constants/sim_constants.h"
|
||||||
|
|
||||||
inline bool isEqual(double a, double b) {
|
bool isEqual(double a, double b) {
|
||||||
return std::abs(a - b) < SimConstants::compare_epsilon;
|
return std::abs(a - b) < SimConstants::compare_epsilon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,9 +27,6 @@ class Coordinate {
|
|||||||
virtual blitz::TinyVector<double, 3> cartesianEntries() const = 0;
|
virtual blitz::TinyVector<double, 3> cartesianEntries() const = 0;
|
||||||
virtual blitz::TinyVector<double, 3> cylinderEntries() const = 0;
|
virtual blitz::TinyVector<double, 3> cylinderEntries() const = 0;
|
||||||
|
|
||||||
virtual double cosAzimuth() const = 0;
|
|
||||||
virtual double sinAzimuth() const = 0;
|
|
||||||
|
|
||||||
virtual void add(const Coordinate& coordinate) = 0;
|
virtual void add(const Coordinate& coordinate) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -41,9 +38,6 @@ class CartesianCoordinate : public Coordinate {
|
|||||||
blitz::TinyVector<double, 3> cartesianEntries() const;
|
blitz::TinyVector<double, 3> cartesianEntries() const;
|
||||||
blitz::TinyVector<double, 3> cylinderEntries() const;
|
blitz::TinyVector<double, 3> cylinderEntries() const;
|
||||||
|
|
||||||
double cosAzimuth() const;
|
|
||||||
double sinAzimuth() const;
|
|
||||||
|
|
||||||
void add(const Coordinate& coordinate);
|
void add(const Coordinate& coordinate);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -58,17 +52,11 @@ class CylinderCoordinate : public Coordinate {
|
|||||||
blitz::TinyVector<double, 3> cartesianEntries() const;
|
blitz::TinyVector<double, 3> cartesianEntries() const;
|
||||||
blitz::TinyVector<double, 3> cylinderEntries() const;
|
blitz::TinyVector<double, 3> cylinderEntries() const;
|
||||||
|
|
||||||
double cosAzimuth() const;
|
|
||||||
double sinAzimuth() const;
|
|
||||||
|
|
||||||
void add(const Coordinate& coordinate);
|
void add(const Coordinate& coordinate);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void limitPhi();
|
void limitPhi();
|
||||||
blitz::TinyVector<double, 3> cylinder_position;
|
blitz::TinyVector<double, 3> cylinder_position;
|
||||||
#ifdef debug
|
|
||||||
bool phi_was_set = false;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Vector {
|
class Vector {
|
||||||
|
|||||||
@@ -23,35 +23,26 @@ class CpuSynchronizer {
|
|||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>&
|
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>&
|
||||||
tracked_species);
|
tracked_species);
|
||||||
|
|
||||||
void synchronize(DynamicDensityField* field);
|
void synchronize(DynamicDensityField* field,
|
||||||
void synchronize(CurrentCollector* collector);
|
DynamicDensityField* last_sync_field);
|
||||||
void synchronize(DeletionLogger* logger);
|
void synchronize(CurrentCollector* collector,
|
||||||
|
CurrentCollector* last_sync_collector);
|
||||||
|
void synchronize(DeletionLogger* logger,
|
||||||
|
DeletionLogger* last_sync_logger);
|
||||||
void synchronize(Timer* timer, Timer* last_sync_timer);
|
void synchronize(Timer* timer, Timer* last_sync_timer);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
sums delta = * - last_sync_* to last_sync_* over all CPUs
|
sums delta = * - last_sync_* to last_sync_* over all CPUs
|
||||||
*/
|
*/
|
||||||
|
void sumToAll(blitz::Array<double, 4>& array,
|
||||||
|
blitz::Array<double, 4>& last_sync_array);
|
||||||
void sumToAll(blitz::Array<double, 3>& array,
|
void sumToAll(blitz::Array<double, 3>& array,
|
||||||
blitz::Array<double, 3>& last_sync_array);
|
blitz::Array<double, 3>& last_sync_array);
|
||||||
void sumToAll(blitz::Array<long int, 4>& array,
|
void sumToAll(blitz::Array<long int, 4>& array,
|
||||||
blitz::Array<long int, 4>& last_sync_array);
|
blitz::Array<long int, 4>& last_sync_array);
|
||||||
void sumToAll(blitz::Array<long int, 5>& array,
|
|
||||||
blitz::Array<long int, 5>& last_sync_array);
|
|
||||||
void sumToAll(double& value, double& last_sync_value);
|
void sumToAll(double& value, double& last_sync_value);
|
||||||
void sumToAll(long int& value, long int& last_sync_value);
|
void sumToAll(long int& value, long int& last_sync_value);
|
||||||
|
|
||||||
// array has to be the delta of the timestep
|
|
||||||
void sumToAll(blitz::Array<double, 5>& array);
|
|
||||||
void sumToAll(blitz::Array<double, 4>& array);
|
|
||||||
|
|
||||||
// collect data to rank 0 functions
|
|
||||||
void sumToRoot(blitz::Array<double, 3>& array);
|
|
||||||
void sumToRoot(blitz::Array<double, 2>& array);
|
|
||||||
void sumToRoot(long int& value);
|
|
||||||
void sumToRoot(double& value);
|
|
||||||
|
|
||||||
const int root = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* CPU_SYNCHRONIZER_H */
|
#endif /* CPU_SYNCHRONIZER_H */
|
||||||
|
|||||||
@@ -14,85 +14,60 @@ class CurrentCollector {
|
|||||||
|
|
||||||
void collect(particle::Particle* particle, const Coordinate& old_position);
|
void collect(particle::Particle* particle, const Coordinate& old_position);
|
||||||
|
|
||||||
blitz::Array<double, 2> negativeCrossingsInR() const;
|
blitz::Array<double, 3> negativeCrossingsInR() const;
|
||||||
blitz::Array<double, 2> positiveCrossingsInR() const;
|
blitz::Array<double, 3> positiveCrossingsInR() const;
|
||||||
blitz::Array<double, 2> areaInR() const;
|
blitz::Array<double, 3> areaInR() const;
|
||||||
blitz::Array<double, 2> currentInR() const;
|
blitz::Array<double, 3> currentInR() const;
|
||||||
|
|
||||||
blitz::Array<double, 2> negativeCrossingsInPhi() const;
|
blitz::Array<double, 3> negativeCrossingsInPhi() const;
|
||||||
blitz::Array<double, 2> positiveCrossingsInPhi() const;
|
blitz::Array<double, 3> positiveCrossingsInPhi() const;
|
||||||
blitz::Array<double, 2> areaInPhi() const;
|
blitz::Array<double, 3> areaInPhi() const;
|
||||||
blitz::Array<double, 2> currentInPhi() const;
|
blitz::Array<double, 3> currentInPhi() const;
|
||||||
|
|
||||||
blitz::Array<double, 2> negativeCrossingsInZ() const;
|
blitz::Array<double, 3> negativeCrossingsInZ() const;
|
||||||
blitz::Array<double, 2> positiveCrossingsInZ() const;
|
blitz::Array<double, 3> positiveCrossingsInZ() const;
|
||||||
blitz::Array<double, 2> areaInZ() const;
|
blitz::Array<double, 3> areaInZ() const;
|
||||||
blitz::Array<double, 2> currentInZ() const;
|
blitz::Array<double, 3> currentInZ() const;
|
||||||
|
|
||||||
#ifdef GENRICHCURRENT
|
|
||||||
blitz::Array<double, 2> sampleNegativeCrossings() const;
|
|
||||||
std::vector<double> energyBinBorders() const;
|
|
||||||
void needsReset() { needs_reset = true; };
|
|
||||||
bool getNeedsReset() const { return needs_reset; };
|
|
||||||
double timeSinceReset() const {return time_since_reset;};
|
|
||||||
#endif //GENRICHCURRENT
|
|
||||||
|
|
||||||
double physicalTime() const;
|
double physicalTime() const;
|
||||||
|
|
||||||
void resetCurrentCollector();
|
|
||||||
|
|
||||||
friend class CpuSynchronizer;
|
friend class CpuSynchronizer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void collectRadialMovement(const blitz::TinyVector<int, 2>& bin_old,
|
void collectRadialMovement(const blitz::TinyVector<int, 3>& bin_old,
|
||||||
const blitz::TinyVector<int, 2>& bin_new,
|
const blitz::TinyVector<int, 3>& bin_new);
|
||||||
const double weight);
|
void collectLongitudinalMovement(const blitz::TinyVector<int, 3>& bin_old,
|
||||||
void collectLongitudinalMovement(const blitz::TinyVector<int, 2>& bin_old,
|
const blitz::TinyVector<int, 3>& bin_new);
|
||||||
const blitz::TinyVector<int, 2>& bin_new,
|
void collectAzimuthalMovement(const blitz::TinyVector<int, 3>& bin_old,
|
||||||
#ifdef GENRICHCURRENT
|
const blitz::TinyVector<int, 3>& bin_new);
|
||||||
const double energy_eV,
|
|
||||||
#endif
|
|
||||||
const double weight);
|
|
||||||
void collectAzimuthalMovement(const blitz::TinyVector<double, 3>& old_pos_cart,
|
|
||||||
const blitz::TinyVector<double, 3>& new_pos_cart,
|
|
||||||
const blitz::TinyVector<int,2>& bin_old,
|
|
||||||
const double weight);
|
|
||||||
|
|
||||||
blitz::Array<double, 2> createAreaLongitudinal(
|
blitz::Array<double, 3> createAreaLongitudinal(
|
||||||
const CylinderBinning& position_binning);
|
const CylinderBinning& position_binning);
|
||||||
blitz::Array<double, 2> createCrossingsLongitudinal(
|
blitz::Array<double, 3> createCrossingsLongitudinal(
|
||||||
const CylinderBinning& position_binning);
|
const CylinderBinning& position_binning);
|
||||||
|
|
||||||
blitz::Array<double, 2> createAreaRadial(
|
blitz::Array<double, 3> createAreaRadial(
|
||||||
const CylinderBinning& position_binning);
|
const CylinderBinning& position_binning);
|
||||||
blitz::Array<double, 2> createCrossingsRadial(
|
blitz::Array<double, 3> createCrossingsRadial(
|
||||||
const CylinderBinning& position_binning);
|
const CylinderBinning& position_binning);
|
||||||
|
|
||||||
blitz::Array<double, 2> createAreaAzimuthal(
|
blitz::Array<double, 3> createAreaAzimuthal(
|
||||||
const CylinderBinning& position_binning);
|
const CylinderBinning& position_binning);
|
||||||
blitz::Array<double, 2> createCrossingsAzimuthal(
|
blitz::Array<double, 3> createCrossingsAzimuthal(
|
||||||
const CylinderBinning& position_binning);
|
const CylinderBinning& position_binning);
|
||||||
|
|
||||||
blitz::Array<double, 2> z_negative_crossings;
|
blitz::Array<double, 3> z_negative_crossings;
|
||||||
blitz::Array<double, 2> z_positive_crossings;
|
blitz::Array<double, 3> z_positive_crossings;
|
||||||
|
|
||||||
blitz::Array<double, 2> phi_negative_crossings;
|
blitz::Array<double, 3> phi_negative_crossings;
|
||||||
blitz::Array<double, 2> phi_positive_crossings;
|
blitz::Array<double, 3> phi_positive_crossings;
|
||||||
|
|
||||||
blitz::Array<double, 2> r_negative_crossings;
|
blitz::Array<double, 3> r_negative_crossings;
|
||||||
blitz::Array<double, 2> r_positive_crossings;
|
blitz::Array<double, 3> r_positive_crossings;
|
||||||
|
|
||||||
blitz::Array<double, 2> collector_areas_r;
|
blitz::Array<double, 3> collector_areas_r;
|
||||||
blitz::Array<double, 2> collector_areas_phi;
|
blitz::Array<double, 3> collector_areas_phi;
|
||||||
blitz::Array<double, 2> collector_areas_z;
|
blitz::Array<double, 3> collector_areas_z;
|
||||||
|
|
||||||
#ifdef GENRICHCURRENT
|
|
||||||
blitz::Array<double, 2> sample_z_negative_crossings;
|
|
||||||
EnergyBinning energy_binning_;
|
|
||||||
|
|
||||||
bool needs_reset = false;
|
|
||||||
double time_since_reset = 0;
|
|
||||||
#endif //GENRICHCURRENT
|
|
||||||
|
|
||||||
CylinderBinning position_binning_;
|
CylinderBinning position_binning_;
|
||||||
std::shared_ptr<Timer> timer_;
|
std::shared_ptr<Timer> timer_;
|
||||||
|
|||||||
@@ -2,9 +2,7 @@
|
|||||||
#define DENSITY_FIELD_H
|
#define DENSITY_FIELD_H
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <random>
|
|
||||||
|
|
||||||
#include "simulation/compare.h"
|
|
||||||
#include "simulation/coordinates.h"
|
#include "simulation/coordinates.h"
|
||||||
#include "simulation/cpu_synchronizer.h"
|
#include "simulation/cpu_synchronizer.h"
|
||||||
#include "simulation/energy_binning.h"
|
#include "simulation/energy_binning.h"
|
||||||
@@ -20,18 +18,12 @@ class DensityField {
|
|||||||
virtual double density(const Coordinate& position, double energy_eV) = 0;
|
virtual double density(const Coordinate& position, double energy_eV) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
// includes a resolution of the pitch angle (i.e. cos(angle(\vec{v}, \vec{B})))
|
|
||||||
class DynamicDensityField : public DensityField {
|
class DynamicDensityField : public DensityField {
|
||||||
public:
|
public:
|
||||||
|
DynamicDensityField(const CylinderBinning& position_binning,
|
||||||
DynamicDensityField(const CylinderBinning& positionBinning,
|
|
||||||
const EnergyBinning& energy_binning,
|
const EnergyBinning& energy_binning,
|
||||||
const PitchAngleBinning& pitch_angle_binning,
|
|
||||||
std::shared_ptr<Timer> timer);
|
std::shared_ptr<Timer> timer);
|
||||||
|
|
||||||
double density(const Coordinate& position);
|
|
||||||
double density(const Coordinate& position, double energy_eV);
|
|
||||||
|
|
||||||
bool changedPositionBin(const Coordinate& old_position,
|
bool changedPositionBin(const Coordinate& old_position,
|
||||||
const Coordinate& new_position) const;
|
const Coordinate& new_position) const;
|
||||||
|
|
||||||
@@ -39,60 +31,52 @@ class DynamicDensityField : public DensityField {
|
|||||||
|
|
||||||
void logMovement(const Coordinate& position,
|
void logMovement(const Coordinate& position,
|
||||||
double energy_eV,
|
double energy_eV,
|
||||||
double pitch_angle,
|
double time_in_bin_s);
|
||||||
double weight);
|
|
||||||
|
|
||||||
// returns true if the old pitch angle and the new pitch angle are in different bins
|
void logDeletion(const Coordinate& position, double energy_eV);
|
||||||
// of the pitch angle binning
|
|
||||||
bool changedPitchAngleBin(double old_pitch_angle, double new_pitch_angle) const;
|
|
||||||
|
|
||||||
blitz::Array<double, 2> densityArray();
|
double density(const Coordinate& position);
|
||||||
blitz::Array<double, 3> spectrumArray();
|
double density(const Coordinate& position, double energy_eV);
|
||||||
blitz::Array<double, 4> numberInBinArray() const;
|
|
||||||
blitz::Array<double, 2> binVolumeArray() const;
|
|
||||||
|
|
||||||
// return an array of the density values at the Coordinate position (only energy
|
blitz::Array<double, 3> densityArray();
|
||||||
// direction left); over and underflow bin are removed
|
blitz::Array<double, 4> spectrumArray();
|
||||||
// (might not be good, since then the underflow particles are lost...)
|
blitz::Array<double, 4> timeInBinArray() const;
|
||||||
blitz::Array<double, 1> sliceSpectrumArray(const Coordinate& position) const;
|
blitz::Array<long int, 4> deletedParticlesArray() const;
|
||||||
|
blitz::Array<double, 3> binVolumeArray() const;
|
||||||
// return an array of the time in bin at the Coordinate position and the energy
|
|
||||||
// energy_eV (only pitch angle direction left); over and underflow bin are removed
|
|
||||||
blitz::Array<double, 1> sliceNumberInBinArray(const Coordinate& position,
|
|
||||||
double energy_eV) const;
|
|
||||||
|
|
||||||
const EnergyBinning* energyBinning() const;
|
const EnergyBinning* energyBinning() const;
|
||||||
const CylinderBinning* positionBinning() const;
|
const CylinderBinning* positionBinning() const;
|
||||||
const PitchAngleBinning* pitchAngleBinning() const;
|
|
||||||
|
|
||||||
double physicalTime() const;
|
double physicalTime() const;
|
||||||
double timeResolution() const;
|
|
||||||
|
|
||||||
void resetDynamicDensityField();
|
|
||||||
|
|
||||||
friend class CpuSynchronizer;
|
friend class CpuSynchronizer;
|
||||||
|
|
||||||
void restartTimer(double time, double delta_t);
|
private:
|
||||||
void restartNumberInBin(blitz::Array<double, 4> number_in_bin);
|
// coordinate ordering: r, phi, z, E
|
||||||
|
// bin numbering
|
||||||
|
// radial:
|
||||||
|
// 0, ..., num_bin_r-1: r < r_max
|
||||||
|
// num_bin_r: r >= r_max
|
||||||
|
//
|
||||||
|
// azimuthal:
|
||||||
|
// 0, ..., num_bin_phi: all
|
||||||
|
//
|
||||||
|
// longitudinal:
|
||||||
|
// -1: z < 0
|
||||||
|
// 0, ..., num_bin_z-1: 0 <= z < z_max
|
||||||
|
// num_bin_z: z >= z_max
|
||||||
|
BinCoordinate densityBin(const CylinderCoordinate& position) const;
|
||||||
void recalculateDensityArray();
|
void recalculateDensityArray();
|
||||||
|
|
||||||
private:
|
blitz::Array<double, 4> time_in_bin_s_;
|
||||||
|
blitz::Array<long int, 4> deleted_particles_;
|
||||||
// use ordering r, z, pitch_angle, E.
|
blitz::Array<double, 4> density_per_m3_;
|
||||||
// Full symmetry in azimuthal direction -> no phi resolution
|
blitz::Array<double, 3> bin_volume_m3_;
|
||||||
blitz::Array<double, 4> number_in_bin_;
|
|
||||||
blitz::Array<double, 4> sync_number_in_bin_;
|
|
||||||
|
|
||||||
blitz::Array<double, 3> density_per_m3_;
|
|
||||||
blitz::Array<double, 2> bin_volume_m3_;
|
|
||||||
|
|
||||||
const CylinderBinning position_binning_;
|
const CylinderBinning position_binning_;
|
||||||
const EnergyBinning energy_binning_;
|
const EnergyBinning energy_binning_;
|
||||||
const PitchAngleBinning pitch_angle_binning_;
|
|
||||||
|
|
||||||
std::shared_ptr<Timer> timer_;
|
std::shared_ptr<Timer> timer_;
|
||||||
bool timer_restarted_ = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ConstantDensityField : public DensityField {
|
class ConstantDensityField : public DensityField {
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ class DriftVelocity {
|
|||||||
DriftVelocity(std::shared_ptr<VectorField> drift_velocity);
|
DriftVelocity(std::shared_ptr<VectorField> drift_velocity);
|
||||||
|
|
||||||
CartesianVector driftVelocity(const Coordinate& position);
|
CartesianVector driftVelocity(const Coordinate& position);
|
||||||
CartesianVector driftVelocity(const CartesianCoordinate& cartCoord,
|
|
||||||
const CylinderCoordinate& cylCoord);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<VectorField> drift_velocity_;
|
std::shared_ptr<VectorField> drift_velocity_;
|
||||||
|
|||||||
@@ -18,22 +18,4 @@ class EnergyBinning {
|
|||||||
const std::vector<double> energy_bin_borders_;
|
const std::vector<double> energy_bin_borders_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// do a seperate class for the pitchangles now (questionable if it's
|
|
||||||
// sensible to have it in here)
|
|
||||||
// might become unneccessary in the future once the option for a linear
|
|
||||||
// binning in the EnergyBinning class is implemented
|
|
||||||
class PitchAngleBinning {
|
|
||||||
public:
|
|
||||||
PitchAngleBinning(int num_bins);
|
|
||||||
|
|
||||||
int bin(double pitch_angle) const;
|
|
||||||
int numBins() const;
|
|
||||||
std::vector<double> binBorders() const;
|
|
||||||
int binIndexMin() const;
|
|
||||||
int binIndexMax() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
const std::vector<double> pitch_angle_bin_borders_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* ENERGY_BINNING_H */
|
#endif /* ENERGY_BINNING_H */
|
||||||
|
|||||||
@@ -20,17 +20,6 @@ class TritiumBetaDecay : public EnergyDistributionFunction {
|
|||||||
std::uniform_real_distribution<double> y_distribution_;
|
std::uniform_real_distribution<double> y_distribution_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TritiumBetaDecayIon : public EnergyDistributionFunction {
|
|
||||||
public:
|
|
||||||
TritiumBetaDecayIon(double endpoint_eV);
|
|
||||||
double rollEnergy(std::mt19937* engine);
|
|
||||||
|
|
||||||
private:
|
|
||||||
const std::function<double(double)> tritium_spectrum_, tritium_spectrum_ion_;
|
|
||||||
std::uniform_real_distribution<double> x_distribution_;
|
|
||||||
std::uniform_real_distribution<double> y_distribution_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MaxwellBoltzmann : public EnergyDistributionFunction {
|
class MaxwellBoltzmann : public EnergyDistributionFunction {
|
||||||
public:
|
public:
|
||||||
MaxwellBoltzmann(double temperature_K);
|
MaxwellBoltzmann(double temperature_K);
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
#include "simulation/coordinates.h"
|
#include "simulation/coordinates.h"
|
||||||
#include "simulation/scalar_field.h"
|
#include "simulation/scalar_field.h"
|
||||||
#include "simulation/density_field.h"
|
|
||||||
|
|
||||||
struct Limit {
|
struct Limit {
|
||||||
Limit() : min(0), max(0){};
|
Limit() : min(0), max(0){};
|
||||||
@@ -15,9 +14,6 @@ struct Limit {
|
|||||||
double max;
|
double max;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Might be possible to generalize the distributions (i.e. create parent class
|
|
||||||
// and let the two that are defined now inherit from it)
|
|
||||||
|
|
||||||
class EventPositionDistribution {
|
class EventPositionDistribution {
|
||||||
public:
|
public:
|
||||||
EventPositionDistribution(std::shared_ptr<ScalarField> mother_density,
|
EventPositionDistribution(std::shared_ptr<ScalarField> mother_density,
|
||||||
|
|||||||
@@ -10,8 +10,6 @@
|
|||||||
|
|
||||||
class DriftVelocity;
|
class DriftVelocity;
|
||||||
class VelocityDistribution;
|
class VelocityDistribution;
|
||||||
class DynamicDensityField;
|
|
||||||
class MagneticField;
|
|
||||||
|
|
||||||
namespace particle {
|
namespace particle {
|
||||||
class Particle;
|
class Particle;
|
||||||
@@ -28,9 +26,6 @@ struct InjectorInfo {
|
|||||||
public:
|
public:
|
||||||
std::shared_ptr<species::TrackedSpecie> created_specie;
|
std::shared_ptr<species::TrackedSpecie> created_specie;
|
||||||
std::shared_ptr<VelocityDistribution> creation_velocity_distribution;
|
std::shared_ptr<VelocityDistribution> creation_velocity_distribution;
|
||||||
double weight = 0;
|
|
||||||
int injection_group;
|
|
||||||
int injection_stride;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Injector {
|
class Injector {
|
||||||
@@ -40,17 +35,7 @@ class Injector {
|
|||||||
std::shared_ptr<EventPositionDistribution> position_distribution,
|
std::shared_ptr<EventPositionDistribution> position_distribution,
|
||||||
std::shared_ptr<DriftVelocity> mother_drift_velocity);
|
std::shared_ptr<DriftVelocity> mother_drift_velocity);
|
||||||
|
|
||||||
std::vector<particle::Particle> rollNewParticles(std::mt19937* engine,
|
std::vector<particle::Particle> rollNewParticles(std::mt19937* engine);
|
||||||
const int timestep);
|
|
||||||
|
|
||||||
// physical_number: physical number of particles that are injected in one
|
|
||||||
// timestep
|
|
||||||
// numerical_number: number of numerical beta particles to be injected on
|
|
||||||
// a single process
|
|
||||||
void setWeights(const double physical_number, const int numerical_number);
|
|
||||||
|
|
||||||
void initInjectionTimeDistribution(double delta_t);
|
|
||||||
|
|
||||||
double timePassed() const;
|
double timePassed() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -58,15 +43,12 @@ class Injector {
|
|||||||
const double activity_;
|
const double activity_;
|
||||||
std::shared_ptr<EventPositionDistribution> position_distribution_;
|
std::shared_ptr<EventPositionDistribution> position_distribution_;
|
||||||
std::shared_ptr<DriftVelocity> mother_drift_velocity_;
|
std::shared_ptr<DriftVelocity> mother_drift_velocity_;
|
||||||
std::uniform_real_distribution<double> injection_time_distribution_;
|
|
||||||
|
|
||||||
particle::Particle rollNewParticle(
|
particle::Particle rollNewParticle(
|
||||||
std::mt19937* engine,
|
std::mt19937* engine,
|
||||||
const Coordinate& position,
|
const Coordinate& position,
|
||||||
std::shared_ptr<species::TrackedSpecie> created_specie,
|
std::shared_ptr<species::TrackedSpecie> created_specie,
|
||||||
std::shared_ptr<VelocityDistribution> creation_velocity_distribution,
|
std::shared_ptr<VelocityDistribution> creation_velocity_distribution);
|
||||||
const double time_birth,
|
|
||||||
const double weight);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* INJECTOR_H */
|
#endif /* INJECTOR_H */
|
||||||
|
|||||||
@@ -30,22 +30,15 @@ class Interaction {
|
|||||||
Interaction(std::function<double(double)> cross_section,
|
Interaction(std::function<double(double)> cross_section,
|
||||||
std::shared_ptr<species::Specie> target);
|
std::shared_ptr<species::Specie> target);
|
||||||
|
|
||||||
virtual double microscopicCrossSection(double energy_eV, const Coordinate& position);
|
virtual double microscopicCrossSection(double energy_eV);
|
||||||
virtual double macroscopicCrossSection(particle::Particle& particle);
|
virtual double macroscopicCrossSection(particle::Particle& particle);
|
||||||
|
|
||||||
// return the time the given particle can travel in the laboratory frame
|
|
||||||
// before this specific interaction occurs (also stores the velocity of the
|
|
||||||
// target particle)
|
|
||||||
virtual double drawCollisionTime(particle::Particle& particle,
|
|
||||||
RandomNumbers* generator);
|
|
||||||
|
|
||||||
virtual InteractionOutput performInteraction(particle::Particle& particle,
|
virtual InteractionOutput performInteraction(particle::Particle& particle,
|
||||||
RandomNumbers* generator) = 0;
|
RandomNumbers* generator) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::function<double(double)> cross_section_;
|
std::function<double(double)> cross_section_;
|
||||||
std::shared_ptr<species::Specie> target_;
|
std::shared_ptr<species::Specie> target_;
|
||||||
CartesianVector target_velocity_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}; // namespace interaction
|
}; // namespace interaction
|
||||||
|
|||||||
@@ -38,11 +38,7 @@ inline int json_int(json_t* object, int default_value = 0) {
|
|||||||
|
|
||||||
inline std::string json_string(json_t* object, std::string default_value = "") {
|
inline std::string json_string(json_t* object, std::string default_value = "") {
|
||||||
if (object) {
|
if (object) {
|
||||||
if (json_string_value(object)) {
|
return std::string(json_string_value(object));
|
||||||
return std::string(json_string_value(object));
|
|
||||||
} else {
|
|
||||||
return default_value;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return default_value;
|
return default_value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,10 +20,6 @@ blitz::TinyVector<double, 3> rotateVector(const blitz::TinyVector<double, 3>& v,
|
|||||||
double theta,
|
double theta,
|
||||||
double phi);
|
double phi);
|
||||||
|
|
||||||
blitz::TinyVector<double, 3> rotateVector2(const blitz::TinyVector<double, 3>& v,
|
|
||||||
double theta,
|
|
||||||
double phi);
|
|
||||||
|
|
||||||
blitz::TinyVector<double, 3> rotateVelocityInCenterOfMassFrame(
|
blitz::TinyVector<double, 3> rotateVelocityInCenterOfMassFrame(
|
||||||
const blitz::TinyVector<double, 3>& velocity_1,
|
const blitz::TinyVector<double, 3>& velocity_1,
|
||||||
const blitz::TinyVector<double, 3>& velocity_2,
|
const blitz::TinyVector<double, 3>& velocity_2,
|
||||||
@@ -69,9 +65,6 @@ blitz::TinyVector<double, 3> velocityVector(
|
|||||||
const blitz::TinyVector<double, 3>& random_unit_vector,
|
const blitz::TinyVector<double, 3>& random_unit_vector,
|
||||||
double mass_kg);
|
double mass_kg);
|
||||||
|
|
||||||
double cosPitchAngle(blitz::TinyVector<double, 3> vector1,
|
|
||||||
blitz::TinyVector<double, 3> vector2);
|
|
||||||
|
|
||||||
}; // namespace kinematic
|
}; // namespace kinematic
|
||||||
|
|
||||||
#endif /* KINEMATIC_H */
|
#endif /* KINEMATIC_H */
|
||||||
|
|||||||
@@ -3,9 +3,8 @@
|
|||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "simulation/particle.h"
|
#include "simulation/coordinates.h"
|
||||||
|
|
||||||
// to count numerical particle deletions
|
|
||||||
enum class DeletionType {
|
enum class DeletionType {
|
||||||
wall,
|
wall,
|
||||||
recombination,
|
recombination,
|
||||||
@@ -14,37 +13,20 @@ enum class DeletionType {
|
|||||||
cluster_formation
|
cluster_formation
|
||||||
};
|
};
|
||||||
|
|
||||||
// to count physical particle deletion
|
|
||||||
enum class PhysicalDeletionType {
|
|
||||||
wall
|
|
||||||
};
|
|
||||||
class Coordinate;
|
|
||||||
|
|
||||||
class DeletionLogger {
|
class DeletionLogger {
|
||||||
public:
|
public:
|
||||||
DeletionLogger(std::vector<DeletionType> used_types,
|
DeletionLogger(std::vector<DeletionType> used_types);
|
||||||
std::vector<PhysicalDeletionType> used_phys_types);
|
|
||||||
// why a coordinate as a parameter -> not used in implementation
|
// why a coordinate as a parameter -> not used in implementation
|
||||||
virtual void logDeletion(const Coordinate& coordinate, DeletionType type);
|
virtual void logDeletion(const Coordinate& coordinate, DeletionType type);
|
||||||
virtual void logDeletion(const particle::Particle& particle,
|
|
||||||
PhysicalDeletionType type);
|
|
||||||
|
|
||||||
std::map<DeletionType, long int> numDeletions() const;
|
std::map<DeletionType, long int> numDeletions() const;
|
||||||
std::map<PhysicalDeletionType, double> numPhysDeletions() const;
|
|
||||||
void numDeletions(long int new_value, DeletionType type);
|
void numDeletions(long int new_value, DeletionType type);
|
||||||
long int numDeletions(DeletionType type) const;
|
long int numDeletions(DeletionType type) const;
|
||||||
|
|
||||||
void resetDeletionLogger();
|
|
||||||
|
|
||||||
friend class CpuSynchronizer;
|
friend class CpuSynchronizer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<DeletionType, long int> num_deletions;
|
std::map<DeletionType, long int> num_deletions;
|
||||||
// std::map<DeletionType, long int> sync_num_deletions;
|
|
||||||
|
|
||||||
std::map<PhysicalDeletionType, double> num_phys_deletions;
|
|
||||||
// std::map<PhysicalDeletionType, double> sync_num_phys_deletions;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* LOGGER_H */
|
#endif /* LOGGER_H */
|
||||||
|
|||||||
@@ -4,16 +4,10 @@
|
|||||||
#include "simulation/electromagnetic_field.h"
|
#include "simulation/electromagnetic_field.h"
|
||||||
#include "simulation/particle.h"
|
#include "simulation/particle.h"
|
||||||
|
|
||||||
class CylinderCoordinate;
|
|
||||||
/*
|
|
||||||
change the mfp_m variable to a time_s variable!
|
|
||||||
*/
|
|
||||||
|
|
||||||
class Mover {
|
class Mover {
|
||||||
public:
|
public:
|
||||||
// return the last position, with which the particle has been checked to be alive with
|
virtual void move(particle::Particle* particle,
|
||||||
virtual CylinderCoordinate move(particle::Particle* particle,
|
double mfp_m,
|
||||||
double collision_time_s,
|
|
||||||
ElectricField* electric_field,
|
ElectricField* electric_field,
|
||||||
MagneticField* magnetic_field,
|
MagneticField* magnetic_field,
|
||||||
GravityField* gravity_field) = 0;
|
GravityField* gravity_field) = 0;
|
||||||
@@ -23,8 +17,8 @@ class BorisMover : public Mover {
|
|||||||
public:
|
public:
|
||||||
BorisMover(double maximal_time_step_s);
|
BorisMover(double maximal_time_step_s);
|
||||||
|
|
||||||
CylinderCoordinate move(particle::Particle* particle,
|
void move(particle::Particle* particle,
|
||||||
double collision_time_s,
|
double mfp_m,
|
||||||
ElectricField* electric_field,
|
ElectricField* electric_field,
|
||||||
MagneticField* magnetic_field,
|
MagneticField* magnetic_field,
|
||||||
GravityField* gravity_field);
|
GravityField* gravity_field);
|
||||||
@@ -35,17 +29,15 @@ class BorisMover : public Mover {
|
|||||||
void movementStep(particle::Particle* particle,
|
void movementStep(particle::Particle* particle,
|
||||||
const blitz::TinyVector<double, 3>& electric_field,
|
const blitz::TinyVector<double, 3>& electric_field,
|
||||||
const blitz::TinyVector<double, 3>& magnetic_field,
|
const blitz::TinyVector<double, 3>& magnetic_field,
|
||||||
const blitz::TinyVector<double, 3>& gravity_field,
|
double& moved_distance) const;
|
||||||
// double& moved_distance,
|
|
||||||
double timestep) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class DriftMover : public Mover {
|
class DriftMover : public Mover {
|
||||||
public:
|
public:
|
||||||
DriftMover(double maximal_distance);
|
DriftMover(double maximal_distance);
|
||||||
|
|
||||||
CylinderCoordinate move(particle::Particle* particle,
|
void move(particle::Particle* particle,
|
||||||
double collision_time_s,
|
double mfp_m,
|
||||||
ElectricField* electric_field,
|
ElectricField* electric_field,
|
||||||
MagneticField* magnetic_field,
|
MagneticField* magnetic_field,
|
||||||
GravityField* gravity_field);
|
GravityField* gravity_field);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#ifndef MPI_COMMUNICATION_H
|
#ifndef MPI_COMMUNICATION_H
|
||||||
#define MPI_COMMUNICATION_H
|
#define MPI_COMMUNICATION_H
|
||||||
|
|
||||||
#include "mpi.h"
|
|
||||||
class MpiCommunication {
|
class MpiCommunication {
|
||||||
public:
|
public:
|
||||||
static int mpi_rank;
|
static int mpi_rank;
|
||||||
@@ -11,9 +10,6 @@ class MpiCommunication {
|
|||||||
static int mpiSize();
|
static int mpiSize();
|
||||||
|
|
||||||
static void init(int argc, char* argv[]);
|
static void init(int argc, char* argv[]);
|
||||||
|
|
||||||
static void create_mpi_info(MPI_Info* info);
|
|
||||||
|
|
||||||
static void finalize();
|
static void finalize();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -5,64 +5,19 @@
|
|||||||
#include "simulation/coordinates.h"
|
#include "simulation/coordinates.h"
|
||||||
#include "simulation/species.h"
|
#include "simulation/species.h"
|
||||||
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
class MpiParticleReader;
|
|
||||||
|
|
||||||
namespace particle {
|
namespace particle {
|
||||||
|
|
||||||
class SerializedParticle {
|
|
||||||
public:
|
|
||||||
SerializedParticle(double weight,
|
|
||||||
blitz::TinyVector<double, 3> cart_pos,
|
|
||||||
blitz::TinyVector<double, 3> cart_vel,
|
|
||||||
std::string spec_name,
|
|
||||||
int next_interaction_index,
|
|
||||||
double time_until_interaction);
|
|
||||||
SerializedParticle() {};
|
|
||||||
|
|
||||||
double weight();
|
|
||||||
blitz::TinyVector<double, 3> cartesianPosition();
|
|
||||||
blitz::TinyVector<double, 3> cartesianVelocity();
|
|
||||||
std::string specieName();
|
|
||||||
double timeUntilCollision();
|
|
||||||
int indexNextInteraction();
|
|
||||||
|
|
||||||
private:
|
|
||||||
blitz::TinyVector<double, 3> cartesian_position_;
|
|
||||||
blitz::TinyVector<double, 3> cartesian_velocity_;
|
|
||||||
// has to include null character, s.t. the transformation back
|
|
||||||
// to a string becomes trivial. This requires the actual string
|
|
||||||
// to be 16-1=15 characters long at most
|
|
||||||
// (it can be shorter due to the null character)
|
|
||||||
// Example: "e-" -> ['e', '-', '\0', ...] gets correctly transformed back
|
|
||||||
// into "e-"
|
|
||||||
std::array<char, 16> specie_name_;
|
|
||||||
double weight_;
|
|
||||||
|
|
||||||
int idx_nxt_interaction_;
|
|
||||||
double time_until_interaction_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Particle {
|
class Particle {
|
||||||
public:
|
public:
|
||||||
|
// Particle(std::shared_ptr<species::TrackedSpecie> specie,
|
||||||
|
// Coordinate* position,
|
||||||
|
// Vector* velocity);
|
||||||
Particle(std::shared_ptr<species::TrackedSpecie> specie,
|
Particle(std::shared_ptr<species::TrackedSpecie> specie,
|
||||||
const Coordinate& position,
|
const Coordinate& position,
|
||||||
const Vector& velocity,
|
const Vector& velocity);
|
||||||
const double time_birth,
|
|
||||||
const double weight);
|
|
||||||
|
|
||||||
Particle(std::shared_ptr<species::TrackedSpecie> specie,
|
|
||||||
const Coordinate& position,
|
|
||||||
const Vector& velocity,
|
|
||||||
const double weight);
|
|
||||||
|
|
||||||
Particle(particle::SerializedParticle sparticle, std::map<std::string,
|
|
||||||
std::shared_ptr<species::TrackedSpecie>>& tracked_species);
|
|
||||||
|
|
||||||
void position(const Coordinate& new_position);
|
void position(const Coordinate& new_position);
|
||||||
CartesianCoordinate cartesianPosition() const;
|
CartesianCoordinate position() const;
|
||||||
CylinderCoordinate cylinderPosition() const;
|
|
||||||
|
|
||||||
void velocity(const CartesianVector& new_velocity);
|
void velocity(const CartesianVector& new_velocity);
|
||||||
CartesianVector velocity() const;
|
CartesianVector velocity() const;
|
||||||
@@ -87,51 +42,18 @@ class Particle {
|
|||||||
void increaseTimeAlive(double time_s);
|
void increaseTimeAlive(double time_s);
|
||||||
double timeAlive() const;
|
double timeAlive() const;
|
||||||
|
|
||||||
long int ID() const;
|
void increaseTimeInBin(double time_s);
|
||||||
|
void resetTimeInBin();
|
||||||
double weight() const;
|
double timeInBin() const;
|
||||||
|
|
||||||
void indexNextInteration(const int index) { index_next_interaction_ = index; };
|
|
||||||
int indexNextInteraction() { return index_next_interaction_; };
|
|
||||||
void invalidateNextInteraction() { index_next_interaction_ = -1; };
|
|
||||||
bool isNextInteractionValid() { return index_next_interaction_ >= 0; };
|
|
||||||
|
|
||||||
void timeUntilCollision(const double time_until_collision);
|
|
||||||
double timeUntilCollision() const;
|
|
||||||
void reduceTimeUntilCollision(const double delta);
|
|
||||||
|
|
||||||
void deposited(bool truthValue=true);
|
|
||||||
bool wasDeposited();
|
|
||||||
|
|
||||||
void setLocalFields(const blitz::TinyVector<double,3>& E,
|
|
||||||
const blitz::TinyVector<double,3>& B);
|
|
||||||
blitz::TinyVector<double, 3> getLocalE() const;
|
|
||||||
blitz::TinyVector<double, 3> getLocalB() const;
|
|
||||||
bool areLocalFieldsSet() const;
|
|
||||||
|
|
||||||
// note: particle id is not being stored!
|
|
||||||
particle::SerializedParticle serialize();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double weight_;
|
|
||||||
|
|
||||||
CartesianVector velocity_;
|
CartesianVector velocity_;
|
||||||
CartesianCoordinate position_cart_;
|
CartesianCoordinate position_;
|
||||||
CylinderCoordinate position_cyl_;
|
|
||||||
|
|
||||||
blitz::TinyVector<double, 3> local_E_cart_ = 0.;
|
|
||||||
blitz::TinyVector<double, 3> local_B_cart_ = 0.;
|
|
||||||
|
|
||||||
double time_alive_s_;
|
double time_alive_s_;
|
||||||
// double time_in_bin_s_;
|
double time_in_bin_s_;
|
||||||
long int interaction_counter_;
|
long int interaction_counter_;
|
||||||
|
|
||||||
bool deposited_ = false;
|
|
||||||
bool set_local_fields_ = false;
|
|
||||||
// index of the interaction with the sortest distance (-1 if that's none of them)
|
|
||||||
int index_next_interaction_ = -1;
|
|
||||||
double time_until_collision_;
|
|
||||||
|
|
||||||
std::shared_ptr<species::TrackedSpecie> specie_;
|
std::shared_ptr<species::TrackedSpecie> specie_;
|
||||||
long int id_;
|
long int id_;
|
||||||
|
|
||||||
|
|||||||
@@ -60,19 +60,21 @@ class CylinderBinning {
|
|||||||
public:
|
public:
|
||||||
CylinderBinning(int num_bins_radial,
|
CylinderBinning(int num_bins_radial,
|
||||||
double radius,
|
double radius,
|
||||||
|
int num_bins_azimuthal,
|
||||||
int num_bins_longitudinal,
|
int num_bins_longitudinal,
|
||||||
double height);
|
double height);
|
||||||
|
|
||||||
blitz::TinyVector<int, 2> bin(
|
blitz::TinyVector<int, 3> bin(
|
||||||
const blitz::TinyVector<double, 3>& cylinder_position) const;
|
const blitz::TinyVector<double, 3>& cylinder_position) const;
|
||||||
blitz::TinyVector<double, 2> stepsize() const;
|
blitz::TinyVector<double, 3> stepsize() const;
|
||||||
|
|
||||||
blitz::TinyVector<int, 2> numBins() const;
|
blitz::TinyVector<int, 3> numBins() const;
|
||||||
blitz::TinyVector<int, 2> numBinsIncludingOverUnderflow() const;
|
blitz::TinyVector<int, 3> numBinsIncludingOverUnderflow() const;
|
||||||
blitz::TinyVector<int, 2> binIndexMin() const;
|
blitz::TinyVector<int, 3> binIndexMin() const;
|
||||||
blitz::TinyVector<int, 2> binIndexMax() const;
|
blitz::TinyVector<int, 3> binIndexMax() const;
|
||||||
|
|
||||||
const LowerBoundBinningWithOverflow radial_binning;
|
const LowerBoundBinningWithOverflow radial_binning;
|
||||||
|
const LowerAndUpperBoundBinning azimuth_binning;
|
||||||
const BinningWithOverAndUnderflow longitudinal_binning;
|
const BinningWithOverAndUnderflow longitudinal_binning;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,6 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
||||||
#include "blitz/array.h"
|
|
||||||
|
|
||||||
class RandomNumbers {
|
class RandomNumbers {
|
||||||
public:
|
public:
|
||||||
RandomNumbers(int seed);
|
RandomNumbers(int seed);
|
||||||
@@ -21,31 +19,4 @@ class RandomNumbers {
|
|||||||
std::uniform_real_distribution<double> real_distribution_;
|
std::uniform_real_distribution<double> real_distribution_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// class to handle a random walk through a density field, where every
|
|
||||||
// bin is visited exactly once
|
|
||||||
class RandomIndex {
|
|
||||||
public:
|
|
||||||
// num_bins: contains the number of bins of all dimensions of a
|
|
||||||
// density binning (order: radial, azimuthal, longitudinal,
|
|
||||||
// pitch angle, energy)
|
|
||||||
RandomIndex(blitz::TinyVector<int, 5> num_bins);
|
|
||||||
|
|
||||||
// get the next index
|
|
||||||
blitz::TinyVector<int, 5> index();
|
|
||||||
|
|
||||||
// check if all bins have been visited
|
|
||||||
bool visited_all();
|
|
||||||
|
|
||||||
// create a new random order and reset the check if all bins have been visited
|
|
||||||
void reshuffle(std::mt19937* engine);
|
|
||||||
|
|
||||||
private:
|
|
||||||
const blitz::TinyVector<int, 5> num_bins_;
|
|
||||||
|
|
||||||
std::vector<size_t> one_dimensional_indices_;
|
|
||||||
|
|
||||||
size_t total_bin_number_;
|
|
||||||
size_t current_index_in_vector_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* RANDOM_NUMBERS_H */
|
#endif /* RANDOM_NUMBERS_H */
|
||||||
|
|||||||
@@ -20,16 +20,6 @@ class ReflectorDPS : public Reflector {
|
|||||||
const double z_position_dps_;
|
const double z_position_dps_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class LongitudinalReflector : public Reflector {
|
|
||||||
public:
|
|
||||||
LongitudinalReflector(double height);
|
|
||||||
bool needsReflectionBackToDomain(const particle::Particle* particle) const;
|
|
||||||
void reflectBackToDomain(particle::Particle* particle) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
const double height_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class NoReflector : public Reflector {
|
class NoReflector : public Reflector {
|
||||||
bool needsReflectionBackToDomain(const particle::Particle* particle) const;
|
bool needsReflectionBackToDomain(const particle::Particle* particle) const;
|
||||||
void reflectBackToDomain(particle::Particle* particle) const;
|
void reflectBackToDomain(particle::Particle* particle) const;
|
||||||
|
|||||||
@@ -35,24 +35,19 @@ class Simulation {
|
|||||||
void start();
|
void start();
|
||||||
void finalize();
|
void finalize();
|
||||||
void processEvents(int events);
|
void processEvents(int events);
|
||||||
|
void processUntilTermination(particle::Particle& particle,
|
||||||
void processDensityEvents();
|
std::vector<particle::Particle>& particle_queue);
|
||||||
void processUntilTermination(particle::Particle& particle);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::vector<particle::Particle> determineInjectedParticles(
|
||||||
|
RandomNumbers* random);
|
||||||
|
|
||||||
// draw the individual collision times of the possible interactions and return the
|
double meanFreePath(particle::Particle& particle, RandomNumbers* random);
|
||||||
// minimum of them. Also sets the "nextInteractionIndex" in the particle to the
|
|
||||||
// interaction of the chosen time.
|
|
||||||
void collisionTime(particle::Particle& particle, RandomNumbers* random);
|
|
||||||
interaction::InteractionOutput interact(particle::Particle& particle,
|
|
||||||
RandomNumbers* random);
|
|
||||||
|
|
||||||
interaction::InteractionOutput interact(particle::Particle& particle,
|
interaction::InteractionOutput interact(particle::Particle& particle,
|
||||||
RandomNumbers* random,
|
RandomNumbers* random);
|
||||||
std::vector<double>& macroscopic_cross_sections_m);
|
|
||||||
|
|
||||||
blitz::Array<double,2> chargedensity();
|
blitz::Array<double,3> chargedensity();
|
||||||
|
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>
|
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>
|
||||||
tracked_species_;
|
tracked_species_;
|
||||||
@@ -74,15 +69,6 @@ class Simulation {
|
|||||||
|
|
||||||
std::shared_ptr<SimulationOutput> output_;
|
std::shared_ptr<SimulationOutput> output_;
|
||||||
std::shared_ptr<CpuSynchronizer> cpu_synchronizer_;
|
std::shared_ptr<CpuSynchronizer> cpu_synchronizer_;
|
||||||
|
|
||||||
std::vector<particle::Particle> queue_;
|
|
||||||
std::vector<particle::SerializedParticle> storage_queue_[2];
|
|
||||||
|
|
||||||
int active_storage = 0;
|
|
||||||
int inactive_storage = 1;
|
|
||||||
|
|
||||||
int timestep = 0;
|
|
||||||
int injectionGroupOffset = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SIMULATION_H */
|
#endif /* SIMULATION_H */
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#include "simulation/parameter.h"
|
#include "simulation/parameter.h"
|
||||||
|
|
||||||
class RandomIndex;
|
|
||||||
class Mover;
|
class Mover;
|
||||||
class Terminator;
|
class Terminator;
|
||||||
class Reflector;
|
class Reflector;
|
||||||
@@ -19,8 +18,6 @@ class DeletionLogger;
|
|||||||
class CurrentCollector;
|
class CurrentCollector;
|
||||||
class VelocityDistribution;
|
class VelocityDistribution;
|
||||||
class DriftVelocity;
|
class DriftVelocity;
|
||||||
class PositionDistributionFromDensity;
|
|
||||||
class VelocityDistributionFromDensityField;
|
|
||||||
|
|
||||||
namespace interaction {
|
namespace interaction {
|
||||||
class Interaction;
|
class Interaction;
|
||||||
@@ -43,7 +40,7 @@ class Specie {
|
|||||||
std::string name() const;
|
std::string name() const;
|
||||||
|
|
||||||
virtual DensityField* densityField() = 0;
|
virtual DensityField* densityField() = 0;
|
||||||
virtual VelocityDistribution* velocityDistribution() = 0;
|
virtual VelocityDistribution* velocityDistibution() = 0;
|
||||||
virtual DriftVelocity* driftVelocity() = 0;
|
virtual DriftVelocity* driftVelocity() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -64,13 +61,15 @@ class TrackedSpecie : public Specie {
|
|||||||
std::shared_ptr<Reflector> reflector,
|
std::shared_ptr<Reflector> reflector,
|
||||||
std::shared_ptr<DynamicDensityField> density_field,
|
std::shared_ptr<DynamicDensityField> density_field,
|
||||||
std::shared_ptr<VelocityDistribution> velocity_distribution,
|
std::shared_ptr<VelocityDistribution> velocity_distribution,
|
||||||
std::shared_ptr<DriftVelocity> drift_velocity);
|
std::shared_ptr<DriftVelocity> drift_velocity,
|
||||||
|
std::shared_ptr<DynamicDensityField> last_sync_density_field);
|
||||||
|
|
||||||
DensityField* densityField();
|
DensityField* densityField();
|
||||||
VelocityDistribution* velocityDistribution();
|
VelocityDistribution* velocityDistibution();
|
||||||
DriftVelocity* driftVelocity();
|
DriftVelocity* driftVelocity();
|
||||||
|
|
||||||
DynamicDensityField* dynamicDensityField();
|
DynamicDensityField* dynamicDensityField();
|
||||||
|
DynamicDensityField* lastSyncDensityField();
|
||||||
Mover* mover();
|
Mover* mover();
|
||||||
Terminator* terminator();
|
Terminator* terminator();
|
||||||
Reflector* reflector();
|
Reflector* reflector();
|
||||||
@@ -78,17 +77,22 @@ class TrackedSpecie : public Specie {
|
|||||||
DeletionLogger* deletionLogger();
|
DeletionLogger* deletionLogger();
|
||||||
void deletionLogger(std::shared_ptr<DeletionLogger> new_logger);
|
void deletionLogger(std::shared_ptr<DeletionLogger> new_logger);
|
||||||
|
|
||||||
|
DeletionLogger* lastSyncDeletionLogger();
|
||||||
|
void lastSyncDeletionLogger(std::shared_ptr<DeletionLogger> new_logger);
|
||||||
|
|
||||||
CurrentCollector* currentCollector();
|
CurrentCollector* currentCollector();
|
||||||
void currentCollector(std::shared_ptr<CurrentCollector> new_collector);
|
void currentCollector(std::shared_ptr<CurrentCollector> new_collector);
|
||||||
|
|
||||||
|
CurrentCollector* lastSyncCurrentCollector();
|
||||||
|
void lastSyncCurrentCollector(
|
||||||
|
std::shared_ptr<CurrentCollector> new_collector);
|
||||||
|
|
||||||
std::vector<std::shared_ptr<interaction::Interaction>> interactions();
|
std::vector<std::shared_ptr<interaction::Interaction>> interactions();
|
||||||
void addInteraction(std::shared_ptr<interaction::Interaction> interaction);
|
void addInteraction(std::shared_ptr<interaction::Interaction> interaction);
|
||||||
|
|
||||||
// getter for the raw pointer to the VelocityDistributionFromDensityField object
|
|
||||||
VelocityDistributionFromDensityField* velocityDistributionFromDensityField();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<DynamicDensityField> density_field_;
|
std::shared_ptr<DynamicDensityField> density_field_;
|
||||||
|
std::shared_ptr<VelocityDistribution> velocity_distribution_;
|
||||||
std::shared_ptr<DriftVelocity> drift_velocity_;
|
std::shared_ptr<DriftVelocity> drift_velocity_;
|
||||||
|
|
||||||
std::shared_ptr<Mover> mover_;
|
std::shared_ptr<Mover> mover_;
|
||||||
@@ -99,9 +103,12 @@ class TrackedSpecie : public Specie {
|
|||||||
std::shared_ptr<CurrentCollector> current_collector_;
|
std::shared_ptr<CurrentCollector> current_collector_;
|
||||||
std::vector<std::shared_ptr<interaction::Interaction>> interactions_;
|
std::vector<std::shared_ptr<interaction::Interaction>> interactions_;
|
||||||
|
|
||||||
// necessary for interactions between TrackedSpecies
|
// fields to store the date of the last synchronization
|
||||||
std::shared_ptr<VelocityDistributionFromDensityField>
|
// (after a synchronization the last_sync field and the non-last_sync field
|
||||||
velocity_distribution_from_density_;
|
// contain the same data)
|
||||||
|
std::shared_ptr<DynamicDensityField> last_sync_density_field_;
|
||||||
|
std::shared_ptr<DeletionLogger> last_sync_deletion_logger_;
|
||||||
|
std::shared_ptr<CurrentCollector> last_sync_current_collector_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BackgroundSpecie : public Specie {
|
class BackgroundSpecie : public Specie {
|
||||||
@@ -115,7 +122,7 @@ class BackgroundSpecie : public Specie {
|
|||||||
std::shared_ptr<DriftVelocity> drift_velocity);
|
std::shared_ptr<DriftVelocity> drift_velocity);
|
||||||
|
|
||||||
DensityField* densityField();
|
DensityField* densityField();
|
||||||
VelocityDistribution* velocityDistribution();
|
VelocityDistribution* velocityDistibution();
|
||||||
DriftVelocity* driftVelocity();
|
DriftVelocity* driftVelocity();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -4,46 +4,23 @@
|
|||||||
#include "simulation/particle.h"
|
#include "simulation/particle.h"
|
||||||
|
|
||||||
class Geometry;
|
class Geometry;
|
||||||
class DynamicDensityField;
|
|
||||||
class Coordinate;
|
|
||||||
class Terminator {
|
class Terminator {
|
||||||
public:
|
public:
|
||||||
Terminator(long int max_interactions,
|
Terminator(long int max_interactions,
|
||||||
double max_time_alive,
|
double max_time_alive,
|
||||||
std::shared_ptr<Geometry> geometry);
|
std::shared_ptr<Geometry> geometry);
|
||||||
Terminator();
|
|
||||||
|
|
||||||
virtual bool isAlive(const particle::Particle* particle) const;
|
bool isAlive(const particle::Particle* particle) const;
|
||||||
virtual bool isAlive(const particle::Particle* particle,
|
bool leftSimulationDomain(const particle::Particle* particle) const;
|
||||||
const Coordinate& old_pos) const;
|
bool reachedMaxInteractions(const particle::Particle* particle) const;
|
||||||
virtual bool leftSimulationDomain(const particle::Particle* particle) const;
|
bool reachedMaxTimeAlive(const particle::Particle* particle) const;
|
||||||
virtual bool leftSimulationDomain(const particle::Particle* particle,
|
double maxTimeAlive() const;
|
||||||
const Coordinate& old_position) const;
|
|
||||||
virtual bool reachedMaxInteractions(const particle::Particle* particle) const;
|
|
||||||
virtual bool reachedMaxTimeAlive(const particle::Particle* particle) const;
|
|
||||||
virtual double maxTimeAlive() const;
|
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
const long int max_interactions_;
|
const long int max_interactions_;
|
||||||
const double max_time_alive_;
|
const double max_time_alive_;
|
||||||
std::shared_ptr<Geometry> geometry_;
|
std::shared_ptr<Geometry> geometry_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TerminatorWithPlates : public Terminator {
|
|
||||||
public:
|
|
||||||
TerminatorWithPlates(long int max_interactions, double max_time_alive,
|
|
||||||
std::shared_ptr<Geometry> geometry,
|
|
||||||
double zpos1, double zpos2, double innerRadius1,
|
|
||||||
double innerRadius2, double outerRadius1,
|
|
||||||
double outerRadius2);
|
|
||||||
|
|
||||||
virtual bool leftSimulationDomain(const particle::Particle* particle) const;
|
|
||||||
virtual bool leftSimulationDomain(const particle::Particle* particle,
|
|
||||||
const Coordinate& old_position) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
const double zpos1_, innerRadius1_, outerRadius1_;
|
|
||||||
const double zpos2_, innerRadius2_, outerRadius2_;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* TERMINATOR_H */
|
#endif /* TERMINATOR_H */
|
||||||
|
|||||||
@@ -10,13 +10,9 @@ class Timer {
|
|||||||
double time() const;
|
double time() const;
|
||||||
void increaseTimestep(double time_s);
|
void increaseTimestep(double time_s);
|
||||||
void setTime(double time_s);
|
void setTime(double time_s);
|
||||||
void resetTime();
|
|
||||||
void setDeltaT(double deltaT);
|
|
||||||
double getDeltaT() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double current_time_s_;
|
double current_time_s_;
|
||||||
double delta_t_time_resolution_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* TIMER_H */
|
#endif /* TIMER_H */
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
std::function<double(double)> tritiumDecayEnergySpectrum(double prefactor);
|
std::function<double(double)> tritiumDecayEnergySpectrum(double prefactor);
|
||||||
std::function<double(double)> tritiumDecayEnergySpectrumIon(double endpoint);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* TRITIUM_SPECTRUM_H */
|
#endif /* TRITIUM_SPECTRUM_H */
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ class VectorField {
|
|||||||
|
|
||||||
class VectorFieldFromArray : public VectorField {
|
class VectorFieldFromArray : public VectorField {
|
||||||
public:
|
public:
|
||||||
VectorFieldFromArray(const blitz::Array<double, 2>& radial_component,
|
VectorFieldFromArray(const blitz::Array<double, 3>& radial_component,
|
||||||
const blitz::Array<double, 2>& azimuthal_component,
|
const blitz::Array<double, 3>& azimuthal_component,
|
||||||
const blitz::Array<double, 2>& longitudial_component,
|
const blitz::Array<double, 3>& longitudial_component,
|
||||||
double radius,
|
double radius,
|
||||||
double length);
|
double length);
|
||||||
|
|
||||||
@@ -24,12 +24,12 @@ class VectorFieldFromArray : public VectorField {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// todo: make sure we use fast axis on z to reduce access time
|
// todo: make sure we use fast axis on z to reduce access time
|
||||||
const blitz::Array<double, 2> Fr_;
|
const blitz::Array<double, 3> Fr_;
|
||||||
const blitz::Array<double, 2> Fphi_;
|
const blitz::Array<double, 3> Fphi_;
|
||||||
const blitz::Array<double, 2> Fz_;
|
const blitz::Array<double, 3> Fz_;
|
||||||
|
|
||||||
CylinderBinning binning_;
|
CylinderBinning binning_;
|
||||||
CylinderVector value(const blitz::TinyVector<int, 2>& bin) const;
|
CylinderVector value(const blitz::TinyVector<int, 3>& bin) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class VectorFieldConstant : public VectorField {
|
class VectorFieldConstant : public VectorField {
|
||||||
|
|||||||
@@ -25,50 +25,22 @@ class VelocityDistributionFromFunction : public VelocityDistribution {
|
|||||||
std::shared_ptr<VelocityDistributionFunction> fv_;
|
std::shared_ptr<VelocityDistributionFunction> fv_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// only applicable to TrackedSpecies (i.e. only for DynamicDensityFields)
|
/*
|
||||||
// other density don't have any information about the velocity direction
|
|
||||||
class DynamicDensityField;
|
todo: implement this for direct interactions of simulated particles
|
||||||
class MagneticField;
|
|
||||||
|
class DensityField;
|
||||||
|
|
||||||
// Class to draw a velocity from the pitch angle resolved density
|
|
||||||
class VelocityDistributionFromDensityField : public VelocityDistribution {
|
class VelocityDistributionFromDensityField : public VelocityDistribution {
|
||||||
public:
|
public:
|
||||||
// Constructor: takes shared ptr to the DynamicDensityField object from which
|
VelocityDistributionFromDensityField(
|
||||||
// should be drawn and the mass of the species to which the density
|
std::shared_ptr<DensityField> density_field);
|
||||||
// field belongs
|
CartesianVector driftVelocity_ms(const CylinderVector& position);
|
||||||
VelocityDistributionFromDensityField(
|
CartesianVector rollVelocity_ms(
|
||||||
std::shared_ptr<DynamicDensityField> density_field, double mass_kg);
|
const CylinderVector& position, std::mt19937* engine);
|
||||||
|
|
||||||
// stub: can be implemented to return the drift velocity of the particles
|
|
||||||
// at the CylinderVector position of the density field
|
|
||||||
CartesianVector driftVelocity_ms(const CylinderVector& position);
|
|
||||||
|
|
||||||
// returns a velocity vector drawn from the energy and pitch angle distributions
|
|
||||||
// since no magnetic field is given use e_z as the direction wrt the definition
|
|
||||||
// of the pitch angle
|
|
||||||
CartesianVector rollVelocity(const Coordinate& position, std::mt19937* engine);
|
|
||||||
|
|
||||||
// returns a velocity vector drawn from the energy and pitch angle distributions
|
|
||||||
// use the given magnetic field at the provided position to determine the
|
|
||||||
// direction of velocity from the pitch angle
|
|
||||||
// the direction of the perpendicular part of the velocity vector is drawn isotropically
|
|
||||||
CartesianVector rollVelocity(const Coordinate& position, std::mt19937* engine,
|
|
||||||
std::shared_ptr<MagneticField> magnetic_field);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// mass of the species of which the density field is a part of
|
std::shared_ptr<DensityField> density_field_;
|
||||||
const double mass_kg_;
|
|
||||||
|
|
||||||
std::shared_ptr<DynamicDensityField> density_field_;
|
|
||||||
|
|
||||||
// blitz::Array<double, 1> energy_values;
|
|
||||||
// blitz::Array<double, 1> mu_values;
|
|
||||||
|
|
||||||
std::vector<double> energyBinBorders_;
|
|
||||||
std::vector<double> pitchAngleBinBorders_;
|
|
||||||
|
|
||||||
std::uniform_real_distribution<double> theta_distribution_;
|
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
#endif /* VELOCITY_DISTRIBUTION_H */
|
#endif /* VELOCITY_DISTRIBUTION_H */
|
||||||
|
|||||||
@@ -35,8 +35,6 @@ LIBS =#-static
|
|||||||
|
|
||||||
CXXFLAGS += -DHOMEBASE=$(HOMEBASE)
|
CXXFLAGS += -DHOMEBASE=$(HOMEBASE)
|
||||||
|
|
||||||
#CXXFLAGS += -Ddebug_timedist
|
|
||||||
|
|
||||||
# Blitz
|
# Blitz
|
||||||
CXXFLAGS += $(BLITZ_INCLUDES)
|
CXXFLAGS += $(BLITZ_INCLUDES)
|
||||||
LIBS += $(BLITZ_LIBS)
|
LIBS += $(BLITZ_LIBS)
|
||||||
@@ -49,18 +47,12 @@ LIBS += $(HDF5P_LIBRARIES)
|
|||||||
CXXFLAGS += $(JANSSON_INCLUDES)
|
CXXFLAGS += $(JANSSON_INCLUDES)
|
||||||
LIBS += $(JANSSON_LIBRARIES)
|
LIBS += $(JANSSON_LIBRARIES)
|
||||||
|
|
||||||
|
|
||||||
CXXFLAGS += -g
|
|
||||||
ifeq ($(DO_DEBUGGING),true)
|
ifeq ($(DO_DEBUGGING),true)
|
||||||
CXXFLAGS += -ftemplate-depth-30 -DBZ_DEBUG
|
CXXFLAGS += -ftemplate-depth-30 -g -DBZ_DEBUG
|
||||||
CXXFLAGS += -Ddebug
|
CXXFLAGS += -Ddebug
|
||||||
CXXFLAGS += -Ddebug_level$(DEBUG_LEVEL)
|
CXXFLAGS += -Ddebug_level$(DEBUG_LEVEL)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(DO_GENRICHCURRENT),true)
|
|
||||||
CXXFLAGS += -DGENRICHCURRENT #-Ddebug_genrich
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Catch2
|
# Catch2
|
||||||
CXXFLAGS += $(CATCH_INCLUDES)
|
CXXFLAGS += $(CATCH_INCLUDES)
|
||||||
|
|
||||||
@@ -89,7 +81,7 @@ TARGET_TEST=$(BIN_DIR)/karl_test
|
|||||||
|
|
||||||
# Compile logic
|
# Compile logic
|
||||||
|
|
||||||
all: blitz jansson karl
|
all: blitz hdf5 jansson karl
|
||||||
|
|
||||||
check_homebase:
|
check_homebase:
|
||||||
ifeq ($(HOMEBASE),)
|
ifeq ($(HOMEBASE),)
|
||||||
@@ -107,6 +99,12 @@ endif
|
|||||||
blitz: check_homebase
|
blitz: check_homebase
|
||||||
ifeq ($(MAKE_BLITZ), true)
|
ifeq ($(MAKE_BLITZ), true)
|
||||||
$(MAKE) -C external/blitz
|
$(MAKE) -C external/blitz
|
||||||
|
$(MAKE) -C external/blitz install
|
||||||
|
endif
|
||||||
|
|
||||||
|
hdf5: check_homebase
|
||||||
|
ifeq ($(MAKE_H5), true)
|
||||||
|
$(MAKE) -C external/h5
|
||||||
endif
|
endif
|
||||||
|
|
||||||
jansson: check_homebase
|
jansson: check_homebase
|
||||||
|
|||||||
@@ -54,6 +54,13 @@
|
|||||||
"yValuesKey": "/vz(ms)",
|
"yValuesKey": "/vz(ms)",
|
||||||
"prefactor": 1
|
"prefactor": 1
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"f5": {
|
||||||
|
"Exponential": {
|
||||||
|
"scale": -1,
|
||||||
|
"prefactor": 1,
|
||||||
|
"comment": "f5 = prefactor*exp(scale*x)"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"3dto1D examples": {
|
"3dto1D examples": {
|
||||||
|
|||||||
@@ -1,923 +0,0 @@
|
|||||||
{
|
|
||||||
"GlobalPositionBinning": {
|
|
||||||
"CylinderBinning": {
|
|
||||||
"Radial": {
|
|
||||||
"NumberOfBins": 5,
|
|
||||||
"MaxRadius": {
|
|
||||||
"value": 4.5,
|
|
||||||
"unit": "cm"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Longitudinal": {
|
|
||||||
"NumberOfBins": 100,
|
|
||||||
"MaxLength": {
|
|
||||||
"value": 1657,
|
|
||||||
"unit": "cm"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Azimuthal": {
|
|
||||||
"NumberOfBins": 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"SourceGeometry": {
|
|
||||||
"Cylinder": {
|
|
||||||
"Radius": {
|
|
||||||
"value": 4.5,
|
|
||||||
"unit": "cm"
|
|
||||||
},
|
|
||||||
"Height": {
|
|
||||||
"value": 1657,
|
|
||||||
"unit": "cm"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Species": {
|
|
||||||
"Background": {
|
|
||||||
"TritiumGas": {
|
|
||||||
"ParticleType": "T2",
|
|
||||||
"ConstantDensityField": {
|
|
||||||
"ScalarField": {
|
|
||||||
"ScalarFieldFunctionInZ": {
|
|
||||||
"zFunction": {
|
|
||||||
"Product": {
|
|
||||||
"fi": {
|
|
||||||
"Constant": {
|
|
||||||
"constant": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"fj": {
|
|
||||||
"Constant": {
|
|
||||||
"constant": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"fk": {
|
|
||||||
"PiecewiseLinearFromFile": {
|
|
||||||
"PathToH5": {
|
|
||||||
"Type": "RelativeToHomebase",
|
|
||||||
"RelativePath": "data/densityDistributions/T2",
|
|
||||||
"Filename": "T2_n_vs_z_kuckert_approximated_relative.h5"
|
|
||||||
},
|
|
||||||
"xValuesKey": "/z_position(m)",
|
|
||||||
"yValuesKey": "/n(m3)",
|
|
||||||
"prefactor": 6.337599E20
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"VelocityDistribution": {
|
|
||||||
"VelocityDistributionFromFunction": {
|
|
||||||
"VelocityDistributionFunction": {
|
|
||||||
"IsotropicDistribution": {
|
|
||||||
"EnergyDistributionFunction": {
|
|
||||||
"MaxwellBoltzmann": {
|
|
||||||
"Temperature": {
|
|
||||||
"value": 80,
|
|
||||||
"unit": "K"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Mass": {
|
|
||||||
"FromParticleType": "T2"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"DriftVelocity": {
|
|
||||||
"VectorField": {
|
|
||||||
"VectorFieldFunctionInZ": {
|
|
||||||
"zFunction": {
|
|
||||||
"Product": {
|
|
||||||
"fi": {
|
|
||||||
"Constant": {
|
|
||||||
"constant": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"fj": {
|
|
||||||
"Constant": {
|
|
||||||
"constant": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"fk": {
|
|
||||||
"PiecewiseLinearFromFile": {
|
|
||||||
"PathToH5": {
|
|
||||||
"Type": "RelativeToHomebase",
|
|
||||||
"RelativePath": "data/velocityDistributions/T2_vz/KuckertPaper",
|
|
||||||
"Filename": "T2_vz_vs_z_kuckert_approximated.h5"
|
|
||||||
},
|
|
||||||
"xValuesKey": "/z_position(m)",
|
|
||||||
"yValuesKey": "/vz(ms)",
|
|
||||||
"prefactor": 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Tracked": {
|
|
||||||
"e-": {
|
|
||||||
"ParticleType": "electron",
|
|
||||||
"StoreInQueue": "true",
|
|
||||||
"Mover": {
|
|
||||||
"Boris": {
|
|
||||||
"MaximalTimestepLength": {
|
|
||||||
"value": 2e-11,
|
|
||||||
"unit": "s"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Terminator": {
|
|
||||||
"MaximumInteractions": 1E6,
|
|
||||||
"MaxTimeAlive": {
|
|
||||||
"value": 1,
|
|
||||||
"unit": "s"
|
|
||||||
},
|
|
||||||
"BoundaryGeometry": {
|
|
||||||
"Cylinder": {
|
|
||||||
"Radius": {
|
|
||||||
"value": 4.5,
|
|
||||||
"unit": "cm"
|
|
||||||
},
|
|
||||||
"Height": {
|
|
||||||
"value": 1657,
|
|
||||||
"unit": "cm"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Reflector": {
|
|
||||||
"ReflectorDPS": {
|
|
||||||
"position_z": {
|
|
||||||
"value": 1657,
|
|
||||||
"unit": "cm"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"DensityField": {
|
|
||||||
"DynamicDensityField": {
|
|
||||||
"PositionBinning": {
|
|
||||||
"CreateSameAs": [
|
|
||||||
"GlobalPositionBinning"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"EnergyBinning": {
|
|
||||||
"Type": "Logarithmic",
|
|
||||||
"NumberOfBins": 100,
|
|
||||||
"MinEnergy": {
|
|
||||||
"value": 1E-6,
|
|
||||||
"unit": "eV"
|
|
||||||
},
|
|
||||||
"MaxEnergy": {
|
|
||||||
"value": 20E3,
|
|
||||||
"unit": "eV"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"PitchAngleBinning": {
|
|
||||||
"Type": "Linear",
|
|
||||||
"NumberOfBins": 5
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"VelocityDistribution": {
|
|
||||||
"null": {}
|
|
||||||
},
|
|
||||||
"DriftVelocity": {
|
|
||||||
"null": {}
|
|
||||||
},
|
|
||||||
"Loggers": {
|
|
||||||
"Deletion": {
|
|
||||||
"Type": "all"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"CurrentCollector": {
|
|
||||||
"PositionBinning": {
|
|
||||||
"CreateSameAs": [
|
|
||||||
"GlobalPositionBinning"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Interactions": {
|
|
||||||
"elastic": {
|
|
||||||
"Type": "ElasticScattering",
|
|
||||||
"Target": "TritiumGas",
|
|
||||||
"CrossSection": {
|
|
||||||
"PredefinedFunction": "eT2_elastic_scattering"
|
|
||||||
},
|
|
||||||
"ScatteringAngleDistribution": {
|
|
||||||
"CompositeAngleDistribution": {
|
|
||||||
"LowerDistribution": {
|
|
||||||
"Isotropic": {}
|
|
||||||
},
|
|
||||||
"HigherDistribution": {
|
|
||||||
"AngleDistributionFromFile": {
|
|
||||||
"PathToH5": {
|
|
||||||
"Type": "RelativeToHomebase",
|
|
||||||
"RelativePath": "data/crossSections/eT2_elastic_scattering",
|
|
||||||
"Filename": "eT2_elastic_cross_section_scattering_angle.h5"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"DeciderEnergy": {
|
|
||||||
"value": 10,
|
|
||||||
"unit": "eV"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ionization1": {
|
|
||||||
"Type": "ElectronIonization",
|
|
||||||
"IonizationModel": "JanevNonDiss",
|
|
||||||
"Target": "TritiumGas",
|
|
||||||
"OutgoingElectron": "e-",
|
|
||||||
"OutgoingIon": "T2+"
|
|
||||||
},
|
|
||||||
"ionization2": {
|
|
||||||
"Type": "ElectronIonization",
|
|
||||||
"IonizationModel": "JanevDissToGround",
|
|
||||||
"Target": "TritiumGas",
|
|
||||||
"OutgoingElectron": "e-",
|
|
||||||
"OutgoingIon": "T+"
|
|
||||||
},
|
|
||||||
"ionization3": {
|
|
||||||
"Type": "ElectronIonization",
|
|
||||||
"IonizationModel": "JanevDissToFirstExcited",
|
|
||||||
"Target": "TritiumGas",
|
|
||||||
"OutgoingElectron": "e-",
|
|
||||||
"OutgoingIon": "T+"
|
|
||||||
},
|
|
||||||
"excitation0": {
|
|
||||||
"Type": "Excitation",
|
|
||||||
"Target": "TritiumGas",
|
|
||||||
"ExcitationState": "janev_singlet_B1"
|
|
||||||
},
|
|
||||||
"excitation1": {
|
|
||||||
"Type": "Excitation",
|
|
||||||
"Target": "TritiumGas",
|
|
||||||
"ExcitationState": "janev_singlet_B1prime"
|
|
||||||
},
|
|
||||||
"excitation2": {
|
|
||||||
"Type": "Excitation",
|
|
||||||
"Target": "TritiumGas",
|
|
||||||
"ExcitationState": "janev_singlet_B1primeprime"
|
|
||||||
},
|
|
||||||
"excitation3": {
|
|
||||||
"Type": "Excitation",
|
|
||||||
"Target": "TritiumGas",
|
|
||||||
"ExcitationState": "janev_singlet_C1"
|
|
||||||
},
|
|
||||||
"excitation4": {
|
|
||||||
"Type": "Excitation",
|
|
||||||
"Target": "TritiumGas",
|
|
||||||
"ExcitationState": "janev_singlet_D1"
|
|
||||||
},
|
|
||||||
"excitation5": {
|
|
||||||
"Type": "Excitation",
|
|
||||||
"Target": "TritiumGas",
|
|
||||||
"ExcitationState": "janev_singlet_D1prime"
|
|
||||||
},
|
|
||||||
"excitation6": {
|
|
||||||
"Type": "Excitation",
|
|
||||||
"Target": "TritiumGas",
|
|
||||||
"ExcitationState": "janev_singlet_symmetry_forbidden_EF1"
|
|
||||||
},
|
|
||||||
"excitation7": {
|
|
||||||
"Type": "Excitation",
|
|
||||||
"Target": "TritiumGas",
|
|
||||||
"ExcitationState": "janev_singlet_symmetry_forbidden_HHb"
|
|
||||||
},
|
|
||||||
"excitation8": {
|
|
||||||
"Type": "Excitation",
|
|
||||||
"Target": "TritiumGas",
|
|
||||||
"ExcitationState": "janev_singlet_symmetry_forbidden_GK1"
|
|
||||||
},
|
|
||||||
"excitation9": {
|
|
||||||
"Type": "Excitation",
|
|
||||||
"Target": "TritiumGas",
|
|
||||||
"ExcitationState": "janev_singlet_symmetry_forbidden_I1"
|
|
||||||
},
|
|
||||||
"excitation10": {
|
|
||||||
"Type": "Excitation",
|
|
||||||
"Target": "TritiumGas",
|
|
||||||
"ExcitationState": "janev_triplet_A3"
|
|
||||||
},
|
|
||||||
"excitation11": {
|
|
||||||
"Type": "Excitation",
|
|
||||||
"Target": "TritiumGas",
|
|
||||||
"ExcitationState": "janev_triplet_B3"
|
|
||||||
},
|
|
||||||
"excitation12": {
|
|
||||||
"Type": "Excitation",
|
|
||||||
"Target": "TritiumGas",
|
|
||||||
"ExcitationState": "janev_triplet_C3"
|
|
||||||
},
|
|
||||||
"excitation13": {
|
|
||||||
"Type": "Excitation",
|
|
||||||
"Target": "TritiumGas",
|
|
||||||
"ExcitationState": "janev_triplet_E3"
|
|
||||||
},
|
|
||||||
"excitation14": {
|
|
||||||
"Type": "Excitation",
|
|
||||||
"Target": "TritiumGas",
|
|
||||||
"ExcitationState": "janev_triplet_D3"
|
|
||||||
},
|
|
||||||
"excitation15": {
|
|
||||||
"Type": "Excitation",
|
|
||||||
"Target": "TritiumGas",
|
|
||||||
"ExcitationState": "janev_vibrational_first"
|
|
||||||
},
|
|
||||||
"excitation16": {
|
|
||||||
"Type": "Excitation",
|
|
||||||
"Target": "TritiumGas",
|
|
||||||
"ExcitationState": "janev_vibrational_second"
|
|
||||||
},
|
|
||||||
"excitation17": {
|
|
||||||
"Type": "Excitation",
|
|
||||||
"Target": "TritiumGas",
|
|
||||||
"ExcitationState": "england_rotational_j0_to_j2"
|
|
||||||
},
|
|
||||||
"excitation18": {
|
|
||||||
"Type": "Excitation",
|
|
||||||
"Target": "TritiumGas",
|
|
||||||
"ExcitationState": "england_rotational_j1_to_j3"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"T2+": {
|
|
||||||
"ParticleType": "T2+",
|
|
||||||
"StoreInQueue": "false",
|
|
||||||
"Mover": {
|
|
||||||
"Boris": {
|
|
||||||
"MaximalTimestepLength": {
|
|
||||||
"value": 6e-11,
|
|
||||||
"unit": "s"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Terminator": {
|
|
||||||
"MaximumInteractions": 1E6,
|
|
||||||
"MaxTimeAlive": {
|
|
||||||
"value": 10,
|
|
||||||
"unit": "s"
|
|
||||||
},
|
|
||||||
"BoundaryGeometry": {
|
|
||||||
"Cylinder": {
|
|
||||||
"Radius": {
|
|
||||||
"value": 4.5,
|
|
||||||
"unit": "cm"
|
|
||||||
},
|
|
||||||
"Height": {
|
|
||||||
"value": 1657,
|
|
||||||
"unit": "cm"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Reflector": {
|
|
||||||
"NoReflector": {}
|
|
||||||
},
|
|
||||||
"DensityField": {
|
|
||||||
"DynamicDensityField": {
|
|
||||||
"PositionBinning": {
|
|
||||||
"CreateSameAs": [
|
|
||||||
"GlobalPositionBinning"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"EnergyBinning": {
|
|
||||||
"Type": "Logarithmic",
|
|
||||||
"NumberOfBins": 50,
|
|
||||||
"MinEnergy": {
|
|
||||||
"value": 1E-6,
|
|
||||||
"unit": "eV"
|
|
||||||
},
|
|
||||||
"MaxEnergy": {
|
|
||||||
"value": 1E1,
|
|
||||||
"unit": "eV"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"PitchAngleBinning": {
|
|
||||||
"Type": "Linear",
|
|
||||||
"NumberOfBins": 5
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"VelocityDistribution": {
|
|
||||||
"null": {}
|
|
||||||
},
|
|
||||||
"DriftVelocity": {
|
|
||||||
"null": {}
|
|
||||||
},
|
|
||||||
"Loggers": {
|
|
||||||
"Deletion": {
|
|
||||||
"Type": "all"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"CurrentCollector": {
|
|
||||||
"PositionBinning": {
|
|
||||||
"CreateSameAs": [
|
|
||||||
"GlobalPositionBinning"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Interactions": {
|
|
||||||
"charge exchange": {
|
|
||||||
"Type": "ChargeExchange",
|
|
||||||
"Target": "TritiumGas",
|
|
||||||
"CrossSection": {
|
|
||||||
"PredefinedFunction": "T2pT2_charge_exchange_janev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"clustering": {
|
|
||||||
"Type": "Clustering",
|
|
||||||
"Target": "TritiumGas",
|
|
||||||
"ClusteringType": "radiative",
|
|
||||||
"Product": "T3+",
|
|
||||||
"CrossSection": {
|
|
||||||
"PredefinedFunction": "T2pT2_clustering_janev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"free_movement_example": {
|
|
||||||
"Type": "FreeMovement"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"T+": {
|
|
||||||
"ParticleType": "T+",
|
|
||||||
"StoreInQueue": "false",
|
|
||||||
"Mover": {
|
|
||||||
"Boris": {
|
|
||||||
"MaximalTimestepLength": {
|
|
||||||
"value": 6e-11,
|
|
||||||
"unit": "s"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Terminator": {
|
|
||||||
"MaximumInteractions": 1E6,
|
|
||||||
"MaxTimeAlive": {
|
|
||||||
"value": 10,
|
|
||||||
"unit": "s"
|
|
||||||
},
|
|
||||||
"BoundaryGeometry": {
|
|
||||||
"Cylinder": {
|
|
||||||
"Radius": {
|
|
||||||
"value": 4.5,
|
|
||||||
"unit": "cm"
|
|
||||||
},
|
|
||||||
"Height": {
|
|
||||||
"value": 1657,
|
|
||||||
"unit": "cm"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Reflector": {
|
|
||||||
"NoReflector": {}
|
|
||||||
},
|
|
||||||
"DensityField": {
|
|
||||||
"DynamicDensityField": {
|
|
||||||
"PositionBinning": {
|
|
||||||
"CreateSameAs": [
|
|
||||||
"GlobalPositionBinning"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"EnergyBinning": {
|
|
||||||
"Type": "Logarithmic",
|
|
||||||
"NumberOfBins": 50,
|
|
||||||
"MinEnergy": {
|
|
||||||
"value": 1E-6,
|
|
||||||
"unit": "eV"
|
|
||||||
},
|
|
||||||
"MaxEnergy": {
|
|
||||||
"value": 1E1,
|
|
||||||
"unit": "eV"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"PitchAngleBinning": {
|
|
||||||
"Type": "Linear",
|
|
||||||
"NumberOfBins": 5
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"VelocityDistribution": {
|
|
||||||
"null": {}
|
|
||||||
},
|
|
||||||
"DriftVelocity": {
|
|
||||||
"null": {}
|
|
||||||
},
|
|
||||||
"Loggers": {
|
|
||||||
"Deletion": {
|
|
||||||
"Type": "all"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"CurrentCollector": {
|
|
||||||
"PositionBinning": {
|
|
||||||
"CreateSameAs": [
|
|
||||||
"GlobalPositionBinning"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Interactions": {
|
|
||||||
"elastic scattering": {
|
|
||||||
"Type": "ElasticScattering",
|
|
||||||
"Target": "TritiumGas",
|
|
||||||
"CrossSection": {
|
|
||||||
"PredefinedFunction": "TpT2_elastic_scattering_tabata"
|
|
||||||
},
|
|
||||||
"ScatteringAngleDistribution": {
|
|
||||||
"Isotropic": {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"clustering1": {
|
|
||||||
"Type": "Clustering",
|
|
||||||
"Target": "TritiumGas",
|
|
||||||
"ClusteringType": "radiative",
|
|
||||||
"Product": "T3+",
|
|
||||||
"CrossSection": {
|
|
||||||
"PredefinedFunction": "TpT2_clustering_radiative_ascendion_pasil"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"clustering2": {
|
|
||||||
"Type": "Clustering",
|
|
||||||
"Target": "TritiumGas",
|
|
||||||
"ClusteringType": "tertiary",
|
|
||||||
"Product": "T3+",
|
|
||||||
"CrossSection": {
|
|
||||||
"PredefinedFunction": "TpT2_clustering_tertiary_ascendion_pasil"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"free_movement_example": {
|
|
||||||
"Type": "FreeMovement"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"T3+": {
|
|
||||||
"ParticleType": "T3+",
|
|
||||||
"StoreInQueue": "false",
|
|
||||||
"Mover": {
|
|
||||||
"Boris": {
|
|
||||||
"MaximalTimestepLength": {
|
|
||||||
"value": 6e-11,
|
|
||||||
"unit": "s"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Terminator": {
|
|
||||||
"MaximumInteractions": 1E6,
|
|
||||||
"MaxTimeAlive": {
|
|
||||||
"value": 10,
|
|
||||||
"unit": "s"
|
|
||||||
},
|
|
||||||
"BoundaryGeometry": {
|
|
||||||
"Cylinder": {
|
|
||||||
"Radius": {
|
|
||||||
"value": 4.5,
|
|
||||||
"unit": "cm"
|
|
||||||
},
|
|
||||||
"Height": {
|
|
||||||
"value": 1657,
|
|
||||||
"unit": "cm"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Reflector": {
|
|
||||||
"NoReflector": {}
|
|
||||||
},
|
|
||||||
"DensityField": {
|
|
||||||
"DynamicDensityField": {
|
|
||||||
"PositionBinning": {
|
|
||||||
"CreateSameAs": [
|
|
||||||
"GlobalPositionBinning"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"EnergyBinning": {
|
|
||||||
"Type": "Logarithmic",
|
|
||||||
"NumberOfBins": 100,
|
|
||||||
"MinEnergy": {
|
|
||||||
"value": 1E-6,
|
|
||||||
"unit": "eV"
|
|
||||||
},
|
|
||||||
"MaxEnergy": {
|
|
||||||
"value": 1E3,
|
|
||||||
"unit": "eV"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"PitchAngleBinning": {
|
|
||||||
"Type": "Linear",
|
|
||||||
"NumberOfBins": 5
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"VelocityDistribution": {
|
|
||||||
"null": {}
|
|
||||||
},
|
|
||||||
"DriftVelocity": {
|
|
||||||
"null": {}
|
|
||||||
},
|
|
||||||
"Loggers": {
|
|
||||||
"Deletion": {
|
|
||||||
"Type": "all"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"CurrentCollector": {
|
|
||||||
"PositionBinning": {
|
|
||||||
"CreateSameAs": [
|
|
||||||
"GlobalPositionBinning"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Interactions": {
|
|
||||||
"elastic scattering": {
|
|
||||||
"Type": "ElasticScattering",
|
|
||||||
"Target": "TritiumGas",
|
|
||||||
"CrossSection": {
|
|
||||||
"PredefinedFunction": "T3pT2_elastic_scattering_tabata"
|
|
||||||
},
|
|
||||||
"ScatteringAngleDistribution": {
|
|
||||||
"Isotropic": {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"free_movement_example": {
|
|
||||||
"Type": "FreeMovement"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Injector": {
|
|
||||||
"CreatedSpecies": {
|
|
||||||
"specie1": {
|
|
||||||
"TrackedSpecieName": "e-",
|
|
||||||
"CreationVelocityDistribution": {
|
|
||||||
"VelocityDistributionFromFunction": {
|
|
||||||
"VelocityDistributionFunction": {
|
|
||||||
"IsotropicDistribution": {
|
|
||||||
"EnergyDistributionFunction": {
|
|
||||||
"TritiumBetaDecay": {}
|
|
||||||
},
|
|
||||||
"Mass": {
|
|
||||||
"FromParticleType": "electron"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"InjectionStride": 1
|
|
||||||
},
|
|
||||||
"specie2": {
|
|
||||||
"TrackedSpecieName": "T2+",
|
|
||||||
"CreationVelocityDistribution": {
|
|
||||||
"VelocityDistributionFromFunction": {
|
|
||||||
"VelocityDistributionFunction": {
|
|
||||||
"IsotropicDistribution": {
|
|
||||||
"EnergyDistributionFunction": {
|
|
||||||
"MaxwellBoltzmann": {
|
|
||||||
"Temperature": {
|
|
||||||
"value": 80,
|
|
||||||
"unit": "K"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Mass": {
|
|
||||||
"FromParticleType": "T2"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"InjectionStride": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"EventPositionDistribution": {
|
|
||||||
"ScalarField": {
|
|
||||||
"ScalarFieldFunctionInZ": {
|
|
||||||
"zFunction": {
|
|
||||||
"Product": {
|
|
||||||
"fi": {
|
|
||||||
"Constant": {
|
|
||||||
"constant": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"fj": {
|
|
||||||
"Constant": {
|
|
||||||
"constant": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"fk": {
|
|
||||||
"PiecewiseLinearFromFile": {
|
|
||||||
"PathToH5": {
|
|
||||||
"Type": "RelativeToHomebase",
|
|
||||||
"RelativePath": "data/densityDistributions/T2",
|
|
||||||
"Filename": "T2_n_vs_z_kuckert_approximated_relative.h5"
|
|
||||||
},
|
|
||||||
"xValuesKey": "/z_position(m)",
|
|
||||||
"yValuesKey": "/n(m3)",
|
|
||||||
"prefactor": 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"DensityLimit": {
|
|
||||||
"min": 0,
|
|
||||||
"max": 1
|
|
||||||
},
|
|
||||||
"PositionLimits": {
|
|
||||||
"rPosition": {
|
|
||||||
"min": 0,
|
|
||||||
"max": 0.045
|
|
||||||
},
|
|
||||||
"phiPosition": {
|
|
||||||
"min": 0,
|
|
||||||
"max": 6.28318530718
|
|
||||||
},
|
|
||||||
"zPosition": {
|
|
||||||
"min": 0,
|
|
||||||
"max": 16.57
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"MotherDriftVelocity": {
|
|
||||||
"VectorField": {
|
|
||||||
"VectorFieldFunctionInZ": {
|
|
||||||
"zFunction": {
|
|
||||||
"Product": {
|
|
||||||
"fi": {
|
|
||||||
"Constant": {
|
|
||||||
"constant": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"fj": {
|
|
||||||
"Constant": {
|
|
||||||
"constant": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"fk": {
|
|
||||||
"PiecewiseLinearFromFile": {
|
|
||||||
"PathToH5": {
|
|
||||||
"Type": "RelativeToHomebase",
|
|
||||||
"RelativePath": "data/velocityDistributions/T2_vz/KuckertPaper",
|
|
||||||
"Filename": "T2_vz_vs_z_kuckert_approximated.h5"
|
|
||||||
},
|
|
||||||
"xValuesKey": "/z_position(m)",
|
|
||||||
"yValuesKey": "/vz(ms)",
|
|
||||||
"prefactor": 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Activity": {
|
|
||||||
"value": 3.7e10,
|
|
||||||
"unit": "Bq"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ElectricField": {
|
|
||||||
"Background": {
|
|
||||||
"VectorField": {
|
|
||||||
"VectorFieldConstant": {
|
|
||||||
"constant": {
|
|
||||||
"vector": [
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"unit": "V/m"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Dynamic": {
|
|
||||||
"VectorField": {
|
|
||||||
"VectorFieldConstant": {
|
|
||||||
"constant": {
|
|
||||||
"vector": [
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"unit": "V/m"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"MagneticField": {
|
|
||||||
"VectorField": {
|
|
||||||
"VectorFieldFunctionInZ": {
|
|
||||||
"zFunction": {
|
|
||||||
"Constant3D": {
|
|
||||||
"constant": 0.025
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"GradientField": {
|
|
||||||
"VectorFieldFunctionInZ": {
|
|
||||||
"zFunction": {
|
|
||||||
"Constant3D": {
|
|
||||||
"constant": 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"GravityField": {
|
|
||||||
"VectorField": {
|
|
||||||
"VectorFieldFunctionInZ": {
|
|
||||||
"zFunction": {
|
|
||||||
"Constant3D": {
|
|
||||||
"constant": 0.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"PoissonSolver": {
|
|
||||||
"BoundaryGeometry": {
|
|
||||||
"CreateSameAs": ["SourceGeometry"]
|
|
||||||
},
|
|
||||||
"PositionBinning": {
|
|
||||||
"CreateSameAs": [
|
|
||||||
"GlobalPositionBinning"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"Boundary": {
|
|
||||||
"Top": {
|
|
||||||
"type": "dirichlet",
|
|
||||||
"value": 0
|
|
||||||
},
|
|
||||||
"Bottom": {
|
|
||||||
"type": "dirichlet",
|
|
||||||
"value": 0
|
|
||||||
},
|
|
||||||
"Hull": {
|
|
||||||
"type": "dirichlet",
|
|
||||||
"value": 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"TargetAccuracy": 1e-6,
|
|
||||||
"NumCycles": 2e4,
|
|
||||||
"DoSolver": "true"
|
|
||||||
},
|
|
||||||
"Simulation": {
|
|
||||||
"NumberTimesteps": 20,
|
|
||||||
"EventStride": 10,
|
|
||||||
"TimeResolutionEvents": 10,
|
|
||||||
"BetaDecayEventsPerCPU": 10,
|
|
||||||
"InjectionStride": 1,
|
|
||||||
"NumberDensityParticlesPerBinPerCPU": 1
|
|
||||||
},
|
|
||||||
"Output": {
|
|
||||||
"folder": "output",
|
|
||||||
"filename": "wgts",
|
|
||||||
"DensityFields": {
|
|
||||||
"Species": "all",
|
|
||||||
"Intervall": 288,
|
|
||||||
"OverwriteLast": "false"
|
|
||||||
},
|
|
||||||
"CurrentBorders": {
|
|
||||||
"Species": "all",
|
|
||||||
"Intervall": 288,
|
|
||||||
"OverwriteLast": "false"
|
|
||||||
},
|
|
||||||
"DeletionLogger": {
|
|
||||||
"Species": "all",
|
|
||||||
"Intervall": 288,
|
|
||||||
"OverwriteLast": "false"
|
|
||||||
},
|
|
||||||
"PoissonSolver": {
|
|
||||||
"Intervall": 288,
|
|
||||||
"OverwriteLast": "false"
|
|
||||||
},
|
|
||||||
"RestartInfo": {
|
|
||||||
"Intervall": 288,
|
|
||||||
"OverwriteLast": "false"
|
|
||||||
},
|
|
||||||
"Particles": {
|
|
||||||
"Intervall": 2880
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Restart": {
|
|
||||||
"Do": "false",
|
|
||||||
"SyncPeriod": 2880,
|
|
||||||
"PathToH5": {
|
|
||||||
"Type": "AbsolutePath",
|
|
||||||
"AbsoluteFolderPath": "/home/christian/Documents/Heidelberg/karl/timeResolvedTests/thermalization/output",
|
|
||||||
"Filename": "const_target_energy"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"RandomNumbers": {
|
|
||||||
"Seed": 1337
|
|
||||||
}
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -568,6 +568,15 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"GradientField": {
|
||||||
|
"VectorFieldFunctionInZ": {
|
||||||
|
"zFunction": {
|
||||||
|
"Constant3D": {
|
||||||
|
"constant": 2.5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"GravityField": {
|
"GravityField": {
|
||||||
@@ -616,7 +625,8 @@
|
|||||||
"TargetAccuracy": 1e-7,
|
"TargetAccuracy": 1e-7,
|
||||||
"NumCycles": 2e4,
|
"NumCycles": 2e4,
|
||||||
"Intervall": 1,
|
"Intervall": 1,
|
||||||
"Offset": 9
|
"Offset": 9,
|
||||||
|
"DoSolver": "true"
|
||||||
},
|
},
|
||||||
"Simulation": {
|
"Simulation": {
|
||||||
"SimulatedEvents": 1,
|
"SimulatedEvents": 1,
|
||||||
@@ -639,9 +649,7 @@
|
|||||||
"OverwriteLast": "true"
|
"OverwriteLast": "true"
|
||||||
},
|
},
|
||||||
"DeletionLogger": {
|
"DeletionLogger": {
|
||||||
"Species": [
|
"Species": "all",
|
||||||
"all"
|
|
||||||
],
|
|
||||||
"Intervall": "EachSync",
|
"Intervall": "EachSync",
|
||||||
"OverwriteLast": "true"
|
"OverwriteLast": "true"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -565,6 +565,15 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"GradientField": {
|
||||||
|
"VectorFieldFunctionInZ": {
|
||||||
|
"zFunction": {
|
||||||
|
"Constant3D": {
|
||||||
|
"constant": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"PoissonSolver": {
|
"PoissonSolver": {
|
||||||
@@ -585,13 +594,30 @@
|
|||||||
"GlobalPositionBinning"
|
"GlobalPositionBinning"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"Boundary": {
|
||||||
|
"Top": {
|
||||||
|
"type": "neumann",
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
"Bottom": {
|
||||||
|
"type": "dirichlet",
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
"Hull": {
|
||||||
|
"type": "dirichlet",
|
||||||
|
"value": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
"TargetAccuracy": 1e-7,
|
"TargetAccuracy": 1e-7,
|
||||||
"NumCycles": 2e4
|
"NumCycles": 2e4,
|
||||||
|
"Intervall": 1,
|
||||||
|
"Offset": 0
|
||||||
},
|
},
|
||||||
"Simulation": {
|
"Simulation": {
|
||||||
"SimulatedEvents": 1,
|
"SimulatedEvents": 1,
|
||||||
"EventStride": 1,
|
"EventStride": 1,
|
||||||
"PoissonOffset": 0
|
"PoissonOffset": 0,
|
||||||
|
"DoSolver": "false"
|
||||||
},
|
},
|
||||||
"Output": {
|
"Output": {
|
||||||
"folder": "output",
|
"folder": "output",
|
||||||
|
|||||||
@@ -1,536 +0,0 @@
|
|||||||
{
|
|
||||||
"GlobalPositionBinning": {
|
|
||||||
"CylinderBinning": {
|
|
||||||
"Radial": {
|
|
||||||
"NumberOfBins": 10,
|
|
||||||
"MaxRadius": {
|
|
||||||
"value": 5,
|
|
||||||
"unit": "cm"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Longitudinal": {
|
|
||||||
"NumberOfBins": 75,
|
|
||||||
"MaxLength": {
|
|
||||||
"value": 300,
|
|
||||||
"unit": "cm"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Azimuthal": {
|
|
||||||
"NumberOfBins": 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"SourceGeometry": {
|
|
||||||
"Cylinder": {
|
|
||||||
"Radius": {
|
|
||||||
"value": 5,
|
|
||||||
"unit": "cm"
|
|
||||||
},
|
|
||||||
"Height": {
|
|
||||||
"value": 300,
|
|
||||||
"unit": "cm"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Species": {
|
|
||||||
"Background": {
|
|
||||||
"TritiumGas": {
|
|
||||||
"ParticleType": "T",
|
|
||||||
"ConstantDensityField": {
|
|
||||||
"ScalarField": {
|
|
||||||
"ScalarFieldFunctionInZ": {
|
|
||||||
"zFunction": {
|
|
||||||
"Product": {
|
|
||||||
"fi": {
|
|
||||||
"Constant": {
|
|
||||||
"constant": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"fj": {
|
|
||||||
"Constant": {
|
|
||||||
"constant": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"fk": {
|
|
||||||
"Exponential": {
|
|
||||||
"scale": -7.1307e-4,
|
|
||||||
"prefactor": 1E17
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"VelocityDistribution": {
|
|
||||||
"VelocityDistributionFromFunction": {
|
|
||||||
"VelocityDistributionFunction": {
|
|
||||||
"IsotropicDistribution": {
|
|
||||||
"EnergyDistributionFunction": {
|
|
||||||
"MaxwellBoltzmann": {
|
|
||||||
"Temperature": {
|
|
||||||
"value": 5,
|
|
||||||
"unit": "K"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Mass": {
|
|
||||||
"FromParticleType": "T"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"DriftVelocity": {
|
|
||||||
"VectorField": {
|
|
||||||
"VectorFieldFunctionInZ": {
|
|
||||||
"zFunction": {
|
|
||||||
"Product": {
|
|
||||||
"fi": {
|
|
||||||
"Constant": {
|
|
||||||
"constant": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"fj": {
|
|
||||||
"Constant": {
|
|
||||||
"constant": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"fk": {
|
|
||||||
"PiecewiseLinear": {
|
|
||||||
"xValues": [
|
|
||||||
0,
|
|
||||||
16
|
|
||||||
],
|
|
||||||
"yValues": [
|
|
||||||
0,
|
|
||||||
0
|
|
||||||
],
|
|
||||||
"prefactor": 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Tracked": {
|
|
||||||
"e-": {
|
|
||||||
"ParticleType": "electron",
|
|
||||||
"Mover": {
|
|
||||||
"Drift": {
|
|
||||||
"MaximalMovedDistance": {
|
|
||||||
"value": 1e-3,
|
|
||||||
"unit": "m"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Terminator": {
|
|
||||||
"MaximumInteractions": 1E6,
|
|
||||||
"MaxTimeAlive": {
|
|
||||||
"value": 1,
|
|
||||||
"unit": "s"
|
|
||||||
},
|
|
||||||
"BoundaryGeometry": {
|
|
||||||
"Cylinder": {
|
|
||||||
"Radius": {
|
|
||||||
"value": 5,
|
|
||||||
"unit": "cm"
|
|
||||||
},
|
|
||||||
"Height": {
|
|
||||||
"value": 300,
|
|
||||||
"unit": "cm"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Reflector": {
|
|
||||||
"NoReflector": {}
|
|
||||||
},
|
|
||||||
"DensityField": {
|
|
||||||
"DynamicDensityField": {
|
|
||||||
"PositionBinning": {
|
|
||||||
"CreateSameAs": [
|
|
||||||
"GlobalPositionBinning"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"EnergyBinning": {
|
|
||||||
"Type": "Logarithmic",
|
|
||||||
"NumberOfBins": 100,
|
|
||||||
"MinEnergy": {
|
|
||||||
"value": 1E-6,
|
|
||||||
"unit": "eV"
|
|
||||||
},
|
|
||||||
"MaxEnergy": {
|
|
||||||
"value": 20E3,
|
|
||||||
"unit": "eV"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"VelocityDistribution": {
|
|
||||||
"null": {}
|
|
||||||
},
|
|
||||||
"DriftVelocity": {
|
|
||||||
"null": {}
|
|
||||||
},
|
|
||||||
"Loggers": {
|
|
||||||
"Deletion": {
|
|
||||||
"Type": "all"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"CurrentCollector": {
|
|
||||||
"PositionBinning": {
|
|
||||||
"CreateSameAs": [
|
|
||||||
"GlobalPositionBinning"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Interactions": {
|
|
||||||
"freeMovement": {
|
|
||||||
"Type": "FreeMovement"
|
|
||||||
},
|
|
||||||
"elastic": {
|
|
||||||
"Type": "ElasticScattering",
|
|
||||||
"Target": "TritiumGas",
|
|
||||||
"CrossSection": {
|
|
||||||
"PredefinedFunction": "eT2_elastic_scattering_constant"
|
|
||||||
},
|
|
||||||
"ScatteringAngleDistribution": {
|
|
||||||
"Isotropic": {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"T+": {
|
|
||||||
"ParticleType": "T+",
|
|
||||||
"Mover": {
|
|
||||||
"Drift":{
|
|
||||||
"MaximalMovedDistance": {
|
|
||||||
"value": 1e-3,
|
|
||||||
"unit": "m"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Terminator": {
|
|
||||||
"MaximumInteractions": 1E6,
|
|
||||||
"MaxTimeAlive": {
|
|
||||||
"value": 1,
|
|
||||||
"unit": "s"
|
|
||||||
},
|
|
||||||
"BoundaryGeometry": {
|
|
||||||
"Cylinder": {
|
|
||||||
"Radius": {
|
|
||||||
"value": 5,
|
|
||||||
"unit": "cm"
|
|
||||||
},
|
|
||||||
"Height": {
|
|
||||||
"value": 300,
|
|
||||||
"unit": "cm"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Reflector": {
|
|
||||||
"NoReflector": {}
|
|
||||||
},
|
|
||||||
"DensityField": {
|
|
||||||
"DynamicDensityField": {
|
|
||||||
"PositionBinning": {
|
|
||||||
"CreateSameAs": [
|
|
||||||
"GlobalPositionBinning"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"EnergyBinning": {
|
|
||||||
"Type": "Logarithmic",
|
|
||||||
"NumberOfBins": 100,
|
|
||||||
"MinEnergy": {
|
|
||||||
"value": 1E-6,
|
|
||||||
"unit": "eV"
|
|
||||||
},
|
|
||||||
"MaxEnergy": {
|
|
||||||
"value": 1E3,
|
|
||||||
"unit": "eV"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"VelocityDistribution": {
|
|
||||||
"null": {}
|
|
||||||
},
|
|
||||||
"DriftVelocity": {
|
|
||||||
"null": {}
|
|
||||||
},
|
|
||||||
"Loggers": {
|
|
||||||
"Deletion": {
|
|
||||||
"Type": "all"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"CurrentCollector": {
|
|
||||||
"PositionBinning": {
|
|
||||||
"CreateSameAs": [
|
|
||||||
"GlobalPositionBinning"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Interactions": {
|
|
||||||
"name1": {
|
|
||||||
"Type": "FreeMovement"
|
|
||||||
},
|
|
||||||
"elastic": {
|
|
||||||
"Type": "ElasticScattering",
|
|
||||||
"Target": "TritiumGas",
|
|
||||||
"CrossSection": {
|
|
||||||
"PredefinedFunction": "eT2_elastic_scattering_constant"
|
|
||||||
},
|
|
||||||
"ScatteringAngleDistribution": {
|
|
||||||
"Isotropic": {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Injector": {
|
|
||||||
"CreatedSpecies": {
|
|
||||||
"specie1": {
|
|
||||||
"TrackedSpecieName": "e-",
|
|
||||||
"CreationVelocityDistribution": {
|
|
||||||
"VelocityDistributionFromFunction": {
|
|
||||||
"VelocityDistributionFunction": {
|
|
||||||
"DirectedDistribution": {
|
|
||||||
"EnergyDistributionFunction": {
|
|
||||||
"Constant": {
|
|
||||||
"constant": {
|
|
||||||
"value": 4.30867e-4,
|
|
||||||
"unit": "eV"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Mass": {
|
|
||||||
"FromParticleType": "electron"
|
|
||||||
},
|
|
||||||
"Direction":{
|
|
||||||
"vector": [1, 0, 1]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"specie2": {
|
|
||||||
"TrackedSpecieName": "T+",
|
|
||||||
"CreationVelocityDistribution": {
|
|
||||||
"VelocityDistributionFromFunction": {
|
|
||||||
"VelocityDistributionFunction": {
|
|
||||||
"DirectedDistribution": {
|
|
||||||
"EnergyDistributionFunction": {
|
|
||||||
"Constant": {
|
|
||||||
"constant": {
|
|
||||||
"unit": "eV",
|
|
||||||
"value": 4.30867e-4
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Mass": {
|
|
||||||
"FromParticleType": "T"
|
|
||||||
},
|
|
||||||
"Direction": {
|
|
||||||
"vector": [1, 0, 1]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"EventPositionDistribution": {
|
|
||||||
"ScalarField": {
|
|
||||||
"ScalarFieldFunctionInZ": {
|
|
||||||
"zFunction": {
|
|
||||||
"Product": {
|
|
||||||
"fi": {
|
|
||||||
"Constant": {
|
|
||||||
"constant": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"fj": {
|
|
||||||
"Constant": {
|
|
||||||
"constant": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"fk": {
|
|
||||||
"PiecewiseLinear": {
|
|
||||||
"xValues": [0.0, 3.0],
|
|
||||||
"yValues": [1.0, 1.0],
|
|
||||||
"prefactor": 1E15
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"DensityLimit": {
|
|
||||||
"min": 0,
|
|
||||||
"max": 1E15
|
|
||||||
},
|
|
||||||
"PositionLimits": {
|
|
||||||
"rPosition": {
|
|
||||||
"min": 0,
|
|
||||||
"max": 0.05
|
|
||||||
},
|
|
||||||
"phiPosition": {
|
|
||||||
"min": 0,
|
|
||||||
"max": 6.28318530718
|
|
||||||
},
|
|
||||||
"zPosition": {
|
|
||||||
"min": 0,
|
|
||||||
"max": 0.3
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"MotherDriftVelocity": {
|
|
||||||
"VectorField": {
|
|
||||||
"VectorFieldConstant": {
|
|
||||||
"constant": {
|
|
||||||
"vector": [
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"unit": "m/s"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Activity": {
|
|
||||||
"value": 1e7,
|
|
||||||
"unit": "Bq"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ElectricField": {
|
|
||||||
"Background": {
|
|
||||||
"VectorField": {
|
|
||||||
"VectorFieldConstant": {
|
|
||||||
"constant": {
|
|
||||||
"vector": [
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"unit": "V/m"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Dynamic": {
|
|
||||||
"VectorField": {
|
|
||||||
"VectorFieldConstant": {
|
|
||||||
"constant": {
|
|
||||||
"vector": [
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"unit": "V/m"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"MagneticField": {
|
|
||||||
"VectorField": {
|
|
||||||
"VectorFieldFunctionInZ": {
|
|
||||||
"zFunction": {
|
|
||||||
"Constant3D": {
|
|
||||||
"constant": 2.5
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"GradientField": {
|
|
||||||
"VectorFieldFunctionInZ": {
|
|
||||||
"zFunction": {
|
|
||||||
"Constant3D": {
|
|
||||||
"constant": 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"GravityField": {
|
|
||||||
"VectorField": {
|
|
||||||
"VectorFieldFunctionInZ": {
|
|
||||||
"zFunction": {
|
|
||||||
"Constant3D": {
|
|
||||||
"constant": -9.81
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"PoissonSolver": {
|
|
||||||
"BoundaryGeometry": {
|
|
||||||
"CreateSameAs": ["SourceGeometry"]
|
|
||||||
},
|
|
||||||
"PositionBinning": {
|
|
||||||
"CreateSameAs": [
|
|
||||||
"GlobalPositionBinning"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"Boundary": {
|
|
||||||
"Top": {
|
|
||||||
"type": "neumann",
|
|
||||||
"value": 0
|
|
||||||
},
|
|
||||||
"Bottom": {
|
|
||||||
"type": "dirichlet",
|
|
||||||
"value": 0
|
|
||||||
},
|
|
||||||
"Hull": {
|
|
||||||
"type": "dirichlet",
|
|
||||||
"value": 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"TargetAccuracy": 1e-6,
|
|
||||||
"NumCycles": 2e4,
|
|
||||||
"DoSolver": "true"
|
|
||||||
},
|
|
||||||
"Simulation": {
|
|
||||||
"SimulatedEvents": 200000,
|
|
||||||
"EventStride": 5000,
|
|
||||||
"TimeResolutionEvents": 20000,
|
|
||||||
"commentTimeRes": "number of events over all cpus defining the timeresolution"
|
|
||||||
},
|
|
||||||
"Output": {
|
|
||||||
"folder": "output",
|
|
||||||
"filename": "timerestest3",
|
|
||||||
"DensityFields": {
|
|
||||||
"Species": "all",
|
|
||||||
"Intervall": 1,
|
|
||||||
"OverwriteLast": "false"
|
|
||||||
},
|
|
||||||
"CurrentBorders": {
|
|
||||||
"Species": [
|
|
||||||
"e-",
|
|
||||||
"T+"
|
|
||||||
],
|
|
||||||
"Intervall": "EachSync",
|
|
||||||
"OverwriteLast": "false"
|
|
||||||
},
|
|
||||||
"DeletionLogger": {
|
|
||||||
"Species": "all",
|
|
||||||
"Intervall": "EachSync",
|
|
||||||
"OverwriteLast": "false"
|
|
||||||
},
|
|
||||||
"PoissonSolver": {
|
|
||||||
"Intervall": "EachSync",
|
|
||||||
"OverwriteLast": "false"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"RandomNumbers": {
|
|
||||||
"Seed": 1337
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,7 +4,6 @@
|
|||||||
#include <hdf5_hl.h>
|
#include <hdf5_hl.h>
|
||||||
|
|
||||||
#include "simulation/errors.h"
|
#include "simulation/errors.h"
|
||||||
#include "constants/sim_constants.h"
|
|
||||||
|
|
||||||
Hdf5Reader::Hdf5Reader(std::string directory, std::string filename)
|
Hdf5Reader::Hdf5Reader(std::string directory, std::string filename)
|
||||||
: absolute_filename_((directory + "/" + filename + ".h5").c_str()) {}
|
: absolute_filename_((directory + "/" + filename + ".h5").c_str()) {}
|
||||||
@@ -101,265 +100,3 @@ blitz::Array<double, 1> Hdf5Reader::readD1Double(std::string path) {
|
|||||||
H5Fclose(file);
|
H5Fclose(file);
|
||||||
return data.copy();
|
return data.copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
double Hdf5Reader::readDouble(std::string path) {
|
|
||||||
hid_t file = H5Fopen(absolute_filename_.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
|
|
||||||
|
|
||||||
// H5Eset_auto(H5E_DEFAULT, NULL, NULL);
|
|
||||||
hid_t dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
|
|
||||||
hid_t dataspace = H5Dget_space(dataset);
|
|
||||||
if (dataset < 0) {
|
|
||||||
ERROR("The given dataset could not be opened");
|
|
||||||
}
|
|
||||||
// turn error report back onby hdf5 because of check H5Dopen2
|
|
||||||
// H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
|
|
||||||
|
|
||||||
const int ndims = H5Sget_simple_extent_ndims(dataspace);
|
|
||||||
hsize_t dims[ndims];
|
|
||||||
if (ndims != 1) {
|
|
||||||
ERROR("The given dataset is not one dimensional. It has dims: " + ndims);
|
|
||||||
}
|
|
||||||
H5Sget_simple_extent_dims(dataspace, dims, NULL);
|
|
||||||
|
|
||||||
double data;
|
|
||||||
|
|
||||||
H5Dread(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT,
|
|
||||||
&data);
|
|
||||||
|
|
||||||
H5Sclose(dataspace);
|
|
||||||
H5Dclose(dataset);
|
|
||||||
H5Fclose(file);
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Hdf5Reader::readInt(std::string path) {
|
|
||||||
hid_t file = H5Fopen(absolute_filename_.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
|
|
||||||
|
|
||||||
// H5Eset_auto(H5E_DEFAULT, NULL, NULL);
|
|
||||||
hid_t dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
|
|
||||||
hid_t dataspace = H5Dget_space(dataset);
|
|
||||||
if (dataset < 0) {
|
|
||||||
ERROR("The given dataset could not be opened");
|
|
||||||
}
|
|
||||||
// turn error report back onby hdf5 because of check H5Dopen2
|
|
||||||
// H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
|
|
||||||
|
|
||||||
const int ndims = H5Sget_simple_extent_ndims(dataspace);
|
|
||||||
hsize_t dims[ndims];
|
|
||||||
if (ndims != 1) {
|
|
||||||
ERROR("The given dataset is not one dimensional. It has dims: " + ndims);
|
|
||||||
}
|
|
||||||
H5Sget_simple_extent_dims(dataspace, dims, NULL);
|
|
||||||
|
|
||||||
int data;
|
|
||||||
|
|
||||||
H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
|
|
||||||
&data);
|
|
||||||
|
|
||||||
H5Sclose(dataspace);
|
|
||||||
H5Dclose(dataset);
|
|
||||||
H5Fclose(file);
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
blitz::Array<double, 4> Hdf5Reader::readD4Double(std::string path) {
|
|
||||||
hid_t file = H5Fopen(absolute_filename_.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
|
|
||||||
|
|
||||||
H5Eset_auto(H5E_DEFAULT, NULL, NULL);
|
|
||||||
hid_t dataset;
|
|
||||||
dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
|
|
||||||
hid_t dataspace = H5Dget_space(dataset);
|
|
||||||
if (dataset < 0) {
|
|
||||||
ERROR("The given dataset could not be opened");
|
|
||||||
}
|
|
||||||
// turn error report back onby hdf5 because of check H5Dopen2
|
|
||||||
H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
|
|
||||||
|
|
||||||
const int ndims = H5Sget_simple_extent_ndims(dataspace);
|
|
||||||
hsize_t dims[ndims];
|
|
||||||
if (ndims != 4) {
|
|
||||||
ERROR("The given dataset is not four-dimensional. It has dims: " + ndims);
|
|
||||||
}
|
|
||||||
H5Sget_simple_extent_dims(dataspace, dims, NULL);
|
|
||||||
|
|
||||||
blitz::Array<double, 4> data(dims[0], dims[1], dims[2], dims[3]);
|
|
||||||
|
|
||||||
H5Dread(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT,
|
|
||||||
data.data());
|
|
||||||
|
|
||||||
H5Dclose(dataset);
|
|
||||||
H5Fclose(file);
|
|
||||||
return data.copy();
|
|
||||||
}
|
|
||||||
|
|
||||||
blitz::Array<double, 5> Hdf5Reader::readD5Double(std::string path) {
|
|
||||||
hid_t file = H5Fopen(absolute_filename_.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
|
|
||||||
|
|
||||||
H5Eset_auto(H5E_DEFAULT, NULL, NULL);
|
|
||||||
hid_t dataset;
|
|
||||||
dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
|
|
||||||
hid_t dataspace = H5Dget_space(dataset);
|
|
||||||
if (dataset < 0) {
|
|
||||||
ERROR("The given dataset could not be opened");
|
|
||||||
}
|
|
||||||
// turn error report back onby hdf5 because of check H5Dopen2
|
|
||||||
H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
|
|
||||||
|
|
||||||
const int ndims = H5Sget_simple_extent_ndims(dataspace);
|
|
||||||
hsize_t dims[ndims];
|
|
||||||
if (ndims != 5) {
|
|
||||||
ERROR("The given dataset is not five-dimensional. It has dims: " + ndims);
|
|
||||||
}
|
|
||||||
H5Sget_simple_extent_dims(dataspace, dims, NULL);
|
|
||||||
|
|
||||||
blitz::Array<double, 5> data(dims[0], dims[1], dims[2], dims[3], dims[4]);
|
|
||||||
|
|
||||||
H5Dread(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT,
|
|
||||||
data.data());
|
|
||||||
|
|
||||||
H5Dclose(dataset);
|
|
||||||
H5Fclose(file);
|
|
||||||
return data.copy();
|
|
||||||
}
|
|
||||||
|
|
||||||
blitz::Array<long int, 4> Hdf5Reader::readD4LongInt(std::string path) {
|
|
||||||
hid_t file = H5Fopen(absolute_filename_.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
|
|
||||||
|
|
||||||
H5Eset_auto(H5E_DEFAULT, NULL, NULL);
|
|
||||||
hid_t dataset;
|
|
||||||
dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
|
|
||||||
hid_t dataspace = H5Dget_space(dataset);
|
|
||||||
if (dataset < 0) {
|
|
||||||
ERROR("The given dataset could not be opened");
|
|
||||||
}
|
|
||||||
// turn error report back onby hdf5 because of check H5Dopen2
|
|
||||||
H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
|
|
||||||
|
|
||||||
const int ndims = H5Sget_simple_extent_ndims(dataspace);
|
|
||||||
hsize_t dims[ndims];
|
|
||||||
if (ndims != 4) {
|
|
||||||
ERROR("The given dataset is not four-dimensional. It has dims: " + ndims);
|
|
||||||
}
|
|
||||||
H5Sget_simple_extent_dims(dataspace, dims, NULL);
|
|
||||||
|
|
||||||
blitz::Array<long int, 4> data(dims[0], dims[1], dims[2], dims[3]);
|
|
||||||
|
|
||||||
H5Dread(dataset, H5T_NATIVE_LONG, H5S_ALL, H5S_ALL, H5P_DEFAULT,
|
|
||||||
data.data());
|
|
||||||
|
|
||||||
H5Dclose(dataset);
|
|
||||||
H5Fclose(file);
|
|
||||||
return data.copy();
|
|
||||||
}
|
|
||||||
|
|
||||||
blitz::Array<long int, 5> Hdf5Reader::readD5LongInt(std::string path) {
|
|
||||||
hid_t file = H5Fopen(absolute_filename_.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
|
|
||||||
|
|
||||||
H5Eset_auto(H5E_DEFAULT, NULL, NULL);
|
|
||||||
hid_t dataset;
|
|
||||||
dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
|
|
||||||
hid_t dataspace = H5Dget_space(dataset);
|
|
||||||
if (dataset < 0) {
|
|
||||||
ERROR("The given dataset could not be opened");
|
|
||||||
}
|
|
||||||
// turn error report back onby hdf5 because of check H5Dopen2
|
|
||||||
H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
|
|
||||||
|
|
||||||
const int ndims = H5Sget_simple_extent_ndims(dataspace);
|
|
||||||
hsize_t dims[ndims];
|
|
||||||
if (ndims != 5) {
|
|
||||||
ERROR("The given dataset is not five-dimensional. It has dims: " + ndims);
|
|
||||||
}
|
|
||||||
H5Sget_simple_extent_dims(dataspace, dims, NULL);
|
|
||||||
|
|
||||||
blitz::Array<long int, 5> data(dims[0], dims[1], dims[2], dims[3], dims[4]);
|
|
||||||
|
|
||||||
H5Dread(dataset, H5T_NATIVE_LONG, H5S_ALL, H5S_ALL, H5P_DEFAULT,
|
|
||||||
data.data());
|
|
||||||
|
|
||||||
H5Dclose(dataset);
|
|
||||||
H5Fclose(file);
|
|
||||||
return data.copy();
|
|
||||||
}
|
|
||||||
|
|
||||||
// reads the engine stringstream with the correct size from the file, such that it should be able
|
|
||||||
// to be used for the initialization of the random engine without any further modification
|
|
||||||
// path has to only be the path to the group that contains the two dataset "string" and "length"
|
|
||||||
std::stringstream Hdf5Reader::readEngineString(std::string path) {
|
|
||||||
std::stringstream out;
|
|
||||||
hid_t file = H5Fopen(absolute_filename_.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
|
|
||||||
|
|
||||||
// H5Eset_auto(H5E_DEFAULT, NULL, NULL);
|
|
||||||
hid_t dataset = H5Dopen2(file, (path + "/string").c_str(), H5P_DEFAULT);
|
|
||||||
hid_t dataspace = H5Dget_space(dataset);
|
|
||||||
if (dataset < 0) {
|
|
||||||
ERROR("The given dataset could not be opened");
|
|
||||||
}
|
|
||||||
// turn error report back onby hdf5 because of check H5Dopen2
|
|
||||||
// H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
|
|
||||||
// might be beneficial to check if the datatype
|
|
||||||
// is the expected one (H5T_STRING)
|
|
||||||
hid_t dtype = H5Dget_type(dataset);
|
|
||||||
size_t size = H5Tget_size(dtype);
|
|
||||||
|
|
||||||
if(size != SimConstants::engine_string_length_max) {
|
|
||||||
ERROR("Size of the string is not the required size of " +
|
|
||||||
std::to_string(SimConstants::engine_string_length_max) +
|
|
||||||
", size of string: " + std::to_string(size));
|
|
||||||
}
|
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("RestartInfo: " + std::to_string(H5Tdetect_class(dtype, H5T_STRING)));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const int ndims = H5Sget_simple_extent_ndims(dataspace);
|
|
||||||
hsize_t dims[ndims];
|
|
||||||
if (ndims != 1) {
|
|
||||||
ERROR("The given dataset is not one dimensional. It has dims: " + ndims);
|
|
||||||
}
|
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3(std::to_string(ndims));
|
|
||||||
DEBUG_LEVEL_3("RestartInfo: " + std::to_string(size));
|
|
||||||
#endif
|
|
||||||
H5Sget_simple_extent_dims(dataspace, dims, NULL);
|
|
||||||
|
|
||||||
char data[SimConstants::engine_string_length_max];
|
|
||||||
H5Dread(dataset, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT,
|
|
||||||
&data);
|
|
||||||
|
|
||||||
H5Tclose(dtype);
|
|
||||||
H5Sclose(dataspace);
|
|
||||||
H5Dclose(dataset);
|
|
||||||
|
|
||||||
dataset = H5Dopen2(file, (path + "/length").c_str(), H5P_DEFAULT);
|
|
||||||
dataspace = H5Dget_space(dataset);
|
|
||||||
if(dataspace < 0) {
|
|
||||||
ERROR("Dataspace for length could not be opened");
|
|
||||||
}
|
|
||||||
|
|
||||||
const int ndimsL = H5Sget_simple_extent_ndims(dataspace);
|
|
||||||
hsize_t dimsL[ndimsL];
|
|
||||||
if(ndimsL != 1) {
|
|
||||||
ERROR("length dataset is not 1-dimensional");
|
|
||||||
}
|
|
||||||
H5Sget_simple_extent_dims(dataspace, dimsL, NULL);
|
|
||||||
|
|
||||||
size_t length;
|
|
||||||
H5Dread(dataset, H5T_NATIVE_HSIZE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &length);
|
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("RestartInfo: read length from file: " + std::to_string(length));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
H5Sclose(dataspace);
|
|
||||||
H5Dclose(dataset);
|
|
||||||
|
|
||||||
H5Fclose(file);
|
|
||||||
|
|
||||||
std::stringstream temp;
|
|
||||||
temp << data;
|
|
||||||
out << temp.str().substr(0, length);
|
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3(std::to_string(out.str().size()));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
@@ -4,8 +4,6 @@
|
|||||||
#include <hdf5_hl.h>
|
#include <hdf5_hl.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "simulation/errors.h"
|
|
||||||
#include "constants/sim_constants.h"
|
|
||||||
|
|
||||||
#include "simulation/mpi_communication.h"
|
#include "simulation/mpi_communication.h"
|
||||||
|
|
||||||
@@ -23,7 +21,6 @@ void Hdf5Writer::createFile(std::string absolute_filename) {
|
|||||||
if (MpiCommunication::mpi_rank == 0) {
|
if (MpiCommunication::mpi_rank == 0) {
|
||||||
hid_t file = H5Fcreate(absolute_filename.c_str(), H5F_ACC_TRUNC,
|
hid_t file = H5Fcreate(absolute_filename.c_str(), H5F_ACC_TRUNC,
|
||||||
H5P_DEFAULT, H5P_DEFAULT);
|
H5P_DEFAULT, H5P_DEFAULT);
|
||||||
H5Fclose(file);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,38 +162,6 @@ void Hdf5Writer::write(const blitz::Array<double, 4>& data, std::string path) {
|
|||||||
H5Fclose(file);
|
H5Fclose(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hdf5Writer::write(const blitz::Array<double, 5>& data, std::string path) {
|
|
||||||
hid_t file = H5Fopen(absolute_filename_.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
|
|
||||||
|
|
||||||
blitz::TinyVector<int, 5> size = data.extent();
|
|
||||||
blitz::TinyVector<int, 5> start(0, 0, 0, 0, 0);
|
|
||||||
|
|
||||||
hid_t filespace =
|
|
||||||
H5Screate_simple(5, blitz::TinyVector<hsize_t, 5>(size).data(), NULL);
|
|
||||||
|
|
||||||
hid_t lcpl = H5Pcreate(H5P_LINK_CREATE);
|
|
||||||
H5Pset_create_intermediate_group(lcpl, 1);
|
|
||||||
|
|
||||||
// turn of error report by hdf5 because of check H5Dopen2
|
|
||||||
H5Eset_auto(H5E_DEFAULT, NULL, NULL);
|
|
||||||
hid_t dataset;
|
|
||||||
dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
|
|
||||||
if (dataset < 0) {
|
|
||||||
dataset = H5Dcreate2(file, path.c_str(), H5T_NATIVE_DOUBLE, filespace, lcpl,
|
|
||||||
H5P_DEFAULT, H5P_DEFAULT);
|
|
||||||
}
|
|
||||||
// turn error report back onby hdf5 because of check H5Dopen2
|
|
||||||
H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
|
|
||||||
|
|
||||||
H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, filespace, H5P_DEFAULT,
|
|
||||||
data.data());
|
|
||||||
|
|
||||||
H5Dclose(dataset);
|
|
||||||
H5Pclose(lcpl);
|
|
||||||
H5Sclose(filespace);
|
|
||||||
H5Fclose(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Hdf5Writer::write(const blitz::Array<long int, 4>& data,
|
void Hdf5Writer::write(const blitz::Array<long int, 4>& data,
|
||||||
std::string path) {
|
std::string path) {
|
||||||
hid_t file = H5Fopen(absolute_filename_.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
|
hid_t file = H5Fopen(absolute_filename_.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
|
||||||
@@ -230,39 +195,6 @@ void Hdf5Writer::write(const blitz::Array<long int, 4>& data,
|
|||||||
H5Fclose(file);
|
H5Fclose(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hdf5Writer::write(const blitz::Array<long int, 5>& data,
|
|
||||||
std::string path) {
|
|
||||||
hid_t file = H5Fopen(absolute_filename_.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
|
|
||||||
|
|
||||||
blitz::TinyVector<int, 5> size = data.extent();
|
|
||||||
blitz::TinyVector<int, 5> start(0, 0, 0, 0, 0);
|
|
||||||
|
|
||||||
hid_t filespace =
|
|
||||||
H5Screate_simple(5, blitz::TinyVector<hsize_t, 5>(size).data(), NULL);
|
|
||||||
|
|
||||||
hid_t lcpl = H5Pcreate(H5P_LINK_CREATE);
|
|
||||||
H5Pset_create_intermediate_group(lcpl, 1);
|
|
||||||
|
|
||||||
// turn of error report by hdf5 because of check H5Dopen2
|
|
||||||
H5Eset_auto(H5E_DEFAULT, NULL, NULL);
|
|
||||||
hid_t dataset;
|
|
||||||
dataset = H5Dopen2(file, path.c_str(), H5P_DEFAULT);
|
|
||||||
if (dataset < 0) {
|
|
||||||
dataset = H5Dcreate2(file, path.c_str(), H5T_NATIVE_LONG, filespace, lcpl,
|
|
||||||
H5P_DEFAULT, H5P_DEFAULT);
|
|
||||||
}
|
|
||||||
// turn error report back onby hdf5 because of check H5Dopen2
|
|
||||||
H5Eset_auto(H5E_DEFAULT, H5E_DEFAULT, H5E_DEFAULT);
|
|
||||||
|
|
||||||
H5Dwrite(dataset, H5T_NATIVE_LONG, H5S_ALL, H5S_ALL, H5P_DEFAULT,
|
|
||||||
data.data());
|
|
||||||
|
|
||||||
H5Dclose(dataset);
|
|
||||||
H5Pclose(lcpl);
|
|
||||||
H5Sclose(filespace);
|
|
||||||
H5Fclose(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Hdf5Writer::write(const blitz::TinyVector<double, 3>& data,
|
void Hdf5Writer::write(const blitz::TinyVector<double, 3>& data,
|
||||||
std::string path) {
|
std::string path) {
|
||||||
hid_t file = H5Fopen(absolute_filename_.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
|
hid_t file = H5Fopen(absolute_filename_.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
|
||||||
@@ -455,8 +387,6 @@ void Hdf5Writer::write(const std::string& data, std::string path) {
|
|||||||
|
|
||||||
hid_t dtype;
|
hid_t dtype;
|
||||||
dtype = H5Tcreate(H5T_STRING, data.size());
|
dtype = H5Tcreate(H5T_STRING, data.size());
|
||||||
// see:https://stackoverflow.com/questions/581209/how-to-best-write-out-a-stdvector-stdstring-container-to-a-hdf5-dataset
|
|
||||||
// for the way to create a variable length dtype and how to write it
|
|
||||||
|
|
||||||
// turn of error report by hdf5 because of check H5Dopen2
|
// turn of error report by hdf5 because of check H5Dopen2
|
||||||
H5Eset_auto(H5E_DEFAULT, NULL, NULL);
|
H5Eset_auto(H5E_DEFAULT, NULL, NULL);
|
||||||
@@ -472,121 +402,7 @@ void Hdf5Writer::write(const std::string& data, std::string path) {
|
|||||||
H5Dwrite(dataset, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, data.c_str());
|
H5Dwrite(dataset, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, data.c_str());
|
||||||
|
|
||||||
H5Dclose(dataset);
|
H5Dclose(dataset);
|
||||||
H5Tclose(dtype);
|
|
||||||
H5Pclose(lcpl);
|
H5Pclose(lcpl);
|
||||||
H5Sclose(filespace);
|
H5Sclose(filespace);
|
||||||
H5Fclose(file);
|
H5Fclose(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
// maybe split into a function that writes a string in parallel and one that writes an
|
|
||||||
// int in parallel. Would be a bit more effort but it would be more consistent with the
|
|
||||||
// way the rest of the writer functions work
|
|
||||||
|
|
||||||
// writes a string-representation of an random numbers engine (right now assumed mt19973)
|
|
||||||
// written output: input string padded with 0 at the end to achieve a fixed length
|
|
||||||
// and the size of the input string
|
|
||||||
void Hdf5Writer::writeRNG(const std::string& data, std::string path_base) {
|
|
||||||
/*
|
|
||||||
* Note:
|
|
||||||
* Writing the string representation of the std::mt19973 engine might not be the best option.
|
|
||||||
* (see comment for statStringSizeMax_ in hdf5_writer.h)
|
|
||||||
* The potential issues are: de-serialization using '>>' not platform independent (i.e. can not be
|
|
||||||
* restarted), length of the max size uncertain, relatively large storage space usage (>6370 bytes/cpu/output)
|
|
||||||
* (comparision: HAWK: size of file ~ 3.4MB/sync, RestartInfo Size (estimate) ~ 81MB/sync (12800 procs))
|
|
||||||
*
|
|
||||||
* Second option: wrapper for the engine and count the times its been used and store that number.
|
|
||||||
* Also has an issue with restarts on a different platform (since engine implementation is platform dependent).
|
|
||||||
* Signigicantly lower storage space usage. Restoring the engine state would easy in implementation
|
|
||||||
* (potentially a bit more expensive in execution time: discard() function).
|
|
||||||
*/
|
|
||||||
|
|
||||||
MPI_Info info;
|
|
||||||
MPI_Info_create(&info);
|
|
||||||
hid_t fapl = H5Pcreate(H5P_FILE_ACCESS);
|
|
||||||
H5Pset_fapl_mpio(fapl, MPI_COMM_WORLD, info);
|
|
||||||
// MPI_Info_free(&info);
|
|
||||||
|
|
||||||
hid_t file = H5Fopen(absolute_filename_.c_str(), H5F_ACC_RDWR, fapl);
|
|
||||||
|
|
||||||
if(file < 0) {
|
|
||||||
SIM_INFO("file could not be opened");
|
|
||||||
}
|
|
||||||
hsize_t scalar = 1;
|
|
||||||
hid_t filespace = H5Screate_simple(1, &scalar, NULL);
|
|
||||||
|
|
||||||
hid_t lcpl = H5Pcreate(H5P_LINK_CREATE);
|
|
||||||
H5Pset_create_intermediate_group(lcpl, 1);
|
|
||||||
|
|
||||||
int mpi_rank = MpiCommunication::mpi_rank;
|
|
||||||
std::string out{data};
|
|
||||||
|
|
||||||
size_t stateStringSize = out.size();
|
|
||||||
|
|
||||||
if(stateStringSize > SimConstants::engine_string_length_max) {
|
|
||||||
ERROR("Max Size (" + std::to_string(SimConstants::engine_string_length_max) + ") too small. String size: " + std::to_string(stateStringSize));
|
|
||||||
}
|
|
||||||
|
|
||||||
out.insert(out.end(), (SimConstants::engine_string_length_max - stateStringSize), '0');
|
|
||||||
|
|
||||||
// apparently it's not possible to use 'H5T_VARIABLE' with the MPI-I/O file driver
|
|
||||||
// (since it doesn't allow for variable size objects to be created, see: https://davis.lbl.gov/Manuals/HDF5-1.8.7/TechNotes/VLTypes.html)
|
|
||||||
hid_t dtype = H5Tcreate(H5T_STRING, SimConstants::engine_string_length_max);
|
|
||||||
|
|
||||||
// store old error stack info
|
|
||||||
H5E_auto2_t oldfunc;
|
|
||||||
void* old_client_data;
|
|
||||||
H5Eget_auto2(H5E_DEFAULT, &oldfunc, &old_client_data);
|
|
||||||
|
|
||||||
// turn of error report by hdf5 because of check H5Dopen2
|
|
||||||
H5Eset_auto(H5E_DEFAULT, NULL, NULL);
|
|
||||||
|
|
||||||
for(int i = 0; i < MpiCommunication::mpi_size; ++i) {
|
|
||||||
std::string path = path_base + std::to_string(i);
|
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3(path);
|
|
||||||
#endif
|
|
||||||
hid_t dataset_string = H5Dcreate2(file, (path + "/string").c_str(), dtype, filespace, lcpl, H5P_DEFAULT, H5P_DEFAULT);
|
|
||||||
// this sadly seems to be the option that takes the least amount of effort.
|
|
||||||
// H5Lexits() would be an option but (!) each group would need to be checked for existance first, which sucks
|
|
||||||
if(dataset_string < 0) {
|
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("Dataset could not be created");
|
|
||||||
#endif
|
|
||||||
dataset_string = H5Dopen2(file, (path + "/string").c_str(), H5P_DEFAULT);
|
|
||||||
if(dataset_string < 0) {
|
|
||||||
ERROR("Dataset for string can neither be created nor opened");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
hid_t dataset_length = H5Dcreate2(file, (path + "/length").c_str(), H5T_NATIVE_HSIZE, filespace, lcpl, H5P_DEFAULT, H5P_DEFAULT);
|
|
||||||
if(dataset_length < 0) {
|
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("Dataset could not be created");
|
|
||||||
#endif
|
|
||||||
dataset_length = H5Dopen2(file, (path + "/length").c_str(), H5P_DEFAULT);
|
|
||||||
if(dataset_length < 0) {
|
|
||||||
ERROR("Dataset for length can neither be created nor opened");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(i == mpi_rank) {
|
|
||||||
H5Dwrite(dataset_string, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, out.c_str());
|
|
||||||
H5Dwrite(dataset_length, H5T_NATIVE_HSIZE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &stateStringSize);
|
|
||||||
}
|
|
||||||
H5Dclose(dataset_string);
|
|
||||||
H5Dclose(dataset_length);
|
|
||||||
}
|
|
||||||
// turn error report back onby hdf5 because of check H5Dopen2
|
|
||||||
H5Eset_auto(H5E_DEFAULT, oldfunc, old_client_data);
|
|
||||||
|
|
||||||
H5Tclose(dtype);
|
|
||||||
H5Pclose(lcpl);
|
|
||||||
H5Sclose(filespace);
|
|
||||||
H5Fclose(file);
|
|
||||||
H5Pclose(fapl);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Debug utility
|
|
||||||
std::string Hdf5Writer::AbsoluteFileName() const {
|
|
||||||
return absolute_filename_;
|
|
||||||
}
|
|
||||||
@@ -1,147 +0,0 @@
|
|||||||
#include "IO/mpi_particle_reader.h"
|
|
||||||
#include "IO/mpi_particle_format.h"
|
|
||||||
#include "simulation/mpi_communication.h"
|
|
||||||
#include "simulation/particle.h"
|
|
||||||
|
|
||||||
#include "mpi.h"
|
|
||||||
|
|
||||||
// filename has to NOT include the ".mpi" component!
|
|
||||||
MpiParticleReader::MpiParticleReader(std::string directory, std::string filename,
|
|
||||||
int restart_at):
|
|
||||||
absolute_filename_(directory + "/" + filename + "-CPUSync-"
|
|
||||||
+ std::to_string(restart_at) + ".mpi") {}
|
|
||||||
|
|
||||||
MpiParticleReader::MpiParticleReader(std::string absolute_filename):
|
|
||||||
absolute_filename_(absolute_filename) {}
|
|
||||||
|
|
||||||
MpiParticleReader::MpiParticleReader(std::string abs_filename_without_extension,
|
|
||||||
int restart_at):
|
|
||||||
absolute_filename_(abs_filename_without_extension + "-CPUSync-" +
|
|
||||||
std::to_string(restart_at) + ".mpi") {}
|
|
||||||
|
|
||||||
void MpiParticleReader::readParticles(
|
|
||||||
std::vector<particle::SerializedParticle>& storage_queue) {
|
|
||||||
MPI_Comm io_comm;
|
|
||||||
int io_rank;
|
|
||||||
|
|
||||||
io_comm = MPI_COMM_WORLD;
|
|
||||||
io_rank = MpiCommunication::mpiRank();
|
|
||||||
|
|
||||||
#ifdef debug
|
|
||||||
DEBUG_LEVEL_0("Reading particles from: " + absolute_filename_);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int status;
|
|
||||||
|
|
||||||
MPI_Datatype particle_type;
|
|
||||||
if(sizeof(particle::SerializedParticle) % sizeof(double) != 0) {
|
|
||||||
ERROR("Size of SerializedParticle is not a multiple of the size of double!");
|
|
||||||
}
|
|
||||||
status = MPI_Type_contiguous(sizeof(particle::SerializedParticle)/sizeof(double),
|
|
||||||
MPI_DOUBLE, &particle_type);
|
|
||||||
status |= MPI_Type_commit(&particle_type);
|
|
||||||
|
|
||||||
if(status) {
|
|
||||||
ERROR("Particle data type could not be defined!");
|
|
||||||
}
|
|
||||||
|
|
||||||
MPI_Info info;
|
|
||||||
MPI_Info_create(&info);
|
|
||||||
|
|
||||||
// open file
|
|
||||||
MPI_File file;
|
|
||||||
MPI_Status mstatus;
|
|
||||||
|
|
||||||
#if defined(debug_level1) || defined(debug_level2) || defined(debug_level3)
|
|
||||||
DEBUG_LEVEL_1("Reading particles from: " + absolute_filename_);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
status = MPI_File_open(io_comm, (char*)absolute_filename_.c_str(),
|
|
||||||
MPI_MODE_RDONLY, info, &file);
|
|
||||||
if(status) {
|
|
||||||
ERROR("Particle file \'" + absolute_filename_ + "\' could not be opened!");
|
|
||||||
}
|
|
||||||
|
|
||||||
//read file header
|
|
||||||
MPI_Datatype file_header_type = build_file_header_type();
|
|
||||||
mpi_io_header_t file_header;
|
|
||||||
status = MPI_File_set_view(file, 0, file_header_type, file_header_type,
|
|
||||||
(char*)"native", info);
|
|
||||||
if(status) {
|
|
||||||
ERROR("View for file header could not be set!");
|
|
||||||
}
|
|
||||||
|
|
||||||
status = MPI_File_read_all(file, &file_header, 1, file_header_type, &mstatus);
|
|
||||||
if(status) {
|
|
||||||
ERROR("File header could not be read (status: " + std::to_string(status) +
|
|
||||||
")!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!file_header.verify()) {
|
|
||||||
ERROR("File header does not verify!");
|
|
||||||
}
|
|
||||||
|
|
||||||
// read CPU header
|
|
||||||
std::uint64_t headeroffset = file_header.cpu_header_offset +
|
|
||||||
sizeof(cpu_header_t)*io_rank;
|
|
||||||
|
|
||||||
MPI_Datatype cpu_header_type = build_cpu_header_type();
|
|
||||||
cpu_header_t cpu_header;
|
|
||||||
|
|
||||||
status = MPI_File_set_view(file, headeroffset, cpu_header_type, cpu_header_type,
|
|
||||||
(char*)"native", info);
|
|
||||||
if(status) {
|
|
||||||
ERROR("File view for the CPU header could not be set!");
|
|
||||||
}
|
|
||||||
|
|
||||||
status = MPI_File_read_all(file, &cpu_header, 1, cpu_header_type, &mstatus);
|
|
||||||
if(status) {
|
|
||||||
ERROR("CPU header could not be read!");
|
|
||||||
}
|
|
||||||
|
|
||||||
storage_queue.reserve(cpu_header.num_particles);
|
|
||||||
#if defined(debug_level1)
|
|
||||||
{
|
|
||||||
std::stringstream out;
|
|
||||||
out << io_rank << ": trying to read " << cpu_header.num_particles;
|
|
||||||
out << " many particles";
|
|
||||||
DEBUG_LEVEL_1(out.str());
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// set file view to the part where the particles are stored
|
|
||||||
status = MPI_File_set_view(file, cpu_header.file_offset, MPI_DOUBLE,
|
|
||||||
particle_type, (char*)"native", info);
|
|
||||||
if(status) {
|
|
||||||
ERROR("File view for the Particles could not be set!");
|
|
||||||
}
|
|
||||||
|
|
||||||
storage_queue.resize(cpu_header.num_particles);
|
|
||||||
|
|
||||||
// read the particles
|
|
||||||
status = MPI_File_read_all(file, storage_queue.data(), cpu_header.num_particles,
|
|
||||||
particle_type, &mstatus);
|
|
||||||
if(status) {
|
|
||||||
ERROR("Particles could not be read (status: " + std::to_string(status) +
|
|
||||||
")!");
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef debug_level1
|
|
||||||
{
|
|
||||||
std::stringstream out;
|
|
||||||
out << io_rank << ": number of particles in queue: " << storage_queue.size();
|
|
||||||
out << "\nposition of first serialized particle: " << storage_queue[0].cartesianPosition();
|
|
||||||
out << "\nvelocity of first serialized particle: " << storage_queue[0].cartesianVelocity();
|
|
||||||
out << "\nweight of first serialized particle: " << storage_queue[0].weight();
|
|
||||||
out << "\nspecname of first serialized particle: " << storage_queue[0].specieName();
|
|
||||||
DEBUG_LEVEL_1(out.str());
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// close everything
|
|
||||||
MPI_File_close(&file);
|
|
||||||
MPI_Type_free(&particle_type);
|
|
||||||
MPI_Type_free(&file_header_type);
|
|
||||||
MPI_Type_free(&cpu_header_type);
|
|
||||||
MPI_Info_free(&info);
|
|
||||||
}
|
|
||||||
@@ -1,177 +0,0 @@
|
|||||||
#include <sys/stat.h>
|
|
||||||
|
|
||||||
#include "IO/mpi_particle_writer.h"
|
|
||||||
#include "IO/mpi_particle_format.h"
|
|
||||||
#include "simulation/particle.h"
|
|
||||||
#include "simulation/mpi_communication.h"
|
|
||||||
#include "simulation/errors.h"
|
|
||||||
|
|
||||||
|
|
||||||
void MpiParticleWriter::createFolder(std::string directory) {
|
|
||||||
mkdir(directory.c_str(), 0755);
|
|
||||||
}
|
|
||||||
|
|
||||||
MpiParticleWriter::MpiParticleWriter(std::string directory,
|
|
||||||
std::string filename,
|
|
||||||
int fs_blocksize) :
|
|
||||||
directory_(directory),
|
|
||||||
filename_(filename),
|
|
||||||
fs_blocksize_(fs_blocksize) {
|
|
||||||
createFolder(directory_);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MpiParticleWriter::output_particles(
|
|
||||||
std::vector<particle::SerializedParticle>& particles,
|
|
||||||
int cpu_sync, double dt) {
|
|
||||||
int status;
|
|
||||||
|
|
||||||
std::stringstream path;
|
|
||||||
path << directory_ << "/" << filename_ << "-CPUSync-" << cpu_sync << ".mpi";
|
|
||||||
|
|
||||||
int io_rank = MpiCommunication::mpiRank();
|
|
||||||
int total_procs = MpiCommunication::mpiSize();
|
|
||||||
MPI_Comm io_comm = MPI_COMM_WORLD;
|
|
||||||
|
|
||||||
#if defined(debug_level1) || defined(debug_level2) || defined(debug_level3)
|
|
||||||
DEBUG_LEVEL_1("Starting MPI particle output: " + path.str());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// size of headers
|
|
||||||
std::uint64_t file_header_size = pad_to_blocksize(sizeof(mpi_io_header_t),
|
|
||||||
fs_blocksize_);
|
|
||||||
std::uint64_t cpu_headers_size = pad_to_blocksize(file_header_size
|
|
||||||
+ sizeof(cpu_header_t) * total_procs, fs_blocksize_);
|
|
||||||
|
|
||||||
// commnicate the number of particles on all cpus
|
|
||||||
std::uint64_t* part_bytes_in = new uint64_t[total_procs];
|
|
||||||
std::uint64_t* part_bytes = new uint64_t[total_procs];
|
|
||||||
|
|
||||||
for(int i = 0; i < total_procs; i++) {
|
|
||||||
part_bytes_in[i] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
part_bytes_in[io_rank] = particles.size() * sizeof(particle::SerializedParticle);
|
|
||||||
part_bytes_in[io_rank] = pad_to_blocksize(part_bytes_in[io_rank], fs_blocksize_);
|
|
||||||
|
|
||||||
MPI_Allreduce(part_bytes_in, part_bytes, total_procs,
|
|
||||||
MPI_LONG_LONG, MPI_SUM, io_comm);
|
|
||||||
|
|
||||||
delete[] part_bytes_in;
|
|
||||||
|
|
||||||
// Calculate the offset from the prefix sum
|
|
||||||
std::uint64_t tmp = 0;
|
|
||||||
std::uint64_t prev = 0;
|
|
||||||
for(int i = 0; i < total_procs; i++) {
|
|
||||||
tmp += part_bytes[i];
|
|
||||||
part_bytes[i] = prev;
|
|
||||||
prev = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
// data type of a single particle
|
|
||||||
MPI_Datatype particle_type;
|
|
||||||
|
|
||||||
if(sizeof(particle::SerializedParticle) % sizeof(double) != 0) {
|
|
||||||
// since type is created as a set of MPI_DOUBLES
|
|
||||||
ERROR("Size of particle is not a multiple of the size of double!");
|
|
||||||
}
|
|
||||||
|
|
||||||
status = MPI_Type_contiguous(sizeof(particle::SerializedParticle)/sizeof(double),
|
|
||||||
MPI_DOUBLE, &particle_type);
|
|
||||||
status |= MPI_Type_commit(&particle_type);
|
|
||||||
if(status) {
|
|
||||||
delete[] part_bytes;
|
|
||||||
ERROR("Mpi particle data type could not be created!");
|
|
||||||
}
|
|
||||||
|
|
||||||
// enable collective buffering
|
|
||||||
MPI_Info info;
|
|
||||||
MpiCommunication::create_mpi_info(&info);
|
|
||||||
|
|
||||||
// open the file
|
|
||||||
MPI_File file;
|
|
||||||
MPI_Status mstatus;
|
|
||||||
#if defined(debug_level1) || defined(debug_level2) || defined(debug_level3)
|
|
||||||
DEBUG_LEVEL_1("Writing particles to " + path.str());
|
|
||||||
#endif
|
|
||||||
status = MPI_File_open(io_comm, (char*)path.str().c_str(),
|
|
||||||
MPI_MODE_WRONLY|MPI_MODE_CREATE, info, &file);
|
|
||||||
if(status) {
|
|
||||||
ERROR("File could not be opened or created! " + path.str());
|
|
||||||
}
|
|
||||||
|
|
||||||
// collectively write file header
|
|
||||||
MPI_Datatype file_header_type = build_file_header_type();
|
|
||||||
mpi_io_header_t file_header;
|
|
||||||
|
|
||||||
file_header.magic = ((std::uint64_t)'KA' << 32) + (uint64_t)'RL';
|
|
||||||
file_header.num_cpus = total_procs;
|
|
||||||
file_header.cpu_header_offset = file_header_size;
|
|
||||||
file_header.dt = dt;
|
|
||||||
|
|
||||||
status = MPI_File_set_view(file, 0, file_header_type, file_header_type,
|
|
||||||
(char*)"native", info);
|
|
||||||
if(status) {
|
|
||||||
ERROR("View for the file header could not be set!");
|
|
||||||
}
|
|
||||||
|
|
||||||
status = MPI_File_write_all(file, &file_header, 1, file_header_type, &mstatus);
|
|
||||||
if(status) {
|
|
||||||
ERROR("File header could not be written (status: " + std::to_string(status) + ")");
|
|
||||||
}
|
|
||||||
|
|
||||||
MPI_Type_free(&file_header_type);
|
|
||||||
|
|
||||||
// calculate where the header of this cpu starts
|
|
||||||
std::uint64_t headeroffset = file_header_size + sizeof(cpu_header_t)*io_rank;
|
|
||||||
|
|
||||||
// calcualte the offset to the data
|
|
||||||
std::uint64_t dataoffset = cpu_headers_size + part_bytes[io_rank];
|
|
||||||
|
|
||||||
// Write per-CPU header
|
|
||||||
cpu_header_t our_cpu_header;
|
|
||||||
our_cpu_header.num_particles = particles.size();
|
|
||||||
our_cpu_header.file_offset = dataoffset;
|
|
||||||
|
|
||||||
MPI_Datatype cpu_header_type = build_cpu_header_type();
|
|
||||||
|
|
||||||
int typesize;
|
|
||||||
MPI_Type_size(cpu_header_type, &typesize);
|
|
||||||
|
|
||||||
#if defined(debug_level1) || defined(debug_level2) || defined(debug_level3)
|
|
||||||
DEBUG_LEVEL_1("Rank " + std::to_string(io_rank) + " has its header at offset " +
|
|
||||||
std::to_string(headeroffset));
|
|
||||||
#endif
|
|
||||||
status = MPI_File_set_view(file, headeroffset, cpu_header_type, cpu_header_type,
|
|
||||||
(char*)"native", info);
|
|
||||||
if(status) {
|
|
||||||
ERROR("File view for the cpu header could not be set!");
|
|
||||||
}
|
|
||||||
|
|
||||||
status = MPI_File_write_all(file, &our_cpu_header, 1, cpu_header_type, &mstatus);
|
|
||||||
if(status) {
|
|
||||||
ERROR("Cpu header could not be written!");
|
|
||||||
}
|
|
||||||
|
|
||||||
// set file view for the particles
|
|
||||||
// the offset is the offset of all headers plus the particles of all prior CPUs
|
|
||||||
status = MPI_File_set_view(file, dataoffset, MPI_DOUBLE, particle_type,
|
|
||||||
(char*)"native", info);
|
|
||||||
if(status) {
|
|
||||||
delete[] part_bytes;
|
|
||||||
ERROR("File view for the particles could not be set!");
|
|
||||||
}
|
|
||||||
|
|
||||||
// dump all particles like they are in memory
|
|
||||||
status = MPI_File_write_all(file, particles.data(), particles.size(),
|
|
||||||
particle_type, &mstatus);
|
|
||||||
if(status) {
|
|
||||||
ERROR("Particles could not be written! status: " + std::to_string(status));
|
|
||||||
}
|
|
||||||
|
|
||||||
// close everything
|
|
||||||
delete[] part_bytes;
|
|
||||||
MPI_File_close(&file);
|
|
||||||
MPI_Type_free(&particle_type);
|
|
||||||
MPI_Type_free(&cpu_header_type);
|
|
||||||
MPI_Info_free(&info);
|
|
||||||
}
|
|
||||||
@@ -1,173 +0,0 @@
|
|||||||
#include <sstream>
|
|
||||||
#include <random>
|
|
||||||
|
|
||||||
#include "IO/restart.h"
|
|
||||||
#include "simulation/random_numbers.h"
|
|
||||||
#include "simulation/mpi_communication.h"
|
|
||||||
#include "simulation/errors.h"
|
|
||||||
#include "simulation/species.h"
|
|
||||||
#include "simulation/density_field.h"
|
|
||||||
#include "poisson_solver/poisson_solver.h"
|
|
||||||
#include "simulation/timer.h"
|
|
||||||
#include "simulation/event_position_distribution.h"
|
|
||||||
|
|
||||||
// Note: error handling is a bit messy. Sometimes it's dealt with in the
|
|
||||||
// called reset function (e.g. in the density field) and sometimes it's
|
|
||||||
// handled here
|
|
||||||
|
|
||||||
// Restart::Restart(bool do_restart, std::string absolute_filename,
|
|
||||||
// std::string restart_identifier):
|
|
||||||
// do_restart_(do_restart),
|
|
||||||
// restart_identifier_(restart_identifier),
|
|
||||||
// reader_(Hdf5Reader(absolute_filename)) {}
|
|
||||||
|
|
||||||
Restart::Restart(bool do_restart, std::string absolute_filename_without_extension,
|
|
||||||
std::string restart_idenitfier, int particle_restart_at):
|
|
||||||
do_restart_(do_restart),
|
|
||||||
restart_identifier_(restart_idenitfier),
|
|
||||||
reader_(absolute_filename_without_extension + ".h5"),
|
|
||||||
particle_reader_(absolute_filename_without_extension,
|
|
||||||
particle_restart_at) {}
|
|
||||||
|
|
||||||
void Restart::restart(
|
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>& species,
|
|
||||||
PoissonSolver* poisson_solver,
|
|
||||||
RandomNumbers* random_numbers,
|
|
||||||
std::vector<particle::SerializedParticle>& storage_queue,
|
|
||||||
int& injectionGroupOffset) {
|
|
||||||
|
|
||||||
if(!do_restart_) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#ifdef debug_level1
|
|
||||||
DEBUG_LEVEL_1("Restarting rng");
|
|
||||||
#endif
|
|
||||||
restartRandomNumbers(random_numbers);
|
|
||||||
|
|
||||||
#ifdef debug_level1
|
|
||||||
DEBUG_LEVEL_1("Restarting poisson solver.");
|
|
||||||
#endif
|
|
||||||
restartPoissonSolver(poisson_solver);
|
|
||||||
|
|
||||||
#ifdef debug_level1
|
|
||||||
DEBUG_LEVEL_1("Restarting timer.");
|
|
||||||
#endif
|
|
||||||
restartTimer(species.begin()->second.get());
|
|
||||||
|
|
||||||
for(const auto& pair: species) {
|
|
||||||
std::string path = pair.second->name() + "/DensityField/SimulationData/" +
|
|
||||||
restart_identifier_;
|
|
||||||
restartDrawingDensityField(pair.second->dynamicDensityField(), path);
|
|
||||||
// pair.second->positionDistributionFromDensity()->setMaximumDensity();
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
std::string path = "/RestartInfo/" + restart_identifier_ + "/InjectionGroupOffset";
|
|
||||||
injectionGroupOffset = reader_.readInt(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(debug_level1) || defined(debug_level2) || defined(debug_level3)
|
|
||||||
DEBUG_LEVEL_1("Reloading particles.");
|
|
||||||
#endif
|
|
||||||
particle_reader_.readParticles(storage_queue);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Restart::restartRandomNumbers(RandomNumbers* random) {
|
|
||||||
std::string path = "/RestartInfo/" + restart_identifier_
|
|
||||||
+ "/CPU_" + std::to_string(MpiCommunication::mpiRank());
|
|
||||||
std::stringstream engine_state = reader_.readEngineString(path);
|
|
||||||
std::mt19937* engine = random->engine();
|
|
||||||
engine_state >> *engine;
|
|
||||||
|
|
||||||
std::stringstream check;
|
|
||||||
check << *engine;
|
|
||||||
|
|
||||||
if(check.str() != engine_state.str()) {
|
|
||||||
ERROR("Something went wrong in the initialization of the "
|
|
||||||
"random engine.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// only restart the time from which the simulation is restarted.
|
|
||||||
void Restart::restartTimer(species::TrackedSpecie* reference_specie) {
|
|
||||||
double time;
|
|
||||||
double delta_t;
|
|
||||||
|
|
||||||
// physical time
|
|
||||||
{
|
|
||||||
std::string path = reference_specie->name() + "/DensityField/SimulationData/" +
|
|
||||||
restart_identifier_ + "/PhysicalTime";
|
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3(path);
|
|
||||||
#endif
|
|
||||||
// probably add a function in the reader to read a single double value instead of
|
|
||||||
// an 1d array of doubles
|
|
||||||
blitz::Array<double, 1> restart_time = reader_.readD1Double(path);
|
|
||||||
if(restart_time.size() != 1) {
|
|
||||||
ERROR("Physical time should be a single double value but " +
|
|
||||||
std::to_string(restart_time.size()) +
|
|
||||||
" was read by the hdf5 reader.");
|
|
||||||
}
|
|
||||||
time = restart_time(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// delta t
|
|
||||||
{
|
|
||||||
std::string path = reference_specie->name() + "/CurrentCollector/SimulationData/" +
|
|
||||||
restart_identifier_ + "/PhysicalTime";
|
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3(path);
|
|
||||||
#endif
|
|
||||||
// probably add a function in the reader to read a single double value instead of
|
|
||||||
// a 1d array of doubles
|
|
||||||
blitz::Array<double, 1> time_resolution = reader_.readD1Double(path);
|
|
||||||
if(time_resolution.size() != 1) {
|
|
||||||
ERROR("Physical time should be a single double value but " +
|
|
||||||
std::to_string(time_resolution.size()) +
|
|
||||||
" was read by the hdf5 reader.");
|
|
||||||
}
|
|
||||||
delta_t = time_resolution(0);
|
|
||||||
}
|
|
||||||
reference_specie->dynamicDensityField()->restartTimer(time, delta_t);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Restart::restartDrawingDensityField(DynamicDensityField* field, std::string path) {
|
|
||||||
// restart TimeInBin field
|
|
||||||
{
|
|
||||||
std::string path_to_data = path + "/TimeInBin";
|
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3(path_to_data);
|
|
||||||
#endif
|
|
||||||
blitz::Array<double, 4> number_in_bin = reader_.readD4Double(path_to_data);
|
|
||||||
field->restartNumberInBin(number_in_bin);
|
|
||||||
field->recalculateDensityArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
// // restart deleted particles
|
|
||||||
// {
|
|
||||||
// std::string path_to_data = path + "/DeletedParticles";
|
|
||||||
// DEBUG_LEVEL_3(path_to_data);
|
|
||||||
// blitz::Array<long int, 5> deleted_particles = reader_.readD5LongInt(path_to_data);
|
|
||||||
// field->restartDeletedParticlesArray(deleted_particles);
|
|
||||||
// }
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// could be removed, but then the potential has to be calculated
|
|
||||||
// as in the normal simulation cycle
|
|
||||||
void Restart::restartPoissonSolver(PoissonSolver* solver) {
|
|
||||||
std::string path = "PoissonSolver/SimulationData/" + restart_identifier_ +
|
|
||||||
"/Potential/";
|
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3(path);
|
|
||||||
#endif
|
|
||||||
blitz::Array<double, 2> potential = reader_.readD2Double(path);
|
|
||||||
solver->setPotential(potential);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Restart::restartParticles(
|
|
||||||
std::vector<particle::SerializedParticle>& storage_queue) {
|
|
||||||
particle_reader_.readParticles(storage_queue);
|
|
||||||
}
|
|
||||||
+24
-195
@@ -1,4 +1,3 @@
|
|||||||
#include "mpi.h"
|
|
||||||
#include "IO/simulation_output.h"
|
#include "IO/simulation_output.h"
|
||||||
#include "IO/hdf5_writer.h"
|
#include "IO/hdf5_writer.h"
|
||||||
|
|
||||||
@@ -11,11 +10,8 @@
|
|||||||
#include "poisson_solver/poisson_solver.h"
|
#include "poisson_solver/poisson_solver.h"
|
||||||
|
|
||||||
SimulationOutput::SimulationOutput(const std::string& output_folder,
|
SimulationOutput::SimulationOutput(const std::string& output_folder,
|
||||||
const std::string& output_filename,
|
const std::string& output_filename)
|
||||||
int fs_blocksize)
|
: writer(Hdf5Writer(output_folder, output_filename)) {}
|
||||||
: writer(Hdf5Writer(output_folder, output_filename)),
|
|
||||||
particle_writer(MpiParticleWriter(output_folder,
|
|
||||||
output_filename, fs_blocksize)) {}
|
|
||||||
|
|
||||||
void SimulationOutput::addDensityFieldOutput(OutputTask task) {
|
void SimulationOutput::addDensityFieldOutput(OutputTask task) {
|
||||||
tasks_density_fields_.push_back(task);
|
tasks_density_fields_.push_back(task);
|
||||||
@@ -33,14 +29,6 @@ void SimulationOutput::setPotentialOutput(OutputTask task) {
|
|||||||
task_potential_ = task;
|
task_potential_ = task;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulationOutput::setRestartInfoOutput(OutputTask task) {
|
|
||||||
task_rng_ = task;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SimulationOutput::setParticleOutput(OutputTask task) {
|
|
||||||
task_particles_ = task;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SimulationOutput::writeMetaData(
|
void SimulationOutput::writeMetaData(
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>& species,
|
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>& species,
|
||||||
const std::shared_ptr<PoissonSolver>& poisson_solver) {
|
const std::shared_ptr<PoissonSolver>& poisson_solver) {
|
||||||
@@ -65,26 +53,14 @@ void SimulationOutput::writeMetaData(
|
|||||||
std::string specie_path = "/" + task_potential_.specie_name;
|
std::string specie_path = "/" + task_potential_.specie_name;
|
||||||
writeMetaData(poisson_solver.get(), specie_path);
|
writeMetaData(poisson_solver.get(), specie_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// write the number of mpi processes used in the current simulation
|
|
||||||
{
|
|
||||||
writer.write(MpiCommunication::mpiSize(), "/NumberProcesses");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulationOutput::writeSimulationData(
|
void SimulationOutput::writeSimulationData(
|
||||||
int cpu_sync,
|
int cpu_sync,
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>& species,
|
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>& species,
|
||||||
PoissonSolver* poisson_solver,
|
PoissonSolver* poisson_solver) {
|
||||||
std::mt19937* engine,
|
|
||||||
std::vector<particle::SerializedParticle>& storage_queue,
|
|
||||||
int injectionGroupOffset) {
|
|
||||||
if (MpiCommunication::mpi_rank == 0) {
|
if (MpiCommunication::mpi_rank == 0) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Write density field data.");
|
DEBUG_LEVEL_2("Write density field data.");
|
||||||
#endif
|
|
||||||
|
|
||||||
for (auto& task : tasks_density_fields_) {
|
for (auto& task : tasks_density_fields_) {
|
||||||
if (cpu_sync % task.intervall == 0) {
|
if (cpu_sync % task.intervall == 0) {
|
||||||
std::string specie_path = "/" + task.specie_name;
|
std::string specie_path = "/" + task.specie_name;
|
||||||
@@ -92,9 +68,7 @@ void SimulationOutput::writeSimulationData(
|
|||||||
specie_path, cpu_sync, task.overwrite_last);
|
specie_path, cpu_sync, task.overwrite_last);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Write current collector data.");
|
DEBUG_LEVEL_2("Write current collector data.");
|
||||||
#endif
|
|
||||||
for (auto& task : tasks_current_collector_) {
|
for (auto& task : tasks_current_collector_) {
|
||||||
if (cpu_sync % task.intervall == 0) {
|
if (cpu_sync % task.intervall == 0) {
|
||||||
std::string specie_path = "/" + task.specie_name;
|
std::string specie_path = "/" + task.specie_name;
|
||||||
@@ -102,9 +76,7 @@ void SimulationOutput::writeSimulationData(
|
|||||||
specie_path, cpu_sync, task.overwrite_last);
|
specie_path, cpu_sync, task.overwrite_last);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Write deletion logger data.");
|
DEBUG_LEVEL_2("Write deletion logger data.");
|
||||||
#endif
|
|
||||||
for (auto& task : tasks_deletion_logger_) {
|
for (auto& task : tasks_deletion_logger_) {
|
||||||
if (cpu_sync % task.intervall == 0) {
|
if (cpu_sync % task.intervall == 0) {
|
||||||
std::string specie_path = "/" + task.specie_name;
|
std::string specie_path = "/" + task.specie_name;
|
||||||
@@ -112,26 +84,13 @@ void SimulationOutput::writeSimulationData(
|
|||||||
specie_path, cpu_sync, task.overwrite_last);
|
specie_path, cpu_sync, task.overwrite_last);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Write PoissonSolver data.");
|
DEBUG_LEVEL_2("Write PoissonSolver data.");
|
||||||
#endif
|
|
||||||
if (cpu_sync % task_potential_.intervall == 0) {
|
if (cpu_sync % task_potential_.intervall == 0) {
|
||||||
std::string poisson_path = "/" + task_potential_.specie_name;
|
std::string poisson_path = "/" + task_potential_.specie_name;
|
||||||
writeSimulationData(poisson_solver, poisson_path, cpu_sync,
|
writeSimulationData(poisson_solver, poisson_path, cpu_sync,
|
||||||
task_potential_.overwrite_last);
|
task_potential_.overwrite_last);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the rng intervall = 0 (no neg. intervalls allowed) -> no output,
|
|
||||||
// otherwise the intervall used the same as for the other outputs
|
|
||||||
if((task_rng_.intervall > 0) && (cpu_sync%task_rng_.intervall == 0)) {
|
|
||||||
writeRestartData(engine, cpu_sync, task_rng_.overwrite_last, injectionGroupOffset);
|
|
||||||
}
|
|
||||||
|
|
||||||
if((task_particles_.intervall > 0) && (cpu_sync%task_particles_.intervall == 0)) {
|
|
||||||
writeParticles(storage_queue, cpu_sync,
|
|
||||||
species.begin()->second->dynamicDensityField()->timeResolution());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulationOutput::writeSimulationData(DynamicDensityField* density_field,
|
void SimulationOutput::writeSimulationData(DynamicDensityField* density_field,
|
||||||
@@ -144,23 +103,15 @@ void SimulationOutput::writeSimulationData(DynamicDensityField* density_field,
|
|||||||
}
|
}
|
||||||
std::string path = species_path + "/DensityField/SimulationData/" + sync_path;
|
std::string path = species_path + "/DensityField/SimulationData/" + sync_path;
|
||||||
|
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("Write spectrum.");
|
DEBUG_LEVEL_3("Write spectrum.");
|
||||||
#endif
|
|
||||||
writeSpectrum(density_field, path);
|
writeSpectrum(density_field, path);
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("Write density.");
|
DEBUG_LEVEL_3("Write density.");
|
||||||
#endif
|
|
||||||
writeDensity(density_field, path);
|
writeDensity(density_field, path);
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("Write time in bin.");
|
DEBUG_LEVEL_3("Write time in bin.");
|
||||||
#endif
|
|
||||||
writeTimeInBin(density_field, path);
|
writeTimeInBin(density_field, path);
|
||||||
// DEBUG_LEVEL_3("Write deleted particles.");
|
DEBUG_LEVEL_3("Write deleted particles.");
|
||||||
// writeDeletedParticles(density_field, path);
|
writeDeletedParticles(density_field, path);
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("Write physical time.");
|
DEBUG_LEVEL_3("Write physical time.");
|
||||||
#endif
|
|
||||||
writePhysicalTime(density_field, path);
|
writePhysicalTime(density_field, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,17 +125,11 @@ void SimulationOutput::writeSimulationData(CurrentCollector* current_collector,
|
|||||||
}
|
}
|
||||||
std::string path =
|
std::string path =
|
||||||
species_path + "/CurrentCollector/SimulationData/" + sync_path;
|
species_path + "/CurrentCollector/SimulationData/" + sync_path;
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("Write current crossings.");
|
DEBUG_LEVEL_3("Write current crossings.");
|
||||||
#endif
|
|
||||||
writeCurrentCrossings(current_collector, path);
|
writeCurrentCrossings(current_collector, path);
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("Write current.");
|
DEBUG_LEVEL_3("Write current.");
|
||||||
#endif
|
|
||||||
writeCurrent(current_collector, path);
|
writeCurrent(current_collector, path);
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("Write physical time.");
|
DEBUG_LEVEL_3("Write physical time.");
|
||||||
#endif
|
|
||||||
writePhysicalTime(current_collector, path);
|
writePhysicalTime(current_collector, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,9 +142,7 @@ void SimulationOutput::writeSimulationData(DeletionLogger* logger,
|
|||||||
sync_path = "LastSyncPeriod";
|
sync_path = "LastSyncPeriod";
|
||||||
}
|
}
|
||||||
std::string path = species_path + "/DeletionLogger/" + sync_path;
|
std::string path = species_path + "/DeletionLogger/" + sync_path;
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("Write number of deletions.");
|
DEBUG_LEVEL_3("Write number of deletions.");
|
||||||
#endif
|
|
||||||
writeNumDeletions(logger, path);
|
writeNumDeletions(logger, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,44 +155,10 @@ void SimulationOutput::writeSimulationData(PoissonSolver* poisson_solver,
|
|||||||
sync_path = "/LastSyncPeriod";
|
sync_path = "/LastSyncPeriod";
|
||||||
}
|
}
|
||||||
std::string path = poisson_path + "/SimulationData" + sync_path;
|
std::string path = poisson_path + "/SimulationData" + sync_path;
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("Write potential.");
|
DEBUG_LEVEL_3("Write potential.");
|
||||||
#endif
|
|
||||||
writePotential(poisson_solver, path);
|
writePotential(poisson_solver, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulationOutput::writeRestartData(std::mt19937* engine, int cpu_sync,
|
|
||||||
bool overwrite_last, int injectionGroupOffset) {
|
|
||||||
std::string path_base = "/RestartInfo/SyncPeriod_" +
|
|
||||||
std::to_string(cpu_sync) +
|
|
||||||
"/CPU_";
|
|
||||||
if (overwrite_last) {
|
|
||||||
path_base = "/RestartInfo/LastSyncPeriod/CPU_";
|
|
||||||
}
|
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3(path_base);
|
|
||||||
DEBUG_LEVEL_3("Write restart info.");
|
|
||||||
#endif
|
|
||||||
writeRandomEngineState(engine, path_base);
|
|
||||||
|
|
||||||
if(MpiCommunication::mpi_rank == 0) {
|
|
||||||
std::string path = "/RestartInfo/SyncPeriod_" +
|
|
||||||
std::to_string(cpu_sync) +
|
|
||||||
"/InjectionGroupOffset";
|
|
||||||
if (overwrite_last) {
|
|
||||||
path = "/RestartInfo/LastSyncPeriod/InjectionGroupOffset";
|
|
||||||
}
|
|
||||||
writer.write(injectionGroupOffset, path);
|
|
||||||
}
|
|
||||||
// DEBUG_LEVEL_3("Done");
|
|
||||||
}
|
|
||||||
|
|
||||||
void SimulationOutput::writeRandomEngineState(std::mt19937* engine, std::string path) {
|
|
||||||
std::ostringstream engine_state;
|
|
||||||
engine_state << (*engine);
|
|
||||||
writer.writeRNG(engine_state.str(), path);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SimulationOutput::writeNumDeletions(DeletionLogger* logger,
|
void SimulationOutput::writeNumDeletions(DeletionLogger* logger,
|
||||||
std::string path) {
|
std::string path) {
|
||||||
std::string path_to_deletions = path + "/NumDeletions";
|
std::string path_to_deletions = path + "/NumDeletions";
|
||||||
@@ -267,13 +176,6 @@ void SimulationOutput::writeNumDeletions(DeletionLogger* logger,
|
|||||||
writer.write(pair.second, path_to_deletions + "/ClusterFormation");
|
writer.write(pair.second, path_to_deletions + "/ClusterFormation");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto physDeletions = logger->numPhysDeletions();
|
|
||||||
for (auto& pair : physDeletions) {
|
|
||||||
if (pair.first == PhysicalDeletionType::wall) {
|
|
||||||
writer.write(pair.second, path_to_deletions + "/Wall(physical)");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulationOutput::writeCurrentCrossings(
|
void SimulationOutput::writeCurrentCrossings(
|
||||||
@@ -293,11 +195,6 @@ void SimulationOutput::writeCurrentCrossings(
|
|||||||
path + "/PositiveCrossingsInZ");
|
path + "/PositiveCrossingsInZ");
|
||||||
writer.write(current_collector->negativeCrossingsInZ(),
|
writer.write(current_collector->negativeCrossingsInZ(),
|
||||||
path + "/NegativeCrossingsInZ");
|
path + "/NegativeCrossingsInZ");
|
||||||
|
|
||||||
#ifdef GENRICHCURRENT
|
|
||||||
writer.write(current_collector->sampleNegativeCrossings(),
|
|
||||||
path + "/SampleNegativeCrossings");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulationOutput::writeCurrent(CurrentCollector* current_collector,
|
void SimulationOutput::writeCurrent(CurrentCollector* current_collector,
|
||||||
@@ -310,10 +207,6 @@ void SimulationOutput::writeCurrent(CurrentCollector* current_collector,
|
|||||||
void SimulationOutput::writePhysicalTime(CurrentCollector* current_collector,
|
void SimulationOutput::writePhysicalTime(CurrentCollector* current_collector,
|
||||||
std::string path) {
|
std::string path) {
|
||||||
writer.write(current_collector->physicalTime(), path + "/PhysicalTime");
|
writer.write(current_collector->physicalTime(), path + "/PhysicalTime");
|
||||||
#ifdef GENRICHCURRENT
|
|
||||||
// write the time over which the "sample" current has been accumulated during
|
|
||||||
writer.write(current_collector->timeSinceReset(), path + "/TimeSinceReset");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulationOutput::writeSpectrum(DynamicDensityField* density_field,
|
void SimulationOutput::writeSpectrum(DynamicDensityField* density_field,
|
||||||
@@ -323,27 +216,21 @@ void SimulationOutput::writeSpectrum(DynamicDensityField* density_field,
|
|||||||
|
|
||||||
void SimulationOutput::writeDensity(DynamicDensityField* density_field,
|
void SimulationOutput::writeDensity(DynamicDensityField* density_field,
|
||||||
std::string path) {
|
std::string path) {
|
||||||
// precaution, shouldn't be necessary due to calculation after cpu sync
|
|
||||||
// density_field->recalculateDensityArray();
|
|
||||||
writer.write(density_field->densityArray(), path + "/Density");
|
writer.write(density_field->densityArray(), path + "/Density");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulationOutput::writeTimeInBin(DynamicDensityField* density_field,
|
void SimulationOutput::writeTimeInBin(DynamicDensityField* density_field,
|
||||||
std::string path) {
|
std::string path) {
|
||||||
writer.write(density_field->numberInBinArray(), path + "/TimeInBin");
|
writer.write(density_field->timeInBinArray(), path + "/TimeInBin");
|
||||||
|
}
|
||||||
|
void SimulationOutput::writeDeletedParticles(DynamicDensityField* density_field,
|
||||||
|
std::string path) {
|
||||||
|
writer.write(density_field->deletedParticlesArray(),
|
||||||
|
path + "/DeletedParticles");
|
||||||
}
|
}
|
||||||
|
|
||||||
// void SimulationOutput::writeDeletedParticles(DynamicDensityField* density_field,
|
|
||||||
// std::string path) {
|
|
||||||
// writer.write(density_field->deletedParticlesArray(),
|
|
||||||
// path + "/DeletedParticles");
|
|
||||||
// }
|
|
||||||
|
|
||||||
void SimulationOutput::writePhysicalTime(DynamicDensityField* density_field,
|
void SimulationOutput::writePhysicalTime(DynamicDensityField* density_field,
|
||||||
std::string path) {
|
std::string path) {
|
||||||
writer.write(density_field->physicalTime(), path + "/PhysicalTime");
|
writer.write(density_field->physicalTime(), path + "/PhysicalTime");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulationOutput::writePotential(PoissonSolver* poisson_solver, std::string path) {
|
void SimulationOutput::writePotential(PoissonSolver* poisson_solver, std::string path) {
|
||||||
writer.write(poisson_solver->potential(), path + "/Potential");
|
writer.write(poisson_solver->potential(), path + "/Potential");
|
||||||
}
|
}
|
||||||
@@ -355,7 +242,6 @@ void SimulationOutput::writeMetaData(species::TrackedSpecie* specie) {
|
|||||||
writer.write(specie->charge_C(), specie_path + "/Charge");
|
writer.write(specie->charge_C(), specie_path + "/Charge");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
void SimulationOutput::writeMetaData(DynamicDensityField* density_field,
|
void SimulationOutput::writeMetaData(DynamicDensityField* density_field,
|
||||||
std::string path) {
|
std::string path) {
|
||||||
std::string path_to_field = path + "/DensityField";
|
std::string path_to_field = path + "/DensityField";
|
||||||
@@ -364,50 +250,6 @@ void SimulationOutput::writeMetaData(DynamicDensityField* density_field,
|
|||||||
writeBinBorders(density_field, path_to_field);
|
writeBinBorders(density_field, path_to_field);
|
||||||
writeNumBins(density_field, path_to_field);
|
writeNumBins(density_field, path_to_field);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// Todo: use the functions again (as in the method thats uncommented above)
|
|
||||||
void SimulationOutput::writeMetaData(DynamicDensityField* density_field,
|
|
||||||
std::string path) {
|
|
||||||
std::string path_to_field = path + "/DensityField";
|
|
||||||
|
|
||||||
// write bin volumes
|
|
||||||
{
|
|
||||||
std::string path_to_volume = path_to_field + "/BinVolumes";
|
|
||||||
writer.write(density_field->binVolumeArray(), path_to_volume);
|
|
||||||
}
|
|
||||||
|
|
||||||
// write bin borders
|
|
||||||
{
|
|
||||||
std::string path_to_bin_borders = path_to_field + "/BinBorders";
|
|
||||||
|
|
||||||
std::vector<double> energy_bin_borders =
|
|
||||||
density_field->energyBinning()->binBorders();
|
|
||||||
writer.write(energy_bin_borders, path_to_bin_borders + "/energy");
|
|
||||||
|
|
||||||
std::vector<double> mu_bin_borders =
|
|
||||||
density_field->pitchAngleBinning()->binBorders();
|
|
||||||
writer.write(mu_bin_borders, path_to_bin_borders + "/pitchAngle");
|
|
||||||
|
|
||||||
std::vector<double> radial_bin_borders =
|
|
||||||
density_field->positionBinning()->radial_binning.binBorders();
|
|
||||||
writer.write(radial_bin_borders, path_to_bin_borders + "/radial");
|
|
||||||
|
|
||||||
std::vector<double> longitudinal_bin_borders =
|
|
||||||
density_field->positionBinning()->longitudinal_binning.binBorders();
|
|
||||||
writer.write(longitudinal_bin_borders, path_to_bin_borders + "/longitudinal");
|
|
||||||
}
|
|
||||||
|
|
||||||
// write num bins
|
|
||||||
{
|
|
||||||
std::string path_to_num_bins = path_to_field + "/NumBins";
|
|
||||||
blitz::TinyVector<int, 3> num_bins = density_field->spectrumArray().extent();
|
|
||||||
|
|
||||||
writer.write(num_bins(0), path_to_num_bins + "/radial");
|
|
||||||
writer.write(num_bins(1), path_to_num_bins + "/longitudinal");
|
|
||||||
writer.write(num_bins(2), path_to_num_bins + "/energy");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SimulationOutput::writeMetaData(CurrentCollector* current_collector,
|
void SimulationOutput::writeMetaData(CurrentCollector* current_collector,
|
||||||
std::string path) {
|
std::string path) {
|
||||||
@@ -426,6 +268,10 @@ void SimulationOutput::writeMetaData(PoissonSolver* poisson_solver,
|
|||||||
poisson_solver->densityBinning()->radial_binning.binBorders();
|
poisson_solver->densityBinning()->radial_binning.binBorders();
|
||||||
writer.write(radial_bin_borders, path_to_bin_borders + "/radial");
|
writer.write(radial_bin_borders, path_to_bin_borders + "/radial");
|
||||||
|
|
||||||
|
std::vector<double> azimuth_bin_borders =
|
||||||
|
poisson_solver->densityBinning()->azimuth_binning.binBorders();
|
||||||
|
writer.write(azimuth_bin_borders, path_to_bin_borders + "/azimuth");
|
||||||
|
|
||||||
std::vector<double> longitudinal_bin_borders =
|
std::vector<double> longitudinal_bin_borders =
|
||||||
poisson_solver->densityBinning()->longitudinal_binning.binBorders();
|
poisson_solver->densityBinning()->longitudinal_binning.binBorders();
|
||||||
writer.write(longitudinal_bin_borders, path_to_bin_borders + "/longitudinal");
|
writer.write(longitudinal_bin_borders, path_to_bin_borders + "/longitudinal");
|
||||||
@@ -436,10 +282,6 @@ void SimulationOutput::writeCollectorAreas(CurrentCollector* current_collector,
|
|||||||
writer.write(current_collector->areaInR(), path + "/AreaInR");
|
writer.write(current_collector->areaInR(), path + "/AreaInR");
|
||||||
writer.write(current_collector->areaInPhi(), path + "/AreaInPhi");
|
writer.write(current_collector->areaInPhi(), path + "/AreaInPhi");
|
||||||
writer.write(current_collector->areaInZ(), path + "/AreaInZ");
|
writer.write(current_collector->areaInZ(), path + "/AreaInZ");
|
||||||
|
|
||||||
#ifdef GENRICHCURRENT
|
|
||||||
writer.write(current_collector->energyBinBorders(), path + "/EnergyBinBorders");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulationOutput::writeBinVolumes(DynamicDensityField* density_field,
|
void SimulationOutput::writeBinVolumes(DynamicDensityField* density_field,
|
||||||
@@ -451,11 +293,12 @@ void SimulationOutput::writeBinVolumes(DynamicDensityField* density_field,
|
|||||||
void SimulationOutput::writeNumBins(DynamicDensityField* density_field,
|
void SimulationOutput::writeNumBins(DynamicDensityField* density_field,
|
||||||
std::string path_to_field) {
|
std::string path_to_field) {
|
||||||
std::string path_to_num_bins = path_to_field + "/NumBins";
|
std::string path_to_num_bins = path_to_field + "/NumBins";
|
||||||
blitz::TinyVector<int, 3> num_bins = density_field->spectrumArray().extent();
|
blitz::TinyVector<int, 4> num_bins = density_field->spectrumArray().extent();
|
||||||
|
|
||||||
writer.write(num_bins(0), path_to_num_bins + "/radial");
|
writer.write(num_bins(0), path_to_num_bins + "/energy");
|
||||||
writer.write(num_bins(1), path_to_num_bins + "/longitudinal");
|
writer.write(num_bins(1), path_to_num_bins + "/radial");
|
||||||
writer.write(num_bins(2), path_to_num_bins + "/energy");
|
writer.write(num_bins(2), path_to_num_bins + "/azimuthal");
|
||||||
|
writer.write(num_bins(3), path_to_num_bins + "/longitudinal");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulationOutput::writeBinBorders(DynamicDensityField* density_field,
|
void SimulationOutput::writeBinBorders(DynamicDensityField* density_field,
|
||||||
@@ -470,25 +313,11 @@ void SimulationOutput::writeBinBorders(DynamicDensityField* density_field,
|
|||||||
density_field->positionBinning()->radial_binning.binBorders();
|
density_field->positionBinning()->radial_binning.binBorders();
|
||||||
writer.write(radial_bin_borders, path_to_bin_borders + "/radial");
|
writer.write(radial_bin_borders, path_to_bin_borders + "/radial");
|
||||||
|
|
||||||
|
std::vector<double> azimuth_bin_borders =
|
||||||
|
density_field->positionBinning()->azimuth_binning.binBorders();
|
||||||
|
writer.write(azimuth_bin_borders, path_to_bin_borders + "/azimuth");
|
||||||
|
|
||||||
std::vector<double> longitudinal_bin_borders =
|
std::vector<double> longitudinal_bin_borders =
|
||||||
density_field->positionBinning()->longitudinal_binning.binBorders();
|
density_field->positionBinning()->longitudinal_binning.binBorders();
|
||||||
writer.write(longitudinal_bin_borders, path_to_bin_borders + "/longitudinal");
|
writer.write(longitudinal_bin_borders, path_to_bin_borders + "/longitudinal");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulationOutput::writeParticles(
|
|
||||||
std::vector<particle::SerializedParticle>& particles,
|
|
||||||
int cpu_sync,
|
|
||||||
double dt) {
|
|
||||||
particle_writer.output_particles(particles, cpu_sync, dt);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef GENRICHCURRENT
|
|
||||||
void SimulationOutput::setResetCurrentCollector(int cpu_sync,
|
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>& species) {
|
|
||||||
for(auto& task : tasks_current_collector_) {
|
|
||||||
if(cpu_sync % task.intervall == 0)
|
|
||||||
species.at(task.specie_name)->currentCollector()->needsReset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@@ -10,9 +10,7 @@ namespace generator {
|
|||||||
|
|
||||||
CylinderBinning buildPositionBinning(json_t* object) {
|
CylinderBinning buildPositionBinning(json_t* object) {
|
||||||
if (json_object_by_path(object, {"CylinderBinning"})) {
|
if (json_object_by_path(object, {"CylinderBinning"})) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating position binning: cylinder binning.");
|
DEBUG_LEVEL_2("Creating position binning: cylinder binning.");
|
||||||
#endif
|
|
||||||
object = json_object_by_path(object, {"CylinderBinning"});
|
object = json_object_by_path(object, {"CylinderBinning"});
|
||||||
|
|
||||||
json_t* radial = json_object_by_path(object, {"Radial"});
|
json_t* radial = json_object_by_path(object, {"Radial"});
|
||||||
@@ -23,6 +21,12 @@ CylinderBinning buildPositionBinning(json_t* object) {
|
|||||||
json_read_length(json_object_by_path(radial, {"MaxRadius"}), "m");
|
json_read_length(json_object_by_path(radial, {"MaxRadius"}), "m");
|
||||||
ASSERT_POSITIVE(&max_radius, "Radius must be positive");
|
ASSERT_POSITIVE(&max_radius, "Radius must be positive");
|
||||||
|
|
||||||
|
json_t* azimuthal = json_object_by_path(object, {"Azimuthal"});
|
||||||
|
int number_of_bins_azimuthal =
|
||||||
|
json_int(json_object_by_path(azimuthal, {"NumberOfBins"}));
|
||||||
|
ASSERT_POSITIVE(&number_of_bins_azimuthal,
|
||||||
|
"Number of Bins must be positive");
|
||||||
|
|
||||||
json_t* longitudinal = json_object_by_path(object, {"Longitudinal"});
|
json_t* longitudinal = json_object_by_path(object, {"Longitudinal"});
|
||||||
int number_of_bins_longitudinal =
|
int number_of_bins_longitudinal =
|
||||||
json_int(json_object_by_path(longitudinal, {"NumberOfBins"}));
|
json_int(json_object_by_path(longitudinal, {"NumberOfBins"}));
|
||||||
@@ -32,20 +36,21 @@ CylinderBinning buildPositionBinning(json_t* object) {
|
|||||||
json_read_length(json_object_by_path(longitudinal, {"MaxLength"}), "m");
|
json_read_length(json_object_by_path(longitudinal, {"MaxLength"}), "m");
|
||||||
ASSERT_POSITIVE(&max_length, "Radius must be positive");
|
ASSERT_POSITIVE(&max_length, "Radius must be positive");
|
||||||
|
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("with number of bins radial: " +
|
DEBUG_LEVEL_3("with number of bins radial: " +
|
||||||
std::to_string(number_of_bins_radial));
|
std::to_string(number_of_bins_radial));
|
||||||
|
DEBUG_LEVEL_3("with number of bins azimuthal: " +
|
||||||
|
std::to_string(number_of_bins_azimuthal));
|
||||||
DEBUG_LEVEL_3("with number of bins longitudinal: " +
|
DEBUG_LEVEL_3("with number of bins longitudinal: " +
|
||||||
std::to_string(number_of_bins_longitudinal));
|
std::to_string(number_of_bins_longitudinal));
|
||||||
DEBUG_LEVEL_3("with radius: " + std::to_string(max_radius) + " m");
|
DEBUG_LEVEL_3("with radius: " + std::to_string(max_radius) + " m");
|
||||||
DEBUG_LEVEL_3("with height: " + std::to_string(max_length) + " m");
|
DEBUG_LEVEL_3("with height: " + std::to_string(max_length) + " m");
|
||||||
#endif
|
|
||||||
|
|
||||||
return CylinderBinning(number_of_bins_radial, max_radius,
|
return CylinderBinning(number_of_bins_radial, max_radius,
|
||||||
|
number_of_bins_azimuthal,
|
||||||
number_of_bins_longitudinal, max_length);
|
number_of_bins_longitudinal, max_length);
|
||||||
} else {
|
} else {
|
||||||
ERROR("This position binning is not implemented.");
|
ERROR("This position binning is not implemented.");
|
||||||
return CylinderBinning(0, 0, 0, 0);
|
return CylinderBinning(0, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,18 +59,14 @@ CylinderBinning buildPositionBinningIncludingRedirection(
|
|||||||
json_path& path_to_binning) {
|
json_path& path_to_binning) {
|
||||||
if (parameter.jsonObjectFromBase(
|
if (parameter.jsonObjectFromBase(
|
||||||
json_path_append(path_to_binning, {"CreateSameAs"}))) {
|
json_path_append(path_to_binning, {"CreateSameAs"}))) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating position binning: CreateSameAs.");
|
DEBUG_LEVEL_2("Creating position binning: CreateSameAs.");
|
||||||
#endif
|
|
||||||
json_path path_to_same = json_path_get(parameter.jsonObjectFromBase(
|
json_path path_to_same = json_path_get(parameter.jsonObjectFromBase(
|
||||||
json_path_append(path_to_binning, {"CreateSameAs"})));
|
json_path_append(path_to_binning, {"CreateSameAs"})));
|
||||||
std::stringstream path;
|
std::stringstream path;
|
||||||
for (auto& p : path_to_same) {
|
for (auto& p : path_to_same) {
|
||||||
path << p << " ";
|
path << p << " ";
|
||||||
}
|
}
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("From path: " + path.str());
|
DEBUG_LEVEL_3("From path: " + path.str());
|
||||||
#endif
|
|
||||||
return buildPositionBinningIncludingRedirection(parameter, path_to_same);
|
return buildPositionBinningIncludingRedirection(parameter, path_to_same);
|
||||||
} else {
|
} else {
|
||||||
return buildPositionBinning(parameter.jsonObjectFromBase(path_to_binning));
|
return buildPositionBinning(parameter.jsonObjectFromBase(path_to_binning));
|
||||||
@@ -75,9 +76,7 @@ CylinderBinning buildPositionBinningIncludingRedirection(
|
|||||||
EnergyBinning buildEnergyBinning(json_t* object) {
|
EnergyBinning buildEnergyBinning(json_t* object) {
|
||||||
std::string energy_type = json_string(json_object_by_path(object, {"Type"}));
|
std::string energy_type = json_string(json_object_by_path(object, {"Type"}));
|
||||||
if (energy_type == "Logarithmic") {
|
if (energy_type == "Logarithmic") {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating energy binning: logarithmic.");
|
DEBUG_LEVEL_2("Creating energy binning: logarithmic.");
|
||||||
#endif
|
|
||||||
int number_of_bins =
|
int number_of_bins =
|
||||||
json_int(json_object_by_path(object, {"NumberOfBins"}));
|
json_int(json_object_by_path(object, {"NumberOfBins"}));
|
||||||
ASSERT_POSITIVE(&number_of_bins, "Number of Bins must be positive");
|
ASSERT_POSITIVE(&number_of_bins, "Number of Bins must be positive");
|
||||||
@@ -88,11 +87,9 @@ EnergyBinning buildEnergyBinning(json_t* object) {
|
|||||||
json_read_energy(json_object_by_path(object, {"MaxEnergy"}), "eV");
|
json_read_energy(json_object_by_path(object, {"MaxEnergy"}), "eV");
|
||||||
ASSERT_POSITIVE(&max_energy, "Max Energy must be positive");
|
ASSERT_POSITIVE(&max_energy, "Max Energy must be positive");
|
||||||
|
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("with number of bins: " + std::to_string(number_of_bins));
|
DEBUG_LEVEL_3("with number of bins: " + std::to_string(number_of_bins));
|
||||||
DEBUG_LEVEL_3("with min energy: " + std::to_string(min_energy));
|
DEBUG_LEVEL_3("with min energy: " + std::to_string(min_energy));
|
||||||
DEBUG_LEVEL_3("with max energy: " + std::to_string(max_energy));
|
DEBUG_LEVEL_3("with max energy: " + std::to_string(max_energy));
|
||||||
#endif
|
|
||||||
|
|
||||||
return EnergyBinning(min_energy, max_energy, number_of_bins);
|
return EnergyBinning(min_energy, max_energy, number_of_bins);
|
||||||
|
|
||||||
@@ -107,75 +104,18 @@ EnergyBinning buildEnergyBinningIncludingRedirection(
|
|||||||
json_path& path_to_binning) {
|
json_path& path_to_binning) {
|
||||||
if (parameter.jsonObjectFromBase(
|
if (parameter.jsonObjectFromBase(
|
||||||
json_path_append(path_to_binning, {"CreateSameAs"}))) {
|
json_path_append(path_to_binning, {"CreateSameAs"}))) {
|
||||||
|
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating energy binning: CreateSameAs.");
|
DEBUG_LEVEL_2("Creating energy binning: CreateSameAs.");
|
||||||
#endif
|
|
||||||
|
|
||||||
json_path path_to_same = json_path_get(parameter.jsonObjectFromBase(
|
json_path path_to_same = json_path_get(parameter.jsonObjectFromBase(
|
||||||
json_path_append(path_to_binning, {"CreateSameAs"})));
|
json_path_append(path_to_binning, {"CreateSameAs"})));
|
||||||
|
|
||||||
#ifdef debug_level3
|
|
||||||
std::stringstream path;
|
std::stringstream path;
|
||||||
for (auto& p : path_to_same) {
|
for (auto& p : path_to_same) {
|
||||||
path << p << " ";
|
path << p << " ";
|
||||||
}
|
}
|
||||||
DEBUG_LEVEL_3("From path: " + path.str());
|
DEBUG_LEVEL_3("From path: " + path.str());
|
||||||
#endif
|
|
||||||
|
|
||||||
return buildEnergyBinningIncludingRedirection(parameter, path_to_same);
|
return buildEnergyBinningIncludingRedirection(parameter, path_to_same);
|
||||||
} else {
|
} else {
|
||||||
return buildEnergyBinning(parameter.jsonObjectFromBase(path_to_binning));
|
return buildEnergyBinning(parameter.jsonObjectFromBase(path_to_binning));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PitchAngleBinning buildPitchAngleBinning(json_t* object) {
|
|
||||||
std::string pitch_angle_type = json_string(json_object_by_path(object, {"Type"}));
|
|
||||||
if (pitch_angle_type == "Linear") {
|
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating pitch angle binning: linear.");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int number_of_bins =
|
|
||||||
json_int(json_object_by_path(object, {"NumberOfBins"}));
|
|
||||||
ASSERT_POSITIVE(&number_of_bins, "Number of Bins must be positive");
|
|
||||||
|
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("with number of bins: " + std::to_string(number_of_bins));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return PitchAngleBinning(number_of_bins);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
ERROR("This pitch angle binning is not implemented: " + pitch_angle_type);
|
|
||||||
return PitchAngleBinning(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PitchAngleBinning buildPitchAngleBinningIncludingRedirection(
|
|
||||||
Parameter& parameter,
|
|
||||||
json_path& path_to_binning) {
|
|
||||||
if (parameter.jsonObjectFromBase(
|
|
||||||
json_path_append(path_to_binning, {"CreateSameAs"}))) {
|
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating energy binning: CreateSameAs.");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
json_path path_to_same = json_path_get(parameter.jsonObjectFromBase(
|
|
||||||
json_path_append(path_to_binning, {"CreateSameAs"})));
|
|
||||||
|
|
||||||
#ifdef debug_level3
|
|
||||||
std::stringstream path;
|
|
||||||
for (auto& p : path_to_same) {
|
|
||||||
path << p << " ";
|
|
||||||
}
|
|
||||||
DEBUG_LEVEL_3("From path: " + path.str());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return buildPitchAngleBinningIncludingRedirection(parameter, path_to_same);
|
|
||||||
} else {
|
|
||||||
return buildPitchAngleBinning(parameter.jsonObjectFromBase(path_to_binning));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}; // namespace generator
|
}; // namespace generator
|
||||||
@@ -9,9 +9,7 @@ std::shared_ptr<CurrentCollector> buildCurrentCollector(
|
|||||||
Parameter& parameter,
|
Parameter& parameter,
|
||||||
const json_path& path_to_collector,
|
const json_path& path_to_collector,
|
||||||
std::shared_ptr<Timer>& timer) {
|
std::shared_ptr<Timer>& timer) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating current collector.");
|
DEBUG_LEVEL_2("Creating current collector.");
|
||||||
#endif
|
|
||||||
json_path path_binning =
|
json_path path_binning =
|
||||||
json_path_append(path_to_collector, {"PositionBinning"});
|
json_path_append(path_to_collector, {"PositionBinning"});
|
||||||
CylinderBinning position_binning =
|
CylinderBinning position_binning =
|
||||||
|
|||||||
@@ -10,9 +10,7 @@ namespace generator {
|
|||||||
|
|
||||||
std::shared_ptr<ConstantDensityField> buildConstantDensityField(
|
std::shared_ptr<ConstantDensityField> buildConstantDensityField(
|
||||||
json_t* object) {
|
json_t* object) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating constant density field.");
|
DEBUG_LEVEL_2("Creating constant density field.");
|
||||||
#endif
|
|
||||||
json_path path = {"ScalarField"};
|
json_path path = {"ScalarField"};
|
||||||
std::shared_ptr<ScalarField> field =
|
std::shared_ptr<ScalarField> field =
|
||||||
buildScalarField(json_object_by_path(object, path));
|
buildScalarField(json_object_by_path(object, path));
|
||||||
@@ -23,25 +21,16 @@ std::shared_ptr<DynamicDensityField> buildDynamicDensityField(
|
|||||||
Parameter& parameter,
|
Parameter& parameter,
|
||||||
const json_path& path_to_field,
|
const json_path& path_to_field,
|
||||||
std::shared_ptr<Timer>& timer) {
|
std::shared_ptr<Timer>& timer) {
|
||||||
|
DEBUG_LEVEL_2("Creating dynamic density field.");
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating dynamic density field with pitch angle.");
|
|
||||||
#endif
|
|
||||||
json_path path_binning = json_path_append(path_to_field, {"PositionBinning"});
|
json_path path_binning = json_path_append(path_to_field, {"PositionBinning"});
|
||||||
CylinderBinning position_binning =
|
CylinderBinning position_binning =
|
||||||
buildPositionBinningIncludingRedirection(parameter, path_binning);
|
buildPositionBinningIncludingRedirection(parameter, path_binning);
|
||||||
json_path path_energy_binning =
|
json_path path_energy_binning =
|
||||||
json_path_append(path_to_field, {"EnergyBinning"});
|
json_path_append(path_to_field, {"EnergyBinning"});
|
||||||
EnergyBinning energy_binning =
|
EnergyBinning energy_binning =
|
||||||
buildEnergyBinningIncludingRedirection(parameter, path_energy_binning);
|
buildEnergyBinningIncludingRedirection(parameter, path_energy_binning);
|
||||||
// TBD: make a function to build the pitchangle binning
|
|
||||||
json_path path_pitch_angle_binning =
|
|
||||||
json_path_append(path_to_field, {"PitchAngleBinning"});
|
|
||||||
PitchAngleBinning pitch_angle_binning =
|
|
||||||
buildPitchAngleBinningIncludingRedirection(parameter, path_pitch_angle_binning);
|
|
||||||
return std::shared_ptr<DynamicDensityField>(
|
return std::shared_ptr<DynamicDensityField>(
|
||||||
new DynamicDensityField(position_binning, energy_binning,
|
new DynamicDensityField(position_binning, energy_binning, timer));
|
||||||
pitch_angle_binning, timer));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // namespace generator
|
}; // namespace generator
|
||||||
@@ -9,18 +9,14 @@ std::shared_ptr<DriftVelocity> buildDriftVelocity(
|
|||||||
const json_path& path_to_drift_velocity) {
|
const json_path& path_to_drift_velocity) {
|
||||||
if (parameter.jsonObjectFromBase(
|
if (parameter.jsonObjectFromBase(
|
||||||
json_path_append(path_to_drift_velocity, {"VectorField"}))) {
|
json_path_append(path_to_drift_velocity, {"VectorField"}))) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating drift velocity: Vector field.");
|
DEBUG_LEVEL_2("Creating drift velocity: Vector field.");
|
||||||
#endif
|
|
||||||
std::shared_ptr<VectorField> field =
|
std::shared_ptr<VectorField> field =
|
||||||
buildVectorField(parameter.jsonObjectFromBase(
|
buildVectorField(parameter.jsonObjectFromBase(
|
||||||
json_path_append(path_to_drift_velocity, {"VectorField"})));
|
json_path_append(path_to_drift_velocity, {"VectorField"})));
|
||||||
return std::shared_ptr<DriftVelocity>(new DriftVelocity(field));
|
return std::shared_ptr<DriftVelocity>(new DriftVelocity(field));
|
||||||
} else if (parameter.jsonObjectFromBase(
|
} else if (parameter.jsonObjectFromBase(
|
||||||
json_path_append(path_to_drift_velocity, {"null"}))) {
|
json_path_append(path_to_drift_velocity, {"null"}))) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating drift velocity: null.");
|
DEBUG_LEVEL_2("Creating drift velocity: null.");
|
||||||
#endif
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
} else {
|
} else {
|
||||||
ERROR("No drift velocity given.");
|
ERROR("No drift velocity given.");
|
||||||
@@ -33,18 +29,14 @@ std::shared_ptr<DriftVelocity> buildDriftVelocityIncludingRedirection(
|
|||||||
std::stringstream cpath;
|
std::stringstream cpath;
|
||||||
if (parameter.jsonObjectFromBase(
|
if (parameter.jsonObjectFromBase(
|
||||||
json_path_append(path_to_drift_velocity, {"CreateSameAs"}))) {
|
json_path_append(path_to_drift_velocity, {"CreateSameAs"}))) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating drift velocity: CreateSameAs.");
|
DEBUG_LEVEL_2("Creating drift velocity: CreateSameAs.");
|
||||||
#endif
|
|
||||||
json_path path_to_same = json_path_get(parameter.jsonObjectFromBase(
|
json_path path_to_same = json_path_get(parameter.jsonObjectFromBase(
|
||||||
json_path_append(path_to_drift_velocity, {"CreateSameAs"})));
|
json_path_append(path_to_drift_velocity, {"CreateSameAs"})));
|
||||||
#ifdef debug_level3
|
|
||||||
std::stringstream path;
|
std::stringstream path;
|
||||||
for (auto& p : path_to_same) {
|
for (auto& p : path_to_same) {
|
||||||
path << p << " ";
|
path << p << " ";
|
||||||
}
|
}
|
||||||
DEBUG_LEVEL_3("From path: " + path.str());
|
DEBUG_LEVEL_3("From path: " + path.str());
|
||||||
#endif
|
|
||||||
return buildDriftVelocityIncludingRedirection(parameter, path_to_same);
|
return buildDriftVelocityIncludingRedirection(parameter, path_to_same);
|
||||||
} else {
|
} else {
|
||||||
return buildDriftVelocity(parameter, path_to_drift_velocity);
|
return buildDriftVelocity(parameter, path_to_drift_velocity);
|
||||||
|
|||||||
@@ -6,16 +6,12 @@
|
|||||||
namespace generator {
|
namespace generator {
|
||||||
|
|
||||||
std::shared_ptr<ElectricField> electricField(json_t* object) {
|
std::shared_ptr<ElectricField> electricField(json_t* object) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Generating electric field.");
|
DEBUG_LEVEL_2("Generating electric field.");
|
||||||
#endif
|
|
||||||
std::shared_ptr<VectorField> background;
|
std::shared_ptr<VectorField> background;
|
||||||
std::shared_ptr<VectorField> dynamic;
|
std::shared_ptr<VectorField> dynamic;
|
||||||
|
|
||||||
if (json_object_by_path(object, {"Background"})) {
|
if (json_object_by_path(object, {"Background"})) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Generating background electric field.");
|
DEBUG_LEVEL_2("Generating background electric field.");
|
||||||
#endif
|
|
||||||
background = buildVectorField(
|
background = buildVectorField(
|
||||||
json_object_by_path(object, {"Background", "VectorField"}));
|
json_object_by_path(object, {"Background", "VectorField"}));
|
||||||
} else {
|
} else {
|
||||||
@@ -23,9 +19,7 @@ std::shared_ptr<ElectricField> electricField(json_t* object) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (json_object_by_path(object, {"Dynamic"})) {
|
if (json_object_by_path(object, {"Dynamic"})) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Generating dynamic electric field.");
|
DEBUG_LEVEL_2("Generating dynamic electric field.");
|
||||||
#endif
|
|
||||||
dynamic = buildVectorField(
|
dynamic = buildVectorField(
|
||||||
json_object_by_path(object, {"Dynamic", "VectorField"}));
|
json_object_by_path(object, {"Dynamic", "VectorField"}));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -11,37 +11,21 @@ std::shared_ptr<EnergyDistributionFunction> buildEnergyDistributionFunction(
|
|||||||
json_t* object = parameter.jsonObjectFromBase(path_to_function);
|
json_t* object = parameter.jsonObjectFromBase(path_to_function);
|
||||||
|
|
||||||
if (json_object_by_path(object, {"TritiumBetaDecay"})) {
|
if (json_object_by_path(object, {"TritiumBetaDecay"})) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating energy distribution function: tritium beta decay.");
|
DEBUG_LEVEL_2("Creating energy distribution function: tritium beta decay.");
|
||||||
#endif
|
|
||||||
return std::shared_ptr<EnergyDistributionFunction>(new TritiumBetaDecay());
|
return std::shared_ptr<EnergyDistributionFunction>(new TritiumBetaDecay());
|
||||||
} else if(json_object_by_path(object, {"TritiumBetaDecayIon"})) {
|
|
||||||
#ifdef debug_level2
|
} else if (json_object_by_path(object, {"MaxwellBoltzmann"})) {
|
||||||
DEBUG_LEVEL_2("Creating energy distribution function: tritium beta decay ion.");
|
|
||||||
#endif
|
|
||||||
double endpoint_eV = json_read_energy(json_object_by_path(object,
|
|
||||||
{"TritiumBetaDecayIon", "MaxRecoilEnergy"}));
|
|
||||||
return std::shared_ptr<EnergyDistributionFunction>(new TritiumBetaDecayIon(endpoint_eV));
|
|
||||||
}else if (json_object_by_path(object, {"MaxwellBoltzmann"})) {
|
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating energy distribution function: Maxwell Boltzmann.");
|
DEBUG_LEVEL_2("Creating energy distribution function: Maxwell Boltzmann.");
|
||||||
#endif
|
|
||||||
double temperature_K = json_double(json_object_by_path(
|
double temperature_K = json_double(json_object_by_path(
|
||||||
object, {"MaxwellBoltzmann", "Temperature", "value"}));
|
object, {"MaxwellBoltzmann", "Temperature", "value"}));
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("with temperature: " + std::to_string(temperature_K) + " K");
|
DEBUG_LEVEL_3("with temperature: " + std::to_string(temperature_K) + " K");
|
||||||
#endif
|
|
||||||
return std::shared_ptr<EnergyDistributionFunction>(
|
return std::shared_ptr<EnergyDistributionFunction>(
|
||||||
new MaxwellBoltzmann(temperature_K));
|
new MaxwellBoltzmann(temperature_K));
|
||||||
} else if (json_object_by_path(object, {"Constant"})) {
|
} else if (json_object_by_path(object, {"Constant"})) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating energy distribution function: Constant.");
|
DEBUG_LEVEL_2("Creating energy distribution function: Constant.");
|
||||||
#endif
|
|
||||||
double constant_eV = json_double(
|
double constant_eV = json_double(
|
||||||
json_object_by_path(object, {"Constant", "constant", "value"}));
|
json_object_by_path(object, {"Constant", "constant", "value"}));
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("with constant: " + std::to_string(constant_eV) + " eV");
|
DEBUG_LEVEL_3("with constant: " + std::to_string(constant_eV) + " eV");
|
||||||
#endif
|
|
||||||
return std::shared_ptr<EnergyDistributionFunction>(
|
return std::shared_ptr<EnergyDistributionFunction>(
|
||||||
new Constant(constant_eV));
|
new Constant(constant_eV));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,20 +11,14 @@ namespace generator {
|
|||||||
|
|
||||||
std::function<double(double)> function1D(json_t* object) {
|
std::function<double(double)> function1D(json_t* object) {
|
||||||
if (json_object_by_path(object, {"Constant"})) {
|
if (json_object_by_path(object, {"Constant"})) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating function1d: constant.");
|
DEBUG_LEVEL_2("Creating function1d: constant.");
|
||||||
#endif
|
|
||||||
double constant =
|
double constant =
|
||||||
json_double(json_object_by_path(object, {"Constant", "constant"}));
|
json_double(json_object_by_path(object, {"Constant", "constant"}));
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("with constant: " + std::to_string(constant));
|
DEBUG_LEVEL_3("with constant: " + std::to_string(constant));
|
||||||
#endif
|
|
||||||
return D1ToD1::Constant(constant);
|
return D1ToD1::Constant(constant);
|
||||||
|
|
||||||
} else if (json_object_by_path(object, {"PiecewiseLinear"})) {
|
} else if (json_object_by_path(object, {"PiecewiseLinear"})) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating function1d: PiecewiseLinear.");
|
DEBUG_LEVEL_2("Creating function1d: PiecewiseLinear.");
|
||||||
#endif
|
|
||||||
std::vector<double> x_values = json_vector(
|
std::vector<double> x_values = json_vector(
|
||||||
json_object_by_path(object, {"PiecewiseLinear", {"xValues"}}));
|
json_object_by_path(object, {"PiecewiseLinear", {"xValues"}}));
|
||||||
std::vector<double> y_values = json_vector(
|
std::vector<double> y_values = json_vector(
|
||||||
@@ -37,15 +31,11 @@ std::function<double(double)> function1D(json_t* object) {
|
|||||||
return D1ToD1::PiecewiseLinear(x_values, y_values);
|
return D1ToD1::PiecewiseLinear(x_values, y_values);
|
||||||
|
|
||||||
} else if (json_object_by_path(object, {"PiecewiseLinearFromFile"})) {
|
} else if (json_object_by_path(object, {"PiecewiseLinearFromFile"})) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating function1d: PiecewiseLinear from file.");
|
DEBUG_LEVEL_2("Creating function1d: PiecewiseLinear from file.");
|
||||||
#endif
|
|
||||||
|
|
||||||
std::string absolute_filename = readAbsoluteFilename(
|
std::string absolute_filename = readAbsoluteFilename(
|
||||||
json_object_by_path(object, {"PiecewiseLinearFromFile", "PathToH5"}));
|
json_object_by_path(object, {"PiecewiseLinearFromFile", "PathToH5"}));
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("with filename: " + absolute_filename);
|
DEBUG_LEVEL_3("with filename: " + absolute_filename);
|
||||||
#endif
|
|
||||||
Hdf5Reader reader(absolute_filename);
|
Hdf5Reader reader(absolute_filename);
|
||||||
|
|
||||||
std::string x_values_key = json_string(
|
std::string x_values_key = json_string(
|
||||||
@@ -63,9 +53,7 @@ std::function<double(double)> function1D(json_t* object) {
|
|||||||
|
|
||||||
double prefactor = json_double(json_object_by_path(
|
double prefactor = json_double(json_object_by_path(
|
||||||
object, {"PiecewiseLinearFromFile", {"prefactor"}}));
|
object, {"PiecewiseLinearFromFile", {"prefactor"}}));
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("with prefactor: " + std::to_string(prefactor));
|
DEBUG_LEVEL_3("with prefactor: " + std::to_string(prefactor));
|
||||||
#endif
|
|
||||||
|
|
||||||
for (int i = 0; i < y_values.size(); ++i) {
|
for (int i = 0; i < y_values.size(); ++i) {
|
||||||
y_values[i] = y_values[i] * prefactor;
|
y_values[i] = y_values[i] * prefactor;
|
||||||
@@ -73,9 +61,7 @@ std::function<double(double)> function1D(json_t* object) {
|
|||||||
return D1ToD1::PiecewiseLinear(x_values, y_values);
|
return D1ToD1::PiecewiseLinear(x_values, y_values);
|
||||||
|
|
||||||
} else if (json_object_by_path(object, {"Product"})) {
|
} else if (json_object_by_path(object, {"Product"})) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating function1d: Product.");
|
DEBUG_LEVEL_2("Creating function1d: Product.");
|
||||||
#endif
|
|
||||||
json_t* function_array = json_object_by_path(object, {"Product"});
|
json_t* function_array = json_object_by_path(object, {"Product"});
|
||||||
std::vector<std::function<double(double)>> functions;
|
std::vector<std::function<double(double)>> functions;
|
||||||
size_t index;
|
size_t index;
|
||||||
@@ -86,9 +72,7 @@ std::function<double(double)> function1D(json_t* object) {
|
|||||||
return D1ToD1::Product(functions);
|
return D1ToD1::Product(functions);
|
||||||
|
|
||||||
} else if (json_object_by_path(object, {"Exponential"})) {
|
} else if (json_object_by_path(object, {"Exponential"})) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating function1d: Exponential.");
|
DEBUG_LEVEL_2("Creating function1d: Exponential.");
|
||||||
#endif
|
|
||||||
double prefactor = json_double(json_object_by_path(
|
double prefactor = json_double(json_object_by_path(
|
||||||
object, {"Exponential", {"prefactor"}}));
|
object, {"Exponential", {"prefactor"}}));
|
||||||
double scale = json_double(json_object_by_path(
|
double scale = json_double(json_object_by_path(
|
||||||
@@ -102,16 +86,12 @@ std::function<double(double)> function1D(json_t* object) {
|
|||||||
|
|
||||||
std::function<double(double, double, double)> function3D(json_t* object) {
|
std::function<double(double, double, double)> function3D(json_t* object) {
|
||||||
if (json_object_by_path(object, {"Constant3D"})) {
|
if (json_object_by_path(object, {"Constant3D"})) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating function3d: Constant3D.");
|
DEBUG_LEVEL_2("Creating function3d: Constant3D.");
|
||||||
#endif
|
|
||||||
double constant =
|
double constant =
|
||||||
json_double(json_object_by_path(object, {"Constant3D", "constant"}));
|
json_double(json_object_by_path(object, {"Constant3D", "constant"}));
|
||||||
return D3ToD1::Constant(constant);
|
return D3ToD1::Constant(constant);
|
||||||
} else if (json_object_by_path(object, {"Product"})) {
|
} else if (json_object_by_path(object, {"Product"})) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating function3d: Product.");
|
DEBUG_LEVEL_2("Creating function3d: Product.");
|
||||||
#endif
|
|
||||||
std::function<double(double)> fi =
|
std::function<double(double)> fi =
|
||||||
function1D(json_object_by_path(object, {"Product", "fi"}));
|
function1D(json_object_by_path(object, {"Product", "fi"}));
|
||||||
std::function<double(double)> fj =
|
std::function<double(double)> fj =
|
||||||
|
|||||||
@@ -7,9 +7,7 @@ std::shared_ptr<Geometry> buildGeometry(Parameter& parameter,
|
|||||||
const json_path& path_to_geometry) {
|
const json_path& path_to_geometry) {
|
||||||
if (parameter.jsonObjectFromBase(
|
if (parameter.jsonObjectFromBase(
|
||||||
json_path_append(path_to_geometry, {"Cylinder"}))) {
|
json_path_append(path_to_geometry, {"Cylinder"}))) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating geometry: cylinder.");
|
DEBUG_LEVEL_2("Creating geometry: cylinder.");
|
||||||
#endif
|
|
||||||
double radius =
|
double radius =
|
||||||
json_read_length(parameter.jsonObjectFromBase(json_path_append(
|
json_read_length(parameter.jsonObjectFromBase(json_path_append(
|
||||||
path_to_geometry, {"Cylinder", "Radius"})),
|
path_to_geometry, {"Cylinder", "Radius"})),
|
||||||
@@ -18,10 +16,8 @@ std::shared_ptr<Geometry> buildGeometry(Parameter& parameter,
|
|||||||
json_read_length(parameter.jsonObjectFromBase(json_path_append(
|
json_read_length(parameter.jsonObjectFromBase(json_path_append(
|
||||||
path_to_geometry, {"Cylinder", "Height"})),
|
path_to_geometry, {"Cylinder", "Height"})),
|
||||||
"m");
|
"m");
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("with radius: " + std::to_string(radius) + " m");
|
DEBUG_LEVEL_3("with radius: " + std::to_string(radius) + " m");
|
||||||
DEBUG_LEVEL_3("with height: " + std::to_string(height) + " m");
|
DEBUG_LEVEL_3("with height: " + std::to_string(height) + " m");
|
||||||
#endif
|
|
||||||
return std::shared_ptr<Geometry>(new Cylinder(radius, height));
|
return std::shared_ptr<Geometry>(new Cylinder(radius, height));
|
||||||
} else {
|
} else {
|
||||||
ERROR("This geometry is not implemented.");
|
ERROR("This geometry is not implemented.");
|
||||||
@@ -33,18 +29,14 @@ std::shared_ptr<Geometry> buildGeometryIncludingRedirection(
|
|||||||
Parameter& parameter, const json_path& path_to_geometry) {
|
Parameter& parameter, const json_path& path_to_geometry) {
|
||||||
if (parameter.jsonObjectFromBase(
|
if (parameter.jsonObjectFromBase(
|
||||||
json_path_append(path_to_geometry, {"CreateSameAs"}))) {
|
json_path_append(path_to_geometry, {"CreateSameAs"}))) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating geometry: CreateSameAs.");
|
DEBUG_LEVEL_2("Creating geometry: CreateSameAs.");
|
||||||
#endif
|
|
||||||
json_path path_to_same = json_path_get(parameter.jsonObjectFromBase(
|
json_path path_to_same = json_path_get(parameter.jsonObjectFromBase(
|
||||||
json_path_append(path_to_geometry, {"CreateSameAs"})));
|
json_path_append(path_to_geometry, {"CreateSameAs"})));
|
||||||
std::stringstream path;
|
std::stringstream path;
|
||||||
for (auto& p : path_to_same) {
|
for (auto& p : path_to_same) {
|
||||||
path << p << " ";
|
path << p << " ";
|
||||||
}
|
}
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("From path: " + path.str());
|
DEBUG_LEVEL_3("From path: " + path.str());
|
||||||
#endif
|
|
||||||
return buildGeometryIncludingRedirection(parameter, path_to_same);
|
return buildGeometryIncludingRedirection(parameter, path_to_same);
|
||||||
} else {
|
} else {
|
||||||
return buildGeometry(parameter, path_to_geometry);
|
return buildGeometry(parameter, path_to_geometry);
|
||||||
|
|||||||
@@ -5,23 +5,14 @@
|
|||||||
namespace generator {
|
namespace generator {
|
||||||
|
|
||||||
std::shared_ptr<GravityField> gravityField(json_t* object) {
|
std::shared_ptr<GravityField> gravityField(json_t* object) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Generating gravity field.");
|
DEBUG_LEVEL_2("Generating gravity field.");
|
||||||
#endif
|
|
||||||
return std::shared_ptr<GravityField>(new GravityField(
|
return std::shared_ptr<GravityField>(new GravityField(
|
||||||
buildVectorField(json_object_by_path(object, {"VectorField"}))));
|
buildVectorField(json_object_by_path(object, {"VectorField"}))));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<GravityField> gravityField(Parameter& parameter) {
|
std::shared_ptr<GravityField> gravityField(Parameter& parameter) {
|
||||||
if(json_object_by_path(parameter.jsonFile(), {"GravityField"})) {
|
return gravityField(
|
||||||
return gravityField(
|
json_object_by_path(parameter.jsonFile(), {"GravityField"}));
|
||||||
json_object_by_path(parameter.jsonFile(), {"GravityField"}));
|
|
||||||
} else {
|
|
||||||
SIM_INFO("No \"GravityField\" object in the json file. Use default of (0,0,0).");
|
|
||||||
return std::shared_ptr<GravityField>( new GravityField(
|
|
||||||
std::shared_ptr<VectorField>( new VectorFieldConstant(
|
|
||||||
CylinderVector(blitz::TinyVector<double, 3> (0,0,0))))));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -4,7 +4,6 @@
|
|||||||
#include "generators/velocity_distribution_generator.h"
|
#include "generators/velocity_distribution_generator.h"
|
||||||
#include "simulation/event_position_distribution.h"
|
#include "simulation/event_position_distribution.h"
|
||||||
#include "simulation/velocity_distribution.h"
|
#include "simulation/velocity_distribution.h"
|
||||||
#include "simulation/mpi_communication.h"
|
|
||||||
|
|
||||||
namespace generator {
|
namespace generator {
|
||||||
|
|
||||||
@@ -26,9 +25,7 @@ std::shared_ptr<Injector> buildInjector(
|
|||||||
json_object_foreach(array, key, value) {
|
json_object_foreach(array, key, value) {
|
||||||
std::string specie_name =
|
std::string specie_name =
|
||||||
json_string(json_object_by_path(value, {"TrackedSpecieName"}));
|
json_string(json_object_by_path(value, {"TrackedSpecieName"}));
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("Injected specie: " + specie_name);
|
DEBUG_LEVEL_3("Injected specie: " + specie_name);
|
||||||
#endif
|
|
||||||
InjectorInfo info;
|
InjectorInfo info;
|
||||||
info.created_specie = tracked_species[specie_name];
|
info.created_specie = tracked_species[specie_name];
|
||||||
|
|
||||||
@@ -36,29 +33,11 @@ std::shared_ptr<Injector> buildInjector(
|
|||||||
parameter,
|
parameter,
|
||||||
json_path_append(path_to_injector, {"CreatedSpecies", std::string(key),
|
json_path_append(path_to_injector, {"CreatedSpecies", std::string(key),
|
||||||
"CreationVelocityDistribution"}));
|
"CreationVelocityDistribution"}));
|
||||||
|
|
||||||
// info.multiplicity = json_int(json_object_by_path(value, {"Multiplicity"}), 1);
|
|
||||||
// ASSERT_POSITIVE(&info.multiplicity, "The multiplicity has to be positive. " +
|
|
||||||
// specie_name + " multiplicity: " + std::to_string(info.multiplicity));
|
|
||||||
int injection_stride = json_int(json_object_by_path(value, {"InjectionStride"}), 1);
|
|
||||||
ASSERT_POSITIVE(&injection_stride, "The injection stride for " + specie_name +
|
|
||||||
" is not positive! (" + std::to_string(injection_stride) + ")");
|
|
||||||
if(injection_stride > MpiCommunication::mpiSize()) {
|
|
||||||
ERROR("Injection stride for " + specie_name + ": "
|
|
||||||
+ std::to_string(injection_stride) + " is larger than the number"
|
|
||||||
" of processes (" + std::to_string(MpiCommunication::mpiSize()) + ")");
|
|
||||||
}
|
|
||||||
|
|
||||||
info.injection_stride = injection_stride;
|
|
||||||
info.injection_group = MpiCommunication::mpi_rank % injection_stride;
|
|
||||||
|
|
||||||
injector_infos.push_back(info);
|
injector_infos.push_back(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
// EventPositionDistribution
|
// EventPositionDistribution
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating event distribution.");
|
DEBUG_LEVEL_2("Creating event distribution.");
|
||||||
#endif
|
|
||||||
std::shared_ptr<ScalarField> field = buildScalarField(json_object_by_path(
|
std::shared_ptr<ScalarField> field = buildScalarField(json_object_by_path(
|
||||||
object, {"EventPositionDistribution", "ScalarField"}));
|
object, {"EventPositionDistribution", "ScalarField"}));
|
||||||
|
|
||||||
@@ -97,9 +76,7 @@ std::shared_ptr<Injector> buildInjector(
|
|||||||
position_limit_phi, position_limit_z));
|
position_limit_phi, position_limit_z));
|
||||||
|
|
||||||
// MotherDriftVelocity
|
// MotherDriftVelocity
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating mother drift velocity.");
|
DEBUG_LEVEL_2("Creating mother drift velocity.");
|
||||||
#endif
|
|
||||||
std::shared_ptr<DriftVelocity> drift_velocity = buildDriftVelocity(
|
std::shared_ptr<DriftVelocity> drift_velocity = buildDriftVelocity(
|
||||||
parameter, json_path_append(path_to_injector, {"MotherDriftVelocity"}));
|
parameter, json_path_append(path_to_injector, {"MotherDriftVelocity"}));
|
||||||
|
|
||||||
|
|||||||
@@ -33,9 +33,7 @@ void addInteractions(
|
|||||||
std::string type = json_string(json_object_by_path(value, {"Type"}));
|
std::string type = json_string(json_object_by_path(value, {"Type"}));
|
||||||
|
|
||||||
if (type == "ElasticScattering") {
|
if (type == "ElasticScattering") {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Adding interactions: ElasticScattering");
|
DEBUG_LEVEL_2("Adding interactions: ElasticScattering");
|
||||||
#endif
|
|
||||||
std::function<double(double)> cross_section =
|
std::function<double(double)> cross_section =
|
||||||
buildTotalCrossSection(json_object_by_path(value, {"CrossSection"}));
|
buildTotalCrossSection(json_object_by_path(value, {"CrossSection"}));
|
||||||
|
|
||||||
@@ -45,9 +43,7 @@ void addInteractions(
|
|||||||
|
|
||||||
std::string target_name =
|
std::string target_name =
|
||||||
json_string(json_object_by_path(value, {"Target"}));
|
json_string(json_object_by_path(value, {"Target"}));
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("with target " + target_name);
|
DEBUG_LEVEL_3("with target " + target_name);
|
||||||
#endif
|
|
||||||
|
|
||||||
std::shared_ptr<species::Specie> target =
|
std::shared_ptr<species::Specie> target =
|
||||||
findTarget(target_name, tracked_species, background_species);
|
findTarget(target_name, tracked_species, background_species);
|
||||||
@@ -56,40 +52,12 @@ void addInteractions(
|
|||||||
new interaction::ElasticScattering(cross_section, target,
|
new interaction::ElasticScattering(cross_section, target,
|
||||||
scattering_angle_distribution)));
|
scattering_angle_distribution)));
|
||||||
|
|
||||||
} else if (type == "ElasticScatteringFull") {
|
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Adding interactions: ElasticScatteringFull");
|
|
||||||
#endif
|
|
||||||
std::function<double(double)> cross_section =
|
|
||||||
buildTotalCrossSection(json_object_by_path(value, {"CrossSection"}));
|
|
||||||
|
|
||||||
std::string target_name =
|
|
||||||
json_string(json_object_by_path(value, {"Target"}));
|
|
||||||
std::string product_name =
|
|
||||||
json_string(json_object_by_path(value, {"Product"}));
|
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG("with target " + target_name);
|
|
||||||
DEBUG("and product " + product_name);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::shared_ptr<species::Specie> target =
|
|
||||||
findTarget(target_name, tracked_species, background_species);
|
|
||||||
std::shared_ptr<species::TrackedSpecie> product =
|
|
||||||
findTracked(product_name, tracked_species);
|
|
||||||
|
|
||||||
specie->addInteraction(std::shared_ptr<interaction::Interaction>(
|
|
||||||
new interaction::ElasticScatteringFull(cross_section, target,
|
|
||||||
nullptr, product)));
|
|
||||||
} else if (type == "FreeMovement") {
|
} else if (type == "FreeMovement") {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Adding interactions: FreeMovement");
|
DEBUG_LEVEL_2("Adding interactions: FreeMovement");
|
||||||
#endif
|
|
||||||
specie->addInteraction(std::shared_ptr<interaction::Interaction>(
|
specie->addInteraction(std::shared_ptr<interaction::Interaction>(
|
||||||
new interaction::FreeMovement()));
|
new interaction::FreeMovement()));
|
||||||
} else if (type == "ElectronIonization") {
|
} else if (type == "ElectronIonization") {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Adding interactions: Ionization");
|
DEBUG_LEVEL_2("Adding interactions: Ionization");
|
||||||
#endif
|
|
||||||
std::string target_name =
|
std::string target_name =
|
||||||
json_string(json_object_by_path(value, {"Target"}));
|
json_string(json_object_by_path(value, {"Target"}));
|
||||||
std::shared_ptr<species::Specie> target =
|
std::shared_ptr<species::Specie> target =
|
||||||
@@ -107,7 +75,6 @@ void addInteractions(
|
|||||||
|
|
||||||
std::string ionization_model =
|
std::string ionization_model =
|
||||||
json_string(json_object_by_path(value, {"IonizationModel"}));
|
json_string(json_object_by_path(value, {"IonizationModel"}));
|
||||||
|
|
||||||
if (ionization_model == "JanevNonDiss") {
|
if (ionization_model == "JanevNonDiss") {
|
||||||
std::function<double(double)> cross_section =
|
std::function<double(double)> cross_section =
|
||||||
interaction::totalCrossSection::eT2_ionization_janev_non_diss();
|
interaction::totalCrossSection::eT2_ionization_janev_non_diss();
|
||||||
@@ -133,7 +100,7 @@ void addInteractions(
|
|||||||
std::make_shared<interaction::ElectronIonization>(
|
std::make_shared<interaction::ElectronIonization>(
|
||||||
cross_section, target, electron, ion,
|
cross_section, target, electron, ion,
|
||||||
ionization_energy_distribution, scattering_angle_distribution,
|
ionization_energy_distribution, scattering_angle_distribution,
|
||||||
ionization_energy_eV, 0.));
|
ionization_energy_eV));
|
||||||
} else if (ionization_model == "JanevDissToGround") {
|
} else if (ionization_model == "JanevDissToGround") {
|
||||||
std::function<double(double)> cross_section =
|
std::function<double(double)> cross_section =
|
||||||
interaction::totalCrossSection::eT2_ionization_janev_diss_ground();
|
interaction::totalCrossSection::eT2_ionization_janev_diss_ground();
|
||||||
@@ -159,7 +126,7 @@ void addInteractions(
|
|||||||
std::make_shared<interaction::ElectronIonization>(
|
std::make_shared<interaction::ElectronIonization>(
|
||||||
cross_section, target, electron, ion,
|
cross_section, target, electron, ion,
|
||||||
ionization_energy_distribution, scattering_angle_distribution,
|
ionization_energy_distribution, scattering_angle_distribution,
|
||||||
ionization_energy_eV, 9.));
|
ionization_energy_eV));
|
||||||
} else if (ionization_model == "JanevDissToFirstExcited") {
|
} else if (ionization_model == "JanevDissToFirstExcited") {
|
||||||
std::function<double(double)> cross_section =
|
std::function<double(double)> cross_section =
|
||||||
interaction::totalCrossSection::eT2_ionization_janev_diss_first();
|
interaction::totalCrossSection::eT2_ionization_janev_diss_first();
|
||||||
@@ -187,7 +154,7 @@ void addInteractions(
|
|||||||
std::make_shared<interaction::ElectronIonization>(
|
std::make_shared<interaction::ElectronIonization>(
|
||||||
cross_section, target, electron, ion,
|
cross_section, target, electron, ion,
|
||||||
ionization_energy_distribution, scattering_angle_distribution,
|
ionization_energy_distribution, scattering_angle_distribution,
|
||||||
ionization_energy_eV, 9.));
|
ionization_energy_eV));
|
||||||
} else if (ionization_model == "JanevAtomic") {
|
} else if (ionization_model == "JanevAtomic") {
|
||||||
std::function<double(double)> cross_section =
|
std::function<double(double)> cross_section =
|
||||||
interaction::totalCrossSection::eT_ionization_from_ground_janev();
|
interaction::totalCrossSection::eT_ionization_from_ground_janev();
|
||||||
@@ -211,14 +178,12 @@ void addInteractions(
|
|||||||
std::make_shared<interaction::ElectronIonization>(
|
std::make_shared<interaction::ElectronIonization>(
|
||||||
cross_section, target, electron, ion,
|
cross_section, target, electron, ion,
|
||||||
ionization_energy_distribution, scattering_angle_distribution,
|
ionization_energy_distribution, scattering_angle_distribution,
|
||||||
ionization_energy_eV, 0.));
|
ionization_energy_eV));
|
||||||
} else {
|
} else {
|
||||||
ERROR("This ionization model is not implemented: " + ionization_model);
|
ERROR("This ionization model is not implemented: " + ionization_model);
|
||||||
}
|
}
|
||||||
} else if (type == "Excitation") {
|
} else if (type == "Excitation") {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Adding interactions: Excitation");
|
DEBUG_LEVEL_2("Adding interactions: Excitation");
|
||||||
#endif
|
|
||||||
std::string target_name =
|
std::string target_name =
|
||||||
json_string(json_object_by_path(value, {"Target"}));
|
json_string(json_object_by_path(value, {"Target"}));
|
||||||
std::shared_ptr<species::Specie> target =
|
std::shared_ptr<species::Specie> target =
|
||||||
@@ -236,9 +201,7 @@ void addInteractions(
|
|||||||
cross_section, target, excitation_energy)));
|
cross_section, target, excitation_energy)));
|
||||||
|
|
||||||
} else if (type == "Clustering") {
|
} else if (type == "Clustering") {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Adding interactions: Clustering");
|
DEBUG_LEVEL_2("Adding interactions: Clustering");
|
||||||
#endif
|
|
||||||
std::string target_name =
|
std::string target_name =
|
||||||
json_string(json_object_by_path(value, {"Target"}));
|
json_string(json_object_by_path(value, {"Target"}));
|
||||||
std::shared_ptr<species::Specie> target =
|
std::shared_ptr<species::Specie> target =
|
||||||
@@ -249,37 +212,12 @@ void addInteractions(
|
|||||||
std::shared_ptr<species::TrackedSpecie> product =
|
std::shared_ptr<species::TrackedSpecie> product =
|
||||||
findTracked(product_name, tracked_species);
|
findTracked(product_name, tracked_species);
|
||||||
|
|
||||||
std::string clustering_type =
|
|
||||||
json_string(json_object_by_path(value, {"ClusteringType"}));
|
|
||||||
|
|
||||||
std::function<double(double)> cross_section =
|
std::function<double(double)> cross_section =
|
||||||
buildTotalCrossSection(json_object_by_path(value, {"CrossSection"}));
|
buildTotalCrossSection(json_object_by_path(value, {"CrossSection"}));
|
||||||
|
specie->addInteraction(std::shared_ptr<interaction::Interaction>(
|
||||||
if(clustering_type == "radiative") {
|
new interaction::ClusterFormation(cross_section, target, product)));
|
||||||
specie->addInteraction(std::shared_ptr<interaction::Interaction>(
|
|
||||||
new interaction::ClusterFormation(cross_section, target, product)));
|
|
||||||
} else if (clustering_type == "tertiary") {
|
|
||||||
SIM_INFO("Warning: tertiary clustering has been chosen. Be warned "
|
|
||||||
"that the cross section function is scaled by the density "
|
|
||||||
"of the target specie at the position of the interaction "
|
|
||||||
"(cross section function assumed to have the units m^5)");
|
|
||||||
|
|
||||||
if(json_string(json_object_by_path(value, {"CrossSection", "PredefinedFunction"}))
|
|
||||||
== "T2pT2_clustering_janev") {
|
|
||||||
specie->addInteraction(std::shared_ptr<interaction::Interaction>(
|
|
||||||
new interaction::ClusterFormationTertiary(cross_section, target, product, false)));
|
|
||||||
} else {
|
|
||||||
specie->addInteraction(std::shared_ptr<interaction::Interaction>(
|
|
||||||
new interaction::ClusterFormationTertiary(cross_section, target, product)));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ERROR("ClusteringType " + clustering_type +
|
|
||||||
": not known, choose either 'radiative' or 'tertiary'.");
|
|
||||||
}
|
|
||||||
} else if (type == "ChargeExchange") {
|
} else if (type == "ChargeExchange") {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Adding interactions: ChargeExchange");
|
DEBUG_LEVEL_2("Adding interactions: ChargeExchange");
|
||||||
#endif
|
|
||||||
std::string target_name =
|
std::string target_name =
|
||||||
json_string(json_object_by_path(value, {"Target"}));
|
json_string(json_object_by_path(value, {"Target"}));
|
||||||
std::shared_ptr<species::Specie> target =
|
std::shared_ptr<species::Specie> target =
|
||||||
@@ -290,9 +228,7 @@ void addInteractions(
|
|||||||
specie->addInteraction(std::shared_ptr<interaction::Interaction>(
|
specie->addInteraction(std::shared_ptr<interaction::Interaction>(
|
||||||
new interaction::ChargeExchange(cross_section, target)));
|
new interaction::ChargeExchange(cross_section, target)));
|
||||||
} else if (type == "Recombination") {
|
} else if (type == "Recombination") {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Adding interactions: Recombination");
|
DEBUG_LEVEL_2("Adding interactions: Recombination");
|
||||||
#endif
|
|
||||||
std::string target_name =
|
std::string target_name =
|
||||||
json_string(json_object_by_path(value, {"Target"}));
|
json_string(json_object_by_path(value, {"Target"}));
|
||||||
std::shared_ptr<species::TrackedSpecie> target =
|
std::shared_ptr<species::TrackedSpecie> target =
|
||||||
@@ -352,7 +288,7 @@ std::function<double(double)> buildTotalCrossSection(json_t* object) {
|
|||||||
return interaction::totalCrossSection::eT_ionization_from_ground_janev();
|
return interaction::totalCrossSection::eT_ionization_from_ground_janev();
|
||||||
} else if (function_name == "TpT_clustering_tertiary_janev") {
|
} else if (function_name == "TpT_clustering_tertiary_janev") {
|
||||||
// needs to be changed to account for the temperature, probs smth like excitation
|
// needs to be changed to account for the temperature, probs smth like excitation
|
||||||
return interaction::totalCrossSection::TpT_clustering_tertiary_janev(5e-3);
|
return interaction::totalCrossSection::TpT_clustering_tertiary_janev(80.);
|
||||||
} else if (function_name == "eTp_recombination_kotelnikov") {
|
} else if (function_name == "eTp_recombination_kotelnikov") {
|
||||||
return interaction::totalCrossSection::eTp_recombination_kotelnikov();
|
return interaction::totalCrossSection::eTp_recombination_kotelnikov();
|
||||||
} else if (function_name == "TpT_charge_exchange_janev") {
|
} else if (function_name == "TpT_charge_exchange_janev") {
|
||||||
@@ -535,24 +471,18 @@ std::function<double(double, double)> build2DCrossSection(json_t* object) {
|
|||||||
std::shared_ptr<ScatteringAngleDistribution> buildScatteringAngleDistribution(
|
std::shared_ptr<ScatteringAngleDistribution> buildScatteringAngleDistribution(
|
||||||
json_t* object) {
|
json_t* object) {
|
||||||
if (json_object_by_path(object, {"Isotropic"})) {
|
if (json_object_by_path(object, {"Isotropic"})) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Adding ScatteringAngleDistribution: Isotropic");
|
DEBUG_LEVEL_2("Adding ScatteringAngleDistribution: Isotropic");
|
||||||
#endif
|
|
||||||
return std::shared_ptr<ScatteringAngleDistribution>(
|
return std::shared_ptr<ScatteringAngleDistribution>(
|
||||||
new IsotropicAngleDistribution());
|
new IsotropicAngleDistribution());
|
||||||
} else if (json_object_by_path(object, {"AngleDistributionFromFile"})) {
|
} else if (json_object_by_path(object, {"AngleDistributionFromFile"})) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2(
|
DEBUG_LEVEL_2(
|
||||||
"Adding ScatteringAngleDistribution: AngleDistributionFromFile");
|
"Adding ScatteringAngleDistribution: AngleDistributionFromFile");
|
||||||
#endif
|
|
||||||
std::string absolute_filepath = readAbsoluteFilename(
|
std::string absolute_filepath = readAbsoluteFilename(
|
||||||
json_object_by_path(object, {"AngleDistributionFromFile", "PathToH5"}));
|
json_object_by_path(object, {"AngleDistributionFromFile", "PathToH5"}));
|
||||||
return std::make_shared<AngleDistributionFromFile>(absolute_filepath);
|
return std::make_shared<AngleDistributionFromFile>(absolute_filepath);
|
||||||
} else if (json_object_by_path(object, {"CompositeAngleDistribution"})) {
|
} else if (json_object_by_path(object, {"CompositeAngleDistribution"})) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2(
|
DEBUG_LEVEL_2(
|
||||||
"Adding ScatteringAngleDistribution: CompositeAngleDistribution");
|
"Adding ScatteringAngleDistribution: CompositeAngleDistribution");
|
||||||
#endif
|
|
||||||
json_t* object_composite =
|
json_t* object_composite =
|
||||||
json_object_by_path(object, {"CompositeAngleDistribution"});
|
json_object_by_path(object, {"CompositeAngleDistribution"});
|
||||||
const double decider_energy = json_read_energy(
|
const double decider_energy = json_read_energy(
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ namespace generator {
|
|||||||
|
|
||||||
std::shared_ptr<DeletionLogger> buildDeletionLogger(json_t* object) {
|
std::shared_ptr<DeletionLogger> buildDeletionLogger(json_t* object) {
|
||||||
std::vector<DeletionType> used_types;
|
std::vector<DeletionType> used_types;
|
||||||
std::vector<PhysicalDeletionType> used_phys_types;
|
|
||||||
|
|
||||||
json_t* type = json_object_by_path(object, {"Type"});
|
json_t* type = json_object_by_path(object, {"Type"});
|
||||||
if (json_is_array(type)) {
|
if (json_is_array(type)) {
|
||||||
@@ -25,9 +24,7 @@ std::shared_ptr<DeletionLogger> buildDeletionLogger(json_t* object) {
|
|||||||
used_types.push_back(DeletionType::max_time_alive);
|
used_types.push_back(DeletionType::max_time_alive);
|
||||||
} else if (type_alias == "cluster_formation") {
|
} else if (type_alias == "cluster_formation") {
|
||||||
used_types.push_back(DeletionType::cluster_formation);
|
used_types.push_back(DeletionType::cluster_formation);
|
||||||
} else if (type_alias == "wall_physical") {
|
} else {
|
||||||
used_phys_types.push_back(PhysicalDeletionType::wall);
|
|
||||||
}else {
|
|
||||||
ERROR("This deletion type " + type_alias + " is not known.");
|
ERROR("This deletion type " + type_alias + " is not known.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -38,18 +35,15 @@ std::shared_ptr<DeletionLogger> buildDeletionLogger(json_t* object) {
|
|||||||
used_types.push_back(DeletionType::max_interactions);
|
used_types.push_back(DeletionType::max_interactions);
|
||||||
used_types.push_back(DeletionType::max_time_alive);
|
used_types.push_back(DeletionType::max_time_alive);
|
||||||
used_types.push_back(DeletionType::cluster_formation);
|
used_types.push_back(DeletionType::cluster_formation);
|
||||||
used_phys_types.push_back(PhysicalDeletionType::wall);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::make_shared<DeletionLogger>(used_types, used_phys_types);
|
return std::make_shared<DeletionLogger>(used_types);
|
||||||
}
|
}
|
||||||
std::shared_ptr<DeletionLogger> buildDeletionLogger(
|
std::shared_ptr<DeletionLogger> buildDeletionLogger(
|
||||||
Parameter& parameter,
|
Parameter& parameter,
|
||||||
const json_path& path_to_loggers) {
|
const json_path& path_to_loggers) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating deletion logger.");
|
DEBUG_LEVEL_2("Creating deletion logger.");
|
||||||
#endif
|
|
||||||
|
|
||||||
json_path path_logger = json_path_append(path_to_loggers, {"Deletion"});
|
json_path path_logger = json_path_append(path_to_loggers, {"Deletion"});
|
||||||
json_t* object = parameter.jsonObjectFromBase(path_logger);
|
json_t* object = parameter.jsonObjectFromBase(path_logger);
|
||||||
|
|||||||
@@ -5,9 +5,7 @@
|
|||||||
namespace generator {
|
namespace generator {
|
||||||
|
|
||||||
std::shared_ptr<MagneticField> magneticField(json_t* object) {
|
std::shared_ptr<MagneticField> magneticField(json_t* object) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Generating magnetic field.");
|
DEBUG_LEVEL_2("Generating magnetic field.");
|
||||||
#endif
|
|
||||||
return std::shared_ptr<MagneticField>(new MagneticField(
|
return std::shared_ptr<MagneticField>(new MagneticField(
|
||||||
buildVectorField(json_object_by_path(object, {"VectorField"})),
|
buildVectorField(json_object_by_path(object, {"VectorField"})),
|
||||||
buildVectorField(json_object_by_path(object, {"GradientField"}))));
|
buildVectorField(json_object_by_path(object, {"GradientField"}))));
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ double buildMass(json_t* object) {
|
|||||||
} else if (json_object_by_path(object, {"value"})) {
|
} else if (json_object_by_path(object, {"value"})) {
|
||||||
return json_double(json_object_by_path(object, {"value"}));
|
return json_double(json_object_by_path(object, {"value"}));
|
||||||
} else {
|
} else {
|
||||||
ERROR("The mass is not given correcty.");
|
ERROR("The mass is not given correctly.");
|
||||||
return 0.;
|
return 0.;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,17 +7,13 @@ std::shared_ptr<Mover> buildMover(Parameter& parameter,
|
|||||||
const json_path& path_to_mover) {
|
const json_path& path_to_mover) {
|
||||||
if (parameter.jsonObjectFromBase(
|
if (parameter.jsonObjectFromBase(
|
||||||
json_path_append(path_to_mover, {"Boris"}))) {
|
json_path_append(path_to_mover, {"Boris"}))) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating mover: Boris.");
|
DEBUG_LEVEL_2("Creating mover: Boris.");
|
||||||
#endif
|
|
||||||
double max_timestep_length = parameter.doubleValue(json_path_append(
|
double max_timestep_length = parameter.doubleValue(json_path_append(
|
||||||
path_to_mover, {"Boris", "MaximalTimestepLength", "value"}));
|
path_to_mover, {"Boris", "MaximalTimestepLength", "value"}));
|
||||||
return std::shared_ptr<Mover>(new BorisMover(max_timestep_length));
|
return std::shared_ptr<Mover>(new BorisMover(max_timestep_length));
|
||||||
} else if (parameter.jsonObjectFromBase(
|
} else if (parameter.jsonObjectFromBase(
|
||||||
json_path_append(path_to_mover, {"Drift"}))) {
|
json_path_append(path_to_mover, {"Drift"}))) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating mover: Drift.");
|
DEBUG_LEVEL_2("Creating mover: Drift.");
|
||||||
#endif
|
|
||||||
double maximal_moved_distance =
|
double maximal_moved_distance =
|
||||||
json_read_length(parameter.jsonObjectFromBase(json_path_append(
|
json_read_length(parameter.jsonObjectFromBase(json_path_append(
|
||||||
path_to_mover, {"Drift", "MaximalMovedDistance"})));
|
path_to_mover, {"Drift", "MaximalMovedDistance"})));
|
||||||
|
|||||||
@@ -10,14 +10,11 @@ namespace generator {
|
|||||||
std::shared_ptr<PoissonSolver> buildPoissonSolver(
|
std::shared_ptr<PoissonSolver> buildPoissonSolver(
|
||||||
Parameter& parameter) {
|
Parameter& parameter) {
|
||||||
|
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Generating Poisson solver.");
|
DEBUG_LEVEL_2("Generating Poisson solver.");
|
||||||
#endif
|
|
||||||
std::shared_ptr<Geometry> geometry;
|
std::shared_ptr<Geometry> geometry;
|
||||||
|
|
||||||
json_t* object = json_object_by_path(
|
json_t* object = json_object_by_path(
|
||||||
parameter.jsonFile(), {"PoissonSolver"});
|
parameter.jsonFile(), {"PoissonSolver"});
|
||||||
|
|
||||||
//create geometry
|
//create geometry
|
||||||
if (json_object_by_path(object, {"BoundaryGeometry"})) {
|
if (json_object_by_path(object, {"BoundaryGeometry"})) {
|
||||||
geometry = buildGeometryIncludingRedirection(parameter,
|
geometry = buildGeometryIncludingRedirection(parameter,
|
||||||
@@ -25,7 +22,6 @@ namespace generator {
|
|||||||
} else {
|
} else {
|
||||||
ERROR("Cannot find boundary geometry for poisson solver.");
|
ERROR("Cannot find boundary geometry for poisson solver.");
|
||||||
}
|
}
|
||||||
|
|
||||||
//create binning
|
//create binning
|
||||||
json_path path_binning = json_path_append({"PoissonSolver"},
|
json_path path_binning = json_path_append({"PoissonSolver"},
|
||||||
{"PositionBinning"});
|
{"PositionBinning"});
|
||||||
@@ -34,37 +30,21 @@ namespace generator {
|
|||||||
|
|
||||||
auto boundaries = buildBoundaries(parameter, {"PoissonSolver", "Boundary"});
|
auto boundaries = buildBoundaries(parameter, {"PoissonSolver", "Boundary"});
|
||||||
|
|
||||||
// build electrodes, might be good to put into own function
|
int solver_intervall = json_int(json_object_by_path(object, {"Intervall"}));
|
||||||
std::vector<std::shared_ptr<Electrode>> electrodes{};
|
if (solver_intervall == 0 &&
|
||||||
const char* key;
|
json_string(json_object_by_path(
|
||||||
json_t* value;
|
object, {"Intervall"})) == "EachSync") {
|
||||||
json_t* array = parameter.jsonObjectFromBase({"PoissonSolver", "Electrodes"});
|
solver_intervall = 1;
|
||||||
json_object_foreach(array, key, value) {
|
|
||||||
std::string type = json_string(json_object_by_path(value, {"Type"}));
|
|
||||||
if(type == "RingElectrode") {
|
|
||||||
double zpos = json_read_length(json_object_by_path(value, {"zPosition"}));
|
|
||||||
double rInner = json_read_length(json_object_by_path(value, {"InnerRadius"}));
|
|
||||||
double rOuter = json_read_length(json_object_by_path(value, {"OuterRadius"}));
|
|
||||||
double potentialValue = json_double(json_object_by_path(value, {"Potential", "value"}));
|
|
||||||
|
|
||||||
#ifdef debug
|
|
||||||
std::stringstream out;
|
|
||||||
out << "Electrode " << std::string(key) << ":\n\t";
|
|
||||||
out << "z position: " << zpos << " m\n\t";
|
|
||||||
out << "inner radius: " << rInner << " m\n\t";
|
|
||||||
out << "outer radius: " << rOuter << " m\n\t";
|
|
||||||
out << "potential: " << potentialValue << " V";
|
|
||||||
DEBUG(out.str());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
electrodes.push_back(
|
|
||||||
std::shared_ptr<RingElectrode>(
|
|
||||||
new RingElectrode(potentialValue, zpos, rInner, rOuter,
|
|
||||||
position_binning.stepsize())));
|
|
||||||
} else {
|
|
||||||
ERROR("Unknown or not implemented electrode type: " + type + ". Available options: \"RingElectrode\"");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
ASSERT_POSITIVE(&solver_intervall,
|
||||||
|
"The intervall for poisson solver stride must be positive"
|
||||||
|
" or 'EachSync'");
|
||||||
|
|
||||||
|
int solver_offset = json_int(json_object_by_path(object, {"Offset"}));
|
||||||
|
ASSERT_NOTNEGATIVE(&solver_offset,
|
||||||
|
"The offset for poisson solver has to be non-negative");
|
||||||
|
|
||||||
|
std::vector<std::shared_ptr<Electrode>> electrodes{};
|
||||||
|
|
||||||
double target_accuracy = parameter.doubleValue(
|
double target_accuracy = parameter.doubleValue(
|
||||||
json_path_append({"PoissonSolver"}, {"TargetAccuracy"}));
|
json_path_append({"PoissonSolver"}, {"TargetAccuracy"}));
|
||||||
@@ -72,19 +52,18 @@ namespace generator {
|
|||||||
int num_cycles = parameter.intValue(json_path_append({"PoissonSolver"},
|
int num_cycles = parameter.intValue(json_path_append({"PoissonSolver"},
|
||||||
{"NumCycles"}));
|
{"NumCycles"}));
|
||||||
|
|
||||||
bool do_solver = parameter.boolValue(
|
bool do_solver = parameter.boolValue(json_path_append({"PoissonSolver"},
|
||||||
json_path_append({"PoissonSolver"}, {"DoSolver"}), false);
|
{"DoSolver"}), true);
|
||||||
|
|
||||||
return std::shared_ptr<PoissonSolver>(new PoissonSolver(boundaries.at("Bottom"),
|
return std::shared_ptr<PoissonSolver>(new PoissonSolver(boundaries.at("Bottom"),
|
||||||
boundaries.at("Top"), boundaries.at("Hull"), geometry, position_binning,
|
boundaries.at("Top"), boundaries.at("Hull"), geometry, position_binning,
|
||||||
electrodes, target_accuracy, num_cycles, do_solver));
|
electrodes, target_accuracy, num_cycles, solver_intervall, solver_offset,
|
||||||
|
do_solver));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<std::string, GlobalBoundary> buildBoundaries(Parameter& parameter,
|
std::map<std::string, GlobalBoundary> buildBoundaries(Parameter& parameter,
|
||||||
const json_path& path_to_boundaries) {
|
const json_path& path_to_boundaries) {
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("Creating Boundaries.");
|
DEBUG_LEVEL_3("Creating Boundaries.");
|
||||||
#endif
|
|
||||||
std::map<std::string, GlobalBoundary> boundary_map {
|
std::map<std::string, GlobalBoundary> boundary_map {
|
||||||
{"Bottom", {0., BoundaryType::dirichlet}},
|
{"Bottom", {0., BoundaryType::dirichlet}},
|
||||||
{"Top", {0., BoundaryType::dirichlet}},
|
{"Top", {0., BoundaryType::dirichlet}},
|
||||||
@@ -99,9 +78,7 @@ namespace generator {
|
|||||||
json_t* value;
|
json_t* value;
|
||||||
json_object_foreach(parameter.jsonObjectFromBase(path_to_boundaries),
|
json_object_foreach(parameter.jsonObjectFromBase(path_to_boundaries),
|
||||||
key, value) {
|
key, value) {
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("Creating " + std::string(key) + ": ");
|
DEBUG_LEVEL_3("Creating " + std::string(key) + ": ");
|
||||||
#endif
|
|
||||||
if(!(boundary_map.find(std::string(key)) == boundary_map.end())) {
|
if(!(boundary_map.find(std::string(key)) == boundary_map.end())) {
|
||||||
double boundary_value =
|
double boundary_value =
|
||||||
json_double(json_object_by_path(value, {"value"}));
|
json_double(json_object_by_path(value, {"value"}));
|
||||||
@@ -120,10 +97,8 @@ namespace generator {
|
|||||||
". Using default boundary (dirichtlet, value 0)");
|
". Using default boundary (dirichtlet, value 0)");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("with type: " + boundary_type);
|
DEBUG_LEVEL_3("with type: " + boundary_type);
|
||||||
DEBUG_LEVEL_3("with value: " + std::to_string(boundary_value));
|
DEBUG_LEVEL_3("with value: " + std::to_string(boundary_value));
|
||||||
#endif
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
SIM_INFO(std::string(key) + ": unknown location. Is ignored.");
|
SIM_INFO(std::string(key) + ": unknown location. Is ignored.");
|
||||||
|
|||||||
@@ -8,25 +8,15 @@ std::shared_ptr<Reflector> buildReflector(Parameter& parameter,
|
|||||||
const json_path& path_to_reflector) {
|
const json_path& path_to_reflector) {
|
||||||
if (parameter.jsonObjectFromBase(
|
if (parameter.jsonObjectFromBase(
|
||||||
json_path_append(path_to_reflector, {"ReflectorDPS"}))) {
|
json_path_append(path_to_reflector, {"ReflectorDPS"}))) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Create reflector: ReflectorDPS");
|
DEBUG_LEVEL_2("Create reflector: ReflectorDPS");
|
||||||
#endif
|
|
||||||
double position_z = json_read_length(
|
double position_z = json_read_length(
|
||||||
parameter.jsonObjectFromBase(json_path_append(
|
parameter.jsonObjectFromBase(json_path_append(
|
||||||
path_to_reflector, {"ReflectorDPS", "position_z"})),
|
path_to_reflector, {"ReflectorDPS", "position_z"})),
|
||||||
"m");
|
"m");
|
||||||
return std::shared_ptr<Reflector>(new ReflectorDPS(position_z));
|
return std::shared_ptr<Reflector>(new ReflectorDPS(position_z));
|
||||||
} else if (parameter.jsonObjectFromBase(
|
|
||||||
json_path_append(path_to_reflector, {"LongitudinalReflector"}))) {
|
|
||||||
double height = json_read_length(
|
|
||||||
parameter.jsonObjectFromBase(
|
|
||||||
json_path_append(path_to_reflector, {"LongitudinalReflector", "height"})), "m");
|
|
||||||
return std::shared_ptr<Reflector>(new LongitudinalReflector(height));
|
|
||||||
} else if (parameter.jsonObjectFromBase(
|
} else if (parameter.jsonObjectFromBase(
|
||||||
json_path_append(path_to_reflector, {"NoReflector"}))) {
|
json_path_append(path_to_reflector, {"NoReflector"}))) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Create reflector: NoReflector");
|
DEBUG_LEVEL_2("Create reflector: NoReflector");
|
||||||
#endif
|
|
||||||
return std::shared_ptr<Reflector>(new NoReflector());
|
return std::shared_ptr<Reflector>(new NoReflector());
|
||||||
} else {
|
} else {
|
||||||
ERROR("This reflector is not implemented.");
|
ERROR("This reflector is not implemented.");
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
#include "generators/restart_generator.h"
|
|
||||||
#include "IO/restart.h"
|
|
||||||
#include "generators/vector_field_generator.h"
|
|
||||||
|
|
||||||
namespace generator {
|
|
||||||
Restart buildRestart(json_t* object) {
|
|
||||||
DEBUG_LEVEL_3("Build Restart.");
|
|
||||||
bool do_restart = json_bool(json_object_by_path(object, {"Do"}));
|
|
||||||
if (!do_restart) {
|
|
||||||
#ifdef debug
|
|
||||||
DEBUG_LEVEL_0("No Restart desired.");
|
|
||||||
#endif
|
|
||||||
return Restart(false, "", "", 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// no file extensions!!! Those get added in the constructor of the hdf5 and mpi
|
|
||||||
// reader classes
|
|
||||||
std::string filepath =
|
|
||||||
readAbsoluteFilename(json_object_by_path(object, {"PathToH5"}));
|
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("Restart: file path:" + filepath);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::string identifier;
|
|
||||||
int sync_period = json_int(json_object_by_path(object, {"SyncPeriod"}));
|
|
||||||
int part_restart_at = sync_period;
|
|
||||||
|
|
||||||
if(sync_period == 0 && json_string(json_object_by_path(object, {"SyncPeriod"}))
|
|
||||||
== "LastSyncPeriod") {
|
|
||||||
identifier = "LastSyncPeriod";
|
|
||||||
|
|
||||||
part_restart_at = json_int(json_object_by_path(object, {"ParticleSyncPeriod"}));
|
|
||||||
ASSERT_POSITIVE(&part_restart_at, "The ParticleSyncPeriod has to be positive!");
|
|
||||||
|
|
||||||
} else {
|
|
||||||
ASSERT_POSITIVE(&sync_period, "The SyncPeriod for the restart has to be either"
|
|
||||||
" positive or \"LastSyncPeriod\".");
|
|
||||||
identifier = "SyncPeriod_" + std::to_string(sync_period);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("Restart: SyncPeriod to be started from: " + identifier);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return Restart(do_restart, filepath, identifier, part_restart_at);
|
|
||||||
}
|
|
||||||
|
|
||||||
Restart buildRestart(Parameter& parameter) {
|
|
||||||
return buildRestart(
|
|
||||||
json_object_by_path(parameter.jsonFile(), {"Restart"}));
|
|
||||||
}
|
|
||||||
} // namespace generator
|
|
||||||
@@ -143,7 +143,7 @@ std::shared_ptr<SimulationOutput> buildSimulationOutput(
|
|||||||
intervall = 1;
|
intervall = 1;
|
||||||
}
|
}
|
||||||
ASSERT_POSITIVE(&intervall,
|
ASSERT_POSITIVE(&intervall,
|
||||||
"The intervall for the poisson solver output must be positive");
|
"The output intervall for the poisson solver output must be positive.");
|
||||||
|
|
||||||
bool overwrite_last = json_bool(
|
bool overwrite_last = json_bool(
|
||||||
json_object_by_path(object, {"PoissonSolver", "OverwriteLast"}));
|
json_object_by_path(object, {"PoissonSolver", "OverwriteLast"}));
|
||||||
@@ -153,56 +153,6 @@ std::shared_ptr<SimulationOutput> buildSimulationOutput(
|
|||||||
output->setPotentialOutput(task);
|
output->setPotentialOutput(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
// RestartInfo
|
|
||||||
{
|
|
||||||
int intervall =
|
|
||||||
json_int(json_object_by_path(object, {"RestartInfo", "Intervall"}), -1);
|
|
||||||
// DEBUG_LEVEL_2("Try value of Intervall as string");
|
|
||||||
if (intervall == -1 && json_string(json_object_by_path(
|
|
||||||
object, {"RestartInfo", "Intervall"})) == "EachSync") {
|
|
||||||
intervall = 1;
|
|
||||||
} else if (intervall == -1) {
|
|
||||||
intervall = 0;
|
|
||||||
}
|
|
||||||
ASSERT_NOTNEGATIVE(&intervall, "The intervall for RestartInfo has to be either 0"
|
|
||||||
",if no output is required or positive otherwise");
|
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("Restart output interval: " + std::to_string(intervall));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool overwrite_last = json_bool(
|
|
||||||
json_object_by_path(object, {"RestartInfo", "OverwriteLast"}));
|
|
||||||
|
|
||||||
OutputTask task = {"RestartInfo", overwrite_last, intervall};
|
|
||||||
|
|
||||||
output->setRestartInfoOutput(task);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Particles
|
|
||||||
{
|
|
||||||
int intervall =
|
|
||||||
json_int(json_object_by_path(object, {"Particles", "Intervall"}), -1);
|
|
||||||
// DEBUG_LEVEL_2("Try value of Intervall as string");
|
|
||||||
if (intervall == -1 && json_string(json_object_by_path(
|
|
||||||
object, {"Particles", "Intervall"})) == "EachSync") {
|
|
||||||
intervall = 1;
|
|
||||||
} else if (intervall == -1) {
|
|
||||||
intervall = 0;
|
|
||||||
}
|
|
||||||
ASSERT_NOTNEGATIVE(&intervall, "The intervall for Particles output has to be either 0"
|
|
||||||
",if no output is required or positive otherwise");
|
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("Particles output interval: " + std::to_string(intervall));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// could be done, but then the naming of the mpi file would need to be adjusted
|
|
||||||
bool overwrite_last = false;
|
|
||||||
|
|
||||||
OutputTask task = {"Particles", overwrite_last, intervall};
|
|
||||||
|
|
||||||
output->setParticleOutput(task);
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -107,17 +107,13 @@ std::shared_ptr<Timer> SpeciesBuilder::lastSyncTimer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SpeciesBuilder::initTimer() {
|
void SpeciesBuilder::initTimer() {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Init timer.");
|
DEBUG_LEVEL_2("Init timer.");
|
||||||
#endif
|
|
||||||
timer_ = std::shared_ptr<Timer>(new Timer());
|
timer_ = std::shared_ptr<Timer>(new Timer());
|
||||||
last_sync_timer_ = std::shared_ptr<Timer>(new Timer());
|
last_sync_timer_ = std::shared_ptr<Timer>(new Timer());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpeciesBuilder::initBackgroundSpecies(Parameter& parameter) {
|
void SpeciesBuilder::initBackgroundSpecies(Parameter& parameter) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Init background species info.");
|
DEBUG_LEVEL_2("Init background species info.");
|
||||||
#endif
|
|
||||||
const char* key;
|
const char* key;
|
||||||
json_t* value;
|
json_t* value;
|
||||||
json_object_foreach(parameter.jsonObjectFromBase({"Species", "Background"}),
|
json_object_foreach(parameter.jsonObjectFromBase({"Species", "Background"}),
|
||||||
@@ -130,18 +126,11 @@ void SpeciesBuilder::initBackgroundSpecies(Parameter& parameter) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SpeciesBuilder::initTrackedSpecies(Parameter& parameter) {
|
void SpeciesBuilder::initTrackedSpecies(Parameter& parameter) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Init tracked species info.");
|
DEBUG_LEVEL_2("Init tracked species info.");
|
||||||
#endif
|
|
||||||
const char* key;
|
const char* key;
|
||||||
json_t* value;
|
json_t* value;
|
||||||
json_object_foreach(parameter.jsonObjectFromBase({"Species", "Tracked"}), key,
|
json_object_foreach(parameter.jsonObjectFromBase({"Species", "Tracked"}), key,
|
||||||
value) {
|
value) {
|
||||||
if(std::string(key).size() >= 16) {
|
|
||||||
std::stringstream out;
|
|
||||||
out << std::string(key) << ": name is to long, has to be 15 chars or less!";
|
|
||||||
ERROR(out.str());
|
|
||||||
}
|
|
||||||
tracked_species_info[std::string(key)] = TrackedSpeciesBuilderInfo();
|
tracked_species_info[std::string(key)] = TrackedSpeciesBuilderInfo();
|
||||||
tracked_species_info[std::string(key)].name = std::string(key);
|
tracked_species_info[std::string(key)].name = std::string(key);
|
||||||
tracked_species_info[std::string(key)].path_in_json = {"Species", "Tracked",
|
tracked_species_info[std::string(key)].path_in_json = {"Species", "Tracked",
|
||||||
@@ -150,15 +139,11 @@ void SpeciesBuilder::initTrackedSpecies(Parameter& parameter) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SpeciesBuilder::fillBackgroundSpecieType(Parameter& parameter) {
|
void SpeciesBuilder::fillBackgroundSpecieType(Parameter& parameter) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Fill background species type.");
|
DEBUG_LEVEL_2("Fill background species type.");
|
||||||
#endif
|
|
||||||
for (auto& b : background_species_info) {
|
for (auto& b : background_species_info) {
|
||||||
std::string type = json_string(parameter.jsonObjectFromBase(
|
std::string type = json_string(parameter.jsonObjectFromBase(
|
||||||
json_path_append(b.second.path_in_json, {"ParticleType"})));
|
json_path_append(b.second.path_in_json, {"ParticleType"})));
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("Type: " + type);
|
DEBUG_LEVEL_3("Type: " + type);
|
||||||
#endif
|
|
||||||
if (SpeciesAlias::isAlias(type)) {
|
if (SpeciesAlias::isAlias(type)) {
|
||||||
b.second.type = SpeciesAlias::alias(type);
|
b.second.type = SpeciesAlias::alias(type);
|
||||||
} else {
|
} else {
|
||||||
@@ -168,15 +153,11 @@ void SpeciesBuilder::fillBackgroundSpecieType(Parameter& parameter) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SpeciesBuilder::fillTrackedSpecieType(Parameter& parameter) {
|
void SpeciesBuilder::fillTrackedSpecieType(Parameter& parameter) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Fill tracked species type.");
|
DEBUG_LEVEL_2("Fill tracked species type.");
|
||||||
#endif
|
|
||||||
for (auto& b : tracked_species_info) {
|
for (auto& b : tracked_species_info) {
|
||||||
std::string type = json_string(parameter.jsonObjectFromBase(
|
std::string type = json_string(parameter.jsonObjectFromBase(
|
||||||
json_path_append(b.second.path_in_json, {"ParticleType"})));
|
json_path_append(b.second.path_in_json, {"ParticleType"})));
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("Type: " + type);
|
DEBUG_LEVEL_3("Type: " + type);
|
||||||
#endif
|
|
||||||
if (SpeciesAlias::isAlias(type)) {
|
if (SpeciesAlias::isAlias(type)) {
|
||||||
b.second.type = SpeciesAlias::alias(type);
|
b.second.type = SpeciesAlias::alias(type);
|
||||||
} else {
|
} else {
|
||||||
@@ -186,9 +167,7 @@ void SpeciesBuilder::fillTrackedSpecieType(Parameter& parameter) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SpeciesBuilder::fillBackgroundDensity(Parameter& parameter) {
|
void SpeciesBuilder::fillBackgroundDensity(Parameter& parameter) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Fill background density.");
|
DEBUG_LEVEL_2("Fill background density.");
|
||||||
#endif
|
|
||||||
for (auto& b : background_species_info) {
|
for (auto& b : background_species_info) {
|
||||||
b.second.density = buildConstantDensityField(parameter.jsonObjectFromBase(
|
b.second.density = buildConstantDensityField(parameter.jsonObjectFromBase(
|
||||||
json_path_append(b.second.path_in_json, {"ConstantDensityField"})));
|
json_path_append(b.second.path_in_json, {"ConstantDensityField"})));
|
||||||
@@ -196,9 +175,7 @@ void SpeciesBuilder::fillBackgroundDensity(Parameter& parameter) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SpeciesBuilder::fillVelocityDistribution(Parameter& parameter) {
|
void SpeciesBuilder::fillVelocityDistribution(Parameter& parameter) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Fill velocity distributions.");
|
DEBUG_LEVEL_2("Fill velocity distributions.");
|
||||||
#endif
|
|
||||||
for (auto& b : background_species_info) {
|
for (auto& b : background_species_info) {
|
||||||
b.second.velocity_distribution = buildVelocityDistribution(
|
b.second.velocity_distribution = buildVelocityDistribution(
|
||||||
parameter,
|
parameter,
|
||||||
@@ -212,9 +189,7 @@ void SpeciesBuilder::fillVelocityDistribution(Parameter& parameter) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SpeciesBuilder::fillDriftVelocity(Parameter& parameter) {
|
void SpeciesBuilder::fillDriftVelocity(Parameter& parameter) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Fill drift velocity.");
|
DEBUG_LEVEL_2("Fill drift velocity.");
|
||||||
#endif
|
|
||||||
for (auto& b : background_species_info) {
|
for (auto& b : background_species_info) {
|
||||||
b.second.drift_velocity = buildDriftVelocityIncludingRedirection(
|
b.second.drift_velocity = buildDriftVelocityIncludingRedirection(
|
||||||
parameter, json_path_append(b.second.path_in_json, {"DriftVelocity"}));
|
parameter, json_path_append(b.second.path_in_json, {"DriftVelocity"}));
|
||||||
@@ -226,9 +201,7 @@ void SpeciesBuilder::fillDriftVelocity(Parameter& parameter) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SpeciesBuilder::fillMass() {
|
void SpeciesBuilder::fillMass() {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Fill masses.");
|
DEBUG_LEVEL_2("Fill masses.");
|
||||||
#endif
|
|
||||||
for (auto& b : background_species_info) {
|
for (auto& b : background_species_info) {
|
||||||
b.second.mass_kg = SpeciesMasses::mass(b.second.type);
|
b.second.mass_kg = SpeciesMasses::mass(b.second.type);
|
||||||
}
|
}
|
||||||
@@ -238,9 +211,7 @@ void SpeciesBuilder::fillMass() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SpeciesBuilder::fillCharge() {
|
void SpeciesBuilder::fillCharge() {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Fill charges.");
|
DEBUG_LEVEL_2("Fill charges.");
|
||||||
#endif
|
|
||||||
for (auto& b : background_species_info) {
|
for (auto& b : background_species_info) {
|
||||||
b.second.charge_C = SpeciesCharges::charge(b.second.type);
|
b.second.charge_C = SpeciesCharges::charge(b.second.type);
|
||||||
}
|
}
|
||||||
@@ -250,9 +221,7 @@ void SpeciesBuilder::fillCharge() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SpeciesBuilder::fillMover(Parameter& parameter) {
|
void SpeciesBuilder::fillMover(Parameter& parameter) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Fill movers.");
|
DEBUG_LEVEL_2("Fill movers.");
|
||||||
#endif
|
|
||||||
for (auto& b : tracked_species_info) {
|
for (auto& b : tracked_species_info) {
|
||||||
if ((b.second.mover == nullptr)) {
|
if ((b.second.mover == nullptr)) {
|
||||||
b.second.mover = buildMover(
|
b.second.mover = buildMover(
|
||||||
@@ -262,9 +231,7 @@ void SpeciesBuilder::fillMover(Parameter& parameter) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SpeciesBuilder::fillTerminator(Parameter& parameter) {
|
void SpeciesBuilder::fillTerminator(Parameter& parameter) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Fill terminators.");
|
DEBUG_LEVEL_2("Fill terminators.");
|
||||||
#endif
|
|
||||||
for (auto& b : tracked_species_info) {
|
for (auto& b : tracked_species_info) {
|
||||||
if ((b.second.terminator == nullptr)) {
|
if ((b.second.terminator == nullptr)) {
|
||||||
b.second.terminator = buildTerminator(
|
b.second.terminator = buildTerminator(
|
||||||
@@ -274,9 +241,7 @@ void SpeciesBuilder::fillTerminator(Parameter& parameter) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SpeciesBuilder::fillReflector(Parameter& parameter) {
|
void SpeciesBuilder::fillReflector(Parameter& parameter) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Fill reflectors.");
|
DEBUG_LEVEL_2("Fill reflectors.");
|
||||||
#endif
|
|
||||||
for (auto& b : tracked_species_info) {
|
for (auto& b : tracked_species_info) {
|
||||||
if ((b.second.reflector == nullptr)) {
|
if ((b.second.reflector == nullptr)) {
|
||||||
b.second.reflector = buildReflector(
|
b.second.reflector = buildReflector(
|
||||||
@@ -285,24 +250,25 @@ void SpeciesBuilder::fillReflector(Parameter& parameter) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TBD: Fill and create dynamic density fields with pitch angle distribution
|
|
||||||
void SpeciesBuilder::fillTrackedDensity(Parameter& parameter) {
|
void SpeciesBuilder::fillTrackedDensity(Parameter& parameter) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Fill tracked density.");
|
DEBUG_LEVEL_2("Fill tracked density.");
|
||||||
#endif
|
|
||||||
for (auto& b : tracked_species_info) {
|
for (auto& b : tracked_species_info) {
|
||||||
b.second.density_field = buildDynamicDensityField(
|
b.second.density_field = buildDynamicDensityField(
|
||||||
parameter,
|
parameter,
|
||||||
json_path_append(b.second.path_in_json,
|
json_path_append(b.second.path_in_json,
|
||||||
{"DensityField", "DynamicDensityField"}),
|
{"DensityField", "DynamicDensityField"}),
|
||||||
timer_);
|
timer_);
|
||||||
|
|
||||||
|
b.second.last_sync_density_field = buildDynamicDensityField(
|
||||||
|
parameter,
|
||||||
|
json_path_append(b.second.path_in_json,
|
||||||
|
{"DensityField", "DynamicDensityField"}),
|
||||||
|
last_sync_timer_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpeciesBuilder::buildSpecies() {
|
void SpeciesBuilder::buildSpecies() {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Build species from info.");
|
DEBUG_LEVEL_2("Build species from info.");
|
||||||
#endif
|
|
||||||
for (auto& b : background_species_info) {
|
for (auto& b : background_species_info) {
|
||||||
background_species[b.first] = std::shared_ptr<species::BackgroundSpecie>(
|
background_species[b.first] = std::shared_ptr<species::BackgroundSpecie>(
|
||||||
new species::BackgroundSpecie(
|
new species::BackgroundSpecie(
|
||||||
@@ -317,46 +283,50 @@ void SpeciesBuilder::buildSpecies() {
|
|||||||
b.second.type, b.second.name, b.second.mass_kg, b.second.charge_C,
|
b.second.type, b.second.name, b.second.mass_kg, b.second.charge_C,
|
||||||
b.second.mover, b.second.terminator, b.second.reflector,
|
b.second.mover, b.second.terminator, b.second.reflector,
|
||||||
b.second.density_field, b.second.velocity_distribution,
|
b.second.density_field, b.second.velocity_distribution,
|
||||||
b.second.drift_velocity));
|
b.second.drift_velocity, b.second.last_sync_density_field));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpeciesBuilder::fillCurrentCollector(Parameter& parameter) {
|
void SpeciesBuilder::fillCurrentCollector(Parameter& parameter) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Fill current collectors.");
|
DEBUG_LEVEL_2("Fill current collectors.");
|
||||||
#endif
|
|
||||||
for (auto& b : tracked_species) {
|
for (auto& b : tracked_species) {
|
||||||
auto current_collector = buildCurrentCollector(
|
auto current_collector = buildCurrentCollector(
|
||||||
parameter,
|
parameter,
|
||||||
json_path_append(tracked_species_info.at(b.first).path_in_json,
|
json_path_append(tracked_species_info.at(b.first).path_in_json,
|
||||||
{"CurrentCollector"}),
|
{"CurrentCollector"}),
|
||||||
timer_);
|
timer_);
|
||||||
|
// has to be recreated, if it would be copied the timer_ pointer would
|
||||||
|
// point to the same object -> could not get updated during synchronization
|
||||||
|
auto last_sync_current_collector = buildCurrentCollector(
|
||||||
|
parameter,
|
||||||
|
json_path_append(tracked_species_info.at(b.first).path_in_json,
|
||||||
|
{"CurrentCollector"}),
|
||||||
|
last_sync_timer_);
|
||||||
b.second->currentCollector(current_collector);
|
b.second->currentCollector(current_collector);
|
||||||
|
b.second->lastSyncCurrentCollector(last_sync_current_collector);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpeciesBuilder::fillLoggers(Parameter& parameter) {
|
void SpeciesBuilder::fillLoggers(Parameter& parameter) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Fill loggers.");
|
DEBUG_LEVEL_2("Fill loggers.");
|
||||||
#endif
|
|
||||||
for (auto& b : tracked_species) {
|
for (auto& b : tracked_species) {
|
||||||
auto deletion_logger = buildDeletionLogger(
|
auto deletion_logger = buildDeletionLogger(
|
||||||
parameter,
|
parameter,
|
||||||
json_path_append(tracked_species_info.at(b.first).path_in_json,
|
json_path_append(tracked_species_info.at(b.first).path_in_json,
|
||||||
{"Loggers"}));
|
{"Loggers"}));
|
||||||
b.second->deletionLogger(deletion_logger);
|
b.second->deletionLogger(deletion_logger);
|
||||||
|
b.second->lastSyncDeletionLogger(
|
||||||
|
std::make_shared<DeletionLogger>(*deletion_logger));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpeciesBuilder::fillInteractions(Parameter& parameter) {
|
void SpeciesBuilder::fillInteractions(Parameter& parameter) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Fill interactions.");
|
DEBUG_LEVEL_2("Fill interactions.");
|
||||||
#endif
|
|
||||||
for (auto& b : tracked_species) {
|
for (auto& b : tracked_species) {
|
||||||
json_path path = tracked_species_info[b.first].path_in_json;
|
json_path path = tracked_species_info[b.first].path_in_json;
|
||||||
path = json_path_append(path, {"Interactions"});
|
path = json_path_append(path, {"Interactions"});
|
||||||
addInteractions(b.second, tracked_species, background_species,
|
addInteractions(b.second, tracked_species, background_species, parameter,
|
||||||
parameter, path);
|
path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,91 +7,19 @@ namespace generator {
|
|||||||
std::shared_ptr<Terminator> buildTerminator(
|
std::shared_ptr<Terminator> buildTerminator(
|
||||||
Parameter& parameter,
|
Parameter& parameter,
|
||||||
const json_path& path_to_terminator) {
|
const json_path& path_to_terminator) {
|
||||||
#ifdef debug_level2
|
DEBUG_LEVEL_2("Creating terminator.");
|
||||||
DEBUG_LEVEL_2("Creating terminator.");
|
long int max_interactions = static_cast<long int>(parameter.doubleValue(
|
||||||
#endif
|
json_path_append(path_to_terminator, {"MaximumInteractions"})));
|
||||||
if (parameter.jsonObjectFromBase(
|
double max_time_alive = parameter.doubleValue(
|
||||||
json_path_append(path_to_terminator, {"Cylinder"}))) {
|
json_path_append(path_to_terminator, {"MaxTimeAlive", "value"}));
|
||||||
long int max_interactions = static_cast<long int>(parameter.doubleValue(
|
DEBUG_LEVEL_3("with max interactions: " + std::to_string(max_interactions));
|
||||||
json_path_append(path_to_terminator, {"Cylinder", "MaximumInteractions"})));
|
DEBUG_LEVEL_3("with max time alive: " + std::to_string(max_time_alive));
|
||||||
double max_time_alive = parameter.doubleValue(
|
|
||||||
json_path_append(path_to_terminator, {"Cylinder", "MaxTimeAlive", "value"}));
|
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("with max interactions: " + std::to_string(max_interactions));
|
|
||||||
DEBUG_LEVEL_3("with max time alive: " + std::to_string(max_time_alive));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::shared_ptr<Geometry> geometry = buildGeometryIncludingRedirection(
|
std::shared_ptr<Geometry> geometry = buildGeometryIncludingRedirection(
|
||||||
parameter, json_path_append(path_to_terminator, {"Cylinder", "BoundaryGeometry"}));
|
parameter, json_path_append(path_to_terminator, {"BoundaryGeometry"}));
|
||||||
|
|
||||||
return std::shared_ptr<Terminator>(
|
return std::shared_ptr<Terminator>(
|
||||||
new Terminator(max_interactions, max_time_alive, geometry));
|
new Terminator(max_interactions, max_time_alive, geometry));
|
||||||
|
|
||||||
} else if (parameter.jsonObjectFromBase(json_path_append(path_to_terminator,
|
|
||||||
{"CylinderWithPlates"}))) {
|
|
||||||
long int max_interactions = static_cast<long int>(parameter.doubleValue(
|
|
||||||
json_path_append(path_to_terminator, {"CylinderWithPlates", "MaximumInteractions"})));
|
|
||||||
double max_time_alive = parameter.doubleValue(
|
|
||||||
json_path_append(path_to_terminator, {"CylinderWithPlates", "MaxTimeAlive", "value"}));
|
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("with max interactions: " + std::to_string(max_interactions));
|
|
||||||
DEBUG_LEVEL_3("with max time alive: " + std::to_string(max_time_alive));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::shared_ptr<Geometry> geometry = buildGeometryIncludingRedirection(
|
|
||||||
parameter, json_path_append(path_to_terminator, {"CylinderWithPlates", "BoundaryGeometry"}));
|
|
||||||
|
|
||||||
double zpos1 = json_read_length(
|
|
||||||
parameter.jsonObjectFromBase(
|
|
||||||
json_path_append(path_to_terminator,
|
|
||||||
{"CylinderWithPlates", "Plate1", "zPosition"})));
|
|
||||||
|
|
||||||
double rInner1 = json_read_length(
|
|
||||||
parameter.jsonObjectFromBase(
|
|
||||||
json_path_append(path_to_terminator,
|
|
||||||
{"CylinderWithPlates", "Plate1", "innerRadius"})));
|
|
||||||
|
|
||||||
double rOuter1 = json_read_length(
|
|
||||||
parameter.jsonObjectFromBase(
|
|
||||||
json_path_append(path_to_terminator,
|
|
||||||
{"CylinderWithPlates", "Plate1", "outerRadius"})));
|
|
||||||
|
|
||||||
double zpos2 = json_read_length(
|
|
||||||
parameter.jsonObjectFromBase(
|
|
||||||
json_path_append(path_to_terminator,
|
|
||||||
{"CylinderWithPlates", "Plate2", "zPosition"})));
|
|
||||||
|
|
||||||
double rInner2 = json_read_length(
|
|
||||||
parameter.jsonObjectFromBase(
|
|
||||||
json_path_append(path_to_terminator,
|
|
||||||
{"CylinderWithPlates", "Plate2", "innerRadius"})));
|
|
||||||
|
|
||||||
double rOuter2 = json_read_length(
|
|
||||||
parameter.jsonObjectFromBase(
|
|
||||||
json_path_append(path_to_terminator,
|
|
||||||
{"CylinderWithPlates", "Plate2", "outerRadius"})));
|
|
||||||
|
|
||||||
if(MpiCommunication::mpi_rank == 0) {
|
|
||||||
std::stringstream out;
|
|
||||||
out << "Specifications of Plate 1:\n";
|
|
||||||
out << "\tz position: " << zpos1 << " m\n\t";
|
|
||||||
out << "inner radius: " << rInner1 << " m\n\t";
|
|
||||||
out << "outer radius: " << rOuter1 << " m\n";
|
|
||||||
out << "Specifications of Plate 2:\n";
|
|
||||||
out << "\tz position: " << zpos2 << " m\n\t";
|
|
||||||
out << "inner radius: " << rInner2 << " m\n\t";
|
|
||||||
out << "outer radius: " << rOuter2 << " m\n";
|
|
||||||
SIM_INFO(out.str());
|
|
||||||
}
|
|
||||||
|
|
||||||
return std::shared_ptr<TerminatorWithPlates>(
|
|
||||||
new TerminatorWithPlates(max_interactions, max_time_alive, geometry,
|
|
||||||
zpos1, zpos2, rInner1, rInner2, rOuter1, rOuter2));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
ERROR("Unknown Terminator type");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // namespace generator
|
}; // namespace generator
|
||||||
@@ -20,7 +20,7 @@ std::string readAbsoluteFilename(json_t* object) {
|
|||||||
json_string(json_object_by_path(object, {"Filename"}));
|
json_string(json_object_by_path(object, {"Filename"}));
|
||||||
return homebase + "/" + relative_path_to_homebase + "/" + filename;
|
return homebase + "/" + relative_path_to_homebase + "/" + filename;
|
||||||
|
|
||||||
} else if (path_type == "AbsolutePath") {
|
} else if (path_type == "AbsolutPath") {
|
||||||
std::string absolute_path =
|
std::string absolute_path =
|
||||||
json_string(json_object_by_path(object, {"AbsoluteFolderPath"}));
|
json_string(json_object_by_path(object, {"AbsoluteFolderPath"}));
|
||||||
std::string filename =
|
std::string filename =
|
||||||
@@ -32,30 +32,30 @@ std::string readAbsoluteFilename(json_t* object) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 2> readFromFile(json_t* object) {
|
blitz::Array<double, 3> readFromFile(json_t* object) {
|
||||||
std::string absolute_filename =
|
std::string absolute_filename =
|
||||||
readAbsoluteFilename(json_object_by_path(object, {"PathToH5"}));
|
readAbsoluteFilename(json_object_by_path(object, {"PathToH5"}));
|
||||||
std::string key = json_string(json_object_by_path(object, {"Key"}));
|
std::string key = json_string(json_object_by_path(object, {"Key"}));
|
||||||
|
|
||||||
Hdf5Reader reader(absolute_filename);
|
Hdf5Reader reader(absolute_filename);
|
||||||
return reader.readD2Double(key);
|
return reader.readD3Double(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 2> readComponentFromFile(json_t* object, int component) {
|
blitz::Array<double, 3> readComponentFromFile(json_t* object, int component) {
|
||||||
std::string absolute_filename =
|
std::string absolute_filename =
|
||||||
readAbsoluteFilename(json_object_by_path(object, {"PathToH5"}));
|
readAbsoluteFilename(json_object_by_path(object, {"PathToH5"}));
|
||||||
|
DEBUG_LEVEL_3("path to h5: " + absolute_filename);
|
||||||
std::string key = json_string(
|
std::string key = json_string(
|
||||||
json_array_get(json_object_by_path(object, {"Keys"}), component));
|
json_array_get(json_object_by_path(object, {"Keys"}), component));
|
||||||
|
DEBUG_LEVEL_3("key: " + key);
|
||||||
|
|
||||||
Hdf5Reader reader(absolute_filename);
|
Hdf5Reader reader(absolute_filename);
|
||||||
return reader.readD2Double(key);
|
return reader.readD3Double(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VectorField> buildVectorField(json_t* object) {
|
std::shared_ptr<VectorField> buildVectorField(json_t* object) {
|
||||||
if (json_object_by_path(object, {"VectorFieldConstant"})) {
|
if (json_object_by_path(object, {"VectorFieldConstant"})) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating Vector field: VectorFieldConstant");
|
DEBUG_LEVEL_2("Creating Vector field: VectorFieldConstant");
|
||||||
#endif
|
|
||||||
blitz::TinyVector<double, 3> constant = json_blitz_vector<3>(
|
blitz::TinyVector<double, 3> constant = json_blitz_vector<3>(
|
||||||
json_object_by_path(object, {"VectorFieldConstant", "constant"}));
|
json_object_by_path(object, {"VectorFieldConstant", "constant"}));
|
||||||
|
|
||||||
@@ -63,27 +63,23 @@ std::shared_ptr<VectorField> buildVectorField(json_t* object) {
|
|||||||
new VectorFieldConstant(CylinderVector(constant)));
|
new VectorFieldConstant(CylinderVector(constant)));
|
||||||
|
|
||||||
} else if (json_object_by_path(object, {"VectorFieldFunctionInZ"})) {
|
} else if (json_object_by_path(object, {"VectorFieldFunctionInZ"})) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating Vector field: VectorFieldFunctionInZ");
|
DEBUG_LEVEL_2("Creating Vector field: VectorFieldFunctionInZ");
|
||||||
#endif
|
|
||||||
std::function<double(double, double, double)> z_function = function3D(
|
std::function<double(double, double, double)> z_function = function3D(
|
||||||
json_object_by_path(object, {"VectorFieldFunctionInZ", "zFunction"}));
|
json_object_by_path(object, {"VectorFieldFunctionInZ", "zFunction"}));
|
||||||
return std::shared_ptr<VectorField>(new VectorFieldFunctionInZ(z_function));
|
return std::shared_ptr<VectorField>(new VectorFieldFunctionInZ(z_function));
|
||||||
|
|
||||||
} else if (json_object_by_path(object, {"VectorFieldFromArray"})) {
|
} else if (json_object_by_path(object, {"VectorFieldFromArray"})) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating Vector field: VectorFieldFromArray");
|
DEBUG_LEVEL_2("Creating Vector field: VectorFieldFromArray");
|
||||||
#endif
|
|
||||||
|
|
||||||
blitz::Array<double, 2> v_radial = readComponentFromFile(
|
blitz::Array<double, 3> v_radial = readComponentFromFile(
|
||||||
json_object_by_path(object,
|
json_object_by_path(object,
|
||||||
{"VectorFieldFromArray", "ReadArrayFromFile"}),
|
{"VectorFieldFromArray", "ReadArrayFromFile"}),
|
||||||
0);
|
0);
|
||||||
blitz::Array<double, 2> v_azimuthal = readComponentFromFile(
|
blitz::Array<double, 3> v_azimuthal = readComponentFromFile(
|
||||||
json_object_by_path(object,
|
json_object_by_path(object,
|
||||||
{"VectorFieldFromArray", "ReadArrayFromFile"}),
|
{"VectorFieldFromArray", "ReadArrayFromFile"}),
|
||||||
1);
|
1);
|
||||||
blitz::Array<double, 2> v_longitudinal = readComponentFromFile(
|
blitz::Array<double, 3> v_longitudinal = readComponentFromFile(
|
||||||
json_object_by_path(object,
|
json_object_by_path(object,
|
||||||
{"VectorFieldFromArray", "ReadArrayFromFile"}),
|
{"VectorFieldFromArray", "ReadArrayFromFile"}),
|
||||||
2);
|
2);
|
||||||
|
|||||||
@@ -11,10 +11,8 @@ std::shared_ptr<VelocityDistributionFunction> buildVelocityDistributionFunction(
|
|||||||
const json_path& path_to_distribution) {
|
const json_path& path_to_distribution) {
|
||||||
if (parameter.jsonObjectFromBase(
|
if (parameter.jsonObjectFromBase(
|
||||||
json_path_append(path_to_distribution, {"IsotropicDistribution"}))) {
|
json_path_append(path_to_distribution, {"IsotropicDistribution"}))) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2(
|
DEBUG_LEVEL_2(
|
||||||
"Creating velocity distribution function: IsotropicDistribution");
|
"Creating velocity distribution function: IsotropicDistribution");
|
||||||
#endif
|
|
||||||
std::shared_ptr<EnergyDistributionFunction> fE =
|
std::shared_ptr<EnergyDistributionFunction> fE =
|
||||||
buildEnergyDistributionFunction(
|
buildEnergyDistributionFunction(
|
||||||
parameter, json_path_append(path_to_distribution,
|
parameter, json_path_append(path_to_distribution,
|
||||||
@@ -28,10 +26,8 @@ std::shared_ptr<VelocityDistributionFunction> buildVelocityDistributionFunction(
|
|||||||
|
|
||||||
} else if (parameter.jsonObjectFromBase(json_path_append(
|
} else if (parameter.jsonObjectFromBase(json_path_append(
|
||||||
path_to_distribution, {"DirectedDistribution"}))) {
|
path_to_distribution, {"DirectedDistribution"}))) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2(
|
DEBUG_LEVEL_2(
|
||||||
"Creating velocity distribution function: DirectedDistribution");
|
"Creating velocity distribution function: DirectedDistribution");
|
||||||
#endif
|
|
||||||
std::shared_ptr<EnergyDistributionFunction> fE =
|
std::shared_ptr<EnergyDistributionFunction> fE =
|
||||||
buildEnergyDistributionFunction(
|
buildEnergyDistributionFunction(
|
||||||
parameter, json_path_append(path_to_distribution,
|
parameter, json_path_append(path_to_distribution,
|
||||||
|
|||||||
@@ -10,10 +10,8 @@ std::shared_ptr<VelocityDistribution> buildVelocityDistribution(
|
|||||||
const json_path& path_to_distribution) {
|
const json_path& path_to_distribution) {
|
||||||
if (parameter.jsonObjectFromBase(json_path_append(
|
if (parameter.jsonObjectFromBase(json_path_append(
|
||||||
path_to_distribution, {"VelocityDistributionFromFunction"}))) {
|
path_to_distribution, {"VelocityDistributionFromFunction"}))) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2(
|
DEBUG_LEVEL_2(
|
||||||
"Creating velocity distribution: VelocityDistributionFromFunction");
|
"Creating velocity distribution: VelocityDistributionFromFunction");
|
||||||
#endif
|
|
||||||
std::shared_ptr<VelocityDistributionFunction> v =
|
std::shared_ptr<VelocityDistributionFunction> v =
|
||||||
buildVelocityDistributionFunction(
|
buildVelocityDistributionFunction(
|
||||||
parameter, json_path_append(path_to_distribution,
|
parameter, json_path_append(path_to_distribution,
|
||||||
@@ -23,9 +21,7 @@ std::shared_ptr<VelocityDistribution> buildVelocityDistribution(
|
|||||||
new VelocityDistributionFromFunction(v));
|
new VelocityDistributionFromFunction(v));
|
||||||
} else if (parameter.jsonObjectFromBase(
|
} else if (parameter.jsonObjectFromBase(
|
||||||
json_path_append(path_to_distribution, {"null"}))) {
|
json_path_append(path_to_distribution, {"null"}))) {
|
||||||
#ifdef debug_level2
|
|
||||||
DEBUG_LEVEL_2("Creating velocity distribution: null");
|
DEBUG_LEVEL_2("Creating velocity distribution: null");
|
||||||
#endif
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
} else {
|
} else {
|
||||||
ERROR("This velocity distribution is not implemented.");
|
ERROR("This velocity distribution is not implemented.");
|
||||||
|
|||||||
@@ -13,18 +13,16 @@ ChargeExchange::ChargeExchange(std::function<double(double)> cross_section,
|
|||||||
InteractionOutput ChargeExchange::performInteraction(
|
InteractionOutput ChargeExchange::performInteraction(
|
||||||
particle::Particle& particle,
|
particle::Particle& particle,
|
||||||
RandomNumbers* generator) {
|
RandomNumbers* generator) {
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("Perform charge exchange.");
|
DEBUG_LEVEL_3("Perform charge exchange.");
|
||||||
#endif
|
|
||||||
|
|
||||||
// const auto x_impact = particle.position();
|
const auto x_impact = particle.position();
|
||||||
// const blitz::TinyVector<double, 3> v_target =
|
const blitz::TinyVector<double, 3> v_target =
|
||||||
// target_->driftVelocity()->driftVelocity(x_impact).cartesianEntries() +
|
target_->driftVelocity()->driftVelocity(x_impact).cartesianEntries() +
|
||||||
// target_->velocityDistribution()
|
target_->velocityDistibution()
|
||||||
// ->rollVelocity(x_impact, generator->engine())
|
->rollVelocity(x_impact, generator->engine())
|
||||||
// .cartesianEntries();
|
.cartesianEntries();
|
||||||
|
|
||||||
particle.velocity(CartesianVector(target_velocity_));
|
particle.velocity(CartesianVector(v_target));
|
||||||
return InteractionOutput();
|
return InteractionOutput();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -5,7 +5,6 @@
|
|||||||
#include "simulation/logger.h"
|
#include "simulation/logger.h"
|
||||||
#include "simulation/velocity_distribution.h"
|
#include "simulation/velocity_distribution.h"
|
||||||
#include "constants/physical_constants.h"
|
#include "constants/physical_constants.h"
|
||||||
#include "simulation/density_field.h"
|
|
||||||
|
|
||||||
namespace interaction {
|
namespace interaction {
|
||||||
|
|
||||||
@@ -18,141 +17,20 @@ ClusterFormation::ClusterFormation(
|
|||||||
InteractionOutput ClusterFormation::performInteraction(
|
InteractionOutput ClusterFormation::performInteraction(
|
||||||
particle::Particle& particle,
|
particle::Particle& particle,
|
||||||
RandomNumbers* generator) {
|
RandomNumbers* generator) {
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("Perform cluster formation.");
|
DEBUG_LEVEL_3("Perform cluster formation.");
|
||||||
#endif
|
const auto x_impact = particle.position();
|
||||||
const auto x_impact = particle.cartesianPosition();
|
const blitz::TinyVector<double, 3> v_target =
|
||||||
// const blitz::TinyVector<double, 3> v_target =
|
target_->driftVelocity()->driftVelocity(x_impact).cartesianEntries() +
|
||||||
// target_->driftVelocity()->driftVelocity(x_impact).cartesianEntries() +
|
target_->velocityDistibution()
|
||||||
// target_->velocityDistribution()
|
->rollVelocity(x_impact, generator->engine())
|
||||||
// ->rollVelocity(x_impact, generator->engine())
|
.cartesianEntries();
|
||||||
// .cartesianEntries();
|
|
||||||
/*****************************************************************************
|
|
||||||
const double energy_eV =
|
const double energy_eV =
|
||||||
kinematic::kineticEnergy(target_velocity_.cartesianEntries(), target_->mass_kg()) *
|
kinematic::kineticEnergy(v_target, target_->mass_kg()) *
|
||||||
UnitConversion::JouleToeV;
|
UnitConversion::JouleToeV;
|
||||||
const blitz::TinyVector<double, 3> v_cluster =
|
const blitz::TinyVector<double, 3> v_cluster =
|
||||||
kinematic::velocity(energy_eV, product_->mass_kg()) *
|
kinematic::velocity(energy_eV, product_->mass_kg()) *
|
||||||
target_velocity_.cartesianEntries() / kinematic::norm(target_velocity_.cartesianEntries());
|
v_target / kinematic::norm(v_target);
|
||||||
// product inherits weight of the main particle (not the target, which is
|
particle::Particle cluster(product_, x_impact, CartesianVector(v_cluster));
|
||||||
// assumed to be just a density, i.e. has no weight of its own)
|
|
||||||
********************************************************************************/
|
|
||||||
|
|
||||||
// neglect the momentum of the photon -> the cluster moves with the CoM velocity
|
|
||||||
// after the collision
|
|
||||||
blitz::TinyVector<double, 3> v_cluster =
|
|
||||||
(particle.mass_kg()*particle.velocity().cartesianEntries() +
|
|
||||||
target_->mass_kg()*target_velocity_.cartesianEntries()) /
|
|
||||||
(particle.mass_kg() + target_->mass_kg());
|
|
||||||
|
|
||||||
particle::Particle cluster(product_, x_impact, CartesianVector(v_cluster),
|
|
||||||
particle.timeAlive(), particle.weight());
|
|
||||||
|
|
||||||
InteractionOutput output;
|
|
||||||
output.add(cluster);
|
|
||||||
output.deleteCurrentParticle(true);
|
|
||||||
|
|
||||||
if (particle.specie()->deletionLogger()) {
|
|
||||||
particle.specie()->deletionLogger()->logDeletion(
|
|
||||||
x_impact, DeletionType::cluster_formation);
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
ClusterFormationTertiary::ClusterFormationTertiary(
|
|
||||||
std::function<double(double)> cross_section,
|
|
||||||
std::shared_ptr<species::Specie> target,
|
|
||||||
std::shared_ptr<species::TrackedSpecie> product,
|
|
||||||
bool rate_coefficient) :
|
|
||||||
ClusterFormation(cross_section, target, product), rate_coefficient_(rate_coefficient) {}
|
|
||||||
|
|
||||||
double ClusterFormationTertiary::microscopicCrossSection(double energy_eV,
|
|
||||||
const Coordinate& position) {
|
|
||||||
// SIM_INFO("Tertiary cross section.");
|
|
||||||
if(!rate_coefficient_) {
|
|
||||||
return cross_section_(energy_eV);
|
|
||||||
}
|
|
||||||
const double rate_over_velocity = cross_section_(energy_eV);
|
|
||||||
auto density = target_->densityField()->density(position);
|
|
||||||
return rate_over_velocity * density;
|
|
||||||
}
|
|
||||||
|
|
||||||
InteractionOutput ClusterFormationTertiary::performInteraction(
|
|
||||||
particle::Particle& particle,
|
|
||||||
RandomNumbers* generator) {
|
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("Perform cluster formation.");
|
|
||||||
#endif
|
|
||||||
const auto x_impact = particle.cartesianPosition();
|
|
||||||
/******************************************************************
|
|
||||||
// const blitz::TinyVector<double, 3> v_target =
|
|
||||||
// target_->driftVelocity()->driftVelocity(x_impact).cartesianEntries() +
|
|
||||||
// target_->velocityDistribution()
|
|
||||||
// ->rollVelocity(x_impact, generator->engine())
|
|
||||||
// .cartesianEntries();
|
|
||||||
const double energy_eV =
|
|
||||||
kinematic::kineticEnergy(target_velocity_.cartesianEntries(), target_->mass_kg()) *
|
|
||||||
UnitConversion::JouleToeV;
|
|
||||||
const blitz::TinyVector<double, 3> v_cluster =
|
|
||||||
kinematic::velocity(energy_eV, product_->mass_kg()) *
|
|
||||||
target_velocity_.cartesianEntries() / kinematic::norm(target_velocity_.cartesianEntries());
|
|
||||||
// product inherits weight of the main particle (not the target, which is
|
|
||||||
// assumed to be just a density, i.e. has no weight of its own)
|
|
||||||
particle::Particle cluster(product_, x_impact, CartesianVector(v_cluster),
|
|
||||||
particle.timeAlive(), particle.weight());
|
|
||||||
*****************************************************************/
|
|
||||||
|
|
||||||
// strictly speaking only correct for the reaction T2+ + T2 -> T3+ + T
|
|
||||||
// (otherwise missing momentum component of actual third body)
|
|
||||||
blitz::TinyVector<double, 3> v_com = particle.mass_kg()*particle.velocity().cartesianEntries() +
|
|
||||||
target_->mass_kg()*target_velocity_.cartesianEntries();
|
|
||||||
|
|
||||||
double E0_com = 0;
|
|
||||||
double total_mass = target_->mass_kg() + particle.mass_kg();
|
|
||||||
|
|
||||||
// differentiate between T+ + 2T2 and T2+ + T2 (probably not ideal if new types
|
|
||||||
// were to be implemented)
|
|
||||||
if(particle.specie()->type() == species::ImplementedSpecies::Tplus &&
|
|
||||||
target_->type() == species::ImplementedSpecies::T2) {
|
|
||||||
// ignore any bulk movement of third interaction partner
|
|
||||||
blitz::TinyVector<double, 3> v3 = target_->velocityDistribution()
|
|
||||||
->rollVelocity(x_impact, generator->engine()).cartesianEntries();
|
|
||||||
total_mass += target_->mass_kg();
|
|
||||||
v_com += target_->mass_kg()*v3;
|
|
||||||
v_com /= particle.mass_kg() + 2*target_->mass_kg();
|
|
||||||
E0_com += 0.5*target_->mass_kg()*blitz::dot(v3 - v_com, v3 - v_com);
|
|
||||||
} else {
|
|
||||||
v_com /= total_mass;
|
|
||||||
}
|
|
||||||
blitz::TinyVector<double, 3> vi_com = particle.velocity().cartesianEntries() - v_com;
|
|
||||||
blitz::TinyVector<double, 3> vt_com = target_velocity_.cartesianEntries() - v_com;
|
|
||||||
|
|
||||||
E0_com += 0.5*particle.mass_kg()*blitz::dot(vi_com, vi_com) +
|
|
||||||
0.5*target_->mass_kg()*blitz::dot(vt_com, vt_com);
|
|
||||||
|
|
||||||
double cluster_mass = product_->mass_kg();
|
|
||||||
double rest_mass = total_mass - cluster_mass;
|
|
||||||
double reduced_mass = 1/(1/cluster_mass + 1/rest_mass);
|
|
||||||
|
|
||||||
// momentum of the scattered particles in the CoM frame
|
|
||||||
double norm_pnew_com = std::sqrt(2*reduced_mass*E0_com);
|
|
||||||
|
|
||||||
double phi = generator->rollUniform(0,1)*M_PI*2;
|
|
||||||
double theta = std::acos(1 - 2*generator->rollUniform(0,1));
|
|
||||||
|
|
||||||
// assume isotropic distribution of the scattered momenta in the CoM frame
|
|
||||||
// (removes the need to rotate wrt the incoming velocity)
|
|
||||||
// if a more general approach is needed, use the same calculation as in elastic scattering
|
|
||||||
|
|
||||||
blitz::TinyVector<double, 3> p_cluster_com(std::sin(theta)*std::cos(phi),
|
|
||||||
std::sin(theta)*std::sin(phi),
|
|
||||||
std::cos(theta));
|
|
||||||
p_cluster_com *= norm_pnew_com;
|
|
||||||
blitz::TinyVector<double, 3> v_cluster = (p_cluster_com/cluster_mass) + v_com;
|
|
||||||
|
|
||||||
particle::Particle cluster(product_, x_impact, CartesianVector(v_cluster),
|
|
||||||
particle.timeAlive(), particle.weight());
|
|
||||||
|
|
||||||
InteractionOutput output;
|
InteractionOutput output;
|
||||||
output.add(cluster);
|
output.add(cluster);
|
||||||
|
|||||||
@@ -28,20 +28,14 @@ std::function<double(double, double)> eT2_ionization_bed() {
|
|||||||
} else {
|
} else {
|
||||||
const double t = impact_energy / ionization_energy;
|
const double t = impact_energy / ionization_energy;
|
||||||
const double w = energy_after_collision / ionization_energy;
|
const double w = energy_after_collision / ionization_energy;
|
||||||
|
|
||||||
double y = 1 / (w + 1);
|
|
||||||
double ysq = y*y;
|
|
||||||
double invtmw = 1. / (t - w);
|
|
||||||
|
|
||||||
const double factor = S_m2 / ionization_energy / (t + u + 1);
|
const double factor = S_m2 / ionization_energy / (t + u + 1);
|
||||||
const double summand_1 =
|
const double summand_1 =
|
||||||
(Ni / N - 2) / (t + 1) * (y + invtmw);
|
(Ni / N - 2) / (t + 1) * (1 / (w + 1) + 1 / (t - w));
|
||||||
const double summand_2 =
|
const double summand_2 =
|
||||||
(2 - Ni / N) * (ysq + invtmw*invtmw);
|
(2 - Ni / N) * (std::pow(w + 1, -2) + std::pow(t - w, -2));
|
||||||
|
double y = 1 / (w + 1);
|
||||||
// const double dfdw = c[0] * std::pow(y, 3) + c[1] * std::pow(y, 4) +
|
const double dfdw = c[0] * std::pow(y, 3) + c[1] * std::pow(y, 4) +
|
||||||
// c[2] * std::pow(y, 5) + c[3] * std::pow(y, 6);
|
c[2] * std::pow(y, 5) + c[3] * std::pow(y, 6);
|
||||||
const double dfdw = ysq*(y*c[0] + ysq*(c[1] + y*(c[2] + y*c[3])));
|
|
||||||
const double summand_3 = std::log(t) / (N * (w + 1)) * dfdw;
|
const double summand_3 = std::log(t) / (N * (w + 1)) * dfdw;
|
||||||
return factor * (summand_1 + summand_2 + summand_3);
|
return factor * (summand_1 + summand_2 + summand_3);
|
||||||
}
|
}
|
||||||
@@ -63,20 +57,14 @@ std::function<double(double, double)> eT_ionization_bed() {
|
|||||||
} else {
|
} else {
|
||||||
const double t = impact_energy / ionization_energy;
|
const double t = impact_energy / ionization_energy;
|
||||||
const double w = energy_after_collision / ionization_energy;
|
const double w = energy_after_collision / ionization_energy;
|
||||||
|
|
||||||
double y = 1 / (w + 1);
|
|
||||||
double ysq = y*y;
|
|
||||||
double invtmw = 1. / (t - w);
|
|
||||||
|
|
||||||
const double factor = S_m2 / ionization_energy / (t + u + 1);
|
const double factor = S_m2 / ionization_energy / (t + u + 1);
|
||||||
const double summand_1 =
|
const double summand_1 =
|
||||||
(Ni / N - 2) / (t + 1) * (y + invtmw);
|
(Ni / N - 2) / (t + 1) * (1 / (w + 1) + 1 / (t - w));
|
||||||
const double summand_2 =
|
const double summand_2 =
|
||||||
(2 - Ni / N) * (ysq + invtmw*invtmw);
|
(2 - Ni / N) * (std::pow(w + 1, -2) + std::pow(t - w, -2));
|
||||||
|
double y = 1 / (w + 1);
|
||||||
// const double dfdw = c[0] * std::pow(y, 2) + c[1] * std::pow(y, 3) +
|
const double dfdw = c[0] * std::pow(y, 2) + c[1] * std::pow(y, 3) +
|
||||||
// c[2] * std::pow(y, 4) + c[3] * std::pow(y, 5);
|
c[2] * std::pow(y, 4) + c[3] * std::pow(y, 5);
|
||||||
const double dfdw = ysq * (c[0] + y*(c[1] + y*(c[2] + y*c[3])));
|
|
||||||
const double summand_3 = std::log(t) / (N * (w + 1)) * dfdw;
|
const double summand_3 = std::log(t) / (N * (w + 1)) * dfdw;
|
||||||
return factor * (summand_1 + summand_2 + summand_3);
|
return factor * (summand_1 + summand_2 + summand_3);
|
||||||
}
|
}
|
||||||
@@ -173,8 +161,7 @@ std::function<double(double)> eT_elastic_scattering() {
|
|||||||
std::function<double(double)> T2pT2_charge_exchange_janev() {
|
std::function<double(double)> T2pT2_charge_exchange_janev() {
|
||||||
return [=](double energy) {
|
return [=](double energy) {
|
||||||
const double sig_ll =
|
const double sig_ll =
|
||||||
// 6.59 / (std::pow(energy, 0.5) * (1 + 2.29 * std::pow(energy, 1.78))) +
|
6.59 / (std::pow(energy, 0.5) * (1 + 2.29 * std::pow(energy, 1.78))) +
|
||||||
6.59 / (std::sqrt(energy) * (1 + 2.29 * std::pow(energy, 1.78))) +
|
|
||||||
12.85 * std::exp(-1.84 * std::pow(energy, -1.55)) /
|
12.85 * std::exp(-1.84 * std::pow(energy, -1.55)) /
|
||||||
(std::pow(energy, 0.0673) * (1 + 2.6E-3 * std::pow(energy, 0.97) +
|
(std::pow(energy, 0.0673) * (1 + 2.6E-3 * std::pow(energy, 0.97) +
|
||||||
1.63E-10 * std::pow(energy, 2.76)));
|
1.63E-10 * std::pow(energy, 2.76)));
|
||||||
@@ -209,13 +196,9 @@ std::function<double(double)> eT2_ionization_bed() {
|
|||||||
const double t = energy / ionization_energy;
|
const double t = energy / ionization_energy;
|
||||||
const double factor = S_m2 / (t + u + 1);
|
const double factor = S_m2 / (t + u + 1);
|
||||||
const double yh = 2. / (t + 1);
|
const double yh = 2. / (t + 1);
|
||||||
const double yh2 = yh*yh;
|
|
||||||
// const double D =
|
|
||||||
// c[0] / 3 * (1 - std::pow(yh, 3)) + c[1] / 4 * (1 - std::pow(yh, 4)) +
|
|
||||||
// c[2] / 5 * (1 - std::pow(yh, 5)) + c[3] / 6 * (1 - std::pow(yh, 6));
|
|
||||||
const double D =
|
const double D =
|
||||||
(c[0]/3 + c[1]/4 + c[2]/5 + c[3]/6) -
|
c[0] / 3 * (1 - std::pow(yh, 3)) + c[1] / 4 * (1 - std::pow(yh, 4)) +
|
||||||
yh2 * (yh*(c[0]/3 + c[2]/5 * yh2) + yh2 * (c[1]/4 + c[3]/6 * yh2));
|
c[2] / 5 * (1 - std::pow(yh, 5)) + c[3] / 6 * (1 - std::pow(yh, 6));
|
||||||
const double summand_1 = D * std::log(t);
|
const double summand_1 = D * std::log(t);
|
||||||
const double summand_2 =
|
const double summand_2 =
|
||||||
(2 - Ni / N) * ((t - 1) / t - std::log(t) / (t + 1));
|
(2 - Ni / N) * ((t - 1) / t - std::log(t) / (t + 1));
|
||||||
@@ -577,12 +560,8 @@ std::function<double(double)> eT2_excitation_vibrational_janev_first() {
|
|||||||
return 0.;
|
return 0.;
|
||||||
}
|
}
|
||||||
const double rel = energy / deltaE_eV;
|
const double rel = energy / deltaE_eV;
|
||||||
// return 5.78 * std::pow(deltaE_eV, -4) * std::pow(rel, -2) *
|
return 5.78 * std::pow(deltaE_eV, -4) * std::pow(rel, -2) *
|
||||||
// std::pow(1 - 1 / rel, 6.11 * std::pow(deltaE_eV, -0.5)) * 1E-20;
|
std::pow(1 - 1 / rel, 6.11 * std::pow(deltaE_eV, -0.5)) * 1E-20;
|
||||||
// change calculation of deltaE_eV^{-4} to a simple constant? (don't know
|
|
||||||
// it the compiler already changes that)
|
|
||||||
return 5.78 * std::pow(deltaE_eV, -4) * 1/(rel*rel) *
|
|
||||||
std::pow(1 - 1 / rel, 6.11 / std::sqrt(deltaE_eV)) * 1E-20;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -593,11 +572,8 @@ std::function<double(double)> eT2_excitation_vibrational_janev_second() {
|
|||||||
return 0.;
|
return 0.;
|
||||||
}
|
}
|
||||||
const double rel = energy / deltaE_eV;
|
const double rel = energy / deltaE_eV;
|
||||||
// return 5.78 * 0.628 * std::pow(deltaE_eV, -4) * std::pow(rel, -2) *
|
return 5.78 * 0.628 * std::pow(deltaE_eV, -4) * std::pow(rel, -2) *
|
||||||
// std::pow(1 - 1 / rel, 6.11 * std::pow(deltaE_eV, -0.5)) * 1E-20;
|
std::pow(1 - 1 / rel, 6.11 * std::pow(deltaE_eV, -0.5)) * 1E-20;
|
||||||
// same comment as for the function above
|
|
||||||
return 5.78 * 0.628 * std::pow(deltaE_eV, -4) / (rel*rel) *
|
|
||||||
std::pow(1 - 1 / rel, 6.11 / std::sqrt(deltaE_eV)) * 1E-20;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -652,8 +628,7 @@ std::function<double(double)> eT2p_recombination_janev() {
|
|||||||
(1 + 1.1 * std::pow(energy, 0.512) +
|
(1 + 1.1 * std::pow(energy, 0.512) +
|
||||||
0.011 * std::pow(energy, 3.10)),
|
0.011 * std::pow(energy, 3.10)),
|
||||||
-1) +
|
-1) +
|
||||||
// 0.133 * std::exp(-0.35 * std::pow(energy - 6.05, 2)));
|
0.133 * std::exp(-0.35 * std::pow(energy - 6.05, 2)));
|
||||||
0.133 * std::exp(-0.35 * (energy - 6.05)*(energy - 6.05)));
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
std::function<double(double)> eT3p_recombination_janev() {
|
std::function<double(double)> eT3p_recombination_janev() {
|
||||||
|
|||||||
@@ -6,8 +6,7 @@
|
|||||||
#include "simulation/kinematic.h"
|
#include "simulation/kinematic.h"
|
||||||
#include "simulation/scattering_angle_distribution.h"
|
#include "simulation/scattering_angle_distribution.h"
|
||||||
#include "simulation/velocity_distribution.h"
|
#include "simulation/velocity_distribution.h"
|
||||||
#include "constants/sim_constants.h"
|
|
||||||
#include "simulation/density_field.h"
|
|
||||||
namespace interaction {
|
namespace interaction {
|
||||||
|
|
||||||
ElasticScattering::ElasticScattering(
|
ElasticScattering::ElasticScattering(
|
||||||
@@ -19,21 +18,18 @@ ElasticScattering::ElasticScattering(
|
|||||||
InteractionOutput ElasticScattering::performInteraction(
|
InteractionOutput ElasticScattering::performInteraction(
|
||||||
particle::Particle& particle,
|
particle::Particle& particle,
|
||||||
RandomNumbers* generator) {
|
RandomNumbers* generator) {
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("Perform elastic scattering.");
|
DEBUG_LEVEL_3("Perform elastic scattering.");
|
||||||
#endif
|
|
||||||
const blitz::TinyVector<double, 3> v_impact =
|
const blitz::TinyVector<double, 3> v_impact =
|
||||||
particle.velocity().cartesianEntries();
|
particle.velocity().cartesianEntries();
|
||||||
// const auto x_impact = particle.position();
|
const auto x_impact = particle.position();
|
||||||
// const blitz::TinyVector<double, 3> v_target =
|
const blitz::TinyVector<double, 3> v_target =
|
||||||
// target_->driftVelocity()->driftVelocity(x_impact).cartesianEntries() +
|
target_->driftVelocity()->driftVelocity(x_impact).cartesianEntries() +
|
||||||
// target_->velocityDistribution()
|
target_->velocityDistibution()
|
||||||
// ->rollVelocity(x_impact, generator->engine())
|
->rollVelocity(x_impact, generator->engine())
|
||||||
// .cartesianEntries();
|
.cartesianEntries();
|
||||||
|
|
||||||
const blitz::TinyVector<double, 3> v_laboratory =
|
const blitz::TinyVector<double, 3> v_laboratory =
|
||||||
kinematic::velocityTargetFixed(v_impact, target_velocity_.cartesianEntries(),
|
kinematic::velocityTargetFixed(v_impact, v_target, particle.mass_kg(),
|
||||||
particle.mass_kg(),
|
|
||||||
target_->mass_kg());
|
target_->mass_kg());
|
||||||
|
|
||||||
const double E_kin =
|
const double E_kin =
|
||||||
@@ -45,136 +41,13 @@ InteractionOutput ElasticScattering::performInteraction(
|
|||||||
|
|
||||||
const blitz::TinyVector<double, 3> v_impact_new =
|
const blitz::TinyVector<double, 3> v_impact_new =
|
||||||
kinematic::rotateVelocityInCenterOfMassFrame(
|
kinematic::rotateVelocityInCenterOfMassFrame(
|
||||||
v_impact, target_velocity_.cartesianEntries(), particle.mass_kg(),
|
v_impact, v_target, particle.mass_kg(), target_->mass_kg(), theta,
|
||||||
target_->mass_kg(), theta, phi);
|
phi);
|
||||||
|
|
||||||
particle.velocity(CartesianVector(v_impact_new));
|
particle.velocity(CartesianVector(v_impact_new));
|
||||||
|
// no Gyrocentrum movement because boris push is used;
|
||||||
|
|
||||||
return InteractionOutput();
|
return InteractionOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
double ElasticScattering::drawCollisionTime(particle::Particle& particle,
|
|
||||||
RandomNumbers* generator) {
|
|
||||||
CartesianVector particle_velocity = particle.velocity();
|
|
||||||
|
|
||||||
target_velocity_ = target_->velocityDistribution()->
|
|
||||||
rollVelocity(particle.cylinderPosition(),
|
|
||||||
generator->engine());
|
|
||||||
|
|
||||||
// // if no drift velocity is present, then assume target at rest otherwise
|
|
||||||
// // use the drift velocity
|
|
||||||
if(target_->driftVelocity()) {
|
|
||||||
// auto tmp = target_->driftVelocity()->driftVelocity(particle.position());
|
|
||||||
target_velocity_.add(target_->driftVelocity()->driftVelocity(
|
|
||||||
particle.cartesianPosition(), particle.cylinderPosition()),
|
|
||||||
particle.cartesianPosition());
|
|
||||||
}
|
|
||||||
|
|
||||||
// masses are irrelevant for the transformation
|
|
||||||
const blitz::TinyVector<double, 3> velocity_target_fixed =
|
|
||||||
kinematic::velocityTargetFixed(particle_velocity.cartesianEntries(),
|
|
||||||
target_velocity_.cartesianEntries(), 0, 0);
|
|
||||||
|
|
||||||
const double relative_velocity = kinematic::norm(velocity_target_fixed);
|
|
||||||
|
|
||||||
// std::stringstream out;
|
|
||||||
// out << "particle "<< particle.specie()->name() <<" velocity: "
|
|
||||||
// << particle_velocity.cartesianEntries();
|
|
||||||
// out << "\ntarget "<< target_->name() <<" velocity: "
|
|
||||||
// << target_velocity_.cartesianEntries();
|
|
||||||
// out << "\nabsolute relative velocity: " << relative_velocity;
|
|
||||||
|
|
||||||
// check if the relative velocity is smaller than an epsilon compared to the larger
|
|
||||||
// of the two present velocities (to avoid division by 0 if either is 0) probably
|
|
||||||
// a better version possible
|
|
||||||
if(relative_velocity/std::max(
|
|
||||||
kinematic::norm(particle_velocity.cartesianEntries()),
|
|
||||||
kinematic::norm(target_velocity_.cartesianEntries())
|
|
||||||
) < SimConstants::compare_epsilon) {
|
|
||||||
return std::numeric_limits<double>::max();
|
|
||||||
}
|
|
||||||
|
|
||||||
const double energy_eV =
|
|
||||||
kinematic::kineticEnergy(velocity_target_fixed, particle.mass_kg())*
|
|
||||||
UnitConversion::JouleToeV;
|
|
||||||
|
|
||||||
// out << "energy collision time: " << energy_eV;
|
|
||||||
|
|
||||||
const double crosssection = microscopicCrossSection(energy_eV,
|
|
||||||
particle.cylinderPosition());
|
|
||||||
// out << "\ncross section: " << crosssection;
|
|
||||||
const double density = target_->densityField()->density(particle.cylinderPosition());
|
|
||||||
|
|
||||||
// out << "\ninverse mfp: " << crosssection*density << ", sigma: " << crosssection;
|
|
||||||
// out << ", density: " << density;
|
|
||||||
|
|
||||||
const double random_number = generator->rollUniform(0.,1.);
|
|
||||||
if (random_number == 0) {
|
|
||||||
return std::numeric_limits<double>::max();
|
|
||||||
}
|
|
||||||
|
|
||||||
const double distance_target_fixed =
|
|
||||||
- 1./(crosssection * density) * log(random_number);
|
|
||||||
|
|
||||||
// out << "\ndistance in target fixed frame: " << distance_target_fixed;
|
|
||||||
|
|
||||||
const double time = distance_target_fixed / relative_velocity;
|
|
||||||
// out << "\ntime before collision: " << time;
|
|
||||||
// if(density != 0)
|
|
||||||
// DEBUG_LEVEL_1(out.str());
|
|
||||||
|
|
||||||
return time;
|
|
||||||
}
|
|
||||||
|
|
||||||
ElasticScatteringFull::ElasticScatteringFull(
|
|
||||||
std::function<double(double)> cross_section,
|
|
||||||
std::shared_ptr<species::Specie> target,
|
|
||||||
std::shared_ptr<ScatteringAngleDistribution> theta_distrib,
|
|
||||||
std::shared_ptr<species::TrackedSpecie> product) :
|
|
||||||
ElasticScattering(cross_section, target, theta_distrib),
|
|
||||||
product_(product) {}
|
|
||||||
|
|
||||||
// always assumes an isotropic angle distribution in the CoM frame
|
|
||||||
InteractionOutput ElasticScatteringFull::performInteraction(particle::Particle& particle,
|
|
||||||
RandomNumbers* generator) {
|
|
||||||
#ifdef debug
|
|
||||||
DEBUG_LEVEL_0("Perform full elastic scattering.");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const blitz::TinyVector<double, 3> v_impact =
|
|
||||||
particle.velocity().cartesianEntries();
|
|
||||||
|
|
||||||
// fprintf(stdout, "<%d>: Ekin T+ %e \n", MpiCommunication::mpiRank(), particle.kineticEnergy_eV());
|
|
||||||
|
|
||||||
const blitz::TinyVector<double, 3> v_com =
|
|
||||||
kinematic::velocityOfCenterOfMass(v_impact, target_velocity_.cartesianEntries(),
|
|
||||||
particle.mass_kg(), target_->mass_kg());
|
|
||||||
|
|
||||||
const double theta = std::acos(1. - 2*generator->rollUniform(0.,1.));
|
|
||||||
const double phi = generator->rollUniform(0., 2 * M_PI);
|
|
||||||
|
|
||||||
double vi_com_abs = kinematic::norm(v_impact - v_com);
|
|
||||||
|
|
||||||
// isotropic in CoM
|
|
||||||
blitz::TinyVector<double, 3> vi_com_scat(std::sin(theta)*std::cos(phi),
|
|
||||||
std::sin(theta)*std::sin(phi),
|
|
||||||
std::cos(theta));
|
|
||||||
vi_com_scat *= vi_com_abs;
|
|
||||||
blitz::TinyVector<double, 3> vt_com_scat = -particle.mass_kg()/target_->mass_kg() * vi_com_scat;
|
|
||||||
|
|
||||||
particle.velocity(CartesianVector(vi_com_scat + v_com));
|
|
||||||
|
|
||||||
// double Ekin = kinematic::kineticEnergy(vt_com_scat, product_->mass_kg())*UnitConversion::JouleToeV;
|
|
||||||
// fprintf(stdout, "<%d>: Ekin T2scat %f\n", MpiCommunication::mpiRank(), Ekin);
|
|
||||||
// Ekin = kinematic::kineticEnergy(vi_com_scat, particle.mass_kg())*UnitConversion::JouleToeV;
|
|
||||||
// fprintf(stdout, "<%d>: Ekin T+scat %f\n", MpiCommunication::mpiRank(), Ekin);
|
|
||||||
|
|
||||||
InteractionOutput output;
|
|
||||||
output.add(particle::Particle(product_, particle.cartesianPosition(),
|
|
||||||
CartesianVector(vt_com_scat+v_com),
|
|
||||||
particle.timeAlive(), particle.weight()));
|
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
}; // namespace interaction
|
}; // namespace interaction
|
||||||
@@ -18,9 +18,7 @@ Excitation::Excitation(std::function<double(double)> cross_section,
|
|||||||
|
|
||||||
InteractionOutput Excitation::performInteraction(particle::Particle& particle,
|
InteractionOutput Excitation::performInteraction(particle::Particle& particle,
|
||||||
RandomNumbers* generator) {
|
RandomNumbers* generator) {
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("Perform excitation.");
|
DEBUG_LEVEL_3("Perform excitation.");
|
||||||
#endif
|
|
||||||
const blitz::TinyVector<double, 3> v_impact =
|
const blitz::TinyVector<double, 3> v_impact =
|
||||||
particle.velocity().cartesianEntries();
|
particle.velocity().cartesianEntries();
|
||||||
const blitz::TinyVector<double, 3> n_impact =
|
const blitz::TinyVector<double, 3> n_impact =
|
||||||
|
|||||||
@@ -10,15 +10,12 @@ FreeMovement::FreeMovement()
|
|||||||
|
|
||||||
InteractionOutput FreeMovement::performInteraction(particle::Particle& particle,
|
InteractionOutput FreeMovement::performInteraction(particle::Particle& particle,
|
||||||
RandomNumbers* generator) {
|
RandomNumbers* generator) {
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("Perform free movement.");
|
DEBUG_LEVEL_3("Perform free movement.");
|
||||||
#endif
|
|
||||||
// do nothing
|
// do nothing
|
||||||
return InteractionOutput();
|
return InteractionOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
double FreeMovement::microscopicCrossSection(double energy_eV,
|
double FreeMovement::microscopicCrossSection(double energy_eV) {
|
||||||
const Coordinate& position) {
|
|
||||||
// returns very small number
|
// returns very small number
|
||||||
return SimConstants::minimal_cross_section;
|
return SimConstants::minimal_cross_section;
|
||||||
}
|
}
|
||||||
@@ -26,8 +23,4 @@ double FreeMovement::macroscopicCrossSection(particle::Particle& particle) {
|
|||||||
// returns a very small number, so the interaction will only be
|
// returns a very small number, so the interaction will only be
|
||||||
return SimConstants::minimal_macroscopic_cross_section;
|
return SimConstants::minimal_macroscopic_cross_section;
|
||||||
}
|
}
|
||||||
double FreeMovement::drawCollisionTime(particle::Particle& particle,
|
|
||||||
RandomNumbers* generator) {
|
|
||||||
return std::numeric_limits<double>::max();
|
|
||||||
}
|
|
||||||
}; // namespace interaction
|
}; // namespace interaction
|
||||||
@@ -18,60 +18,39 @@ ElectronIonization::ElectronIonization(
|
|||||||
std::shared_ptr<species::TrackedSpecie> ion,
|
std::shared_ptr<species::TrackedSpecie> ion,
|
||||||
std::shared_ptr<IonizationEnergyDistribution> distribution,
|
std::shared_ptr<IonizationEnergyDistribution> distribution,
|
||||||
std::shared_ptr<IonizationScatteringAngleDistribution> angle_distribution,
|
std::shared_ptr<IonizationScatteringAngleDistribution> angle_distribution,
|
||||||
double ionization_energy_eV, double ion_energy)
|
double ionization_energy_eV)
|
||||||
: Interaction(cross_section, target),
|
: Interaction(cross_section, target),
|
||||||
electron_(electron),
|
electron_(electron),
|
||||||
ion_(ion),
|
ion_(ion),
|
||||||
energy_distribution_(distribution),
|
energy_distribution_(distribution),
|
||||||
angle_distribution_(angle_distribution),
|
angle_distribution_(angle_distribution),
|
||||||
ionization_energy_eV_(ionization_energy_eV),
|
ionization_energy_eV_(ionization_energy_eV) {}
|
||||||
ion_energy_(ion_energy) {}
|
|
||||||
|
|
||||||
InteractionOutput ElectronIonization::performInteraction(
|
InteractionOutput ElectronIonization::performInteraction(
|
||||||
particle::Particle& particle,
|
particle::Particle& particle,
|
||||||
RandomNumbers* generator) {
|
RandomNumbers* generator) {
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("Perform ionization.");
|
DEBUG_LEVEL_3("Perform ionization.");
|
||||||
#endif
|
|
||||||
|
|
||||||
const blitz::TinyVector<double, 3> v_impact =
|
const blitz::TinyVector<double, 3> v_impact =
|
||||||
particle.velocity().cartesianEntries();
|
particle.velocity().cartesianEntries();
|
||||||
const auto x_impact = particle.cartesianPosition();
|
const auto x_impact = particle.position();
|
||||||
|
|
||||||
blitz::TinyVector<double, 3> v_target = target_->velocityDistribution()->
|
blitz::TinyVector<double, 3> v_target;
|
||||||
rollVelocity(particle.cylinderPosition(),
|
blitz::TinyVector<double, 3> v_laboratory;
|
||||||
generator->engine()).cartesianEntries();
|
double E_impact;
|
||||||
if(target_->driftVelocity()) {
|
do {
|
||||||
v_target += target_->driftVelocity()
|
v_target =
|
||||||
->driftVelocity(x_impact, particle.cylinderPosition())
|
target_->driftVelocity()->driftVelocity(x_impact).cartesianEntries() +
|
||||||
.cartesianEntries();
|
target_->velocityDistibution()
|
||||||
}
|
->rollVelocity(x_impact, generator->engine())
|
||||||
|
.cartesianEntries();
|
||||||
|
|
||||||
// don't think is quite right, since there is no energy transfer to the ion,
|
v_laboratory = kinematic::velocityTargetFixed(
|
||||||
// and in the case of a dissociative event, the energy of the parent particle
|
v_impact, v_target, particle.mass_kg(), target_->mass_kg());
|
||||||
// is split between the child particles -> no rescaling required, since
|
|
||||||
// the neutral child particle also carries some of the energy
|
|
||||||
// v_target *= std::sqrt(target_->mass_kg()/ion_->mass_kg());
|
|
||||||
|
|
||||||
blitz::TinyVector<double, 3> v_laboratory = kinematic::velocityTargetFixed(
|
E_impact = kinematic::kineticEnergy(v_laboratory, particle.mass_kg()) *
|
||||||
v_impact, target_velocity_.cartesianEntries(), particle.mass_kg(), target_->mass_kg()
|
UnitConversion::JouleToeV;
|
||||||
);
|
} while (E_impact <= ionization_energy_eV_);
|
||||||
|
|
||||||
double E_impact = kinematic::kineticEnergy(v_laboratory, particle.mass_kg()) *
|
|
||||||
UnitConversion::JouleToeV;
|
|
||||||
// do {
|
|
||||||
// v_target =
|
|
||||||
// target_->driftVelocity()->driftVelocity(x_impact).cartesianEntries() +
|
|
||||||
// target_->velocityDistribution()
|
|
||||||
// ->rollVelocity(x_impact, generator->engine())
|
|
||||||
// .cartesianEntries();
|
|
||||||
|
|
||||||
// v_laboratory = kinematic::velocityTargetFixed(
|
|
||||||
// v_impact, v_target, particle.mass_kg(), target_->mass_kg());
|
|
||||||
|
|
||||||
// E_impact = kinematic::kineticEnergy(v_laboratory, particle.mass_kg()) *
|
|
||||||
// UnitConversion::JouleToeV;
|
|
||||||
// } while (E_impact <= ionization_energy_eV_);
|
|
||||||
|
|
||||||
const double E_impact_new =
|
const double E_impact_new =
|
||||||
energy_distribution_->rollImpactParticleEnergyAfterCollision(E_impact,
|
energy_distribution_->rollImpactParticleEnergyAfterCollision(E_impact,
|
||||||
@@ -87,7 +66,7 @@ InteractionOutput ElectronIonization::performInteraction(
|
|||||||
|
|
||||||
const double azimuth_angle_impact_new =
|
const double azimuth_angle_impact_new =
|
||||||
angle_distribution_->rollAzimuthImpactParticleAfterCollision(
|
angle_distribution_->rollAzimuthImpactParticleAfterCollision(
|
||||||
E_impact, E_ejected, generator);
|
E_impact, E_impact_new, generator);
|
||||||
const double azimuth_angle_ejected =
|
const double azimuth_angle_ejected =
|
||||||
angle_distribution_->rollAzimuthEjectedParticleAfterCollision(
|
angle_distribution_->rollAzimuthEjectedParticleAfterCollision(
|
||||||
E_impact, E_ejected, generator);
|
E_impact, E_ejected, generator);
|
||||||
@@ -104,34 +83,20 @@ InteractionOutput ElectronIonization::performInteraction(
|
|||||||
kinematic::rotateVector(v_lab_norm, azimuth_angle_impact_new,
|
kinematic::rotateVector(v_lab_norm, azimuth_angle_impact_new,
|
||||||
polar_angle_impact_new) *
|
polar_angle_impact_new) *
|
||||||
v_lab_impact_new +
|
v_lab_impact_new +
|
||||||
target_velocity_.cartesianEntries();
|
v_target;
|
||||||
|
|
||||||
const blitz::TinyVector<double, 3> v_ejected =
|
const blitz::TinyVector<double, 3> v_ejected =
|
||||||
kinematic::rotateVector(v_lab_norm, azimuth_angle_ejected,
|
kinematic::rotateVector(v_lab_norm, azimuth_angle_ejected,
|
||||||
polar_angle_ejected) *
|
polar_angle_ejected) *
|
||||||
v_lab_ejected +
|
v_lab_ejected +
|
||||||
target_velocity_.cartesianEntries();
|
v_target;
|
||||||
|
|
||||||
particle.velocity(v_impact_new);
|
particle.velocity(v_impact_new);
|
||||||
|
|
||||||
|
|
||||||
blitz::TinyVector<double, 3> v_ion = v_target;
|
|
||||||
|
|
||||||
if(ion_energy_ > 0) {
|
|
||||||
v_ion *= std::sqrt(ion_energy_*UnitConversion::eVToJoule/(kinematic::kineticEnergy(v_target, ion_->mass_kg())));
|
|
||||||
}
|
|
||||||
|
|
||||||
const double time_birth = particle.timeAlive();
|
|
||||||
const double weight_parent = particle.weight();
|
|
||||||
|
|
||||||
InteractionOutput output;
|
InteractionOutput output;
|
||||||
output.add(
|
output.add(
|
||||||
particle::Particle(electron_, x_impact, CartesianVector(v_ejected),
|
particle::Particle(electron_, x_impact, CartesianVector(v_ejected)));
|
||||||
time_birth, weight_parent));
|
output.add(particle::Particle(ion_, x_impact, CartesianVector(v_target)));
|
||||||
if(ion_energy_ > 0) {
|
|
||||||
output.add(particle::Particle(ion_, x_impact, CartesianVector(v_ion),
|
|
||||||
time_birth, weight_parent));
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
@@ -148,7 +113,7 @@ double IonizationEnergyDistribution::rollImpactParticleEnergyAfterCollision(
|
|||||||
// using rejection method:
|
// using rejection method:
|
||||||
// assuming cross section is highest at smallest numbers
|
// assuming cross section is highest at smallest numbers
|
||||||
const double energy_after_min = SimConstants::random_lower_limit;
|
const double energy_after_min = SimConstants::random_lower_limit;
|
||||||
const double energy_after_max = impact_energy - ionization_energy_eV_; // probably multiply by 0.5
|
const double energy_after_max = impact_energy - ionization_energy_eV_;
|
||||||
const double cross_section_min = 0;
|
const double cross_section_min = 0;
|
||||||
const double cross_section_max =
|
const double cross_section_max =
|
||||||
d2_cross_section_(impact_energy, energy_after_min);
|
d2_cross_section_(impact_energy, energy_after_min);
|
||||||
|
|||||||
@@ -6,8 +6,6 @@
|
|||||||
#include "simulation/kinematic.h"
|
#include "simulation/kinematic.h"
|
||||||
#include "constants/physical_constants.h"
|
#include "constants/physical_constants.h"
|
||||||
#include "simulation/drift_velocity.h"
|
#include "simulation/drift_velocity.h"
|
||||||
#include "simulation/electromagnetic_field.h"
|
|
||||||
#include "simulation/velocity_distribution.h"
|
|
||||||
|
|
||||||
namespace interaction {
|
namespace interaction {
|
||||||
|
|
||||||
@@ -18,107 +16,77 @@ Recombination::Recombination(std::function<double(double)> cross_section,
|
|||||||
InteractionOutput Recombination::performInteraction(
|
InteractionOutput Recombination::performInteraction(
|
||||||
particle::Particle& particle,
|
particle::Particle& particle,
|
||||||
RandomNumbers* generator) {
|
RandomNumbers* generator) {
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("Perform recombination.");
|
DEBUG_LEVEL_3("Perform recombination.");
|
||||||
#endif
|
|
||||||
|
|
||||||
// std::vector<double> macroscopic_bin_cross_sections_m;
|
std::vector<double> macroscopic_bin_cross_sections_m;
|
||||||
// const int number_energy_bins = recombination_target_->dynamicDensityField()
|
const int number_energy_bins = recombination_target_->dynamicDensityField()
|
||||||
// ->energyBinning()->binIndexMax();
|
->energyBinning()->binIndexMax();
|
||||||
// std::vector<double> energyBinBorders = recombination_target_->
|
std::vector<double> energyBinBorders = recombination_target_->
|
||||||
// dynamicDensityField()->energyBinning()->binBorders();
|
dynamicDensityField()->energyBinning()->binBorders();
|
||||||
|
|
||||||
// if(recombination_target_->type() == species::ImplementedSpecies::electron) {
|
if(recombination_target_->type() == species::ImplementedSpecies::electron) {
|
||||||
// for (int bin = 0; bin < number_energy_bins - 1; ++bin) {
|
for (int bin = 0; bin < number_energy_bins - 1; ++bin) {
|
||||||
// macroscopic_bin_cross_sections_m.push_back(
|
macroscopic_bin_cross_sections_m.push_back(
|
||||||
// macroscopicCrossSection(particle.position(), bin));
|
macroscopicCrossSection(particle.position(), bin));
|
||||||
// }
|
}
|
||||||
// } else {
|
} else {
|
||||||
// const blitz::TinyVector<double, 3> v_particle =
|
const blitz::TinyVector<double, 3> v_particle =
|
||||||
// particle.velocity().cartesianEntries();
|
particle.velocity().cartesianEntries();
|
||||||
|
|
||||||
// if(!recombination_target_->driftVelocity()) {
|
if(!recombination_target_->driftVelocity()) {
|
||||||
// ERROR(recombination_target_->name() + ": does not have a drift velocity!");
|
ERROR(recombination_target_->name() + ": does not have a drift velocity!");
|
||||||
// }
|
}
|
||||||
|
|
||||||
// const blitz::TinyVector<double, 3> v_partner =
|
const blitz::TinyVector<double, 3> v_partner =
|
||||||
// recombination_target_->driftVelocity()
|
recombination_target_->driftVelocity()
|
||||||
// ->driftVelocity(particle.position()).cartesianEntries();
|
->driftVelocity(particle.position()).cartesianEntries();
|
||||||
|
|
||||||
// const blitz::TinyVector<double, 3> velocity_target_fixed =
|
const blitz::TinyVector<double, 3> velocity_target_fixed =
|
||||||
// kinematic::velocityTargetFixed(v_particle, v_partner, particle.mass_kg(),
|
kinematic::velocityTargetFixed(v_particle, v_partner, particle.mass_kg(),
|
||||||
// recombination_target_->mass_kg());
|
recombination_target_->mass_kg());
|
||||||
|
|
||||||
// const double kinetic_energy_eV =
|
const double kinetic_energy_eV =
|
||||||
// kinematic::kineticEnergy(velocity_target_fixed, particle.mass_kg()) *
|
kinematic::kineticEnergy(velocity_target_fixed, particle.mass_kg()) *
|
||||||
// UnitConversion::JouleToeV;
|
UnitConversion::JouleToeV;
|
||||||
|
|
||||||
|
|
||||||
// double energy_eV_bin_center;
|
double energy_eV_bin_center;
|
||||||
// for (int bin = 0; bin < number_energy_bins - 1; ++bin) {
|
for (int bin = 0; bin < number_energy_bins - 1; ++bin) {
|
||||||
// energy_eV_bin_center = (energyBinBorders[bin] + energyBinBorders[bin+1])/2.;
|
energy_eV_bin_center = (energyBinBorders[bin] + energyBinBorders[bin+1])/2.;
|
||||||
// macroscopic_bin_cross_sections_m.push_back(
|
macroscopic_bin_cross_sections_m.push_back(
|
||||||
// microscopicCrossSection(kinetic_energy_eV) *
|
microscopicCrossSection(kinetic_energy_eV) *
|
||||||
// recombination_target_->dynamicDensityField()
|
recombination_target_->dynamicDensityField()
|
||||||
// ->density(particle.position(), energy_eV_bin_center));
|
->density(particle.position(), energy_eV_bin_center));
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// const double total_macroscopic_cross_section_m =
|
const double total_macroscopic_cross_section_m =
|
||||||
// std::accumulate(macroscopic_bin_cross_sections_m.begin(),
|
std::accumulate(macroscopic_bin_cross_sections_m.begin(),
|
||||||
// macroscopic_bin_cross_sections_m.end(), 0.0);
|
macroscopic_bin_cross_sections_m.end(), 0.0);
|
||||||
|
|
||||||
// if(total_macroscopic_cross_section_m <= 0.) {
|
if(total_macroscopic_cross_section_m <= 0.) {
|
||||||
// ERROR("Total cross section is " +
|
ERROR("Total cross section is " +
|
||||||
// std::to_string(total_macroscopic_cross_section_m) +
|
std::to_string(total_macroscopic_cross_section_m) +
|
||||||
// ". But recombination was chosen.");
|
". But recombination was chosen.");
|
||||||
// }
|
}
|
||||||
|
|
||||||
// std::discrete_distribution<int> energy_bin_decider(
|
std::discrete_distribution<int> energy_bin_decider(
|
||||||
// macroscopic_bin_cross_sections_m.begin(),
|
macroscopic_bin_cross_sections_m.begin(),
|
||||||
// macroscopic_bin_cross_sections_m.end());
|
macroscopic_bin_cross_sections_m.end());
|
||||||
|
|
||||||
// const int energy_bin = energy_bin_decider(*(generator->engine()));
|
const int energy_bin = energy_bin_decider(*(generator->engine()));
|
||||||
// const double energy_eV = (energyBinBorders[energy_bin] +
|
const double energy_eV = (energyBinBorders[energy_bin] +
|
||||||
// energyBinBorders[energy_bin+1]) / 2.;
|
energyBinBorders[energy_bin+1]) / 2.;
|
||||||
|
|
||||||
// blitz::TinyVector<double, 3> position_bins = recombination_target_->dynamicDensityField()
|
recombination_target_->dynamicDensityField()->logDeletion(particle.position(),
|
||||||
// ->positionBinning()->bin(particle.position().cylinderEntries());
|
energy_eV);
|
||||||
|
|
||||||
// const blitz::Array<double, 1> mu_distribution =
|
|
||||||
// recombination_target_->dynamicDensityField()
|
|
||||||
// ->timeInBinArray()(position_bins(0),
|
|
||||||
// position_bins(1),
|
|
||||||
// position_bins(2),
|
|
||||||
// blitz::Range::all(),
|
|
||||||
// energy_bin);
|
|
||||||
|
|
||||||
// std::vector<double> mu_borders = recombination_target_->dynamicDensityField()
|
|
||||||
// ->pitchAngleBinning()->binBorders();
|
|
||||||
|
|
||||||
// std::discrete_distribution<int> mu_bin_decider(mu_distribution.begin(),
|
|
||||||
// mu_distribution.end());
|
|
||||||
|
|
||||||
// const int mu_bin = mu_bin_decider(*(generator->engine()));
|
|
||||||
|
|
||||||
// if((mu_bin == 0) || (mu_bin == mu_distribution.size()-1)) {
|
|
||||||
// ERROR("Recombination: drawn mu is from over- or underflow bin!");
|
|
||||||
// std::stringstream out;
|
|
||||||
// out << "mu distribution values: n";
|
|
||||||
// out << mu_distribution;
|
|
||||||
// DEBUG_LEVEL_3(out.str());
|
|
||||||
// }
|
|
||||||
// const double mu = (mu_borders[mu_bin - 1] + mu_borders[mu_bin])/2.;
|
|
||||||
|
|
||||||
// recombination_target_->dynamicDensityField()->logDeletion(particle.position(),
|
|
||||||
// energy_eV, mu);
|
|
||||||
|
|
||||||
InteractionOutput output;
|
InteractionOutput output;
|
||||||
output.deleteCurrentParticle(true);
|
output.deleteCurrentParticle(true);
|
||||||
|
|
||||||
if (particle.specie()->deletionLogger()) {
|
if (particle.specie()->deletionLogger()) {
|
||||||
particle.specie()->deletionLogger()->logDeletion(
|
particle.specie()->deletionLogger()->logDeletion(
|
||||||
particle.cartesianPosition(), DeletionType::recombination);
|
particle.position(), DeletionType::recombination);
|
||||||
}
|
}
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
@@ -129,7 +97,7 @@ double Recombination::macroscopicCrossSection(particle::Particle& particle) {
|
|||||||
const int numBins = recombination_target_->dynamicDensityField()->
|
const int numBins = recombination_target_->dynamicDensityField()->
|
||||||
energyBinning()->binIndexMax();
|
energyBinning()->binIndexMax();
|
||||||
double macroscopic_cross_section = 0.;
|
double macroscopic_cross_section = 0.;
|
||||||
const auto position = particle.cylinderPosition();
|
const auto position = particle.position();
|
||||||
for (int bin = 0; bin < numBins - 1; ++bin) {
|
for (int bin = 0; bin < numBins - 1; ++bin) {
|
||||||
macroscopic_cross_section += macroscopicCrossSection(position, bin);
|
macroscopic_cross_section += macroscopicCrossSection(position, bin);
|
||||||
}
|
}
|
||||||
@@ -159,100 +127,11 @@ double Recombination::macroscopicCrossSection(const Coordinate& position,
|
|||||||
//Simpson's rule
|
//Simpson's rule
|
||||||
const double integrated_microscopic_cross_section =
|
const double integrated_microscopic_cross_section =
|
||||||
(upper_bound - lower_bound)/6. *
|
(upper_bound - lower_bound)/6. *
|
||||||
(microscopicCrossSection(upper_bound, position) +
|
(microscopicCrossSection(upper_bound) +
|
||||||
4*microscopicCrossSection(intermediate_value, position) +
|
4*microscopicCrossSection(intermediate_value) +
|
||||||
microscopicCrossSection(lower_bound, position));
|
microscopicCrossSection(lower_bound));
|
||||||
// assumption, that the differential density is constant within a cell
|
// assumption, that the differential density is constant within a cell
|
||||||
return differential_density_value * integrated_microscopic_cross_section;
|
return differential_density_value * integrated_microscopic_cross_section;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Recombination::drawCollisionTime(particle::Particle& particle,
|
|
||||||
RandomNumbers* generator) {
|
|
||||||
CartesianVector particle_velocity = particle.velocity();
|
|
||||||
// const double density = target_->densityField()->density(particle.cylinderPosition());
|
|
||||||
// Use the density for drawing field, since it contains the density of the earlier
|
|
||||||
// timestep
|
|
||||||
const double density = recombination_target_->dynamicDensityField()
|
|
||||||
->density(particle.cylinderPosition());
|
|
||||||
|
|
||||||
// recombination_target_->densityForDrawing()->recalculateDensityArray();
|
|
||||||
// if(density != recombination_target_->densityForDrawing()
|
|
||||||
// ->density(particle.cylinderPosition())) {
|
|
||||||
// ERROR("density changes after recalculation of density array!");
|
|
||||||
// }
|
|
||||||
// density effectively 0
|
|
||||||
if(density <= SimConstants::compare_epsilon) {
|
|
||||||
return std::numeric_limits<double>::max();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Assumes that B || z, which is obviously not necessarily the case !!!
|
|
||||||
target_velocity_ = recombination_target_->velocityDistributionFromDensityField()
|
|
||||||
->rollVelocity(particle.cylinderPosition(), generator->engine());
|
|
||||||
|
|
||||||
// for testing purposes
|
|
||||||
// target_velocity_ = CartesianVector(blitz::TinyVector<double, 3>(0.,0.,0.));
|
|
||||||
|
|
||||||
// masses are irrelevant for the transformation
|
|
||||||
const blitz::TinyVector<double, 3> velocity_target_fixed =
|
|
||||||
kinematic::velocityTargetFixed(particle_velocity.cartesianEntries(),
|
|
||||||
target_velocity_.cartesianEntries(), 0, 0);
|
|
||||||
|
|
||||||
const double relative_velocity = kinematic::norm(velocity_target_fixed);
|
|
||||||
|
|
||||||
// check if the relative velocity is smaller than an epsilon compared to the larger
|
|
||||||
// of the two present velocities (to avoid division by 0 if either is 0) probably
|
|
||||||
// a better version possible
|
|
||||||
if(relative_velocity/std::max(
|
|
||||||
kinematic::norm(particle_velocity.cartesianEntries()),
|
|
||||||
kinematic::norm(target_velocity_.cartesianEntries())
|
|
||||||
) < SimConstants::compare_epsilon) {
|
|
||||||
return std::numeric_limits<double>::max();
|
|
||||||
}
|
|
||||||
|
|
||||||
const double energy_eV =
|
|
||||||
(recombination_target_->type() == species::ImplementedSpecies::electron) ?
|
|
||||||
kinematic::kineticEnergy(velocity_target_fixed, recombination_target_->mass_kg())*
|
|
||||||
UnitConversion::JouleToeV :
|
|
||||||
kinematic::kineticEnergy(velocity_target_fixed, particle.mass_kg())*
|
|
||||||
UnitConversion::JouleToeV;
|
|
||||||
|
|
||||||
const double crosssection = microscopicCrossSection(energy_eV,
|
|
||||||
particle.cylinderPosition());
|
|
||||||
|
|
||||||
#if defined(debug)
|
|
||||||
if(density > 0 && std::isnan(crosssection)) {
|
|
||||||
std::stringstream msg;
|
|
||||||
msg << particle.specie()->name() << particle.cartesianPosition().cartesianEntries();
|
|
||||||
msg << " " << recombination_target_->dynamicDensityField()->positionBinning()->bin(particle.cylinderPosition().cylinderEntries());
|
|
||||||
msg << ": Recombination: density is not nan but the cross section is ";
|
|
||||||
msg << density << ", " << crosssection;
|
|
||||||
msg << recombination_target_->dynamicDensityField()->sliceSpectrumArray(particle.cylinderPosition());
|
|
||||||
ERROR(msg.str());
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const double random_number = generator->rollUniform(0.,1.);
|
|
||||||
if (random_number == 0) {
|
|
||||||
return std::numeric_limits<double>::max();
|
|
||||||
}
|
|
||||||
|
|
||||||
const double distance_target_fixed =
|
|
||||||
- 1./(crosssection * density) * log(random_number);
|
|
||||||
|
|
||||||
const double time = distance_target_fixed / relative_velocity;
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef debug_level2
|
|
||||||
std::stringstream out;
|
|
||||||
out << "particle energy: " << particle.kineticEnergy_eV();
|
|
||||||
out << "\ncross section: " << crosssection;
|
|
||||||
out << "\ndensity: " << density;
|
|
||||||
out << "\ntime: " << time;
|
|
||||||
if(density > 0)
|
|
||||||
DEBUG_LEVEL_2(out.str());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return time;
|
|
||||||
}
|
|
||||||
|
|
||||||
}; // namespace interaction
|
}; // namespace interaction
|
||||||
@@ -16,80 +16,88 @@ PoissonSolver::PoissonSolver(GlobalBoundary bottom_boundary,
|
|||||||
std::vector<std::shared_ptr<Electrode>> electrodes,
|
std::vector<std::shared_ptr<Electrode>> electrodes,
|
||||||
double target_accuracy,
|
double target_accuracy,
|
||||||
int num_cycles,
|
int num_cycles,
|
||||||
|
int solver_intervall,
|
||||||
|
int solver_offset,
|
||||||
bool do_solver)
|
bool do_solver)
|
||||||
: bottom_boundary_(bottom_boundary),
|
: bottom_boundary_(bottom_boundary),
|
||||||
top_boundary_(top_boundary),
|
top_boundary_(top_boundary),
|
||||||
hull_boundary_(hull_boundary),
|
hull_boundary_(hull_boundary),
|
||||||
geometry_(geometry),
|
geometry_(geometry),
|
||||||
density_binning_(density_binning),
|
density_binning_(density_binning),
|
||||||
potential_(blitz::Array<PotentialGridPoint, 2>(
|
potential_(blitz::Array<PotentialGridPoint, 3>(
|
||||||
blitz::Range(density_binning.binIndexMin()(0),
|
blitz::Range(density_binning.binIndexMin()(0),
|
||||||
density_binning.binIndexMax()(0)),
|
density_binning.binIndexMax()(0)),
|
||||||
blitz::Range(density_binning.binIndexMin()(1) + 1,
|
blitz::Range(density_binning.binIndexMin()(1),
|
||||||
density_binning.binIndexMax()(1)))),
|
density_binning.binIndexMax()(1)), // the azimuthal direction is periodic
|
||||||
|
blitz::Range(density_binning.binIndexMin()(2) + 1,
|
||||||
|
density_binning.binIndexMax()(2)))),
|
||||||
electrodes_(electrodes),
|
electrodes_(electrodes),
|
||||||
target_accuracy_(target_accuracy),
|
target_accuracy_(target_accuracy),
|
||||||
num_cycles_(num_cycles),
|
num_cycles_(num_cycles),
|
||||||
|
solver_intervall_(solver_intervall),
|
||||||
|
solver_offset_(solver_offset),
|
||||||
do_solver_(do_solver) {
|
do_solver_(do_solver) {
|
||||||
|
|
||||||
blitz::TinyVector<double, 2> stepsize = density_binning_.stepsize();
|
blitz::TinyVector<double, 3> stepsize = density_binning_.stepsize();
|
||||||
for (int i = potential_.lbound(0); i <= potential_.ubound(0); ++i) {
|
for (int i = potential_.lbound(0); i <= potential_.ubound(0); ++i) {
|
||||||
for (int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
for (int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
||||||
CylinderCoordinate position(blitz::TinyVector<double, 3>(
|
for (int k = potential_.lbound(2); k <= potential_.ubound(2);
|
||||||
i * stepsize(0), 0, j * stepsize(1)));
|
++k) {
|
||||||
|
CylinderCoordinate position(blitz::TinyVector<double, 3>(
|
||||||
|
i * stepsize(0), j * stepsize(1), k * stepsize(2)));
|
||||||
|
|
||||||
switch(geometry_->isWhere(position)) {
|
switch(geometry_->isWhere(position)) {
|
||||||
case GeometryPositioning::bottom:
|
case GeometryPositioning::bottom:
|
||||||
potential_(i,j) = {bottom_boundary_.type, bottom_boundary_.boundary_value};
|
potential_(i,j,k) = {bottom_boundary_.type, bottom_boundary_.boundary_value};
|
||||||
break;
|
break;
|
||||||
case GeometryPositioning::top:
|
case GeometryPositioning::top:
|
||||||
potential_(i,j) = {top_boundary_.type, top_boundary_.boundary_value};
|
potential_(i,j,k) = {top_boundary_.type, top_boundary_.boundary_value};
|
||||||
break;
|
break;
|
||||||
case GeometryPositioning::hull:
|
case GeometryPositioning::hull:
|
||||||
potential_(i,j) = {hull_boundary_.type, hull_boundary_.boundary_value};
|
potential_(i,j,k) = {hull_boundary_.type, hull_boundary_.boundary_value};
|
||||||
break;
|
break;
|
||||||
case GeometryPositioning::inside:
|
case GeometryPositioning::inside:
|
||||||
potential_(i,j) = {BoundaryType::no_boundary, 0.};
|
potential_(i,j,k) = {BoundaryType::no_boundary, 0.};
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// include position in output
|
// include position in output
|
||||||
ERROR("Something went terribly wrong. Position is nowhere.");
|
ERROR("Something went terribly wrong. Position is nowhere.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (auto& electrode : electrodes_) {
|
for (auto& electrode : electrodes_) {
|
||||||
if (electrode->isOnElectrode(position)) {
|
if (electrode->isOnElectrode(position)) {
|
||||||
potential_(i,j).type = BoundaryType::dirichlet;
|
potential_(i,j,k).type = BoundaryType::dirichlet;
|
||||||
potential_(i,j).value = electrode->electrodePotential();
|
potential_(i,j,k).value = electrode->electrodePotential();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
blitz::Array<double, 2> zero_chargedensity(
|
blitz::Array<double, 3> zero_chargedensity(
|
||||||
blitz::Range(density_binning.binIndexMin()(0),
|
blitz::Range(density_binning.binIndexMin()(0),
|
||||||
density_binning.binIndexMax()(0)),
|
density_binning.binIndexMax()(0)),
|
||||||
blitz::Range(density_binning.binIndexMin()(1),
|
blitz::Range(density_binning.binIndexMin()(1),
|
||||||
density_binning.binIndexMax()(1)));
|
density_binning.binIndexMax()(1)),
|
||||||
|
blitz::Range(density_binning.binIndexMin()(2),
|
||||||
|
density_binning.binIndexMax()(2)));
|
||||||
zero_chargedensity = 0.;
|
zero_chargedensity = 0.;
|
||||||
solvePotential(zero_chargedensity);
|
solvePotential(zero_chargedensity, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PoissonSolver::solvePotential(
|
void PoissonSolver::solvePotential(
|
||||||
const blitz::Array<double, 2> charge_density) {
|
const blitz::Array<double, 3> charge_density, int cpu_sync) {
|
||||||
if (!(do_solver_)) {
|
if ((!do_solver_) || ((cpu_sync % solver_intervall_ != 0) || ((cpu_sync <= solver_offset_)
|
||||||
|
&& (cpu_sync > 0)))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("Interpolating chargedensity.");
|
DEBUG_LEVEL_3("Interpolating chargedensity.");
|
||||||
#endif
|
blitz::Array<double, 3> interpolated_density =
|
||||||
blitz::Array<double, 2> interpolated_density =
|
|
||||||
interpolateDensityToPotentialGrid(charge_density);
|
interpolateDensityToPotentialGrid(charge_density);
|
||||||
int it = 1;
|
int it = 1;
|
||||||
do {
|
do {
|
||||||
solverIteration(interpolated_density);
|
solverIteration(interpolated_density);
|
||||||
if (it % 1000 == 0) {
|
if (it % 1000 == 0) {
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("Poisson solver, iteration: " + std::to_string(it));
|
DEBUG_LEVEL_3("Poisson solver, iteration: " + std::to_string(it));
|
||||||
#endif
|
|
||||||
if (converged(interpolated_density)) {
|
if (converged(interpolated_density)) {
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
@@ -99,45 +107,61 @@ void PoissonSolver::solvePotential(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PoissonSolver::solverIteration(
|
void PoissonSolver::solverIteration(
|
||||||
const blitz::Array<double, 2>& interpolated_density) {
|
const blitz::Array<double, 3>& interpolated_density) {
|
||||||
blitz::TinyVector<double, 2> stepsize = density_binning_.stepsize();
|
blitz::TinyVector<double, 3> stepsize = density_binning_.stepsize();
|
||||||
const double dr_sq = stepsize(0)*stepsize(0); // shorthand
|
const double dr_sq = std::pow(stepsize(0), 2); // shorthand
|
||||||
const double dz_sq = stepsize(1)*stepsize(1); // shorthand
|
const double dth_sq = std::pow(stepsize(1), 2); // shorthand
|
||||||
|
const double dz_sq = std::pow(stepsize(2), 2); // shorthand
|
||||||
|
|
||||||
for (int i = potential_.lbound(0); i <= potential_.ubound(0); ++i) {
|
for (int i = potential_.lbound(0); i <= potential_.ubound(0); ++i) {
|
||||||
for (int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
for (int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
||||||
//rewrite with a switch-case
|
for (int k = potential_.lbound(2); k <= potential_.ubound(2); ++k) {
|
||||||
if (potential_(i, j).type == BoundaryType::dirichlet) {
|
//rewrite with a switch-case
|
||||||
potential_(i, j).value = potential_(i, j).value;
|
if (potential_(i, j, k).type == BoundaryType::dirichlet) {
|
||||||
} else if (potential_(i, j).type == BoundaryType::neumann_to_top) {
|
potential_(i, j, k).value = potential_(i, j, k).value;
|
||||||
potential_(i, j).value = potential_(i, j-1).value
|
} else if (potential_(i, j, k).type == BoundaryType::neumann_to_top) {
|
||||||
+ top_boundary_.boundary_value * stepsize(1);
|
potential_(i, j, k).value = potential_(i, j, k - 1).value
|
||||||
} else if (potential_(i, j).type == BoundaryType::neumann_to_bottom) {
|
+ top_boundary_.boundary_value * stepsize(2);
|
||||||
potential_(i, j).value = potential_(i, j + 1).value
|
} else if (potential_(i, j, k).type == BoundaryType::neumann_to_bottom) {
|
||||||
- bottom_boundary_.boundary_value * stepsize(1);
|
potential_(i, j, k).value = potential_(i, j, k + 1).value
|
||||||
} else if (potential_(i, j).type == BoundaryType::neumann_to_hull) {
|
- bottom_boundary_.boundary_value * stepsize(2);
|
||||||
potential_(i, j).value = potential_(i - 1, j).value
|
} else if (potential_(i, j, k).type == BoundaryType::neumann_to_hull) {
|
||||||
+ hull_boundary_.boundary_value * stepsize(0);
|
potential_(i, j, k).value = potential_(i - 1, j, k).value
|
||||||
} else if (i == 0) {
|
+ hull_boundary_.boundary_value * stepsize(0);
|
||||||
// special calculation for r=0
|
} else if (i == 0) {
|
||||||
const double scaling_factor = 4 / dr_sq + 2 / dz_sq;
|
// special calculation for r=0
|
||||||
potential_(i, j).value =
|
const int jmirror = (j<potential_.extent(1)/2) ? j+potential_.extent(1)/2
|
||||||
(1 / scaling_factor) *
|
: j-potential_.extent(1)/2;
|
||||||
((4 / dr_sq) * (potential_(i + 1, j).value) +
|
const double scaling_factor = 4 / dr_sq + 2 / dz_sq;
|
||||||
(1 / dz_sq) * (potential_(i, j + 1).value +
|
potential_(i, j, k).value =
|
||||||
potential_(i, j - 1).value) +
|
(1 / scaling_factor) *
|
||||||
interpolated_density(i, j)/SI::eps0);
|
((2 / dr_sq) * (potential_(i + 1, j, k).value +
|
||||||
|
potential_(i + 1, jmirror, k).value) +
|
||||||
|
(1 / dz_sq) * (potential_(i, j, k + 1).value +
|
||||||
|
potential_(i, j, k - 1).value) +
|
||||||
|
interpolated_density(i, j, k)/SI::eps0);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
const double scaling_factor = 2 / dr_sq + 2 / dz_sq;
|
const int jp1 = j + 1 > potential_.ubound(1)
|
||||||
|
? potential_.lbound(1)
|
||||||
|
: j + 1; // j+1 with periodic guard
|
||||||
|
const int jm1 = j - 1 < potential_.lbound(1)
|
||||||
|
? potential_.ubound(1)
|
||||||
|
: j - 1; // j-1 with periodic guard
|
||||||
|
|
||||||
potential_(i, j).value =
|
const double scaling_factor = 2 / dr_sq + 2 / dz_sq +
|
||||||
(1 / scaling_factor) *
|
2 / (std::pow(i, 2) * dr_sq * dth_sq);
|
||||||
((1 / dr_sq * (1 + 1. / (2. * i))) * potential_(i + 1, j).value +
|
|
||||||
(1 / dr_sq * (1 - 1. / (2. * i))) * potential_(i - 1, j).value +
|
potential_(i, j, k).value =
|
||||||
(1 / dz_sq) * (potential_(i, j + 1).value +
|
(1 / scaling_factor) *
|
||||||
potential_(i, j - 1).value) +
|
((1 / dr_sq * (1 + 1. / (2. * i))) * potential_(i + 1, j, k).value +
|
||||||
interpolated_density(i, j)/SI::eps0);
|
(1 / dr_sq * (1 - 1. / (2. * i))) * potential_(i - 1, j, k).value +
|
||||||
|
(1 / (std::pow(i, 2) * dr_sq * dth_sq)) *
|
||||||
|
(potential_(i, jp1, k).value + potential_(i, jm1, k).value) +
|
||||||
|
(1 / dz_sq) * (potential_(i, j, k + 1).value +
|
||||||
|
potential_(i, j, k - 1).value) +
|
||||||
|
interpolated_density(i, j, k)/SI::eps0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -146,10 +170,11 @@ void PoissonSolver::solverIteration(
|
|||||||
//as of now does not check for inner cells with dirichlet or neumann
|
//as of now does not check for inner cells with dirichlet or neumann
|
||||||
//boundary, probably needs to be added (or the "electrodes" removed)
|
//boundary, probably needs to be added (or the "electrodes" removed)
|
||||||
bool PoissonSolver::converged(
|
bool PoissonSolver::converged(
|
||||||
const blitz::Array<double, 2>& interpolated_density) {
|
const blitz::Array<double, 3>& interpolated_density) {
|
||||||
blitz::TinyVector<double, 2> stepsize = density_binning_.stepsize();
|
blitz::TinyVector<double, 3> stepsize = density_binning_.stepsize();
|
||||||
const double dr_sq = stepsize(0)*stepsize(0); // shorthand
|
const double dr_sq = std::pow(stepsize(0), 2); // shorthand
|
||||||
const double dz_sq = stepsize(1)*stepsize(1); // shorthand
|
const double dth_sq = std::pow(stepsize(1), 2); // shorthand
|
||||||
|
const double dz_sq = std::pow(stepsize(2), 2); // shorthand
|
||||||
|
|
||||||
double cumulated_quadradic_difference = 0.;
|
double cumulated_quadradic_difference = 0.;
|
||||||
double normalized_difference = 0.;
|
double normalized_difference = 0.;
|
||||||
@@ -157,88 +182,104 @@ bool PoissonSolver::converged(
|
|||||||
|
|
||||||
for (int i = potential_.lbound(0); i < potential_.ubound(0); ++i) {
|
for (int i = potential_.lbound(0); i < potential_.ubound(0); ++i) {
|
||||||
for (int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
for (int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
||||||
if(potential_(i,j).type != BoundaryType::no_boundary) {
|
for (int k = potential_.lbound(2) + 1; k <= potential_.ubound(2) - 1;
|
||||||
continue;
|
++k) {
|
||||||
}
|
if(potential_(i,j,k).type != BoundaryType::no_boundary) {
|
||||||
if (i == 0) {
|
continue;
|
||||||
// special calculation for r=0
|
|
||||||
const double difference = interpolated_density(i,j)/SI::eps0 +
|
|
||||||
4*(potential_(i+1,j).value - potential_(i,j).value)/dr_sq +
|
|
||||||
(potential_(i,j+1).value - 2*potential_(i,j).value +
|
|
||||||
potential_(i,j-1).value)/dz_sq;
|
|
||||||
|
|
||||||
cumulated_quadradic_difference += difference*difference;
|
|
||||||
|
|
||||||
if(fabs(difference) > maximum_difference) {
|
|
||||||
maximum_difference = fabs(difference);
|
|
||||||
}
|
}
|
||||||
|
if (i == 0) {
|
||||||
|
// special calculation for r=0
|
||||||
|
//Note: the value \phi_{i,j+Nj/2,k} as the replacement of
|
||||||
|
// \phi_{i-1,j,k} is only correct if Nj is even otherwise the mirrored point
|
||||||
|
// lies inbetween two known values; additionally not sure if this calculation
|
||||||
|
// is correct at all (would definitely be fine for cylindrical symmetric calc.)
|
||||||
|
const int jmirror = (j<potential_.extent(1)/2) ? j+potential_.extent(1)/2
|
||||||
|
: j-potential_.extent(1)/2;
|
||||||
|
const double difference = interpolated_density(i,j,k)/SI::eps0 +
|
||||||
|
2*(potential_(i+1,j,k).value - 2*potential_(i,j,k).value +
|
||||||
|
potential_(i+1,jmirror,k).value)/dr_sq +
|
||||||
|
(potential_(i,j,k+1).value - 2*potential_(i,j,k).value +
|
||||||
|
potential_(i,j,k-1).value)/dz_sq;
|
||||||
|
|
||||||
} else {
|
cumulated_quadradic_difference += std::pow(difference, 2);
|
||||||
const double difference = interpolated_density(i,j)/SI::eps0 +
|
|
||||||
(potential_(i+1,j).value - 2*potential_(i,j).value +
|
|
||||||
potential_(i-1,j).value)/dr_sq +
|
|
||||||
(potential_(i+1,j).value - potential_(i-1,j).value)/
|
|
||||||
(2*i*dr_sq) +
|
|
||||||
(potential_(i,j+1).value - 2*potential_(i,j).value +
|
|
||||||
potential_(i,j-1).value)/dz_sq;
|
|
||||||
|
|
||||||
cumulated_quadradic_difference += difference*difference;
|
if(fabs(difference) > maximum_difference) {
|
||||||
|
maximum_difference = fabs(difference);
|
||||||
|
}
|
||||||
|
|
||||||
if(fabs(difference) > maximum_difference) {
|
} else {
|
||||||
maximum_difference = fabs(difference);
|
const int jp1 = j + 1 > potential_.ubound(1)
|
||||||
|
? potential_.lbound(1)
|
||||||
|
: j + 1; // j+1 with periodic guard
|
||||||
|
const int jm1 = j - 1 < potential_.lbound(1)
|
||||||
|
? potential_.ubound(1)
|
||||||
|
: j - 1; // j-1 with periodic guard
|
||||||
|
|
||||||
|
const double difference = interpolated_density(i,j,k)/SI::eps0 +
|
||||||
|
(potential_(i+1,j,k).value - 2*potential_(i,j,k).value +
|
||||||
|
potential_(i-1,j,k).value)/dr_sq +
|
||||||
|
(potential_(i+1,j,k).value - potential_(i-1,j,k).value)/
|
||||||
|
(2*i*dr_sq) +
|
||||||
|
(potential_(i,jp1,k).value - 2*potential_(i,j,k).value +
|
||||||
|
potential_(i,jm1,k).value)/(std::pow(i,2)*dr_sq*dth_sq) +
|
||||||
|
(potential_(i,j,k+1).value - 2*potential_(i,j,k).value +
|
||||||
|
potential_(i,j,k-1).value)/dz_sq;
|
||||||
|
|
||||||
|
cumulated_quadradic_difference += std::pow(difference, 2);
|
||||||
|
|
||||||
|
if(fabs(difference) > maximum_difference) {
|
||||||
|
maximum_difference = fabs(difference);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const int nr = potential_.extent(0) - 1;
|
const int nr = potential_.extent(0) - 1;
|
||||||
const int nz = potential_.extent(1) - 2;
|
const int nth = potential_.extent(1);
|
||||||
|
const int nz = potential_.extent(2) - 2;
|
||||||
|
|
||||||
normalized_difference =
|
normalized_difference =
|
||||||
std::sqrt(cumulated_quadradic_difference / (nr * nz));
|
std::sqrt(cumulated_quadradic_difference / (nr * nth * nz));
|
||||||
#ifdef debug
|
DEBUG_LEVEL_0("Poisson solver reached a normalized difference of: " +
|
||||||
std::stringstream out;
|
std::to_string(normalized_difference));
|
||||||
out << "Poisson solver reached a normalized difference of: ";
|
|
||||||
out << normalized_difference;
|
|
||||||
DEBUG_LEVEL_0(out.str());
|
|
||||||
#endif
|
|
||||||
double normalized_maximum =
|
double normalized_maximum =
|
||||||
maximum_difference*SI::eps0/(fabs(blitz::max(interpolated_density)) + 1e-12);
|
maximum_difference*SI::eps0/(fabs(blitz::max(interpolated_density)) + 1e-12);
|
||||||
#ifdef debug
|
|
||||||
std::ostringstream message;
|
std::ostringstream message;
|
||||||
message << "Maximum Difference normalized by order of magnitude: "
|
message << "Maximum Differenece normalized by order of magnitude: "
|
||||||
<< normalized_maximum;
|
<< normalized_difference;
|
||||||
DEBUG(message.str());
|
DEBUG_LEVEL_0(message.str());
|
||||||
#endif
|
|
||||||
return normalized_difference < target_accuracy_;
|
return normalized_difference < target_accuracy_;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 2> PoissonSolver::potential() {
|
blitz::Array<double, 3> PoissonSolver::potential() {
|
||||||
// there might be a better way to do this... (if one can do array.memberValue without
|
// there might be a better way to do this... (if one can do array.memberValue without
|
||||||
// explicitely looping)
|
// explicitely looping)
|
||||||
blitz::Array<double, 2> potentialValues(potential_.lbound(), potential_.extent());
|
blitz::Array<double, 3> potentialValues(potential_.lbound(), potential_.extent());
|
||||||
#ifdef debug_level3
|
|
||||||
DEBUG_LEVEL_3("Extracting potential values");
|
DEBUG_LEVEL_3("Extracting potential values");
|
||||||
#endif
|
|
||||||
for(int i = potential_.lbound(0); i <= potential_.ubound(0); ++i) {
|
for(int i = potential_.lbound(0); i <= potential_.ubound(0); ++i) {
|
||||||
for(int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
for(int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
||||||
potentialValues(i,j) = potential_(i,j).value;
|
for(int k = potential_.lbound(2); k <= potential_.ubound(2); ++k) {
|
||||||
|
potentialValues(i,j,k) = potential_(i,j,k).value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return potentialValues;
|
return potentialValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 2> PoissonSolver::interpolateDensityToPotentialGrid(
|
blitz::Array<double, 3> PoissonSolver::interpolateDensityToPotentialGrid(
|
||||||
const blitz::Array<double, 2> density) {
|
const blitz::Array<double, 3> density) {
|
||||||
// adapted from the external poisson solver (SDS: \\lsdf02.urz.uni-heidelberg.de\SD19H002\karl\src\tools\analysis_jkellerer)
|
// adapted from the external poisson solver (SDS: \\lsdf02.urz.uni-heidelberg.de\SD19H002\karl\src\tools\analysis_jkellerer)
|
||||||
blitz::Array<double, 2> interpolatedDensity(potential_.lbound(), potential_.extent());
|
blitz::Array<double, 3> interpolatedDensity(potential_.lbound(), potential_.extent());
|
||||||
interpolatedDensity = 0.;
|
interpolatedDensity = 0.;
|
||||||
|
|
||||||
//center values
|
//center values
|
||||||
for(int i = potential_.lbound(0)+1; i <= potential_.ubound(0); ++i) {
|
for(int i = potential_.lbound(0)+1; i <= potential_.ubound(0); ++i) {
|
||||||
for(int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
for(int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
||||||
interpolatedDensity(i, j) = (
|
for(int k = potential_.lbound(2); k <= potential_.ubound(2); ++k) {
|
||||||
density(i-1, j-1) + density(i, j-1) +
|
interpolatedDensity(i, j, k) = (
|
||||||
density(i-1, j ) + density(i, j ))/4.;
|
density(i-1, j , k-1) + density(i, j , k-1) +
|
||||||
|
density(i-1, j , k ) + density(i, j , k ))/4.;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,79 +287,79 @@ blitz::Array<double, 2> PoissonSolver::interpolateDensityToPotentialGrid(
|
|||||||
//values for r=0; charge density has to be single valued at r=0
|
//values for r=0; charge density has to be single valued at r=0
|
||||||
//therefore all elements in the j index have to be the same
|
//therefore all elements in the j index have to be the same
|
||||||
fixedIndex = potential_.lbound(0);
|
fixedIndex = potential_.lbound(0);
|
||||||
for(int k = potential_.lbound(1)+1; k <= potential_.ubound(1)-1; ++k) {
|
for(int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
||||||
//might not work that way, would need a dummy variable otherwise
|
for(int k = potential_.lbound(2)+1; k <= potential_.ubound(2)-1; ++k) {
|
||||||
interpolatedDensity(potential_.lbound(0), k) =
|
//might not work that way, would need a dummy variable otherwise
|
||||||
(density(fixedIndex, k-1) + density(fixedIndex, k))/2.;
|
interpolatedDensity(potential_.lbound(0), blitz::Range::all(), k) +=
|
||||||
|
(density(fixedIndex, j, k-1) + density(fixedIndex, j, k))/2.;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef debug_level3
|
//might not work that way (if not needs a loop)
|
||||||
|
interpolatedDensity(fixedIndex, blitz::Range::all(), blitz::Range::all()) /=
|
||||||
|
potential_.extent(1);
|
||||||
|
|
||||||
DEBUG_LEVEL_3("Max Value in interpolated density array: " +
|
DEBUG_LEVEL_3("Max Value in interpolated density array: " +
|
||||||
std::to_string(blitz::max(interpolatedDensity)));
|
std::to_string(blitz::max(interpolatedDensity)));
|
||||||
#endif
|
|
||||||
//for r=r_max, k=k_min and k=k_max do not use an interpolation,
|
//for r=r_max, k=k_min and k=k_max do not use an interpolation,
|
||||||
//since no boundary cell needs the information about its density value
|
//since no boundary cell needs the information about its density value
|
||||||
return interpolatedDensity;
|
return interpolatedDensity;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VectorField> PoissonSolver::staticElectricField() {
|
std::shared_ptr<VectorField> PoissonSolver::staticElectricField() {
|
||||||
blitz::TinyVector<double, 2> stepsize = density_binning_.stepsize();
|
blitz::TinyVector<double, 3> stepsize = density_binning_.stepsize();
|
||||||
blitz::TinyVector<int,2> Eextent = potential_.extent() -
|
blitz::TinyVector<int,3> Eextent = potential_.extent() -
|
||||||
blitz::TinyVector<int,2>(1,1);
|
blitz::TinyVector<int,3>(1,0,1);
|
||||||
blitz::Array<double, 2> Er(potential_.lbound(), Eextent);
|
blitz::Array<double, 3> Er(potential_.lbound(), Eextent);
|
||||||
blitz::Array<double, 2> Ephi(potential_.lbound(), Eextent);
|
blitz::Array<double, 3> Ephi(potential_.lbound(), Eextent);
|
||||||
blitz::Array<double, 2> Ez(potential_.lbound(), Eextent);
|
blitz::Array<double, 3> Ez(potential_.lbound(), Eextent);
|
||||||
|
|
||||||
Ephi = 0.;
|
Ephi = 0.;
|
||||||
//do calculation of E from the potential and interpolation to
|
//do calculation of E from the potential and interpolation to
|
||||||
//cell center at the same time
|
//cell center at the same time
|
||||||
|
for(int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
||||||
|
int jp = (j+1 > potential_.ubound(1)) ? potential_.lbound(1) : j+1;
|
||||||
|
int jm = (j-1 < potential_.lbound(1)) ? potential_.ubound(1) : j-1;
|
||||||
|
for(int i = potential_.lbound(0); i < potential_.ubound(0); ++i) {
|
||||||
|
for(int k = potential_.lbound(2); k < potential_.ubound(2); ++k) {
|
||||||
|
Er(i,j,k) = -(potential_(i+1,j,k ).value -
|
||||||
|
potential_(i ,j,k ).value +
|
||||||
|
potential_(i+1,j,k+1).value -
|
||||||
|
potential_(i ,j,k+1).value)
|
||||||
|
/(2*stepsize(0));
|
||||||
|
|
||||||
for(int i = potential_.lbound(0); i < potential_.ubound(0); ++i) {
|
Ez(i,j,k) = -(potential_(i ,j,k+1).value -
|
||||||
for(int k = potential_.lbound(1); k < potential_.ubound(1); ++k) {
|
potential_(i ,j,k ).value +
|
||||||
Er(i,k) = -(potential_(i+1,k ).value -
|
potential_(i+1,j,k+1).value -
|
||||||
potential_(i ,k ).value +
|
potential_(i+1,j,k ).value)
|
||||||
potential_(i+1,k+1).value -
|
/(2*stepsize(2));
|
||||||
potential_(i ,k+1).value ) /(2*stepsize(0));
|
|
||||||
|
|
||||||
Ez(i,k) = -(potential_(i ,k+1).value -
|
if(i==potential_.lbound(0)) {
|
||||||
potential_(i ,k ).value +
|
Ephi(i,j,k) = -(
|
||||||
potential_(i+1,k+1).value -
|
potential_(i+1,jp,k ).value - potential_(i+1,jm,k ).value +
|
||||||
potential_(i+1,k ).value )/(2*stepsize(1));
|
potential_(i+1,jp,k+1).value - potential_(i+1,jm,k+1).value)
|
||||||
|
/((i+1)*stepsize(0)*stepsize(2))/4.;
|
||||||
|
} else {
|
||||||
|
Ephi(i,j,k) = -(
|
||||||
|
(potential_(i ,jp,k ).value - potential_(i ,jm,k ).value +
|
||||||
|
potential_(i ,jp,k+1).value - potential_(i ,jm,k+1).value)
|
||||||
|
/(i*stepsize(0)) +
|
||||||
|
(potential_(i+1,jp,k ).value - potential_(i+1,jm,k ).value +
|
||||||
|
potential_(i+1,jp,k+1).value - potential_(i+1,jm,k+1).value)
|
||||||
|
/((i+1)*stepsize(0)) )/(4.*stepsize(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::shared_ptr<VectorField>(
|
return std::shared_ptr<VectorField>(
|
||||||
new VectorFieldFromArray(Er, Ephi, Ez,
|
new VectorFieldFromArray(Er, Ephi, Ez,
|
||||||
Eextent(0)*stepsize(0), Eextent(1)*stepsize(1)));
|
Eextent(0)*stepsize(0), Eextent(2)*stepsize(2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
const CylinderBinning* PoissonSolver::densityBinning() {
|
const CylinderBinning* PoissonSolver::densityBinning() {
|
||||||
return &density_binning_;
|
return &density_binning_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PoissonSolver::setPotential(blitz::Array<double, 2>& potential) {
|
|
||||||
// check if the loaded potential has the same size as the potential
|
|
||||||
// specified by the json file
|
|
||||||
if(!blitz::all(potential.length() == potential_.length())) {
|
|
||||||
std::stringstream out;
|
|
||||||
out << "The size of the potential is " << potential.length();
|
|
||||||
out << ". But expected a size of " << potential_.length();
|
|
||||||
ERROR(out.str());
|
|
||||||
}
|
|
||||||
|
|
||||||
// necessary since it's not guaranteed (or even likely) that both arrays
|
|
||||||
// are indexed the same (i.e. potential_ is most likely starting from -1,
|
|
||||||
// while the parameter array is most likely starting from 0)
|
|
||||||
const int i_offset = potential.lbound(0) - potential_.lbound(0);
|
|
||||||
const int j_offset = potential.lbound(1) - potential_.lbound(1);
|
|
||||||
|
|
||||||
for(int i = potential_.lbound(0); i <= potential_.ubound(0); ++i) {
|
|
||||||
for(int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
|
||||||
potential_(i,j).value = potential(i + i_offset,j + j_offset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Electrode::Electrode(double potential): potential_(potential) {};
|
Electrode::Electrode(double potential): potential_(potential) {};
|
||||||
|
|
||||||
double Electrode::electrodePotential() {
|
double Electrode::electrodePotential() {
|
||||||
@@ -334,33 +375,3 @@ bool RearWall::isOnElectrode(const Coordinate& position) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
RingElectrode::RingElectrode(double potential, const double zPosition,
|
|
||||||
const double innerRadius,
|
|
||||||
const double outerRadius,
|
|
||||||
const blitz::TinyVector<double, 2> stepsize):
|
|
||||||
Electrode(potential),
|
|
||||||
specs_(blitz::TinyVector<double, 3>(innerRadius, outerRadius, zPosition)),
|
|
||||||
stepsize_(stepsize) {}
|
|
||||||
|
|
||||||
bool RingElectrode::isOnElectrode(const Coordinate& pos) {
|
|
||||||
blitz::TinyVector<double, 3> pos_cyl = pos.cylinderEntries();
|
|
||||||
|
|
||||||
bool zdir = std::abs(pos_cyl(2) - specs_(2)) <= stepsize_(1)/2;
|
|
||||||
zdir = (specs_(2) - pos_cyl(2) == stepsize_(1)/2) ? false : zdir;
|
|
||||||
|
|
||||||
bool rInner = (pos_cyl(0) >= specs_(0));
|
|
||||||
bool rOuter = (pos_cyl(0) < specs_(1));
|
|
||||||
|
|
||||||
#ifdef debug
|
|
||||||
std::stringstream out;
|
|
||||||
out << "Position " << pos_cyl << ": \n\t";
|
|
||||||
out << "z-dir: " << ((zdir) ? "true" : "false") << "\n\t";
|
|
||||||
out << "rinner-dir: " << ((rInner) ? "true" : "false") << "\n\t";
|
|
||||||
out << "router-dir: " << ((rOuter) ? "true" : "false") << "\n\t";
|
|
||||||
out << "total: " << ((zdir && rInner && rOuter) ? "true" : "false") << "\n\t";
|
|
||||||
DEBUG(out.str());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return zdir && rInner && rOuter;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -56,24 +56,10 @@ blitz::TinyVector<double, 3> CartesianCoordinate::cartesianEntries() const {
|
|||||||
return cartesian_position;
|
return cartesian_position;
|
||||||
}
|
}
|
||||||
|
|
||||||
double CartesianCoordinate::sinAzimuth() const {
|
|
||||||
double rad = std::sqrt(cartesian_position(0)*cartesian_position(0) +
|
|
||||||
cartesian_position(1)*cartesian_position(1));
|
|
||||||
return cartesian_position(1)/rad;
|
|
||||||
}
|
|
||||||
|
|
||||||
double CartesianCoordinate::cosAzimuth() const {
|
|
||||||
double rad = std::sqrt(cartesian_position(0)*cartesian_position(0) +
|
|
||||||
cartesian_position(1)*cartesian_position(1));
|
|
||||||
return cartesian_position(0)/rad;
|
|
||||||
}
|
|
||||||
|
|
||||||
blitz::TinyVector<double, 3> CartesianCoordinate::cylinderEntries() const {
|
blitz::TinyVector<double, 3> CartesianCoordinate::cylinderEntries() const {
|
||||||
// const double radius = std::sqrt(std::pow(cartesian_position(0), 2) +
|
const double radius = std::sqrt(std::pow(cartesian_position(0), 2) +
|
||||||
// std::pow(cartesian_position(1), 2));
|
std::pow(cartesian_position(1), 2));
|
||||||
const double radius = std::sqrt(cartesian_position(0)*cartesian_position(0) +
|
const double phi = std::atan2(cartesian_position(1), cartesian_position(0));
|
||||||
cartesian_position(1)*cartesian_position(1));
|
|
||||||
const double phi = 0.;//std::atan2(cartesian_position(1), cartesian_position(0));
|
|
||||||
const double z = cartesian_position(2);
|
const double z = cartesian_position(2);
|
||||||
return blitz::TinyVector<double, 3>(radius, phi, z);
|
return blitz::TinyVector<double, 3>(radius, phi, z);
|
||||||
}
|
}
|
||||||
@@ -89,9 +75,6 @@ void CartesianCoordinate::add(const Coordinate& coordinate) {
|
|||||||
CylinderCoordinate::CylinderCoordinate(
|
CylinderCoordinate::CylinderCoordinate(
|
||||||
const blitz::TinyVector<double, 3>& cylinder_position)
|
const blitz::TinyVector<double, 3>& cylinder_position)
|
||||||
: cylinder_position(cylinder_position) {
|
: cylinder_position(cylinder_position) {
|
||||||
#ifdef debug
|
|
||||||
phi_was_set = true;
|
|
||||||
#endif
|
|
||||||
// limitPhi();
|
// limitPhi();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,27 +83,7 @@ CylinderCoordinate::CylinderCoordinate(const Coordinate& coordinate)
|
|||||||
// limitPhi();
|
// limitPhi();
|
||||||
}
|
}
|
||||||
|
|
||||||
double CylinderCoordinate::cosAzimuth() const {
|
|
||||||
#ifdef debug
|
|
||||||
if(!phi_was_set)
|
|
||||||
fprintf(stdout, "CylinderCoordinate cos calc\n");
|
|
||||||
#endif
|
|
||||||
return std::cos(cylinder_position(1));
|
|
||||||
}
|
|
||||||
|
|
||||||
double CylinderCoordinate::sinAzimuth() const {
|
|
||||||
#ifdef debug
|
|
||||||
if(!phi_was_set)
|
|
||||||
fprintf(stdout, "CylinderCoordinate sin calc\n");
|
|
||||||
#endif
|
|
||||||
return std::sin(cylinder_position(1));
|
|
||||||
}
|
|
||||||
|
|
||||||
blitz::TinyVector<double, 3> CylinderCoordinate::cartesianEntries() const {
|
blitz::TinyVector<double, 3> CylinderCoordinate::cartesianEntries() const {
|
||||||
#ifdef debug
|
|
||||||
if(!phi_was_set)
|
|
||||||
fprintf(stdout, "Transformation form cylinder coordinate to cartesian!\n");
|
|
||||||
#endif
|
|
||||||
return blitz::TinyVector<double, 3>(
|
return blitz::TinyVector<double, 3>(
|
||||||
cylinder_position(0) * std::cos(cylinder_position(1)),
|
cylinder_position(0) * std::cos(cylinder_position(1)),
|
||||||
cylinder_position(0) * std::sin(cylinder_position(1)),
|
cylinder_position(0) * std::sin(cylinder_position(1)),
|
||||||
@@ -147,7 +110,7 @@ void CylinderCoordinate::add(const Coordinate& coordinate) {
|
|||||||
const CartesianCoordinate c_cart(new_cart_position);
|
const CartesianCoordinate c_cart(new_cart_position);
|
||||||
const CylinderCoordinate c_cyl(c_cart);
|
const CylinderCoordinate c_cyl(c_cart);
|
||||||
cylinder_position = c_cyl.cylinderEntries();
|
cylinder_position = c_cyl.cylinderEntries();
|
||||||
// limitPhi();
|
limitPhi();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -171,16 +134,12 @@ CylinderVector CylinderVector::operator+(const CylinderVector& vector) {
|
|||||||
|
|
||||||
blitz::TinyVector<double, 3> CylinderVector::cartesianEntries(
|
blitz::TinyVector<double, 3> CylinderVector::cartesianEntries(
|
||||||
const Coordinate& coordinate) const {
|
const Coordinate& coordinate) const {
|
||||||
// double phi = coordinate.cylinderEntries()(1);
|
|
||||||
double cosphi = coordinate.cosAzimuth();
|
|
||||||
double sinphi = coordinate.sinAzimuth();
|
|
||||||
|
|
||||||
const double A_x =
|
const double A_x =
|
||||||
cosphi * cylinder_vector(0) -
|
std::cos(coordinate.cylinderEntries()(1)) * cylinder_vector(0) -
|
||||||
sinphi * cylinder_vector(1);
|
std::sin(coordinate.cylinderEntries()(1)) * cylinder_vector(1);
|
||||||
const double A_y =
|
const double A_y =
|
||||||
sinphi * cylinder_vector(0) +
|
std::sin(coordinate.cylinderEntries()(1)) * cylinder_vector(0) +
|
||||||
cosphi * cylinder_vector(1);
|
std::cos(coordinate.cylinderEntries()(1)) * cylinder_vector(1);
|
||||||
const double A_z = cylinder_vector(2);
|
const double A_z = cylinder_vector(2);
|
||||||
return blitz::TinyVector<double, 3>(A_x, A_y, A_z);
|
return blitz::TinyVector<double, 3>(A_x, A_y, A_z);
|
||||||
}
|
}
|
||||||
@@ -194,7 +153,6 @@ blitz::TinyVector<double, 3> CylinderVector::cylinderEntries() const {
|
|||||||
return cylinder_vector;
|
return cylinder_vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
// think that function is wrong
|
|
||||||
void CylinderVector::add(const Vector& vector, const Coordinate& coordinate) {
|
void CylinderVector::add(const Vector& vector, const Coordinate& coordinate) {
|
||||||
cylinder_vector += vector.cylinderEntries(coordinate);
|
cylinder_vector += vector.cylinderEntries(coordinate);
|
||||||
}
|
}
|
||||||
@@ -225,7 +183,6 @@ blitz::TinyVector<double, 3> CartesianVector::cartesianEntries() const {
|
|||||||
|
|
||||||
blitz::TinyVector<double, 3> CartesianVector::cylinderEntries(
|
blitz::TinyVector<double, 3> CartesianVector::cylinderEntries(
|
||||||
const Coordinate& coordinate) const {
|
const Coordinate& coordinate) const {
|
||||||
fprintf(stdout, "Transformation Cartesian Vector to Cylinder vector\n");
|
|
||||||
const blitz::TinyVector<double, 3> cylinder_vector =
|
const blitz::TinyVector<double, 3> cylinder_vector =
|
||||||
coordinate.cylinderEntries();
|
coordinate.cylinderEntries();
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user