Compare commits
19
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2518e9bbc6 | ||
|
|
2b850c6be9 | ||
|
|
31d56a4054 | ||
|
|
4dc92fc6e7 | ||
|
|
324da20d4a | ||
|
|
32f4703f4e | ||
|
|
364191d92f | ||
|
|
ca78062738 | ||
|
|
c9a8b511f9 | ||
|
|
0a843f0a4c | ||
|
|
32521298d4 | ||
|
|
26b5820a15 | ||
|
|
41ffe0b96f | ||
|
|
68d1d88962 | ||
|
|
09dfddb6da | ||
|
|
5d72083a25 | ||
|
|
af2ea430f4 | ||
|
|
753ff2c09a | ||
|
|
5cb560e727 |
+61
-4
@@ -7,6 +7,7 @@ import argparse
|
|||||||
import glob
|
import glob
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
|
import plot_standards as pst
|
||||||
|
|
||||||
def get_time_and_total_charge_(files, considered_keys=['All'], exclude_underflow=False):
|
def get_time_and_total_charge_(files, considered_keys=['All'], exclude_underflow=False):
|
||||||
times = []
|
times = []
|
||||||
@@ -52,6 +53,46 @@ def get_time_and_total_charge_(files, considered_keys=['All'], exclude_underflow
|
|||||||
|
|
||||||
return times, total_charges
|
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) :
|
def getFiles(dir:str, base_name:str, pattern:str) :
|
||||||
if dir[-1] == '/':
|
if dir[-1] == '/':
|
||||||
pathname = dir + base_name
|
pathname = dir + base_name
|
||||||
@@ -64,7 +105,10 @@ if __name__ == '__main__':
|
|||||||
parser = argparse.ArgumentParser(description="Program to create a plot of the charge against time from the output of KARL")
|
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("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("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("--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.')
|
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()
|
args = parser.parse_args()
|
||||||
|
|
||||||
@@ -74,9 +118,16 @@ if __name__ == '__main__':
|
|||||||
print(files)
|
print(files)
|
||||||
|
|
||||||
if(files == []):
|
if(files == []):
|
||||||
print(f"No files found in {args.dir}, which match '{args.basename}[0-9]*\\.h5'")
|
print(f"No files found in {args.dir}, which match '{args.basename}{args.pattern}\\.h5'")
|
||||||
exit(1)
|
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)
|
times, charges = get_time_and_total_charge_(files, args.species)
|
||||||
|
|
||||||
legstr = ''
|
legstr = ''
|
||||||
@@ -85,9 +136,12 @@ if __name__ == '__main__':
|
|||||||
legstr = legstr[:-3]
|
legstr = legstr[:-3]
|
||||||
|
|
||||||
|
|
||||||
plt.rcParams.update({'font.size': 14})
|
plt.rcParams.update({'font.size': 10})
|
||||||
fig = plt.figure(figsize=(10,6))
|
fig = plt.figure(figsize=pst.set_size(args.width))
|
||||||
plt.plot(times, charges, marker = 'x', label = legstr)
|
plt.plot(times, charges, marker = 'x', label = legstr)
|
||||||
|
if args.losses:
|
||||||
|
plt.ylabel('loss rate (1/s)')
|
||||||
|
else:
|
||||||
plt.ylabel('charge (C)')
|
plt.ylabel('charge (C)')
|
||||||
plt.xlabel('time (s)')
|
plt.xlabel('time (s)')
|
||||||
plt.legend()
|
plt.legend()
|
||||||
@@ -102,11 +156,14 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
os.makedirs(outname, exist_ok=True)
|
os.makedirs(outname, exist_ok=True)
|
||||||
|
|
||||||
|
if args.losses:
|
||||||
|
outname += args.basename + "_wallLossRateAgainstTime_species-"
|
||||||
|
else:
|
||||||
outname += args.basename + "_chargeAgainstTime_species-"
|
outname += args.basename + "_chargeAgainstTime_species-"
|
||||||
|
|
||||||
for value in args.species:
|
for value in args.species:
|
||||||
outname += value
|
outname += value
|
||||||
outname += '.pdf'
|
outname += '_test.pdf'
|
||||||
|
|
||||||
# print(outname)
|
# print(outname)
|
||||||
plt.savefig(outname, format='pdf', bbox_inches = 'tight')
|
plt.savefig(outname, format='pdf', bbox_inches = 'tight')
|
||||||
|
|||||||
Binary file not shown.
@@ -52,6 +52,11 @@ class SimulationOutput {
|
|||||||
std::vector<particle::SerializedParticle>& storage_queue,
|
std::vector<particle::SerializedParticle>& storage_queue,
|
||||||
int injectionGroupOffset);
|
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_;
|
||||||
|
|||||||
@@ -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, 3> readComponentFromFile(json_t* object, int component);
|
blitz::Array<double, 2> readComponentFromFile(json_t* object, int component);
|
||||||
blitz::Array<double, 3> readFromFile(json_t* object);
|
blitz::Array<double, 2> readFromFile(json_t* object);
|
||||||
} // namespace generator
|
} // namespace generator
|
||||||
|
|
||||||
#endif /* VECTOR_FIELD_GENERATOR_H */
|
#endif /* VECTOR_FIELD_GENERATOR_H */
|
||||||
|
|||||||
@@ -10,21 +10,20 @@ class Specie;
|
|||||||
|
|
||||||
namespace interaction {
|
namespace interaction {
|
||||||
|
|
||||||
// class for (radiative) cluster formation interactions (A + B --> AB) 7
|
// class for (radiative) cluster formation interactions (A + B --> AB)
|
||||||
// or (A + BC --> AB + C)
|
|
||||||
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);
|
||||||
InteractionOutput performInteraction(particle::Particle& particle,
|
virtual InteractionOutput performInteraction(particle::Particle& particle,
|
||||||
RandomNumbers* generator);
|
RandomNumbers* generator);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::shared_ptr<species::TrackedSpecie> product_;
|
std::shared_ptr<species::TrackedSpecie> product_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// class for tertiary association (A + B + B --> AB + B)
|
// class for tertiary association (A + B + B --> AB + B or A + B2 -> AB + B)
|
||||||
class ClusterFormationTertiary : public ClusterFormation {
|
class ClusterFormationTertiary : public ClusterFormation {
|
||||||
public:
|
public:
|
||||||
// Constructor: takes the function describing the cross section (dependent on the energy of the incident particle)
|
// Constructor: takes the function describing the cross section (dependent on the energy of the incident particle)
|
||||||
@@ -32,12 +31,21 @@ class ClusterFormationTertiary : public ClusterFormation {
|
|||||||
// and a shared_ptr to the TrackedSpecie that is the product of the interaction
|
// and a shared_ptr to the TrackedSpecie that is the product of the interaction
|
||||||
ClusterFormationTertiary(std::function<double(double)> cross_section,
|
ClusterFormationTertiary(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,
|
||||||
|
bool rate_coefficient = true);
|
||||||
|
|
||||||
// due to only the rate coefficients being available the cross section is
|
// due to only the rate coefficients being available the cross section is
|
||||||
// approximated as sigma = rate_coefficient * density / velocity
|
// approximated as sigma = rate_coefficient * density / velocity
|
||||||
// (units of the tertiary rate coefficient m^6/s)
|
// (units of the tertiary rate coefficient m^6/s)
|
||||||
double microscopicCrossSection(double energy_eV, const Coordinate& position);
|
double microscopicCrossSection(double energy_eV, const Coordinate& position);
|
||||||
|
|
||||||
|
InteractionOutput performInteraction(particle::Particle& particle,
|
||||||
|
RandomNumbers* generator);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// flag whether the "cross_section_" function is in truth calculated using a
|
||||||
|
// three body association rate
|
||||||
|
bool rate_coefficient_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,14 +13,29 @@ 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);
|
||||||
|
|
||||||
InteractionOutput performInteraction(particle::Particle& particle,
|
virtual InteractionOutput performInteraction(particle::Particle& particle,
|
||||||
RandomNumbers* generator);
|
RandomNumbers* generator);
|
||||||
virtual double drawCollisionTime(particle::Particle& particle,
|
virtual double drawCollisionTime(particle::Particle& particle,
|
||||||
RandomNumbers* generator);
|
RandomNumbers* generator);
|
||||||
private:
|
protected:
|
||||||
std::shared_ptr<ScatteringAngleDistribution> theta_distrib_;
|
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,
|
||||||
|
RandomNumbers* generator);
|
||||||
|
protected:
|
||||||
|
std::shared_ptr<species::TrackedSpecie> product_;
|
||||||
|
};
|
||||||
|
|
||||||
}; // namespace interaction
|
}; // namespace interaction
|
||||||
|
|
||||||
#endif /* ELASTIC_SCATTERING_H */
|
#endif /* ELASTIC_SCATTERING_H */
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ 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);
|
||||||
@@ -48,6 +49,7 @@ 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_;
|
||||||
|
|||||||
@@ -29,11 +29,14 @@ 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;
|
||||||
double electrodePotential();
|
virtual double electrodePotential();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const double potential_;
|
const double potential_;
|
||||||
@@ -45,6 +48,21 @@ 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,
|
||||||
@@ -57,12 +75,12 @@ class PoissonSolver {
|
|||||||
int num_cycles,
|
int num_cycles,
|
||||||
bool do_solver);
|
bool do_solver);
|
||||||
|
|
||||||
void solvePotential(const blitz::Array<double, 3> charge_density);
|
void solvePotential(const blitz::Array<double, 2> charge_density);
|
||||||
blitz::Array<double, 3> potential();
|
blitz::Array<double, 2> potential();
|
||||||
std::shared_ptr<VectorField> staticElectricField();
|
std::shared_ptr<VectorField> staticElectricField();
|
||||||
const CylinderBinning* densityBinning();
|
const CylinderBinning* densityBinning();
|
||||||
|
|
||||||
void setPotential(blitz::Array<double, 3>& potential);
|
void setPotential(blitz::Array<double, 2>& potential);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GlobalBoundary bottom_boundary_;
|
GlobalBoundary bottom_boundary_;
|
||||||
@@ -78,13 +96,13 @@ class PoissonSolver {
|
|||||||
// 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, 3> potential_; //unit V
|
blitz::Array<PotentialGridPoint, 2> potential_; //unit V
|
||||||
|
|
||||||
blitz::Array<double, 3> interpolateDensityToPotentialGrid(
|
blitz::Array<double, 2> interpolateDensityToPotentialGrid(
|
||||||
const blitz::Array<double, 3> charge_density);
|
const blitz::Array<double, 2> charge_density);
|
||||||
|
|
||||||
void solverIteration(const blitz::Array<double, 3>& interpolated_density);
|
void solverIteration(const blitz::Array<double, 2>& interpolated_density);
|
||||||
bool converged(const blitz::Array<double, 3>& interpolated_density);
|
bool converged(const blitz::Array<double, 2>& interpolated_density);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Electrodes can only be dirichlet boundary conditions
|
// Electrodes can only be dirichlet boundary conditions
|
||||||
|
|||||||
@@ -66,6 +66,9 @@ class CylinderCoordinate : public 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 {
|
||||||
|
|||||||
@@ -32,8 +32,6 @@ class CpuSynchronizer {
|
|||||||
/*
|
/*
|
||||||
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,
|
||||||
@@ -45,9 +43,11 @@ class CpuSynchronizer {
|
|||||||
|
|
||||||
// array has to be the delta of the timestep
|
// array has to be the delta of the timestep
|
||||||
void sumToAll(blitz::Array<double, 5>& array);
|
void sumToAll(blitz::Array<double, 5>& array);
|
||||||
|
void sumToAll(blitz::Array<double, 4>& array);
|
||||||
|
|
||||||
// collect data to rank 0 functions
|
// collect data to rank 0 functions
|
||||||
void sumToRoot(blitz::Array<double, 3>& array);
|
void sumToRoot(blitz::Array<double, 3>& array);
|
||||||
|
void sumToRoot(blitz::Array<double, 2>& array);
|
||||||
void sumToRoot(long int& value);
|
void sumToRoot(long int& value);
|
||||||
void sumToRoot(double& value);
|
void sumToRoot(double& value);
|
||||||
|
|
||||||
|
|||||||
@@ -14,20 +14,28 @@ class CurrentCollector {
|
|||||||
|
|
||||||
void collect(particle::Particle* particle, const Coordinate& old_position);
|
void collect(particle::Particle* particle, const Coordinate& old_position);
|
||||||
|
|
||||||
blitz::Array<double, 3> negativeCrossingsInR() const;
|
blitz::Array<double, 2> negativeCrossingsInR() const;
|
||||||
blitz::Array<double, 3> positiveCrossingsInR() const;
|
blitz::Array<double, 2> positiveCrossingsInR() const;
|
||||||
blitz::Array<double, 3> areaInR() const;
|
blitz::Array<double, 2> areaInR() const;
|
||||||
blitz::Array<double, 3> currentInR() const;
|
blitz::Array<double, 2> currentInR() const;
|
||||||
|
|
||||||
blitz::Array<double, 3> negativeCrossingsInPhi() const;
|
blitz::Array<double, 2> negativeCrossingsInPhi() const;
|
||||||
blitz::Array<double, 3> positiveCrossingsInPhi() const;
|
blitz::Array<double, 2> positiveCrossingsInPhi() const;
|
||||||
blitz::Array<double, 3> areaInPhi() const;
|
blitz::Array<double, 2> areaInPhi() const;
|
||||||
blitz::Array<double, 3> currentInPhi() const;
|
blitz::Array<double, 2> currentInPhi() const;
|
||||||
|
|
||||||
blitz::Array<double, 3> negativeCrossingsInZ() const;
|
blitz::Array<double, 2> negativeCrossingsInZ() const;
|
||||||
blitz::Array<double, 3> positiveCrossingsInZ() const;
|
blitz::Array<double, 2> positiveCrossingsInZ() const;
|
||||||
blitz::Array<double, 3> areaInZ() const;
|
blitz::Array<double, 2> areaInZ() const;
|
||||||
blitz::Array<double, 3> currentInZ() const;
|
blitz::Array<double, 2> 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;
|
||||||
|
|
||||||
@@ -36,52 +44,55 @@ class CurrentCollector {
|
|||||||
friend class CpuSynchronizer;
|
friend class CpuSynchronizer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void collectRadialMovement(const blitz::TinyVector<int, 3>& bin_old,
|
void collectRadialMovement(const blitz::TinyVector<int, 2>& bin_old,
|
||||||
const blitz::TinyVector<int, 3>& bin_new,
|
const blitz::TinyVector<int, 2>& bin_new,
|
||||||
const double weight);
|
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,
|
||||||
|
#ifdef GENRICHCURRENT
|
||||||
|
const double energy_eV,
|
||||||
|
#endif
|
||||||
const double weight);
|
const double weight);
|
||||||
void collectAzimuthalMovement(const blitz::TinyVector<int, 3>& bin_old,
|
void collectAzimuthalMovement(const blitz::TinyVector<double, 3>& old_pos_cart,
|
||||||
const blitz::TinyVector<int, 3>& bin_new,
|
const blitz::TinyVector<double, 3>& new_pos_cart,
|
||||||
|
const blitz::TinyVector<int,2>& bin_old,
|
||||||
const double weight);
|
const double weight);
|
||||||
|
|
||||||
blitz::Array<double, 3> createAreaLongitudinal(
|
blitz::Array<double, 2> createAreaLongitudinal(
|
||||||
const CylinderBinning& position_binning);
|
const CylinderBinning& position_binning);
|
||||||
blitz::Array<double, 3> createCrossingsLongitudinal(
|
blitz::Array<double, 2> createCrossingsLongitudinal(
|
||||||
const CylinderBinning& position_binning);
|
const CylinderBinning& position_binning);
|
||||||
|
|
||||||
blitz::Array<double, 3> createAreaRadial(
|
blitz::Array<double, 2> createAreaRadial(
|
||||||
const CylinderBinning& position_binning);
|
const CylinderBinning& position_binning);
|
||||||
blitz::Array<double, 3> createCrossingsRadial(
|
blitz::Array<double, 2> createCrossingsRadial(
|
||||||
const CylinderBinning& position_binning);
|
const CylinderBinning& position_binning);
|
||||||
|
|
||||||
blitz::Array<double, 3> createAreaAzimuthal(
|
blitz::Array<double, 2> createAreaAzimuthal(
|
||||||
const CylinderBinning& position_binning);
|
const CylinderBinning& position_binning);
|
||||||
blitz::Array<double, 3> createCrossingsAzimuthal(
|
blitz::Array<double, 2> createCrossingsAzimuthal(
|
||||||
const CylinderBinning& position_binning);
|
const CylinderBinning& position_binning);
|
||||||
|
|
||||||
blitz::Array<double, 3> z_negative_crossings;
|
blitz::Array<double, 2> z_negative_crossings;
|
||||||
blitz::Array<double, 3> z_positive_crossings;
|
blitz::Array<double, 2> z_positive_crossings;
|
||||||
|
|
||||||
blitz::Array<double, 3> phi_negative_crossings;
|
blitz::Array<double, 2> phi_negative_crossings;
|
||||||
blitz::Array<double, 3> phi_positive_crossings;
|
blitz::Array<double, 2> phi_positive_crossings;
|
||||||
|
|
||||||
blitz::Array<double, 3> r_negative_crossings;
|
blitz::Array<double, 2> r_negative_crossings;
|
||||||
blitz::Array<double, 3> r_positive_crossings;
|
blitz::Array<double, 2> r_positive_crossings;
|
||||||
|
|
||||||
// blitz::Array<double, 3> sync_z_negative_crossings;
|
blitz::Array<double, 2> collector_areas_r;
|
||||||
// blitz::Array<double, 3> sync_z_positive_crossings;
|
blitz::Array<double, 2> collector_areas_phi;
|
||||||
|
blitz::Array<double, 2> collector_areas_z;
|
||||||
|
|
||||||
// blitz::Array<double, 3> sync_phi_negative_crossings;
|
#ifdef GENRICHCURRENT
|
||||||
// blitz::Array<double, 3> sync_phi_positive_crossings;
|
blitz::Array<double, 2> sample_z_negative_crossings;
|
||||||
|
EnergyBinning energy_binning_;
|
||||||
|
|
||||||
// blitz::Array<double, 3> sync_r_negative_crossings;
|
bool needs_reset = false;
|
||||||
// blitz::Array<double, 3> sync_r_positive_crossings;
|
double time_since_reset = 0;
|
||||||
|
#endif //GENRICHCURRENT
|
||||||
blitz::Array<double, 3> collector_areas_r;
|
|
||||||
blitz::Array<double, 3> collector_areas_phi;
|
|
||||||
blitz::Array<double, 3> collector_areas_z;
|
|
||||||
|
|
||||||
CylinderBinning position_binning_;
|
CylinderBinning position_binning_;
|
||||||
std::shared_ptr<Timer> timer_;
|
std::shared_ptr<Timer> timer_;
|
||||||
|
|||||||
@@ -46,10 +46,10 @@ class DynamicDensityField : public DensityField {
|
|||||||
// of the pitch angle binning
|
// of the pitch angle binning
|
||||||
bool changedPitchAngleBin(double old_pitch_angle, double new_pitch_angle) const;
|
bool changedPitchAngleBin(double old_pitch_angle, double new_pitch_angle) const;
|
||||||
|
|
||||||
blitz::Array<double, 3> densityArray();
|
blitz::Array<double, 2> densityArray();
|
||||||
blitz::Array<double, 4> spectrumArray();
|
blitz::Array<double, 3> spectrumArray();
|
||||||
blitz::Array<double, 5> timeInBinArray() const;
|
blitz::Array<double, 4> numberInBinArray() const;
|
||||||
blitz::Array<double, 3> binVolumeArray() const;
|
blitz::Array<double, 2> binVolumeArray() const;
|
||||||
|
|
||||||
// return an array of the density values at the Coordinate position (only energy
|
// return an array of the density values at the Coordinate position (only energy
|
||||||
// direction left); over and underflow bin are removed
|
// direction left); over and underflow bin are removed
|
||||||
@@ -58,7 +58,7 @@ class DynamicDensityField : public DensityField {
|
|||||||
|
|
||||||
// return an array of the time in bin at the Coordinate position and the energy
|
// 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
|
// energy_eV (only pitch angle direction left); over and underflow bin are removed
|
||||||
blitz::Array<double, 1> sliceTimeInBinArray(const Coordinate& position,
|
blitz::Array<double, 1> sliceNumberInBinArray(const Coordinate& position,
|
||||||
double energy_eV) const;
|
double energy_eV) const;
|
||||||
|
|
||||||
const EnergyBinning* energyBinning() const;
|
const EnergyBinning* energyBinning() const;
|
||||||
@@ -73,21 +73,19 @@ class DynamicDensityField : public DensityField {
|
|||||||
friend class CpuSynchronizer;
|
friend class CpuSynchronizer;
|
||||||
|
|
||||||
void restartTimer(double time, double delta_t);
|
void restartTimer(double time, double delta_t);
|
||||||
void restartTimeInBin(blitz::Array<double, 5> time_in_bin);
|
void restartNumberInBin(blitz::Array<double, 4> number_in_bin);
|
||||||
|
|
||||||
void recalculateDensityArray();
|
void recalculateDensityArray();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// use ordering r, phi, z, pitch_angle, E
|
// use ordering r, z, pitch_angle, E.
|
||||||
// time in bin now contains the physical particle number per bin
|
// Full symmetry in azimuthal direction -> no phi resolution
|
||||||
// (not renamed, since that would require many, many changes due to
|
blitz::Array<double, 4> number_in_bin_;
|
||||||
// renaming of the functions)
|
blitz::Array<double, 4> sync_number_in_bin_;
|
||||||
blitz::Array<double, 5> time_in_bin_s_;
|
|
||||||
blitz::Array<double, 5> sync_time_in_bin_s_;
|
|
||||||
|
|
||||||
blitz::Array<double, 4> density_per_m3_;
|
blitz::Array<double, 3> density_per_m3_;
|
||||||
blitz::Array<double, 3> bin_volume_m3_;
|
blitz::Array<double, 2> bin_volume_m3_;
|
||||||
|
|
||||||
const CylinderBinning position_binning_;
|
const CylinderBinning position_binning_;
|
||||||
const EnergyBinning energy_binning_;
|
const EnergyBinning energy_binning_;
|
||||||
|
|||||||
@@ -20,6 +20,17 @@ 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);
|
||||||
|
|||||||
@@ -4,14 +4,15 @@
|
|||||||
#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!
|
change the mfp_m variable to a time_s variable!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class Mover {
|
class Mover {
|
||||||
public:
|
public:
|
||||||
virtual void move(particle::Particle* particle,
|
// return the last position, with which the particle has been checked to be alive with
|
||||||
|
virtual CylinderCoordinate move(particle::Particle* particle,
|
||||||
double collision_time_s,
|
double collision_time_s,
|
||||||
ElectricField* electric_field,
|
ElectricField* electric_field,
|
||||||
MagneticField* magnetic_field,
|
MagneticField* magnetic_field,
|
||||||
@@ -22,7 +23,7 @@ class BorisMover : public Mover {
|
|||||||
public:
|
public:
|
||||||
BorisMover(double maximal_time_step_s);
|
BorisMover(double maximal_time_step_s);
|
||||||
|
|
||||||
void move(particle::Particle* particle,
|
CylinderCoordinate move(particle::Particle* particle,
|
||||||
double collision_time_s,
|
double collision_time_s,
|
||||||
ElectricField* electric_field,
|
ElectricField* electric_field,
|
||||||
MagneticField* magnetic_field,
|
MagneticField* magnetic_field,
|
||||||
@@ -43,7 +44,7 @@ class DriftMover : public Mover {
|
|||||||
public:
|
public:
|
||||||
DriftMover(double maximal_distance);
|
DriftMover(double maximal_distance);
|
||||||
|
|
||||||
void move(particle::Particle* particle,
|
CylinderCoordinate move(particle::Particle* particle,
|
||||||
double collision_time_s,
|
double collision_time_s,
|
||||||
ElectricField* electric_field,
|
ElectricField* electric_field,
|
||||||
MagneticField* magnetic_field,
|
MagneticField* magnetic_field,
|
||||||
|
|||||||
@@ -103,6 +103,12 @@ class Particle {
|
|||||||
void deposited(bool truthValue=true);
|
void deposited(bool truthValue=true);
|
||||||
bool wasDeposited();
|
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!
|
// note: particle id is not being stored!
|
||||||
particle::SerializedParticle serialize();
|
particle::SerializedParticle serialize();
|
||||||
|
|
||||||
@@ -113,11 +119,15 @@ class Particle {
|
|||||||
CartesianCoordinate position_cart_;
|
CartesianCoordinate position_cart_;
|
||||||
CylinderCoordinate position_cyl_;
|
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 deposited_ = false;
|
||||||
|
bool set_local_fields_ = false;
|
||||||
// index of the interaction with the sortest distance (-1 if that's none of them)
|
// index of the interaction with the sortest distance (-1 if that's none of them)
|
||||||
int index_next_interaction_ = -1;
|
int index_next_interaction_ = -1;
|
||||||
double time_until_collision_;
|
double time_until_collision_;
|
||||||
|
|||||||
@@ -60,21 +60,19 @@ 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, 3> bin(
|
blitz::TinyVector<int, 2> bin(
|
||||||
const blitz::TinyVector<double, 3>& cylinder_position) const;
|
const blitz::TinyVector<double, 3>& cylinder_position) const;
|
||||||
blitz::TinyVector<double, 3> stepsize() const;
|
blitz::TinyVector<double, 2> stepsize() const;
|
||||||
|
|
||||||
blitz::TinyVector<int, 3> numBins() const;
|
blitz::TinyVector<int, 2> numBins() const;
|
||||||
blitz::TinyVector<int, 3> numBinsIncludingOverUnderflow() const;
|
blitz::TinyVector<int, 2> numBinsIncludingOverUnderflow() const;
|
||||||
blitz::TinyVector<int, 3> binIndexMin() const;
|
blitz::TinyVector<int, 2> binIndexMin() const;
|
||||||
blitz::TinyVector<int, 3> binIndexMax() const;
|
blitz::TinyVector<int, 2> binIndexMax() const;
|
||||||
|
|
||||||
const LowerBoundBinningWithOverflow radial_binning;
|
const LowerBoundBinningWithOverflow radial_binning;
|
||||||
const LowerAndUpperBoundBinning azimuth_binning;
|
|
||||||
const BinningWithOverAndUnderflow longitudinal_binning;
|
const BinningWithOverAndUnderflow longitudinal_binning;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,16 @@ 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;
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class Simulation {
|
|||||||
RandomNumbers* random,
|
RandomNumbers* random,
|
||||||
std::vector<double>& macroscopic_cross_sections_m);
|
std::vector<double>& macroscopic_cross_sections_m);
|
||||||
|
|
||||||
blitz::Array<double,3> chargedensity();
|
blitz::Array<double,2> chargedensity();
|
||||||
|
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>
|
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>
|
||||||
tracked_species_;
|
tracked_species_;
|
||||||
|
|||||||
@@ -5,22 +5,45 @@
|
|||||||
|
|
||||||
class Geometry;
|
class Geometry;
|
||||||
class DynamicDensityField;
|
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();
|
||||||
|
|
||||||
bool isAlive(const particle::Particle* particle) const;
|
virtual bool isAlive(const particle::Particle* particle) const;
|
||||||
bool leftSimulationDomain(const particle::Particle* particle) const;
|
virtual bool isAlive(const particle::Particle* particle,
|
||||||
bool reachedMaxInteractions(const particle::Particle* particle) const;
|
const Coordinate& old_pos) const;
|
||||||
bool reachedMaxTimeAlive(const particle::Particle* particle) const;
|
virtual bool leftSimulationDomain(const particle::Particle* particle) const;
|
||||||
double maxTimeAlive() const;
|
virtual bool leftSimulationDomain(const particle::Particle* particle,
|
||||||
|
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;
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
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 */
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#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, 3>& radial_component,
|
VectorFieldFromArray(const blitz::Array<double, 2>& radial_component,
|
||||||
const blitz::Array<double, 3>& azimuthal_component,
|
const blitz::Array<double, 2>& azimuthal_component,
|
||||||
const blitz::Array<double, 3>& longitudial_component,
|
const blitz::Array<double, 2>& 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, 3> Fr_;
|
const blitz::Array<double, 2> Fr_;
|
||||||
const blitz::Array<double, 3> Fphi_;
|
const blitz::Array<double, 2> Fphi_;
|
||||||
const blitz::Array<double, 3> Fz_;
|
const blitz::Array<double, 2> Fz_;
|
||||||
|
|
||||||
CylinderBinning binning_;
|
CylinderBinning binning_;
|
||||||
CylinderVector value(const blitz::TinyVector<int, 3>& bin) const;
|
CylinderVector value(const blitz::TinyVector<int, 2>& bin) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class VectorFieldConstant : public VectorField {
|
class VectorFieldConstant : public VectorField {
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ 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)
|
||||||
@@ -55,6 +57,10 @@ ifeq ($(DO_DEBUGGING),true)
|
|||||||
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)
|
||||||
|
|
||||||
|
|||||||
Executable
+1049
File diff suppressed because it is too large
Load Diff
+3
-3
@@ -139,8 +139,8 @@ void Restart::restartDrawingDensityField(DynamicDensityField* field, std::string
|
|||||||
#ifdef debug_level3
|
#ifdef debug_level3
|
||||||
DEBUG_LEVEL_3(path_to_data);
|
DEBUG_LEVEL_3(path_to_data);
|
||||||
#endif
|
#endif
|
||||||
blitz::Array<double, 5> time_in_bin = reader_.readD5Double(path_to_data);
|
blitz::Array<double, 4> number_in_bin = reader_.readD4Double(path_to_data);
|
||||||
field->restartTimeInBin(time_in_bin);
|
field->restartNumberInBin(number_in_bin);
|
||||||
field->recalculateDensityArray();
|
field->recalculateDensityArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ void Restart::restartPoissonSolver(PoissonSolver* solver) {
|
|||||||
#ifdef debug_level3
|
#ifdef debug_level3
|
||||||
DEBUG_LEVEL_3(path);
|
DEBUG_LEVEL_3(path);
|
||||||
#endif
|
#endif
|
||||||
blitz::Array<double, 3> potential = reader_.readD3Double(path);
|
blitz::Array<double, 2> potential = reader_.readD2Double(path);
|
||||||
solver->setPotential(potential);
|
solver->setPotential(potential);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,6 @@ void SimulationOutput::writeSimulationData(
|
|||||||
std::vector<particle::SerializedParticle>& storage_queue,
|
std::vector<particle::SerializedParticle>& storage_queue,
|
||||||
int injectionGroupOffset) {
|
int injectionGroupOffset) {
|
||||||
if (MpiCommunication::mpi_rank == 0) {
|
if (MpiCommunication::mpi_rank == 0) {
|
||||||
|
|
||||||
#ifdef debug_level2
|
#ifdef debug_level2
|
||||||
DEBUG_LEVEL_2("Write density field data.");
|
DEBUG_LEVEL_2("Write density field data.");
|
||||||
#endif
|
#endif
|
||||||
@@ -294,6 +293,11 @@ 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,
|
||||||
@@ -306,6 +310,10 @@ 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,
|
||||||
@@ -322,7 +330,7 @@ void SimulationOutput::writeDensity(DynamicDensityField* density_field,
|
|||||||
|
|
||||||
void SimulationOutput::writeTimeInBin(DynamicDensityField* density_field,
|
void SimulationOutput::writeTimeInBin(DynamicDensityField* density_field,
|
||||||
std::string path) {
|
std::string path) {
|
||||||
writer.write(density_field->timeInBinArray(), path + "/TimeInBin");
|
writer.write(density_field->numberInBinArray(), path + "/TimeInBin");
|
||||||
}
|
}
|
||||||
|
|
||||||
// void SimulationOutput::writeDeletedParticles(DynamicDensityField* density_field,
|
// void SimulationOutput::writeDeletedParticles(DynamicDensityField* density_field,
|
||||||
@@ -385,10 +393,6 @@ void SimulationOutput::writeMetaData(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");
|
||||||
@@ -397,12 +401,11 @@ void SimulationOutput::writeMetaData(DynamicDensityField* density_field,
|
|||||||
// write num bins
|
// write num bins
|
||||||
{
|
{
|
||||||
std::string path_to_num_bins = path_to_field + "/NumBins";
|
std::string path_to_num_bins = path_to_field + "/NumBins";
|
||||||
blitz::TinyVector<int, 4> num_bins = density_field->spectrumArray().extent();
|
blitz::TinyVector<int, 3> num_bins = density_field->spectrumArray().extent();
|
||||||
|
|
||||||
writer.write(num_bins(0), path_to_num_bins + "/energy");
|
writer.write(num_bins(0), path_to_num_bins + "/radial");
|
||||||
writer.write(num_bins(1), path_to_num_bins + "/radial");
|
writer.write(num_bins(1), path_to_num_bins + "/longitudinal");
|
||||||
writer.write(num_bins(2), path_to_num_bins + "/azimuthal");
|
writer.write(num_bins(2), path_to_num_bins + "/energy");
|
||||||
writer.write(num_bins(3), path_to_num_bins + "/longitudinal");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -423,10 +426,6 @@ 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");
|
||||||
@@ -437,6 +436,10 @@ 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,
|
||||||
@@ -448,12 +451,11 @@ 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, 4> num_bins = density_field->spectrumArray().extent();
|
blitz::TinyVector<int, 3> num_bins = density_field->spectrumArray().extent();
|
||||||
|
|
||||||
writer.write(num_bins(0), path_to_num_bins + "/energy");
|
writer.write(num_bins(0), path_to_num_bins + "/radial");
|
||||||
writer.write(num_bins(1), path_to_num_bins + "/radial");
|
writer.write(num_bins(1), path_to_num_bins + "/longitudinal");
|
||||||
writer.write(num_bins(2), path_to_num_bins + "/azimuthal");
|
writer.write(num_bins(2), path_to_num_bins + "/energy");
|
||||||
writer.write(num_bins(3), path_to_num_bins + "/longitudinal");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulationOutput::writeBinBorders(DynamicDensityField* density_field,
|
void SimulationOutput::writeBinBorders(DynamicDensityField* density_field,
|
||||||
@@ -468,10 +470,6 @@ 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");
|
||||||
@@ -483,3 +481,14 @@ void SimulationOutput::writeParticles(
|
|||||||
double dt) {
|
double dt) {
|
||||||
particle_writer.output_particles(particles, cpu_sync, 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
|
||||||
@@ -23,12 +23,6 @@ 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"}));
|
||||||
@@ -41,8 +35,6 @@ CylinderBinning buildPositionBinning(json_t* object) {
|
|||||||
#ifdef debug_level3
|
#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");
|
||||||
@@ -50,11 +42,10 @@ CylinderBinning buildPositionBinning(json_t* object) {
|
|||||||
#endif
|
#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, 0);
|
return CylinderBinning(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,14 @@ std::shared_ptr<EnergyDistributionFunction> buildEnergyDistributionFunction(
|
|||||||
DEBUG_LEVEL_2("Creating energy distribution function: tritium beta decay.");
|
DEBUG_LEVEL_2("Creating energy distribution function: tritium beta decay.");
|
||||||
#endif
|
#endif
|
||||||
return std::shared_ptr<EnergyDistributionFunction>(new TritiumBetaDecay());
|
return std::shared_ptr<EnergyDistributionFunction>(new TritiumBetaDecay());
|
||||||
|
} else if(json_object_by_path(object, {"TritiumBetaDecayIon"})) {
|
||||||
} else if (json_object_by_path(object, {"MaxwellBoltzmann"})) {
|
#ifdef debug_level2
|
||||||
|
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
|
#ifdef debug_level2
|
||||||
DEBUG_LEVEL_2("Creating energy distribution function: Maxwell Boltzmann.");
|
DEBUG_LEVEL_2("Creating energy distribution function: Maxwell Boltzmann.");
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -56,6 +56,30 @@ 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
|
#ifdef debug_level2
|
||||||
DEBUG_LEVEL_2("Adding interactions: FreeMovement");
|
DEBUG_LEVEL_2("Adding interactions: FreeMovement");
|
||||||
@@ -83,6 +107,7 @@ 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();
|
||||||
@@ -108,7 +133,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));
|
ionization_energy_eV, 0.));
|
||||||
} 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();
|
||||||
@@ -134,7 +159,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));
|
ionization_energy_eV, 9.));
|
||||||
} 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();
|
||||||
@@ -162,7 +187,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));
|
ionization_energy_eV, 9.));
|
||||||
} 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();
|
||||||
@@ -186,7 +211,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));
|
ionization_energy_eV, 0.));
|
||||||
} else {
|
} else {
|
||||||
ERROR("This ionization model is not implemented: " + ionization_model);
|
ERROR("This ionization model is not implemented: " + ionization_model);
|
||||||
}
|
}
|
||||||
@@ -238,8 +263,15 @@ void addInteractions(
|
|||||||
"that the cross section function is scaled by the density "
|
"that the cross section function is scaled by the density "
|
||||||
"of the target specie at the position of the interaction "
|
"of the target specie at the position of the interaction "
|
||||||
"(cross section function assumed to have the units m^5)");
|
"(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>(
|
specie->addInteraction(std::shared_ptr<interaction::Interaction>(
|
||||||
new interaction::ClusterFormationTertiary(cross_section, target, product)));
|
new interaction::ClusterFormationTertiary(cross_section, target, product)));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ERROR("ClusteringType " + clustering_type +
|
ERROR("ClusteringType " + clustering_type +
|
||||||
": not known, choose either 'radiative' or 'tertiary'.");
|
": not known, choose either 'radiative' or 'tertiary'.");
|
||||||
@@ -320,7 +352,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(80.);
|
return interaction::totalCrossSection::TpT_clustering_tertiary_janev(5e-3);
|
||||||
} 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") {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ namespace generator {
|
|||||||
|
|
||||||
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,
|
||||||
@@ -24,6 +25,7 @@ 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"});
|
||||||
@@ -32,7 +34,37 @@ namespace generator {
|
|||||||
|
|
||||||
auto boundaries = buildBoundaries(parameter, {"PoissonSolver", "Boundary"});
|
auto boundaries = buildBoundaries(parameter, {"PoissonSolver", "Boundary"});
|
||||||
|
|
||||||
|
// build electrodes, might be good to put into own function
|
||||||
std::vector<std::shared_ptr<Electrode>> electrodes{};
|
std::vector<std::shared_ptr<Electrode>> electrodes{};
|
||||||
|
const char* key;
|
||||||
|
json_t* value;
|
||||||
|
json_t* array = parameter.jsonObjectFromBase({"PoissonSolver", "Electrodes"});
|
||||||
|
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\"");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
double target_accuracy = parameter.doubleValue(
|
double target_accuracy = parameter.doubleValue(
|
||||||
json_path_append({"PoissonSolver"}, {"TargetAccuracy"}));
|
json_path_append({"PoissonSolver"}, {"TargetAccuracy"}));
|
||||||
|
|||||||
@@ -16,6 +16,12 @@ std::shared_ptr<Reflector> buildReflector(Parameter& parameter,
|
|||||||
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
|
#ifdef debug_level2
|
||||||
|
|||||||
@@ -10,20 +10,88 @@ std::shared_ptr<Terminator> buildTerminator(
|
|||||||
#ifdef debug_level2
|
#ifdef debug_level2
|
||||||
DEBUG_LEVEL_2("Creating terminator.");
|
DEBUG_LEVEL_2("Creating terminator.");
|
||||||
#endif
|
#endif
|
||||||
|
if (parameter.jsonObjectFromBase(
|
||||||
|
json_path_append(path_to_terminator, {"Cylinder"}))) {
|
||||||
long int max_interactions = static_cast<long int>(parameter.doubleValue(
|
long int max_interactions = static_cast<long int>(parameter.doubleValue(
|
||||||
json_path_append(path_to_terminator, {"MaximumInteractions"})));
|
json_path_append(path_to_terminator, {"Cylinder", "MaximumInteractions"})));
|
||||||
double max_time_alive = parameter.doubleValue(
|
double max_time_alive = parameter.doubleValue(
|
||||||
json_path_append(path_to_terminator, {"MaxTimeAlive", "value"}));
|
json_path_append(path_to_terminator, {"Cylinder", "MaxTimeAlive", "value"}));
|
||||||
#ifdef debug_level3
|
#ifdef debug_level3
|
||||||
DEBUG_LEVEL_3("with max interactions: " + std::to_string(max_interactions));
|
DEBUG_LEVEL_3("with max interactions: " + std::to_string(max_interactions));
|
||||||
DEBUG_LEVEL_3("with max time alive: " + std::to_string(max_time_alive));
|
DEBUG_LEVEL_3("with max time alive: " + std::to_string(max_time_alive));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::shared_ptr<Geometry> geometry = buildGeometryIncludingRedirection(
|
std::shared_ptr<Geometry> geometry = buildGeometryIncludingRedirection(
|
||||||
parameter, json_path_append(path_to_terminator, {"BoundaryGeometry"}));
|
parameter, json_path_append(path_to_terminator, {"Cylinder", "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
|
||||||
@@ -32,23 +32,23 @@ std::string readAbsoluteFilename(json_t* object) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> readFromFile(json_t* object) {
|
blitz::Array<double, 2> 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.readD3Double(key);
|
return reader.readD2Double(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> readComponentFromFile(json_t* object, int component) {
|
blitz::Array<double, 2> 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"}));
|
||||||
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));
|
||||||
|
|
||||||
Hdf5Reader reader(absolute_filename);
|
Hdf5Reader reader(absolute_filename);
|
||||||
return reader.readD3Double(key);
|
return reader.readD2Double(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VectorField> buildVectorField(json_t* object) {
|
std::shared_ptr<VectorField> buildVectorField(json_t* object) {
|
||||||
@@ -75,15 +75,15 @@ std::shared_ptr<VectorField> buildVectorField(json_t* object) {
|
|||||||
DEBUG_LEVEL_2("Creating Vector field: VectorFieldFromArray");
|
DEBUG_LEVEL_2("Creating Vector field: VectorFieldFromArray");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
blitz::Array<double, 3> v_radial = readComponentFromFile(
|
blitz::Array<double, 2> v_radial = readComponentFromFile(
|
||||||
json_object_by_path(object,
|
json_object_by_path(object,
|
||||||
{"VectorFieldFromArray", "ReadArrayFromFile"}),
|
{"VectorFieldFromArray", "ReadArrayFromFile"}),
|
||||||
0);
|
0);
|
||||||
blitz::Array<double, 3> v_azimuthal = readComponentFromFile(
|
blitz::Array<double, 2> v_azimuthal = readComponentFromFile(
|
||||||
json_object_by_path(object,
|
json_object_by_path(object,
|
||||||
{"VectorFieldFromArray", "ReadArrayFromFile"}),
|
{"VectorFieldFromArray", "ReadArrayFromFile"}),
|
||||||
1);
|
1);
|
||||||
blitz::Array<double, 3> v_longitudinal = readComponentFromFile(
|
blitz::Array<double, 2> v_longitudinal = readComponentFromFile(
|
||||||
json_object_by_path(object,
|
json_object_by_path(object,
|
||||||
{"VectorFieldFromArray", "ReadArrayFromFile"}),
|
{"VectorFieldFromArray", "ReadArrayFromFile"}),
|
||||||
2);
|
2);
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ InteractionOutput ClusterFormation::performInteraction(
|
|||||||
// target_->velocityDistribution()
|
// 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(target_velocity_.cartesianEntries(), target_->mass_kg()) *
|
||||||
UnitConversion::JouleToeV;
|
UnitConversion::JouleToeV;
|
||||||
@@ -35,6 +36,15 @@ InteractionOutput ClusterFormation::performInteraction(
|
|||||||
target_velocity_.cartesianEntries() / kinematic::norm(target_velocity_.cartesianEntries());
|
target_velocity_.cartesianEntries() / kinematic::norm(target_velocity_.cartesianEntries());
|
||||||
// product inherits weight of the main particle (not the target, which is
|
// 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)
|
// 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::Particle cluster(product_, x_impact, CartesianVector(v_cluster),
|
||||||
particle.timeAlive(), particle.weight());
|
particle.timeAlive(), particle.weight());
|
||||||
|
|
||||||
@@ -53,15 +63,107 @@ InteractionOutput ClusterFormation::performInteraction(
|
|||||||
ClusterFormationTertiary::ClusterFormationTertiary(
|
ClusterFormationTertiary::ClusterFormationTertiary(
|
||||||
std::function<double(double)> cross_section,
|
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,
|
||||||
ClusterFormation(cross_section, target, product) {}
|
bool rate_coefficient) :
|
||||||
|
ClusterFormation(cross_section, target, product), rate_coefficient_(rate_coefficient) {}
|
||||||
|
|
||||||
double ClusterFormationTertiary::microscopicCrossSection(double energy_eV,
|
double ClusterFormationTertiary::microscopicCrossSection(double energy_eV,
|
||||||
const Coordinate& position) {
|
const Coordinate& position) {
|
||||||
// SIM_INFO("Tertiary cross section.");
|
// SIM_INFO("Tertiary cross section.");
|
||||||
|
if(!rate_coefficient_) {
|
||||||
|
return cross_section_(energy_eV);
|
||||||
|
}
|
||||||
const double rate_over_velocity = cross_section_(energy_eV);
|
const double rate_over_velocity = cross_section_(energy_eV);
|
||||||
auto density = target_->densityField()->density(position);
|
auto density = target_->densityField()->density(position);
|
||||||
return rate_over_velocity * density;
|
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;
|
||||||
|
output.add(cluster);
|
||||||
|
output.deleteCurrentParticle(true);
|
||||||
|
|
||||||
|
if (particle.specie()->deletionLogger()) {
|
||||||
|
particle.specie()->deletionLogger()->logDeletion(
|
||||||
|
x_impact, DeletionType::cluster_formation);
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace interaction
|
} // namespace interaction
|
||||||
|
|||||||
@@ -126,4 +126,55 @@ double ElasticScattering::drawCollisionTime(particle::Particle& particle,
|
|||||||
return time;
|
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,13 +18,14 @@ 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 ionization_energy_eV, double ion_energy)
|
||||||
: 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,
|
||||||
@@ -46,7 +47,11 @@ InteractionOutput ElectronIonization::performInteraction(
|
|||||||
.cartesianEntries();
|
.cartesianEntries();
|
||||||
}
|
}
|
||||||
|
|
||||||
v_target *= std::sqrt(target_->mass_kg()/ion_->mass_kg());
|
// don't think is quite right, since there is no energy transfer to the ion,
|
||||||
|
// and in the case of a dissociative event, the energy of the parent particle
|
||||||
|
// 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(
|
blitz::TinyVector<double, 3> v_laboratory = kinematic::velocityTargetFixed(
|
||||||
v_impact, target_velocity_.cartesianEntries(), particle.mass_kg(), target_->mass_kg()
|
v_impact, target_velocity_.cartesianEntries(), particle.mass_kg(), target_->mass_kg()
|
||||||
@@ -82,7 +87,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_impact_new, generator);
|
E_impact, E_ejected, 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);
|
||||||
@@ -110,6 +115,12 @@ InteractionOutput ElectronIonization::performInteraction(
|
|||||||
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 time_birth = particle.timeAlive();
|
||||||
const double weight_parent = particle.weight();
|
const double weight_parent = particle.weight();
|
||||||
|
|
||||||
@@ -117,8 +128,10 @@ InteractionOutput ElectronIonization::performInteraction(
|
|||||||
output.add(
|
output.add(
|
||||||
particle::Particle(electron_, x_impact, CartesianVector(v_ejected),
|
particle::Particle(electron_, x_impact, CartesianVector(v_ejected),
|
||||||
time_birth, weight_parent));
|
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));
|
time_birth, weight_parent));
|
||||||
|
}
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
@@ -135,7 +148,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_;
|
const double energy_after_max = impact_energy - ionization_energy_eV_; // probably multiply by 0.5
|
||||||
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);
|
||||||
|
|||||||
@@ -22,38 +22,34 @@ PoissonSolver::PoissonSolver(GlobalBoundary bottom_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, 3>(
|
potential_(blitz::Array<PotentialGridPoint, 2>(
|
||||||
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) + 1,
|
||||||
density_binning.binIndexMax()(1)), // the azimuthal direction is periodic
|
density_binning.binIndexMax()(1)))),
|
||||||
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),
|
||||||
do_solver_(do_solver) {
|
do_solver_(do_solver) {
|
||||||
|
|
||||||
blitz::TinyVector<double, 3> stepsize = density_binning_.stepsize();
|
blitz::TinyVector<double, 2> 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) {
|
||||||
for (int k = potential_.lbound(2); k <= potential_.ubound(2);
|
|
||||||
++k) {
|
|
||||||
CylinderCoordinate position(blitz::TinyVector<double, 3>(
|
CylinderCoordinate position(blitz::TinyVector<double, 3>(
|
||||||
i * stepsize(0), j * stepsize(1), k * stepsize(2)));
|
i * stepsize(0), 0, j * stepsize(1)));
|
||||||
|
|
||||||
switch(geometry_->isWhere(position)) {
|
switch(geometry_->isWhere(position)) {
|
||||||
case GeometryPositioning::bottom:
|
case GeometryPositioning::bottom:
|
||||||
potential_(i,j,k) = {bottom_boundary_.type, bottom_boundary_.boundary_value};
|
potential_(i,j) = {bottom_boundary_.type, bottom_boundary_.boundary_value};
|
||||||
break;
|
break;
|
||||||
case GeometryPositioning::top:
|
case GeometryPositioning::top:
|
||||||
potential_(i,j,k) = {top_boundary_.type, top_boundary_.boundary_value};
|
potential_(i,j) = {top_boundary_.type, top_boundary_.boundary_value};
|
||||||
break;
|
break;
|
||||||
case GeometryPositioning::hull:
|
case GeometryPositioning::hull:
|
||||||
potential_(i,j,k) = {hull_boundary_.type, hull_boundary_.boundary_value};
|
potential_(i,j) = {hull_boundary_.type, hull_boundary_.boundary_value};
|
||||||
break;
|
break;
|
||||||
case GeometryPositioning::inside:
|
case GeometryPositioning::inside:
|
||||||
potential_(i,j,k) = {BoundaryType::no_boundary, 0.};
|
potential_(i,j) = {BoundaryType::no_boundary, 0.};
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// include position in output
|
// include position in output
|
||||||
@@ -62,33 +58,30 @@ PoissonSolver::PoissonSolver(GlobalBoundary bottom_boundary,
|
|||||||
}
|
}
|
||||||
for (auto& electrode : electrodes_) {
|
for (auto& electrode : electrodes_) {
|
||||||
if (electrode->isOnElectrode(position)) {
|
if (electrode->isOnElectrode(position)) {
|
||||||
potential_(i,j,k).type = BoundaryType::dirichlet;
|
potential_(i,j).type = BoundaryType::dirichlet;
|
||||||
potential_(i,j,k).value = electrode->electrodePotential();
|
potential_(i,j).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);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PoissonSolver::solvePotential(
|
void PoissonSolver::solvePotential(
|
||||||
const blitz::Array<double, 3> charge_density) {
|
const blitz::Array<double, 2> charge_density) {
|
||||||
if (!(do_solver_)) {
|
if (!(do_solver_)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef debug_level3
|
#ifdef debug_level3
|
||||||
DEBUG_LEVEL_3("Interpolating chargedensity.");
|
DEBUG_LEVEL_3("Interpolating chargedensity.");
|
||||||
#endif
|
#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 {
|
||||||
@@ -106,61 +99,45 @@ void PoissonSolver::solvePotential(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PoissonSolver::solverIteration(
|
void PoissonSolver::solverIteration(
|
||||||
const blitz::Array<double, 3>& interpolated_density) {
|
const blitz::Array<double, 2>& interpolated_density) {
|
||||||
blitz::TinyVector<double, 3> stepsize = density_binning_.stepsize();
|
blitz::TinyVector<double, 2> stepsize = density_binning_.stepsize();
|
||||||
const double dr_sq = stepsize(0)*stepsize(0); // shorthand
|
const double dr_sq = stepsize(0)*stepsize(0); // shorthand
|
||||||
const double dth_sq = stepsize(1)*stepsize(1); // shorthand
|
const double dz_sq = stepsize(1)*stepsize(1); // shorthand
|
||||||
const double dz_sq = stepsize(2)*stepsize(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) {
|
||||||
for (int k = potential_.lbound(2); k <= potential_.ubound(2); ++k) {
|
|
||||||
//rewrite with a switch-case
|
//rewrite with a switch-case
|
||||||
if (potential_(i, j, k).type == BoundaryType::dirichlet) {
|
if (potential_(i, j).type == BoundaryType::dirichlet) {
|
||||||
potential_(i, j, k).value = potential_(i, j, k).value;
|
potential_(i, j).value = potential_(i, j).value;
|
||||||
} else if (potential_(i, j, k).type == BoundaryType::neumann_to_top) {
|
} else if (potential_(i, j).type == BoundaryType::neumann_to_top) {
|
||||||
potential_(i, j, k).value = potential_(i, j, k - 1).value
|
potential_(i, j).value = potential_(i, j-1).value
|
||||||
+ top_boundary_.boundary_value * stepsize(2);
|
+ top_boundary_.boundary_value * stepsize(1);
|
||||||
} else if (potential_(i, j, k).type == BoundaryType::neumann_to_bottom) {
|
} else if (potential_(i, j).type == BoundaryType::neumann_to_bottom) {
|
||||||
potential_(i, j, k).value = potential_(i, j, k + 1).value
|
potential_(i, j).value = potential_(i, j + 1).value
|
||||||
- bottom_boundary_.boundary_value * stepsize(2);
|
- bottom_boundary_.boundary_value * stepsize(1);
|
||||||
} else if (potential_(i, j, k).type == BoundaryType::neumann_to_hull) {
|
} else if (potential_(i, j).type == BoundaryType::neumann_to_hull) {
|
||||||
potential_(i, j, k).value = potential_(i - 1, j, k).value
|
potential_(i, j).value = potential_(i - 1, j).value
|
||||||
+ hull_boundary_.boundary_value * stepsize(0);
|
+ hull_boundary_.boundary_value * stepsize(0);
|
||||||
} else if (i == 0) {
|
} else if (i == 0) {
|
||||||
// special calculation for r=0
|
// special calculation for r=0
|
||||||
const int jmirror = (j<potential_.extent(1)/2) ? j+potential_.extent(1)/2
|
|
||||||
: j-potential_.extent(1)/2;
|
|
||||||
const double scaling_factor = 4 / dr_sq + 2 / dz_sq;
|
const double scaling_factor = 4 / dr_sq + 2 / dz_sq;
|
||||||
potential_(i, j, k).value =
|
potential_(i, j).value =
|
||||||
(1 / scaling_factor) *
|
(1 / scaling_factor) *
|
||||||
((2 / dr_sq) * (potential_(i + 1, j, k).value +
|
((4 / dr_sq) * (potential_(i + 1, j).value) +
|
||||||
potential_(i + 1, jmirror, k).value) +
|
(1 / dz_sq) * (potential_(i, j + 1).value +
|
||||||
(1 / dz_sq) * (potential_(i, j, k + 1).value +
|
potential_(i, j - 1).value) +
|
||||||
potential_(i, j, k - 1).value) +
|
interpolated_density(i, j)/SI::eps0);
|
||||||
interpolated_density(i, j, k)/SI::eps0);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
const int jp1 = j + 1 > potential_.ubound(1)
|
const double scaling_factor = 2 / dr_sq + 2 / dz_sq;
|
||||||
? 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 scaling_factor = 2 / dr_sq + 2 / dz_sq +
|
potential_(i, j).value =
|
||||||
2 / (i*i * dr_sq * dth_sq);
|
|
||||||
|
|
||||||
potential_(i, j, k).value =
|
|
||||||
(1 / scaling_factor) *
|
(1 / scaling_factor) *
|
||||||
((1 / dr_sq * (1 + 1. / (2. * i))) * potential_(i + 1, j, k).value +
|
((1 / dr_sq * (1 + 1. / (2. * i))) * potential_(i + 1, j).value +
|
||||||
(1 / dr_sq * (1 - 1. / (2. * i))) * potential_(i - 1, j, k).value +
|
(1 / dr_sq * (1 - 1. / (2. * i))) * potential_(i - 1, j).value +
|
||||||
(1 / (i*i * dr_sq * dth_sq)) *
|
(1 / dz_sq) * (potential_(i, j + 1).value +
|
||||||
(potential_(i, jp1, k).value + potential_(i, jm1, k).value) +
|
potential_(i, j - 1).value) +
|
||||||
(1 / dz_sq) * (potential_(i, j, k + 1).value +
|
interpolated_density(i, j)/SI::eps0);
|
||||||
potential_(i, j, k - 1).value) +
|
|
||||||
interpolated_density(i, j, k)/SI::eps0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -169,11 +146,10 @@ 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, 3>& interpolated_density) {
|
const blitz::Array<double, 2>& interpolated_density) {
|
||||||
blitz::TinyVector<double, 3> stepsize = density_binning_.stepsize();
|
blitz::TinyVector<double, 2> stepsize = density_binning_.stepsize();
|
||||||
const double dr_sq = stepsize(0)*stepsize(0); // shorthand
|
const double dr_sq = stepsize(0)*stepsize(0); // shorthand
|
||||||
const double dth_sq = stepsize(1)*stepsize(1); // shorthand
|
const double dz_sq = stepsize(1)*stepsize(1); // shorthand
|
||||||
const double dz_sq = stepsize(2)*stepsize(2); // shorthand
|
|
||||||
|
|
||||||
double cumulated_quadradic_difference = 0.;
|
double cumulated_quadradic_difference = 0.;
|
||||||
double normalized_difference = 0.;
|
double normalized_difference = 0.;
|
||||||
@@ -181,24 +157,15 @@ 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) {
|
||||||
for (int k = potential_.lbound(2) + 1; k <= potential_.ubound(2) - 1;
|
if(potential_(i,j).type != BoundaryType::no_boundary) {
|
||||||
++k) {
|
|
||||||
if(potential_(i,j,k).type != BoundaryType::no_boundary) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
// special calculation for r=0
|
// special calculation for r=0
|
||||||
//Note: the value \phi_{i,j+Nj/2,k} as the replacement of
|
const double difference = interpolated_density(i,j)/SI::eps0 +
|
||||||
// \phi_{i-1,j,k} is only correct if Nj is even otherwise the mirrored point
|
4*(potential_(i+1,j).value - potential_(i,j).value)/dr_sq +
|
||||||
// lies inbetween two known values; additionally not sure if this calculation
|
(potential_(i,j+1).value - 2*potential_(i,j).value +
|
||||||
// is correct at all (would definitely be fine for cylindrical symmetric calc.)
|
potential_(i,j-1).value)/dz_sq;
|
||||||
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;
|
|
||||||
|
|
||||||
cumulated_quadradic_difference += difference*difference;
|
cumulated_quadradic_difference += difference*difference;
|
||||||
|
|
||||||
@@ -207,22 +174,13 @@ bool PoissonSolver::converged(
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
const int jp1 = j + 1 > potential_.ubound(1)
|
const double difference = interpolated_density(i,j)/SI::eps0 +
|
||||||
? potential_.lbound(1)
|
(potential_(i+1,j).value - 2*potential_(i,j).value +
|
||||||
: j + 1; // j+1 with periodic guard
|
potential_(i-1,j).value)/dr_sq +
|
||||||
const int jm1 = j - 1 < potential_.lbound(1)
|
(potential_(i+1,j).value - potential_(i-1,j).value)/
|
||||||
? 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) +
|
(2*i*dr_sq) +
|
||||||
(potential_(i,jp1,k).value - 2*potential_(i,j,k).value +
|
(potential_(i,j+1).value - 2*potential_(i,j).value +
|
||||||
potential_(i,jm1,k).value)/(i*i*dr_sq*dth_sq) +
|
potential_(i,j-1).value)/dz_sq;
|
||||||
(potential_(i,j,k+1).value - 2*potential_(i,j,k).value +
|
|
||||||
potential_(i,j,k-1).value)/dz_sq;
|
|
||||||
|
|
||||||
cumulated_quadradic_difference += difference*difference;
|
cumulated_quadradic_difference += difference*difference;
|
||||||
|
|
||||||
@@ -232,59 +190,55 @@ bool PoissonSolver::converged(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
const int nr = potential_.extent(0) - 1;
|
const int nr = potential_.extent(0) - 1;
|
||||||
const int nth = potential_.extent(1);
|
const int nz = potential_.extent(1) - 2;
|
||||||
const int nz = potential_.extent(2) - 2;
|
|
||||||
|
|
||||||
normalized_difference =
|
normalized_difference =
|
||||||
std::sqrt(cumulated_quadradic_difference / (nr * nth * nz));
|
std::sqrt(cumulated_quadradic_difference / (nr * nz));
|
||||||
#ifdef debug
|
#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
|
#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_level1
|
#ifdef debug
|
||||||
std::ostringstream message;
|
std::ostringstream message;
|
||||||
message << "Maximum Difference normalized by order of magnitude: "
|
message << "Maximum Difference normalized by order of magnitude: "
|
||||||
<< normalized_difference;
|
<< normalized_maximum;
|
||||||
DEBUG_LEVEL_1(message.str());
|
DEBUG(message.str());
|
||||||
#endif
|
#endif
|
||||||
return normalized_difference < target_accuracy_;
|
return normalized_difference < target_accuracy_;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> PoissonSolver::potential() {
|
blitz::Array<double, 2> 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, 3> potentialValues(potential_.lbound(), potential_.extent());
|
blitz::Array<double, 2> potentialValues(potential_.lbound(), potential_.extent());
|
||||||
#ifdef debug_level3
|
#ifdef debug_level3
|
||||||
DEBUG_LEVEL_3("Extracting potential values");
|
DEBUG_LEVEL_3("Extracting potential values");
|
||||||
#endif
|
#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) {
|
||||||
for(int k = potential_.lbound(2); k <= potential_.ubound(2); ++k) {
|
potentialValues(i,j) = potential_(i,j).value;
|
||||||
potentialValues(i,j,k) = potential_(i,j,k).value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return potentialValues;
|
return potentialValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> PoissonSolver::interpolateDensityToPotentialGrid(
|
blitz::Array<double, 2> PoissonSolver::interpolateDensityToPotentialGrid(
|
||||||
const blitz::Array<double, 3> density) {
|
const blitz::Array<double, 2> 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, 3> interpolatedDensity(potential_.lbound(), potential_.extent());
|
blitz::Array<double, 2> 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) {
|
||||||
for(int k = potential_.lbound(2); k <= potential_.ubound(2); ++k) {
|
interpolatedDensity(i, j) = (
|
||||||
interpolatedDensity(i, j, k) = (
|
density(i-1, j-1) + density(i, j-1) +
|
||||||
density(i-1, j , k-1) + density(i, j , k-1) +
|
density(i-1, j ) + density(i, j ))/4.;
|
||||||
density(i-1, j , k ) + density(i, j , k ))/4.;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,17 +246,12 @@ blitz::Array<double, 3> 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 j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
for(int k = potential_.lbound(1)+1; k <= potential_.ubound(1)-1; ++k) {
|
||||||
for(int k = potential_.lbound(2)+1; k <= potential_.ubound(2)-1; ++k) {
|
|
||||||
//might not work that way, would need a dummy variable otherwise
|
//might not work that way, would need a dummy variable otherwise
|
||||||
interpolatedDensity(potential_.lbound(0), blitz::Range::all(), k) +=
|
interpolatedDensity(potential_.lbound(0), k) =
|
||||||
(density(fixedIndex, j, k-1) + density(fixedIndex, j, k))/2.;
|
(density(fixedIndex, k-1) + density(fixedIndex, k))/2.;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//might not work that way (if not needs a loop)
|
|
||||||
interpolatedDensity(fixedIndex, blitz::Range::all(), blitz::Range::all()) /=
|
|
||||||
potential_.extent(1);
|
|
||||||
#ifdef debug_level3
|
#ifdef debug_level3
|
||||||
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)));
|
||||||
@@ -313,60 +262,41 @@ blitz::Array<double, 3> PoissonSolver::interpolateDensityToPotentialGrid(
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<VectorField> PoissonSolver::staticElectricField() {
|
std::shared_ptr<VectorField> PoissonSolver::staticElectricField() {
|
||||||
blitz::TinyVector<double, 3> stepsize = density_binning_.stepsize();
|
blitz::TinyVector<double, 2> stepsize = density_binning_.stepsize();
|
||||||
blitz::TinyVector<int,3> Eextent = potential_.extent() -
|
blitz::TinyVector<int,2> Eextent = potential_.extent() -
|
||||||
blitz::TinyVector<int,3>(1,0,1);
|
blitz::TinyVector<int,2>(1,1);
|
||||||
blitz::Array<double, 3> Er(potential_.lbound(), Eextent);
|
blitz::Array<double, 2> Er(potential_.lbound(), Eextent);
|
||||||
blitz::Array<double, 3> Ephi(potential_.lbound(), Eextent);
|
blitz::Array<double, 2> Ephi(potential_.lbound(), Eextent);
|
||||||
blitz::Array<double, 3> Ez(potential_.lbound(), Eextent);
|
blitz::Array<double, 2> 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 i = potential_.lbound(0); i < potential_.ubound(0); ++i) {
|
||||||
for(int k = potential_.lbound(2); k < potential_.ubound(2); ++k) {
|
for(int k = potential_.lbound(1); k < potential_.ubound(1); ++k) {
|
||||||
Er(i,j,k) = -(potential_(i+1,j,k ).value -
|
Er(i,k) = -(potential_(i+1,k ).value -
|
||||||
potential_(i ,j,k ).value +
|
potential_(i ,k ).value +
|
||||||
potential_(i+1,j,k+1).value -
|
potential_(i+1,k+1).value -
|
||||||
potential_(i ,j,k+1).value)
|
potential_(i ,k+1).value ) /(2*stepsize(0));
|
||||||
/(2*stepsize(0));
|
|
||||||
|
|
||||||
Ez(i,j,k) = -(potential_(i ,j,k+1).value -
|
Ez(i,k) = -(potential_(i ,k+1).value -
|
||||||
potential_(i ,j,k ).value +
|
potential_(i ,k ).value +
|
||||||
potential_(i+1,j,k+1).value -
|
potential_(i+1,k+1).value -
|
||||||
potential_(i+1,j,k ).value)
|
potential_(i+1,k ).value )/(2*stepsize(1));
|
||||||
/(2*stepsize(2));
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(i==potential_.lbound(0)) {
|
|
||||||
Ephi(i,j,k) = -(
|
|
||||||
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)*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(2)*stepsize(2)));
|
Eextent(0)*stepsize(0), Eextent(1)*stepsize(1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
const CylinderBinning* PoissonSolver::densityBinning() {
|
const CylinderBinning* PoissonSolver::densityBinning() {
|
||||||
return &density_binning_;
|
return &density_binning_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PoissonSolver::setPotential(blitz::Array<double, 3>& potential) {
|
void PoissonSolver::setPotential(blitz::Array<double, 2>& potential) {
|
||||||
// check if the loaded potential has the same size as the potential
|
// check if the loaded potential has the same size as the potential
|
||||||
// specified by the json file
|
// specified by the json file
|
||||||
if(!blitz::all(potential.length() == potential_.length())) {
|
if(!blitz::all(potential.length() == potential_.length())) {
|
||||||
@@ -381,13 +311,10 @@ void PoissonSolver::setPotential(blitz::Array<double, 3>& potential) {
|
|||||||
// while the parameter array is most likely starting from 0)
|
// while the parameter array is most likely starting from 0)
|
||||||
const int i_offset = potential.lbound(0) - potential_.lbound(0);
|
const int i_offset = potential.lbound(0) - potential_.lbound(0);
|
||||||
const int j_offset = potential.lbound(1) - potential_.lbound(1);
|
const int j_offset = potential.lbound(1) - potential_.lbound(1);
|
||||||
const int k_offset = potential.lbound(2) - potential_.lbound(2);
|
|
||||||
|
|
||||||
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) {
|
||||||
for(int k = potential_.lbound(2); k <= potential_.ubound(2); ++k) {
|
potential_(i,j).value = potential(i + i_offset,j + j_offset);
|
||||||
potential_(i,j,k).value = potential(i + i_offset,j + j_offset,k + k_offset);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -407,3 +334,33 @@ 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;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ blitz::TinyVector<double, 3> CartesianCoordinate::cylinderEntries() const {
|
|||||||
// 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 radius = std::sqrt(cartesian_position(0)*cartesian_position(0) +
|
||||||
cartesian_position(1)*cartesian_position(1));
|
cartesian_position(1)*cartesian_position(1));
|
||||||
const double phi = std::atan2(cartesian_position(1), cartesian_position(0));
|
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,6 +89,9 @@ 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,14 +101,26 @@ CylinderCoordinate::CylinderCoordinate(const Coordinate& coordinate)
|
|||||||
}
|
}
|
||||||
|
|
||||||
double CylinderCoordinate::cosAzimuth() const {
|
double CylinderCoordinate::cosAzimuth() const {
|
||||||
|
#ifdef debug
|
||||||
|
if(!phi_was_set)
|
||||||
|
fprintf(stdout, "CylinderCoordinate cos calc\n");
|
||||||
|
#endif
|
||||||
return std::cos(cylinder_position(1));
|
return std::cos(cylinder_position(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
double CylinderCoordinate::sinAzimuth() const {
|
double CylinderCoordinate::sinAzimuth() const {
|
||||||
|
#ifdef debug
|
||||||
|
if(!phi_was_set)
|
||||||
|
fprintf(stdout, "CylinderCoordinate sin calc\n");
|
||||||
|
#endif
|
||||||
return std::sin(cylinder_position(1));
|
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)),
|
||||||
@@ -210,6 +225,7 @@ 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();
|
||||||
|
|
||||||
|
|||||||
@@ -7,14 +7,10 @@
|
|||||||
#include "simulation/species.h"
|
#include "simulation/species.h"
|
||||||
#include "simulation/mpi_communication.h"
|
#include "simulation/mpi_communication.h"
|
||||||
|
|
||||||
void CpuSynchronizer::sumToAll(blitz::Array<double, 4>& array,
|
void CpuSynchronizer::sumToAll(blitz::Array<double, 4>& array) {
|
||||||
blitz::Array<double, 4>& last_sync_array) {
|
|
||||||
int size = array.size();
|
int size = array.size();
|
||||||
blitz::Array<double, 4> delta(array.extent());
|
MPI_Allreduce(MPI_IN_PLACE, array.data(), size, MPI_DOUBLE,
|
||||||
delta = array - last_sync_array;
|
|
||||||
MPI_Allreduce(MPI_IN_PLACE, delta.data(), size, MPI_DOUBLE,
|
|
||||||
MPI_SUM, MPI_COMM_WORLD);
|
MPI_SUM, MPI_COMM_WORLD);
|
||||||
last_sync_array += delta;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CpuSynchronizer::sumToAll(blitz::Array<double, 5>& array) {
|
void CpuSynchronizer::sumToAll(blitz::Array<double, 5>& array) {
|
||||||
@@ -77,6 +73,14 @@ void CpuSynchronizer::sumToRoot(blitz::Array<double, 3>& array) {
|
|||||||
MPI_Reduce(array.data(), nullptr, size, MPI_DOUBLE, MPI_SUM, root, MPI_COMM_WORLD);
|
MPI_Reduce(array.data(), nullptr, size, MPI_DOUBLE, MPI_SUM, root, MPI_COMM_WORLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CpuSynchronizer::sumToRoot(blitz::Array<double, 2>& array) {
|
||||||
|
int size = array.size();
|
||||||
|
if(MpiCommunication::mpi_rank == root)
|
||||||
|
MPI_Reduce(MPI_IN_PLACE, array.data(), size, MPI_DOUBLE, MPI_SUM, root, MPI_COMM_WORLD);
|
||||||
|
else
|
||||||
|
MPI_Reduce(array.data(), nullptr, size, MPI_DOUBLE, MPI_SUM, root, MPI_COMM_WORLD);
|
||||||
|
}
|
||||||
|
|
||||||
void CpuSynchronizer::sumToRoot(long int& value) {
|
void CpuSynchronizer::sumToRoot(long int& value) {
|
||||||
int size = 1;
|
int size = 1;
|
||||||
if(MpiCommunication::mpi_rank == root) {
|
if(MpiCommunication::mpi_rank == root) {
|
||||||
@@ -110,8 +114,8 @@ void CpuSynchronizer::synchronize(Timer* timer, Timer* last_sync_timer) {
|
|||||||
// array storing the previous timestep
|
// array storing the previous timestep
|
||||||
void CpuSynchronizer::synchronize(DynamicDensityField* field) {
|
void CpuSynchronizer::synchronize(DynamicDensityField* field) {
|
||||||
if (field) {
|
if (field) {
|
||||||
sumToAll(field->sync_time_in_bin_s_);
|
sumToAll(field->sync_number_in_bin_);
|
||||||
field->time_in_bin_s_ = field->sync_time_in_bin_s_;
|
field->number_in_bin_ = field->sync_number_in_bin_;
|
||||||
field->recalculateDensityArray();
|
field->recalculateDensityArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -153,6 +157,11 @@ void CpuSynchronizer::synchronize(CurrentCollector* collector) {
|
|||||||
// collector->r_positive_crossings =
|
// collector->r_positive_crossings =
|
||||||
// collector->sync_r_positive_crossings;
|
// collector->sync_r_positive_crossings;
|
||||||
sumToRoot(collector->r_positive_crossings);
|
sumToRoot(collector->r_positive_crossings);
|
||||||
|
|
||||||
|
#ifdef GENRICHCURRENT
|
||||||
|
if(collector->getNeedsReset())
|
||||||
|
sumToRoot(collector->sample_z_negative_crossings);
|
||||||
|
#endif //GENRICHCURRENT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,26 +12,31 @@ CurrentCollector::CurrentCollector(const CylinderBinning& position_binning,
|
|||||||
collector_areas_r(createAreaRadial(position_binning)),
|
collector_areas_r(createAreaRadial(position_binning)),
|
||||||
phi_negative_crossings(createCrossingsAzimuthal(position_binning)),
|
phi_negative_crossings(createCrossingsAzimuthal(position_binning)),
|
||||||
phi_positive_crossings(createCrossingsAzimuthal(position_binning)),
|
phi_positive_crossings(createCrossingsAzimuthal(position_binning)),
|
||||||
collector_areas_phi(createAreaAzimuthal(position_binning))//,
|
collector_areas_phi(createAreaAzimuthal(position_binning))
|
||||||
// sync_z_negative_crossings(createCrossingsLongitudinal(position_binning)),
|
#ifdef GENRICHCURRENT
|
||||||
// sync_z_positive_crossings(createCrossingsLongitudinal(position_binning)),
|
// Hard coded values, not ideal, but it didn't work using defines...
|
||||||
// sync_r_negative_crossings(createCrossingsRadial(position_binning)),
|
, energy_binning_(0.1, 10, 100)
|
||||||
// sync_r_positive_crossings(createCrossingsRadial(position_binning)),
|
, sample_z_negative_crossings(
|
||||||
// sync_phi_negative_crossings(createCrossingsAzimuthal(position_binning)),
|
blitz::Range(position_binning.binIndexMin()(0),
|
||||||
// sync_phi_positive_crossings(createCrossingsAzimuthal(position_binning))
|
position_binning.binIndexMax()(0)),
|
||||||
{}
|
blitz::Range(-1, 100))
|
||||||
|
#endif //GENRICHCURRENT
|
||||||
|
{
|
||||||
|
#ifdef GENRICHCURRENT
|
||||||
|
sample_z_negative_crossings = 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> CurrentCollector::createAreaLongitudinal(
|
blitz::Array<double, 2> CurrentCollector::createAreaLongitudinal(
|
||||||
const CylinderBinning& position_binning) {
|
const CylinderBinning& position_binning) {
|
||||||
const blitz::TinyVector<int, 3> bin_index_min =
|
const blitz::TinyVector<int, 2> bin_index_min =
|
||||||
position_binning.binIndexMin();
|
position_binning.binIndexMin();
|
||||||
const blitz::TinyVector<int, 3> bin_index_max =
|
const blitz::TinyVector<int, 2> bin_index_max =
|
||||||
position_binning.binIndexMax();
|
position_binning.binIndexMax();
|
||||||
|
|
||||||
blitz::Array<double, 3> area_z(
|
blitz::Array<double, 2> area_z(
|
||||||
blitz::Range(bin_index_min(0), bin_index_max(0)),
|
blitz::Range(bin_index_min(0), bin_index_max(0)),
|
||||||
blitz::Range(bin_index_min(1), bin_index_max(1)),
|
blitz::Range(0, bin_index_max(1)));
|
||||||
blitz::Range(0, bin_index_max(2)));
|
|
||||||
|
|
||||||
for (int ir = 0; ir <= area_z.ubound(0); ++ir) {
|
for (int ir = 0; ir <= area_z.ubound(0); ++ir) {
|
||||||
const double dr = position_binning.stepsize()(0);
|
const double dr = position_binning.stepsize()(0);
|
||||||
@@ -39,218 +44,239 @@ blitz::Array<double, 3> CurrentCollector::createAreaLongitudinal(
|
|||||||
const double r2 = (ir + 1) * dr;
|
const double r2 = (ir + 1) * dr;
|
||||||
// const double area_element =
|
// const double area_element =
|
||||||
// (std::pow(r2, 2) - std::pow(r1, 2)) * M_PI / (area_z.extent(1));
|
// (std::pow(r2, 2) - std::pow(r1, 2)) * M_PI / (area_z.extent(1));
|
||||||
const double area_element =
|
const double area_element = (r2*r2 - r1*r1) * M_PI;
|
||||||
(r2*r2 - r1*r1) * M_PI / (area_z.extent(1));
|
area_z(ir, blitz::Range::all()) = area_element;
|
||||||
area_z(ir, blitz::Range::all(), blitz::Range::all()) = area_element;
|
|
||||||
}
|
}
|
||||||
return area_z;
|
return area_z;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> CurrentCollector::createCrossingsLongitudinal(
|
blitz::Array<double, 2> CurrentCollector::createCrossingsLongitudinal(
|
||||||
const CylinderBinning& position_binning) {
|
const CylinderBinning& position_binning) {
|
||||||
const blitz::TinyVector<int, 3> bin_index_min =
|
const blitz::TinyVector<int, 2> bin_index_min =
|
||||||
position_binning.binIndexMin();
|
position_binning.binIndexMin();
|
||||||
const blitz::TinyVector<int, 3> bin_index_max =
|
const blitz::TinyVector<int, 2> bin_index_max =
|
||||||
position_binning.binIndexMax();
|
position_binning.binIndexMax();
|
||||||
|
|
||||||
blitz::Array<double, 3> crossings_longitudinal(
|
blitz::Array<double, 2> crossings_longitudinal(
|
||||||
blitz::Range(bin_index_min(0), bin_index_max(0)),
|
blitz::Range(bin_index_min(0), bin_index_max(0)),
|
||||||
blitz::Range(bin_index_min(1), bin_index_max(1)),
|
blitz::Range(0, bin_index_max(1)));
|
||||||
blitz::Range(0, bin_index_max(2)));
|
|
||||||
crossings_longitudinal = 0.;
|
crossings_longitudinal = 0.;
|
||||||
return crossings_longitudinal;
|
return crossings_longitudinal;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> CurrentCollector::createAreaRadial(
|
blitz::Array<double, 2> CurrentCollector::createAreaRadial(
|
||||||
const CylinderBinning& position_binning) {
|
const CylinderBinning& position_binning) {
|
||||||
const blitz::TinyVector<int, 3> bin_index_min =
|
const blitz::TinyVector<int, 2> bin_index_min =
|
||||||
position_binning.binIndexMin();
|
position_binning.binIndexMin();
|
||||||
const blitz::TinyVector<int, 3> bin_index_max =
|
const blitz::TinyVector<int, 2> bin_index_max =
|
||||||
position_binning.binIndexMax();
|
position_binning.binIndexMax();
|
||||||
|
|
||||||
blitz::Array<double, 3> area_r(
|
blitz::Array<double, 2> area_r(
|
||||||
blitz::Range(bin_index_min(0), bin_index_max(0) - 1),
|
blitz::Range(bin_index_min(0), bin_index_max(0) - 1),
|
||||||
blitz::Range(bin_index_min(1), bin_index_max(1)),
|
blitz::Range(bin_index_min(1), bin_index_max(1)));
|
||||||
blitz::Range(bin_index_min(2), bin_index_max(2)));
|
|
||||||
|
|
||||||
for (int ir = 0; ir <= area_r.ubound(0); ++ir) {
|
for (int ir = 0; ir <= area_r.ubound(0); ++ir) {
|
||||||
const double dr = position_binning.stepsize()(0);
|
const double dr = position_binning.stepsize()(0);
|
||||||
const double dz = position_binning.stepsize()(2);
|
const double dz = position_binning.stepsize()(1);
|
||||||
const double r = (ir + 1) * dr;
|
const double r = (ir + 1) * dr;
|
||||||
const double area_element = (2 * M_PI * r) / area_r.extent(1) * dz;
|
const double area_element = (2 * M_PI * r) * dz;
|
||||||
|
|
||||||
area_r(ir, blitz::Range::all(), blitz::Range::all()) = area_element;
|
area_r(ir, blitz::Range::all()) = area_element;
|
||||||
}
|
}
|
||||||
return area_r;
|
return area_r;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> CurrentCollector::createCrossingsRadial(
|
blitz::Array<double, 2> CurrentCollector::createCrossingsRadial(
|
||||||
const CylinderBinning& position_binning) {
|
const CylinderBinning& position_binning) {
|
||||||
const blitz::TinyVector<int, 3> bin_index_min =
|
const blitz::TinyVector<int, 2> bin_index_min =
|
||||||
position_binning.binIndexMin();
|
position_binning.binIndexMin();
|
||||||
const blitz::TinyVector<int, 3> bin_index_max =
|
const blitz::TinyVector<int, 2> bin_index_max =
|
||||||
position_binning.binIndexMax();
|
position_binning.binIndexMax();
|
||||||
|
|
||||||
blitz::Array<double, 3> crossings_radial(
|
blitz::Array<double, 2> crossings_radial(
|
||||||
blitz::Range(bin_index_min(0), bin_index_max(0) - 1),
|
blitz::Range(bin_index_min(0), bin_index_max(0) - 1),
|
||||||
blitz::Range(bin_index_min(1), bin_index_max(1)),
|
blitz::Range(bin_index_min(1), bin_index_max(1)));
|
||||||
blitz::Range(bin_index_min(2), bin_index_max(2)));
|
|
||||||
crossings_radial = 0.;
|
crossings_radial = 0.;
|
||||||
return crossings_radial;
|
return crossings_radial;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> CurrentCollector::createAreaAzimuthal(
|
blitz::Array<double, 2> CurrentCollector::createAreaAzimuthal(
|
||||||
const CylinderBinning& position_binning) {
|
const CylinderBinning& position_binning) {
|
||||||
const blitz::TinyVector<int, 3> bin_index_min =
|
const blitz::TinyVector<int, 2> bin_index_min =
|
||||||
position_binning.binIndexMin();
|
position_binning.binIndexMin();
|
||||||
const blitz::TinyVector<int, 3> bin_index_max =
|
const blitz::TinyVector<int, 2> bin_index_max =
|
||||||
position_binning.binIndexMax();
|
position_binning.binIndexMax();
|
||||||
|
|
||||||
blitz::Array<double, 3> area_phi(
|
blitz::Array<double, 2> area_phi(
|
||||||
blitz::Range(bin_index_min(0), bin_index_max(0)),
|
blitz::Range(bin_index_min(0), bin_index_max(0)),
|
||||||
blitz::Range(bin_index_min(1), bin_index_max(1)),
|
blitz::Range(bin_index_min(1), bin_index_max(1)));
|
||||||
blitz::Range(bin_index_min(2), bin_index_max(2)));
|
|
||||||
|
|
||||||
const double dr = position_binning.stepsize()(0);
|
const double dr = position_binning.stepsize()(0);
|
||||||
const double dz = position_binning.stepsize()(2);
|
const double dz = position_binning.stepsize()(1);
|
||||||
const double area_element = dr * dz;
|
const double area_element = dr * dz;
|
||||||
area_phi(blitz::Range::all(), blitz::Range::all(), blitz::Range::all()) =
|
area_phi(blitz::Range::all(), blitz::Range::all()) =
|
||||||
area_element;
|
area_element;
|
||||||
return area_phi;
|
return area_phi;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> CurrentCollector::createCrossingsAzimuthal(
|
blitz::Array<double, 2> CurrentCollector::createCrossingsAzimuthal(
|
||||||
const CylinderBinning& position_binning) {
|
const CylinderBinning& position_binning) {
|
||||||
const blitz::TinyVector<int, 3> bin_index_min =
|
const blitz::TinyVector<int, 2> bin_index_min =
|
||||||
position_binning.binIndexMin();
|
position_binning.binIndexMin();
|
||||||
const blitz::TinyVector<int, 3> bin_index_max =
|
const blitz::TinyVector<int, 2> bin_index_max =
|
||||||
position_binning.binIndexMax();
|
position_binning.binIndexMax();
|
||||||
|
|
||||||
blitz::Array<double, 3> crossings_azimuthal(
|
blitz::Array<double, 2> crossings_azimuthal(
|
||||||
blitz::Range(bin_index_min(0), bin_index_max(0)),
|
blitz::Range(bin_index_min(0), bin_index_max(0)),
|
||||||
blitz::Range(bin_index_min(1), bin_index_max(1)),
|
blitz::Range(bin_index_min(1), bin_index_max(1)));
|
||||||
blitz::Range(bin_index_min(2), bin_index_max(2)));
|
|
||||||
crossings_azimuthal = 0;
|
crossings_azimuthal = 0;
|
||||||
return crossings_azimuthal;
|
return crossings_azimuthal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// old_position should be a CartesianCoordinate, since the cartesian entries are needed
|
||||||
|
// for the Azimuthal collection and a transformation from cylinder -> cartesian is not possible
|
||||||
void CurrentCollector::collect(particle::Particle* particle,
|
void CurrentCollector::collect(particle::Particle* particle,
|
||||||
const Coordinate& old_position) {
|
const Coordinate& old_position) {
|
||||||
blitz::TinyVector<int, 3> bin_old =
|
blitz::TinyVector<int, 2> bin_old =
|
||||||
position_binning_.bin(old_position.cylinderEntries());
|
position_binning_.bin(old_position.cylinderEntries());
|
||||||
blitz::TinyVector<int, 3> bin_new =
|
blitz::TinyVector<int, 2> bin_new =
|
||||||
position_binning_.bin(particle->cylinderPosition().cylinderEntries());
|
position_binning_.bin(particle->cylinderPosition().cylinderEntries());
|
||||||
|
|
||||||
const double weight = particle->weight();
|
const double weight = particle->weight();
|
||||||
|
|
||||||
|
#ifdef debug_genrich
|
||||||
|
if(particle->specie()->type() == species::ImplementedSpecies::Tplus &&
|
||||||
|
bin_new(1) == -1) {
|
||||||
|
std::stringstream out;
|
||||||
|
out << "Energy " << particle->kineticEnergy_eV() << " \n\t";
|
||||||
|
out << "Bin old " << bin_old << "; Bin new " << bin_new;
|
||||||
|
out << "; energy bin " << energy_binning_.bin(particle->kineticEnergy_eV());
|
||||||
|
out << "\n";
|
||||||
|
std::cout << out.str();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
collectRadialMovement(bin_old, bin_new, weight);
|
collectRadialMovement(bin_old, bin_new, weight);
|
||||||
collectLongitudinalMovement(bin_old, bin_new, weight);
|
collectLongitudinalMovement(bin_old, bin_new,
|
||||||
collectAzimuthalMovement(bin_old, bin_new, weight);
|
#ifdef GENRICHCURRENT
|
||||||
|
particle->kineticEnergy_eV(),
|
||||||
|
#endif
|
||||||
|
weight);
|
||||||
|
collectAzimuthalMovement(old_position.cartesianEntries(),
|
||||||
|
particle->cartesianPosition().cartesianEntries(),
|
||||||
|
bin_old, weight);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurrentCollector::collectRadialMovement(
|
void CurrentCollector::collectRadialMovement(
|
||||||
const blitz::TinyVector<int, 3>& bin_old,
|
const blitz::TinyVector<int, 2>& bin_old,
|
||||||
const blitz::TinyVector<int, 3>& bin_new,
|
const blitz::TinyVector<int, 2>& bin_new,
|
||||||
const double weight) {
|
const double weight) {
|
||||||
if (bin_new(0) < bin_old(0)) {
|
if (bin_new(0) < bin_old(0)) {
|
||||||
r_negative_crossings(bin_new(0), bin_old(1), bin_old(2)) += weight;
|
r_negative_crossings(bin_new(0), bin_old(1)) += weight;
|
||||||
} else if (bin_new(0) > bin_old(0)) {
|
} else if (bin_new(0) > bin_old(0)) {
|
||||||
r_positive_crossings(bin_new(0) - 1, bin_old(1), bin_old(2)) += weight;
|
r_positive_crossings(bin_new(0) - 1, bin_old(1)) += weight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void CurrentCollector::collectLongitudinalMovement(
|
void CurrentCollector::collectLongitudinalMovement(
|
||||||
const blitz::TinyVector<int, 3>& bin_old,
|
const blitz::TinyVector<int, 2>& bin_old,
|
||||||
const blitz::TinyVector<int, 3>& bin_new,
|
const blitz::TinyVector<int, 2>& bin_new,
|
||||||
|
#ifdef GENRICHCURRENT
|
||||||
|
const double energy_eV,
|
||||||
|
#endif
|
||||||
const double weight) {
|
const double weight) {
|
||||||
if (bin_new(2) < bin_old(2)) {
|
if (bin_new(1) < bin_old(1)) {
|
||||||
z_negative_crossings(bin_old(0), bin_old(1), bin_new(2) + 1) += weight;
|
z_negative_crossings(bin_old(0), bin_new(1) + 1) += weight;
|
||||||
} else if (bin_new(2) > bin_old(2)) {
|
#ifdef GENRICHCURRENT
|
||||||
z_positive_crossings(bin_old(0), bin_old(1), bin_new(2)) += weight;
|
if(bin_new(1) == -1) {
|
||||||
|
int ebin = energy_binning_.bin(energy_eV);
|
||||||
|
// #ifdef debug_genrich
|
||||||
|
// // fprintf(stdout, "Energybin: %d, energy: %f\n", ebin, energy_eV);
|
||||||
|
// #endif
|
||||||
|
sample_z_negative_crossings(bin_old(0), ebin) += weight;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
} else if (bin_new(1) > bin_old(1)) {
|
||||||
|
z_positive_crossings(bin_old(0), bin_new(1)) += weight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// does not work correctly if \Delta t*v_phi > pi*r!
|
||||||
void CurrentCollector::collectAzimuthalMovement(
|
void CurrentCollector::collectAzimuthalMovement(
|
||||||
const blitz::TinyVector<int, 3>& bin_old,
|
const blitz::TinyVector<double, 3>& old_pos_cart,
|
||||||
const blitz::TinyVector<int, 3>& bin_new,
|
const blitz::TinyVector<double, 3>& new_pos_cart,
|
||||||
|
const blitz::TinyVector<int, 2>& bin_old,
|
||||||
const double weight) {
|
const double weight) {
|
||||||
if ((bin_new(1) < bin_old(1)) ||
|
if(old_pos_cart(0) < 0 && new_pos_cart(0) < 0) {
|
||||||
((bin_old(1) == 0) &&
|
return;
|
||||||
(bin_new(1) == position_binning_.binIndexMax()(1)))) {
|
}
|
||||||
phi_negative_crossings(bin_old(0), bin_new(1), bin_old(2)) += weight;
|
if(old_pos_cart(1) > 0 && new_pos_cart(1) < 0) {
|
||||||
} else if ((bin_new(1) > bin_old(1)) ||
|
phi_negative_crossings(bin_old) += weight;
|
||||||
((bin_old(1) == position_binning_.binIndexMax()(1)) &&
|
} else if (old_pos_cart(1) < 0 && new_pos_cart(1) > 0) {
|
||||||
(bin_new(1) == 0))) {
|
phi_positive_crossings(bin_old) += weight;
|
||||||
phi_positive_crossings(bin_old(0), bin_new(1) - 1, bin_old(2)) += weight;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> CurrentCollector::negativeCrossingsInZ() const {
|
blitz::Array<double, 2> CurrentCollector::negativeCrossingsInZ() const {
|
||||||
return z_negative_crossings;
|
return z_negative_crossings;
|
||||||
}
|
}
|
||||||
blitz::Array<double, 3> CurrentCollector::positiveCrossingsInZ() const {
|
blitz::Array<double, 2> CurrentCollector::positiveCrossingsInZ() const {
|
||||||
return z_positive_crossings;
|
return z_positive_crossings;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> CurrentCollector::negativeCrossingsInPhi() const {
|
blitz::Array<double, 2> CurrentCollector::negativeCrossingsInPhi() const {
|
||||||
return phi_negative_crossings;
|
return phi_negative_crossings;
|
||||||
}
|
}
|
||||||
blitz::Array<double, 3> CurrentCollector::positiveCrossingsInPhi() const {
|
blitz::Array<double, 2> CurrentCollector::positiveCrossingsInPhi() const {
|
||||||
return phi_positive_crossings;
|
return phi_positive_crossings;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> CurrentCollector::negativeCrossingsInR() const {
|
blitz::Array<double, 2> CurrentCollector::negativeCrossingsInR() const {
|
||||||
return r_negative_crossings;
|
return r_negative_crossings;
|
||||||
}
|
}
|
||||||
blitz::Array<double, 3> CurrentCollector::positiveCrossingsInR() const {
|
blitz::Array<double, 2> CurrentCollector::positiveCrossingsInR() const {
|
||||||
return r_positive_crossings;
|
return r_positive_crossings;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> CurrentCollector::areaInR() const {
|
blitz::Array<double, 2> CurrentCollector::areaInR() const {
|
||||||
return collector_areas_r;
|
return collector_areas_r;
|
||||||
}
|
}
|
||||||
blitz::Array<double, 3> CurrentCollector::areaInPhi() const {
|
blitz::Array<double, 2> CurrentCollector::areaInPhi() const {
|
||||||
return collector_areas_phi;
|
return collector_areas_phi;
|
||||||
}
|
}
|
||||||
blitz::Array<double, 3> CurrentCollector::areaInZ() const {
|
blitz::Array<double, 2> CurrentCollector::areaInZ() const {
|
||||||
return collector_areas_z;
|
return collector_areas_z;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> CurrentCollector::currentInZ() const {
|
blitz::Array<double, 2> CurrentCollector::currentInZ() const {
|
||||||
blitz::Array<double, 3> current_in_z = z_positive_crossings.copy();
|
blitz::Array<double, 2> current_in_z = z_positive_crossings.copy();
|
||||||
current_in_z(blitz::Range::all(), blitz::Range::all(), blitz::Range::all()) =
|
current_in_z(blitz::Range::all(), blitz::Range::all()) =
|
||||||
(z_positive_crossings(blitz::Range::all(), blitz::Range::all(),
|
(z_positive_crossings(blitz::Range::all(), blitz::Range::all()) -
|
||||||
blitz::Range::all()) -
|
z_negative_crossings(blitz::Range::all(), blitz::Range::all())) /
|
||||||
z_negative_crossings(blitz::Range::all(), blitz::Range::all(),
|
|
||||||
blitz::Range::all())) /
|
|
||||||
(physicalTime() * collector_areas_z(blitz::Range::all(),
|
(physicalTime() * collector_areas_z(blitz::Range::all(),
|
||||||
blitz::Range::all(),
|
|
||||||
blitz::Range::all()));
|
blitz::Range::all()));
|
||||||
return current_in_z;
|
return current_in_z;
|
||||||
}
|
}
|
||||||
blitz::Array<double, 3> CurrentCollector::currentInPhi() const {
|
|
||||||
blitz::Array<double, 3> current_in_phi = phi_positive_crossings.copy();
|
// does not work due to wrong phi_{positive/negative}_crossings
|
||||||
current_in_phi(blitz::Range::all(), blitz::Range::all(),
|
blitz::Array<double, 2> CurrentCollector::currentInPhi() const {
|
||||||
blitz::Range::all()) =
|
blitz::Array<double, 2> current_in_phi = phi_positive_crossings.copy();
|
||||||
(phi_positive_crossings(blitz::Range::all(), blitz::Range::all(),
|
current_in_phi(blitz::Range::all(), blitz::Range::all()) =
|
||||||
blitz::Range::all()) -
|
(phi_positive_crossings(blitz::Range::all(), blitz::Range::all()) -
|
||||||
phi_negative_crossings(blitz::Range::all(), blitz::Range::all(),
|
phi_negative_crossings(blitz::Range::all(), blitz::Range::all())) /
|
||||||
blitz::Range::all())) /
|
|
||||||
(physicalTime() * collector_areas_phi(blitz::Range::all(),
|
(physicalTime() * collector_areas_phi(blitz::Range::all(),
|
||||||
blitz::Range::all(),
|
|
||||||
blitz::Range::all()));
|
blitz::Range::all()));
|
||||||
return current_in_phi;
|
return current_in_phi;
|
||||||
}
|
}
|
||||||
blitz::Array<double, 3> CurrentCollector::currentInR() const {
|
|
||||||
blitz::Array<double, 3> current_in_r = r_positive_crossings.copy();
|
blitz::Array<double, 2> CurrentCollector::currentInR() const {
|
||||||
current_in_r(blitz::Range::all(), blitz::Range::all(), blitz::Range::all()) =
|
blitz::Array<double, 2> current_in_r = r_positive_crossings.copy();
|
||||||
(r_positive_crossings(blitz::Range::all(), blitz::Range::all(),
|
current_in_r(blitz::Range::all(), blitz::Range::all()) =
|
||||||
blitz::Range::all()) -
|
(r_positive_crossings(blitz::Range::all(), blitz::Range::all()) -
|
||||||
r_negative_crossings(blitz::Range::all(), blitz::Range::all(),
|
r_negative_crossings(blitz::Range::all(), blitz::Range::all())) /
|
||||||
blitz::Range::all())) /
|
|
||||||
(physicalTime() * collector_areas_r(blitz::Range::all(),
|
(physicalTime() * collector_areas_r(blitz::Range::all(),
|
||||||
blitz::Range::all(),
|
|
||||||
blitz::Range::all()));
|
blitz::Range::all()));
|
||||||
return current_in_r;
|
return current_in_r;
|
||||||
}
|
}
|
||||||
|
|
||||||
double CurrentCollector::physicalTime() const {
|
double CurrentCollector::physicalTime() const {
|
||||||
return timer_->getDeltaT();
|
return timer_->getDeltaT();
|
||||||
}
|
}
|
||||||
@@ -265,12 +291,25 @@ void CurrentCollector::resetCurrentCollector() {
|
|||||||
r_negative_crossings = 0.;
|
r_negative_crossings = 0.;
|
||||||
r_positive_crossings = 0.;
|
r_positive_crossings = 0.;
|
||||||
|
|
||||||
// sync_z_negative_crossings = 0.;
|
#ifdef GENRICHCURRENT
|
||||||
// sync_z_positive_crossings = 0.;
|
if(needs_reset) {
|
||||||
|
sample_z_negative_crossings = 0.;
|
||||||
// sync_phi_negative_crossings = 0.;
|
needs_reset = false;
|
||||||
// sync_phi_positive_crossings = 0.;
|
time_since_reset = timer_->getDeltaT();
|
||||||
|
} else {
|
||||||
// sync_r_negative_crossings = 0.;
|
time_since_reset += timer_->getDeltaT();
|
||||||
// sync_r_positive_crossings = 0.;
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef GENRICHCURRENT
|
||||||
|
|
||||||
|
blitz::Array<double, 2> CurrentCollector::sampleNegativeCrossings() const {
|
||||||
|
return sample_z_negative_crossings;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<double> CurrentCollector::energyBinBorders() const {
|
||||||
|
return energy_binning_.binBorders();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -9,11 +9,20 @@
|
|||||||
#include "tools/simulation_time.h"
|
#include "tools/simulation_time.h"
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
blitz::Array<T, 4> initiate4DArray(blitz::Range radial,
|
blitz::Array<T, 3> initiate3DArray(blitz::Range radial,
|
||||||
blitz::Range phi,
|
|
||||||
blitz::Range longitudinal,
|
blitz::Range longitudinal,
|
||||||
blitz::Range energy) {
|
blitz::Range energy) {
|
||||||
blitz::Array<T, 4> data(radial, phi, longitudinal, energy);
|
blitz::Array<T, 3> data(radial, longitudinal, energy);
|
||||||
|
data = static_cast<T>(0);
|
||||||
|
return data.copy();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
blitz::Array<T, 4> initiate4DArray(blitz::Range radial,
|
||||||
|
blitz::Range longitudinal,
|
||||||
|
blitz::Range energy,
|
||||||
|
blitz::Range pitchangle) {
|
||||||
|
blitz::Array<T, 4> data(radial, longitudinal, energy, pitchangle);
|
||||||
data = static_cast<T>(0);
|
data = static_cast<T>(0);
|
||||||
return data.copy();
|
return data.copy();
|
||||||
}
|
}
|
||||||
@@ -29,24 +38,23 @@ blitz::Array<T, 5> initiate5DArray(blitz::Range radial,
|
|||||||
return data.copy();
|
return data.copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> initiateVolumeArray(
|
blitz::Array<double, 2> initiateVolumeArray(
|
||||||
blitz::Range radial,
|
blitz::Range radial,
|
||||||
blitz::Range phi,
|
|
||||||
blitz::Range longitudinal,
|
blitz::Range longitudinal,
|
||||||
const blitz::TinyVector<double, 3>& position_spacing) {
|
const blitz::TinyVector<double, 2>& position_spacing) {
|
||||||
blitz::Array<double, 3> volume(radial, phi, longitudinal);
|
blitz::Array<double, 2> volume(radial, longitudinal);
|
||||||
|
|
||||||
for (int ir = 0; ir <= volume.ubound(0); ++ir) {
|
for (int ir = 0; ir <= volume.ubound(0); ++ir) {
|
||||||
const double r1 = ir * position_spacing(0);
|
const double r1 = ir * position_spacing(0);
|
||||||
const double r2 = (ir + 1) * position_spacing(0);
|
const double r2 = (ir + 1) * position_spacing(0);
|
||||||
for (int iz = volume.lbound(2); iz <= volume.ubound(2); ++iz) {
|
for (int iz = volume.lbound(1); iz <= volume.ubound(1); ++iz) {
|
||||||
const double z1 = iz * position_spacing(2);
|
const double z1 = iz * position_spacing(1);
|
||||||
const double z2 = (iz + 1) * position_spacing(2);
|
const double z2 = (iz + 1) * position_spacing(1);
|
||||||
|
|
||||||
const double bin_volume =
|
const double bin_volume =
|
||||||
M_PI * ((r2*r2) - (r1*r1)) * (z2 - z1) / phi.length();
|
M_PI * ((r2*r2) - (r1*r1)) * (z2 - z1);
|
||||||
|
|
||||||
volume(ir, blitz::Range::all(), iz) = bin_volume;
|
volume(ir, iz) = bin_volume;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return volume.copy();
|
return volume.copy();
|
||||||
@@ -61,33 +69,27 @@ DynamicDensityField::DynamicDensityField(
|
|||||||
energy_binning_(energy_binning),
|
energy_binning_(energy_binning),
|
||||||
pitch_angle_binning_(pitch_angle_binning),
|
pitch_angle_binning_(pitch_angle_binning),
|
||||||
timer_(timer),
|
timer_(timer),
|
||||||
time_in_bin_s_(initiate5DArray<double>(
|
number_in_bin_(initiate4DArray<double>(
|
||||||
blitz::Range(position_binning.radial_binning.binIndexMin(),
|
blitz::Range(position_binning.radial_binning.binIndexMin(),
|
||||||
position_binning.radial_binning.binIndexMax()),
|
position_binning.radial_binning.binIndexMax()),
|
||||||
blitz::Range(position_binning.azimuth_binning.binIndexMin(),
|
|
||||||
position_binning.azimuth_binning.binIndexMax()),
|
|
||||||
blitz::Range(position_binning.longitudinal_binning.binIndexMin(),
|
blitz::Range(position_binning.longitudinal_binning.binIndexMin(),
|
||||||
position_binning.longitudinal_binning.binIndexMax()),
|
position_binning.longitudinal_binning.binIndexMax()),
|
||||||
blitz::Range(pitch_angle_binning.binIndexMin(),
|
blitz::Range(pitch_angle_binning.binIndexMin(),
|
||||||
pitch_angle_binning.binIndexMax()),
|
pitch_angle_binning.binIndexMax()),
|
||||||
blitz::Range(energy_binning.binIndexMin(),
|
blitz::Range(energy_binning.binIndexMin(),
|
||||||
energy_binning.binIndexMax()))),
|
energy_binning.binIndexMax()))),
|
||||||
sync_time_in_bin_s_(initiate5DArray<double>(
|
sync_number_in_bin_(initiate4DArray<double>(
|
||||||
blitz::Range(position_binning.radial_binning.binIndexMin(),
|
blitz::Range(position_binning.radial_binning.binIndexMin(),
|
||||||
position_binning.radial_binning.binIndexMax()),
|
position_binning.radial_binning.binIndexMax()),
|
||||||
blitz::Range(position_binning.azimuth_binning.binIndexMin(),
|
|
||||||
position_binning.azimuth_binning.binIndexMax()),
|
|
||||||
blitz::Range(position_binning.longitudinal_binning.binIndexMin(),
|
blitz::Range(position_binning.longitudinal_binning.binIndexMin(),
|
||||||
position_binning.longitudinal_binning.binIndexMax()),
|
position_binning.longitudinal_binning.binIndexMax()),
|
||||||
blitz::Range(pitch_angle_binning.binIndexMin(),
|
blitz::Range(pitch_angle_binning.binIndexMin(),
|
||||||
pitch_angle_binning.binIndexMax()),
|
pitch_angle_binning.binIndexMax()),
|
||||||
blitz::Range(energy_binning.binIndexMin(),
|
blitz::Range(energy_binning.binIndexMin(),
|
||||||
energy_binning.binIndexMax()))),
|
energy_binning.binIndexMax()))),
|
||||||
density_per_m3_(initiate4DArray<double>(
|
density_per_m3_(initiate3DArray<double>(
|
||||||
blitz::Range(position_binning.radial_binning.binIndexMin(),
|
blitz::Range(position_binning.radial_binning.binIndexMin(),
|
||||||
position_binning.radial_binning.binIndexMax()),
|
position_binning.radial_binning.binIndexMax()),
|
||||||
blitz::Range(position_binning.azimuth_binning.binIndexMin(),
|
|
||||||
position_binning.azimuth_binning.binIndexMax()),
|
|
||||||
blitz::Range(position_binning.longitudinal_binning.binIndexMin(),
|
blitz::Range(position_binning.longitudinal_binning.binIndexMin(),
|
||||||
position_binning.longitudinal_binning.binIndexMax()),
|
position_binning.longitudinal_binning.binIndexMax()),
|
||||||
blitz::Range(energy_binning.binIndexMin(),
|
blitz::Range(energy_binning.binIndexMin(),
|
||||||
@@ -95,8 +97,6 @@ DynamicDensityField::DynamicDensityField(
|
|||||||
bin_volume_m3_(initiateVolumeArray(
|
bin_volume_m3_(initiateVolumeArray(
|
||||||
blitz::Range(position_binning.radial_binning.binIndexMin(),
|
blitz::Range(position_binning.radial_binning.binIndexMin(),
|
||||||
position_binning.radial_binning.binIndexMax()),
|
position_binning.radial_binning.binIndexMax()),
|
||||||
blitz::Range(position_binning.azimuth_binning.binIndexMin(),
|
|
||||||
position_binning.azimuth_binning.binIndexMax()),
|
|
||||||
blitz::Range(position_binning.longitudinal_binning.binIndexMin(),
|
blitz::Range(position_binning.longitudinal_binning.binIndexMin(),
|
||||||
position_binning.longitudinal_binning.binIndexMax()),
|
position_binning.longitudinal_binning.binIndexMax()),
|
||||||
position_binning.stepsize())) {
|
position_binning.stepsize())) {
|
||||||
@@ -106,7 +106,7 @@ DynamicDensityField::DynamicDensityField(
|
|||||||
}
|
}
|
||||||
|
|
||||||
double DynamicDensityField::density(const Coordinate& position) {
|
double DynamicDensityField::density(const Coordinate& position) {
|
||||||
const blitz::TinyVector<int, 3> position_bin =
|
const blitz::TinyVector<int, 2> position_bin =
|
||||||
position_binning_.bin(position.cylinderEntries());
|
position_binning_.bin(position.cylinderEntries());
|
||||||
|
|
||||||
#ifdef debug_level1
|
#ifdef debug_level1
|
||||||
@@ -117,7 +117,7 @@ double DynamicDensityField::density(const Coordinate& position) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return blitz::sum(density_per_m3_(position_bin(0), position_bin(1), position_bin(2),
|
return blitz::sum(density_per_m3_(position_bin(0), position_bin(1),
|
||||||
blitz::Range::all()));
|
blitz::Range::all()));
|
||||||
|
|
||||||
/*/
|
/*/
|
||||||
@@ -136,33 +136,31 @@ double DynamicDensityField::density(const Coordinate& position) {
|
|||||||
|
|
||||||
double DynamicDensityField::density(const Coordinate& position,
|
double DynamicDensityField::density(const Coordinate& position,
|
||||||
double energy_eV) {
|
double energy_eV) {
|
||||||
const blitz::TinyVector<int, 3> position_bin =
|
const blitz::TinyVector<int, 2> position_bin =
|
||||||
position_binning_.bin(position.cylinderEntries());
|
position_binning_.bin(position.cylinderEntries());
|
||||||
|
|
||||||
const int energy_bin = energy_binning_.bin(energy_eV);
|
const int energy_bin = energy_binning_.bin(energy_eV);
|
||||||
// const double t = timer_->getDeltaT();
|
// const double t = timer_->getDeltaT();
|
||||||
const double time_in_bin = blitz::sum(time_in_bin_s_(
|
const double number_in_bin = blitz::sum(number_in_bin_(
|
||||||
position_bin(0), position_bin(1), position_bin(2),
|
position_bin(0), position_bin(1), blitz::Range::all(), energy_bin));
|
||||||
blitz::Range::all(), energy_bin));
|
|
||||||
// const long deleted_particles = blitz::sum(deleted_particles_(
|
// const long deleted_particles = blitz::sum(deleted_particles_(
|
||||||
// position_bin(0), position_bin(1), position_bin(2),
|
// position_bin(0), position_bin(1), position_bin(2),
|
||||||
// blitz::Range::all(), energy_bin));
|
// blitz::Range::all(), energy_bin));
|
||||||
|
|
||||||
return (time_in_bin) / // - deleted_particles) /
|
return (number_in_bin) / // - deleted_particles) /
|
||||||
bin_volume_m3_(position_bin(0), position_bin(1), position_bin(2));
|
bin_volume_m3_(position_bin(0), position_bin(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DynamicDensityField::changedPositionBin(
|
bool DynamicDensityField::changedPositionBin(
|
||||||
const Coordinate& old_position,
|
const Coordinate& old_position,
|
||||||
const Coordinate& new_position) const {
|
const Coordinate& new_position) const {
|
||||||
const blitz::TinyVector<int, 3> old_bin =
|
const blitz::TinyVector<int, 2> old_bin =
|
||||||
position_binning_.bin(old_position.cylinderEntries());
|
position_binning_.bin(old_position.cylinderEntries());
|
||||||
|
|
||||||
const blitz::TinyVector<int, 3> new_bin =
|
const blitz::TinyVector<int, 2> new_bin =
|
||||||
position_binning_.bin(new_position.cylinderEntries());
|
position_binning_.bin(new_position.cylinderEntries());
|
||||||
|
|
||||||
return !((old_bin(0) == new_bin(0)) && (old_bin(1) == new_bin(1)) &&
|
return !((old_bin(0) == new_bin(0)) && (old_bin(1) == new_bin(1)));
|
||||||
(old_bin(2) == new_bin(2)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DynamicDensityField::changedEnergyBin(double old_energy_eV,
|
bool DynamicDensityField::changedEnergyBin(double old_energy_eV,
|
||||||
@@ -194,50 +192,48 @@ void DynamicDensityField::logMovement(const Coordinate& position,
|
|||||||
double pitch_angle,
|
double pitch_angle,
|
||||||
double weight) {
|
double weight) {
|
||||||
|
|
||||||
const blitz::TinyVector<int, 3> position_bin =
|
const blitz::TinyVector<int, 2> position_bin =
|
||||||
position_binning_.bin(position.cylinderEntries());
|
position_binning_.bin(position.cylinderEntries());
|
||||||
const int energy_bin = energy_binning_.bin(energy_eV);
|
const int energy_bin = energy_binning_.bin(energy_eV);
|
||||||
const int pitch_angle_bin = pitch_angle_binning_.bin(pitch_angle);
|
const int pitch_angle_bin = pitch_angle_binning_.bin(pitch_angle);
|
||||||
|
|
||||||
sync_time_in_bin_s_(position_bin(0), position_bin(1), position_bin(2),
|
sync_number_in_bin_(position_bin(0), position_bin(1),
|
||||||
pitch_angle_bin, energy_bin) += weight;
|
pitch_angle_bin, energy_bin) += weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 3> DynamicDensityField::densityArray() {
|
blitz::Array<double, 2> DynamicDensityField::densityArray() {
|
||||||
#ifdef debug_level3
|
#ifdef debug_level3
|
||||||
DEBUG_LEVEL_3("recalc Density array");
|
DEBUG_LEVEL_3("recalc Density array");
|
||||||
#endif
|
#endif
|
||||||
// recalculated after a timestep reset (as of now hope that's enough and works correctly)
|
// recalculated after a timestep reset (as of now hope that's enough and works correctly)
|
||||||
// recalculateDensityArray();
|
// recalculateDensityArray();
|
||||||
|
|
||||||
blitz::TinyVector<int,3> lowerbound(density_per_m3_.lbound(0),
|
blitz::TinyVector<int,2> lowerbound(density_per_m3_.lbound(0),
|
||||||
density_per_m3_.lbound(1),
|
density_per_m3_.lbound(1));
|
||||||
density_per_m3_.lbound(2));
|
blitz::TinyVector<int,2> extent(density_per_m3_.extent(0),
|
||||||
blitz::TinyVector<int,3> extent(density_per_m3_.extent(0),
|
density_per_m3_.extent(1));
|
||||||
density_per_m3_.extent(1),
|
blitz::Array<double, 2> density(lowerbound, extent);
|
||||||
density_per_m3_.extent(2));
|
|
||||||
blitz::Array<double, 3> density(lowerbound, extent);
|
|
||||||
|
|
||||||
blitz::fourthIndex iE;
|
blitz::thirdIndex iE;
|
||||||
// DEBUG_LEVEL_3("density sum");
|
// DEBUG_LEVEL_3("density sum");
|
||||||
density = blitz::sum(density_per_m3_, iE);
|
density = blitz::sum(density_per_m3_, iE);
|
||||||
return density.copy();
|
return density.copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 4> DynamicDensityField::spectrumArray() {
|
blitz::Array<double, 3> DynamicDensityField::spectrumArray() {
|
||||||
// recalculateDensityArray();
|
// recalculateDensityArray();
|
||||||
return density_per_m3_;
|
return density_per_m3_;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 5> DynamicDensityField::timeInBinArray() const {
|
blitz::Array<double, 4> DynamicDensityField::numberInBinArray() const {
|
||||||
return time_in_bin_s_;
|
return number_in_bin_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// blitz::Array<long int, 5> DynamicDensityField::deletedParticlesArray() const {
|
// blitz::Array<long int, 5> DynamicDensityField::deletedParticlesArray() const {
|
||||||
// return deleted_particles_;
|
// return deleted_particles_;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
blitz::Array<double, 3> DynamicDensityField::binVolumeArray() const {
|
blitz::Array<double, 2> DynamicDensityField::binVolumeArray() const {
|
||||||
return bin_volume_m3_;
|
return bin_volume_m3_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,18 +260,17 @@ double DynamicDensityField::timeResolution() const {
|
|||||||
void DynamicDensityField::recalculateDensityArray() {
|
void DynamicDensityField::recalculateDensityArray() {
|
||||||
// SimulationTimer::eventStartPoint("recalcDensityArray");
|
// SimulationTimer::eventStartPoint("recalcDensityArray");
|
||||||
blitz::firstIndex ir;
|
blitz::firstIndex ir;
|
||||||
blitz::secondIndex iphi;
|
blitz::secondIndex iz;
|
||||||
blitz::thirdIndex iz;
|
blitz::thirdIndex ipitch;
|
||||||
blitz::fourthIndex ipitch;
|
blitz::fourthIndex iE;
|
||||||
blitz::fifthIndex iE;
|
|
||||||
|
|
||||||
// reduction only seems to work for the last dimension (iE)
|
// reduction only seems to work for the last dimension (iE)
|
||||||
// -> first reorder (by exchanging iE and ipitch) and afterwards doing
|
// -> first reorder (by exchanging iE and ipitch) and afterwards doing
|
||||||
// the reduction over iE (which now contains the pitch dimension)
|
// the reduction over iE (which now contains the pitch dimension)
|
||||||
// blitz::Array<double, 5> temp((time_in_bin_s_(ir, iphi, iz, ipitch, iE)));
|
// blitz::Array<double, 5> temp((time_in_bin_s_(ir, iphi, iz, ipitch, iE)));
|
||||||
|
|
||||||
density_per_m3_ = blitz::sum((time_in_bin_s_(ir, iphi, iz, iE, ipitch)), iE) /
|
density_per_m3_ = blitz::sum((number_in_bin_(ir, iz, iE, ipitch)), iE) /
|
||||||
bin_volume_m3_(ir, iphi, iz);
|
bin_volume_m3_(ir, iz);
|
||||||
// SimulationTimer::eventStopPoint("recalcDensityArray");
|
// SimulationTimer::eventStopPoint("recalcDensityArray");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,7 +278,7 @@ void DynamicDensityField::recalculateDensityArray() {
|
|||||||
// particle number
|
// particle number
|
||||||
blitz::Array<double, 1> DynamicDensityField::sliceSpectrumArray(
|
blitz::Array<double, 1> DynamicDensityField::sliceSpectrumArray(
|
||||||
const Coordinate& position) const {
|
const Coordinate& position) const {
|
||||||
blitz::TinyVector<int, 3> position_bin =
|
blitz::TinyVector<int, 2> position_bin =
|
||||||
position_binning_.bin(position.cylinderEntries());
|
position_binning_.bin(position.cylinderEntries());
|
||||||
|
|
||||||
// blitz::Array<double, 4> check = density_per_m3_.copy();
|
// blitz::Array<double, 4> check = density_per_m3_.copy();
|
||||||
@@ -292,25 +287,25 @@ blitz::Array<double, 1> DynamicDensityField::sliceSpectrumArray(
|
|||||||
// ERROR("splice specturm array: check failed.");
|
// ERROR("splice specturm array: check failed.");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
return density_per_m3_(position_bin(0), position_bin(1), position_bin(2),
|
return density_per_m3_(position_bin(0), position_bin(1),
|
||||||
blitz::Range(energy_binning_.binIndexMin(),
|
blitz::Range(energy_binning_.binIndexMin(),
|
||||||
energy_binning_.binIndexMax()-1));
|
energy_binning_.binIndexMax()-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::Array<double, 1> DynamicDensityField::sliceTimeInBinArray(
|
blitz::Array<double, 1> DynamicDensityField::sliceNumberInBinArray(
|
||||||
const Coordinate& position, double energy_eV) const {
|
const Coordinate& position, double energy_eV) const {
|
||||||
blitz::TinyVector<int, 3> position_bin =
|
blitz::TinyVector<int, 2> position_bin =
|
||||||
position_binning_.bin(position.cylinderEntries());
|
position_binning_.bin(position.cylinderEntries());
|
||||||
int energy_bin = energy_binning_.bin(energy_eV);
|
int energy_bin = energy_binning_.bin(energy_eV);
|
||||||
|
|
||||||
return time_in_bin_s_(position_bin(0), position_bin(1), position_bin(2),
|
return number_in_bin_(position_bin(0), position_bin(1),
|
||||||
blitz::Range(0, pitch_angle_binning_.binIndexMax()-1),
|
blitz::Range(0, pitch_angle_binning_.binIndexMax()-1),
|
||||||
energy_bin);
|
energy_bin);
|
||||||
}
|
}
|
||||||
|
|
||||||
// resets the field that logs the new density
|
// resets the field that logs the new density
|
||||||
void DynamicDensityField::resetDynamicDensityField() {
|
void DynamicDensityField::resetDynamicDensityField() {
|
||||||
sync_time_in_bin_s_ = 0.;
|
sync_number_in_bin_ = 0.;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicDensityField::restartTimer(double time, double delta_t) {
|
void DynamicDensityField::restartTimer(double time, double delta_t) {
|
||||||
@@ -324,15 +319,15 @@ void DynamicDensityField::restartTimer(double time, double delta_t) {
|
|||||||
timer_->setDeltaT(delta_t);
|
timer_->setDeltaT(delta_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicDensityField::restartTimeInBin(blitz::Array<double, 5> time_in_bin) {
|
void DynamicDensityField::restartNumberInBin(blitz::Array<double, 4> number_in_bin) {
|
||||||
if(!blitz::all(time_in_bin_s_.length() == time_in_bin.length())) {
|
if(!blitz::all(number_in_bin_.length() == number_in_bin.length())) {
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
out << "Expected a size of " << time_in_bin_s_.length();
|
out << "Expected a size of " << number_in_bin_.length();
|
||||||
out << ", received a length of " << time_in_bin.length();
|
out << ", received a length of " << number_in_bin.length();
|
||||||
out << " for time_in_bin array";
|
out << " for time_in_bin array";
|
||||||
ERROR(out.str());
|
ERROR(out.str());
|
||||||
}
|
}
|
||||||
time_in_bin_s_ = time_in_bin.copy().reindex(time_in_bin_s_.lbound());
|
number_in_bin_ = number_in_bin.copy().reindex(number_in_bin_.lbound());
|
||||||
}
|
}
|
||||||
|
|
||||||
// void DynamicDensityField::restartDeletedParticlesArray(
|
// void DynamicDensityField::restartDeletedParticlesArray(
|
||||||
|
|||||||
@@ -27,6 +27,31 @@ double TritiumBetaDecay::rollEnergy(std::mt19937* engine) {
|
|||||||
return random_number_x;
|
return random_number_x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// endpoint_eV is the recoil energy of the target species for an electron
|
||||||
|
// energy at 18.6keV (i.e. the endpoint energy of the electron distribution)
|
||||||
|
TritiumBetaDecayIon::TritiumBetaDecayIon(double endpoint_eV)
|
||||||
|
: x_distribution_(
|
||||||
|
std::uniform_real_distribution<double>(0., T2BetaDecay::E0_T)),
|
||||||
|
y_distribution_(std::uniform_real_distribution<double>(
|
||||||
|
0.,
|
||||||
|
T2BetaDecay::spectrum_maximum)),
|
||||||
|
tritium_spectrum_(tritiumDecayEnergySpectrum(1.)),
|
||||||
|
tritium_spectrum_ion_(tritiumDecayEnergySpectrumIon(endpoint_eV)) {}
|
||||||
|
|
||||||
|
// due to not great structure, draw a(nother) electron energy to inject
|
||||||
|
// the ion at the corresponding (approximated) energy
|
||||||
|
double TritiumBetaDecayIon::rollEnergy(std::mt19937* engine) {
|
||||||
|
double random_number_x;
|
||||||
|
double random_number_y;
|
||||||
|
double return_value;
|
||||||
|
do {
|
||||||
|
random_number_x = x_distribution_(*engine);
|
||||||
|
random_number_y = y_distribution_(*engine);
|
||||||
|
} while (random_number_y > tritium_spectrum_(random_number_x));
|
||||||
|
|
||||||
|
return tritium_spectrum_ion_(random_number_x);
|
||||||
|
}
|
||||||
|
|
||||||
MaxwellBoltzmann::MaxwellBoltzmann(double temperature_K)
|
MaxwellBoltzmann::MaxwellBoltzmann(double temperature_K)
|
||||||
: distribution_(std::gamma_distribution<double>(
|
: distribution_(std::gamma_distribution<double>(
|
||||||
3. / 2.,
|
3. / 2.,
|
||||||
|
|||||||
@@ -19,12 +19,12 @@ BorisMover::BorisMover(double maximal_time_step_s)
|
|||||||
"The maximal timestep for boris push must be positive.");
|
"The maximal timestep for boris push must be positive.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void BorisMover::move(particle::Particle* particle,
|
CylinderCoordinate BorisMover::move(particle::Particle* particle,
|
||||||
double collision_time_s,
|
double collision_time_s,
|
||||||
ElectricField* electric_field,
|
ElectricField* electric_field,
|
||||||
MagneticField* magnetic_field,
|
MagneticField* magnetic_field,
|
||||||
GravityField* gravity_field) {
|
GravityField* gravity_field) {
|
||||||
|
// DEBUG("start mover");
|
||||||
// only useful if the timescale defined by the gyro frequency allows fast particles
|
// only useful if the timescale defined by the gyro frequency allows fast particles
|
||||||
// to move too far
|
// to move too far
|
||||||
// keep hard coded for now; has to be decided to be either kept (new field for Boris
|
// keep hard coded for now; has to be decided to be either kept (new field for Boris
|
||||||
@@ -46,6 +46,17 @@ void BorisMover::move(particle::Particle* particle,
|
|||||||
|
|
||||||
blitz::TinyVector<double, 3> B =
|
blitz::TinyVector<double, 3> B =
|
||||||
magnetic_field->value(old_position_cyl).cartesianEntries(old_position_cart);
|
magnetic_field->value(old_position_cyl).cartesianEntries(old_position_cart);
|
||||||
|
blitz::TinyVector<double, 3> E;
|
||||||
|
if(particle->areLocalFieldsSet()) {
|
||||||
|
// In case of spatially variable magnetic fields use the one at the "actual" particle
|
||||||
|
// position, since that value is not dependent on the particles itself
|
||||||
|
// B = particle->getLocalB();
|
||||||
|
E = particle->getLocalE();
|
||||||
|
} else {
|
||||||
|
B = magnetic_field->value(old_position_cyl).cartesianEntries(old_position_cart);
|
||||||
|
E = electric_field->value(old_position_cyl).cartesianEntries(old_position_cart);
|
||||||
|
particle->setLocalFields(E, B);
|
||||||
|
}
|
||||||
|
|
||||||
// double old_mu;
|
// double old_mu;
|
||||||
// double new_mu;
|
// double new_mu;
|
||||||
@@ -81,8 +92,8 @@ void BorisMover::move(particle::Particle* particle,
|
|||||||
timestep = std::min(timestep, max_distance / old_velocity);
|
timestep = std::min(timestep, max_distance / old_velocity);
|
||||||
timestep = std::min(timestep, max_time_alive);
|
timestep = std::min(timestep, max_time_alive);
|
||||||
|
|
||||||
const blitz::TinyVector<double, 3> E =
|
// const blitz::TinyVector<double, 3> E =
|
||||||
electric_field->value(old_position_cyl).cartesianEntries(old_position_cart);
|
// electric_field->value(old_position_cyl).cartesianEntries(old_position_cart);
|
||||||
const blitz::TinyVector<double, 3> g =
|
const blitz::TinyVector<double, 3> g =
|
||||||
gravity_field->value(old_position_cyl).cartesianEntries(old_position_cart);
|
gravity_field->value(old_position_cyl).cartesianEntries(old_position_cart);
|
||||||
|
|
||||||
@@ -116,7 +127,7 @@ void BorisMover::move(particle::Particle* particle,
|
|||||||
old_kinetic_energy, particle->kineticEnergy_eV());
|
old_kinetic_energy, particle->kineticEnergy_eV());
|
||||||
|
|
||||||
left_simulation_domain =
|
left_simulation_domain =
|
||||||
particle->specie()->terminator()->leftSimulationDomain(particle);
|
particle->specie()->terminator()->leftSimulationDomain(particle, old_position_cyl);
|
||||||
|
|
||||||
died_in_bin =
|
died_in_bin =
|
||||||
particle->specie()->terminator()->reachedMaxTimeAlive(particle);
|
particle->specie()->terminator()->reachedMaxTimeAlive(particle);
|
||||||
@@ -177,7 +188,9 @@ void BorisMover::move(particle::Particle* particle,
|
|||||||
DEBUG(out.str());
|
DEBUG(out.str());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
particle->specie()->currentCollector()->collect(particle, old_position_cyl);
|
particle->specie()->currentCollector()->collect(particle, old_position_cart);
|
||||||
|
return old_position_cyl;
|
||||||
|
// DEBUG("end mover");
|
||||||
}
|
}
|
||||||
|
|
||||||
void BorisMover::movementStep(
|
void BorisMover::movementStep(
|
||||||
@@ -279,7 +292,7 @@ void BorisMover::movementStep(
|
|||||||
DriftMover::DriftMover(double maximal_distance)
|
DriftMover::DriftMover(double maximal_distance)
|
||||||
: maximal_distance_m_(maximal_distance){};
|
: maximal_distance_m_(maximal_distance){};
|
||||||
|
|
||||||
void DriftMover::move(particle::Particle* particle,
|
CylinderCoordinate DriftMover::move(particle::Particle* particle,
|
||||||
double collision_time_s,
|
double collision_time_s,
|
||||||
ElectricField* electric_field,
|
ElectricField* electric_field,
|
||||||
MagneticField* magnetic_field,
|
MagneticField* magnetic_field,
|
||||||
@@ -490,7 +503,7 @@ void DriftMover::move(particle::Particle* particle,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
left_simulation_domain =
|
left_simulation_domain =
|
||||||
particle->specie()->terminator()->leftSimulationDomain(particle);
|
particle->specie()->terminator()->leftSimulationDomain(particle, old_position_cyl);
|
||||||
|
|
||||||
leftover_time -= timestep;
|
leftover_time -= timestep;
|
||||||
particle->reduceTimeUntilCollision(timestep);
|
particle->reduceTimeUntilCollision(timestep);
|
||||||
@@ -504,6 +517,7 @@ void DriftMover::move(particle::Particle* particle,
|
|||||||
particle->weight());
|
particle->weight());
|
||||||
}
|
}
|
||||||
particle->specie()->currentCollector()->collect(particle, old_position_cyl);
|
particle->specie()->currentCollector()->collect(particle, old_position_cyl);
|
||||||
|
return old_position_cyl;
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::TinyVector<double, 3> DriftMover::driftVelocity(
|
blitz::TinyVector<double, 3> DriftMover::driftVelocity(
|
||||||
|
|||||||
@@ -211,6 +211,25 @@ void Particle::reduceTimeUntilCollision(double delta) {
|
|||||||
time_until_collision_ -= delta;
|
time_until_collision_ -= delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Particle::setLocalFields(const blitz::TinyVector<double, 3>& E,
|
||||||
|
const blitz::TinyVector<double, 3>& B) {
|
||||||
|
local_E_cart_ = E;
|
||||||
|
local_B_cart_ = B;
|
||||||
|
set_local_fields_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
blitz::TinyVector<double, 3> Particle::getLocalE() const {
|
||||||
|
return local_E_cart_;
|
||||||
|
}
|
||||||
|
|
||||||
|
blitz::TinyVector<double, 3> Particle::getLocalB() const {
|
||||||
|
return local_B_cart_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Particle::areLocalFieldsSet() const {
|
||||||
|
return set_local_fields_;
|
||||||
|
}
|
||||||
|
|
||||||
particle::SerializedParticle Particle::serialize() {
|
particle::SerializedParticle Particle::serialize() {
|
||||||
return particle::SerializedParticle(weight_,
|
return particle::SerializedParticle(weight_,
|
||||||
position_cart_.cartesianEntries(), velocity_.cartesianEntries(),
|
position_cart_.cartesianEntries(), velocity_.cartesianEntries(),
|
||||||
|
|||||||
@@ -117,46 +117,40 @@ int BinningWithOverAndUnderflow::binIndexMax() const {
|
|||||||
|
|
||||||
CylinderBinning::CylinderBinning(int num_bins_radial,
|
CylinderBinning::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)
|
||||||
: radial_binning(num_bins_radial, radius),
|
: radial_binning(num_bins_radial, radius),
|
||||||
azimuth_binning(num_bins_azimuthal, 2 * M_PI),
|
|
||||||
longitudinal_binning(num_bins_longitudinal, height) {}
|
longitudinal_binning(num_bins_longitudinal, height) {}
|
||||||
|
|
||||||
blitz::TinyVector<int, 3> CylinderBinning::bin(
|
blitz::TinyVector<int, 2> CylinderBinning::bin(
|
||||||
const blitz::TinyVector<double, 3>& cylinder_position) const {
|
const blitz::TinyVector<double, 3>& cylinder_position) const {
|
||||||
return blitz::TinyVector<int, 3>(
|
return blitz::TinyVector<int, 2>(
|
||||||
radial_binning.bin(cylinder_position(0)),
|
radial_binning.bin(cylinder_position(0)),
|
||||||
azimuth_binning.bin(cylinder_position(1)),
|
|
||||||
longitudinal_binning.bin(cylinder_position(2)));
|
longitudinal_binning.bin(cylinder_position(2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::TinyVector<int, 3> CylinderBinning::numBins() const {
|
blitz::TinyVector<int, 2> CylinderBinning::numBins() const {
|
||||||
return blitz::TinyVector<int, 3>(
|
return blitz::TinyVector<int, 2>(
|
||||||
radial_binning.numBinsWithoutOverflow(), azimuth_binning.numBins(),
|
radial_binning.numBinsWithoutOverflow(),
|
||||||
longitudinal_binning.numBinsWithoutOverUnderflow());
|
longitudinal_binning.numBinsWithoutOverUnderflow());
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::TinyVector<double, 3> CylinderBinning::stepsize() const {
|
blitz::TinyVector<double, 2> CylinderBinning::stepsize() const {
|
||||||
return blitz::TinyVector<double, 3>(radial_binning.stepsize(),
|
return blitz::TinyVector<double, 2>(radial_binning.stepsize(),
|
||||||
azimuth_binning.stepsize(),
|
|
||||||
longitudinal_binning.stepsize());
|
longitudinal_binning.stepsize());
|
||||||
}
|
}
|
||||||
|
|
||||||
blitz::TinyVector<int, 3> CylinderBinning::numBinsIncludingOverUnderflow()
|
blitz::TinyVector<int, 2> CylinderBinning::numBinsIncludingOverUnderflow()
|
||||||
const {
|
const {
|
||||||
return blitz::TinyVector<int, 3>(
|
return blitz::TinyVector<int, 2>(
|
||||||
radial_binning.numBinsWithOverflow(), azimuth_binning.numBins(),
|
radial_binning.numBinsWithOverflow(),
|
||||||
longitudinal_binning.numBinsWithOverUnderflow());
|
longitudinal_binning.numBinsWithOverUnderflow());
|
||||||
}
|
}
|
||||||
blitz::TinyVector<int, 3> CylinderBinning::binIndexMin() const {
|
blitz::TinyVector<int, 2> CylinderBinning::binIndexMin() const {
|
||||||
return blitz::TinyVector<int, 3>(radial_binning.binIndexMin(),
|
return blitz::TinyVector<int, 2>(radial_binning.binIndexMin(),
|
||||||
azimuth_binning.binIndexMin(),
|
|
||||||
longitudinal_binning.binIndexMin());
|
longitudinal_binning.binIndexMin());
|
||||||
}
|
}
|
||||||
blitz::TinyVector<int, 3> CylinderBinning::binIndexMax() const {
|
blitz::TinyVector<int, 2> CylinderBinning::binIndexMax() const {
|
||||||
return blitz::TinyVector<int, 3>(radial_binning.binIndexMax(),
|
return blitz::TinyVector<int, 2>(radial_binning.binIndexMax(),
|
||||||
azimuth_binning.binIndexMax(),
|
|
||||||
longitudinal_binning.binIndexMax());
|
longitudinal_binning.binIndexMax());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,15 +10,39 @@ bool ReflectorDPS::needsReflectionBackToDomain(
|
|||||||
|
|
||||||
void ReflectorDPS::reflectBackToDomain(particle::Particle* particle) const {
|
void ReflectorDPS::reflectBackToDomain(particle::Particle* particle) const {
|
||||||
blitz::TinyVector<double, 3> old_position =
|
blitz::TinyVector<double, 3> old_position =
|
||||||
particle->cylinderPosition().cylinderEntries();
|
particle->cartesianPosition().cartesianEntries();
|
||||||
old_position(2) = 2 * z_position_dps_ - old_position(2);
|
old_position(2) = 2 * z_position_dps_ - old_position(2);
|
||||||
particle->position(CylinderCoordinate(old_position));
|
particle->position(CartesianCoordinate(old_position));
|
||||||
blitz::TinyVector<double, 3> old_velocity =
|
blitz::TinyVector<double, 3> old_velocity =
|
||||||
particle->velocity().cartesianEntries();
|
particle->velocity().cartesianEntries();
|
||||||
old_velocity(2) *= -1;
|
old_velocity(2) *= -1;
|
||||||
particle->velocity(CartesianVector(old_velocity));
|
particle->velocity(CartesianVector(old_velocity));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LongitudinalReflector::LongitudinalReflector(double height) : height_(height) {}
|
||||||
|
|
||||||
|
bool LongitudinalReflector::needsReflectionBackToDomain(const particle::Particle* particle) const {
|
||||||
|
blitz::TinyVector<double, 3> position = particle->cartesianPosition().cartesianEntries();
|
||||||
|
if(position(2) < 0 || position(2) > height_) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
void LongitudinalReflector::reflectBackToDomain(particle::Particle* particle) const {
|
||||||
|
blitz::TinyVector<double, 3> old_position = particle->cartesianPosition().cartesianEntries();
|
||||||
|
blitz::TinyVector<double, 3> old_velocity = particle->velocity().cartesianEntries();
|
||||||
|
|
||||||
|
if(old_position(2) < 0) {
|
||||||
|
old_position(2) *= -1;
|
||||||
|
} else if(old_position(2) > height_) {
|
||||||
|
old_position(2) = 2*height_ - old_position(2);
|
||||||
|
}
|
||||||
|
old_velocity(2) *= -1.;
|
||||||
|
|
||||||
|
particle->position(CartesianCoordinate(old_position));
|
||||||
|
particle->velocity(CartesianVector(old_velocity));
|
||||||
|
}
|
||||||
|
|
||||||
bool NoReflector::needsReflectionBackToDomain(
|
bool NoReflector::needsReflectionBackToDomain(
|
||||||
const particle::Particle* particle) const {
|
const particle::Particle* particle) const {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -38,6 +38,11 @@
|
|||||||
|
|
||||||
#include "tools/simulation_time.h"
|
#include "tools/simulation_time.h"
|
||||||
|
|
||||||
|
// #ifdef debug_timedist
|
||||||
|
// #include <fstream>
|
||||||
|
// #include <iomanip>
|
||||||
|
// #endif
|
||||||
|
|
||||||
Simulation::Simulation(std::string parameter_filename)
|
Simulation::Simulation(std::string parameter_filename)
|
||||||
: parameter_(parameter_filename) {
|
: parameter_(parameter_filename) {
|
||||||
init(parameter_);
|
init(parameter_);
|
||||||
@@ -164,7 +169,7 @@ void Simulation::start() {
|
|||||||
timer_->setDeltaT(delta_t);
|
timer_->setDeltaT(delta_t);
|
||||||
injector_->initInjectionTimeDistribution(delta_t);
|
injector_->initInjectionTimeDistribution(delta_t);
|
||||||
|
|
||||||
timer_->increaseTimestep(delta_t);
|
// timer_->increaseTimestep(delta_t);
|
||||||
|
|
||||||
while (timestep < number_timesteps) {
|
while (timestep < number_timesteps) {
|
||||||
#if defined(debug_level3)
|
#if defined(debug_level3)
|
||||||
@@ -188,8 +193,12 @@ void Simulation::start() {
|
|||||||
|
|
||||||
#if defined(debug_level1) || defined(debug_level2) || defined(debug_level3)
|
#if defined(debug_level1) || defined(debug_level2) || defined(debug_level3)
|
||||||
DEBUG_LEVEL_1("Processing timestep: " + std::to_string(timestep));
|
DEBUG_LEVEL_1("Processing timestep: " + std::to_string(timestep));
|
||||||
DEBUG_LEVEL_1("Leftover events this timestep: " +
|
// DEBUG_LEVEL_1("Leftover events this timestep: " +
|
||||||
std::to_string(leftover_events_time_resolution));
|
// std::to_string(leftover_events_time_resolution));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef GENRICHCURRENT
|
||||||
|
output_->setResetCurrentCollector(timestep + 1, tracked_species_);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef debug
|
#ifdef debug
|
||||||
@@ -376,9 +385,11 @@ void Simulation::processUntilTermination(particle::Particle& particle) {
|
|||||||
DEBUG_LEVEL_3("Process particle until termination");
|
DEBUG_LEVEL_3("Process particle until termination");
|
||||||
DEBUG_LEVEL_3("Weight of the particle: " + std::to_string(particle.weight()));
|
DEBUG_LEVEL_3("Weight of the particle: " + std::to_string(particle.weight()));
|
||||||
#endif
|
#endif
|
||||||
while (particle.specie()->terminator()->isAlive(&particle)) {
|
|
||||||
auto old_position = particle.cylinderPosition();
|
auto old_position = particle.cylinderPosition();
|
||||||
double old_energy = particle.kineticEnergy_eV();
|
double old_energy = particle.kineticEnergy_eV();
|
||||||
|
while (particle.specie()->terminator()->isAlive(&particle, old_position)) {
|
||||||
|
old_position = particle.cylinderPosition();
|
||||||
|
old_energy = particle.kineticEnergy_eV();
|
||||||
|
|
||||||
if(!particle.isNextInteractionValid()) {
|
if(!particle.isNextInteractionValid()) {
|
||||||
// DEBUG_LEVEL_1("Calculate time until collision");
|
// DEBUG_LEVEL_1("Calculate time until collision");
|
||||||
@@ -394,7 +405,7 @@ void Simulation::processUntilTermination(particle::Particle& particle) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
SimulationTimer::eventStartPoint(std::string("Mover"));
|
SimulationTimer::eventStartPoint(std::string("Mover"));
|
||||||
particle.specie()->mover()->move(&particle,
|
old_position = particle.specie()->mover()->move(&particle,
|
||||||
particle.timeUntilCollision(),
|
particle.timeUntilCollision(),
|
||||||
electric_field_.get(),
|
electric_field_.get(),
|
||||||
magnetic_field_.get(),
|
magnetic_field_.get(),
|
||||||
@@ -402,13 +413,14 @@ void Simulation::processUntilTermination(particle::Particle& particle) {
|
|||||||
SimulationTimer::eventStopPoint(std::string("Mover"));
|
SimulationTimer::eventStopPoint(std::string("Mover"));
|
||||||
|
|
||||||
bool was_reflected = false;
|
bool was_reflected = false;
|
||||||
if (particle.specie()->reflector()->needsReflectionBackToDomain(
|
if (particle.specie()->reflector()->needsReflectionBackToDomain(&particle)) {
|
||||||
&particle)) {
|
|
||||||
#ifdef debug_level3
|
#ifdef debug_level3
|
||||||
DEBUG_LEVEL_3("Reflect particle.");
|
DEBUG_LEVEL_3("Reflect particle.");
|
||||||
#endif
|
#endif
|
||||||
old_position = particle.cylinderPosition();
|
old_position = particle.cylinderPosition();
|
||||||
particle.specie()->reflector()->reflectBackToDomain(&particle);
|
particle.specie()->reflector()->reflectBackToDomain(&particle);
|
||||||
|
// current in azimuthal direction will not be calculated correctly due
|
||||||
|
// old_position being a CylinderCoordinate
|
||||||
particle.specie()->currentCollector()->collect(&particle, old_position);
|
particle.specie()->currentCollector()->collect(&particle, old_position);
|
||||||
was_reflected = true;
|
was_reflected = true;
|
||||||
}
|
}
|
||||||
@@ -416,7 +428,8 @@ void Simulation::processUntilTermination(particle::Particle& particle) {
|
|||||||
if (particle.specie()->terminator()->reachedMaxTimeAlive(
|
if (particle.specie()->terminator()->reachedMaxTimeAlive(
|
||||||
&particle) &&
|
&particle) &&
|
||||||
!particle.specie()->terminator()->leftSimulationDomain(
|
!particle.specie()->terminator()->leftSimulationDomain(
|
||||||
&particle)) {
|
&particle, old_position) &&
|
||||||
|
!was_reflected) {
|
||||||
// particle.invalidateNextInteraction();
|
// particle.invalidateNextInteraction();
|
||||||
#ifdef debug_level3
|
#ifdef debug_level3
|
||||||
DEBUG_LEVEL_3("Terminate particle " + particle.specie()->name() +
|
DEBUG_LEVEL_3("Terminate particle " + particle.specie()->name() +
|
||||||
@@ -443,7 +456,7 @@ void Simulation::processUntilTermination(particle::Particle& particle) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} else if (particle.specie()->terminator()->leftSimulationDomain(
|
} else if (particle.specie()->terminator()->leftSimulationDomain(
|
||||||
&particle)) {
|
&particle, old_position)) {
|
||||||
#if defined(debug)
|
#if defined(debug)
|
||||||
DEBUG("Terminate particle " + particle.specie()->name()
|
DEBUG("Terminate particle " + particle.specie()->name()
|
||||||
+ ". Left simulation domain.");
|
+ ". Left simulation domain.");
|
||||||
@@ -463,19 +476,28 @@ void Simulation::processUntilTermination(particle::Particle& particle) {
|
|||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
out << "particle " << particle.specie()->name();
|
out << "particle " << particle.specie()->name();
|
||||||
out << " left simulation domain but still contributes to the density";
|
out << " left simulation domain but still contributes to the density";
|
||||||
|
out << "\nold position: " << old_position.cylinderEntries();
|
||||||
out << "\nposition: " << particle.cylinderPosition().cylinderEntries();
|
out << "\nposition: " << particle.cylinderPosition().cylinderEntries();
|
||||||
out << "\nvelocity: " << particle.velocity().cartesianEntries();
|
out << "\nvelocity: " << particle.velocity().cartesianEntries();
|
||||||
ERROR(out.str());
|
ERROR(out.str());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
} else if ((particle.specie()->type() == species::ImplementedSpecies::electron) && (particle.kineticEnergy_eV() < 10.) ||
|
||||||
|
(particle.kineticEnergy_eV() < 0.05)) {
|
||||||
|
// delete electrons once they can definitely no longer ionize the background particles and delete ions once they fell into the thermal region
|
||||||
|
if(particle.specie()->deletionLogger()) {
|
||||||
|
// abuse the "max deletion" deletion type to count the number of particles that are deleted due to falling out of the energy region of interest
|
||||||
|
particle.specie()->deletionLogger()->logDeletion(particle.cylinderPosition(), DeletionType::max_interactions);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(particle.specie()->dynamicDensityField()->changedPositionBin(
|
if ((!(particle.specie()->dynamicDensityField()->changedPositionBin(
|
||||||
old_position, particle.cylinderPosition())) &&
|
old_position, particle.cylinderPosition())) &&
|
||||||
!(particle.specie()->dynamicDensityField()->changedEnergyBin(
|
!(particle.specie()->dynamicDensityField()->changedEnergyBin(
|
||||||
old_energy, particle.kineticEnergy_eV())) &&
|
old_energy, particle.kineticEnergy_eV())) &&
|
||||||
!was_reflected) {
|
!was_reflected) || particle.timeUntilCollision() <= 0.) {
|
||||||
#ifdef debug_level3
|
#ifdef debug_level3
|
||||||
DEBUG_LEVEL_3("Perform interaction.");
|
DEBUG_LEVEL_3("Perform interaction.");
|
||||||
DEBUG_LEVEL_3("Number of Interactions: " +
|
DEBUG_LEVEL_3("Number of Interactions: " +
|
||||||
@@ -557,7 +579,7 @@ void Simulation::collisionTime(particle::Particle& particle, RandomNumbers* rand
|
|||||||
particle.indexNextInteration((min_iterator - collision_times.begin()));
|
particle.indexNextInteration((min_iterator - collision_times.begin()));
|
||||||
particle.timeUntilCollision(*min_iterator);
|
particle.timeUntilCollision(*min_iterator);
|
||||||
|
|
||||||
#ifdef debug
|
#ifdef debug_level1
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
out << "collision times ";
|
out << "collision times ";
|
||||||
out << particle.specie()->name() <<":\n[ ";
|
out << particle.specie()->name() <<":\n[ ";
|
||||||
@@ -575,6 +597,19 @@ void Simulation::collisionTime(particle::Particle& particle, RandomNumbers* rand
|
|||||||
|
|
||||||
interaction::InteractionOutput Simulation::interact(
|
interaction::InteractionOutput Simulation::interact(
|
||||||
particle::Particle& particle, RandomNumbers* random) {
|
particle::Particle& particle, RandomNumbers* random) {
|
||||||
|
// #ifdef debug_timedist
|
||||||
|
// if(particle.kineticEnergy_eV() > 20 && particle.specie()->type() == species::ImplementedSpecies::electron) {
|
||||||
|
// std::ofstream file;
|
||||||
|
// std::stringstream filename;
|
||||||
|
// filename << MpiCommunication::mpi_rank << "_collisionTimeDistribution.dat";
|
||||||
|
// file.open(filename.str(), std::ios_base::app);
|
||||||
|
|
||||||
|
// file << std::setprecision(16) << particle.timeSinceCollision() << "\n";
|
||||||
|
// file.close();
|
||||||
|
// }
|
||||||
|
// particle.resetTimeSinceCollision();
|
||||||
|
// #endif
|
||||||
|
|
||||||
return particle.specie()->interactions().at(particle.indexNextInteraction())
|
return particle.specie()->interactions().at(particle.indexNextInteraction())
|
||||||
->performInteraction(particle, random);
|
->performInteraction(particle, random);
|
||||||
}
|
}
|
||||||
@@ -604,7 +639,7 @@ interaction::InteractionOutput Simulation::interact(
|
|||||||
}
|
}
|
||||||
|
|
||||||
//maybe put that into the poisson solver
|
//maybe put that into the poisson solver
|
||||||
blitz::Array<double,3> Simulation::chargedensity() {
|
blitz::Array<double,2> Simulation::chargedensity() {
|
||||||
#ifdef debug_level3
|
#ifdef debug_level3
|
||||||
DEBUG_LEVEL_3("Initialize chargedensity Array");
|
DEBUG_LEVEL_3("Initialize chargedensity Array");
|
||||||
#endif
|
#endif
|
||||||
@@ -619,9 +654,9 @@ blitz::Array<double,3> Simulation::chargedensity() {
|
|||||||
if(!firstTracked)
|
if(!firstTracked)
|
||||||
ERROR("Extracted pointer is null.");
|
ERROR("Extracted pointer is null.");
|
||||||
|
|
||||||
blitz::Array<double,3> init = firstTracked->
|
blitz::Array<double,2> init = firstTracked->
|
||||||
dynamicDensityField()->densityArray();
|
dynamicDensityField()->densityArray();
|
||||||
blitz::Array<double, 3> chargeden(init.lbound(), init.extent());
|
blitz::Array<double, 2> chargeden(init.lbound(), init.extent());
|
||||||
chargeden = 0.;
|
chargeden = 0.;
|
||||||
|
|
||||||
#ifdef debug_level3
|
#ifdef debug_level3
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ Terminator::Terminator(long int max_interactions,
|
|||||||
max_time_alive_(max_time_alive),
|
max_time_alive_(max_time_alive),
|
||||||
geometry_(geometry) {
|
geometry_(geometry) {
|
||||||
if (!geometry_) {
|
if (!geometry_) {
|
||||||
ERROR("No particle lives forever. Give a geometry to terminatior.\n");
|
ERROR("No particle lives forever. Give a geometry to terminator.\n");
|
||||||
}
|
}
|
||||||
ASSERT_POSITIVE(
|
ASSERT_POSITIVE(
|
||||||
&max_interactions_,
|
&max_interactions_,
|
||||||
@@ -27,6 +27,12 @@ bool Terminator::isAlive(const particle::Particle* particle) const {
|
|||||||
!leftSimulationDomain(particle);
|
!leftSimulationDomain(particle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Terminator::isAlive(const particle::Particle* particle,
|
||||||
|
const Coordinate& old_position) const {
|
||||||
|
return !reachedMaxInteractions(particle) && !reachedMaxTimeAlive(particle) &&
|
||||||
|
!leftSimulationDomain(particle, old_position);
|
||||||
|
}
|
||||||
|
|
||||||
bool Terminator::reachedMaxInteractions(
|
bool Terminator::reachedMaxInteractions(
|
||||||
const particle::Particle* particle) const {
|
const particle::Particle* particle) const {
|
||||||
return particle->interactionCounter() > max_interactions_;
|
return particle->interactionCounter() > max_interactions_;
|
||||||
@@ -41,6 +47,43 @@ bool Terminator::leftSimulationDomain(
|
|||||||
return !(geometry_->isInside(particle->cylinderPosition()));
|
return !(geometry_->isInside(particle->cylinderPosition()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Terminator::leftSimulationDomain(
|
||||||
|
const particle::Particle* particle, const Coordinate& old_position) const {
|
||||||
|
return !(geometry_->isInside(particle->cylinderPosition()));
|
||||||
|
}
|
||||||
|
|
||||||
double Terminator::maxTimeAlive() const {
|
double Terminator::maxTimeAlive() const {
|
||||||
return max_time_alive_;
|
return max_time_alive_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TerminatorWithPlates::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) :
|
||||||
|
zpos1_(zpos1), zpos2_(zpos2),
|
||||||
|
innerRadius1_(innerRadius1), innerRadius2_(innerRadius2),
|
||||||
|
outerRadius1_(outerRadius1), outerRadius2_(outerRadius2),
|
||||||
|
Terminator(max_interactions, max_time_alive, geometry) {}
|
||||||
|
|
||||||
|
bool TerminatorWithPlates::leftSimulationDomain(const particle::Particle* particle,
|
||||||
|
const Coordinate& old_position) const {
|
||||||
|
blitz::TinyVector<double, 3> cyl_pos_new = particle->cylinderPosition().cylinderEntries();
|
||||||
|
blitz::TinyVector<double, 3> cyl_pos_old = old_position.cylinderEntries();
|
||||||
|
bool outerbounds = Terminator::leftSimulationDomain(particle);
|
||||||
|
// crossing of zpos1_ plane
|
||||||
|
bool firstPlate = ((cyl_pos_new(2)-zpos1_)*(cyl_pos_old(2)-zpos1_) < 0) &&
|
||||||
|
(cyl_pos_new(0) > innerRadius1_) &&
|
||||||
|
(cyl_pos_new(0) < outerRadius1_);
|
||||||
|
|
||||||
|
bool secondPlate = ((cyl_pos_new(2)-zpos2_)*(cyl_pos_old(2)-zpos2_) < 0) &&
|
||||||
|
(cyl_pos_new(0) > innerRadius2_) &&
|
||||||
|
(cyl_pos_new(0) < outerRadius2_);
|
||||||
|
|
||||||
|
return outerbounds || firstPlate || secondPlate;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TerminatorWithPlates::leftSimulationDomain(const particle::Particle* particle) const {
|
||||||
|
ERROR("TerminatorWithPlates: \"leftSimulationDomain\" cannot be called with only a single set of coordinates!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
@@ -33,3 +33,16 @@ std::function<double(double)> tritiumDecayEnergySpectrum(double prefactor) {
|
|||||||
(T2BetaDecay::E0_T - energy_eV)*(T2BetaDecay::E0_T - energy_eV) * prefactor;
|
(T2BetaDecay::E0_T - energy_eV)*(T2BetaDecay::E0_T - energy_eV) * prefactor;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::function<double(double)> tritiumDecayEnergySpectrumIon(double endpoint) {
|
||||||
|
if (endpoint <= 0.) {
|
||||||
|
ERROR("Endpoint energy must be positive");
|
||||||
|
}
|
||||||
|
|
||||||
|
return [=](double energy_eV) {
|
||||||
|
if (energy_eV < 0.) {
|
||||||
|
ERROR("Beta decay spectrum (ion) not defined for negative energies.");
|
||||||
|
}
|
||||||
|
return energy_eV*endpoint/T2BetaDecay::E0_T;
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -3,9 +3,9 @@
|
|||||||
#include "simulation/coordinates.h"
|
#include "simulation/coordinates.h"
|
||||||
|
|
||||||
VectorFieldFromArray::VectorFieldFromArray(
|
VectorFieldFromArray::VectorFieldFromArray(
|
||||||
const blitz::Array<double, 3>& radial_component,
|
const blitz::Array<double, 2>& radial_component,
|
||||||
const blitz::Array<double, 3>& azimuthal_component,
|
const blitz::Array<double, 2>& azimuthal_component,
|
||||||
const blitz::Array<double, 3>& longitudial_component,
|
const blitz::Array<double, 2>& longitudial_component,
|
||||||
double radius,
|
double radius,
|
||||||
double length)
|
double length)
|
||||||
: Fr_(radial_component.copy()),
|
: Fr_(radial_component.copy()),
|
||||||
@@ -14,17 +14,16 @@ VectorFieldFromArray::VectorFieldFromArray(
|
|||||||
binning_(CylinderBinning(radial_component.extent(0),
|
binning_(CylinderBinning(radial_component.extent(0),
|
||||||
radius,
|
radius,
|
||||||
radial_component.extent(1),
|
radial_component.extent(1),
|
||||||
radial_component.extent(2),
|
|
||||||
length)) {}
|
length)) {}
|
||||||
|
|
||||||
CylinderVector VectorFieldFromArray::value(const Coordinate& coordinate) const {
|
CylinderVector VectorFieldFromArray::value(const Coordinate& coordinate) const {
|
||||||
const blitz::TinyVector<int, 3> bin =
|
const blitz::TinyVector<int, 2> bin =
|
||||||
binning_.bin(coordinate.cylinderEntries());
|
binning_.bin(coordinate.cylinderEntries());
|
||||||
return value(bin);
|
return value(bin);
|
||||||
}
|
}
|
||||||
|
|
||||||
CylinderVector VectorFieldFromArray::value(
|
CylinderVector VectorFieldFromArray::value(
|
||||||
const blitz::TinyVector<int, 3>& bin) const {
|
const blitz::TinyVector<int, 2>& bin) const {
|
||||||
if (Fr_.isInRange(bin)) {
|
if (Fr_.isInRange(bin)) {
|
||||||
return CylinderVector(
|
return CylinderVector(
|
||||||
blitz::TinyVector<double, 3>(Fr_(bin), Fphi_(bin), Fz_(bin)));
|
blitz::TinyVector<double, 3>(Fr_(bin), Fphi_(bin), Fz_(bin)));
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ CartesianVector VelocityDistributionFromDensityField::rollVelocity(
|
|||||||
|
|
||||||
// SIM_INFO("set mu values");
|
// SIM_INFO("set mu values");
|
||||||
|
|
||||||
const blitz::Array<double, 1> mu_values = density_field_->sliceTimeInBinArray(position, energy_eV);
|
const blitz::Array<double, 1> mu_values = density_field_->sliceNumberInBinArray(position, energy_eV);
|
||||||
|
|
||||||
// std::cout << mu_values;
|
// std::cout << mu_values;
|
||||||
|
|
||||||
@@ -211,7 +211,7 @@ CartesianVector VelocityDistributionFromDensityField::rollVelocity(
|
|||||||
// draw pitch angle from DynamicDensityField
|
// draw pitch angle from DynamicDensityField
|
||||||
|
|
||||||
blitz::Array<double, 1> pitchAngleValues = density_field_->
|
blitz::Array<double, 1> pitchAngleValues = density_field_->
|
||||||
sliceTimeInBinArray(position, energy_eV);
|
sliceNumberInBinArray(position, energy_eV);
|
||||||
|
|
||||||
std::piecewise_constant_distribution<double> pitchAngle_dist(
|
std::piecewise_constant_distribution<double> pitchAngle_dist(
|
||||||
pitchAngleBinBorders_.begin(),
|
pitchAngleBinBorders_.begin(),
|
||||||
|
|||||||
Reference in New Issue
Block a user