Reworked Logging class.

Added Populations for individual Species.
This commit is contained in:
Christian
2019-05-06 13:14:03 +02:00
parent 67f6dcb633
commit 2f764c4812
17 changed files with 385 additions and 547 deletions
+50
View File
@@ -0,0 +1,50 @@
//
// find_species.h
// mc_electron
//
// Created by Christian Reiling on 03.05.19.
// Copyright © 2019 Christian Reiling. All rights reserved.
//
#ifndef find_species_h
#define find_species_h
#include <vector>
#include "particle.hpp"
template <typename T>
inline typename std::vector<T*>::iterator find_SpeciesItr(std::vector<T*> Vec, species Species) {
typename std::vector<T*>::iterator Itr;
if (Vec.size() == 0) {
Itr = Vec.end();
} else {
Itr = Vec.begin();
while (Itr != Vec.end() ) {
if ((*Itr)->get_Species() == Species) {
break;
}
Itr++;
}
}
return (Itr);
}
template <typename T>
inline typename std::vector<T*>::const_iterator find_SpeciesConstItr(const std::vector<T*> Vec, species Species) {
typename std::vector<T*>::const_iterator Itr;
if (Vec.size() == 0) {
Itr = Vec.end();
} else {
Itr = Vec.cbegin();
while (Itr != Vec.cend() ) {
if ( (*Itr)->get_Species() == Species) {
break;
}
Itr++;
}
}
return (Itr);
}
#endif /* find_species_h */
-27
View File
@@ -45,31 +45,4 @@ void InteractionProcessor::add_ParticleInteraction(class ParticleInteractions* p
ParticleInteractions.push_back(particleInteraction);
}
ParticleInteractionsVec::const_iterator InteractionProcessor::find_ParticleInteraction (species findSpec) const {
ParticleInteractionsVec::const_iterator Itr;
if (empty()) {
Itr = ParticleInteractions.cend();
} else {
Itr = ParticleInteractions.cbegin();
while (Itr != ParticleInteractions.end()) {
if ((*Itr)->get_Species() == findSpec) {
break;
}
Itr++;
}
}
return (Itr);
}
ParticleInteractionsVec::iterator InteractionProcessor::find_ParticleInteraction (species findSpec) {
ParticleInteractionsVec::iterator Itr;
if (empty()) {
Itr = ParticleInteractions.end();
} else {
Itr = ParticleInteractions.begin();
while (Itr != ParticleInteractions.end() || (*Itr)->get_Species() == findSpec) {
Itr++;
}
}
return (Itr);
}
+7 -3
View File
@@ -10,7 +10,7 @@
#define interaction_processor_hpp
#include "interaction_species.hpp"
#include "find_species.h"
typedef std::vector <ParticleInteractions*> ParticleInteractionsVec;
@@ -32,8 +32,12 @@ public:
bool empty() const {return (ParticleInteractions.size()==0 ? true : false);}
private:
ParticleInteractionsVec::const_iterator find_ParticleInteraction (species findSpec) const;
ParticleInteractionsVec::iterator find_ParticleInteraction (species findSpec);
ParticleInteractionsVec::const_iterator find_ParticleInteraction (species findSpec) const {
return (find_SpeciesConstItr(ParticleInteractions, findSpec));
};
ParticleInteractionsVec::iterator find_ParticleInteraction (species findSpec) {
return (find_SpeciesItr(ParticleInteractions, findSpec));
};
};
#endif /* interaction_processor_hpp */
-7
View File
@@ -9,18 +9,11 @@
#include "katrin.hpp"
#include "sstream"
using namespace std;
const double Katrin::rearwallZ_m = getParameter("rearwallZ_m");
const double Katrin::wgtsStartZ_m = getParameter("wgtsStartZ_m");
const double Katrin::wgtsEndZ_m = getParameter("wgtsEndZ_m");
const double Katrin::wgtsRadius_m = getParameter("wgtsRadius_m");
const double Katrin::wgtsMagField_T = getParameter("wgtsMagField_T");
const double Katrin::wgtsT2MaxDensity_m3 = getParameter("wgtsT2MaxDensity_m3");
-41
View File
@@ -27,47 +27,6 @@ public:
private:
void check_Properties();
// Geometrics
public:
double get_z_RW_m() const {return(rearwallZ_m);};
double get_z_WGTSstart_m() const {return(wgtsStartZ_m);};
double get_z_WGTSend_m() const {return(wgtsEndZ_m);};
double get_radius_m() const {return(wgtsRadius_m);};
bool outside(vec3 loc_m) const;
private:
double wgtsLength_m() const {return (get_z_WGTSend_m() - get_z_WGTSstart_m());};
static const double rearwallZ_m;
static const double wgtsStartZ_m;
static const double wgtsEndZ_m;
static const double wgtsRadius_m;
// EM-Fields
public:
vec3 getMagField_T(vec3 loc_m) const { return (vec3(0,0,wgtsMagField_T)); };
vec3 getElField_Vm(vec3 loc_m) const {return (vec3(0,0,0));};
private:
static const double wgtsMagField_T;
//Particle Densities
public:
double getTritiumDensity_m3(vec3 loc_m);
// Maxwell Boltzmann Part
public:
vec3 roll_totEqSpeed_ms(vec3 loc_m);
vec3 get_flowEqSpeed_ms(vec3 loc_m);
vec3 roll_thermEqSpeed_ms(vec3 loc_m);
private:
static const double wgtsT2MaxDensity_m3;
static const double wgtsTemp_K;
static const double wgtsT2FlowSpeed_ms;
//Skalar_WGTS_Container Ion_Container = Skalar_WGTS_Container(0, wgtsLength_m, wgtsRadius_m, vec3(10,10,12));
};
+9
View File
@@ -0,0 +1,9 @@
//
// katrin_fields.cpp
// mc_electron
//
// Created by Christian Reiling on 03.05.19.
// Copyright © 2019 Christian Reiling. All rights reserved.
//
#include "katrin_fields.hpp"
+34
View File
@@ -0,0 +1,34 @@
//
// katrin_fields.hpp
// mc_electron
//
// Created by Christian Reiling on 03.05.19.
// Copyright © 2019 Christian Reiling. All rights reserved.
//
#ifndef katrin_fields_hpp
#define katrin_fields_hpp
#include "katrin_geo.hpp"
class Katrin_Fields {
static const double wgtsMagField_T;
Katrin_Geo *Kat_Geo;
public:
Katrin_Fields() {};
vec3 getMagField_T(vec3 loc_m) const {
Kat_Geo->check_inKatrin(loc_m);
return (vec3(0,0,wgtsMagField_T));
}
vec3 getElField_Vm(vec3 loc_m) const {
Kat_Geo->check_inKatrin(loc_m);
return (vec3(0,0,0));
}
private:
};
#endif /* katrin_fields_hpp */
+64
View File
@@ -0,0 +1,64 @@
//
// katrin_geo.cpp
// mc_electron
//
// Created by Christian Reiling on 03.05.19.
// Copyright © 2019 Christian Reiling. All rights reserved.
//
#include <sstream>
#include "error_types.h"
#include "katrin_geo.hpp"
#include "read_system.h"
const double Katrin_Geo::rearwallZ_m = getParameter("rearwallZ_m");
const double Katrin_Geo::wgtsStartZ_m = getParameter("wgtsStartZ_m");
const double Katrin_Geo::wgtsEndZ_m = getParameter("wgtsEndZ_m");
const double Katrin_Geo::wgtsRadius_m = getParameter("wgtsRadius_m");
using namespace std;
void Katrin_Geo::check_inWGTS(vec3 loc_m) {
if (inWGTS(loc_m)) {
stringstream ss;
ss<<"Katrin_Geo::check_inWGTS: Location not within WGTS\nLocation:\t"<<loc_m<<"\n";
throw MyException (ss.str());
}
}
void Katrin_Geo::check_inKatrin(vec3 loc_m) {
if (inKatrin(loc_m)) {
stringstream ss;
ss<<"Katrin_Geo::check_inKatrin: Location not within Katrin\nLocation:\t"<<loc_m<<"\n";
throw MyException (ss.str());
}
}
bool Katrin_Geo::inWGTS(vec3 loc_m) {
double z_m = loc_m[2];
double r_m = sqrt(loc_m[0]*loc_m[0] + loc_m[1]*loc_m[1]);
if (z_m < wgtsStartZ_m) {
return (false);
} else if (z_m > wgtsEndZ_m) {
return (false);
} else if (r_m > wgtsRadius_m) {
return (false);
} else {
return (true);
}
}
bool Katrin_Geo::inKatrin(vec3 loc_m) {
double z_m = loc_m[2];
double r_m = sqrt(loc_m[0]*loc_m[0] + loc_m[1]*loc_m[1]);
if (z_m < rearwallZ_m) {
return (false);
} else if (z_m > wgtsEndZ_m) {
return (false);
} else if (r_m > wgtsRadius_m) {
return (false);
} else {
return (true);
}
}
+41
View File
@@ -0,0 +1,41 @@
//
// katrin_geo.hpp
// mc_electron
//
// Created by Christian Reiling on 03.05.19.
// Copyright © 2019 Christian Reiling. All rights reserved.
//
#ifndef katrin_geo_hpp
#define katrin_geo_hpp
#include <blitz/tinyvec2.h>
typedef blitz::TinyVector<double,3> vec3;
class Katrin_Geo {
static const double rearwallZ_m;
static const double wgtsStartZ_m;
static const double wgtsEndZ_m;
static const double wgtsRadius_m;
public:
Katrin_Geo() {};
static double get_z_RW_m() {return(rearwallZ_m);};
static double get_z_WGTSstart_m() {return(wgtsStartZ_m);};
static double get_z_WGTSend_m() {return(wgtsEndZ_m);};
static double get_radius_m() {return(wgtsRadius_m);};
static void check_inWGTS(vec3 loc_m);
static void check_inKatrin(vec3 loc_m);
static bool inWGTS(vec3 loc_m);
static bool inKatrin(vec3 loc_m);
private:
static double wgtsLength_m() {return (get_z_WGTSend_m() - get_z_WGTSstart_m());};
};
#endif /* katrin_geo_hpp */
@@ -0,0 +1,36 @@
//
// katrin_population_builder.cpp
// mc_electron
//
// Created by Christian Reiling on 06.05.19.
// Copyright © 2019 Christian Reiling. All rights reserved.
//
#include "katrin_population_builder.hpp"
const int InteractionBuilder::eT2elastic = getParameter("eT2elastic");
const int InteractionBuilder::eT2ionization = getParameter("eT2ionization");
InteractionProcessor InteractionBuilder::build_InteractionProcessor() {
InteractionProcessor InterProcessor(Kat,rngUni,rngNormal);
InterProcessor.add_ParticleInteraction(build_eInteractions());
return(InterProcessor);
}
ParticleInteractions* InteractionBuilder::build_eInteractions() {
ParticleInteractions* eInteractions = new ParticleInteractions(Kat, rngUni, rngNormal, electron);
if (eT2elastic == 1) {
eInteractions->add_Interaction(new e_T2_elasticScattering(Kat, rngUni, rngNormal));
}
if (eT2ionization == 1) {
eInteractions->add_Interaction(new e_T2_ionization(Kat, rngUni, rngNormal));
}
return(eInteractions);
}
/*
ParticleInteractions InteractionBuilder::build_T2Interactions() {
}
*/
@@ -0,0 +1,40 @@
//
// katrin_population_builder.hpp
// mc_electron
//
// Created by Christian Reiling on 06.05.19.
// Copyright © 2019 Christian Reiling. All rights reserved.
//
#ifndef katrin_population_builder_hpp
#define katrin_population_builder_hpp
#include <stdio.h>
class Katrin_Populations_Builder {
};
class InteractionBuilder : public RNG_Base {
Katrin *Kat;
static const int eT2ionization;
static const int eT2elastic;
public:
InteractionBuilder(Katrin *Kat, UniRNG *rngUni, NormalRNG *rngNormal) : RNG_Base(rngUni, rngNormal) {
this->Kat = Kat;
}
InteractionProcessor build_InteractionProcessor();
private:
ParticleInteractions* build_eInteractions();
//ParticleInteractions* build_T2Interactions();
};
#endif /* katrin_population_builder_hpp */
-318
View File
@@ -1,318 +0,0 @@
//
// logger.cpp
// mc_electron
//
// Created by Christian Reiling on 27.02.19.
// Copyright © 2019 Christian Reiling. All rights reserved.
//
#include "logger.hpp"
#include "hdf5.h"
#include "hdf5_hl.h"
#include <stdlib.h>
#include <fstream>
#include <sys/stat.h>
using namespace std;
const int Base_Logger::numberZBins = getParameter("numberZBins");
// Base_Logger
Base_Logger::Base_Logger(Katrin *Kat) {
this->Kat = Kat;
if (numberZBins == 0) {
cout<<"Logging turned off."<<endl;
logging = false;
return;
}
set_zLogValues();
}
void Base_Logger::set_zLogValues() {
zLogValues.clear();
logging = true;
if (numberZBins == -1) {
cout<<"Logging everything to one file."<<endl;
} else if (numberZBins == 1) {
cout<<"Logging 1 z-Value: "<<Kat->get_z_WGTSend_m()<<endl;
zLogValues.push_back(Kat->get_z_WGTSend_m());
} else {
double z_m;
double length_m = Kat->get_z_WGTSend_m() - Kat->get_z_RW_m();
double stepLength_m = length_m/(numberZBins-1);
for (int i = 0;i<numberZBins;i++) {
z_m = Kat->get_z_RW_m() + stepLength_m*i;
zLogValues.push_back(z_m);
}
cout<<"Logging "<<numberZBins<<" z-Values."<<endl;
}
return;
}
std::string Base_Logger::getparName() {
string parpath = getenv("parpath");
string parfile = remove_catEnding(getenv("parfile"));
return (parpath + "/" + parfile);
}
std::string Base_Logger::remove_catEnding (std::string inString) {
if ( inString.substr(inString.size()-4, 4) == ".cat" ){
return (inString.substr(0, inString.size()-4) );
} else {
return (inString);
}
}
bool Base_Logger::isFile(std::string fileName) {
struct stat buffer;
return (stat (fileName.c_str(), &buffer) == 0);
}
bool Base_Logger::isDir(std::string dirPath) {
struct stat info;
if( stat( dirPath.c_str(), &info ) != 0 )
return (false);
else if( info.st_mode & S_IFDIR ) // S_ISDIR() doesn't exist on my windows
return (true);
else
return (false);
}
// ASCI_Logger
ASCI_Logger::ASCI_Logger(Katrin *Kat) : Base_Logger(Kat) {
set_outdirName();
create_outdir();
set_outStream();
}
void ASCI_Logger::log_Particle(Particle *logPart, blitz::TinyVector<double,3> oldLoc_m) {
if (!logging) {
return;
}
if (logPart->get_Species() != electron) {
return;
}
// Assumption: no change of sign in v_z
if (numberZBins == -1) {
outStream[0]<<*logPart<<endl;
} else {
double zold = oldLoc_m[2];
double znew = logPart->get_Location_m()[2];
double zmin = min(zold,znew);
double zmax = max(zold,znew);
for (int i=0;i<numberZBins;i++) {
if (zLogValues[i]>=zmin && zLogValues[i]<=zmax) {
outStream[i]<<*logPart<<endl; // Location wrong, because it s the new Location.
}
}
}
}
void ASCI_Logger::set_outdirName() {
string parname = getparName();
stringstream dirname;
int i = 1;
do {
dirname.str(std::string());
dirname << parname << "_" << getTimeString() << "_" << i++;
} while ( isDir(dirname.str()) );
outdirName = dirname.str();
return;
}
void ASCI_Logger::create_outdir() {
if (mkdir(outdirName.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) {
stringstream ss;
ss<<"ASCI_Logger::create_outdir: Could not create output directiory.\n outdirName = "<<outdirName<<endl;
throw MyException(ss.str());
}
return;
}
void ASCI_Logger::set_outStream() {
if (numberZBins == -1) {
outStream = new ofstream [1];
stringstream ss;
ss <<outdirName << "/all" << ".dat";
outStream[0].open(ss.str().c_str());
} else {
outStream = new ofstream [numberZBins];
for (int i = 0; i < numberZBins; i++)
{
stringstream ss;
ss << outdirName << "/z=" << zLogValues[i] << ".dat";
outStream[i].open(ss.str().c_str());
}
}
}
// ParticleH5TB_Properties
const size_t ParticleH5TB_Properties::size = sizeof(logParticle);
const char *ParticleH5TB_Properties::fieldNames[8] = { "Id","ParentId", "x_m", "y_m", "z_m", "vx_ms", "vy_ms", "vz_ms" };
const size_t ParticleH5TB_Properties::offset[8] = {
HOFFSET(logParticle, Id),
HOFFSET(logParticle, parentId),
HOFFSET(logParticle, x_m),
HOFFSET(logParticle, y_m),
HOFFSET(logParticle, z_m),
HOFFSET(logParticle, vx_ms),
HOFFSET(logParticle, vy_ms),
HOFFSET(logParticle, vz_ms)};
const hid_t ParticleH5TB_Properties::fieldTypes[8] = {
H5T_NATIVE_INT,
H5T_NATIVE_INT,
H5T_NATIVE_DOUBLE,
H5T_NATIVE_DOUBLE,
H5T_NATIVE_DOUBLE,
H5T_NATIVE_DOUBLE,
H5T_NATIVE_DOUBLE,
H5T_NATIVE_DOUBLE};
const hsize_t ParticleH5TB_Properties::chunkSize = 4096;
logParticle samplelogParticle = {0,0,0,0,0,0,0,0};
const size_t ParticleH5TB_Properties::sizes[8] = {
sizeof( samplelogParticle.Id),
sizeof( samplelogParticle.parentId),
sizeof( samplelogParticle.x_m),
sizeof( samplelogParticle.y_m),
sizeof( samplelogParticle.z_m),
sizeof( samplelogParticle.vx_ms),
sizeof( samplelogParticle.vy_ms),
sizeof( samplelogParticle.vz_ms)};
// ParticleLogger
void ParticleLogger::create_particle_H5TBs() {
if (numberZBins == -1) {
particle_H5TB = new hid_t[1];
particle_H5TB[0] = H5TBmake_table(speciesIdentifier.c_str(), particle_zH5G[0], speciesIdentifier.c_str(), 8, 0,
size, fieldNames, offset, fieldTypes,
chunkSize, NULL, 0, NULL);
} else {
particle_H5TB = new hid_t[numberZBins];
for (int i = 0; i < numberZBins; i++)
{
particle_H5TB[i] = H5TBmake_table( speciesIdentifier.c_str(), particle_zH5G[i], speciesIdentifier.c_str(),8,0,
size, fieldNames, offset, fieldTypes,
chunkSize, NULL, 0, NULL);
}
}
}
void ParticleLogger::log_Particle(const Particle &logPart, const vec3 &oldLoc_m) {
check_Species(logPart);
logParticle logParticle_buffer = transformTo_logParticle(logPart);
// Assumption: no change of sign in v_z
if (singleFile) {
H5TBappend_records(particle_zH5G[0], speciesIdentifier.c_str() , 1, size, offset, sizes, &logParticle_buffer );
} else {
double zold = oldLoc_m[2];
double znew = logPart.get_Location_m()[2];
double zmin = min(zold,znew);
double zmax = max(zold,znew);
for (int i=0;i<numberZBins;i++) {
if (zLogValues[i]>=zmin && zLogValues[i]<=zmax) {
H5TBappend_records(particle_zH5G[i], speciesIdentifier.c_str(), 1, size, offset, sizes, &logParticle_buffer ); // Location wrong, because it s the new Location.
}
}
}
return;
}
void ParticleLogger::check_Species(const Particle &logPart) {
if (logPart.get_Species() != Species) {
stringstream ss;
ss<<"ParticleLogger::check_Species: Wrong Species\nExpected:\t"<<Species<<"\nInput:\t"<<logPart.get_Species()<<"\n";
throw MyException (ss.str());
}
}
logParticle ParticleLogger::transformTo_logParticle(const Particle &logPart) {
logParticle res;
res.Id = logPart.get_Id();
res.parentId = logPart.get_ParentId();
res.x_m = logPart.get_Location_m()[0];
res.y_m = logPart.get_Location_m()[1];
res.z_m = logPart.get_Location_m()[2];
res.vx_ms = logPart.get_Speed_ms()[0];
res.vy_ms = logPart.get_Speed_ms()[1];
res.vz_ms = logPart.get_Speed_ms()[2];
return (res);
}
// H5_Logger
void H5_Logger::create_outH5F() {
const string constH5Name = get_outH5F_fullPath();
outH5F = H5Fcreate(constH5Name.c_str(), H5F_ACC_EXCL, H5P_DEFAULT, H5P_DEFAULT);
}
string H5_Logger::get_outH5F_fullPath() {
string parname = getparName();
stringstream H5name;
int i = 1;
do {
H5name.str(std::string());
H5name << parname << "_" << getTimeString() << "_" << i++<<".h5";
} while ( isFile(H5name.str()) );
return (H5name.str());
}
void H5_Logger::create_particleH5G() {
particleH5G = H5Gcreate2(outH5F, "/Particles", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
}
void H5_Logger::create_particle_zH5G() {
if (numberZBins == -1) {
particle_zH5G = new hid_t[1];
particle_zH5G[0] = H5Gcreate2(particleH5G, "/z=all", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
} else {
particle_zH5G = new hid_t [numberZBins];
for (int i = 0; i < numberZBins; i++)
{
stringstream ss;
ss << "/z=" << zLogValues[i];
particle_zH5G[i] = H5Gcreate2(particleH5G, ss.str().c_str(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
}
}
}
void H5_Logger::add_ParticleLogger(ParticleLogger* addParticleLogger){
if (find_ParticleLogger(addParticleLogger->get_Species()) != ParticleLoggers.end()) {
stringstream ss;
ss<<"H5_Logger::add_ParticleLogger: Species already exists.\nSpecies:\t"<<addParticleLogger->get_Species()<<"\n";
throw MyException (ss.str());
}
ParticleLoggers.push_back(addParticleLogger);
}
ParticleLoggerVec::iterator H5_Logger::find_ParticleLogger (species findSpec) {
if (ParticleLoggers.size() == 0) {
return (ParticleLoggers.end());
}
ParticleLoggerVec::iterator Itr;
Itr = ParticleLoggers.begin();
while (Itr != ParticleLoggers.end()) {
if ((*Itr)->get_Species() == findSpec ) {
return (Itr);
}
Itr++;
}
return (Itr);
}
void H5_Logger::log_Particle(const Particle &logPart, vec3 oldLoc_m) {
ParticleLoggerVec::iterator Itr;
Itr = find_ParticleLogger(logPart.get_Species());
if (Itr!= ParticleLoggers.end()) {
(*Itr)->log_Particle(logPart, oldLoc_m);
}
}
-150
View File
@@ -1,150 +0,0 @@
//
// logger.hpp
// mc_electron
//
// Created by Christian Reiling on 27.02.19.
// Copyright © 2019 Christian Reiling. All rights reserved.
//
#ifndef logger_hpp
#define logger_hpp
#include "particle.hpp"
#include "katrin.hpp"
#include "hdf5.h"
typedef struct logParticle {
unsigned int Id;
unsigned int parentId;
double x_m;
double y_m;
double z_m;
double vx_ms;
double vy_ms;
double vz_ms;
} logParticle;
// Base_Logger: Base_Class for all Logger: Reading Paramter and calculating z-Barrieres.
class Base_Logger {
public:
Base_Logger(Katrin *Kat);
protected:
static const int numberZBins;
bool logging;
std::vector<double> zLogValues;
void set_zLogValues();
std::string getparName();
std::string remove_catEnding (std::string inString);
bool isFile(std::string fileName);
bool isDir(std::string dirPath);
Katrin *Kat;
};
// ASCI_Logger: Log to ASCI-File. Only Electron Logger. Not very efficient.
class ASCI_Logger : public Base_Logger {
public:
ASCI_Logger(Katrin *Kat);
void log_Particle(Particle *inPart , vec3 oldLoc_m);
private:
std::string outdirName;
std::ofstream *outStream;
void set_outdirName();
void create_outdir();
void set_outStream();
};
class ParticleH5TB_Properties {
public:
ParticleH5TB_Properties() {};
protected:
static const size_t size;
static const char *fieldNames[8];
static const size_t offset[8];
static const hid_t fieldTypes[8];
static const hsize_t chunkSize;
static const size_t sizes[8];
};
class ParticleLogger : ParticleH5TB_Properties{
public:
ParticleLogger(species Species, hid_t *particle_zH5G, std::vector<double> zLogValues) {
this->Species = Species;
this->particle_zH5G = particle_zH5G;
this->zLogValues = zLogValues;
numberZBins = zLogValues.size();
singleFile = (numberZBins == 1) ? true : false;
stringstream ss;
ss<<Species;
speciesIdentifier = ss.str();
create_particle_H5TBs();
};
private:
void create_particle_H5TBs();
private:
hid_t *particle_zH5G;
std::vector<double> zLogValues;
hid_t *particle_H5TB;
species Species;
int numberZBins;
bool singleFile;
std::string speciesIdentifier;
public:
void log_Particle(const Particle &logPart, const vec3 &oldLoc_m);
private:
logParticle transformTo_logParticle(const Particle &logPart);
public:
species get_Species() const {return(Species);};
private:
void check_Species(const Particle &logPart);
};
typedef std::vector<ParticleLogger*> ParticleLoggerVec;
class H5_Logger : private Base_Logger {
public:
H5_Logger(Katrin *Kat) : Base_Logger(Kat) {
create_outH5F();
create_particleH5G();
create_particle_zH5G();
add_ParticleLogger(new ParticleLogger(electron, particle_zH5G,zLogValues));
};
private:
hid_t outH5F;
hid_t particleH5G;
hid_t *particle_zH5G;
ParticleLoggerVec ParticleLoggers;
private:
void create_outH5F();
std::string get_outH5F_fullPath();
void create_particleH5G();
void create_particle_zH5G();
public:
void add_ParticleLogger(ParticleLogger* addParticleLogger);
private:
ParticleLoggerVec::iterator find_ParticleLogger (species findSpec);
public:
void log_Particle(const Particle &logPart, vec3 oldLoc_m);
};
#endif /* logger_hpp */
+1 -1
View File
@@ -17,7 +17,7 @@
#include "blitz/array.h"
typedef blitz::TinyVector<double,3> vec3;
typedef enum species{undef, electron, positron, proton, tritium, tritium2, helium, deuterium, DT}species;
typedef enum species{undef, electron, tritium, tritium2, helium, deuterium, DT}species;
std::ostream& operator<<(std::ostream& os, const species& SpecOut);
+40
View File
@@ -166,4 +166,44 @@ inline std::string getHomebase() {
inline std::string getDataPath() {
return (getHomebase() + "src/mc_electron/data/");
}
inline std::string remove_catEnding (std::string inString) {
if ( inString.substr(inString.size()-4, 4) == ".cat" ){
return (inString.substr(0, inString.size()-4) );
} else {
return (inString);
}
}
inline std::string getparName() {
string parpath = getenv("parpath");
string parfile = remove_catEnding(getenv("parfile"));
return (parpath + "/" + parfile);
}
inline bool isFile(std::string fileName) {
struct stat buffer;
return (stat (fileName.c_str(), &buffer) == 0);
}
inline bool isDir(std::string dirPath) {
struct stat info;
if( stat( dirPath.c_str(), &info ) != 0 )
return (false);
else if( info.st_mode & S_IFDIR ) // S_ISDIR() doesn't exist on my windows
return (true);
else
return (false);
}
#endif /* read_system_h */
+28
View File
@@ -0,0 +1,28 @@
//
// tritium_population.cpp
// mc_electron
//
// Created by Christian Reiling on 06.05.19.
// Copyright © 2019 Christian Reiling. All rights reserved.
//
#include "tritium_population.hpp"
const double T2_Density::wgtsTemp_K = getParameter("wgtsTemp_K");
const double T2_Density::wgtsT2MaxDensity_m3 = getParameter("wgtsT2MaxDensity_m3");
const double T2_Density::wgtsT2FlowSpeed_ms = getParameter("wgtsT2FlowSpeed_ms");
double T2_Density::get_Density(vec3 loc_m) const {
Katrin_Geo::check_inKatrin(loc_m);
if (!Katrin_Geo::inWGTS(loc_m)) {
return (0);
} else {
}
}
double T2_Density::roll_Energy(vec3 loc_m, UniRNG *rngUni) const {
Katrin_Geo::check_inKatrin(loc_m);
}
+35
View File
@@ -0,0 +1,35 @@
//
// tritium_population.hpp
// mc_electron
//
// Created by Christian Reiling on 06.05.19.
// Copyright © 2019 Christian Reiling. All rights reserved.
//
#ifndef tritium_population_hpp
#define tritium_population_hpp
#include "population_base.h"
class T2_Density : public Population_Base {
static const double wgtsT2MaxDensity_m3;
static const double wgtsTemp_K;
static const double wgtsT2FlowSpeed_ms;
public:
T2_Density() : Population_Base(tritium2) {};
double get_Density(vec3 loc_m) const ;
double roll_Energy(vec3 loc_m, UniRNG *rngUni) const ;
void up_Denisty(vec3 loc_m, double Ekin_eV) {Katrin_Geo::check_inKatrin(loc_m);};
};
//Skalar_WGTS_Container Ion_Container = Skalar_WGTS_Container(0, wgtsLength_m, wgtsRadius_m, vec3(10,10,12));
#endif /* tritium_population_hpp */