Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4638a6563c | ||
|
|
324da20d4a |
+64
-7
@@ -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,10 +118,17 @@ 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)
|
||||||
|
|
||||||
times, charges = get_time_and_total_charge_(files, args.species)
|
if (not args.width == 'thesis') and (not args.width == 'beamer'):
|
||||||
|
print(f"{args.width} is not a valid parameter for width; fall back to \'thesis\'")
|
||||||
|
args.width = 'thesis'
|
||||||
|
|
||||||
|
if args.losses:
|
||||||
|
times, charges = get_time_and_wall_losses(files, args.species)
|
||||||
|
else:
|
||||||
|
times, charges = get_time_and_total_charge_(files, args.species)
|
||||||
|
|
||||||
legstr = ''
|
legstr = ''
|
||||||
for val in args.species:
|
for val in args.species:
|
||||||
@@ -85,10 +136,13 @@ 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)
|
||||||
plt.ylabel('charge (C)')
|
if args.losses:
|
||||||
|
plt.ylabel('loss rate (1/s)')
|
||||||
|
else:
|
||||||
|
plt.ylabel('charge (C)')
|
||||||
plt.xlabel('time (s)')
|
plt.xlabel('time (s)')
|
||||||
plt.legend()
|
plt.legend()
|
||||||
plt.grid()
|
plt.grid()
|
||||||
@@ -102,11 +156,14 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
os.makedirs(outname, exist_ok=True)
|
os.makedirs(outname, exist_ok=True)
|
||||||
|
|
||||||
outname += args.basename + "_chargeAgainstTime_species-"
|
if args.losses:
|
||||||
|
outname += args.basename + "_wallLossRateAgainstTime_species-"
|
||||||
|
else:
|
||||||
|
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')
|
||||||
|
|||||||
@@ -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_;
|
||||||
|
|||||||
@@ -29,6 +29,14 @@ class CurrentCollector {
|
|||||||
blitz::Array<double, 2> areaInZ() const;
|
blitz::Array<double, 2> areaInZ() const;
|
||||||
blitz::Array<double, 2> 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;
|
||||||
|
|
||||||
void resetCurrentCollector();
|
void resetCurrentCollector();
|
||||||
@@ -41,6 +49,9 @@ class CurrentCollector {
|
|||||||
const double weight);
|
const double weight);
|
||||||
void collectLongitudinalMovement(const blitz::TinyVector<int, 2>& bin_old,
|
void collectLongitudinalMovement(const blitz::TinyVector<int, 2>& bin_old,
|
||||||
const blitz::TinyVector<int, 2>& 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<double, 3>& old_pos_cart,
|
void collectAzimuthalMovement(const blitz::TinyVector<double, 3>& old_pos_cart,
|
||||||
const blitz::TinyVector<double, 3>& new_pos_cart,
|
const blitz::TinyVector<double, 3>& new_pos_cart,
|
||||||
@@ -71,19 +82,18 @@ class CurrentCollector {
|
|||||||
blitz::Array<double, 2> r_negative_crossings;
|
blitz::Array<double, 2> r_negative_crossings;
|
||||||
blitz::Array<double, 2> r_positive_crossings;
|
blitz::Array<double, 2> r_positive_crossings;
|
||||||
|
|
||||||
// blitz::Array<double, 3> sync_z_negative_crossings;
|
|
||||||
// blitz::Array<double, 3> sync_z_positive_crossings;
|
|
||||||
|
|
||||||
// blitz::Array<double, 3> sync_phi_negative_crossings;
|
|
||||||
// blitz::Array<double, 3> sync_phi_positive_crossings;
|
|
||||||
|
|
||||||
// blitz::Array<double, 3> sync_r_negative_crossings;
|
|
||||||
// blitz::Array<double, 3> sync_r_positive_crossings;
|
|
||||||
|
|
||||||
blitz::Array<double, 2> collector_areas_r;
|
blitz::Array<double, 2> collector_areas_r;
|
||||||
blitz::Array<double, 2> collector_areas_phi;
|
blitz::Array<double, 2> collector_areas_phi;
|
||||||
blitz::Array<double, 2> collector_areas_z;
|
blitz::Array<double, 2> collector_areas_z;
|
||||||
|
|
||||||
|
#ifdef GENRICHCURRENT
|
||||||
|
blitz::Array<double, 2> sample_z_negative_crossings;
|
||||||
|
EnergyBinning energy_binning_;
|
||||||
|
|
||||||
|
bool needs_reset = false;
|
||||||
|
double time_since_reset = 0;
|
||||||
|
#endif //GENRICHCURRENT
|
||||||
|
|
||||||
CylinderBinning position_binning_;
|
CylinderBinning position_binning_;
|
||||||
std::shared_ptr<Timer> timer_;
|
std::shared_ptr<Timer> timer_;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|
||||||
|
|||||||
@@ -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,
|
||||||
@@ -428,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,
|
||||||
@@ -468,4 +480,15 @@ void SimulationOutput::writeParticles(
|
|||||||
int cpu_sync,
|
int cpu_sync,
|
||||||
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
|
||||||
@@ -157,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,14 +12,20 @@ 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, 5, 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, 2> CurrentCollector::createAreaLongitudinal(
|
blitz::Array<double, 2> CurrentCollector::createAreaLongitudinal(
|
||||||
const CylinderBinning& position_binning) {
|
const CylinderBinning& position_binning) {
|
||||||
@@ -138,8 +144,24 @@ void CurrentCollector::collect(particle::Particle* particle,
|
|||||||
|
|
||||||
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,
|
||||||
|
#ifdef GENRICHCURRENT
|
||||||
|
particle->kineticEnergy_eV(),
|
||||||
|
#endif
|
||||||
|
weight);
|
||||||
collectAzimuthalMovement(old_position.cartesianEntries(),
|
collectAzimuthalMovement(old_position.cartesianEntries(),
|
||||||
particle->cartesianPosition().cartesianEntries(),
|
particle->cartesianPosition().cartesianEntries(),
|
||||||
bin_old, weight);
|
bin_old, weight);
|
||||||
@@ -158,9 +180,21 @@ void CurrentCollector::collectRadialMovement(
|
|||||||
void CurrentCollector::collectLongitudinalMovement(
|
void CurrentCollector::collectLongitudinalMovement(
|
||||||
const blitz::TinyVector<int, 2>& bin_old,
|
const blitz::TinyVector<int, 2>& bin_old,
|
||||||
const blitz::TinyVector<int, 2>& 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(1) < bin_old(1)) {
|
if (bin_new(1) < bin_old(1)) {
|
||||||
z_negative_crossings(bin_old(0), bin_new(1) + 1) += weight;
|
z_negative_crossings(bin_old(0), bin_new(1) + 1) += weight;
|
||||||
|
#ifdef GENRICHCURRENT
|
||||||
|
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)) {
|
} else if (bin_new(1) > bin_old(1)) {
|
||||||
z_positive_crossings(bin_old(0), bin_new(1)) += weight;
|
z_positive_crossings(bin_old(0), bin_new(1)) += weight;
|
||||||
}
|
}
|
||||||
@@ -257,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.;
|
||||||
|
needs_reset = false;
|
||||||
|
time_since_reset = timer_->getDeltaT();
|
||||||
|
} else {
|
||||||
|
time_since_reset += timer_->getDeltaT();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// sync_phi_negative_crossings = 0.;
|
#ifdef GENRICHCURRENT
|
||||||
// sync_phi_positive_crossings = 0.;
|
|
||||||
|
|
||||||
// sync_r_negative_crossings = 0.;
|
blitz::Array<double, 2> CurrentCollector::sampleNegativeCrossings() const {
|
||||||
// sync_r_positive_crossings = 0.;
|
return sample_z_negative_crossings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<double> CurrentCollector::energyBinBorders() const {
|
||||||
|
return energy_binning_.binBorders();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -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_);
|
||||||
@@ -192,6 +197,10 @@ void Simulation::start() {
|
|||||||
// std::to_string(leftover_events_time_resolution));
|
// std::to_string(leftover_events_time_resolution));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef GENRICHCURRENT
|
||||||
|
output_->setResetCurrentCollector(timestep + 1, tracked_species_);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef debug
|
#ifdef debug
|
||||||
SIM_INFO("Cpu sync.");
|
SIM_INFO("Cpu sync.");
|
||||||
#endif
|
#endif
|
||||||
@@ -404,8 +413,7 @@ 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
|
||||||
@@ -477,11 +485,11 @@ void Simulation::processUntilTermination(particle::Particle& particle) {
|
|||||||
break;
|
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: " +
|
||||||
@@ -581,6 +589,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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user