PyNE C++
tally.h
1 
6 #ifndef PYNE_IQ4M73STINHJDPRV6KWUZZXOYE
7 #define PYNE_IQ4M73STINHJDPRV6KWUZZXOYE
8 
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <fstream>
12 #include <iostream>
13 #include <map>
14 #include <set>
15 #include <string>
16 
17 #ifndef PYNE_IS_AMALGAMATED
18  #include "h5wrap.h"
19  #include "utils.h"
20 #endif
21 
22 
23 namespace pyne
24 {
25  // simplifying implementation...
26  using std::vector;
27  // default empty parameters for constructors
28  const vector<double> null_v_dbl;
29  const vector<int> null_v_int;
30 
31  class Tally
32  {
33  public:
34  std::map<std::string, std::string> rx2fluka;
35  std::map<std::string, std::string> rx2mcnp5;
36  std::map<std::string, std::string> rx2mcnp6;
37 
39  Tally ();
40 
51  Tally(std::string type, std::string particle_name, int entity,
52  std::string entity_type, std::string entity_name,
53  std::string tally_name = "", double entity_size = 0.0,
54  double normalization = 1.0);
55 
66  Tally(std::string type, std::vector<std::string> part_names, int entity,
67  std::string entity_type, std::string entity_name,
68  std::string tally_name = "", double entity_size = 0.0,
69  double normalization = 1.0);
70 
85  Tally(std::string particle_name, std::string entity_geom, vector<double> orgn,
86  vector<double> i_mesh, vector<double> j_mesh, vector<double> k_mesh,
87  vector<int> i_ints = null_v_int,
88  vector<int> j_ints = null_v_int,
89  vector<int> k_ints = null_v_int,
90  vector<double> e_bounds = null_v_dbl, vector<int> e_ints = null_v_int,
91  vector<double> axs =null_v_dbl, vector<double> vec = null_v_dbl,
92  std::string tally_name = "", double norm = 1.0);
93 
94  ~Tally();
95 
96  // Create hdf5 datatable for tallies
97  hid_t create_dataspace(hid_t file, std::string datapath);
98 
99  // create filetype of data
100  hid_t create_filetype();
101 
102  // create memory type for tally struct
103  hid_t create_memtype();
104 
110  void from_hdf5(char* filename, char* datapath, int row = -1);
111 
117  void from_hdf5(std::string filename, std::string datapath, int row = -1);
118 
123  void write_hdf5(char* filename, char* datapath);
124 
129  void write_hdf5(std::string filename, std::string datapath);
130 
131  // mcnp tally
132  std::string mcnp(int tally_index = 1, std::string mcnp_version = "mcnp5",
133  std::string out = "");
134 
135  template<typename T> bool is_zero(T vect);
136 
137  // Form the mcnp tally line as function of its properties
138  std::string form_mcnp_tally(int tally_index, int type,
139  std::string particle_token, int entity_id,
140  double entity_size, double normalization);
141  // Form the mesh tally line as function of its properties
142  std::string form_mcnp_meshtally(
143  int tally_index, std::string particle_token, std::string entity_geometry,
144  std::vector<double> axs, std::vector<double> vec,
145  std::vector<double> origin, std::vector<double> meshes[3],
146  std::vector<int> ints[3], std::vector<double> e_bounds,
147  std::vector<int> e_ints, std::string out);
148 
149  // fluka tally
150  std::string fluka(std::string unit_number = "-21");
151 
154  std::string entity_type;
155  std::string entity_name;
156  std::vector<std::string> particle_names;
157  std::string tally_type;
158  std::string tally_name;
159  int entity_id;
160  double entity_size;
161  double normalization;
162 
164  std::string entity_geometry;
165  std::vector<double> origin;
166  std::vector<double> vec;
167  std::vector<double> axs;
168  std::vector<double> meshes[3];
169  std::vector<int> ints[3];
170  std::vector<double> e_bounds;
171  std::vector<int> e_ints;
172  };
173 
175  std::ostream& operator<< (std::ostream& os, Tally tally);
176 
177 
181  typedef struct tally_struct {
182  int entity_id;
183  int entity_type;
184  int tally_type;
185  const char* particle_name;
186  const char* entity_name;
187  const char* tally_name;
188  double entity_size;
189  double normalization;
190  } tally_struct;
191 
192 // End pyne namespace
193 }
194 
195 #endif
std::vector< std::string > particle_names
particle names string
Definition: tally.h:156
double entity_size
the physical size of the entity
Definition: tally.h:160
std::vector< double > origin
Origin of the Mesh Tally.
Definition: tally.h:165
std::string tally_type
type of tally flux or current
Definition: tally.h:157
std::string tally_name
name of the tally
Definition: tally.h:158
std::string entity_name
the name of the entity (optional)
Definition: tally.h:155
std::vector< double > e_bounds
Energy Mesh.
Definition: tally.h:170
std::vector< double > meshes[3]
mesh interval coordinates
Definition: tally.h:168
Definition: tally.h:181
std::string entity_type
the type of entity (volume,surface)
Definition: tally.h:154
std::vector< double > vec
defining with axs the place for Theta=0 (Cyl Mesh)
Definition: tally.h:166
std::vector< double > axs
dircetion of the axis of the cylindrical Mesh
Definition: tally.h:167
struct pyne::tally_struct tally_struct
Tally()
Tally Constructors.
Definition: tally.cpp:33
Provides some HDF5 helper functionality in its own namespace.
Definition: tally.h:31
std::ostream & operator<<(std::ostream &os, Material mat)
Definition: material.cpp:1446
std::vector< int > e_ints
Bin per energy.
Definition: tally.h:171
std::string entity_geometry
Mesh Tally variables.
Definition: tally.h:164
void write_hdf5(char *filename, char *datapath)
Definition: tally.cpp:196
A container representing enrichment cascades.
Definition: _atomic_data.h:16
int entity_id
id number of the entity being tallied upon
Definition: tally.h:159
void from_hdf5(char *filename, char *datapath, int row=-1)
Definition: tally.cpp:112
double normalization
the tally normalization
Definition: tally.h:161
hid_t create_dataspace(hid_t file, std::string datapath)
default destructor
Definition: tally.cpp:256
std::vector< int > ints[3]
Bin per mesh interval.
Definition: tally.h:169