Added class for population logging.
This commit is contained in:
@@ -17,7 +17,8 @@ using namespace std;
|
|||||||
|
|
||||||
H5_File::H5_File() {
|
H5_File::H5_File() {
|
||||||
create();
|
create();
|
||||||
h5p = H5_Particles(&h5_file);
|
h5part = H5_Particles(&h5_file);
|
||||||
|
h5pop = H5_Populations(&h5_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
void H5_File::create() {
|
void H5_File::create() {
|
||||||
|
|||||||
@@ -10,15 +10,17 @@
|
|||||||
#define h5_file_hpp
|
#define h5_file_hpp
|
||||||
|
|
||||||
#include "h5_particles.h"
|
#include "h5_particles.h"
|
||||||
|
#include "h5_populations.h"
|
||||||
|
|
||||||
class H5_File {
|
class H5_File {
|
||||||
hid_t h5_file;
|
hid_t h5_file;
|
||||||
H5_Particles h5p;
|
H5_Particles h5part;
|
||||||
|
H5_Populations h5pop;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
H5_File();
|
H5_File();
|
||||||
H5_Particles *get_h5p() {return(&h5p);}
|
H5_Particles *get_h5part() {return(&h5part);}
|
||||||
|
H5_Populations *get_h5pop() {return(&h5pop);}
|
||||||
private:
|
private:
|
||||||
void create();
|
void create();
|
||||||
std::string getFileName();
|
std::string getFileName();
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
//
|
||||||
|
// h5_populations.h
|
||||||
|
// mc_electron
|
||||||
|
//
|
||||||
|
// Created by Christian Reiling on 28.05.19.
|
||||||
|
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef h5_populations_h
|
||||||
|
#define h5_populations_h
|
||||||
|
|
||||||
|
#include "read_system.h"
|
||||||
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
#include "hdf5.h"
|
||||||
|
#include "hdf5_hl.h"
|
||||||
|
|
||||||
|
#include "katrin_geo.hpp"
|
||||||
|
|
||||||
|
class H5_Populations {
|
||||||
|
hid_t *h5_file;
|
||||||
|
hid_t *h5g_populations;
|
||||||
|
|
||||||
|
public:
|
||||||
|
H5_Populations() {};
|
||||||
|
H5_Populations(hid_t *h5_file);
|
||||||
|
|
||||||
|
hid_t *get_h5g_pop() {return(h5g_populations);}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
inline H5_Populations::H5_Populations(hid_t *h5_file) {
|
||||||
|
this->h5_file = h5_file;
|
||||||
|
h5g_populations = new hid_t;
|
||||||
|
*h5g_populations = H5Gcreate(*h5_file, "/Populations", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* h5_populations_h */
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// h5tb_interface.cpp
|
// h5tb_particle_interface.cpp
|
||||||
// mc_electron
|
// mc_electron
|
||||||
//
|
//
|
||||||
// Created by Christian Reiling on 19.05.19.
|
// Created by Christian Reiling on 19.05.19.
|
||||||
@@ -7,14 +7,14 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include "h5tb_interface.hpp"
|
#include "h5tb_particle_interface.hpp"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
logParticle samplelogParticle = {0,0,0,0,0,0,0,0};
|
logParticle samplelogParticle = {0,0,0,0,0,0,0,0};
|
||||||
const size_t H5TB_Interface::size = sizeof(logParticle);
|
const size_t H5TB_Particle_Interface::size = sizeof(logParticle);
|
||||||
const char *H5TB_Interface::fieldNames[8] = { "Id","ParentId", "x_m", "y_m", "z_m", "vx_ms", "vy_ms", "vz_ms" };
|
const char *H5TB_Particle_Interface::fieldNames[8] = { "Id","ParentId", "x_m", "y_m", "z_m", "vx_ms", "vy_ms", "vz_ms" };
|
||||||
const size_t H5TB_Interface::offset[8] = {
|
const size_t H5TB_Particle_Interface::offset[8] = {
|
||||||
HOFFSET(logParticle, Id),
|
HOFFSET(logParticle, Id),
|
||||||
HOFFSET(logParticle, parentId),
|
HOFFSET(logParticle, parentId),
|
||||||
HOFFSET(logParticle, x_m),
|
HOFFSET(logParticle, x_m),
|
||||||
@@ -23,7 +23,7 @@ const size_t H5TB_Interface::offset[8] = {
|
|||||||
HOFFSET(logParticle, vx_ms),
|
HOFFSET(logParticle, vx_ms),
|
||||||
HOFFSET(logParticle, vy_ms),
|
HOFFSET(logParticle, vy_ms),
|
||||||
HOFFSET(logParticle, vz_ms)};
|
HOFFSET(logParticle, vz_ms)};
|
||||||
const hid_t H5TB_Interface::fieldTypes[8] = {
|
const hid_t H5TB_Particle_Interface::fieldTypes[8] = {
|
||||||
H5T_NATIVE_INT,
|
H5T_NATIVE_INT,
|
||||||
H5T_NATIVE_INT,
|
H5T_NATIVE_INT,
|
||||||
H5T_NATIVE_DOUBLE,
|
H5T_NATIVE_DOUBLE,
|
||||||
@@ -32,8 +32,8 @@ const hid_t H5TB_Interface::fieldTypes[8] = {
|
|||||||
H5T_NATIVE_DOUBLE,
|
H5T_NATIVE_DOUBLE,
|
||||||
H5T_NATIVE_DOUBLE,
|
H5T_NATIVE_DOUBLE,
|
||||||
H5T_NATIVE_DOUBLE};
|
H5T_NATIVE_DOUBLE};
|
||||||
const hsize_t H5TB_Interface::chunkSize = 4096;
|
const hsize_t H5TB_Particle_Interface::chunkSize = 4096;
|
||||||
const size_t H5TB_Interface::sizes[8] = {
|
const size_t H5TB_Particle_Interface::sizes[8] = {
|
||||||
sizeof( samplelogParticle.Id),
|
sizeof( samplelogParticle.Id),
|
||||||
sizeof( samplelogParticle.parentId),
|
sizeof( samplelogParticle.parentId),
|
||||||
sizeof( samplelogParticle.x_m),
|
sizeof( samplelogParticle.x_m),
|
||||||
@@ -44,24 +44,24 @@ const size_t H5TB_Interface::sizes[8] = {
|
|||||||
sizeof( samplelogParticle.vz_ms)};
|
sizeof( samplelogParticle.vz_ms)};
|
||||||
|
|
||||||
|
|
||||||
void H5TB_Interface::create() {
|
void H5TB_Particle_Interface::create() {
|
||||||
herr_t state = H5TBmake_table(tableName.c_str(), *loc_id, tableName.c_str(), 8, 0,
|
herr_t state = H5TBmake_table(table_name.c_str(), *loc_id, table_name.c_str(), 8, 0,
|
||||||
size, fieldNames, offset, fieldTypes,
|
size, fieldNames, offset, fieldTypes,
|
||||||
chunkSize, NULL, 0, NULL);
|
chunkSize, NULL, 0, NULL);
|
||||||
if (state < 0) {
|
if (state < 0) {
|
||||||
stringstream ss;
|
stringstream ss;
|
||||||
ss<<"H5TB_Interface::create: Error creating.\n";
|
ss<<"H5TB_Particle_Interface::create: Error creating.\n";
|
||||||
throw MyException(ss.str());
|
throw MyException(ss.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void H5TB_Interface::write(const Particle &logPart) {
|
void H5TB_Particle_Interface::write(const Particle &logPart) {
|
||||||
logParticle logParticle_buffer = transform(logPart);
|
logParticle logParticle_buffer = transform(logPart);
|
||||||
// Maybe add real buffer here....
|
// Maybe add real buffer here....
|
||||||
H5TBappend_records(*loc_id, tableName.c_str() , 1, size, offset, sizes, &logParticle_buffer );
|
H5TBappend_records(*loc_id, table_name.c_str() , 1, size, offset, sizes, &logParticle_buffer );
|
||||||
}
|
}
|
||||||
|
|
||||||
loggerParticle H5TB_Interface::transform(const Particle &logPart) {
|
loggerParticle H5TB_Particle_Interface::transform(const Particle &logPart) {
|
||||||
logParticle res;
|
logParticle res;
|
||||||
res.Id = logPart.get_Id();
|
res.Id = logPart.get_Id();
|
||||||
res.parentId = logPart.get_ParentId();
|
res.parentId = logPart.get_ParentId();
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
//
|
//
|
||||||
// h5tb_interface.hpp
|
// h5tb_particle_interface.hpp
|
||||||
// mc_electron
|
// mc_electron
|
||||||
//
|
//
|
||||||
// Created by Christian Reiling on 19.05.19.
|
// Created by Christian Reiling on 19.05.19.
|
||||||
// Copyright © 2019 Christian Reiling. All rights reserved.
|
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef h5tb_interface_hpp
|
#ifndef h5tb_particle_interface_hpp
|
||||||
#define h5tb_interface_hpp
|
#define h5tb_particle_interface_hpp
|
||||||
|
|
||||||
#include "hdf5.h"
|
#include "hdf5.h"
|
||||||
#include "hdf5_hl.h"
|
#include "hdf5_hl.h"
|
||||||
@@ -26,7 +26,7 @@ typedef struct loggerParticle {
|
|||||||
} logParticle;
|
} logParticle;
|
||||||
|
|
||||||
|
|
||||||
class H5TB_Interface {
|
class H5TB_Particle_Interface {
|
||||||
static const size_t size;
|
static const size_t size;
|
||||||
static const char *fieldNames[8];
|
static const char *fieldNames[8];
|
||||||
static const size_t offset[8];
|
static const size_t offset[8];
|
||||||
@@ -34,13 +34,13 @@ class H5TB_Interface {
|
|||||||
static const hsize_t chunkSize;
|
static const hsize_t chunkSize;
|
||||||
static const size_t sizes[8];
|
static const size_t sizes[8];
|
||||||
|
|
||||||
std::string tableName;
|
std::string table_name;
|
||||||
hid_t *loc_id;
|
hid_t *loc_id;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
H5TB_Interface() {};
|
H5TB_Particle_Interface() {};
|
||||||
H5TB_Interface(const std::string &tableName, hid_t *loc_id) {
|
H5TB_Particle_Interface(const std::string &table_name, hid_t *loc_id) {
|
||||||
this->tableName = tableName;
|
this->table_name = table_name;
|
||||||
this->loc_id = loc_id;
|
this->loc_id = loc_id;
|
||||||
create();
|
create();
|
||||||
}
|
}
|
||||||
@@ -54,4 +54,4 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* h5tb_interface_hpp */
|
#endif /* h5tb_particle_interface_hpp */
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
//
|
||||||
|
// h5tb_population_interface.cpp
|
||||||
|
// mc_electron
|
||||||
|
//
|
||||||
|
// Created by Christian Reiling on 28.05.19.
|
||||||
|
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "h5tb_population_interface.hpp"
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
log_population_bin sample_log_cell = {0,0,0,0,0,0,0};
|
||||||
|
const size_t H5TB_Population_Interface::size = sizeof(log_population_bin);
|
||||||
|
const char *H5TB_Population_Interface::fieldNames[7] = {
|
||||||
|
"n_decay",
|
||||||
|
"z_bin",
|
||||||
|
"r_bin",
|
||||||
|
"phi_bin",
|
||||||
|
"E_bin",
|
||||||
|
"cum_time",
|
||||||
|
"offset"};
|
||||||
|
const size_t H5TB_Population_Interface::offset[7] = {
|
||||||
|
HOFFSET(log_population_bin, number_decay),
|
||||||
|
HOFFSET(log_population_bin, z_bin),
|
||||||
|
HOFFSET(log_population_bin, r_bin),
|
||||||
|
HOFFSET(log_population_bin, phi_bin),
|
||||||
|
HOFFSET(log_population_bin, E_bin),
|
||||||
|
HOFFSET(log_population_bin, cumulative_time),
|
||||||
|
HOFFSET(log_population_bin, offset)};
|
||||||
|
const hid_t H5TB_Population_Interface::fieldTypes[7] = {
|
||||||
|
H5T_NATIVE_INT,
|
||||||
|
H5T_NATIVE_INT,
|
||||||
|
H5T_NATIVE_INT,
|
||||||
|
H5T_NATIVE_INT,
|
||||||
|
H5T_NATIVE_INT,
|
||||||
|
H5T_NATIVE_DOUBLE,
|
||||||
|
H5T_NATIVE_INT};
|
||||||
|
const hsize_t H5TB_Population_Interface::chunkSize = 4096;
|
||||||
|
const size_t H5TB_Population_Interface::sizes[7] = {
|
||||||
|
sizeof( sample_log_cell.number_decay),
|
||||||
|
sizeof( sample_log_cell.z_bin),
|
||||||
|
sizeof( sample_log_cell.r_bin),
|
||||||
|
sizeof( sample_log_cell.phi_bin),
|
||||||
|
sizeof( sample_log_cell.E_bin),
|
||||||
|
sizeof( sample_log_cell.cumulative_time),
|
||||||
|
sizeof( sample_log_cell.offset)};
|
||||||
|
|
||||||
|
|
||||||
|
void H5TB_Population_Interface::create() {
|
||||||
|
herr_t state = H5TBmake_table(table_name.c_str(), *loc_id, table_name.c_str(), 7, 0,
|
||||||
|
size, fieldNames, offset, fieldTypes,
|
||||||
|
chunkSize, NULL, 0, NULL);
|
||||||
|
if (state < 0) {
|
||||||
|
stringstream ss;
|
||||||
|
ss<<"H5TB_Population_Interface::create: Error creating.\n";
|
||||||
|
throw MyException(ss.str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void H5TB_Population_Interface::write(const log_population_bin &log_bin) {
|
||||||
|
H5TBappend_records(*loc_id, table_name.c_str() , 1, size, offset, sizes, &log_bin);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
//
|
||||||
|
// h5tb_population_interface.hpp
|
||||||
|
// mc_electron
|
||||||
|
//
|
||||||
|
// Created by Christian Reiling on 28.05.19.
|
||||||
|
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef h5tb_population_interface_hpp
|
||||||
|
#define h5tb_population_interface_hpp
|
||||||
|
|
||||||
|
#include "error_types.h"
|
||||||
|
|
||||||
|
#include "hdf5.h"
|
||||||
|
#include "hdf5_hl.h"
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct log_population_bin {
|
||||||
|
int number_decay;
|
||||||
|
int z_bin;
|
||||||
|
int r_bin;
|
||||||
|
int phi_bin;
|
||||||
|
int E_bin;
|
||||||
|
double cumulative_time;
|
||||||
|
int offset;
|
||||||
|
} log_population_bin;
|
||||||
|
|
||||||
|
|
||||||
|
class H5TB_Population_Interface {
|
||||||
|
static const size_t size;
|
||||||
|
static const char *fieldNames[7];
|
||||||
|
static const size_t offset[7];
|
||||||
|
static const hid_t fieldTypes[7];
|
||||||
|
static const hsize_t chunkSize;
|
||||||
|
static const size_t sizes[7];
|
||||||
|
|
||||||
|
std::string table_name;
|
||||||
|
hid_t *loc_id;
|
||||||
|
|
||||||
|
public:
|
||||||
|
H5TB_Population_Interface() {};
|
||||||
|
H5TB_Population_Interface(const std::string &table_name, hid_t *loc_id) {
|
||||||
|
this->table_name = table_name;
|
||||||
|
this->loc_id = loc_id;
|
||||||
|
create();
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
void create();
|
||||||
|
|
||||||
|
public:
|
||||||
|
void write(const log_population_bin &log_bin);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* h5tb_population_interface_hpp */
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
//
|
||||||
|
// h5tb_population_meta_interface.cpp
|
||||||
|
// mc_electron
|
||||||
|
//
|
||||||
|
// Created by Christian Reiling on 03.06.19.
|
||||||
|
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "h5tb_population_meta_interface.hpp"
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
log_meta_bin sample_bin = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
|
const size_t H5TB_Population_Meta_Interface::size = sizeof(log_meta_bin);
|
||||||
|
const char *H5TB_Population_Meta_Interface::fieldNames[12] = {
|
||||||
|
"z_bin",
|
||||||
|
"r_bin",
|
||||||
|
"phi_bin",
|
||||||
|
"E_bin",
|
||||||
|
"z_min_m",
|
||||||
|
"z_max_m",
|
||||||
|
"r_min_m",
|
||||||
|
"r_max_m",
|
||||||
|
"phi_min",
|
||||||
|
"phi_max",
|
||||||
|
"E_min_eV",
|
||||||
|
"E_max_eV"};
|
||||||
|
const size_t H5TB_Population_Meta_Interface::offset[12] = {
|
||||||
|
HOFFSET(log_meta_bin, z_bin),
|
||||||
|
HOFFSET(log_meta_bin, r_bin),
|
||||||
|
HOFFSET(log_meta_bin, phi_bin),
|
||||||
|
HOFFSET(log_meta_bin, E_bin),
|
||||||
|
HOFFSET(log_meta_bin, z_min_m),
|
||||||
|
HOFFSET(log_meta_bin, z_max_m),
|
||||||
|
HOFFSET(log_meta_bin, r_min_m),
|
||||||
|
HOFFSET(log_meta_bin, r_max_m),
|
||||||
|
HOFFSET(log_meta_bin, phi_min),
|
||||||
|
HOFFSET(log_meta_bin, phi_max),
|
||||||
|
HOFFSET(log_meta_bin, E_min_eV),
|
||||||
|
HOFFSET(log_meta_bin, E_max_eV)};
|
||||||
|
|
||||||
|
|
||||||
|
const hid_t H5TB_Population_Meta_Interface::fieldTypes[12] = {
|
||||||
|
H5T_NATIVE_INT,
|
||||||
|
H5T_NATIVE_INT,
|
||||||
|
H5T_NATIVE_INT,
|
||||||
|
H5T_NATIVE_INT,
|
||||||
|
H5T_NATIVE_DOUBLE,
|
||||||
|
H5T_NATIVE_DOUBLE,
|
||||||
|
H5T_NATIVE_DOUBLE,
|
||||||
|
H5T_NATIVE_DOUBLE,
|
||||||
|
H5T_NATIVE_DOUBLE,
|
||||||
|
H5T_NATIVE_DOUBLE,
|
||||||
|
H5T_NATIVE_DOUBLE,
|
||||||
|
H5T_NATIVE_DOUBLE};
|
||||||
|
const hsize_t H5TB_Population_Meta_Interface::chunkSize = 4096;
|
||||||
|
const size_t H5TB_Population_Meta_Interface::sizes[12] = {
|
||||||
|
sizeof( sample_bin.z_bin),
|
||||||
|
sizeof( sample_bin.r_bin),
|
||||||
|
sizeof( sample_bin.phi_bin),
|
||||||
|
sizeof( sample_bin.E_bin),
|
||||||
|
sizeof( sample_bin.z_min_m),
|
||||||
|
sizeof( sample_bin.z_max_m),
|
||||||
|
sizeof( sample_bin.r_min_m),
|
||||||
|
sizeof( sample_bin.r_max_m),
|
||||||
|
sizeof( sample_bin.phi_min),
|
||||||
|
sizeof( sample_bin.phi_max),
|
||||||
|
sizeof( sample_bin.E_min_eV),
|
||||||
|
sizeof( sample_bin.E_max_eV)};
|
||||||
|
|
||||||
|
|
||||||
|
void H5TB_Population_Meta_Interface::create() {
|
||||||
|
herr_t state = H5TBmake_table(table_name.c_str(), *loc_id, table_name.c_str(), 12, 0,
|
||||||
|
size, fieldNames, offset, fieldTypes,
|
||||||
|
chunkSize, NULL, 0, NULL);
|
||||||
|
if (state < 0) {
|
||||||
|
stringstream ss;
|
||||||
|
ss<<"H5TB_Population_Meta_Interface::create: Error creating.\n";
|
||||||
|
throw MyException(ss.str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void H5TB_Population_Meta_Interface::write(const log_meta_bin &log_meta) {
|
||||||
|
H5TBappend_records(*loc_id, table_name.c_str() , 1, size, offset, sizes, &log_meta);
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
//
|
||||||
|
// h5tb_population_meta_interface.hpp
|
||||||
|
// mc_electron
|
||||||
|
//
|
||||||
|
// Created by Christian Reiling on 03.06.19.
|
||||||
|
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef h5tb_population_meta_interface_hpp
|
||||||
|
#define h5tb_population_meta_interface_hpp
|
||||||
|
|
||||||
|
#include "error_types.h"
|
||||||
|
|
||||||
|
#include "hdf5.h"
|
||||||
|
#include "hdf5_hl.h"
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct log_meta_bin {
|
||||||
|
int z_bin;
|
||||||
|
int r_bin;
|
||||||
|
int phi_bin;
|
||||||
|
int E_bin;
|
||||||
|
double z_min_m;
|
||||||
|
double z_max_m;
|
||||||
|
double r_min_m;
|
||||||
|
double r_max_m;
|
||||||
|
double phi_min;
|
||||||
|
double phi_max;
|
||||||
|
double E_min_eV;
|
||||||
|
double E_max_eV;
|
||||||
|
} log_meta_bin;
|
||||||
|
|
||||||
|
|
||||||
|
class H5TB_Population_Meta_Interface {
|
||||||
|
static const size_t size;
|
||||||
|
static const char *fieldNames[12];
|
||||||
|
static const size_t offset[12];
|
||||||
|
static const hid_t fieldTypes[12];
|
||||||
|
static const hsize_t chunkSize;
|
||||||
|
static const size_t sizes[12];
|
||||||
|
|
||||||
|
std::string table_name;
|
||||||
|
hid_t *loc_id;
|
||||||
|
|
||||||
|
public:
|
||||||
|
H5TB_Population_Meta_Interface() {};
|
||||||
|
H5TB_Population_Meta_Interface(const std::string &table_name, hid_t *loc_id) {
|
||||||
|
this->table_name = table_name;
|
||||||
|
this->loc_id = loc_id;
|
||||||
|
create();
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
void create();
|
||||||
|
|
||||||
|
public:
|
||||||
|
void write(const log_meta_bin &log_meta);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* h5tb_population_meta_interface_hpp */
|
||||||
@@ -35,6 +35,11 @@ public:
|
|||||||
delta_x = (max_x - min_x)/number_bins;
|
delta_x = (max_x - min_x)/number_bins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
friend bool operator==(const Lin_Scale &scale1, const Lin_Scale &scale2);
|
||||||
|
|
||||||
|
double get_min_val() {return(min_x);}
|
||||||
|
double get_max_val() {return(max_x);}
|
||||||
|
|
||||||
int get_max_index() {return(number_bins);}
|
int get_max_index() {return(number_bins);}
|
||||||
int get_dimension() {return(number_bins + 1);}
|
int get_dimension() {return(number_bins + 1);}
|
||||||
|
|
||||||
@@ -61,5 +66,11 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline bool operator==(const Lin_Scale &scale1, const Lin_Scale &scale2) {
|
||||||
|
return (scale1.min_x== scale2.min_x &&
|
||||||
|
scale1.max_x== scale2.max_x &&
|
||||||
|
scale1.delta_x== scale2.delta_x &&
|
||||||
|
scale1.number_bins== scale2.number_bins);
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* linScale_h */
|
#endif /* linScale_h */
|
||||||
|
|||||||
@@ -15,22 +15,31 @@
|
|||||||
|
|
||||||
Particle_Logger_Manager Particle_Logger_Builder::build(H5_File *h5f) {
|
Particle_Logger_Manager Particle_Logger_Builder::build(H5_File *h5f) {
|
||||||
Particle_Logger_Manager ParticleLogger;
|
Particle_Logger_Manager ParticleLogger;
|
||||||
H5_Particles *h5p = h5f->get_h5p();
|
H5_Particles *h5part = h5f->get_h5part();
|
||||||
|
|
||||||
ParticleLogger.add(build_eLogger(h5p));
|
ParticleLogger.add(build_eLogger(h5part));
|
||||||
ParticleLogger.add(new Off_Particle_Logger(tritiumI));
|
ParticleLogger.add(new Off_Particle_Logger(tritiumI));
|
||||||
ParticleLogger.add(new Off_Particle_Logger(tritium2I));
|
ParticleLogger.add(new Off_Particle_Logger(tritium2I));
|
||||||
return (ParticleLogger);
|
return (ParticleLogger);
|
||||||
}
|
}
|
||||||
|
|
||||||
Particle_Logger_Base *Particle_Logger_Builder::build_eLogger(H5_Particles *h5p) {
|
Particle_Logger_Base *Particle_Logger_Builder::build_eLogger(H5_Particles *h5part) {
|
||||||
Particle_Logger_Base *res;
|
Particle_Logger_Base *res;
|
||||||
if (h5p->get_logging() == false) {
|
if (h5part->get_logging() == false) {
|
||||||
res = new Off_Particle_Logger(electron);
|
res = new Off_Particle_Logger(electron);
|
||||||
} else if(h5p->get_numberZBins() == -1){
|
} else if(h5part->get_numberZBins() == -1){
|
||||||
res = new SF_Particle_Logger(electron, h5p->get_h5g_z());
|
res = new SF_Particle_Logger(electron, h5part->get_h5g_z());
|
||||||
} else {
|
} else {
|
||||||
res = new MuliZ_Particle_Logger(electron, h5p->get_numberZBins(), h5p->get_zValues(), h5p->get_h5g_z());
|
res = new MuliZ_Particle_Logger(electron, h5part->get_numberZBins(), h5part->get_zValues(), h5part->get_h5g_z());
|
||||||
}
|
}
|
||||||
return (res);
|
return (res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Population_Logger_Manager Population_Logger_Builder::build(H5_File *h5f, Population_Manager *populations) {
|
||||||
|
Population_Logger_Manager Population_Logger;
|
||||||
|
H5_Populations *h5pop = h5f->get_h5pop();
|
||||||
|
Thermal_Base *T2I_population = dynamic_cast<Thermal_Base*>(populations->find(tritium2I));
|
||||||
|
|
||||||
|
Population_Logger.add(new Thermal_Population_Logger(T2I_population, h5pop->get_h5g_pop()));
|
||||||
|
return (Population_Logger);
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,9 +12,10 @@
|
|||||||
#include "h5_file.hpp"
|
#include "h5_file.hpp"
|
||||||
|
|
||||||
#include "manager_base.h"
|
#include "manager_base.h"
|
||||||
|
|
||||||
#include "particle_logger_base.h"
|
#include "particle_logger_base.h"
|
||||||
|
|
||||||
|
#include "population_builder.hpp"
|
||||||
|
#include "thermal_population_logger.h"
|
||||||
|
|
||||||
typedef Manager_Base<Particle_Logger_Base> Particle_Logger_Manager;
|
typedef Manager_Base<Particle_Logger_Base> Particle_Logger_Manager;
|
||||||
|
|
||||||
@@ -25,7 +26,19 @@ public:
|
|||||||
|
|
||||||
static Particle_Logger_Manager build(H5_File *h5f);
|
static Particle_Logger_Manager build(H5_File *h5f);
|
||||||
private:
|
private:
|
||||||
static Particle_Logger_Base *build_eLogger(H5_Particles *h5p);
|
static Particle_Logger_Base *build_eLogger(H5_Particles *h5part);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Population_Logger_Builder {
|
||||||
|
|
||||||
|
public:
|
||||||
|
Population_Logger_Builder() {};
|
||||||
|
|
||||||
|
static Population_Logger_Manager build(H5_File *h5f, Population_Manager *populations);
|
||||||
|
//private:
|
||||||
|
//static Population_Logger_Manager *build_Logger(H5_Particles *h5part);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* logger_builder_hpp */
|
#endif /* logger_builder_hpp */
|
||||||
|
|||||||
@@ -16,5 +16,4 @@ int main(int argc, const char * argv[]) {
|
|||||||
Simulation Sim;
|
Simulation Sim;
|
||||||
Sim.doit();
|
Sim.doit();
|
||||||
cout<<"Duration: "<< ( clock() - start ) / (double) CLOCKS_PER_SEC <<'\n';
|
cout<<"Duration: "<< ( clock() - start ) / (double) CLOCKS_PER_SEC <<'\n';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ mcelectron: main.o simulation.o\
|
|||||||
tcs_container.o dcs_container.o population3_container.o size_container.o \
|
tcs_container.o dcs_container.o population3_container.o size_container.o \
|
||||||
thermalPop_container.o energeticPop_container.o \
|
thermalPop_container.o energeticPop_container.o \
|
||||||
particle.o injector.o timer.o katrin_geo.o katrin_fields.o \
|
particle.o injector.o timer.o katrin_geo.o katrin_fields.o \
|
||||||
h5_file.o h5tb_interface.o logger_builder.o \
|
h5_file.o logger_builder.o \
|
||||||
|
h5tb_particle_interface.o h5tb_population_interface.o h5tb_population_meta_interface.o \
|
||||||
population_builder.o \
|
population_builder.o \
|
||||||
mover_builder.o \
|
mover_builder.o \
|
||||||
interaction_builder.o BED_eT2_ionization.o uehara_eT2_elastic.o rutherford_elastic.o \
|
interaction_builder.o BED_eT2_ionization.o uehara_eT2_elastic.o rutherford_elastic.o \
|
||||||
|
|||||||
@@ -13,36 +13,34 @@
|
|||||||
|
|
||||||
|
|
||||||
class MuliZ_Particle_Logger : public Particle_Logger_Base {
|
class MuliZ_Particle_Logger : public Particle_Logger_Base {
|
||||||
H5TB_Interface *h5tb;
|
H5TB_Particle_Interface *h5tb;
|
||||||
|
|
||||||
int numberZBins;
|
int numberZBins;
|
||||||
double *zLogValues;
|
double *zLogValues;
|
||||||
hid_t *h5g_z;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MuliZ_Particle_Logger(species this_species, const int &numberZBins, double *zLogValues, hid_t *h5g_z) : Particle_Logger_Base(this_species) {
|
MuliZ_Particle_Logger(species this_species, const int &numberZBins, double *zLogValues, hid_t *h5g_z) : Particle_Logger_Base(this_species) {
|
||||||
this->numberZBins = numberZBins;
|
this->numberZBins = numberZBins;
|
||||||
this->zLogValues = zLogValues;
|
this->zLogValues = zLogValues;
|
||||||
this->h5g_z = h5g_z;
|
create(h5g_z);
|
||||||
create();
|
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
void create();
|
void create(hid_t *h5g_z);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void log(const Particle &logPart, const vec3 &oldLoc_m);
|
void log(const Particle &logPart, const vec3 &oldLoc_m);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline void MuliZ_Particle_Logger::create() {
|
inline void MuliZ_Particle_Logger::create(hid_t *h5g_z) {
|
||||||
std::string speciesName = get_species_string(get_species());
|
std::string speciesName = get_species_string(get_species());
|
||||||
if (numberZBins < 1) {
|
if (numberZBins < 1) {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss<<"MuliZ_Particle_Logger::create: numberZBins < 1.\n";
|
ss<<"MuliZ_Particle_Logger::create: numberZBins < 1.\n";
|
||||||
}
|
}
|
||||||
h5tb = new H5TB_Interface[numberZBins];
|
h5tb = new H5TB_Particle_Interface[numberZBins];
|
||||||
for (int i = 0; i < numberZBins; i++) {
|
for (int i = 0; i < numberZBins; i++) {
|
||||||
h5tb[i] = H5TB_Interface(speciesName, &h5g_z[i]);
|
h5tb[i] = H5TB_Particle_Interface(speciesName, &h5g_z[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#ifndef particle_logger_base_h
|
#ifndef particle_logger_base_h
|
||||||
#define particle_logger_base_h
|
#define particle_logger_base_h
|
||||||
|
|
||||||
#include "h5tb_interface.hpp"
|
#include "h5tb_particle_interface.hpp"
|
||||||
#include "process_base.h"
|
#include "process_base.h"
|
||||||
|
|
||||||
class Particle_Logger_Base : public Process_Base {
|
class Particle_Logger_Base : public Process_Base {
|
||||||
|
|||||||
@@ -12,31 +12,70 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
Pop3_Container::~Pop3_Container() {
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
Pop3_Container::Pop3_Container(int num_z_bins, int num_r_bins, int num_phi_bins) {
|
Pop3_Container::Pop3_Container(int num_z_bins, int num_r_bins, int num_phi_bins) {
|
||||||
z_scale = Lin_Scale(Katrin_Geo::get_z_RW_m(), Katrin_Geo::get_z_WGTSend_m(), num_z_bins);
|
z_scale = Lin_Scale(Katrin_Geo::get_z_RW_m(), Katrin_Geo::get_z_WGTSend_m(), num_z_bins);
|
||||||
r_scale = Lin_Scale(0,Katrin_Geo::get_radius_m(), num_r_bins);
|
r_scale = Lin_Scale(0,Katrin_Geo::get_radius_m(), num_r_bins);
|
||||||
phi_scale = Lin_Scale(0, 180, num_phi_bins);
|
phi_scale = Lin_Scale(0, 180, num_phi_bins);
|
||||||
|
int z_dimension = z_scale.get_dimension();
|
||||||
|
int r_dimension = r_scale.get_dimension();
|
||||||
|
int phi_dimension = phi_scale.get_dimension();
|
||||||
|
|
||||||
data = new double **[num_z_bins+1];
|
data = new double **[z_dimension];
|
||||||
for (int i = 0; i <= num_z_bins; i++)
|
for (int i = 0; i < z_dimension; i++) {
|
||||||
{
|
data[i] = new double *[r_dimension];
|
||||||
data[i] = new double *[num_r_bins+1];
|
for(int j = 0; j < r_dimension; j++) {
|
||||||
for(int j = 0; j<=num_r_bins; j++)
|
data[i][j] = new double[phi_dimension];
|
||||||
data[i][j] = new double[num_phi_bins+1];
|
for (int k = 0; k < phi_dimension; k++) {
|
||||||
}
|
|
||||||
for (int i = 0; i<=num_z_bins; i++) {
|
|
||||||
for (int j = 0; j<=num_r_bins; j++) {
|
|
||||||
for (int k = 0; k<=num_phi_bins; k++) {
|
|
||||||
data[i][j][k] = 0;
|
data[i][j][k] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Pop3_Container::~Pop3_Container() {
|
||||||
|
int z_dimension = z_scale.get_dimension();
|
||||||
|
int r_dimension = r_scale.get_dimension();
|
||||||
|
for (int i = 0; i < z_dimension; i++) {
|
||||||
|
for(int j = 0; j < r_dimension; j++) {
|
||||||
|
delete[] data[i][j];
|
||||||
|
}
|
||||||
|
delete[] data[i];
|
||||||
|
}
|
||||||
|
delete[] data;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Pop3_Container::Pop3_Container(const Pop3_Container& other) {
|
||||||
|
z_scale = other.z_scale;
|
||||||
|
r_scale = other.r_scale;
|
||||||
|
phi_scale = other.phi_scale;
|
||||||
|
int z_dimension = z_scale.get_dimension();
|
||||||
|
int r_dimension = r_scale.get_dimension();
|
||||||
|
int phi_dimension = phi_scale.get_dimension();
|
||||||
|
|
||||||
|
data = new double **[z_dimension];
|
||||||
|
for (int i = 0; i < z_dimension; i++) {
|
||||||
|
data[i] = new double *[r_dimension];
|
||||||
|
for(int j = 0; j < r_dimension; j++) {
|
||||||
|
data[i][j] = new double[phi_dimension];
|
||||||
|
for (int k = 0; k < phi_dimension; k++) {
|
||||||
|
data[i][j][k] = other.data[i][j][k];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Pop3_Container& Pop3_Container::operator=(const Pop3_Container& other) {
|
||||||
|
Pop3_Container tmp(other);
|
||||||
|
swap(z_scale, tmp.z_scale);
|
||||||
|
swap(z_scale, tmp.z_scale);
|
||||||
|
swap(z_scale, tmp.z_scale);
|
||||||
|
swap(data, tmp.data);
|
||||||
|
return (*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Pop3_Container::increase_value(const double &value, const vec3 &loc_m) {
|
void Pop3_Container::increase_value(const double &value, const vec3 &loc_m) {
|
||||||
int zbin = z_scale.calc_index(get_z_m(loc_m));
|
int zbin = z_scale.calc_index(get_z_m(loc_m));
|
||||||
int rbin = r_scale.calc_index(get_r_m(loc_m));
|
int rbin = r_scale.calc_index(get_r_m(loc_m));
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include "katrin_geo.hpp"
|
#include "katrin_geo.hpp"
|
||||||
#include "timer.hpp"
|
#include "timer.hpp"
|
||||||
|
|
||||||
|
|
||||||
class Pop3_Container {
|
class Pop3_Container {
|
||||||
double ***data;
|
double ***data;
|
||||||
Lin_Scale z_scale;
|
Lin_Scale z_scale;
|
||||||
@@ -20,12 +21,22 @@ class Pop3_Container {
|
|||||||
Lin_Scale phi_scale;
|
Lin_Scale phi_scale;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~Pop3_Container();
|
|
||||||
Pop3_Container(int num_z_bins, int num_r_bins, int num_phi_bins);
|
Pop3_Container(int num_z_bins, int num_r_bins, int num_phi_bins);
|
||||||
|
|
||||||
|
~Pop3_Container();
|
||||||
|
Pop3_Container(const Pop3_Container& other);
|
||||||
|
Pop3_Container& operator=(const Pop3_Container& other);
|
||||||
|
|
||||||
void increase_value(const double &value, const vec3 &loc_m);
|
void increase_value(const double &value, const vec3 &loc_m);
|
||||||
void increase_value(const double &value, const vec3 &loc1_m, const vec3 &loc2_m);
|
void increase_value(const double &value, const vec3 &loc1_m, const vec3 &loc2_m);
|
||||||
double get_value (vec3 loc_m);
|
double get_value (vec3 loc_m);
|
||||||
|
|
||||||
|
|
||||||
|
double get_value_by_bin(int z_bin, int r_bin, int phi_bin) {return (data[z_bin][r_bin][phi_bin]);}
|
||||||
|
//double ***get_data(){return(data);}
|
||||||
|
Lin_Scale get_z_scale(){return(z_scale);}
|
||||||
|
Lin_Scale get_r_scale(){return(r_scale);}
|
||||||
|
Lin_Scale get_phi_scale(){return(phi_scale);}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,15 @@
|
|||||||
|
|
||||||
typedef blitz::TinyVector<double,3> vec3;
|
typedef blitz::TinyVector<double,3> vec3;
|
||||||
|
|
||||||
|
typedef struct population_log_info {
|
||||||
|
double z_m;
|
||||||
|
double r_m;
|
||||||
|
double phi;
|
||||||
|
double E_eV;
|
||||||
|
double cumulative_time_s;
|
||||||
|
double offset;
|
||||||
|
} population_log_info;
|
||||||
|
|
||||||
|
|
||||||
class Population_Base : public Process_Base {
|
class Population_Base : public Process_Base {
|
||||||
|
|
||||||
@@ -33,7 +42,6 @@ public:
|
|||||||
virtual vec3 roll_speed_ms (const vec3 &loc_m) = 0;
|
virtual vec3 roll_speed_ms (const vec3 &loc_m) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
//
|
||||||
|
// population_logger_base.h
|
||||||
|
// mc_electron
|
||||||
|
//
|
||||||
|
// Created by Christian Reiling on 28.05.19.
|
||||||
|
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef population_logger_base_h
|
||||||
|
#define population_logger_base_h
|
||||||
|
|
||||||
|
#include "population_base.h"
|
||||||
|
|
||||||
|
class Population_Logger_Base {
|
||||||
|
public:
|
||||||
|
Population_Logger_Base() {};
|
||||||
|
virtual void log(int number_decay) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Population_Logger_Manager {
|
||||||
|
Population_Logger_Base **population_loggers;
|
||||||
|
int num_loggers = 0;
|
||||||
|
public:
|
||||||
|
Population_Logger_Manager() {};
|
||||||
|
|
||||||
|
void add(Population_Logger_Base *new_population_logger) {
|
||||||
|
if (num_loggers != 0) {
|
||||||
|
Population_Logger_Base *tempArray[num_loggers];
|
||||||
|
for (int i = 0; i < num_loggers; i++) {
|
||||||
|
tempArray[i] = population_loggers[i];
|
||||||
|
}
|
||||||
|
delete[] population_loggers;
|
||||||
|
population_loggers = new Population_Logger_Base *[num_loggers + 1];
|
||||||
|
for (int i = 0; i < num_loggers; i++) {
|
||||||
|
population_loggers[i] = tempArray[i];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
population_loggers = new Population_Logger_Base *[num_loggers + 1];
|
||||||
|
}
|
||||||
|
population_loggers[num_loggers] = new_population_logger;
|
||||||
|
num_loggers += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void log(const int &numberDecays) {
|
||||||
|
for (int i=0; i<num_loggers; i++) {
|
||||||
|
population_loggers[i]->log(numberDecays);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* population_logger_base_h */
|
||||||
@@ -13,27 +13,24 @@
|
|||||||
|
|
||||||
|
|
||||||
class SF_Particle_Logger : public Particle_Logger_Base {
|
class SF_Particle_Logger : public Particle_Logger_Base {
|
||||||
hid_t *h5g_z;
|
H5TB_Particle_Interface h5tb;
|
||||||
|
|
||||||
H5TB_Interface h5tb;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SF_Particle_Logger(species this_species, hid_t *h5g_z) : Particle_Logger_Base(this_species) {
|
SF_Particle_Logger(species this_species, hid_t *h5g_z) : Particle_Logger_Base(this_species) {
|
||||||
this->h5g_z = h5g_z;
|
create(h5g_z);
|
||||||
create();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void create();
|
void create(hid_t *h5g_z);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void log(const Particle &logPart, const vec3 &oldLoc_m);
|
void log(const Particle &logPart, const vec3 &oldLoc_m);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline void SF_Particle_Logger::create() {
|
inline void SF_Particle_Logger::create(hid_t *h5g_z) {
|
||||||
std::string speciesName = get_species_string(get_species());
|
std::string speciesName = get_species_string(get_species());
|
||||||
h5tb = H5TB_Interface(speciesName, h5g_z);
|
h5tb = H5TB_Particle_Interface(speciesName, h5g_z);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void SF_Particle_Logger::log(const Particle &logPart, const vec3 &oldLoc_m) {
|
inline void SF_Particle_Logger::log(const Particle &logPart, const vec3 &oldLoc_m) {
|
||||||
|
|||||||
@@ -18,14 +18,16 @@ void Simulation::init() {
|
|||||||
set_RNGs();
|
set_RNGs();
|
||||||
|
|
||||||
timer = Timer(&numberDecays);
|
timer = Timer(&numberDecays);
|
||||||
loggers = Particle_Logger_Builder::build(&h5f);
|
part_loggers = Particle_Logger_Builder::build(&h5f);
|
||||||
populations = Population_Builder::build(&timer, &rngUni, &rngNormal);
|
populations = Population_Builder::build(&timer, &rngUni, &rngNormal);
|
||||||
|
|
||||||
injector = Injector(&rngUni, &rngNormal);
|
injector = Injector(&rngUni, &rngNormal);
|
||||||
movers = Mover_Builder::build(&loggers, &populations);
|
movers = Mover_Builder::build(&part_loggers, &populations);
|
||||||
interactions = Interaction_Builder::build(&populations, &rngUni);
|
interactions = Interaction_Builder::build(&populations, &rngUni);
|
||||||
terminators = Terminator_Builder::build();
|
terminators = Terminator_Builder::build();
|
||||||
|
|
||||||
|
pop_loggers = Population_Logger_Builder::build(&h5f, &populations);
|
||||||
|
|
||||||
set_statusUpdater();
|
set_statusUpdater();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,6 +54,7 @@ void Simulation::doit() {
|
|||||||
vec3 oldLoc_m;
|
vec3 oldLoc_m;
|
||||||
while ( (numberDecays < numberTotalDecays) || (!partQue.empty()) ) {
|
while ( (numberDecays < numberTotalDecays) || (!partQue.empty()) ) {
|
||||||
if (partQue.empty()) {
|
if (partQue.empty()) {
|
||||||
|
pop_loggers.log(numberDecays);
|
||||||
curPart = injector.injectElectron(numberTotalParticles);
|
curPart = injector.injectElectron(numberTotalParticles);
|
||||||
numberDecays++;
|
numberDecays++;
|
||||||
numberTotalParticles++;
|
numberTotalParticles++;
|
||||||
@@ -84,6 +87,7 @@ void Simulation::doit() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pop_loggers.log(numberDecays);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,6 @@
|
|||||||
#include "terminator_builder.hpp"
|
#include "terminator_builder.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Simulation {
|
class Simulation {
|
||||||
static const long int seed;
|
static const long int seed;
|
||||||
static const long int numberTotalDecays;
|
static const long int numberTotalDecays;
|
||||||
@@ -33,7 +31,7 @@ class Simulation {
|
|||||||
H5_File h5f;
|
H5_File h5f;
|
||||||
Timer timer;
|
Timer timer;
|
||||||
|
|
||||||
Particle_Logger_Manager loggers;
|
Particle_Logger_Manager part_loggers;
|
||||||
Population_Manager populations;
|
Population_Manager populations;
|
||||||
|
|
||||||
|
|
||||||
@@ -42,6 +40,7 @@ class Simulation {
|
|||||||
Interaction_Manager interactions;
|
Interaction_Manager interactions;
|
||||||
Terminator_Manager terminators;
|
Terminator_Manager terminators;
|
||||||
|
|
||||||
|
Population_Logger_Manager pop_loggers;
|
||||||
int numberTotalParticles = 0;
|
int numberTotalParticles = 0;
|
||||||
int numberDecays = 0;
|
int numberDecays = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
class Thermal_Base : public Population_Base, protected RNG_Base{
|
class Thermal_Base : public Population_Base, protected RNG_Base{
|
||||||
Pop3_Container cumulated_times_s;
|
Pop3_Container cumulated_times_s;
|
||||||
Pop3_Container numbers_annhilated;
|
Pop3_Container number_annhilated;
|
||||||
Size_Container bin_sizes;
|
Size_Container bin_sizes;
|
||||||
|
|
||||||
Timer *timer;
|
Timer *timer;
|
||||||
@@ -29,7 +29,7 @@ public:
|
|||||||
Thermal_Base(species this_species, Timer *timer, UniRNG *rngUni, NormalRNG *rngNormal, int num_z_bins, int num_r_bins, int num_phi_bins) : Population_Base(this_species),
|
Thermal_Base(species this_species, Timer *timer, UniRNG *rngUni, NormalRNG *rngNormal, int num_z_bins, int num_r_bins, int num_phi_bins) : Population_Base(this_species),
|
||||||
RNG_Base(rngUni, rngNormal),
|
RNG_Base(rngUni, rngNormal),
|
||||||
cumulated_times_s(num_z_bins, num_r_bins, num_phi_bins),
|
cumulated_times_s(num_z_bins, num_r_bins, num_phi_bins),
|
||||||
numbers_annhilated(num_z_bins, num_r_bins, num_phi_bins),
|
number_annhilated(num_z_bins, num_r_bins, num_phi_bins),
|
||||||
bin_sizes(num_z_bins, num_r_bins, num_phi_bins) {
|
bin_sizes(num_z_bins, num_r_bins, num_phi_bins) {
|
||||||
this->timer = timer;
|
this->timer = timer;
|
||||||
};
|
};
|
||||||
@@ -41,13 +41,16 @@ public:
|
|||||||
|
|
||||||
virtual vec3 get_average_speed_ms (const vec3 &loc_m) = 0;
|
virtual vec3 get_average_speed_ms (const vec3 &loc_m) = 0;
|
||||||
virtual vec3 roll_speed_ms (const vec3 &loc_m) = 0;
|
virtual vec3 roll_speed_ms (const vec3 &loc_m) = 0;
|
||||||
|
Pop3_Container get_cumulated_time_container () const {return(cumulated_times_s);}
|
||||||
|
Pop3_Container get_number_annhilated_container () const {return(number_annhilated);}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline double Thermal_Base::get_density_m3(const vec3 &loc_m) {
|
inline double Thermal_Base::get_density_m3(const vec3 &loc_m) {
|
||||||
//Katrin_Geo::check_inKatrin(loc_m);
|
//Katrin_Geo::check_inKatrin(loc_m);
|
||||||
double physical_time_s = timer->get_physTime_s();
|
double physical_time_s = timer->get_physTime_s();
|
||||||
double cumulative_time_s = cumulated_times_s.get_value(loc_m);
|
double cumulative_time_s = cumulated_times_s.get_value(loc_m);
|
||||||
double offset = numbers_annhilated.get_value(loc_m);
|
double offset = number_annhilated.get_value(loc_m);
|
||||||
double bin_size_m3 = bin_sizes.get_cell_volume_m3(loc_m);
|
double bin_size_m3 = bin_sizes.get_cell_volume_m3(loc_m);
|
||||||
double dens_m3 = cumulative_time_s/physical_time_s/bin_size_m3 - offset;
|
double dens_m3 = cumulative_time_s/physical_time_s/bin_size_m3 - offset;
|
||||||
dens_m3 = (dens_m3 < 0) ? zero : dens_m3;
|
dens_m3 = (dens_m3 < 0) ? zero : dens_m3;
|
||||||
@@ -60,7 +63,7 @@ inline void Thermal_Base::increase_density(const Particle &upPart, const vec3 &o
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void Thermal_Base::decrease_denisty (const vec3 &loc_m) {
|
inline void Thermal_Base::decrease_denisty (const vec3 &loc_m) {
|
||||||
numbers_annhilated.increase_value(1, loc_m);
|
number_annhilated.increase_value(1, loc_m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,129 @@
|
|||||||
|
//
|
||||||
|
// thermal_population_logger.h
|
||||||
|
// mc_electron
|
||||||
|
//
|
||||||
|
// Created by Christian Reiling on 28.05.19.
|
||||||
|
// Copyright © 2019 Christian Reiling. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef thermal_population_logger_h
|
||||||
|
#define thermal_population_logger_h
|
||||||
|
|
||||||
|
#include "population_logger_base.h"
|
||||||
|
#include "thermal_base.h"
|
||||||
|
#include "h5tb_population_interface.hpp"
|
||||||
|
#include "h5tb_population_meta_interface.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
class Thermal_Population_Logger : public Population_Logger_Base {
|
||||||
|
H5TB_Population_Interface h5tb;
|
||||||
|
H5TB_Population_Meta_Interface h5tb_meta;
|
||||||
|
|
||||||
|
Thermal_Base *thermal_pop;
|
||||||
|
Lin_Scale z_scale;
|
||||||
|
Lin_Scale r_scale;
|
||||||
|
Lin_Scale phi_scale;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
Thermal_Population_Logger(Thermal_Base *thermal_pop, hid_t *h5g) : Population_Logger_Base() {
|
||||||
|
this->thermal_pop = thermal_pop;
|
||||||
|
create_scales();
|
||||||
|
create_h5tb(h5g);
|
||||||
|
create_h5tb_meta(h5g);
|
||||||
|
};
|
||||||
|
private:
|
||||||
|
void create_scales();
|
||||||
|
void create_h5tb(hid_t *h5g);
|
||||||
|
void create_h5tb_meta(hid_t *h5g);
|
||||||
|
void log(int number_decay);
|
||||||
|
};
|
||||||
|
|
||||||
|
inline void Thermal_Population_Logger::create_scales() {
|
||||||
|
Pop3_Container cum_time = thermal_pop->get_cumulated_time_container();
|
||||||
|
Pop3_Container anhilated = thermal_pop->get_number_annhilated_container();
|
||||||
|
if (cum_time.get_z_scale() == anhilated.get_z_scale()) {
|
||||||
|
z_scale = cum_time.get_z_scale();
|
||||||
|
} else {
|
||||||
|
std::stringstream ss;
|
||||||
|
ss<<"Thermal_Population_Logger::create_scales: Missmatch in scales.\n";
|
||||||
|
throw MyException(ss.str());
|
||||||
|
}
|
||||||
|
if (cum_time.get_r_scale() == anhilated.get_r_scale()) {
|
||||||
|
r_scale = cum_time.get_r_scale();
|
||||||
|
} else {
|
||||||
|
std::stringstream ss;
|
||||||
|
ss<<"Thermal_Population_Logger::create_scales: Missmatch in scales.\n";
|
||||||
|
throw MyException(ss.str());
|
||||||
|
}
|
||||||
|
if (cum_time.get_phi_scale() == anhilated.get_phi_scale()) {
|
||||||
|
phi_scale = cum_time.get_phi_scale();
|
||||||
|
} else {
|
||||||
|
std::stringstream ss;
|
||||||
|
ss<<"Thermal_Population_Logger::create_scales: Missmatch in scales.\n";
|
||||||
|
throw MyException(ss.str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Thermal_Population_Logger::create_h5tb(hid_t *h5g) {
|
||||||
|
species Species = thermal_pop->get_species();
|
||||||
|
std::string species_string = get_species_string(Species);
|
||||||
|
h5tb = H5TB_Population_Interface(species_string, h5g);
|
||||||
|
log(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Thermal_Population_Logger::create_h5tb_meta(hid_t *h5g) {
|
||||||
|
species Species = thermal_pop->get_species();
|
||||||
|
std::string species_string = get_species_string(Species);
|
||||||
|
std::stringstream ss;
|
||||||
|
ss<<species_string;
|
||||||
|
ss<<"_meta_data";
|
||||||
|
h5tb_meta = H5TB_Population_Meta_Interface(ss.str(), h5g);
|
||||||
|
|
||||||
|
log_meta_bin meta_bin = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
|
meta_bin.E_bin = 0;
|
||||||
|
meta_bin.E_min_eV = NAN;
|
||||||
|
meta_bin.E_max_eV = NAN;
|
||||||
|
meta_bin.z_min_m = z_scale.get_min_val();
|
||||||
|
for (int i_z=0; i_z<z_scale.get_dimension(); i_z++) {
|
||||||
|
meta_bin.z_bin = i_z;
|
||||||
|
meta_bin.z_max_m = z_scale.calc_upper_bound(i_z);
|
||||||
|
meta_bin.r_min_m = r_scale.get_min_val();
|
||||||
|
for (int i_r=0; i_r<r_scale.get_dimension(); i_r++) {
|
||||||
|
meta_bin.r_bin = i_r;
|
||||||
|
meta_bin.r_max_m = r_scale.calc_upper_bound(i_r);
|
||||||
|
meta_bin.phi_min = phi_scale.get_min_val();
|
||||||
|
for (int i_phi=0; i_phi<phi_scale.get_dimension(); i_phi++) {
|
||||||
|
meta_bin.phi_bin = i_phi;
|
||||||
|
meta_bin.phi_max = phi_scale.calc_upper_bound(i_phi);
|
||||||
|
h5tb_meta.write(meta_bin);
|
||||||
|
meta_bin.phi_min = meta_bin.phi_max;
|
||||||
|
}
|
||||||
|
meta_bin.r_min_m = meta_bin.r_max_m;
|
||||||
|
}
|
||||||
|
meta_bin.z_min_m = meta_bin.z_max_m;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void Thermal_Population_Logger::log(int number_decay) {
|
||||||
|
log_population_bin pop_bin = {0, 0, 0, 0, 0, 0, 0};
|
||||||
|
Pop3_Container cum_time = thermal_pop->get_cumulated_time_container();
|
||||||
|
Pop3_Container anhilated = thermal_pop->get_number_annhilated_container();
|
||||||
|
pop_bin.number_decay = number_decay;
|
||||||
|
pop_bin.E_bin = -1;
|
||||||
|
for (int i_z=0; i_z<z_scale.get_dimension(); i_z++) {
|
||||||
|
pop_bin.z_bin = i_z;
|
||||||
|
for (int i_r=0; i_r<r_scale.get_dimension(); i_r++) {
|
||||||
|
pop_bin.r_bin = i_r;
|
||||||
|
for (int i_phi=0; i_phi<phi_scale.get_dimension(); i_phi++) {
|
||||||
|
pop_bin.phi_bin = i_phi;
|
||||||
|
pop_bin.cumulative_time = cum_time.get_value_by_bin(i_z, i_r, i_phi);
|
||||||
|
pop_bin.offset = anhilated.get_value_by_bin(i_z, i_r, i_phi);
|
||||||
|
h5tb.write(pop_bin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* thermal_population_logger_h */
|
||||||
Reference in New Issue
Block a user