CYCLUS
Loading...
Searching...
No Matches
pyne.h
Go to the documentation of this file.
1// This file is composed of the following original files:
2
3// license.txt
4// src/utils.h
5// src/extra_types.h
6// src/h5wrap.h
7// src/nucname.h
8// src/rxname.h
9// src/_atomic_data.h
10// src/data.h
11// src/json-forwards.h
12// src/json.h
13// src/jsoncustomwriter.h
14// src/material.h
15// src/enrichment_cascade.h
16// src/enrichment.h
17// src/enrichment_symbolic.h
18// src/_decay.h
19
20// PyNE amalgated header http://pyne.io/
21#ifndef PYNE_52BMSKGZ3FHG3NQI566D4I2ZLY
22#define PYNE_52BMSKGZ3FHG3NQI566D4I2ZLY
23
24#define PYNE_IS_AMALGAMATED
25
26//
27// start of license.txt
28//
29// Copyright 2011-2015, the PyNE Development Team. All rights reserved.
30//
31// Redistribution and use in source and binary forms, with or without modification, are
32// permitted provided that the following conditions are met:
33//
34// 1. Redistributions of source code must retain the above copyright notice, this list of
35// conditions and the following disclaimer.
36//
37// 2. Redistributions in binary form must reproduce the above copyright notice, this list
38// of conditions and the following disclaimer in the documentation and/or other materials
39// provided with the distribution.
40//
41// THIS SOFTWARE IS PROVIDED BY THE PYNE DEVELOPMENT TEAM ``AS IS'' AND ANY EXPRESS OR IMPLIED
42// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
43// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
44// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
45// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
46// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
47// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
48// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
49// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
50//
51// The views and conclusions contained in the software and documentation are those of the
52// authors and should not be interpreted as representing official policies, either expressed
53// or implied, of the stakeholders of the PyNE project or the employers of PyNE developers.
54//
55// -------------------------------------------------------------------------------
56// The files cpp/measure.cpp and cpp/measure.hpp are covered by:
57//
58// Copyright 2004 Sandia Corporation. Under the terms of Contract
59// DE-AC04-94AL85000 with Sandia Coroporation, the U.S. Government
60// retains certain rights in this software.
61//
62// http://trac.mcs.anl.gov/projects/ITAPS/wiki/MOAB
63// //
64// end of license.txt
65//
66
67
68//
69// start of src/utils.h
70//
71/// \brief This is the base PyNE library.
72///
73/// It contains a lot of utility functions and constants that are globaly useful
74/// through out the rest of the PyNE infrastructure.
75///
76
77// Header for general library file.
78
79#ifndef PYNE_KMMHYNANYFF5BFMEYIP7TUNLHA
80#define PYNE_KMMHYNANYFF5BFMEYIP7TUNLHA
81
82//standard libraries
83#include <string>
84#include <string.h>
85#include <sstream>
86#include <cctype>
87#include <stdlib.h>
88#include <iostream>
89#include <cmath>
90#include <exception>
91#include <sys/stat.h>
92#include <sys/types.h>
93#include <cstdlib>
94#include <vector>
95#include <algorithm>
96
97#if (__GNUC__ >= 4)
98 #include <cmath>
99 using std::isnan;
100#else
101 #include <math.h>
102 #define isnan(x) __isnand((double)x)
103#endif
104
105#ifdef __WIN_MSVC__
106 #define isnan(x) ((x) != (x))
107#endif
108
109#ifndef JSON_IS_AMALGAMATION
110 #define JSON_IS_AMALGAMATION
111#endif
112
113/// The 'pyne' namespace all PyNE functionality is included in.
114namespace pyne {
115
116 void pyne_start (); ///< Initializes PyNE based on environment.
117
118 /// Path to the directory containing the PyNE data.
119 extern std::string PYNE_DATA;
120 extern std::string NUC_DATA_PATH; ///< Path to the nuc_data.h5 file.
121
122 // String Transformations
123 /// string of digit characters
124 static std::string digits = "0123456789";
125 /// uppercase alphabetical characters
126 static std::string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
127 /// string of all valid word characters for variable names in programing languages.
128 static std::string words = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
129
130 /// \name String Conversion Functions
131 /// \{
132 /// Converts the variables of various types to their C++ string representation.
133 std::string to_str(int t);
134 std::string to_str(unsigned int t);
135 std::string to_str(double t);
136 std::string to_str(bool t);
137 /// \}
138
139 int to_int(std::string s); ///< Converts a string of digits to an int using atoi().
140
141 double to_dbl(std::string s); ///< Converts a valid string to a float using atof().
142
143 /// Converts a string from ENDF format to a float. Only handles E-less format
144 /// but is roughly 5 times faster than endftod.
145 double endftod_cpp(char * s);
146 double endftod_f(char * s); ///< Converts a string from ENDF format to a float.
147 extern double (*endftod)(char * s); ///< endftod function pointer. defaults to fortran
148
149 void use_fast_endftod();/// switches endftod to fast cpp version
150
151 /// Returns an all upper case copy of the string.
152 std::string to_upper(std::string s);
153
154 /// Returns an all lower case copy of the string.
155 std::string to_lower(std::string s);
156
157 /// Returns a capitalized copy of the string.
158 std::string capitalize(std::string s);
159
160 /// Finds and returns the first white-space delimited token of a line.
161 /// \param line a character array to take the first token from.
162 /// \param max_l an upper bound to the length of the token. Must be 11 or less.
163 /// \returns a the flag as a string
164 std::string get_flag(char line[], int max_l);
165
166 /// Creates a copy of \a s with all instances of \a substr taken out.
167 std::string remove_substring(std::string s, std::string substr);
168
169 /// Removes all characters in the string \a chars from \a s.
170 std::string remove_characters(std::string s, std::string chars);
171
172 /// Replaces all instance of \a substr in \a s with \a repstr.
173 std::string replace_all_substrings(std::string s, std::string substr,
174 std::string repstr);
175
176 /// Returns the last character in a string.
177 std::string last_char(std::string s);
178
179 /// Returns the slice of a string \a s using the negative index \a n and the
180 /// length of the slice \a l.
181 std::string slice_from_end(std::string s, int n=-1, int l=1);
182
183 /// Returns true if \a a <= \a b <= \a c and flase otherwise.
184 bool ternary_ge(int a, int b, int c);
185
186 /// Returns true if \a substr is in \a s.
187 bool contains_substring(std::string s, std::string substr);
188
189 /// Calculates a version of the string \a name that is also a valid variable name.
190 /// That is to say that the return value uses only word characters.
191 std::string natural_naming(std::string name);
192
193 /// Finds the slope of a line from the points (\a x1, \a y1) and (\a x2, \a y2).
194 double slope (double x2, double y2, double x1, double y1);
195
196 /// Solves the equation for the line y = mx + b, given \a x and the points that
197 /// form the line: (\a x1, \a y1) and (\a x2, \a y2).
198 double solve_line (double x, double x2, double y2, double x1, double y1);
199
200 double tanh(double x); ///< The hyperbolic tangent function.
201 double coth(double x); ///< The hyperbolic cotangent function.
202
203
204 // File Helpers
205 /// Returns true if the file can be found.
206 bool file_exists(std::string strfilename);
207
208 // Message Helpers
209 extern bool USE_WARNINGS;
210 /// Toggles warnings on and off
211 bool toggle_warnings();
212
213 /// Prints a warning message.
214 void warning(std::string s);
215
216 /// Custom exception to be thrown in the event that a required file is not able to
217 /// be found.
218 class FileNotFound : public std::exception
219 {
220 public:
221
222 /// default constructor
224
225 /// default destructor
226 ~FileNotFound () throw () {};
227
228 /// constructor with the filename \a fname.
229 FileNotFound(std::string fname)
230 {
231 filename = fname;
232 };
233
234 /// Creates a helpful error message.
235 virtual const char* what() const throw()
236 {
237 std::string FNFstr ("File not found: ");
238 if (!filename.empty())
239 FNFstr += filename;
240
241 return (const char *) FNFstr.c_str();
242 };
243
244 private:
245 std::string filename; ///< unfindable filename.
246 };
247
248
249// End PyNE namespace
250}
251
252#endif // PYNE_KMMHYNANYFF5BFMEYIP7TUNLHA
253//
254// end of src/utils.h
255//
256
257
258//
259// start of src/extra_types.h
260//
261/// \file extra_types.h
262/// \author Anthony Scopatz (scopatz\@gmail.com)
263///
264/// Provides some extra types that may be generally useful
265
266#if !defined(_XDRESS_EXTRA_TYPES_)
267#define _XDRESS_EXTRA_TYPES_
268
269#if defined(__cplusplus)
270namespace extra_types
271{
272 /// complex type struct, matching PyTables definition
273// typedef struct {
274// double re; ///< real part
275// double im; ///< imaginary part
276// } complex_t;
277
278 /// Chivalrously handles C++ memory issues that Cython does
279 /// not yet have a syntax for. This is a template class,
280 /// rather than three template functions, because Cython does
281 /// not yet support template function wrapping.
282 template <class T>
283 class MemoryKnight
284 {
285 public:
286 MemoryKnight(){}; ///< Default constructor
287 ~MemoryKnight(){}; ///< Default Destructor
288
289 /// Creates a new instance of type T on the heap using
290 /// its default constructor.
291 /// \return T *
292 T * defnew(){return new T();};
293
294 /// Creates a new instance of type T, using T's default
295 /// constructor, at a given location.
296 /// \param void * ptr, location to create T instance
297 /// \return value of ptr recast as T *
298 T * renew(void * ptr){return new (ptr) T();};
299
300 /// Deallocates a location in memory using delete.
301 /// \param T * ptr, location to remove
302 void deall(T * ptr){delete ptr;};
303 };
304
305// End namespace extra_types
306}
307
308#elif defined(__STDC__)
309
310// de nada
311
312#endif
313
314
315/// complex type struct, matching PyTables definition
316typedef struct {
317 double re; ///< real part
318 double im; ///< imaginary part
320
321#endif
322
323//
324// end of src/extra_types.h
325//
326
327
328//
329// start of src/h5wrap.h
330//
331/// \file h5wrap.h
332/// \author Anthony Scopatz (scopatz\@gmail.com)
333///
334/// \brief Provides some HDF5 helper functionality in its own namespace
335
336#ifndef PYNE_MRNAFG5GNZDNPCRPX3UCBZ5MFE
337#define PYNE_MRNAFG5GNZDNPCRPX3UCBZ5MFE
338
339#include <iostream>
340#include <fstream>
341#include <string>
342#include <map>
343#include <vector>
344#include <set>
345#include <stdio.h>
346#include <stdlib.h>
347#include <exception>
348
349#include "hdf5.h"
350
351#ifndef PYNE_IS_AMALGAMATED
352#include "extra_types.h"
353#endif
354
355//! Wrapper for standard HDF5 operations
356namespace h5wrap
357{
358 /// Custom exception for HDF5 indexing errors.
359 class HDF5BoundsError: public std::exception
360 {
361 /// returns error message.
362 virtual const char* what() const throw()
363 {
364 return "Index of point is out of bounds. Cannot handle in HDF5 file.";
365 };
366 };
367
368
369 /// Custom exception for when an existing file is not in a valid HDF5 format.
370 class FileNotHDF5: public std::exception
371 {
372 public:
373
374 /// default constructor
376
377 /// default destructor
378 ~FileNotHDF5() throw () {};
379
380 /// constructor with the filename
381 FileNotHDF5(std::string fname)
382 {
383 filename = fname;
384 };
385
386 /// helpful error message that includes the filename
387 virtual const char* what() const throw()
388 {
389 std::string FNH5str ("Not a valid HDF5 file: ");
390 if (!filename.empty())
391 FNH5str += filename;
392
393 return (const char *) FNH5str.c_str();
394 };
395
396 private:
397 std::string filename; ///< the file which is not in HDF5 format.
398 };
399
400
401 /// Custom exception for when a group cannot be found in an HDF5 file.
402 class GroupNotFound: public std::exception
403 {
404 public:
405
406 /// default constructor
408
409 /// default destructor
410 ~GroupNotFound() throw () {};
411
412 /// constructor with the filename and the groupname
413 GroupNotFound(std::string fname, std::string gname)
414 {
415 filename = fname;
416 };
417
418 /// helpful error message that includes the filename and the groupname
419 virtual const char* what() const throw()
420 {
421 std::string msg ("the group ");
422 msg += groupname;
423 msg += " not found in the file ";
424 msg += filename;
425 return (const char *) msg.c_str();
426 };
427
428 private:
429 std::string filename; ///< the HDF5 file
430 std::string groupname; ///< the group in the hierarchy
431 };
432
433 /// Custom exception for when a path is not found in an HDF5 file
434 class PathNotFound: public std::exception
435 {
436 public:
437
438 /// default constructor
440
441 /// default destructor
442 ~PathNotFound() throw () {};
443
444 /// constructor with the filename and the pathname
445 PathNotFound(std::string fname, std::string pname)
446 {
447 filename = fname;
448 path = pname;
449 };
450
451 /// helpful error message that includes the filename and the pathname
452 virtual const char* what() const throw()
453 {
454 std::string msg ("the path ");
455 msg += path;
456 msg += " was not found in the HDF5 file ";
457 msg += filename;
458 return (const char *) msg.c_str();
459 };
460
461 private:
462 std::string filename; ///< the HDF5 file
463 std::string path; ///< the path in the file
464 };
465
466
467
468 // Read-in Functions
469
470 /// Retrieves the \a nth index out of the dataset \a dset (which has an HDF5
471 /// datatype \a dtype). The value is returned as the C/C++ type given by \a T.
472 template <typename T>
473 T get_array_index(hid_t dset, int n, hid_t dtype=H5T_NATIVE_DOUBLE)
474 {
475 hsize_t count [1] = {1};
476 hsize_t offset [1] = {static_cast<hsize_t>(n)};
477
478 hid_t dspace = H5Dget_space(dset);
479 hsize_t npoints = H5Sget_simple_extent_npoints(dspace);
480
481 //Handle negative indices
482 if (n < 0)
483 offset[0] = offset[0] + npoints;
484
485 //If still out of range we have a problem
486 if (npoints <= offset[0])
487 throw HDF5BoundsError();
488
489 H5Sselect_hyperslab(dspace, H5S_SELECT_SET, offset, NULL, count, NULL);
490
491 //Set memmory hyperspace
492 hsize_t dimsm[1] = {1};
493 hid_t memspace = H5Screate_simple(1, dimsm, NULL);
494
495 hsize_t count_out [1] = {1};
496 hsize_t offset_out [1] = {0};
497
498 H5Sselect_hyperslab(memspace, H5S_SELECT_SET, offset_out, NULL,
499 count_out, NULL);
500
501 T data_out [1];
502 H5Dread(dset, dtype, memspace, dspace, H5P_DEFAULT, data_out);
503
504 return data_out[0];
505 }
506
507
508 // Conversion functions
509
510 /// Reads in data from an HDF5 file as a C++ set. \a T should roughly match
511 /// \a dtype.
512 /// \param h5file HDF5 file id for an open file.
513 /// \param data_path path to the data in the open file.
514 /// \param dtype HDF5 data type for the data set at \a data_path.
515 /// \return an in memory set of type \a T.
516 template <typename T>
517 std::set<T> h5_array_to_cpp_set(hid_t h5file, std::string data_path, hid_t dtype=H5T_NATIVE_DOUBLE)
518 {
519 std::set<T> cpp_set = std::set<T>();
520 hsize_t arr_len[1];
521 hid_t dset = H5Dopen2(h5file, data_path.c_str(), H5P_DEFAULT);
522
523 // Initilize to dataspace, to find the indices we are looping over
524 hid_t arr_space = H5Dget_space(dset);
525 int arr_dim = H5Sget_simple_extent_dims(arr_space, arr_len, NULL);
526
527 // Read in data from file to memory
528 T * mem_arr = new T [arr_len[0]];
529 H5Dread(dset, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, mem_arr);
530
531 // Load new values into the set
532 cpp_set.insert(&mem_arr[0], &mem_arr[arr_len[0]]);
533
534 H5Dclose(dset);
535
536 delete[] mem_arr;
537 return cpp_set;
538 }
539
540
541 /// Reads in data from an HDF5 file as a 1 dimiensional vector. \a T should roughly
542 /// match \a dtype.
543 /// \param h5file HDF5 file id for an open file.
544 /// \param data_path path to the data in the open file.
545 /// \param dtype HDF5 data type for the data set at \a data_path.
546 /// \return an in memory 1D vector of type \a T.
547 template <typename T>
548 std::vector<T> h5_array_to_cpp_vector_1d(hid_t h5file, std::string data_path,
549 hid_t dtype=H5T_NATIVE_DOUBLE)
550 {
551 std::vector<T> cpp_vec;
552 hsize_t arr_dims [1];
553 hid_t dset = H5Dopen2(h5file, data_path.c_str(), H5P_DEFAULT);
554
555 // Initilize to dataspace, to find the indices we are looping over
556 hid_t arr_space = H5Dget_space(dset);
557 int arr_ndim = H5Sget_simple_extent_dims(arr_space, arr_dims, NULL);
558
559 // Read in data from file to memory
560 T mem_arr [arr_dims[0]];
561 H5Dread(dset, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, mem_arr);
562
563 // Load new values into the vector
564 cpp_vec.assign(mem_arr, mem_arr+arr_dims[0]);
565
566 H5Dclose(dset);
567 return cpp_vec;
568 }
569
570
571 /// Reads in data from an HDF5 file as a 2 dimiensional vector. \a T should roughly
572 /// match \a dtype.
573 /// \param h5file HDF5 file id for an open file.
574 /// \param data_path path to the data in the open file.
575 /// \param dtype HDF5 data type for the data set at \a data_path.
576 /// \return an in memory 2D vector of type \a T.
577 template <typename T>
578 std::vector< std::vector<T> > h5_array_to_cpp_vector_2d(hid_t h5file, std::string data_path,
579 hid_t dtype=H5T_NATIVE_DOUBLE)
580 {
581 hsize_t arr_dims [2];
582 hid_t dset = H5Dopen2(h5file, data_path.c_str(), H5P_DEFAULT);
583
584 // Initilize to dataspace, to find the indices we are looping over
585 hid_t arr_space = H5Dget_space(dset);
586 int arr_ndim = H5Sget_simple_extent_dims(arr_space, arr_dims, NULL);
587
588 // Read in data from file to memory
589 // Have to read in as 1D array to get HDF5 and new keyword
590 // to play nice with each other
591 T mem_arr [arr_dims[0] * arr_dims[1]];
592 H5Dread(dset, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, mem_arr);
593
594 // Load new values into the vector of vectors, using some indexing tricks
595 std::vector< std::vector<T> > cpp_vec (arr_dims[0], std::vector<T>(arr_dims[1]));
596 for(int i = 0; i < arr_dims[0]; i++)
597 {
598 cpp_vec[i].assign(mem_arr+(i*arr_dims[1]), mem_arr+((i+1)*arr_dims[1]));
599 };
600
601 H5Dclose(dset);
602 return cpp_vec;
603 }
604
605
606 /// Reads in data from an HDF5 file as a 3 dimiensional vector. \a T should roughly
607 /// match \a dtype.
608 /// \param h5file HDF5 file id for an open file.
609 /// \param data_path path to the data in the open file.
610 /// \param dtype HDF5 data type for the data set at \a data_path.
611 /// \return an in memory 3D vector of type \a T.
612 template <typename T>
613 std::vector< std::vector< std::vector<T> > > h5_array_to_cpp_vector_3d(hid_t h5file,
614 std::string data_path,
615 hid_t dtype=H5T_NATIVE_DOUBLE)
616 {
617 hsize_t arr_dims [3];
618 hid_t dset = H5Dopen2(h5file, data_path.c_str(), H5P_DEFAULT);
619
620 // Initilize to dataspace, to find the indices we are looping over
621 hid_t arr_space = H5Dget_space(dset);
622 int arr_ndim = H5Sget_simple_extent_dims(arr_space, arr_dims, NULL);
623
624 // Read in data from file to memory
625 // Have to read in as 1D array to get HDF5 and new keyword
626 // to play nice with each other
627 T mem_arr [arr_dims[0] * arr_dims[1] * arr_dims[2]];
628 H5Dread(dset, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, mem_arr);
629
630 // Load new values into the vector of vectors of vectors, using some indexing tricks
631 std::vector< std::vector< std::vector<T> > > cpp_vec (arr_dims[0], std::vector< std::vector<T> >(arr_dims[1], std::vector<T>(arr_dims[2])));
632 for(int i = 0; i < arr_dims[0]; i++)
633 {
634 for(int j = 0; j < arr_dims[1]; j++)
635 {
636 cpp_vec[i][j].assign(mem_arr+((i*arr_dims[1]*arr_dims[2]) + (j*arr_dims[2])), mem_arr+((i*arr_dims[1]*arr_dims[2]) + ((j+1)*arr_dims[2])));
637 };
638 };
639
640 H5Dclose(dset);
641 return cpp_vec;
642 }
643
644
645
646 // Classes
647 /// A class representing a high-level table contruct whose columns all have the same
648 /// type \a T in C/C++ (and the analogous type in HDF5).
649 template <typename T>
651 {
652 public:
653
654 /// default constructor
656
657 /// default destructor
659
660 /// Constructor to load in data upon initialization. \a T should roughly
661 /// match \a dtype.
662 /// \param h5file HDF5 file id for an open file.
663 /// \param data_path path to the data in the open file.
664 /// \param dtype HDF5 data type for the data set at \a data_path.
665 HomogenousTypeTable(hid_t h5file, std::string data_path, hid_t dtype=H5T_NATIVE_DOUBLE)
666 {
667 hid_t h5_set = H5Dopen2(h5file, data_path.c_str(), H5P_DEFAULT);
668 hid_t h5_space = H5Dget_space(h5_set);
669 hid_t h5_type = H5Dget_type(h5_set);
670
671 // set path
672 path = data_path;
673
674 // set shape
675 shape[0] = H5Sget_simple_extent_npoints(h5_space);
676 shape[1] = H5Tget_nmembers(h5_type);
677
678 // set cols
679 std::string * cols_buf = new std::string [shape[1]];
680 for(int n = 0; n < shape[1]; n++)
681 cols_buf[n] = H5Tget_member_name(h5_type, n);
682 cols.assign(cols_buf, cols_buf+shape[1]);
683
684 // set data
685 hid_t col_type;
686 T * col_buf = new T [shape[0]];
687
688 data.clear();
689 for(int n = 0; n < shape[1]; n++)
690 {
691 // Make a compound data type of just this column
692 col_type = H5Tcreate(H5T_COMPOUND, sizeof(T));
693 H5Tinsert(col_type, cols[n].c_str(), 0, dtype);
694
695 // Read in this column
696 H5Dread(h5_set, col_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, col_buf);
697
698 // save this column as a vector in out data map
699 data[cols[n]] = std::vector<T>(col_buf, col_buf+shape[0]);
700 };
701 delete[] col_buf;
702 };
703
704 // Metadata attributes
705 std::string path; ///< path in file to the data
706 int shape [2]; ///< table shape, rows x columns.
707 std::vector<std::string> cols; ///< column names
708 /// mapping from column names to column data
709 std::map<std::string, std::vector<T> > data;
710
711 //
712 // operator overloads
713 //
714 /// index into the table by column name (string)
715 std::vector<T> operator[] (std::string col_name)
716 {
717 return data[col_name];
718 };
719
720 /// index into the table by row
721 std::map<std::string, T> operator[] (int m)
722 {
723 std::map<std::string, T> row = std::map<std::string, T>();
724
725 for(int n = 0; n < shape[1]; n++)
726 row[cols[n]] = data[cols[n]][m];
727
728 return row;
729 };
730 };
731
732
733 /// Create an HDF5 data type for complex 128 bit data, which happens to match the
734 /// complex data type that is used by PyTables ^_~.
736 {
737 hid_t ct = H5Tcreate(H5T_COMPOUND, sizeof(xd_complex_t));
738 H5Tinsert(ct, "r", HOFFSET(xd_complex_t, re), H5T_NATIVE_DOUBLE);
739 H5Tinsert(ct, "i", HOFFSET(xd_complex_t, im), H5T_NATIVE_DOUBLE);
740 return ct;
741 }
742
743 /// The HDF5 id for a complex data type compatible with PyTables generated data.
745
746
747 /// Determines if a path exists in an hdf5 file.
748 /// \param h5file HDF5 file id for an open file.
749 /// \param path path to the data in the open file.
750 /// \return true or false
751 inline bool path_exists(hid_t h5file, std::string path)
752 {
753 bool rtn = false;
754 hid_t ds = H5Dopen2(h5file, path.c_str(), H5P_DEFAULT);
755 if (0 <= ds)
756 {
757 rtn = true;
758 H5Dclose(ds);
759 }
760 else
761 {
762 hid_t grp = H5Gopen2(h5file, path.c_str(), H5P_DEFAULT);
763 if (0 <= grp)
764 {
765 rtn = true;
766 H5Gclose(grp);
767 }
768 }
769 return rtn;
770 }
771
772
773// End namespace h5wrap
774}
775
776
777
778#endif
779//
780// end of src/h5wrap.h
781//
782
783
784//
785// start of src/nucname.h
786//
787/// \brief Converts between naming conventions for nuclides.
788
789#ifndef PYNE_D35WIXV5DZAA5LLOWBY2BL2DPA
790#define PYNE_D35WIXV5DZAA5LLOWBY2BL2DPA
791#include <iostream>
792#include <string>
793#include <map>
794#include <set>
795#include <exception>
796#include <stdlib.h>
797#include <stdio.h>
798
799#ifndef PYNE_IS_AMALGAMATED
800#include "utils.h"
801#endif
802
803namespace pyne
804{
805//! Nuclide naming conventions
806namespace nucname
807{
808 typedef std::string name_t; ///< name type
809 typedef int zz_t; ///< Z number type
810
811 typedef std::map<name_t, zz_t> name_zz_t; ///< name and Z num map type
812 typedef name_zz_t::iterator name_zz_iter; ///< name and Z num iter type
813 name_zz_t get_name_zz(); ///< Creates standard name to Z number mapping.
814 extern name_zz_t name_zz; ///< name to Z num map
815
816 typedef std::map<zz_t, name_t> zzname_t; ///< Z num to name map type
817 typedef zzname_t::iterator zzname_iter; ///< Z num to name iter type
818 zzname_t get_zz_name(); ///< Creates standard Z number to name mapping.
819 extern zzname_t zz_name; ///< Z num to name map
820
821 name_zz_t get_fluka_zz(); ///< Creates standard fluka-name to nucid mapping.
822 extern name_zz_t fluka_zz; ///< fluka-name to nucid map
823 zzname_t get_zz_fluka(); ///< Creates standard nucid to fluka-name mapping.
824 extern zzname_t zz_fluka; ///< nucid to fluka-name map
825 /******************************************/
826 /*** Define useful elemental group sets ***/
827 /******************************************/
828
829 /// name grouping type (for testing containment)
830 typedef std::set<name_t> name_group;
831 typedef name_group::iterator name_group_iter; ///< name grouping iter type
832
833 /// Z number grouping type (for testing containment)
834 typedef std::set<zz_t> zz_group;
835 typedef zz_group::iterator zz_group_iter; ///< Z number grouping iter
836
837 /// Converts a name group to a Z number group.
838 /// \param eg a grouping of nuclides by name
839 /// \return a Z numbered group
841
842 extern name_t LAN_array[15]; ///< array of lanthanide names
843 extern name_group LAN; ///< lanthanide name group
844 extern zz_group lan; ///< lanthanide Z number group
845
846 extern name_t ACT_array[15]; ///< array of actinide names
847 extern name_group ACT; ///< actinide name group
848 extern zz_group act; ///< actinide Z number group
849
850 extern name_t TRU_array[22]; ///< array of transuranic names
851 extern name_group TRU; ///< transuranic name group
852 extern zz_group tru; ///< transuranic Z number group
853
854 extern name_t MA_array[10]; ///< array of minor actinide names
855 extern name_group MA; ///< minor actinide name group
856 extern zz_group ma; ///< minor actinide Z number group
857
858 extern name_t FP_array[88]; ///< array of fission product names
859 extern name_group FP; ///< fission product name group
860 extern zz_group fp; ///< fission product Z number group
861
862
863 /******************/
864 /*** Exceptions ***/
865 /******************/
866
867 /// Custom expection for declaring that a value does not follow a recognizable
868 /// nuclide naming convention.
869 class NotANuclide : public std::exception
870 {
871 public:
872 /// default constructor
874
875 /// default destructor
876 ~NotANuclide () throw () {};
877
878 /// Constructor given previous and current state of nulide name
879 /// \param wasptr Previous state, typically user input.
880 /// \param nowptr Current state, as far as PyNE could get.
881 NotANuclide(std::string wasptr, std::string nowptr)
882 {
883 nucwas = wasptr;
884 nucnow = nowptr;
885 };
886
887 /// Constructor given previous and current state of nulide name
888 /// \param wasptr Previous state, typically user input.
889 /// \param nowptr Current state, as far as PyNE could get.
890 NotANuclide(std::string wasptr, int nowptr)
891 {
892 nucwas = wasptr;
893 nucnow = pyne::to_str(nowptr);
894 };
895
896 /// Constructor given previous and current state of nulide name
897 /// \param wasptr Previous state, typically user input.
898 /// \param nowptr Current state, as far as PyNE could get.
899 NotANuclide(int wasptr, std::string nowptr)
900 {
901 nucwas = pyne::to_str(wasptr);
902 nucnow = nowptr;
903 };
904
905 /// Constructor given previous and current state of nulide name
906 /// \param wasptr Previous state, typically user input.
907 /// \param nowptr Current state, as far as PyNE could get.
908 NotANuclide(int wasptr, int nowptr)
909 {
910 nucwas = pyne::to_str(wasptr);
911 nucnow = pyne::to_str(nowptr);
912 };
913
914 /// Generates an informational message for the exception
915 /// \return The error string
916 virtual const char* what() const throw()
917 {
918 std::string NaNEstr ("Not a Nuclide! ");
919 if (!nucwas.empty())
920 NaNEstr += nucwas;
921
922 if (!nucnow.empty())
923 {
924 NaNEstr += " --> ";
925 NaNEstr += nucnow;
926 }
927 return (const char *) NaNEstr.c_str();
928 };
929
930 private:
931 std::string nucwas; ///< previous nuclide state
932 std::string nucnow; ///< current nuclide state
933 };
934
935 /// Custom expection for declaring that a value represents one or more nuclides
936 /// in one or more namig conventions
937 class IndeterminateNuclideForm : public std::exception
938 {
939 public:
940 /// default constructor
942
943 /// default destuctor
945
946 /// Constructor given previous and current state of nulide name
947 /// \param wasptr Previous state, typically user input.
948 /// \param nowptr Current state, as far as PyNE could get.
949 IndeterminateNuclideForm(std::string wasptr, std::string nowptr)
950 {
951 nucwas = wasptr;
952 nucnow = nowptr;
953 };
954
955 /// Constructor given previous and current state of nulide name
956 /// \param wasptr Previous state, typically user input.
957 /// \param nowptr Current state, as far as PyNE could get.
958 IndeterminateNuclideForm(std::string wasptr, int nowptr)
959 {
960 nucwas = wasptr;
961 nucnow = pyne::to_str(nowptr);
962 };
963
964 /// Constructor given previous and current state of nulide name
965 /// \param wasptr Previous state, typically user input.
966 /// \param nowptr Current state, as far as PyNE could get.
967 IndeterminateNuclideForm(int wasptr, std::string nowptr)
968 {
969 nucwas = pyne::to_str(wasptr);
970 nucnow = nowptr;
971 };
972
973 /// Constructor given previous and current state of nulide name
974 /// \param wasptr Previous state, typically user input.
975 /// \param nowptr Current state, as far as PyNE could get.
976 IndeterminateNuclideForm(int wasptr, int nowptr)
977 {
978 nucwas = pyne::to_str(wasptr);
979 nucnow = pyne::to_str(nowptr);
980 };
981
982 /// Generates an informational message for the exception
983 /// \return The error string
984 virtual const char* what() const throw()
985 {
986 std::string INFEstr ("Indeterminate nuclide form: ");
987 if (!nucwas.empty())
988 INFEstr += nucwas;
989
990 if (!nucnow.empty())
991 {
992 INFEstr += " --> ";
993 INFEstr += nucnow;
994 }
995 return (const char *) INFEstr.c_str();
996 }
997
998 private:
999 std::string nucwas; ///< previous nuclide state
1000 std::string nucnow; ///< current nuclide state
1001 };
1002
1003 /// \name isnuclide functions
1004 /// \{
1005 /// These functions test if an input \a nuc is a valid nuclide.
1006 /// \param nuc a possible nuclide
1007 /// \return a bool
1008 bool isnuclide(std::string nuc);
1009 bool isnuclide(const char * nuc);
1010 bool isnuclide(int nuc);
1011 /// \}
1012
1013 /// \name iselement functions
1014 /// \{
1015 /// These functions test if an input \a nuc is a valid element.
1016 /// \param nuc a possible element
1017 /// \return a bool
1018 bool iselement(std::string nuc);
1019 bool iselement(const char * nuc);
1020 bool iselement(int nuc);
1021
1022 /// \}
1023 /// \name Identifier Form Functions
1024 /// \{
1025 /// The 'id' nuclide naming convention is the canonical form for representing
1026 /// nuclides in PyNE. This is termed a ZAS, or ZZZAAASSSS, representation because
1027 /// It stores 3 Z-number digits, 3 A-number digits, followed by 4 S-number digits
1028 /// which the nucleus excitation state.
1029 ///
1030 /// The id() function will always return an nuclide in id form, if successful.
1031 /// If the input nuclide is in id form already, then this is function does no
1032 /// work. For all other formats, the id() function provides a best-guess based
1033 /// on a heirarchy of other formats that is used to resolve ambiguities between
1034 /// naming conventions. For integer input the form resolution order is:
1035 /// - id
1036 /// - zz (elemental z-num only given)
1037 /// - zzaaam
1038 /// - cinder (aaazzzm)
1039 /// - mcnp
1040 /// - zzaaa
1041 /// For string (or char *) input the form resolution order is as follows:
1042 /// - ZZ-LL-AAAM
1043 /// - Integer form in a string representation, uses interger resolution
1044 /// - NIST
1045 /// - name form
1046 /// - Serpent
1047 /// - LL (element symbol)
1048 /// For well-defined situations where you know ahead of time what format the
1049 /// nuclide is in, you should use the various form_to_id() functions, rather
1050 /// than the id() function which is meant to resolve possibly ambiquous cases.
1051 /// \param nuc a nuclide
1052 /// \return nucid 32-bit integer identifier
1053 int id(int nuc);
1054 int id(const char * nuc);
1055 int id(std::string nuc);
1056 /// \}
1057
1058 /// \name Name Form Functions
1059 /// \{
1060 /// The 'name' nuclide naming convention is the more common, human readable
1061 /// notation. The chemical symbol (one or two characters long) is first, followed
1062 /// by the nucleon number. Lastly if the nuclide is metastable, the letter M is
1063 /// concatenated to the end. For example, ‘H-1’ and ‘Am242M’ are both valid.
1064 /// Note that nucname will always return name form with dashes removed, the
1065 /// chemical symbol used for letter casing (ie 'Pu'), and a trailing upercase 'M'
1066 /// for a metastable flag. The name() function first converts functions to id form
1067 /// using the id() function. Thus the form order resolution for id() also applies
1068 /// here.
1069 /// \param nuc a nuclide
1070 /// \return a string nuclide identifier.
1071 std::string name(int nuc);
1072 std::string name(const char * nuc);
1073 std::string name(std::string nuc);
1074 /// \}
1075
1076 /// \name Z-Number Functions
1077 /// \{
1078 /// The Z-number, or charge number, represents the number of protons in a
1079 /// nuclide. This function returns that number.
1080 /// \param nuc a nuclide
1081 /// \return an integer Z-number.
1082 int znum(int nuc);
1083 int znum(const char * nuc);
1084 int znum(std::string nuc);
1085 /// \}
1086
1087 /// \name A-Number Functions
1088 /// \{
1089 /// The A-number, or nucleon number, represents the number of protons and
1090 /// neutrons in a nuclide. This function returns that number.
1091 /// \param nuc a nuclide
1092 /// \return an integer A-number.
1093 int anum(int nuc);
1094 int anum(const char * nuc);
1095 int anum(std::string nuc);
1096 /// \}
1097
1098 /// \name S-Number Functions
1099 /// \{
1100 /// The S-number, or excitation state number, represents the excitation
1101 /// level of a nuclide. Normally, this is zero. This function returns
1102 /// that number.
1103 /// \param nuc a nuclide
1104 /// \return an integer A-number.
1105 int snum(int nuc);
1106 int snum(const char * nuc);
1107 int snum(std::string nuc);
1108 /// \}
1109
1110 /// \name ZZAAAM Form Functions
1111 /// \{
1112 /// The ZZAAAM nuclide naming convention is the former canonical form for
1113 /// nuclides in PyNE. This places the charge of the nucleus out front, then has
1114 /// three digits for the atomic mass number, and ends with a metastable flag
1115 /// (0 = ground, 1 = first excited state, 2 = second excited state, etc).
1116 /// Uranium-235 here would be expressed as ‘922350’.
1117 /// \param nuc a nuclide
1118 /// \return an integer nuclide identifier.
1119 int zzaaam(int nuc);
1120 int zzaaam(const char * nuc);
1121 int zzaaam(std::string nuc);
1122 /// \}
1123
1124 /// \name ZZAAAM Form to Identifier Form Functions
1125 /// \{
1126 /// This converts from the ZZAAAM nuclide naming convention
1127 /// to the id canonical form for nuclides in PyNE.
1128 /// \param nuc a nuclide in ZZAAAM form.
1129 /// \return an integer id nuclide identifier.
1130 int zzaaam_to_id(int nuc);
1131 int zzaaam_to_id(const char * nuc);
1132 int zzaaam_to_id(std::string nuc);
1133 /// \}
1134
1135
1136 /// \name ZZZAAA Form Functions
1137 /// \{
1138 /// The ZZZAAA nuclide naming convention is a form in which the nuclides three
1139 ///digit ZZZ number is followed by the 3 digit AAA number. If the ZZZ number
1140 ///is 2 digits, the preceding zeros are not included.
1141 /// Uranium-235 here would be expressed as ‘92235’.
1142 /// \param nuc a nuclide
1143 /// \return an integer nuclide identifier.
1144 int zzzaaa(int nuc);
1145 int zzzaaa(const char * nuc);
1146 int zzzaaa(std::string nuc);
1147 /// \}
1148
1149
1150 /// \name ZZZAAA Form to Identifier Form Functions
1151 /// \{
1152 /// This converts from the ZZZAAA nuclide naming convention
1153 /// to the id canonical form for nuclides in PyNE.
1154 /// \param nuc a nuclide in ZZZAAA form.
1155 /// \return an integer id nuclide identifier.
1156 int zzzaaa_to_id(int nuc);
1157 int zzzaaa_to_id(const char * nuc);
1158 int zzzaaa_to_id(std::string nuc);
1159 /// \}
1160
1161
1162 /// \name ZZLLAAAM Form Functions
1163 /// \{
1164 /// The ZZLLAAAM nuclide naming convention is a form in which the nuclides
1165 /// AA number is followed by the redundant two LL characters, followed by
1166 /// the nuclides ZZZ number. Can also be followed with a metastable flag.
1167 /// Uranium-235 here would be expressed as ‘92-U-235’.
1168 /// \param nuc a nuclide
1169 /// \return an integer nuclide identifier.
1170 std::string zzllaaam(int nuc);
1171 std::string zzllaaam(const char * nuc);
1172 std::string zzllaaam(std::string nuc);
1173 /// \}
1174
1175
1176 /// \name ZZLLAAAM Form to Identifier Form Functions
1177 /// \{
1178 /// This converts from the ZZLLAAAM nuclide naming convention
1179 /// to the id canonical form for nuclides in PyNE.
1180 /// \param nuc a nuclide in ZZLLAAAM form.
1181 /// \return an integer id nuclide identifier.
1182 //int zzllaaam_to_id(int nuc);
1183 int zzllaaam_to_id(const char * nuc);
1184 int zzllaaam_to_id(std::string nuc);
1185 /// \}
1186
1187
1188 /// \name MCNP Form Functions
1189 /// \{
1190 /// This is the naming convention used by the MCNP suite of codes.
1191 /// The MCNP format for entering nuclides is unfortunately non-standard.
1192 /// In most ways it is similar to zzaaam form, except that it lacks the metastable
1193 /// flag. For information on how metastable isotopes are named, please consult the
1194 /// MCNP documentation for more information.
1195 /// \param nuc a nuclide
1196 /// \return a string nuclide identifier.
1197 int mcnp(int nuc);
1198 int mcnp(const char * nuc);
1199 int mcnp(std::string nuc);
1200 /// \}
1201
1202 /// \name MCNP Form to Identifier Form Functions
1203 /// \{
1204 /// This converts from the MCNP nuclide naming convention
1205 /// to the id canonical form for nuclides in PyNE.
1206 /// \param nuc a nuclide in MCNP form.
1207 /// \return an integer id nuclide identifier.
1208 int mcnp_to_id(int nuc);
1209 int mcnp_to_id(const char * nuc);
1210 int mcnp_to_id(std::string nuc);
1211 /// \}
1212
1213 /// \name FLUKA Form Functions
1214 /// \{
1215 /// This is the naming convention used by the FLUKA suite of codes.
1216 /// The FLUKA format for entering nuclides requires some knowledge of FLUKA
1217 /// The nuclide in must cases should be the atomic # times 10000000.
1218 /// The exceptions are for FLUKA's named isotopes
1219 /// See the FLUKA Manual for more information.
1220 /// \param nuc a nuclide
1221 /// \return the received FLUKA name
1222 std::string fluka(int nuc);
1223 /// \}
1224
1225 /// \name FLUKA Form to Identifier Form Functions
1226 /// \{
1227 /// This converts from the FLUKA name to the
1228 /// id canonical form for nuclides in PyNE.
1229 /// \param name a fluka name
1230 /// \return an integer id nuclide identifier.
1231 int fluka_to_id(std::string name);
1232 int fluka_to_id(char * name);
1233 /// \}
1234
1235 /// \name Serpent Form Functions
1236 /// \{
1237 /// This is the string-based naming convention used by the Serpent suite of codes.
1238 /// The serpent naming convention is similar to name form. However, only the first
1239 /// letter in the chemical symbol is uppercase, the dash is always present, and the
1240 /// the meta-stable flag is lowercase. For instance, ‘Am-242m’ is the valid serpent
1241 /// notation for this nuclide.
1242 /// \param nuc a nuclide
1243 /// \return a string nuclide identifier.
1244 std::string serpent(int nuc);
1245 std::string serpent(const char * nuc);
1246 std::string serpent(std::string nuc);
1247 /// \}
1248
1249 /// \name Serpent Form to Identifier Form Functions
1250 /// \{
1251 /// This converts from the Serpent nuclide naming convention
1252 /// to the id canonical form for nuclides in PyNE.
1253 /// \param nuc a nuclide in Serpent form.
1254 /// \return an integer id nuclide identifier.
1255 //int serpent_to_id(int nuc); Should be ZAID
1256 int serpent_to_id(const char * nuc);
1257 int serpent_to_id(std::string nuc);
1258 /// \}
1259
1260 /// \name NIST Form Functions
1261 /// \{
1262 /// This is the string-based naming convention used by NIST.
1263 /// The NIST naming convention is also similar to the Serpent form. However, this
1264 /// convention contains no metastable information. Moreover, the A-number comes
1265 /// before the element symbol. For example, ‘242Am’ is the valid NIST notation.
1266 /// \param nuc a nuclide
1267 /// \return a string nuclide identifier.
1268 std::string nist(int nuc);
1269 std::string nist(const char * nuc);
1270 std::string nist(std::string nuc);
1271 /// \}
1272
1273 /// \name NIST Form to Identifier Form Functions
1274 /// \{
1275 /// This converts from the NIST nuclide naming convention
1276 /// to the id canonical form for nuclides in PyNE.
1277 /// \param nuc a nuclide in NIST form.
1278 /// \return an integer id nuclide identifier.
1279 //int serpent_to_id(int nuc); NON-EXISTANT
1280 int nist_to_id(const char * nuc);
1281 int nist_to_id(std::string nuc);
1282 /// \}
1283
1284 /// \name CINDER Form Functions
1285 /// \{
1286 /// This is the naming convention used by the CINDER burnup library.
1287 /// The CINDER format is similar to zzaaam form except that the placement of the
1288 /// Z- and A-numbers are swapped. Therefore, this format is effectively aaazzzm.
1289 /// For example, ‘2420951’ is the valid cinder notation for ‘AM242M’.
1290 /// \param nuc a nuclide
1291 /// \return a string nuclide identifier.
1292 int cinder(int nuc);
1293 int cinder(const char * nuc);
1294 int cinder(std::string nuc);
1295 /// \}
1296
1297 /// \name Cinder Form to Identifier Form Functions
1298 /// \{
1299 /// This converts from the Cinder nuclide naming convention
1300 /// to the id canonical form for nuclides in PyNE.
1301 /// \param nuc a nuclide in Cinder form.
1302 /// \return an integer id nuclide identifier.
1303 int cinder_to_id(int nuc);
1304 int cinder_to_id(const char * nuc);
1305 int cinder_to_id(std::string nuc);
1306 /// \}
1307
1308 /// \name ALARA Form Functions
1309 /// \{
1310 /// This is the format used in the ALARA activation code elements library.
1311 /// For elements, the form is "ll" where ll is the atomic symbol. For isotopes
1312 /// the form is "ll:AAA". No metastable isotope flag is used.
1313 /// \param nuc a nuclide
1314 /// \return a string nuclide identifier.
1315 std::string alara(int nuc);
1316 std::string alara(const char * nuc);
1317 std::string alara(std::string nuc);
1318 /// \}
1319
1320 /// \name ALARA Form to Identifier Form Functions
1321 /// \{
1322 /// This converts from the ALARA nuclide naming convention
1323 /// to the id canonical form for nuclides in PyNE.
1324 /// \param nuc a nuclide in ALARA form.
1325 /// \return an integer id nuclide identifier.
1326 //int alara_to_id(int nuc); NOT POSSIBLE
1327 int alara_to_id(const char * nuc);
1328 int alara_to_id(std::string nuc);
1329 /// \}
1330
1331 /// \name SZA Form Functions
1332 /// \{
1333 /// This is the new format for ACE data tables in the form SSSZZZAAA.
1334 /// The first three digits represent the excited state (000 = ground,
1335 /// 001 = first excited state, 002 = second excited state, etc).
1336 /// The second three digits are the atomic number and the last three
1337 /// digits are the atomic mass. Prepending zeros can be omitted, making
1338 /// the SZA form equal to the MCNP form for non-excited nuclides.
1339 /// \param nuc a nuclide
1340 /// \return a string nuclide identifier.
1341 int sza(int nuc);
1342 int sza(const char * nuc);
1343 int sza(std::string nuc);
1344 /// \}
1345
1346 /// \name SZA Form to Identifier Form Functions
1347 /// \{
1348 /// This converts from the SZA nuclide naming convention
1349 /// to the id canonical form for nuclides in PyNE.
1350 /// \param nuc a nuclide in SZA form.
1351 /// \return an integer id nuclide identifier.
1352 int sza_to_id(int nuc);
1353 int sza_to_id(const char * nuc);
1354 int sza_to_id(std::string nuc);
1355 /// \}
1356
1357 /// \name Ground State Form Functions
1358 /// \{
1359 /// This form stores the nuclide in id form, but removes
1360 /// the state information about the nuclide. I is in the same
1361 /// form as ID, but the four last digits are all zeros.
1362 /// \param nuc a nuclide
1363 /// \return a integer groundstate id
1364 inline int groundstate(int nuc) {return (id(nuc) / 10000 ) * 10000;}
1365 inline int groundstate(std::string nuc) {return groundstate(id(nuc));}
1366 inline int groundstate(const char * nuc) {return groundstate(std::string(nuc));}
1367 /// \}
1368
1369 /// \name State Map functions
1370 /// \{
1371 /// These convert from/to decay state ids (used in decay data)
1372 /// to metastable ids (the PyNE default)
1373 void _load_state_map();
1374 int state_id_to_id(int state);
1375 int id_to_state_id(int nuc_id);
1376 extern std::map<int, int> state_id_map;
1377 /// \}
1378
1379 /// \name ENSDF Form Functions
1380 /// \{
1381 /// This converts id's stored using standard ensdf syntax to nuc_id's
1382 /// \param ensdf nuc string
1383 /// \return PyNE nuc_id
1384 int ensdf_to_id(const char * nuc);
1385 int ensdf_to_id(std::string nuc);
1386 /// \}
1387
1388}
1389}
1390
1391#endif // PYNE_D35WIXV5DZAA5LLOWBY2BL2DPA
1392//
1393// end of src/nucname.h
1394//
1395
1396
1397//
1398// start of src/rxname.h
1399//
1400/// \brief Converts between naming conventions for reaction channels.
1401
1402#ifndef PYNE_7DOEB2PKSBEFFIA3Q2NARI3KFY
1403#define PYNE_7DOEB2PKSBEFFIA3Q2NARI3KFY
1404#include <utility>
1405#include <iostream>
1406#include <string>
1407#include <map>
1408#include <set>
1409#include <exception>
1410#include <stdlib.h>
1411#include <stdio.h>
1412
1413#ifndef PYNE_IS_AMALGAMATED
1414#include "utils.h"
1415#include "nucname.h"
1416#endif
1417
1418/// Number of reactions supported by default.
1419#define NUM_RX_NAMES 572
1420
1421namespace pyne
1422{
1423//! Converts between naming conventions for reaction channels.
1424namespace rxname
1425{
1426 extern std::string _names[NUM_RX_NAMES]; ///< Raw array of reaction names
1427 /// Set of reaction names, must be valid variable names.
1428 extern std::set<std::string> names;
1429 /// Mapping from reaction ids to reaction names.
1430 extern std::map<unsigned int, std::string> id_name;
1431 /// Mapping from reaction names to reaction ids.
1432 extern std::map<std::string, unsigned int> name_id;
1433 /// Mapping between alternative names for reactions and the reaction id.
1434 extern std::map<std::string, unsigned int> altnames;
1435 /// Mapping from reaction ids to MT numbers.
1436 extern std::map<unsigned int, unsigned int> id_mt;
1437 /// Mapping from MT numbers to reaction names.
1438 extern std::map<unsigned int, unsigned int> mt_id;
1439 /// Mapping from reaction ids to labels (short descriptions).
1440 extern std::map<unsigned int, std::string> labels;
1441 /// Mapping from reaction ids to documentation strings (long descriptions).
1442 extern std::map<unsigned int, std::string> docs;
1443 /// Mapping from particle type and offset pairs to reaction ids.
1444 /// Particle flags are 'n', 'p', 'd', 't', 'He3', 'a', 'gamma', and 'decay'.
1445 extern std::map<std::pair<std::string, int>, unsigned int> offset_id;
1446 /// Mapping from particle type and reaction ids to offsets.
1447 /// Particle flags are 'n', 'p', 'd', 't', 'He3', 'a', 'gamma', and 'decay'.
1448 extern std::map<std::pair<std::string, unsigned int>, int> id_offset;
1449
1450 /// A helper function to set the contents of the variables in this library.
1451 void * _fill_maps();
1452 extern void * _; ///< A dummy variable used when calling #_fill_maps().
1453
1454 /// A helper function to compute nuclide id offsets from z-, a-, and s- deltas
1455 inline int offset(int dz, int da, int ds=0) {return dz*10000000 + da*10000 + ds;}
1456
1457 /// \name Hash Functions
1458 /// \{
1459 /// Custom hash function for reaction name to reaction ids.
1460 /// This functions will not return a value less than 1000, effectively reserving
1461 /// space for the MT numbers.
1462 unsigned int hash(std::string s);
1463 unsigned int hash(const char * s);
1464 /// \}
1465
1466 /// \name Name Functions
1467 /// \{
1468 /// Returns the canonical name of a reaction channel.
1469 /// \param n Integer input of possible reaction, nominally an id or MT number.
1470 /// \param s String input of possible reaction, often a reaction or alternate name.
1471 /// \param from_nuc Initial target nuclide prior to reaction. When \a from_nuc is
1472 /// an integer it must be in id form.
1473 /// \param to_nuc Target nuclide after reaction occurs. When \a to_nuc is
1474 /// an integer it must be in id form.
1475 /// \param z Flag for incident particle type.
1476 /// Particle flags are 'n', 'p', 'd', 't', 'He3', 'a', 'gamma', and 'decay'.
1477 std::string name(int n);
1478 std::string name(unsigned int n);
1479 std::string name(char * s);
1480 std::string name(std::string s);
1481 std::string name(int from_nuc, int to_nuc, std::string z="n");
1482 std::string name(int from_nuc, std::string to_nuc, std::string z="n");
1483 std::string name(std::string from_nuc, int to_nuc, std::string z="n");
1484 std::string name(std::string from_nuc, std::string to_nuc, std::string z="n");
1485 /// \}
1486
1487 /// \name ID Functions
1488 /// \{
1489 /// Returns the recation id of a reaction channel. This id has been precomputed
1490 /// from the hash of the name.
1491 /// \param x Input reaction specification, may be a reaction name, alternate name,
1492 /// an id, or an MT number.
1493 /// \param from_nuc Initial target nuclide prior to reaction. When \a from_nuc is
1494 /// an integer it must be in id form.
1495 /// \param to_nuc Target nuclide after reaction occurs. When \a to_nuc is
1496 /// an integer it must be in id form.
1497 /// \param z Flag for incident particle type.
1498 /// Particle flags are 'n', 'p', 'd', 't', 'He3', 'a', 'gamma', and 'decay'.
1499 unsigned int id(int x);
1500 unsigned int id(unsigned int x);
1501 unsigned int id(const char * x);
1502 unsigned int id(std::string x);
1503 unsigned int id(int from_nuc, int to_nuc, std::string z="n");
1504 unsigned int id(int from_nuc, std::string to_nuc, std::string z="n");
1505 unsigned int id(std::string from_nuc, int to_nuc, std::string z="n");
1506 unsigned int id(std::string from_nuc, std::string to_nuc, std::string z="n");
1507 /// \}
1508
1509 /// \name MT Number Functions
1510 /// \{
1511 /// Returns the MT number of a reaction channel, if available.
1512 /// \param x Input reaction specification, may be a reaction name, alternate name,
1513 /// an id, or an MT number.
1514 /// \param from_nuc Initial target nuclide prior to reaction. When \a from_nuc is
1515 /// an integer it must be in id form.
1516 /// \param to_nuc Target nuclide after reaction occurs. When \a to_nuc is
1517 /// an integer it must be in id form.
1518 /// \param z Flag for incident particle type.
1519 /// Particle flags are 'n', 'p', 'd', 't', 'He3', 'a', 'gamma', and 'decay'.
1520 unsigned int mt(int x);
1521 unsigned int mt(unsigned int x);
1522 unsigned int mt(char * x);
1523 unsigned int mt(std::string x);
1524 unsigned int mt(int from_nuc, int to_nuc, std::string z="n");
1525 unsigned int mt(int from_nuc, std::string to_nuc, std::string z="n");
1526 unsigned int mt(std::string from_nuc, int to_nuc, std::string z="n");
1527 unsigned int mt(std::string from_nuc, std::string to_nuc, std::string z="n");
1528 /// \}
1529
1530 //// \name Label Functions
1531 /// \{
1532 /// Returns a short description of a reaction channel.
1533 /// \param x Input reaction specification, may be a reaction name, alternate name,
1534 /// an id, or an MT number.
1535 /// \param from_nuc Initial target nuclide prior to reaction. When \a from_nuc is
1536 /// an integer it must be in id form.
1537 /// \param to_nuc Target nuclide after reaction occurs. When \a to_nuc is
1538 /// an integer it must be in id form.
1539 /// \param z Flag for incident particle type.
1540 /// Particle flags are 'n', 'p', 'd', 't', 'He3', 'a', 'gamma', and 'decay'.
1541 std::string label(int x);
1542 std::string label(unsigned int x);
1543 std::string label(char * x);
1544 std::string label(std::string x);
1545 std::string label(int from_nuc, int to_nuc, std::string z="n");
1546 std::string label(int from_nuc, std::string to_nuc, std::string z="n");
1547 std::string label(std::string from_nuc, int to_nuc, std::string z="n");
1548 std::string label(std::string from_nuc, std::string to_nuc, std::string z="n");
1549 /// \}
1550
1551 /// \name Documentation Functions
1552 /// \{
1553 /// Returns a short description of a reaction channel.
1554 /// \param x Input reaction specification, may be a reaction name, alternate name,
1555 /// an id, or an MT number.
1556 /// \param from_nuc Initial target nuclide prior to reaction. When \a from_nuc is
1557 /// an integer it must be in id form.
1558 /// \param to_nuc Target nuclide after reaction occurs. When \a to_nuc is
1559 /// an integer it must be in id form.
1560 /// \param z Flag for incident particle type.
1561 /// Particle flags are 'n', 'p', 'd', 't', 'He3', 'a', 'gamma', and 'decay'.
1562 std::string doc(int x);
1563 std::string doc(unsigned int x);
1564 std::string doc(char * x);
1565 std::string doc(std::string x);
1566 std::string doc(int from_nuc, int to_nuc, std::string z="n");
1567 std::string doc(int from_nuc, std::string to_nuc, std::string z="n");
1568 std::string doc(std::string from_nuc, int to_nuc, std::string z="n");
1569 std::string doc(std::string from_nuc, std::string to_nuc, std::string z="n");
1570 /// \}
1571
1572 /// \name Child Functions
1573 /// \{
1574 /// Returns the child nuclide comming from a parent for a reaction channel.
1575 /// \param nuc Nuclide after reaction occurs. When \a nuc is
1576 /// an integer it must be in id form.
1577 /// \param rx Input reaction specification, may be a reaction name, alternate name,
1578 /// an id, or an MT number.
1579 /// \param z Flag for incident particle type.
1580 /// Particle flags are 'n', 'p', 'd', 't', 'He3', 'a', 'gamma', and 'decay'.
1581 int parent(int nuc, unsigned int rx, std::string z="n");
1582 int parent(int nuc, std::string rx, std::string z="n");
1583 int parent(std::string nuc, unsigned int rx, std::string z="n");
1584 int parent(std::string nuc, std::string rx, std::string z="n");
1585 /// \}
1586
1587 /// \name Parent Functions
1588 /// \{
1589 /// Returns the parent nuclide comming for a child and a given reaction channel.
1590 /// \param nuc Initial target nuclide prior to reaction. When \a nuc is
1591 /// an integer it must be in id form.
1592 /// \param rx Input reaction specification, may be a reaction name, alternate name,
1593 /// an id, or an MT number.
1594 /// \param z Flag for incident particle type.
1595 /// Particle flags are 'n', 'p', 'd', 't', 'He3', 'a', 'gamma', and 'decay'.
1596 int child(int nuc, unsigned int rx, std::string z="n");
1597 int child(int nuc, std::string rx, std::string z="n");
1598 int child(std::string nuc, unsigned int rx, std::string z="n");
1599 int child(std::string nuc, std::string rx, std::string z="n");
1600 /// \}
1601
1602 /// Custom exception for declaring a value not to be a valid reaction.
1603 class NotAReaction : public std::exception
1604 {
1605 public:
1606
1607 /// default constructor
1609
1610 /// default destructor
1611 ~NotAReaction () throw () {};
1612
1613 /// Constructor using original reaction (\a wasptr) and the eventual state
1614 /// that PyNE calculated (\a nowptr).
1615 NotAReaction(std::string wasptr, std::string nowptr)
1616 {
1617 rxwas = wasptr;
1618 rxnow = nowptr;
1619 };
1620
1621 /// Constructor using original reaction (\a wasptr) and the eventual state
1622 /// that PyNE calculated (\a nowptr).
1623 NotAReaction(std::string wasptr, int nowptr)
1624 {
1625 rxwas = wasptr;
1626 rxnow = pyne::to_str(nowptr);
1627 };
1628
1629 /// Constructor using original reaction (\a wasptr) and the eventual state
1630 /// that PyNE calculated (\a nowptr).
1631 NotAReaction(int wasptr, std::string nowptr)
1632 {
1633 rxwas = pyne::to_str(wasptr);
1634 rxnow = nowptr;
1635 };
1636
1637 /// Constructor using original reaction (\a wasptr) and the eventual state
1638 /// that PyNE calculated (\a nowptr).
1639 NotAReaction(int wasptr, int nowptr)
1640 {
1641 rxwas = pyne::to_str(wasptr);
1642 rxnow = pyne::to_str(nowptr);
1643 };
1644
1645 /// Constructor using original reaction (\a wasptr) and the eventual state
1646 /// that PyNE calculated (\a nowptr).
1647 NotAReaction(std::string wasptr, unsigned int nowptr)
1648 {
1649 rxwas = wasptr;
1650 rxnow = pyne::to_str(nowptr);
1651 };
1652
1653 /// Constructor using original reaction (\a wasptr) and the eventual state
1654 /// that PyNE calculated (\a nowptr).
1655 NotAReaction(unsigned int wasptr, std::string nowptr)
1656 {
1657 rxwas = pyne::to_str(wasptr);
1658 rxnow = nowptr;
1659 };
1660
1661 /// Constructor using original reaction (\a wasptr) and the eventual state
1662 /// that PyNE calculated (\a nowptr).
1663 NotAReaction(unsigned int wasptr, unsigned int nowptr)
1664 {
1665 rxwas = pyne::to_str(wasptr);
1666 rxnow = pyne::to_str(nowptr);
1667 };
1668
1669 /// Returns a helpful error message containing prior and current reaction state.
1670 virtual const char* what() const throw()
1671 {
1672 std::string narxstr ("Not a reaction! ");
1673 if (!rxwas.empty())
1674 narxstr += rxwas;
1675
1676 if (!rxnow.empty())
1677 {
1678 narxstr += " --> ";
1679 narxstr += rxnow;
1680 }
1681 return (const char *) narxstr.c_str();
1682 };
1683
1684 private:
1685 std::string rxwas; ///< previous reaction state
1686 std::string rxnow; ///< current reaction state
1687 };
1688
1689
1690
1691 /// Custom exception for declaring a value not to be of ambiquous reaction form.
1692 class IndeterminateReactionForm : public std::exception
1693 {
1694 public:
1695
1696 /// default constructor
1698
1699 /// default destructor
1701
1702 /// Constructor using original reaction (\a wasptr) and the eventual state
1703 /// that PyNE calculated (\a nowptr).
1704 IndeterminateReactionForm(std::string wasptr, std::string nowptr)
1705 {
1706 rxwas = wasptr;
1707 rxnow = nowptr;
1708 };
1709
1710 /// Constructor using original reaction (\a wasptr) and the eventual state
1711 /// that PyNE calculated (\a nowptr).
1712 IndeterminateReactionForm(std::string wasptr, int nowptr)
1713 {
1714 rxwas = wasptr;
1715 rxnow = pyne::to_str(nowptr);
1716 };
1717
1718 /// Constructor using original reaction (\a wasptr) and the eventual state
1719 /// that PyNE calculated (\a nowptr).
1720 IndeterminateReactionForm(int wasptr, std::string nowptr)
1721 {
1722 rxwas = pyne::to_str(wasptr);
1723 rxnow = nowptr;
1724 };
1725
1726 /// Constructor using original reaction (\a wasptr) and the eventual state
1727 /// that PyNE calculated (\a nowptr).
1728 IndeterminateReactionForm(int wasptr, int nowptr)
1729 {
1730 rxwas = pyne::to_str(wasptr);
1731 rxnow = pyne::to_str(nowptr);
1732 };
1733
1734 /// Returns a helpful error message containing prior and current reaction state.
1735 virtual const char* what() const throw()
1736 {
1737 std::string INFEstr ("Indeterminate reaction form: ");
1738 if (!rxwas.empty())
1739 INFEstr += rxwas;
1740
1741 if (!rxnow.empty())
1742 {
1743 INFEstr += " --> ";
1744 INFEstr += rxnow;
1745 }
1746 return (const char *) INFEstr.c_str();
1747 }
1748
1749 private:
1750 std::string rxwas; ///< previous reaction state
1751 std::string rxnow; ///< current reaction state
1752 };
1753}
1754}
1755
1756#endif // PYNE_7DOEB2PKSBEFFIA3Q2NARI3KFY
1757//
1758// end of src/rxname.h
1759//
1760
1761
1762//
1763// start of src/_atomic_data.h
1764//
1765/// \/file atomic_nuclear_data.h
1766/// \/author Andrew Davis (andrew.davis@wisc.edu)
1767///
1768/// \/brief Impliments all the fundamental atomic & nuclear data data
1769#include <map>
1770
1771namespace pyne
1772{
1773 /// main function to be called when you whish to load the nuclide data
1774 /// into memory
1776 /// function to create mapping from nuclides in id form
1777 /// to their atomic masses
1778
1780
1781 /// function to create mapping from nuclides in id form
1782 /// to their natural abundances
1783 void _insert_abund_map();
1784
1785 /// Mapping from nuclides in id form to their natural abundances
1786 extern std::map<int,double> natural_abund_map;
1787
1788 /// Mapping from nuclides in id form to their atomic masses.
1789 extern std::map<int,double> atomic_mass_map;
1790
1791 /// Mapping from nuclides in id form to the associated error in
1792 /// abdundance
1793 extern std::map<int,double> atomic_mass_error_map;
1794} // namespace pyne
1795//
1796// end of src/_atomic_data.h
1797//
1798
1799
1800//
1801// start of src/data.h
1802//
1803/// \file data.h
1804/// \author Anthony Scopatz (scopatz\@gmail.com)
1805///
1806/// \brief Implements basic nuclear data functions.
1807
1808#ifndef PYNE_TEWK4A7VOFFLHDDXD5ZZ7KPXEQ
1809#define PYNE_TEWK4A7VOFFLHDDXD5ZZ7KPXEQ
1810#include <iostream>
1811#include <string>
1812#include <utility>
1813#include <map>
1814#include <set>
1815#include <limits>
1816#include <exception>
1817#include <stdlib.h>
1818#include <stdio.h>
1819#include <float.h>
1820#include <math.h>
1821
1822#include "hdf5.h"
1823#include "hdf5_hl.h"
1824
1825#ifndef PYNE_IS_AMALGAMATED
1826#include "h5wrap.h"
1827#include "extra_types.h"
1828#include "utils.h"
1829#include "nucname.h"
1830#include "rxname.h"
1831#endif
1832
1833namespace pyne
1834{
1835 /// \name Mathematical and Physical Constants
1836 /// \{
1837 extern const double pi; ///< pi = 3.14159265359
1838 extern const double N_A; ///< Avogadro's Number
1839 extern const double barns_per_cm2; ///< barns per cm^2
1840 extern const double cm2_per_barn; ///< cm^2 per barn
1841 extern const double sec_per_day; ///< seconds per day
1842 extern const double MeV_per_K; ///< MeV per Kelvin
1843 extern const double MeV_per_MJ; ///< MeV per MJ
1844 extern const double Bq_per_Ci; ///< Becquerel per Curie
1845 extern const double Ci_per_Bq; ///< Curies per Becquerel
1846 /// \}
1847
1848 extern std::string NUC_DATA_PATH; ///< Path to the nuc_data.h5 file.
1849
1850 /// Mapping from nodes in nuc_data.h5 to hashes of nodes
1851 extern std::map<std::string, std::string> data_checksums;
1852
1853 /// \name Atomic Mass Data
1854 /// \{
1855
1856 /// Mapping from nuclides in id form to their atomic masses.
1857 extern std::map<int, double> atomic_mass_map;
1858
1859 /// a struct matching the atomic_mass table in nuc_data.h5.
1860 typedef struct atomic_mass_data {
1861 int nuc; ///< nuclide in id form
1862 double mass; ///< nuclide atomic mass [amu]
1863 double error; ///< error in atomic mass [amu]
1864 double abund; ///< natural abundance of nuclide [atom fraction]
1866
1867 // Loads preset dataset hashes into memory.
1868 std::map<std::string, std::string> get_data_checksums();
1869
1870 /// Loads the atomic mass and natural abundance data from the nuc_data.h5 file
1871 /// into memory.
1872 void _load_atomic_mass_map();
1873
1874 /// \brief Returns the atomic mass of a nuclide \a nuc.
1875 ///
1876 /// This function will first try to find the atomic mass data in the atomic_mass_map.
1877 /// If this map is empty, it will load the data from disk. If the nuclide is in an
1878 /// excited state and not found in the map, it will give the value for the ground
1879 /// state nuclide. If the nuclide simply cannot be found, the A number is returned.
1880 double atomic_mass(int nuc);
1881 /// Returns the atomic mass of a nuclide \a nuc.
1882 double atomic_mass(char * nuc);
1883 /// Returns the atomic mass of a nuclide \a nuc.
1884 double atomic_mass(std::string nuc);
1885 /// \}
1886
1887
1888 /// \name Natural Abundance Data
1889 /// \{
1890
1891 /// Mapping from nuclides in id form to their natural abundances.
1892 extern std::map<int, double> natural_abund_map;
1893
1894 /// \brief Returns the natural abundance of a nuclide \a nuc.
1895 ///
1896 /// This follows the same the basic rules for finding or computing the natural
1897 /// abundances as the atomic_mass() functions do. However, if the nuclide cannot
1898 /// be found, the default value returned is 0.0.
1899 double natural_abund(int nuc);
1900 /// Returns the natural abundance of a nuclide \a nuc.
1901 double natural_abund(char * nuc);
1902 /// Returns the natural abundance of a nuclide \a nuc.
1903 double natural_abund(std::string nuc);
1904 /// \}
1905
1906
1907
1908 /// \name Q_value Data
1909 /// \{
1910
1911 /// Mapping from nuclides in id form to their q_values and
1912 /// the fraction of Q that comes from gammas.
1913 extern std::map<int, double> q_val_map;
1914 extern std::map<int, double> gamma_frac_map;
1915
1916 /// a struct matching the q_value table in nuc_data.h5.
1917 typedef struct q_val_data {
1918 int nuc; ///< nuclide in id form
1919 double q_val; ///< nuclide q_value [MeV/fission]
1920 double gamma_frac; ///< fraction of q that comes from gammas
1922
1923 /// Loads the q_value data from the nuc_data.h5 file into memory.
1924 void _load_q_val_map();
1925
1926 /// \brief Returns the q_value of a nuclide \a nuc.
1927 ///
1928 /// This function will first try to find the q_value data in the q_val_map.
1929 /// If this map is empty, it will load the data from disk. If the nuclide simply
1930 /// cannot be found, the default value returned is 0.0.
1931 double q_val(int nuc);
1932 double q_val(const char * nuc);
1933 double q_val(std::string nuc);
1934 double gamma_frac(int nuc);
1935 double gamma_frac(const char * nuc);
1936 double gamma_frac(std::string nuc);
1937 /// \}
1938
1939
1940 /// \name Dose Factor Data
1941 /// \{
1942
1943 /// A struct matching the dose factor table in nuc_data.h5.
1944 typedef struct dose {
1945 int nuc; ///< nuclide in id form
1946 double ext_air_dose; ///< nuclide ext_air dose factor [mrem/h per Ci/m^3]
1947 double ratio; ///< ratio of external air dose factor to dose factor due to inhalation
1948 double ext_soil_dose; ///< nuclide ext_soil dose factor [mrem/h per Ci/m^2]
1949 double ingest_dose; ///< nuclide dose factor due to ingestion [mrem/pCi]
1950 double fluid_frac; ///< fraction of activity abosorbed in body fluids
1951 double inhale_dose; ///< nuclide dose factor due to inhalation [mrem/pCi]
1952 char lung_mod; ///< model of lung used (time of biological half life-- D, W, or Y)
1954
1955 /// Mapping from int to dose for 3 sources
1956 extern std::map<int, dose> epa_dose_map;
1957 extern std::map<int, dose> doe_dose_map;
1958 extern std::map<int, dose> genii_dose_map;
1959
1960 /// Loads the dose factor data from the nuc_data.h5 file into memory
1961 /// according to the user-input source.
1962 void _load_dose_map(std::map<int, dose>& dm, std::string source_path);
1963
1964 /// \brief Returns the dose factors of a nuclide.
1965 ///
1966 /// These functions will first try to find the dose factor data in the dose_maps.
1967 /// If the maps are empty, it will load the data from disk. If the nuclide simply
1968 /// cannot be found, the default value returned is -1.
1969 double ext_air_dose(int nuc, int source);
1970 double ext_air_dose(const char * nuc, int source);
1971 double ext_air_dose(std::string nuc, int source);
1972 double ext_soil_dose(int nuc, int source);
1973 double ext_soil_dose(const char * nuc, int source);
1974 double ext_soil_dose(std::string nuc, int source);
1975 double ingest_dose(int nuc, int source);
1976 double ingest_dose(const char * nuc, int source);
1977 double ingest_dose(std::string nuc, int source);
1978 double inhale_dose(int nuc, int source);
1979 double inhale_dose(const char * nuc, int source);
1980 double inhale_dose(std::string nuc, int source);
1981 double dose_ratio(int nuc, int source);
1982 double dose_ratio(const char * nuc, int source);
1983 double dose_ratio(std::string nuc, int source);
1984 double dose_fluid_frac(int nuc, int source);
1985 double dose_fluid_frac(const char * nuc, int source);
1986 double dose_fluid_frac(std::string nuc, int source);
1987 std::string dose_lung_model(int nuc, int source);
1988 std::string dose_lung_model(const char * nuc, int source);
1989 std::string dose_lung_model(std::string nuc, int source);
1990 /// \}
1991
1992
1993
1994 /// \name Scattering Length Data
1995 /// \{
1996
1997 /// Mapping from nuclides in id form to their coherent scattering length.
1998 extern std::map<int, xd_complex_t> b_coherent_map;
1999 /// Mapping from nuclides in id form to their incoherent scattering length.
2000 extern std::map<int, xd_complex_t> b_incoherent_map;
2001 /// Mapping from nuclides in id form to their scattering length.
2002 extern std::map<int, double> b_map;
2003
2004 /// a struct matching the '/neutron/scattering_lengths' table in nuc_data.h5.
2005 typedef struct scattering_lengths {
2006 int nuc; ///< nuclide in id form
2007 xd_complex_t b_coherent; ///< coherent scattering length [cm]
2008 xd_complex_t b_incoherent; ///< incoherent scattering length [cm]
2009 double xs_coherent; ///< coherent scattering cross section
2010 double xs_incoherent; ///< incoherent scattering cross section
2011 double xs; ///< scattering cross section
2013
2014 /// Loads the scattering length data from the nuc_data.h5 file into memory.
2016
2017 /// \brief Finds the coherent scattering length [cm] for a nuclide \a nuc.
2018 ///
2019 /// This function works by first checking the b_coherent_map. If the map is empty
2020 /// then the data is read in from disk. If no data is found than a value from a
2021 /// nuclide with the same A number is returned instead. If none of these exist,
2022 /// then the value of a nuclide with the same Z number is used. If none of these
2023 /// work then 0.0 is returned.
2024 xd_complex_t b_coherent(int nuc);
2025 /// Finds the coherent scattering length [cm] for a nuclide \a nuc.
2026 xd_complex_t b_coherent(char * nuc);
2027 /// Finds the coherent scattering length [cm] for a nuclide \a nuc.
2028 xd_complex_t b_coherent(std::string nuc);
2029
2030 /// \brief Finds the incoherent scattering length [cm] for a nuclide \a nuc.
2031 ///
2032 /// This function works in the same way that b_coherent() does.
2033 xd_complex_t b_incoherent(int nuc);
2034 /// Finds the incoherent scattering length [cm] for a nuclide \a nuc.
2035 xd_complex_t b_incoherent(char * nuc);
2036 /// Finds the incoherent scattering length [cm] for a nuclide \a nuc.
2037 xd_complex_t b_incoherent(std::string nuc);
2038
2039 /// Computes the scattering length [cm] from the coherent and incoherent components.
2040 double b(int nuc);
2041 /// Computes the scattering length [cm] from the coherent and incoherent components.
2042 double b(char * nuc);
2043 /// Computes the scattering length [cm] from the coherent and incoherent components.
2044 double b(std::string nuc);
2045 /// \}
2046
2047
2048 /// \name Fission Product Yield Data
2049 /// \{
2050
2051 /// Mapping from nuclides in id form to their scattering length.
2052 extern std::map<std::pair<int, int>, double> wimsdfpy_data;
2053
2054 /// a struct matching the '/neutron/wimsd_fission_product' table in nuc_data.h5.
2055 typedef struct wimsdfpy {
2056 int from_nuc; ///< from nuclide in id form
2057 int to_nuc; ///< from nuclide in id form
2058 double yields; ///< fission product yield, fraction [unitless]
2060
2061 /// Loads the WIMSD fission product yield data from the nuc_data.h5 file into memory.
2062 void _load_wimsdfpy();
2063
2064 /// a struct matching the '/neutron/nds_fission_product' table in nuc_data.h5
2065 typedef struct ndsfpy {
2066 int from_nuc; ///< id of fissioning nuclide
2067 int to_nuc; ///< id of fission product
2068 double yield_thermal; ///< thermal yield [fraction]
2069 double yield_thermal_err; ///< thermal yield error [fraction]
2070 double yield_fast; ///< fast yield [fraction]
2071 double yield_fast_err; ///< fast yield error [fraction]
2072 double yield_14MeV; ///< 14 MeV yield [fraction]
2073 double yield_14MeV_err; ///< 14 MeV yield error [fraction]
2075
2076 /// a struct for the nds data for fpyield
2077 typedef struct ndsfpysub {
2078 double yield_thermal; ///< thermal yield [fraction]
2079 double yield_thermal_err; ///< thermal yield error [fraction]
2080 double yield_fast; ///< fast yield [fraction]
2081 double yield_fast_err; ///< fast yield error [fraction]
2082 double yield_14MeV; ///< 14 MeV yield [fraction]
2083 double yield_14MeV_err; ///< 14 MeV yield error [fraction]
2085
2086
2087 extern std::map<std::pair<int, int>, ndsfpysub> ndsfpy_data;
2088
2089 /// Loads the NDS fission product yield data from the nuc_data.h5 file into memory.
2090 void _load_ndsfpy();
2091
2092 /// \brief Returns the fission product yield for a parent/child nuclide pair
2093 ///
2094 /// This function works by first checking the fission yield data. If this is
2095 /// empty it loads the data from disk. If the parent/child nuclide pair
2096 /// is still not found, then the process is assumed to be impossible
2097 /// and 0.0 is returned. The data source is determined by the type value
2098 /// as follows: 0 WIMS, 1 thermal NDS, 2 fast NDS, 3 14 MeV NDS.
2099 /// negative type values return error for that data type.
2100 double fpyield(std::pair<int, int> from_to, int source, bool get_error);
2101 /// Returns the fission product yield for a parent/child nuclide pair
2102 double fpyield(int from_nuc, int to_nuc, int source, bool get_error);
2103 /// Returns the fission product yield for a parent/child nuclide pair
2104 double fpyield(char * from_nuc, char * to_nuc, int source, bool get_error);
2105 /// Returns the fission product yield for a parent/child nuclide pair
2106 double fpyield(std::string from_nuc, std::string to_nuc, int source, bool get_error);
2107
2108 /// \}
2109
2110
2111 /// \name Decay Data
2112 /// \{
2113
2114 /// Data access functions
2115
2116 /// simple class to swap the order in which a pair is compared
2118 public:
2119 /// This operator compares the second item in a pair first
2120 bool operator()(const std::pair<int, double>& lhs,
2121 const std::pair<int, double>& rhs) const;
2122 };
2123
2124 /// Access data in a std::map<std::pair<int, double> for a range of
2125 /// values of the second member of the pair. Returns a vector of all
2126 /// values at valoffset of class U of type T f
2127 template<typename T, typename U> std::vector<T> data_access(double emin,
2128 double emax, size_t valoffset, std::map<std::pair<int, double>, U> &data);
2129 /// Access data in a std::map<std::pair<int, double> for a given
2130 /// value of the first member of the pair. Returns a vector of all
2131 /// values at valoffset of class U of type T
2132 template<typename T, typename U> std::vector<T> data_access(int parent,
2133 double min, double max, size_t valoffset,
2134 std::map<std::pair<int, double>, U> &data);
2135 /// Access data in a std::map<std::pair<int, int> for a given
2136 /// matching pair. Returns the value at valoffset of
2137 /// class U of type T
2138 template<typename T, typename U> T data_access(std::pair<int, int> from_to,
2139 size_t valoffset, std::map<std::pair<int, int>, U> &data);
2140 /// Access data in a std::map<std::pair<int, int> for a given
2141 /// value of the first member of the pair. Returns an array of the values
2142 /// at valoffset of class U of type T
2143 template<typename T, typename U> std::vector<T> data_access(int parent,
2144 size_t valoffset, std::map<std::pair<int, int>, U> &data);
2145 template<typename T, typename U> std::vector<T> data_access(int parent,
2146 size_t valoffset, std::map<std::pair<int, unsigned int>, U> &data);
2147
2148 /// Access data in a std::map<int, data> format for a given first member
2149 /// of the pair. Returns the value at valoffset of the matching datapoint.
2150 template<typename U> double data_access(int parent,
2151 size_t valoffset, std::map<int, U> &data);
2152
2153 /// Structure for atomic data
2154 typedef struct atomic{
2155 int z; ///< number of protons [int]
2156 double k_shell_fluor; ///< K-shell fluorescence [fraction]
2157 double k_shell_fluor_error; ///< K-shell fluorescence error [fraction]
2158 double l_shell_fluor; ///< L-shell fluorescence [fraction]
2159 double l_shell_fluor_error; ///< L-shell fluorescence error [fraction]
2160 double prob; ///< probability K shell hole is filled by L shell [fraction]
2161 double k_shell_be; ///< K-shell binding energy [fraction]
2162 double k_shell_be_err; ///< K-shell binding energy error [fraction]
2163 double li_shell_be; ///< L-shell binding energy [fraction]
2164 double li_shell_be_err; ///< L-shell binding energy error [fraction]
2165 double mi_shell_be; ///< M-shell binding energy [fraction]
2166 double mi_shell_be_err; ///< M-shell binding energy error [fraction]
2167 double ni_shell_be; ///< N-shell binding energy [fraction]
2168 double ni_shell_be_err; ///< N-shell binding energy error [fraction]
2169 double kb_to_ka; ///< ratio of Kb to Ka fluorescence [fraction]
2170 double kb_to_ka_err; ///< error in ratio of Kb to Ka fluorescence [fraction]
2171 double ka2_to_ka1; ///< Ka2 to Ka1 fluorescence ratio [fraction]
2172 double ka2_to_ka1_err; ///< Ka2 to Ka1 fluorescence error [fraction]
2173 double k_auger; ///< Auger electrons from k shell holes [fraction]
2174 double l_auger; ///< Auger electrons from l shell holes [fraction]
2175 double ka1_x_ray_en; ///< Ka1 X-ray energy [keV]
2176 double ka1_x_ray_en_err; ///< Ka1 X-ray energy error [keV]
2177 double ka2_x_ray_en; ///< Ka2 X-ray energy [keV]
2178 double ka2_x_ray_en_err; ///< Ka2 X-ray energy error [keV]
2179 double kb_x_ray_en; ///< Kb X-ray energy [keV]
2180 double l_x_ray_en; ///< L X-ray energy [keV]
2182
2183 // map of Z to atomic data
2184 extern std::map<int, atomic> atomic_data_map;
2185
2186 template<typename T> void _load_data();
2187 template<> void _load_data<atomic>();
2188
2189 // compute X-ray data
2190 std::vector<std::pair<double, double> >
2191 calculate_xray_data(int z, double k_conv, double l_conv);
2192
2193
2194 /// a struct matching the '/decay/level_list' table in nuc_data.h5.
2195 typedef struct level_data{
2196 int nuc_id; ///< state id of nuclide
2197 unsigned int rx_id; ///< rx id of reaction, 0 for basic level data
2198 double half_life; ///< half life [seconds]
2199 double level; ///< level energy [keV]
2200 double branch_ratio; ///< branch ratio [fraction]
2201 int metastable; ///< metastable level [int]
2202 char special; ///< special high-spin state [character]
2204
2205 /// Mapping from nuclides in id form to a struct containing data associated
2206 /// with that level.
2207 extern std::map<std::pair<int,double>, level_data> level_data_lvl_map;
2208 extern std::map<std::pair<int,unsigned int>, level_data> level_data_rx_map;
2209
2210 template<> void _load_data<level_data>();
2211
2212 /// \brief Returns the nuc_id of an energy level
2213 ///
2214 /// This function looks for the level that best matches the input level
2215 /// within 1 keV of the input nuclide
2216 int id_from_level(int nuc, double level);
2217 int id_from_level(int nuc, double level, std::string special);
2218 /// \brief Returns the nuc_id of a metastable state
2219 ///
2220 /// This function looks through the level map for a given input nuc_id to find the
2221 /// nuc_id corresponding to the level
2222 int metastable_id(int nuc, int m);
2223 /// Assumes the first metastable state is the desired one
2224 int metastable_id(int nuc);
2225
2226 /// \brief Returns the half life for a nuclide \a nuc.
2227 ///
2228 /// This function works by first checking the half_life_map. If this is empty it
2229 /// loads the data from disk. If the nuclide is still not found, then the species
2230 /// is assumed to be stable and infinity is returned.
2231 double half_life(int nuc);
2232 /// Returns the half life for a nuclide \a nuc.
2233 double half_life(char * nuc);
2234 /// Returns the half life for a nuclide \a nuc.
2235 double half_life(std::string nuc);
2236
2237 /// \brief Returns the decay constant for a nuclide \a nuc.
2238 ///
2239 /// This function works by first checking the decay_const_map. If this is empty it
2240 /// loads the data from disk. If the nuclide is still not found, then the species
2241 /// is assumed to be stable and 0.0 is returned.
2242 double decay_const(int nuc);
2243 /// Returns the decay constant for a nuclide \a nuc.
2244 double decay_const(char * nuc);
2245 /// Returns the decay constant for a nuclide \a nuc.
2246 double decay_const(std::string nuc);
2247
2248 /// \brief Returns the branch ratio for a parent/child nuclide pair.
2249 ///
2250 /// This function works by first checking the branch_ratio_map. If this is empty it
2251 /// loads the data from disk. If the parent/child nuclide pair is still not found,
2252 /// then the decay is assumed to be impossible and 0.0 is returned.
2253 double branch_ratio(std::pair<int, int> from_to);
2254 /// Returns the branch ratio for a parent/child nuclide pair.
2255 double branch_ratio(int from_nuc, int to_nuc);
2256 /// Returns the branch ratio for a parent/child nuclide pair.
2257 double branch_ratio(char * from_nuc, char * to_nuc);
2258 /// Returns the branch ratio for a parent/child nuclide pair.
2259 double branch_ratio(std::string from_nuc, std::string to_nuc);
2260
2261 /// \brief Returns the excitation energy [MeV] of a \a nuc in a given state.
2262 ///
2263 /// This function works by first checking the state_energy_map. If this is empty it
2264 /// loads the data from disk. If the nuclide is still not found, then the species
2265 /// is assumed to be in a ground state and 0.0 is returned.
2266 double state_energy(int nuc);
2267 /// Returns the excitation energy [MeV] of a \a nuc in a given state.
2268 double state_energy(char * nuc);
2269 /// Returns the excitation energy [MeV] of a \a nuc in a given state.
2270 double state_energy(std::string nuc);
2271
2272 /// \brief Returns a set of decay children of a \a nuc.
2273 ///
2274 /// This function works by first checking decay_chidlren_map. If this is empty it
2275 /// loads the data from disk. If the nuclide is still not found, then the species
2276 /// is assumed to be stable and an empty set is returned.
2277 std::set<int> decay_children(int nuc);
2278 /// Returns the decay constant for a nuclide \a nuc.
2279 std::set<int> decay_children(char * nuc);
2280 /// Returns the decay constant for a nuclide \a nuc.
2281 std::set<int> decay_children(std::string nuc);
2282
2283 /// a struct matching the '/decay/decays' table in nuc_data.h5.
2284 typedef struct decay{
2285 int parent; ///< state id of decay parent
2286 int child; ///< state id of decay child
2287 unsigned int decay; ///< rx id of decay
2288 double half_life; ///< half life of the decay [s]
2289 double half_life_error; ///< half life error of the decay [s]
2290 double branch_ratio; ///< branching ratio of this decay [fraction]
2291 double branch_ratio_error; ///< branching ratio of this decay [fraction]
2292 /// photon branching ratio of this decay [fraction]
2294 /// photon branching ratio error of this decay [fraction]
2296 /// beta branching ratio of this decay [fraction]
2298 /// beta branching ratio error of this decay [fraction]
2301
2302 /// Loads the decay data from the nuc_data.h5 file into memory.
2303 template<> void _load_data<decay>();
2304 /// Mapping from a pair of nuclides in id form to a struct containing data
2305 /// associated with the decay from the first to the second
2306 extern std::map<std::pair<int, int>, decay> decay_data;
2307
2308 //
2309 //
2310 std::vector<int> decay_data_children(int parent);
2311 std::pair<double, double> decay_half_life(std::pair<int,int>);
2312 std::vector<std::pair<double, double> > decay_half_lifes(int);
2313 std::pair<double, double> decay_branch_ratio(std::pair<int,int>);
2314 std::vector<double> decay_branch_ratios(int parent);
2315 std::pair<double, double> decay_photon_branch_ratio(std::pair<int,int>);
2316 std::vector<std::pair<double, double> >decay_photon_branch_ratios(int parent);
2317 std::pair<double, double> decay_beta_branch_ratio(std::pair<int,int>);
2318 std::vector<std::pair<double, double> >decay_beta_branch_ratios(int parent);
2319
2320
2321 /// a struct matching the '/decay/gammas' table in nuc_data.h5.
2322 typedef struct gamma{
2323 int from_nuc; ///< state id of starting level
2324 int to_nuc; ///< state id of final level
2325 int parent_nuc; ///< state id of the primary decaying nucleus
2326 int child_nuc; ///< stateless id of the child nucleus
2327 double energy; ///< energy of the photon [keV]
2328 double energy_err; ///< energy error of the photon [keV]
2329 double photon_intensity; ///< photon intensity
2330 double photon_intensity_err; ///< photon intensity error
2331 double conv_intensity; ///< conversion intensity
2332 double conv_intensity_err; ///< conversion intensity error
2333 double total_intensity; ///< total decay intensity
2334 double total_intensity_err; ///< total decay intensity error
2335 double k_conv_e; ///< k conversion electron fraction
2336 double l_conv_e; ///< l conversion electron fraction
2337 double m_conv_e; ///< m conversion electron fraction
2339
2340 /// Loads the gamma ray data from the nuc_data.h5 file into memory.
2341 template<> void _load_data<gamma>();
2342
2343 extern std::map<std::pair<int, double>, gamma> gamma_data;
2344
2345 //returns a list of gamma decay energies from input parent nuclide
2346 std::vector<std::pair<double, double> > gamma_energy(int parent);
2347 std::vector<std::pair<double, double> > gamma_energy(double energy,
2348 double error);
2349 //returns a list of gamma photon intensities from input parent nuclide
2350 std::vector<std::pair<double, double> > gamma_photon_intensity(int parent);
2351 std::vector<std::pair<double, double> > gamma_photon_intensity(double energy,
2352 double error);
2353 //returns a list of gamma conversion intensities from input parent nuclide
2354 std::vector<std::pair<double, double> > gamma_conversion_intensity(int parent);
2355 //returns a list of gamma total intensities from input parent nuclide
2356 std::vector<std::pair<double, double> > gamma_total_intensity(int parent);
2357 //returns a list of pairs of excited state transitions from an input parent nuclide
2358 std::vector<std::pair<int, int> > gamma_from_to(int parent);
2359 //returns a list of pairs of excited state transitions from an decay energy
2360 std::vector<std::pair<int, int> > gamma_from_to(double energy, double error);
2361 //returns a list of parent/child pairs associated with an input decay energy
2362 std::vector<std::pair<int, int> > gamma_parent_child(double energy, double error);
2363 //returns a list of parent nuclides associated with an input decay energy
2364 std::vector<int> gamma_parent(double energy, double error);
2365 // returns a list of child state_id's based on a gamma-ray energy
2366 std::vector<int> gamma_child(double energy, double error);
2367 // returns a list of child state_id's based on a parent state_id
2368 std::vector<int> gamma_child(int parent);
2369 //returns an array of arrays of X-ray energies and intesities for a
2370 //given parent
2371 std::vector<std::pair<double, double> > gamma_xrays(int parent);
2372
2373 /// Returns a list of energies and intensities normalized to branching ratios
2374 std::vector<std::pair<double, double> > gammas(int parent_state_id);
2375 std::vector<std::pair<double, double> > alphas(int parent_state_id);
2376 std::vector<std::pair<double, double> > betas(int parent_state_id);
2377 std::vector<std::pair<double, double> > xrays(int parent);
2378
2379 /// a struct matching the '/decay/alphas' table in nuc_data.h5.
2380 typedef struct alpha{
2381 int from_nuc; ///< state id of parent nuclide
2382 int to_nuc; ///< state id of child nuclide
2383 double energy; ///< energy of alpha
2384 double intensity; ///< intensity of alpha decay
2386
2387 /// Loads the alpha decay data from the nuc_data.h5 file into memory.
2388 template<> void _load_data<alpha>();
2389
2390 /// A vector of structs containing alpha data for access in memory
2391 extern std::map<std::pair<int, double>, alpha> alpha_data;
2392
2393 //returns a list of alpha decay energies from input parent nuclide
2394 std::vector<double > alpha_energy(int parent);
2395 //returns a list of alpha decay intensities from input parent nuclide
2396 std::vector<double> alpha_intensity(int parent);
2397 //returns a list of alpha decay parents from input decay energy range
2398 std::vector<int> alpha_parent(double energy, double error);
2399 //returns a list of alpha decay children from input decay energy range
2400 std::vector<int> alpha_child(double energy, double error);
2401 //returns a list of alpha decay children from input parent nuclide
2402 std::vector<int> alpha_child(int parent);
2403
2404 /// a struct matching the '/decay/betas' table in nuc_data.h5.
2405 typedef struct beta{
2406 int from_nuc; ///< state id of parent nuclide
2407 int to_nuc; ///< state id of child nuclide
2408 double endpoint_energy; ///< beta decay endpoint energy
2409 double avg_energy; ///< beta decay average energy
2410 double intensity; ///< beta intensity
2412
2413 /// Loads the beta decay data from the nuc_data.h5 file into memory.
2414 template<> void _load_data<beta>();
2415
2416 /// A vector of structs containing beta data for access in memory
2417 extern std::map<std::pair<int, double>, beta> beta_data;
2418 //returns a list of beta decay endpoint energies from input parent nuclide
2419 std::vector<double > beta_endpoint_energy(int parent);
2420 //returns a list of beta decay average energies from input parent nuclide
2421 std::vector<double > beta_average_energy(int parent);
2422 //returns a list of beta decay intensities from input parent nuclide
2423 std::vector<double> beta_intensity(int parent);
2424 //returns a list of beta decay parents from input decay energy range
2425 std::vector<int> beta_parent(double energy, double error);
2426 //returns a list of beta decay children from input decay energy range
2427 std::vector<int> beta_child(double energy, double error);
2428 //returns a list of beta decay children from input parent nuclide
2429 std::vector<int> beta_child(int parent);
2430
2431 /// A struct matching the '/decay/ecbp' table in nuc_data.h5.
2432 typedef struct ecbp{
2433 int from_nuc; ///< state id of parent nuclide
2434 int to_nuc; ///< state id of child nuclide
2435 double endpoint_energy; ///< beta decay endpoint energy
2436 double avg_energy; ///< beta decay average energy
2437 double beta_plus_intensity; ///< intensity of beta plus decay
2438 double ec_intensity; ///< intensity of electron capture
2439 double k_conv_e; ///< k conversion electron fraction
2440 double l_conv_e; ///< l conversion electron fraction
2441 double m_conv_e; ///< m conversion electron fraction
2443
2444 /// A vector of structs containing ecbp data for access in memory
2445 extern std::map<std::pair<int, double>, ecbp> ecbp_data;
2446
2447 /// Loads the electron capture and beta plus decay data from the
2448 /// nuc_data.h5 file into memory.
2449 template<> void _load_data<ecbp>();
2450 ///returns a list of electron capture/ beta plus decay endpoint energies from
2451 ///input parent nuclide
2452 std::vector<double > ecbp_endpoint_energy(int parent);
2453 //returns a list of electron capture/ beta plus decay average energies from
2454 //input parent nuclide
2455 std::vector<double > ecbp_average_energy(int parent);
2456 //returns a list of electron capture decay intensities from input parent
2457 //nuclide
2458 std::vector<double> ec_intensity(int parent);
2459 //returns a list of beta plus decay intensities from input parent nuclide
2460 std::vector<double> bp_intensity(int parent);
2461 //returns a list of electron capture /beta plus decay parents from input
2462 //decay energy range
2463 std::vector<int> ecbp_parent(double energy, double error);
2464 //returns a list of electron capture /beta plus decay children from input
2465 //decay energy range
2466 std::vector<int> ecbp_child(double energy, double error);
2467 //returns a list of electron capture /beta plus decay children from input
2468 //parent nuclide
2469 std::vector<int> ecbp_child(int parent);
2470 //returns an array of arrays of X-ray energies and intesities for a
2471 //given parent
2472 std::vector<std::pair<double, double> > ecbp_xrays(int parent);
2473 /// \}
2474
2475 /// map<energy, map<nuclide, map<rx, xs> > >
2476 extern std::map<std::string, std::map<int, std::map<int, double> > >
2478
2479 /// returns the microscopic cross section in barns for the specified
2480 /// nuclide, reaction, and energy group. energy must be one of: "thermal",
2481 /// "thermal_maxwell_ave", "resonance_integral", "fourteen_MeV",
2482 /// "fission_spectrum_ave".
2483 double simple_xs(int nuc, int rx, std::string energy);
2484 /// returns the microscopic cross section in barns for the specified
2485 /// nuclide, reaction, and energy group. energy must be one of: "thermal",
2486 /// "thermal_maxwell_ave", "resonance_integral", "fourteen_MeV",
2487 /// "fission_spectrum_ave".
2488 double simple_xs(int nuc, std::string rx, std::string energy);
2489 /// returns the microscopic cross section in barns for the specified
2490 /// nuclide, reaction, and energy group. energy must be one of: "thermal",
2491 /// "thermal_maxwell_ave", "resonance_integral", "fourteen_MeV",
2492 /// "fission_spectrum_ave".
2493 double simple_xs(std::string nuc, int rx, std::string energy);
2494 /// returns the microscopic cross section in barns for the specified
2495 /// nuclide, reaction, and energy group. energy must be one of: "thermal",
2496 /// "thermal_maxwell_ave", "resonance_integral", "fourteen_MeV",
2497 /// "fission_spectrum_ave".
2498 double simple_xs(std::string nuc, std::string rx, std::string energy);
2499
2500 /// Custom exception for declaring a simple_xs request invalid
2501 class InvalidSimpleXS : public std::exception {
2502 public:
2504 ~InvalidSimpleXS () throw () {};
2505 /// Exception thrown if energy group or rxname are invalid
2506 InvalidSimpleXS(std::string msg) : msg_(msg) {};
2507 /// Exception returns the string passed when thrown.
2508 virtual const char* what() const throw() {
2509 return msg_.c_str();
2510 };
2511
2512 private:
2513 std::string msg_;
2514 };
2515
2516} // namespace pyne
2517
2518#endif
2519//
2520// end of src/data.h
2521//
2522
2523
2524//
2525// start of src/json-forwards.h
2526//
2527/// Json-cpp amalgated forward header (http://jsoncpp.sourceforge.net/).
2528/// It is intented to be used with #include <json/json-forwards.h>
2529/// This header provides forward declaration for all JsonCpp types.
2530
2531// //////////////////////////////////////////////////////////////////////
2532// Beginning of content of file: LICENSE
2533// //////////////////////////////////////////////////////////////////////
2534
2535/*
2536The JsonCpp library's source code, including accompanying documentation,
2537tests and demonstration applications, are licensed under the following
2538conditions...
2539
2540The author (Baptiste Lepilleur) explicitly disclaims copyright in all
2541jurisdictions which recognize such a disclaimer. In such jurisdictions,
2542this software is released into the Public Domain.
2543
2544In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
25452010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is
2546released under the terms of the MIT License (see below).
2547
2548In jurisdictions which recognize Public Domain property, the user of this
2549software may choose to accept it either as 1) Public Domain, 2) under the
2550conditions of the MIT License (see below), or 3) under the terms of dual
2551Public Domain/MIT License conditions described here, as they choose.
2552
2553The MIT License is about as close to Public Domain as a license can get, and is
2554described in clear, concise terms at:
2555
2556 http://en.wikipedia.org/wiki/MIT_License
2557
2558The full text of the MIT License follows:
2559
2560========================================================================
2561Copyright (c) 2007-2010 Baptiste Lepilleur
2562
2563Permission is hereby granted, free of charge, to any person
2564obtaining a copy of this software and associated documentation
2565files (the "Software"), to deal in the Software without
2566restriction, including without limitation the rights to use, copy,
2567modify, merge, publish, distribute, sublicense, and/or sell copies
2568of the Software, and to permit persons to whom the Software is
2569furnished to do so, subject to the following conditions:
2570
2571The above copyright notice and this permission notice shall be
2572included in all copies or substantial portions of the Software.
2573
2574THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2575EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2576MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2577NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
2578BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
2579ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
2580CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2581SOFTWARE.
2582========================================================================
2583(END LICENSE TEXT)
2584
2585The MIT license is compatible with both the GPL and commercial
2586software, affording one all of the rights of Public Domain with the
2587minor nuisance of being required to keep the above copyright notice
2588and license text in the source code. Note also that by accepting the
2589Public Domain "license" you can re-license your copy using whatever
2590license you like.
2591
2592*/
2593
2594// //////////////////////////////////////////////////////////////////////
2595// End of content of file: LICENSE
2596// //////////////////////////////////////////////////////////////////////
2597
2598
2599#ifdef PYNE_IS_AMALGAMATED
2600 #if !defined(JSON_IS_AMALGAMATION)
2601 #define JSON_IS_AMALGAMATION
2602 #endif
2603#endif
2604
2605
2606#ifndef JSON_FORWARD_AMALGATED_H_INCLUDED
2607# define JSON_FORWARD_AMALGATED_H_INCLUDED
2608/// If defined, indicates that the source file is amalgated
2609/// to prevent private header inclusion.
2610#define JSON_IS_AMALGATED
2611
2612// //////////////////////////////////////////////////////////////////////
2613// Beginning of content of file: include/json/config.h
2614// //////////////////////////////////////////////////////////////////////
2615
2616// Copyright 2007-2010 Baptiste Lepilleur
2617// Distributed under MIT license, or public domain if desired and
2618// recognized in your jurisdiction.
2619// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
2620
2621#ifndef JSON_CONFIG_H_INCLUDED
2622# define JSON_CONFIG_H_INCLUDED
2623
2624/// If defined, indicates that json library is embedded in CppTL library.
2625//# define JSON_IN_CPPTL 1
2626
2627/// If defined, indicates that json may leverage CppTL library
2628//# define JSON_USE_CPPTL 1
2629/// If defined, indicates that cpptl vector based map should be used instead of std::map
2630/// as Value container.
2631//# define JSON_USE_CPPTL_SMALLMAP 1
2632/// If defined, indicates that Json specific container should be used
2633/// (hash table & simple deque container with customizable allocator).
2634/// THIS FEATURE IS STILL EXPERIMENTAL! There is know bugs: See #3177332
2635//# define JSON_VALUE_USE_INTERNAL_MAP 1
2636/// Force usage of standard new/malloc based allocator instead of memory pool based allocator.
2637/// The memory pools allocator used optimization (initializing Value and ValueInternalLink
2638/// as if it was a POD) that may cause some validation tool to report errors.
2639/// Only has effects if JSON_VALUE_USE_INTERNAL_MAP is defined.
2640//# define JSON_USE_SIMPLE_INTERNAL_ALLOCATOR 1
2641
2642/// If defined, indicates that Json use exception to report invalid type manipulation
2643/// instead of C assert macro.
2644# define JSON_USE_EXCEPTION 1
2645
2646/// If defined, indicates that the source file is amalgated
2647/// to prevent private header inclusion.
2648/// Remarks: it is automatically defined in the generated amalgated header.
2649// #define JSON_IS_AMALGAMATION
2650
2651
2652# ifdef JSON_IN_CPPTL
2653# include <cpptl/config.h>
2654# ifndef JSON_USE_CPPTL
2655# define JSON_USE_CPPTL 1
2656# endif
2657# endif
2658
2659# ifdef JSON_IN_CPPTL
2660# define JSON_API CPPTL_API
2661# elif defined(JSON_DLL_BUILD)
2662# define JSON_API __declspec(dllexport)
2663# elif defined(JSON_DLL)
2664# define JSON_API __declspec(dllimport)
2665# else
2666# define JSON_API
2667# endif
2668
2669// If JSON_NO_INT64 is defined, then Json only support C++ "int" type for integer
2670// Storages, and 64 bits integer support is disabled.
2671// #define JSON_NO_INT64 1
2672
2673#if defined(_MSC_VER) && _MSC_VER <= 1200 // MSVC 6
2674// Microsoft Visual Studio 6 only support conversion from __int64 to double
2675// (no conversion from unsigned __int64).
2676#define JSON_USE_INT64_DOUBLE_CONVERSION 1
2677#endif // if defined(_MSC_VER) && _MSC_VER < 1200 // MSVC 6
2678
2679#if defined(_MSC_VER) && _MSC_VER >= 1500 // MSVC 2008
2680/// Indicates that the following function is deprecated.
2681# define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
2682#endif
2683
2684#if !defined(JSONCPP_DEPRECATED)
2685# define JSONCPP_DEPRECATED(message)
2686#endif // if !defined(JSONCPP_DEPRECATED)
2687
2688namespace Json {
2689 typedef int Int;
2690 typedef unsigned int UInt;
2691# if defined(JSON_NO_INT64)
2692 typedef int LargestInt;
2693 typedef unsigned int LargestUInt;
2694# undef JSON_HAS_INT64
2695# else // if defined(JSON_NO_INT64)
2696 // For Microsoft Visual use specific types as long long is not supported
2697# if defined(_MSC_VER) // Microsoft Visual Studio
2698 typedef __int64 Int64;
2699 typedef unsigned __int64 UInt64;
2700# else // if defined(_MSC_VER) // Other platforms, use long long
2701 typedef long long int Int64;
2702 typedef unsigned long long int UInt64;
2703# endif // if defined(_MSC_VER)
2706# define JSON_HAS_INT64
2707# endif // if defined(JSON_NO_INT64)
2708} // end namespace Json
2709
2710
2711#endif // JSON_CONFIG_H_INCLUDED
2712
2713// //////////////////////////////////////////////////////////////////////
2714// End of content of file: include/json/config.h
2715// //////////////////////////////////////////////////////////////////////
2716
2717
2718
2719
2720
2721
2722// //////////////////////////////////////////////////////////////////////
2723// Beginning of content of file: include/json/forwards.h
2724// //////////////////////////////////////////////////////////////////////
2725
2726// Copyright 2007-2010 Baptiste Lepilleur
2727// Distributed under MIT license, or public domain if desired and
2728// recognized in your jurisdiction.
2729// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
2730
2731#ifndef JSON_FORWARDS_H_INCLUDED
2732# define JSON_FORWARDS_H_INCLUDED
2733
2734#if !defined(JSON_IS_AMALGAMATION)
2735# include "config.h"
2736#endif // if !defined(JSON_IS_AMALGAMATION)
2737
2738namespace Json {
2739
2740 // writer.h
2741 class FastWriter;
2742 class StyledWriter;
2743
2744 // reader.h
2745 class Reader;
2746
2747 // features.h
2748 class Features;
2749
2750 // value.h
2751 typedef unsigned int ArrayIndex;
2752 class StaticString;
2753 class Path;
2754 class PathArgument;
2755 class Value;
2756 class ValueIteratorBase;
2757 class ValueIterator;
2758 class ValueConstIterator;
2759#ifdef JSON_VALUE_USE_INTERNAL_MAP
2760 class ValueMapAllocator;
2761 class ValueInternalLink;
2762 class ValueInternalArray;
2763 class ValueInternalMap;
2764#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP
2765
2766} // namespace Json
2767
2768
2769#endif // JSON_FORWARDS_H_INCLUDED
2770
2771// //////////////////////////////////////////////////////////////////////
2772// End of content of file: include/json/forwards.h
2773// //////////////////////////////////////////////////////////////////////
2774
2775
2776
2777
2778
2779#endif //ifndef JSON_FORWARD_AMALGATED_H_INCLUDED
2780//
2781// end of src/json-forwards.h
2782//
2783
2784
2785//
2786// start of src/json.h
2787//
2788/// Json-cpp amalgated header (http://jsoncpp.sourceforge.net/).
2789/// It is intented to be used with #include <json.h>
2790
2791// //////////////////////////////////////////////////////////////////////
2792// Beginning of content of file: LICENSE
2793// //////////////////////////////////////////////////////////////////////
2794
2795/*
2796The JsonCpp library's source code, including accompanying documentation,
2797tests and demonstration applications, are licensed under the following
2798conditions...
2799
2800The author (Baptiste Lepilleur) explicitly disclaims copyright in all
2801jurisdictions which recognize such a disclaimer. In such jurisdictions,
2802this software is released into the Public Domain.
2803
2804In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
28052010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is
2806released under the terms of the MIT License (see below).
2807
2808In jurisdictions which recognize Public Domain property, the user of this
2809software may choose to accept it either as 1) Public Domain, 2) under the
2810conditions of the MIT License (see below), or 3) under the terms of dual
2811Public Domain/MIT License conditions described here, as they choose.
2812
2813The MIT License is about as close to Public Domain as a license can get, and is
2814described in clear, concise terms at:
2815
2816 http://en.wikipedia.org/wiki/MIT_License
2817
2818The full text of the MIT License follows:
2819
2820========================================================================
2821Copyright (c) 2007-2010 Baptiste Lepilleur
2822
2823Permission is hereby granted, free of charge, to any person
2824obtaining a copy of this software and associated documentation
2825files (the "Software"), to deal in the Software without
2826restriction, including without limitation the rights to use, copy,
2827modify, merge, publish, distribute, sublicense, and/or sell copies
2828of the Software, and to permit persons to whom the Software is
2829furnished to do so, subject to the following conditions:
2830
2831The above copyright notice and this permission notice shall be
2832included in all copies or substantial portions of the Software.
2833
2834THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2835EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2836MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2837NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
2838BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
2839ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
2840CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2841SOFTWARE.
2842========================================================================
2843(END LICENSE TEXT)
2844
2845The MIT license is compatible with both the GPL and commercial
2846software, affording one all of the rights of Public Domain with the
2847minor nuisance of being required to keep the above copyright notice
2848and license text in the source code. Note also that by accepting the
2849Public Domain "license" you can re-license your copy using whatever
2850license you like.
2851
2852*/
2853
2854// //////////////////////////////////////////////////////////////////////
2855// End of content of file: LICENSE
2856// //////////////////////////////////////////////////////////////////////
2857
2858#ifdef PYNE_IS_AMALGAMATED
2859 #if !defined(JSON_IS_AMALGAMATION)
2860 #define JSON_IS_AMALGAMATION
2861 #endif
2862#endif
2863
2864
2865
2866#ifndef JSON_AMALGATED_H_INCLUDED
2867# define JSON_AMALGATED_H_INCLUDED
2868/// If defined, indicates that the source file is amalgated
2869/// to prevent private header inclusion.
2870#define JSON_IS_AMALGATED
2871
2872// //////////////////////////////////////////////////////////////////////
2873// Beginning of content of file: include/json/config.h
2874// //////////////////////////////////////////////////////////////////////
2875
2876// Copyright 2007-2010 Baptiste Lepilleur
2877// Distributed under MIT license, or public domain if desired and
2878// recognized in your jurisdiction.
2879// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
2880
2881#ifndef JSON_CONFIG_H_INCLUDED
2882# define JSON_CONFIG_H_INCLUDED
2883
2884/// If defined, indicates that json library is embedded in CppTL library.
2885//# define JSON_IN_CPPTL 1
2886
2887/// If defined, indicates that json may leverage CppTL library
2888//# define JSON_USE_CPPTL 1
2889/// If defined, indicates that cpptl vector based map should be used instead of std::map
2890/// as Value container.
2891//# define JSON_USE_CPPTL_SMALLMAP 1
2892/// If defined, indicates that Json specific container should be used
2893/// (hash table & simple deque container with customizable allocator).
2894/// THIS FEATURE IS STILL EXPERIMENTAL! There is know bugs: See #3177332
2895//# define JSON_VALUE_USE_INTERNAL_MAP 1
2896/// Force usage of standard new/malloc based allocator instead of memory pool based allocator.
2897/// The memory pools allocator used optimization (initializing Value and ValueInternalLink
2898/// as if it was a POD) that may cause some validation tool to report errors.
2899/// Only has effects if JSON_VALUE_USE_INTERNAL_MAP is defined.
2900//# define JSON_USE_SIMPLE_INTERNAL_ALLOCATOR 1
2901
2902/// If defined, indicates that Json use exception to report invalid type manipulation
2903/// instead of C assert macro.
2904# define JSON_USE_EXCEPTION 1
2905
2906/// If defined, indicates that the source file is amalgated
2907/// to prevent private header inclusion.
2908/// Remarks: it is automatically defined in the generated amalgated header.
2909// #define JSON_IS_AMALGAMATION
2910
2911
2912# ifdef JSON_IN_CPPTL
2913# include <cpptl/config.h>
2914# ifndef JSON_USE_CPPTL
2915# define JSON_USE_CPPTL 1
2916# endif
2917# endif
2918
2919# ifdef JSON_IN_CPPTL
2920# define JSON_API CPPTL_API
2921# elif defined(JSON_DLL_BUILD)
2922# define JSON_API __declspec(dllexport)
2923# elif defined(JSON_DLL)
2924# define JSON_API __declspec(dllimport)
2925# else
2926# define JSON_API
2927# endif
2928
2929// If JSON_NO_INT64 is defined, then Json only support C++ "int" type for integer
2930// Storages, and 64 bits integer support is disabled.
2931// #define JSON_NO_INT64 1
2932
2933#if defined(_MSC_VER) && _MSC_VER <= 1200 // MSVC 6
2934// Microsoft Visual Studio 6 only support conversion from __int64 to double
2935// (no conversion from unsigned __int64).
2936#define JSON_USE_INT64_DOUBLE_CONVERSION 1
2937#endif // if defined(_MSC_VER) && _MSC_VER < 1200 // MSVC 6
2938
2939#if defined(_MSC_VER) && _MSC_VER >= 1500 // MSVC 2008
2940/// Indicates that the following function is deprecated.
2941# define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
2942#endif
2943
2944#if !defined(JSONCPP_DEPRECATED)
2945# define JSONCPP_DEPRECATED(message)
2946#endif // if !defined(JSONCPP_DEPRECATED)
2947
2948namespace Json {
2949 typedef int Int;
2950 typedef unsigned int UInt;
2951# if defined(JSON_NO_INT64)
2952 typedef int LargestInt;
2953 typedef unsigned int LargestUInt;
2954# undef JSON_HAS_INT64
2955# else // if defined(JSON_NO_INT64)
2956 // For Microsoft Visual use specific types as long long is not supported
2957# if defined(_MSC_VER) // Microsoft Visual Studio
2958 typedef __int64 Int64;
2959 typedef unsigned __int64 UInt64;
2960# else // if defined(_MSC_VER) // Other platforms, use long long
2961 typedef long long int Int64;
2962 typedef unsigned long long int UInt64;
2963# endif // if defined(_MSC_VER)
2964 typedef Int64 LargestInt;
2965 typedef UInt64 LargestUInt;
2966# define JSON_HAS_INT64
2967# endif // if defined(JSON_NO_INT64)
2968} // end namespace Json
2969
2970
2971#endif // JSON_CONFIG_H_INCLUDED
2972
2973// //////////////////////////////////////////////////////////////////////
2974// End of content of file: include/json/config.h
2975// //////////////////////////////////////////////////////////////////////
2976
2977
2978
2979
2980
2981
2982// //////////////////////////////////////////////////////////////////////
2983// Beginning of content of file: include/json/forwards.h
2984// //////////////////////////////////////////////////////////////////////
2985
2986// Copyright 2007-2010 Baptiste Lepilleur
2987// Distributed under MIT license, or public domain if desired and
2988// recognized in your jurisdiction.
2989// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
2990
2991#ifndef JSON_FORWARDS_H_INCLUDED
2992# define JSON_FORWARDS_H_INCLUDED
2993
2994#if !defined(JSON_IS_AMALGAMATION)
2995# include "config.h"
2996#endif // if !defined(JSON_IS_AMALGAMATION)
2997
2998namespace Json {
2999
3000 // writer.h
3001 class FastWriter;
3002 class StyledWriter;
3003
3004 // reader.h
3005 class Reader;
3006
3007 // features.h
3008 class Features;
3009
3010 // value.h
3011 typedef unsigned int ArrayIndex;
3012 class StaticString;
3013 class Path;
3014 class PathArgument;
3015 class Value;
3016 class ValueIteratorBase;
3017 class ValueIterator;
3018 class ValueConstIterator;
3019#ifdef JSON_VALUE_USE_INTERNAL_MAP
3020 class ValueMapAllocator;
3021 class ValueInternalLink;
3022 class ValueInternalArray;
3023 class ValueInternalMap;
3024#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP
3025
3026} // namespace Json
3027
3028
3029#endif // JSON_FORWARDS_H_INCLUDED
3030
3031// //////////////////////////////////////////////////////////////////////
3032// End of content of file: include/json/forwards.h
3033// //////////////////////////////////////////////////////////////////////
3034
3035
3036
3037
3038
3039
3040// //////////////////////////////////////////////////////////////////////
3041// Beginning of content of file: include/json/features.h
3042// //////////////////////////////////////////////////////////////////////
3043
3044// Copyright 2007-2010 Baptiste Lepilleur
3045// Distributed under MIT license, or public domain if desired and
3046// recognized in your jurisdiction.
3047// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
3048
3049#ifndef CPPTL_JSON_FEATURES_H_INCLUDED
3050# define CPPTL_JSON_FEATURES_H_INCLUDED
3051
3052#if !defined(JSON_IS_AMALGAMATION)
3053# include "forwards.h"
3054#endif // if !defined(JSON_IS_AMALGAMATION)
3055
3056namespace Json {
3057
3058 /** \brief Configuration passed to reader and writer.
3059 * This configuration object can be used to force the Reader or Writer
3060 * to behave in a standard conforming way.
3061 */
3063 {
3064 public:
3065 /** \brief A configuration that allows all features and assumes all strings are UTF-8.
3066 * - C & C++ comments are allowed
3067 * - Root object can be any JSON value
3068 * - Assumes Value strings are encoded in UTF-8
3069 */
3070 static Features all();
3071
3072 /** \brief A configuration that is strictly compatible with the JSON specification.
3073 * - Comments are forbidden.
3074 * - Root object must be either an array or an object value.
3075 * - Assumes Value strings are encoded in UTF-8
3076 */
3077 static Features strictMode();
3078
3079 /** \brief Initialize the configuration like JsonConfig::allFeatures;
3080 */
3081 Features();
3082
3083 /// \c true if comments are allowed. Default: \c true.
3085
3086 /// \c true if root must be either an array or an object value. Default: \c false.
3088 };
3089
3090} // namespace Json
3091
3092#endif // CPPTL_JSON_FEATURES_H_INCLUDED
3093
3094// //////////////////////////////////////////////////////////////////////
3095// End of content of file: include/json/features.h
3096// //////////////////////////////////////////////////////////////////////
3097
3098
3099
3100
3101
3102
3103// //////////////////////////////////////////////////////////////////////
3104// Beginning of content of file: include/json/value.h
3105// //////////////////////////////////////////////////////////////////////
3106
3107// Copyright 2007-2010 Baptiste Lepilleur
3108// Distributed under MIT license, or public domain if desired and
3109// recognized in your jurisdiction.
3110// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
3111
3112#ifndef CPPTL_JSON_H_INCLUDED
3113# define CPPTL_JSON_H_INCLUDED
3114
3115#if !defined(JSON_IS_AMALGAMATION)
3116# include "forwards.h"
3117#endif // if !defined(JSON_IS_AMALGAMATION)
3118# include <string>
3119# include <vector>
3120
3121# ifndef JSON_USE_CPPTL_SMALLMAP
3122# include <map>
3123# else
3124# include <cpptl/smallmap.h>
3125# endif
3126# ifdef JSON_USE_CPPTL
3127# include <cpptl/forwards.h>
3128# endif
3129
3130/** \brief JSON (JavaScript Object Notation).
3131 */
3132namespace Json {
3133
3134 /** \brief Type of the value held by a Value object.
3135 */
3137 {
3138 nullValue = 0, ///< 'null' value
3139 intValue, ///< signed integer value
3140 uintValue, ///< unsigned integer value
3141 realValue, ///< double value
3142 stringValue, ///< UTF-8 string value
3143 booleanValue, ///< bool value
3144 arrayValue, ///< array value (ordered list)
3145 objectValue ///< object value (collection of name/value pairs).
3147
3149 {
3150 commentBefore = 0, ///< a comment placed on the line before a value
3151 commentAfterOnSameLine, ///< a comment just after a value on the same line
3152 commentAfter, ///< a comment on the line after a value (only make sense for root value)
3155
3156//# ifdef JSON_USE_CPPTL
3157// typedef CppTL::AnyEnumerator<const char *> EnumMemberNames;
3158// typedef CppTL::AnyEnumerator<const Value &> EnumValues;
3159//# endif
3160
3161 /** \brief Lightweight wrapper to tag static string.
3162 *
3163 * Value constructor and objectValue member assignement takes advantage of the
3164 * StaticString and avoid the cost of string duplication when storing the
3165 * string or the member name.
3166 *
3167 * Example of usage:
3168 * \code
3169 * Json::Value aValue( StaticString("some text") );
3170 * Json::Value object;
3171 * static const StaticString code("code");
3172 * object[code] = 1234;
3173 * \endcode
3174 */
3176 {
3177 public:
3178 explicit StaticString( const char *czstring )
3179 : str_( czstring )
3180 {
3181 }
3182
3183 operator const char *() const
3184 {
3185 return str_;
3186 }
3187
3188 const char *c_str() const
3189 {
3190 return str_;
3191 }
3192
3193 private:
3194 const char *str_;
3195 };
3196
3197 /** \brief Represents a <a HREF="http://www.json.org">JSON</a> value.
3198 *
3199 * This class is a discriminated union wrapper that can represents a:
3200 * - signed integer [range: Value::minInt - Value::maxInt]
3201 * - unsigned integer (range: 0 - Value::maxUInt)
3202 * - double
3203 * - UTF-8 string
3204 * - boolean
3205 * - 'null'
3206 * - an ordered list of Value
3207 * - collection of name/value pairs (javascript object)
3208 *
3209 * The type of the held value is represented by a #ValueType and
3210 * can be obtained using type().
3211 *
3212 * values of an #objectValue or #arrayValue can be accessed using operator[]() methods.
3213 * Non const methods will automatically create the a #nullValue element
3214 * if it does not exist.
3215 * The sequence of an #arrayValue will be automatically resize and initialized
3216 * with #nullValue. resize() can be used to enlarge or truncate an #arrayValue.
3217 *
3218 * The get() methods can be used to obtanis default value in the case the required element
3219 * does not exist.
3220 *
3221 * It is possible to iterate over the list of a #objectValue values using
3222 * the getMemberNames() method.
3223 */
3225 {
3226 friend class ValueIteratorBase;
3227# ifdef JSON_VALUE_USE_INTERNAL_MAP
3228 friend class ValueInternalLink;
3229 friend class ValueInternalMap;
3230# endif
3231 public:
3232 typedef std::vector<std::string> Members;
3237# if defined(JSON_HAS_INT64)
3240#endif // defined(JSON_HAS_INT64)
3244
3245 static const Value null;
3246 /// Minimum signed integer value that can be stored in a Json::Value.
3248 /// Maximum signed integer value that can be stored in a Json::Value.
3250 /// Maximum unsigned integer value that can be stored in a Json::Value.
3252
3253 /// Minimum signed int value that can be stored in a Json::Value.
3254 static const Int minInt;
3255 /// Maximum signed int value that can be stored in a Json::Value.
3256 static const Int maxInt;
3257 /// Maximum unsigned int value that can be stored in a Json::Value.
3258 static const UInt maxUInt;
3259
3260 /// Minimum signed 64 bits int value that can be stored in a Json::Value.
3261 static const Int64 minInt64;
3262 /// Maximum signed 64 bits int value that can be stored in a Json::Value.
3263 static const Int64 maxInt64;
3264 /// Maximum unsigned 64 bits int value that can be stored in a Json::Value.
3265 static const UInt64 maxUInt64;
3266
3267 private:
3268#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
3269# ifndef JSON_VALUE_USE_INTERNAL_MAP
3270 class CZString
3271 {
3272 public:
3273 enum DuplicationPolicy
3274 {
3275 noDuplication = 0,
3276 duplicate,
3277 duplicateOnCopy
3278 };
3279 CZString( ArrayIndex index );
3280 CZString( const char *cstr, DuplicationPolicy allocate );
3281 CZString( const CZString &other );
3282 ~CZString();
3283 CZString &operator =( const CZString &other );
3284 bool operator<( const CZString &other ) const;
3285 bool operator==( const CZString &other ) const;
3286 ArrayIndex index() const;
3287 const char *c_str() const;
3288 bool isStaticString() const;
3289 private:
3290 void swap( CZString &other );
3291 const char *cstr_;
3292 ArrayIndex index_;
3293 };
3294
3295 public:
3296# ifndef JSON_USE_CPPTL_SMALLMAP
3297 typedef std::map<CZString, Value> ObjectValues;
3298# else
3299 typedef CppTL::SmallMap<CZString, Value> ObjectValues;
3300# endif // ifndef JSON_USE_CPPTL_SMALLMAP
3301# endif // ifndef JSON_VALUE_USE_INTERNAL_MAP
3302#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
3303
3304 public:
3305 /** \brief Create a default Value of the given type.
3306
3307 This is a very useful constructor.
3308 To create an empty array, pass arrayValue.
3309 To create an empty object, pass objectValue.
3310 Another Value can then be set to this one by assignment.
3311 This is useful since clear() and resize() will not alter types.
3312
3313 Examples:
3314 \code
3315 Json::Value null_value; // null
3316 Json::Value arr_value(Json::arrayValue); // []
3317 Json::Value obj_value(Json::objectValue); // {}
3318 \endcode
3319 */
3320 Value( ValueType type = nullValue );
3321 Value( Int value );
3322 Value( UInt value );
3323#if defined(JSON_HAS_INT64)
3324 Value( Int64 value );
3325 Value( UInt64 value );
3326#endif // if defined(JSON_HAS_INT64)
3327 Value( double value );
3328 Value( const char *value );
3329 Value( const char *beginValue, const char *endValue );
3330 /** \brief Constructs a value from a static string.
3331
3332 * Like other value string constructor but do not duplicate the string for
3333 * internal storage. The given string must remain alive after the call to this
3334 * constructor.
3335 * Example of usage:
3336 * \code
3337 * Json::Value aValue( StaticString("some text") );
3338 * \endcode
3339 */
3340 Value( const StaticString &value );
3341 Value( const std::string &value );
3342# ifdef JSON_USE_CPPTL
3343 Value( const CppTL::ConstString &value );
3344# endif
3345 Value( bool value );
3346 Value( const Value &other );
3347 ~Value();
3348
3349 Value &operator=( const Value &other );
3350 /// Swap values.
3351 /// \note Currently, comments are intentionally not swapped, for
3352 /// both logic and efficiency.
3353 void swap( Value &other );
3354
3355 ValueType type() const;
3356
3357 bool operator <( const Value &other ) const;
3358 bool operator <=( const Value &other ) const;
3359 bool operator >=( const Value &other ) const;
3360 bool operator >( const Value &other ) const;
3361
3362 bool operator ==( const Value &other ) const;
3363 bool operator !=( const Value &other ) const;
3364
3365 int compare( const Value &other ) const;
3366
3367 const char *asCString() const;
3368 std::string asString() const;
3369# ifdef JSON_USE_CPPTL
3370 CppTL::ConstString asConstString() const;
3371# endif
3372 Int asInt() const;
3373 UInt asUInt() const;
3374 Int64 asInt64() const;
3375 UInt64 asUInt64() const;
3376 LargestInt asLargestInt() const;
3377 LargestUInt asLargestUInt() const;
3378 float asFloat() const;
3379 double asDouble() const;
3380 bool asBool() const;
3381
3382 bool isNull() const;
3383 bool isBool() const;
3384 bool isInt() const;
3385 bool isUInt() const;
3386 bool isIntegral() const;
3387 bool isDouble() const;
3388 bool isNumeric() const;
3389 bool isString() const;
3390 bool isArray() const;
3391 bool isObject() const;
3392
3393 bool isConvertibleTo( ValueType other ) const;
3394
3395 /// Number of values in array or object
3396 ArrayIndex size() const;
3397
3398 /// \brief Return true if empty array, empty object, or null;
3399 /// otherwise, false.
3400 bool empty() const;
3401
3402 /// Return isNull()
3403 bool operator!() const;
3404
3405 /// Remove all object members and array elements.
3406 /// \pre type() is arrayValue, objectValue, or nullValue
3407 /// \post type() is unchanged
3408 void clear();
3409
3410 /// Resize the array to size elements.
3411 /// New elements are initialized to null.
3412 /// May only be called on nullValue or arrayValue.
3413 /// \pre type() is arrayValue or nullValue
3414 /// \post type() is arrayValue
3415 void resize( ArrayIndex size );
3416
3417 /// Access an array element (zero based index ).
3418 /// If the array contains less than index element, then null value are inserted
3419 /// in the array so that its size is index+1.
3420 /// (You may need to say 'value[0u]' to get your compiler to distinguish
3421 /// this from the operator[] which takes a string.)
3422 Value &operator[]( ArrayIndex index );
3423
3424 /// Access an array element (zero based index ).
3425 /// If the array contains less than index element, then null value are inserted
3426 /// in the array so that its size is index+1.
3427 /// (You may need to say 'value[0u]' to get your compiler to distinguish
3428 /// this from the operator[] which takes a string.)
3429 Value &operator[]( int index );
3430
3431 /// Access an array element (zero based index )
3432 /// (You may need to say 'value[0u]' to get your compiler to distinguish
3433 /// this from the operator[] which takes a string.)
3434 const Value &operator[]( ArrayIndex index ) const;
3435
3436 /// Access an array element (zero based index )
3437 /// (You may need to say 'value[0u]' to get your compiler to distinguish
3438 /// this from the operator[] which takes a string.)
3439 const Value &operator[]( int index ) const;
3440
3441 /// If the array contains at least index+1 elements, returns the element value,
3442 /// otherwise returns defaultValue.
3443 Value get( ArrayIndex index,
3444 const Value &defaultValue ) const;
3445 /// Return true if index < size().
3446 bool isValidIndex( ArrayIndex index ) const;
3447 /// \brief Append value to array at the end.
3448 ///
3449 /// Equivalent to jsonvalue[jsonvalue.size()] = value;
3450 Value &append( const Value &value );
3451
3452 /// Access an object value by name, create a null member if it does not exist.
3453 Value &operator[]( const char *key );
3454 /// Access an object value by name, returns null if there is no member with that name.
3455 const Value &operator[]( const char *key ) const;
3456 /// Access an object value by name, create a null member if it does not exist.
3457 Value &operator[]( const std::string &key );
3458 /// Access an object value by name, returns null if there is no member with that name.
3459 const Value &operator[]( const std::string &key ) const;
3460 /** \brief Access an object value by name, create a null member if it does not exist.
3461
3462 * If the object as no entry for that name, then the member name used to store
3463 * the new entry is not duplicated.
3464 * Example of use:
3465 * \code
3466 * Json::Value object;
3467 * static const StaticString code("code");
3468 * object[code] = 1234;
3469 * \endcode
3470 */
3471 Value &operator[]( const StaticString &key );
3472# ifdef JSON_USE_CPPTL
3473 /// Access an object value by name, create a null member if it does not exist.
3474 Value &operator[]( const CppTL::ConstString &key );
3475 /// Access an object value by name, returns null if there is no member with that name.
3476 const Value &operator[]( const CppTL::ConstString &key ) const;
3477# endif
3478 /// Return the member named key if it exist, defaultValue otherwise.
3479 Value get( const char *key,
3480 const Value &defaultValue ) const;
3481 /// Return the member named key if it exist, defaultValue otherwise.
3482 Value get( const std::string &key,
3483 const Value &defaultValue ) const;
3484# ifdef JSON_USE_CPPTL
3485 /// Return the member named key if it exist, defaultValue otherwise.
3486 Value get( const CppTL::ConstString &key,
3487 const Value &defaultValue ) const;
3488# endif
3489 /// \brief Remove and return the named member.
3490 ///
3491 /// Do nothing if it did not exist.
3492 /// \return the removed Value, or null.
3493 /// \pre type() is objectValue or nullValue
3494 /// \post type() is unchanged
3495 Value removeMember( const char* key );
3496 /// Same as removeMember(const char*)
3497 Value removeMember( const std::string &key );
3498
3499 /// Return true if the object has a member named key.
3500 bool isMember( const char *key ) const;
3501 /// Return true if the object has a member named key.
3502 bool isMember( const std::string &key ) const;
3503# ifdef JSON_USE_CPPTL
3504 /// Return true if the object has a member named key.
3505 bool isMember( const CppTL::ConstString &key ) const;
3506# endif
3507
3508 /// \brief Return a list of the member names.
3509 ///
3510 /// If null, return an empty list.
3511 /// \pre type() is objectValue or nullValue
3512 /// \post if type() was nullValue, it remains nullValue
3513 Members getMemberNames() const;
3514
3515//# ifdef JSON_USE_CPPTL
3516// EnumMemberNames enumMemberNames() const;
3517// EnumValues enumValues() const;
3518//# endif
3519
3520 /// Comments must be //... or /* ... */
3521 void setComment( const char *comment,
3522 CommentPlacement placement );
3523 /// Comments must be //... or /* ... */
3524 void setComment( const std::string &comment,
3525 CommentPlacement placement );
3526 bool hasComment( CommentPlacement placement ) const;
3527 /// Include delimiters and embedded newlines.
3528 std::string getComment( CommentPlacement placement ) const;
3529
3530 std::string toStyledString() const;
3531
3532 const_iterator begin() const;
3533 const_iterator end() const;
3534
3535 iterator begin();
3536 iterator end();
3537
3538 private:
3539 Value &resolveReference( const char *key,
3540 bool isStatic );
3541
3542# ifdef JSON_VALUE_USE_INTERNAL_MAP
3543 inline bool isItemAvailable() const
3544 {
3545 return itemIsUsed_ == 0;
3546 }
3547
3548 inline void setItemUsed( bool isUsed = true )
3549 {
3550 itemIsUsed_ = isUsed ? 1 : 0;
3551 }
3552
3553 inline bool isMemberNameStatic() const
3554 {
3555 return memberNameIsStatic_ == 0;
3556 }
3557
3558 inline void setMemberNameIsStatic( bool isStatic )
3559 {
3560 memberNameIsStatic_ = isStatic ? 1 : 0;
3561 }
3562# endif // # ifdef JSON_VALUE_USE_INTERNAL_MAP
3563
3564 private:
3565 struct CommentInfo
3566 {
3567 CommentInfo();
3568 ~CommentInfo();
3569
3570 void setComment( const char *text );
3571
3572 char *comment_;
3573 };
3574
3575 //struct MemberNamesTransform
3576 //{
3577 // typedef const char *result_type;
3578 // const char *operator()( const CZString &name ) const
3579 // {
3580 // return name.c_str();
3581 // }
3582 //};
3583
3584 union ValueHolder
3585 {
3586 LargestInt int_;
3587 LargestUInt uint_;
3588 double real_;
3589 bool bool_;
3590 char *string_;
3591# ifdef JSON_VALUE_USE_INTERNAL_MAP
3592 ValueInternalArray *array_;
3593 ValueInternalMap *map_;
3594#else
3595 ObjectValues *map_;
3596# endif
3597 } value_;
3598 ValueType type_ : 8;
3599 int allocated_ : 1; // Notes: if declared as bool, bitfield is useless.
3600# ifdef JSON_VALUE_USE_INTERNAL_MAP
3601 unsigned int itemIsUsed_ : 1; // used by the ValueInternalMap container.
3602 int memberNameIsStatic_ : 1; // used by the ValueInternalMap container.
3603# endif
3604 CommentInfo *comments_;
3605 };
3606
3607
3608 /** \brief Experimental and untested: represents an element of the "path" to access a node.
3609 */
3611 {
3612 public:
3613 friend class Path;
3614
3615 PathArgument();
3616 PathArgument( ArrayIndex index );
3617 PathArgument( const char *key );
3618 PathArgument( const std::string &key );
3619
3620 private:
3621 enum Kind
3622 {
3623 kindNone = 0,
3624 kindIndex,
3625 kindKey
3626 };
3627 std::string key_;
3628 ArrayIndex index_;
3629 Kind kind_;
3630 };
3631
3632 /** \brief Experimental and untested: represents a "path" to access a node.
3633 *
3634 * Syntax:
3635 * - "." => root node
3636 * - ".[n]" => elements at index 'n' of root node (an array value)
3637 * - ".name" => member named 'name' of root node (an object value)
3638 * - ".name1.name2.name3"
3639 * - ".[0][1][2].name1[3]"
3640 * - ".%" => member name is provided as parameter
3641 * - ".[%]" => index is provied as parameter
3642 */
3643 class Path
3644 {
3645 public:
3646 Path( const std::string &path,
3647 const PathArgument &a1 = PathArgument(),
3648 const PathArgument &a2 = PathArgument(),
3649 const PathArgument &a3 = PathArgument(),
3650 const PathArgument &a4 = PathArgument(),
3651 const PathArgument &a5 = PathArgument() );
3652
3653 const Value &resolve( const Value &root ) const;
3654 Value resolve( const Value &root,
3655 const Value &defaultValue ) const;
3656 /// Creates the "path" to access the specified node and returns a reference on the node.
3657 Value &make( Value &root ) const;
3658
3659 private:
3660 typedef std::vector<const PathArgument *> InArgs;
3661 typedef std::vector<PathArgument> Args;
3662
3663 void makePath( const std::string &path,
3664 const InArgs &in );
3665 void addPathInArg( const std::string &path,
3666 const InArgs &in,
3667 InArgs::const_iterator &itInArg,
3668 PathArgument::Kind kind );
3669 void invalidPath( const std::string &path,
3670 int location );
3671
3672 Args args_;
3673 };
3674
3675
3676
3677#ifdef JSON_VALUE_USE_INTERNAL_MAP
3678 /** \brief Allocator to customize Value internal map.
3679 * Below is an example of a simple implementation (default implementation actually
3680 * use memory pool for speed).
3681 * \code
3682 class DefaultValueMapAllocator : public ValueMapAllocator
3683 {
3684 public: // overridden from ValueMapAllocator
3685 virtual ValueInternalMap *newMap()
3686 {
3687 return new ValueInternalMap();
3688 }
3689
3690 virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other )
3691 {
3692 return new ValueInternalMap( other );
3693 }
3694
3695 virtual void destructMap( ValueInternalMap *map )
3696 {
3697 delete map;
3698 }
3699
3700 virtual ValueInternalLink *allocateMapBuckets( unsigned int size )
3701 {
3702 return new ValueInternalLink[size];
3703 }
3704
3705 virtual void releaseMapBuckets( ValueInternalLink *links )
3706 {
3707 delete [] links;
3708 }
3709
3710 virtual ValueInternalLink *allocateMapLink()
3711 {
3712 return new ValueInternalLink();
3713 }
3714
3715 virtual void releaseMapLink( ValueInternalLink *link )
3716 {
3717 delete link;
3718 }
3719 };
3720 * \endcode
3721 */
3722 class JSON_API ValueMapAllocator
3723 {
3724 public:
3725 virtual ~ValueMapAllocator();
3726 virtual ValueInternalMap *newMap() = 0;
3727 virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other ) = 0;
3728 virtual void destructMap( ValueInternalMap *map ) = 0;
3729 virtual ValueInternalLink *allocateMapBuckets( unsigned int size ) = 0;
3730 virtual void releaseMapBuckets( ValueInternalLink *links ) = 0;
3731 virtual ValueInternalLink *allocateMapLink() = 0;
3732 virtual void releaseMapLink( ValueInternalLink *link ) = 0;
3733 };
3734
3735 /** \brief ValueInternalMap hash-map bucket chain link (for internal use only).
3736 * \internal previous_ & next_ allows for bidirectional traversal.
3737 */
3738 class JSON_API ValueInternalLink
3739 {
3740 public:
3741 enum { itemPerLink = 6 }; // sizeof(ValueInternalLink) = 128 on 32 bits architecture.
3742 enum InternalFlags {
3743 flagAvailable = 0,
3744 flagUsed = 1
3745 };
3746
3747 ValueInternalLink();
3748
3749 ~ValueInternalLink();
3750
3751 Value items_[itemPerLink];
3752 char *keys_[itemPerLink];
3753 ValueInternalLink *previous_;
3754 ValueInternalLink *next_;
3755 };
3756
3757
3758 /** \brief A linked page based hash-table implementation used internally by Value.
3759 * \internal ValueInternalMap is a tradional bucket based hash-table, with a linked
3760 * list in each bucket to handle collision. There is an addional twist in that
3761 * each node of the collision linked list is a page containing a fixed amount of
3762 * value. This provides a better compromise between memory usage and speed.
3763 *
3764 * Each bucket is made up of a chained list of ValueInternalLink. The last
3765 * link of a given bucket can be found in the 'previous_' field of the following bucket.
3766 * The last link of the last bucket is stored in tailLink_ as it has no following bucket.
3767 * Only the last link of a bucket may contains 'available' item. The last link always
3768 * contains at least one element unless is it the bucket one very first link.
3769 */
3770 class JSON_API ValueInternalMap
3771 {
3772 friend class ValueIteratorBase;
3773 friend class Value;
3774 public:
3775 typedef unsigned int HashKey;
3776 typedef unsigned int BucketIndex;
3777
3778# ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
3779 struct IteratorState
3780 {
3781 IteratorState()
3782 : map_(0)
3783 , link_(0)
3784 , itemIndex_(0)
3785 , bucketIndex_(0)
3786 {
3787 }
3788 ValueInternalMap *map_;
3789 ValueInternalLink *link_;
3790 BucketIndex itemIndex_;
3791 BucketIndex bucketIndex_;
3792 };
3793# endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
3794
3795 ValueInternalMap();
3796 ValueInternalMap( const ValueInternalMap &other );
3797 ValueInternalMap &operator =( const ValueInternalMap &other );
3798 ~ValueInternalMap();
3799
3800 void swap( ValueInternalMap &other );
3801
3802 BucketIndex size() const;
3803
3804 void clear();
3805
3806 bool reserveDelta( BucketIndex growth );
3807
3808 bool reserve( BucketIndex newItemCount );
3809
3810 const Value *find( const char *key ) const;
3811
3812 Value *find( const char *key );
3813
3814 Value &resolveReference( const char *key,
3815 bool isStatic );
3816
3817 void remove( const char *key );
3818
3819 void doActualRemove( ValueInternalLink *link,
3820 BucketIndex index,
3821 BucketIndex bucketIndex );
3822
3823 ValueInternalLink *&getLastLinkInBucket( BucketIndex bucketIndex );
3824
3825 Value &setNewItem( const char *key,
3826 bool isStatic,
3827 ValueInternalLink *link,
3828 BucketIndex index );
3829
3830 Value &unsafeAdd( const char *key,
3831 bool isStatic,
3832 HashKey hashedKey );
3833
3834 HashKey hash( const char *key ) const;
3835
3836 int compare( const ValueInternalMap &other ) const;
3837
3838 private:
3839 void makeBeginIterator( IteratorState &it ) const;
3840 void makeEndIterator( IteratorState &it ) const;
3841 static bool equals( const IteratorState &x, const IteratorState &other );
3842 static void increment( IteratorState &iterator );
3843 static void incrementBucket( IteratorState &iterator );
3844 static void decrement( IteratorState &iterator );
3845 static const char *key( const IteratorState &iterator );
3846 static const char *key( const IteratorState &iterator, bool &isStatic );
3847 static Value &value( const IteratorState &iterator );
3848 static int distance( const IteratorState &x, const IteratorState &y );
3849
3850 private:
3851 ValueInternalLink *buckets_;
3852 ValueInternalLink *tailLink_;
3853 BucketIndex bucketsSize_;
3854 BucketIndex itemCount_;
3855 };
3856
3857 /** \brief A simplified deque implementation used internally by Value.
3858 * \internal
3859 * It is based on a list of fixed "page", each page contains a fixed number of items.
3860 * Instead of using a linked-list, a array of pointer is used for fast item look-up.
3861 * Look-up for an element is as follow:
3862 * - compute page index: pageIndex = itemIndex / itemsPerPage
3863 * - look-up item in page: pages_[pageIndex][itemIndex % itemsPerPage]
3864 *
3865 * Insertion is amortized constant time (only the array containing the index of pointers
3866 * need to be reallocated when items are appended).
3867 */
3868 class JSON_API ValueInternalArray
3869 {
3870 friend class Value;
3871 friend class ValueIteratorBase;
3872 public:
3873 enum { itemsPerPage = 8 }; // should be a power of 2 for fast divide and modulo.
3874 typedef Value::ArrayIndex ArrayIndex;
3875 typedef unsigned int PageIndex;
3876
3877# ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
3878 struct IteratorState // Must be a POD
3879 {
3880 IteratorState()
3881 : array_(0)
3882 , currentPageIndex_(0)
3883 , currentItemIndex_(0)
3884 {
3885 }
3886 ValueInternalArray *array_;
3887 Value **currentPageIndex_;
3888 unsigned int currentItemIndex_;
3889 };
3890# endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
3891
3892 ValueInternalArray();
3893 ValueInternalArray( const ValueInternalArray &other );
3894 ValueInternalArray &operator =( const ValueInternalArray &other );
3895 ~ValueInternalArray();
3896 void swap( ValueInternalArray &other );
3897
3898 void clear();
3899 void resize( ArrayIndex newSize );
3900
3901 Value &resolveReference( ArrayIndex index );
3902
3903 Value *find( ArrayIndex index ) const;
3904
3905 ArrayIndex size() const;
3906
3907 int compare( const ValueInternalArray &other ) const;
3908
3909 private:
3910 static bool equals( const IteratorState &x, const IteratorState &other );
3911 static void increment( IteratorState &iterator );
3912 static void decrement( IteratorState &iterator );
3913 static Value &dereference( const IteratorState &iterator );
3914 static Value &unsafeDereference( const IteratorState &iterator );
3915 static int distance( const IteratorState &x, const IteratorState &y );
3916 static ArrayIndex indexOf( const IteratorState &iterator );
3917 void makeBeginIterator( IteratorState &it ) const;
3918 void makeEndIterator( IteratorState &it ) const;
3919 void makeIterator( IteratorState &it, ArrayIndex index ) const;
3920
3921 void makeIndexValid( ArrayIndex index );
3922
3923 Value **pages_;
3924 ArrayIndex size_;
3925 PageIndex pageCount_;
3926 };
3927
3928 /** \brief Experimental: do not use. Allocator to customize Value internal array.
3929 * Below is an example of a simple implementation (actual implementation use
3930 * memory pool).
3931 \code
3932class DefaultValueArrayAllocator : public ValueArrayAllocator
3933{
3934public: // overridden from ValueArrayAllocator
3935 virtual ~DefaultValueArrayAllocator()
3936 {
3937 }
3938
3939 virtual ValueInternalArray *newArray()
3940 {
3941 return new ValueInternalArray();
3942 }
3943
3944 virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other )
3945 {
3946 return new ValueInternalArray( other );
3947 }
3948
3949 virtual void destruct( ValueInternalArray *array )
3950 {
3951 delete array;
3952 }
3953
3954 virtual void reallocateArrayPageIndex( Value **&indexes,
3955 ValueInternalArray::PageIndex &indexCount,
3956 ValueInternalArray::PageIndex minNewIndexCount )
3957 {
3958 ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1;
3959 if ( minNewIndexCount > newIndexCount )
3960 newIndexCount = minNewIndexCount;
3961 void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount );
3962 if ( !newIndexes )
3963 throw std::bad_alloc();
3964 indexCount = newIndexCount;
3965 indexes = static_cast<Value **>( newIndexes );
3966 }
3967 virtual void releaseArrayPageIndex( Value **indexes,
3968 ValueInternalArray::PageIndex indexCount )
3969 {
3970 if ( indexes )
3971 free( indexes );
3972 }
3973
3974 virtual Value *allocateArrayPage()
3975 {
3976 return static_cast<Value *>( malloc( sizeof(Value) * ValueInternalArray::itemsPerPage ) );
3977 }
3978
3979 virtual void releaseArrayPage( Value *value )
3980 {
3981 if ( value )
3982 free( value );
3983 }
3984};
3985 \endcode
3986 */
3987 class JSON_API ValueArrayAllocator
3988 {
3989 public:
3990 virtual ~ValueArrayAllocator();
3991 virtual ValueInternalArray *newArray() = 0;
3992 virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other ) = 0;
3993 virtual void destructArray( ValueInternalArray *array ) = 0;
3994 /** \brief Reallocate array page index.
3995 * Reallocates an array of pointer on each page.
3996 * \param indexes [input] pointer on the current index. May be \c NULL.
3997 * [output] pointer on the new index of at least
3998 * \a minNewIndexCount pages.
3999 * \param indexCount [input] current number of pages in the index.
4000 * [output] number of page the reallocated index can handle.
4001 * \b MUST be >= \a minNewIndexCount.
4002 * \param minNewIndexCount Minimum number of page the new index must be able to
4003 * handle.
4004 */
4005 virtual void reallocateArrayPageIndex( Value **&indexes,
4006 ValueInternalArray::PageIndex &indexCount,
4007 ValueInternalArray::PageIndex minNewIndexCount ) = 0;
4008 virtual void releaseArrayPageIndex( Value **indexes,
4009 ValueInternalArray::PageIndex indexCount ) = 0;
4010 virtual Value *allocateArrayPage() = 0;
4011 virtual void releaseArrayPage( Value *value ) = 0;
4012 };
4013#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP
4014
4015
4016 /** \brief base class for Value iterators.
4017 *
4018 */
4020 {
4021 public:
4022 typedef unsigned int size_t;
4023 typedef int difference_type;
4025
4027#ifndef JSON_VALUE_USE_INTERNAL_MAP
4028 explicit ValueIteratorBase( const Value::ObjectValues::iterator &current );
4029#else
4030 ValueIteratorBase( const ValueInternalArray::IteratorState &state );
4031 ValueIteratorBase( const ValueInternalMap::IteratorState &state );
4032#endif
4033
4034 bool operator ==( const SelfType &other ) const
4035 {
4036 return isEqual( other );
4037 }
4038
4039 bool operator !=( const SelfType &other ) const
4040 {
4041 return !isEqual( other );
4042 }
4043
4045 {
4046 return computeDistance( other );
4047 }
4048
4049 /// Return either the index or the member name of the referenced value as a Value.
4050 Value key() const;
4051
4052 /// Return the index of the referenced Value. -1 if it is not an arrayValue.
4053 UInt index() const;
4054
4055 /// Return the member name of the referenced Value. "" if it is not an objectValue.
4056 const char *memberName() const;
4057
4058 protected:
4059 Value &deref() const;
4060
4061 void increment();
4062
4063 void decrement();
4064
4065 difference_type computeDistance( const SelfType &other ) const;
4066
4067 bool isEqual( const SelfType &other ) const;
4068
4069 void copy( const SelfType &other );
4070
4071 private:
4072#ifndef JSON_VALUE_USE_INTERNAL_MAP
4073 Value::ObjectValues::iterator current_;
4074 // Indicates that iterator is for a null value.
4075 bool isNull_;
4076#else
4077 union
4078 {
4079 ValueInternalArray::IteratorState array_;
4080 ValueInternalMap::IteratorState map_;
4081 } iterator_;
4082 bool isArray_;
4083#endif
4084 };
4085
4086 /** \brief const iterator for object and array value.
4087 *
4088 */
4090 {
4091 friend class Value;
4092 public:
4093 typedef unsigned int size_t;
4094 typedef int difference_type;
4095 typedef const Value &reference;
4096 typedef const Value *pointer;
4098
4100 private:
4101 /*! \internal Use by Value to create an iterator.
4102 */
4103#ifndef JSON_VALUE_USE_INTERNAL_MAP
4104 explicit ValueConstIterator( const Value::ObjectValues::iterator &current );
4105#else
4106 ValueConstIterator( const ValueInternalArray::IteratorState &state );
4107 ValueConstIterator( const ValueInternalMap::IteratorState &state );
4108#endif
4109 public:
4110 SelfType &operator =( const ValueIteratorBase &other );
4111
4113 {
4114 SelfType temp( *this );
4115 ++*this;
4116 return temp;
4117 }
4118
4120 {
4121 SelfType temp( *this );
4122 --*this;
4123 return temp;
4124 }
4125
4127 {
4128 decrement();
4129 return *this;
4130 }
4131
4133 {
4134 increment();
4135 return *this;
4136 }
4137
4139 {
4140 return deref();
4141 }
4142 };
4143
4144
4145 /** \brief Iterator for object and array value.
4146 */
4148 {
4149 friend class Value;
4150 public:
4151 typedef unsigned int size_t;
4152 typedef int difference_type;
4154 typedef Value *pointer;
4156
4157 ValueIterator();
4158 ValueIterator( const ValueConstIterator &other );
4159 ValueIterator( const ValueIterator &other );
4160 private:
4161 /*! \internal Use by Value to create an iterator.
4162 */
4163#ifndef JSON_VALUE_USE_INTERNAL_MAP
4164 explicit ValueIterator( const Value::ObjectValues::iterator &current );
4165#else
4166 ValueIterator( const ValueInternalArray::IteratorState &state );
4167 ValueIterator( const ValueInternalMap::IteratorState &state );
4168#endif
4169 public:
4170
4171 SelfType &operator =( const SelfType &other );
4172
4174 {
4175 SelfType temp( *this );
4176 ++*this;
4177 return temp;
4178 }
4179
4181 {
4182 SelfType temp( *this );
4183 --*this;
4184 return temp;
4185 }
4186
4188 {
4189 decrement();
4190 return *this;
4191 }
4192
4194 {
4195 increment();
4196 return *this;
4197 }
4198
4200 {
4201 return deref();
4202 }
4203 };
4204
4205
4206} // namespace Json
4207
4208
4209#endif // CPPTL_JSON_H_INCLUDED
4210
4211// //////////////////////////////////////////////////////////////////////
4212// End of content of file: include/json/value.h
4213// //////////////////////////////////////////////////////////////////////
4214
4215
4216
4217
4218
4219
4220// //////////////////////////////////////////////////////////////////////
4221// Beginning of content of file: include/json/reader.h
4222// //////////////////////////////////////////////////////////////////////
4223
4224// Copyright 2007-2010 Baptiste Lepilleur
4225// Distributed under MIT license, or public domain if desired and
4226// recognized in your jurisdiction.
4227// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
4228
4229#ifndef CPPTL_JSON_READER_H_INCLUDED
4230# define CPPTL_JSON_READER_H_INCLUDED
4231
4232#if !defined(JSON_IS_AMALGAMATION)
4233# include "features.h"
4234# include "value.h"
4235#endif // if !defined(JSON_IS_AMALGAMATION)
4236# include <deque>
4237# include <stack>
4238# include <string>
4239# include <iostream>
4240
4241namespace Json {
4242
4243 /** \brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a Value.
4244 *
4245 */
4247 {
4248 public:
4249 typedef char Char;
4250 typedef const Char *Location;
4251
4252 /** \brief Constructs a Reader allowing all features
4253 * for parsing.
4254 */
4255 Reader();
4256
4257 /** \brief Constructs a Reader allowing the specified feature set
4258 * for parsing.
4259 */
4260 Reader( const Features &features );
4261
4262 /** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a> document.
4263 * \param document UTF-8 encoded string containing the document to read.
4264 * \param root [out] Contains the root value of the document if it was
4265 * successfully parsed.
4266 * \param collectComments \c true to collect comment and allow writing them back during
4267 * serialization, \c false to discard comments.
4268 * This parameter is ignored if Features::allowComments_
4269 * is \c false.
4270 * \return \c true if the document was successfully parsed, \c false if an error occurred.
4271 */
4272 bool parse( const std::string &document,
4273 Value &root,
4274 bool collectComments = true );
4275
4276 /** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a> document.
4277 * \param beginDoc Pointer on the beginning of the UTF-8 encoded string of the document to read.
4278 * \param endDoc Pointer on the end of the UTF-8 encoded string of the document to read.
4279 \ Must be >= beginDoc.
4280 * \param root [out] Contains the root value of the document if it was
4281 * successfully parsed.
4282 * \param collectComments \c true to collect comment and allow writing them back during
4283 * serialization, \c false to discard comments.
4284 * This parameter is ignored if Features::allowComments_
4285 * is \c false.
4286 * \return \c true if the document was successfully parsed, \c false if an error occurred.
4287 */
4288 bool parse( const char *beginDoc, const char *endDoc,
4289 Value &root,
4290 bool collectComments = true );
4291
4292 /// \brief Parse from input stream.
4293 /// \see Json::operator>>(std::istream&, Json::Value&).
4294 bool parse( std::istream &is,
4295 Value &root,
4296 bool collectComments = true );
4297
4298 /** \brief Returns a user friendly string that list errors in the parsed document.
4299 * \return Formatted error message with the list of errors with their location in
4300 * the parsed document. An empty string is returned if no error occurred
4301 * during parsing.
4302 * \deprecated Use getFormattedErrorMessages() instead (typo fix).
4303 */
4304 JSONCPP_DEPRECATED("Use getFormattedErrorMessages instead")
4305 std::string getFormatedErrorMessages() const;
4306
4307 /** \brief Returns a user friendly string that list errors in the parsed document.
4308 * \return Formatted error message with the list of errors with their location in
4309 * the parsed document. An empty string is returned if no error occurred
4310 * during parsing.
4311 */
4312 std::string getFormattedErrorMessages() const;
4313
4314 private:
4315 enum TokenType
4316 {
4317 tokenEndOfStream = 0,
4318 tokenObjectBegin,
4319 tokenObjectEnd,
4320 tokenArrayBegin,
4321 tokenArrayEnd,
4322 tokenString,
4323 tokenNumber,
4324 tokenTrue,
4325 tokenFalse,
4326 tokenNull,
4327 tokenArraySeparator,
4328 tokenMemberSeparator,
4329 tokenComment,
4330 tokenError
4331 };
4332
4333 class Token
4334 {
4335 public:
4336 TokenType type_;
4337 Location start_;
4338 Location end_;
4339 };
4340
4341 class ErrorInfo
4342 {
4343 public:
4344 Token token_;
4345 std::string message_;
4346 Location extra_;
4347 };
4348
4349 typedef std::deque<ErrorInfo> Errors;
4350
4351 bool expectToken( TokenType type, Token &token, const char *message );
4352 bool readToken( Token &token );
4353 void skipSpaces();
4354 bool match( Location pattern,
4355 int patternLength );
4356 bool readComment();
4357 bool readCStyleComment();
4358 bool readCppStyleComment();
4359 bool readString();
4360 void readNumber();
4361 bool readValue();
4362 bool readObject( Token &token );
4363 bool readArray( Token &token );
4364 bool decodeNumber( Token &token );
4365 bool decodeString( Token &token );
4366 bool decodeString( Token &token, std::string &decoded );
4367 bool decodeDouble( Token &token );
4368 bool decodeUnicodeCodePoint( Token &token,
4369 Location &current,
4370 Location end,
4371 unsigned int &unicode );
4372 bool decodeUnicodeEscapeSequence( Token &token,
4373 Location &current,
4374 Location end,
4375 unsigned int &unicode );
4376 bool addError( const std::string &message,
4377 Token &token,
4378 Location extra = 0 );
4379 bool recoverFromError( TokenType skipUntilToken );
4380 bool addErrorAndRecover( const std::string &message,
4381 Token &token,
4382 TokenType skipUntilToken );
4383 void skipUntilSpace();
4384 Value &currentValue();
4385 Char getNextChar();
4386 void getLocationLineAndColumn( Location location,
4387 int &line,
4388 int &column ) const;
4389 std::string getLocationLineAndColumn( Location location ) const;
4390 void addComment( Location begin,
4391 Location end,
4392 CommentPlacement placement );
4393 void skipCommentTokens( Token &token );
4394
4395 typedef std::stack<Value *> Nodes;
4396 Nodes nodes_;
4397 Errors errors_;
4398 std::string document_;
4399 Location begin_;
4400 Location end_;
4401 Location current_;
4402 Location lastValueEnd_;
4403 Value *lastValue_;
4404 std::string commentsBefore_;
4405 Features features_;
4406 bool collectComments_;
4407 };
4408
4409 /** \brief Read from 'sin' into 'root'.
4410
4411 Always keep comments from the input JSON.
4412
4413 This can be used to read a file into a particular sub-object.
4414 For example:
4415 \code
4416 Json::Value root;
4417 cin >> root["dir"]["file"];
4418 cout << root;
4419 \endcode
4420 Result:
4421 \verbatim
4422 {
4423 "dir": {
4424 "file": {
4425 // The input stream JSON would be nested here.
4426 }
4427 }
4428 }
4429 \endverbatim
4430 \throw std::exception on parse error.
4431 \see Json::operator<<()
4432 */
4433 std::istream& operator>>( std::istream&, Value& );
4434
4435} // namespace Json
4436
4437#endif // CPPTL_JSON_READER_H_INCLUDED
4438
4439// //////////////////////////////////////////////////////////////////////
4440// End of content of file: include/json/reader.h
4441// //////////////////////////////////////////////////////////////////////
4442
4443
4444
4445
4446
4447
4448// //////////////////////////////////////////////////////////////////////
4449// Beginning of content of file: include/json/writer.h
4450// //////////////////////////////////////////////////////////////////////
4451
4452// Copyright 2007-2010 Baptiste Lepilleur
4453// Distributed under MIT license, or public domain if desired and
4454// recognized in your jurisdiction.
4455// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
4456
4457#ifndef JSON_WRITER_H_INCLUDED
4458# define JSON_WRITER_H_INCLUDED
4459
4460#if !defined(JSON_IS_AMALGAMATION)
4461# include "value.h"
4462#endif // if !defined(JSON_IS_AMALGAMATION)
4463# include <vector>
4464# include <string>
4465# include <iostream>
4466
4467namespace Json {
4468
4469 class Value;
4470
4471 /** \brief Abstract class for writers.
4472 */
4474 {
4475 public:
4476 virtual ~Writer();
4477
4478 virtual std::string write( const Value &root ) = 0;
4479 };
4480
4481 /** \brief Outputs a Value in <a HREF="http://www.json.org">JSON</a> format without formatting (not human friendly).
4482 *
4483 * The JSON document is written in a single line. It is not intended for 'human' consumption,
4484 * but may be usefull to support feature such as RPC where bandwith is limited.
4485 * \sa Reader, Value
4486 */
4488 {
4489 public:
4490 FastWriter();
4491 virtual ~FastWriter(){}
4492
4493 void enableYAMLCompatibility();
4494
4495 public: // overridden from Writer
4496 virtual std::string write( const Value &root );
4497
4498 private:
4499 void writeValue( const Value &value );
4500
4501 std::string document_;
4502 bool yamlCompatiblityEnabled_;
4503 };
4504
4505 /** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a human friendly way.
4506 *
4507 * The rules for line break and indent are as follow:
4508 * - Object value:
4509 * - if empty then print {} without indent and line break
4510 * - if not empty the print '{', line break & indent, print one value per line
4511 * and then unindent and line break and print '}'.
4512 * - Array value:
4513 * - if empty then print [] without indent and line break
4514 * - if the array contains no object value, empty array or some other value types,
4515 * and all the values fit on one lines, then print the array on a single line.
4516 * - otherwise, it the values do not fit on one line, or the array contains
4517 * object or non empty array, then print one value per line.
4518 *
4519 * If the Value have comments then they are outputed according to their #CommentPlacement.
4520 *
4521 * \sa Reader, Value, Value::setComment()
4522 */
4524 {
4525 public:
4526 StyledWriter();
4527 virtual ~StyledWriter(){}
4528
4529 public: // overridden from Writer
4530 /** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
4531 * \param root Value to serialize.
4532 * \return String containing the JSON document that represents the root value.
4533 */
4534 virtual std::string write( const Value &root );
4535
4536 private:
4537 void writeValue( const Value &value );
4538 void writeArrayValue( const Value &value );
4539 bool isMultineArray( const Value &value );
4540 void pushValue( const std::string &value );
4541 void writeIndent();
4542 void writeWithIndent( const std::string &value );
4543 void indent();
4544 void unindent();
4545 void writeCommentBeforeValue( const Value &root );
4546 void writeCommentAfterValueOnSameLine( const Value &root );
4547 bool hasCommentForValue( const Value &value );
4548 static std::string normalizeEOL( const std::string &text );
4549
4550 typedef std::vector<std::string> ChildValues;
4551
4552 ChildValues childValues_;
4553 std::string document_;
4554 std::string indentString_;
4555 int rightMargin_;
4556 int indentSize_;
4557 bool addChildValues_;
4558 };
4559
4560 /** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a human friendly way,
4561 to a stream rather than to a string.
4562 *
4563 * The rules for line break and indent are as follow:
4564 * - Object value:
4565 * - if empty then print {} without indent and line break
4566 * - if not empty the print '{', line break & indent, print one value per line
4567 * and then unindent and line break and print '}'.
4568 * - Array value:
4569 * - if empty then print [] without indent and line break
4570 * - if the array contains no object value, empty array or some other value types,
4571 * and all the values fit on one lines, then print the array on a single line.
4572 * - otherwise, it the values do not fit on one line, or the array contains
4573 * object or non empty array, then print one value per line.
4574 *
4575 * If the Value have comments then they are outputed according to their #CommentPlacement.
4576 *
4577 * \param indentation Each level will be indented by this amount extra.
4578 * \sa Reader, Value, Value::setComment()
4579 */
4581 {
4582 public:
4583 StyledStreamWriter( std::string indentation="\t" );
4585
4586 public:
4587 /** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
4588 * \param out Stream to write to. (Can be ostringstream, e.g.)
4589 * \param root Value to serialize.
4590 * \note There is no point in deriving from Writer, since write() should not return a value.
4591 */
4592 void write( std::ostream &out, const Value &root );
4593
4594 private:
4595 void writeValue( const Value &value );
4596 void writeArrayValue( const Value &value );
4597 bool isMultineArray( const Value &value );
4598 void pushValue( const std::string &value );
4599 void writeIndent();
4600 void writeWithIndent( const std::string &value );
4601 void indent();
4602 void unindent();
4603 void writeCommentBeforeValue( const Value &root );
4604 void writeCommentAfterValueOnSameLine( const Value &root );
4605 bool hasCommentForValue( const Value &value );
4606 static std::string normalizeEOL( const std::string &text );
4607
4608 typedef std::vector<std::string> ChildValues;
4609
4610 ChildValues childValues_;
4611 std::ostream* document_;
4612 std::string indentString_;
4613 int rightMargin_;
4614 std::string indentation_;
4615 bool addChildValues_;
4616 };
4617
4618# if defined(JSON_HAS_INT64)
4619 std::string JSON_API valueToString( Int value );
4620 std::string JSON_API valueToString( UInt value );
4621# endif // if defined(JSON_HAS_INT64)
4622 std::string JSON_API valueToString( LargestInt value );
4623 std::string JSON_API valueToString( LargestUInt value );
4624 std::string JSON_API valueToString( double value );
4625 std::string JSON_API valueToString( bool value );
4626 std::string JSON_API valueToQuotedString( const char *value );
4627
4628 /// \brief Output using the StyledStreamWriter.
4629 /// \see Json::operator>>()
4630 std::ostream& operator<<( std::ostream&, const Value &root );
4631
4632} // namespace Json
4633
4634
4635
4636#endif // JSON_WRITER_H_INCLUDED
4637
4638// //////////////////////////////////////////////////////////////////////
4639// End of content of file: include/json/writer.h
4640// //////////////////////////////////////////////////////////////////////
4641
4642
4643
4644
4645
4646#endif //ifndef JSON_AMALGATED_H_INCLUDED
4647//
4648// end of src/json.h
4649//
4650
4651
4652//
4653// start of src/jsoncustomwriter.h
4654//
4655/**********************************************************************
4656Copyright (c) 2013 by Matt Swain <m.swain@me.com>
4657
4658The MIT License
4659
4660Permission is hereby granted, free of charge, to any person obtaining a copy
4661of this software and associated documentation files (the "Software"), to deal
4662in the Software without restriction, including without limitation the rights
4663to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4664copies of the Software, and to permit persons to whom the Software is
4665furnished to do so, subject to the following conditions:
4666
4667The above copyright notice and this permission notice shall be included in
4668all copies or substantial portions of the Software.
4669
4670THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4671IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4672FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4673AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4674LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4675OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
4676THE SOFTWARE.
4677
4678***********************************************************************/
4679
4680#ifndef PYNE_46Z7LQYFI5HZNASIPCWHVX3X5E
4681#define PYNE_46Z7LQYFI5HZNASIPCWHVX3X5E
4682
4683#include <string>
4684
4685namespace Json {
4686
4687 /** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format with custom formatting.
4688 *
4689 * The JSON document is written according to the rules specified in the constructor. Objects and
4690 * arrays are printed on a single line if they are below a certain length, otherwise they are
4691 * indented. It is possible to output invalid json if the customizable parameters are specified
4692 * incorrectly. Set maxWidth to 0 to print output on a single line.
4693 *
4694 * \sa Reader, Value
4695 */
4697 {
4698 public:
4699 CustomWriter( std::string opencurly = "{",
4700 std::string closecurly = "}",
4701 std::string opensquare = "[",
4702 std::string closesquare = "]",
4703 std::string colon = ":",
4704 std::string comma = ",",
4705 std::string indent = " ",
4706 int maxWidth = 74);
4707 virtual ~CustomWriter(){}
4708
4709 public: // overridden from Writer
4710 virtual std::string write( const Value &root );
4711
4712 private:
4713 void writeValue( const Value &value, std::string &doc, bool forceSingleLine );
4714 bool isMultiline( const Value &value );
4715 void indent();
4716 void unindent();
4717
4718 std::string document_;
4719 std::string indentString_;
4720 std::string opencurly_;
4721 std::string closecurly_;
4722 std::string opensquare_;
4723 std::string closesquare_;
4724 std::string colon_;
4725 std::string comma_;
4726 std::string indent_;
4727 int maxWidth_;
4728 };
4729
4730}
4731
4732#endif//
4733// end of src/jsoncustomwriter.h
4734//
4735
4736
4737//
4738// start of src/material.h
4739//
4740/// \brief The ever-important material class and related helpers.
4741///
4742/// The material class is effectively a normalized nuclide linked list with
4743/// associated mass, density, atoms per mol, and metadata. However, this
4744/// implementation also contains other functions for mixing materials and generating
4745/// related materials.
4746
4747#ifndef PYNE_MR34UE5INRGMZK2QYRDWICFHVM
4748#define PYNE_MR34UE5INRGMZK2QYRDWICFHVM
4749
4750#include <iostream>
4751#include <fstream>
4752#include <string>
4753#include <map>
4754#include <set>
4755#include <stdio.h>
4756#include <stdlib.h>
4757#include <sstream> // std::ostringstream
4758
4759#if !defined(JSON_IS_AMALGAMATION)
4760 #define JSON_IS_AMALGAMATION
4761#endif
4762
4763#ifndef PYNE_IS_AMALGAMATED
4764#include "json-forwards.h"
4765#include "json.h"
4766#include "h5wrap.h"
4767#include "utils.h"
4768#include "nucname.h"
4769#include "data.h"
4770#include "decay.h"
4771#endif
4772
4773namespace pyne
4774{
4775 // Set Type Definitions
4776 typedef std::map<int, double> comp_map; ///< Nuclide-mass composition map type
4777 typedef comp_map::iterator comp_iter; ///< Nuclide-mass composition iter type
4778
4779 #ifdef PYNE_IS_AMALGAMATED
4780 namespace decayers {
4781 extern comp_map decay(comp_map, double);
4782 } // namespace decayers
4783 #endif
4784
4785
4786 // These 37 strings are predefined FLUKA materials.
4787 // Materials not on this list requires a MATERIAL card.
4788 static std::string fluka_mat_strings[] = {
4789 "BLCKHOLE", "VACUUM", "HYDROGEN", "HELIUM", "BERYLLIU", "CARBON",
4790 "NITROGEN", "OXYGEN", "MAGNESIU", "ALUMINUM", "IRON", "COPPER",
4791 "SILVER", "SILICON", "GOLD", "MERCURY", "LEAD", "TANTALUM",
4792 "SODIUM", "ARGON", "CALCIUM", "TIN", "TUNGSTEN", "TITANIUM",
4793 "NICKEL", "WATER", "POLYSTYR", "PLASCINT", "PMMA", "BONECOMP",
4794 "BONECORT", "MUSCLESK", "MUSCLEST", "ADTISSUE", "KAPTON", "POLYETHY", "AIR"
4795 };
4796
4797 static int FLUKA_MAT_NUM = 37;
4798
4799 /// Material composed of nuclides.
4801 {
4802 protected:
4803
4804 /// Computes the total mass stored in the composition.
4805 double get_comp_sum ();
4806
4807 public:
4808
4809 // Material Constructors
4810 Material (); ///< empty constructor
4811 /// Constructor from composition map
4812 /// \param cm composition map
4813 /// \param m mass value, the mass is set to the sum of the values in the
4814 /// composition if \a m is negative.
4815 /// \param d density value
4816 /// \param apm atoms per mole
4817 /// \param attributes initial metadata
4818 Material(comp_map cm, double m=-1.0, double d=-1.0, double apm=-1.0,
4820 /// Constructor from file
4821 /// \param filename path to file on disk, this file may be either in plaintext
4822 /// or HDF5 format.
4823 /// \param m mass value, the mass is set to the sum of the values in the
4824 /// composition if \a m is negative,
4825 /// may be overridden by the value from disk.
4826 /// \param d density value,
4827 /// may be overridden by the value from disk.
4828 /// \param apm atoms per mole,
4829 /// may be overridden by the value from disk.
4830 /// \param attributes initial metadata,
4831 /// may be overridden by the value from disk.
4832 Material(char * filename, double m=-1.0, double d=-1.0, double apm=-1.0,
4834 /// Constructor from file
4835 /// \param filename path to file on disk, this file may be either in plaintext
4836 /// or HDF5 format.
4837 /// \param m mass value, the mass is set to the sum of the values in the
4838 /// composition if \a m is negative,
4839 /// may be overridden by the value from disk.
4840 /// \param d density value,
4841 /// may be overridden by the value from disk.
4842 /// \param apm atoms per mole,
4843 /// may be overridden by the value from disk.
4844 /// \param attributes initial metadata,
4845 /// may be overridden by the value from disk.
4846 Material(std::string filename, double m=-1.0, double d=-1.0, double apm=-1.0,
4848 ~Material (); ///< default destructor
4849
4850 /// Normalizes the mass values in the composition.
4851 void norm_comp ();
4852
4853 // Persistence functions.
4854
4855 /// Loads the matrial composition from an HDF5 file according to the layout
4856 /// defined by protocol 0. This protocol is depratacted.
4857 /// \param db HDF5 id for the open HDF5 file.
4858 /// \param datapath Path to the base node for the material in \a db.
4859 /// \param row The index to read out, may be negative.
4860 void _load_comp_protocol0(hid_t db, std::string datapath, int row);
4861
4862 /// Loads the matrial composition from an HDF5 file according to the layout
4863 /// defined by protocol 1. This protocol should be used in favor of protocol 0.
4864 /// \param db HDF5 id for the open HDF5 file.
4865 /// \param datapath Path to the base node for the material in \a db.
4866 /// \param row The index to read out, may be negative.
4867 void _load_comp_protocol1(hid_t db, std::string datapath, int row);
4868
4869 /// Loads a material from an HDF5 file into this object.
4870 /// \param filename Path on disk to the HDF5 file.
4871 /// \param datapath Path to the the material in the file.
4872 /// \param row The index to read out, may be negative.
4873 /// \param protocol Flag for layout of material on disk.
4874 void from_hdf5(char * filename, char * datapath, int row=-1, int protocol=1);
4875
4876 /// Loads a material from an HDF5 file into this object.
4877 /// \param filename Path on disk to the HDF5 file.
4878 /// \param datapath Path to the the material in the file.
4879 /// \param row The index to read out, may be negative.
4880 /// \param protocol Flag for layout of material on disk.
4881 void from_hdf5(std::string filename, std::string datapath="/material",
4882 int row=-1, int protocol=1);
4883
4884 /// Writes this material out to an HDF5 file.
4885 /// This happens according to protocol 1.
4886 /// \param filename Path on disk to the HDF5 file.
4887 /// \param datapath Path to the the material in the file.
4888 /// \param nucpath Path to the nuclides set in the file.
4889 /// \param row The index to read out, may be negative. Also note that this is a
4890 /// float. A value of -0.0 indicates that the material should be
4891 /// appended to the end of the dataset.
4892 /// \param chunksize The chunksize for all material data on disk.
4893 void write_hdf5(char * filename, char * datapath, char * nucpath, float row=-0.0,
4894 int chunksize=100);
4895 /// Writes this material out to an HDF5 file.
4896 /// This happens according to protocol 1.
4897 /// \param filename Path on disk to the HDF5 file.
4898 /// \param datapath Path to the the material in the file.
4899 /// \param nucpath Path to the nuclides set in the file.
4900 /// \param row The index to read out, may be negative. Also note that this is a
4901 /// float. A value of -0.0 indicates that the material should be
4902 /// appended to the end of the dataset.
4903 /// \param chunksize The chunksize for all material data on disk.
4904 void write_hdf5(std::string filename, std::string datapath="/material",
4905 std::string nucpath="/nucid", float row=-0.0, int chunksize=100);
4906
4907 /// Return an mcnp input deck record as a string
4908 std::string mcnp(std::string frac_type = "mass");
4909 ///
4910 /// Return a fluka input deck MATERIAL card as a string
4911 std::string fluka(int id, std::string frac_type = "mass");
4912 /// Convenience function to tell whether a given name needs a material card
4913 bool not_fluka_builtin(std::string fluka_name);
4914 /// High level call to get details and call material_component(..)
4915 std::string fluka_material_str(int id);
4916 /// Intermediate level call to prepare final info and call material_line(..)
4917 std::string fluka_material_component(int fid, int nucid,
4918 std::string fluka_name);
4919 /// Format information into a FLUKA material card
4920 std::string fluka_material_line(int znum, double atomic_mass,
4921 int fid, std::string fluka_name);
4922 /// Convenience function to format a single fluka field
4923 std::string fluka_format_field(float field);
4924 /// Return FLUKA compound card and the material card for the named compound
4925 /// but not the material cards of the components
4926 std::string fluka_compound_str(int id, std::string frac_type = "mass");
4927
4928 /// Reads data from a plaintext file at \a filename into this Material instance.
4929 void from_text(char * filename);
4930 /// Reads data from a plaintext file at \a filename into this Material instance.
4931 void from_text(std::string filename);
4932
4933 /// Writes the Material out to a simple plaintext file readable by from_text().
4934 void write_text(char * filename);
4935 /// Writes the Material out to a simple plaintext file readable by from_text().
4936 void write_text(std::string filename);
4937
4938 /// Loads a JSON instance tree into this Material.
4939 void load_json(Json::Value);
4940 /// Dumps the Material out to a JSON instance tree.
4942 /// Reads data from a JSON file at \a filename into this Material instance.
4943 void from_json(char * filename);
4944 /// Reads data from a JSON file at \a filename into this Material instance.
4945 void from_json(std::string filname);
4946 /// Writes the Material out to a JSON file
4947 void write_json(char * filename);
4948 /// Writes the Material out to a JSON file
4949 void write_json(std::string filename);
4950
4951 // Fundemental mass stream data
4952 /// composition, maps nuclides in id form to normalized mass weights.
4954 double mass; ///< mass (in arbitrary units) of the Material.
4955 double density; ///< density (in arbitrary units) of the Material.
4956 double atoms_per_molecule; ///< The number of atoms per molecule.
4957 /// container for arbitrary metadata, following the JSON rules.
4959
4960 // Material function definitions
4961 void normalize (); ///< Normalizes the mass.
4962 /// Returns a composition map that has been unnormalized by multiplying each
4963 /// mass weight by the actual mass of the material.
4965 /// Calculates the atomic weight of this material based on the composition
4966 /// and the number of atoms per mol. If \a apm is non-negative then it is
4967 /// used (and stored on the instance) as the atoms_per_molecule for this calculation.
4968 /// If \a apm and atoms_per_molecule on this instance are both negative, then the best
4969 /// guess value calculated from the normailized composition is used here.
4970 double molecular_mass(double apm=-1.0);
4971 /// Calculates the activity of a material based on the composition and each
4972 /// nuclide's mass, decay_const, and atmoic_mass.
4974 /// Calculates the decay heat of a material based on the composition and
4975 /// each nuclide's mass, q_val, decay_const, and atomic_mass. This assumes
4976 /// input mass of grams. Return values is in megawatts.
4978 /// Caclulates the dose per gram using the composition of the the
4979 /// material, the dose type desired, and the source for dose factors
4980 /// dose_type is one of:
4981 /// ext_air -- returns mrem/h per g per m^3
4982 /// ext_soil -- returns mrem/h per g per m^2
4983 /// ingest -- returns mrem per g
4984 /// inhale -- returns mrem per g
4985 /// source is:
4986 /// {EPA=0, DOE=1, GENII=2}, default is EPA
4987 comp_map dose_per_g(std::string dose_type, int source=0);
4988 /// Returns a copy of the current material where all natural elements in the
4989 /// composition are expanded to their natural isotopic abundances.
4991 // Returns a copy of the current material where all the isotopes of the elements
4992 // are added up, atomic-fraction-wise, unless they are in the exception set
4993 Material collapse_elements(std::set<int> exception_znum);
4994 // Wrapped version to facilitate calling from python
4995 Material collapse_elements(int **int_ptr_arry);
4996 // void print_material( pyne::Material test_mat);
4997 /// Computes, sets, and returns the mass density when \a num_dens is greater
4998 /// than or equal zero. If \a num_dens is negative, this simply returns the
4999 /// current value of the density member variable. You may also use / set the
5000 /// atoms per molecule (atoms_per_molecule) in this function using \a apm.
5001 double mass_density(double num_dens=-1.0, double apm=-1.0);
5002 /// Computes and returns the number density of the material using the
5003 /// mass density if \a mass_dens is greater than or equal to zero. If
5004 /// \a mass_dens is negative, the denisty member variable is used instead.
5005 /// You may also use / set the atoms per molecule (atoms_per_molecule) in this
5006 /// function using \a apm.
5007 double number_density(double mass_dens=-1.0, double apm=-1.0);
5008
5009 // Sub-Stream Computation
5010 /// Creates a sub-Material with only the nuclides present in \a nucset.
5011 /// Elements of this set may be either in id form or simple Z numbers.
5012 Material sub_mat(std::set<int> nucset);
5013 /// Creates a sub-Material with only the nuclides present in \a nucset.
5014 /// Elements of this set may be in any form.
5015 Material sub_mat(std::set<std::string> nucset);
5016
5017 /// Creates a new Material with the mass weights for all nuclides in \a nucset
5018 /// set to \a value.
5019 /// Elements of \a nucset may be either in id form or simple Z numbers.
5020 Material set_mat(std::set<int> nucset, double value);
5021 /// Creates a new Material with the mass weights for all nuclides in \a nucset
5022 /// set to \a value. Elements of \a nucset may be in any form.
5023 Material set_mat(std::set<std::string> nucset, double value);
5024
5025 /// Creates a new Material with the all nuclides in \a nucset removed.
5026 /// Elements of \a nucset may be either in id form or simple Z numbers.
5027 Material del_mat(std::set<int> nucset);
5028 /// Creates a new Material with the all nuclides in \a nucset removed.
5029 /// Elements of \a nucset may be in any form.
5030 Material del_mat(std::set<std::string> nucset);
5031
5032 /// Creates a sub-Material based on a range of id-form integers.
5033 Material sub_range(int lower=0, int upper=10000000);
5034 /// Creates a new Material with the mass weights for all nuclides in the id
5035 /// range set to \a value.
5036 Material set_range(int lower=0, int upper=10000000, double value=0.0);
5037 /// Creates a new Material with the all nuclides in the id range removed.
5038 Material del_range(int lower=0, int upper=10000000);
5039
5040 /// Creates a sub-Material of only the given element. Assumes element is
5041 /// id form.
5042 Material sub_elem(int element);
5043 /// Creates a sub-Material of only lanthanides.
5044 Material sub_lan();
5045 /// Creates a sub-Material of only actinides.
5046 Material sub_act();
5047 /// Creates a sub-Material of only transuranics.
5048 Material sub_tru();
5049 /// Creates a sub-Material of only minor actinides.
5050 Material sub_ma();
5051 /// Creates a sub-Material of only fission products.
5052 Material sub_fp();
5053
5054 // Atom fraction functions
5055 /// Returns a mapping of the nuclides in this material to their atom fractions.
5056 /// This calculation is based off of the material's molecular weight.
5057 std::map<int, double> to_atom_frac();
5058 /// Sets the composition, mass, and atoms_per_molecule of this material to those
5059 /// calculated from \a atom_fracs, a mapping of nuclides to atom fractions values.
5060 void from_atom_frac(std::map<int, double> atom_fracs);
5061
5062 /// Returns a mapping of the nuclides in this material to their atom densities.
5063 /// This calculation is based off of the material's density.
5064 std::map<int, double> to_atom_dens();
5065
5066 // Radioactive Material functions
5067 /// Returns a list of gamma-rays energies in keV and intensities in
5068 /// decays/s/atom material unnormalized
5069 std::vector<std::pair<double, double> > gammas();
5070 /// Returns a list of x-rays average energies in keV and intensities in
5071 /// decays/s material unnormalized
5072 std::vector<std::pair<double, double> > xrays();
5073 /// Returns a list of photon energies in keV and intensities in
5074 /// decays/s/atom material unnormalized
5075 std::vector<std::pair<double, double> > photons(bool norm);
5076 /// Takes a list of photon energies and intensities and normalizes them
5077 /// so the sum of the intensities is one
5078 std::vector<std::pair<double, double> > normalize_radioactivity(
5079 std::vector<std::pair<double, double> > unnormed);
5080
5081 /// Decays this material for a given amount of time in seconds
5082 Material decay(double t);
5083
5084 // Overloaded Operators
5085 /// Adds mass to a material instance.
5086 Material operator+ (double);
5087 /// Adds two materials together.
5089 /// Multiplies a material's mass.
5090 Material operator* (double);
5091 /// Divides a material's mass.
5092 Material operator/ (double);
5093 };
5094
5095 /// Converts a Material to a string stream representation for canonical writing.
5096 /// This operator is also defined on inheritors of std::ostream
5097 std::ostream& operator<< (std::ostream& os, Material mat);
5098
5099 /// A stuct for reprensenting fundemental data in a material.
5100 /// Useful for HDF5 representations.
5101 typedef struct material_data {
5102 double mass; ///< material mass
5103 double density; ///< material density
5104 double atoms_per_mol; ///< material atoms per mole
5105 double comp[1]; ///< array of material composition mass weights.
5107
5108 /// Custom exception for invalid HDF5 protocol numbers
5109 class MaterialProtocolError: public std::exception
5110 {
5111 /// marginally helpful error message.
5112 virtual const char* what() const throw()
5113 {
5114 return "Invalid loading protocol number; please use 0 or 1.";
5115 }
5116 };
5117
5118// End pyne namespace
5119}
5120
5121#endif // PYNE_MR34UE5INRGMZK2QYRDWICFHVM
5122//
5123// end of src/material.h
5124//
5125
5126
5127//
5128// start of src/enrichment_cascade.h
5129//
5130/// \brief A container representing enrichment cascades.
5131
5132#ifndef PYNE_3QGDWZMLZBHDHI424JL52SQHN4
5133#define PYNE_3QGDWZMLZBHDHI424JL52SQHN4
5134
5135#ifndef PYNE_IS_AMALGAMATED
5136#include "utils.h"
5137#include "nucname.h"
5138#include "data.h"
5139#include "material.h"
5140#endif
5141
5142/************************************************/
5143/*** Enrichment Component Class and Functions ***/
5144/************************************************/
5145
5146namespace pyne {
5147namespace enrichment {
5148
5149 /// A set of physical parameters used to specify an enrichment cascade.
5151 {
5152
5153 public:
5154
5155 /// default constructors
5156 Cascade();
5157
5158 /// default destructor
5159 ~Cascade();
5160
5161 // Attributes
5162 double alpha; ///< stage separation factor
5163 double Mstar; ///< mass separation factor
5164
5165 int j; ///< Component to enrich (U-235), id form
5166 int k; ///< Component to de-enrich, or strip (U-238), id form
5167
5168 double N; ///< number of enriching stages
5169 double M; ///< number of stripping stages
5170
5171 double x_feed_j; ///< enrichment of the #j-th isotope in the feed stream
5172 double x_prod_j; ///< enrichment of the #j-th isotope in the product stream
5173 double x_tail_j; ///< enrichment of the #j-th isotope in the tails stream
5174
5175 pyne::Material mat_feed; ///< feed material
5176 pyne::Material mat_prod; ///< product material
5177 pyne::Material mat_tail; ///< tails material
5178
5179 double l_t_per_feed; ///< Total flow rate per feed rate.
5180 double swu_per_feed; ///< This is the SWU for 1 kg of Feed material.
5181 double swu_per_prod; ///< This is the SWU for 1 kg of Product material.
5182
5183 // member functions
5184 void _reset_xjs(); ///< Sets #x_feed_j to #j-th value of #mat_feed.
5185 };
5186
5187// end enrichment
5188}
5189// end pyne
5190}
5191
5192#endif
5193
5194
5195//
5196// end of src/enrichment_cascade.h
5197//
5198
5199
5200//
5201// start of src/enrichment.h
5202//
5203/// \file enrichment.h
5204/// \author Anthony Scopatz (scopatz\@gmail.com)
5205///
5206/// \brief Top-level enrichment functionality.
5207
5208#ifndef PYNE_B3ANNCKDQ5HEJLI33RPZPDNX6A
5209#define PYNE_B3ANNCKDQ5HEJLI33RPZPDNX6A
5210
5211#ifndef PYNE_IS_AMALGAMATED
5212#include "enrichment_symbolic.h"
5213#endif
5214
5215/************************************************/
5216/*** Enrichment Component Class and Functions ***/
5217/************************************************/
5218
5219namespace pyne {
5220//! Enrichment Component Class and Functions
5221namespace enrichment {
5222
5223 /// Greates a cascade instance with default values for a uranium enrichment.
5225 /// a cascade instance with default values for a uranium enrichment.
5226 extern Cascade default_uranium_cascade;
5227
5228 /// Computes the feed per product mass ratio for feed, product, and tails
5229 /// enrichments \a x_feed, \a x_prod, and \a x_tails.
5230 double feed_per_prod(double x_feed, double x_prod, double x_tail);
5231 /// Computes the feed per tails mass ratio for feed, product, and tails
5232 /// enrichments \a x_feed, \a x_prod, and \a x_tails.
5233 double feed_per_tail(double x_feed, double x_prod, double x_tail);
5234 /// Computes the product per feed mass ratio for feed, product, and tails
5235 /// enrichments \a x_feed, \a x_prod, and \a x_tails.
5236 double prod_per_feed(double x_feed, double x_prod, double x_tail);
5237 /// Computes the product per tails mass ratio for feed, product, and tails
5238 /// enrichments \a x_feed, \a x_prod, and \a x_tails.
5239 double prod_per_tail(double x_feed, double x_prod, double x_tail);
5240 /// Computes the tails per feed mass ratio for feed, product, and tails
5241 /// enrichments \a x_feed, \a x_prod, and \a x_tails.
5242 double tail_per_feed(double x_feed, double x_prod, double x_tail);
5243 /// Computes the tails per product mass ratio for feed, product, and tails
5244 /// enrichments \a x_feed, \a x_prod, and \a x_tails.
5245 double tail_per_prod(double x_feed, double x_prod, double x_tail);
5246 /// Computes the value or separation potential of an assay \a x.
5247 double value_func(double x);
5248 /// Computes the swu per feed ratio for feed, product, and tails
5249 /// enrichments \a x_feed, \a x_prod, and \a x_tails.
5250 double swu_per_feed(double x_feed, double x_prod, double x_tail);
5251 /// Computes the swu per product ratio for feed, product, and tails
5252 /// enrichments \a x_feed, \a x_prod, and \a x_tails.
5253 double swu_per_prod(double x_feed, double x_prod, double x_tail);
5254 /// Computes the swu per tails ratio for feed, product, and tails
5255 /// enrichments \a x_feed, \a x_prod, and \a x_tails.
5256 double swu_per_tail(double x_feed, double x_prod, double x_tail);
5257
5258 /// Computes the nuclide-specific stage separation factor from the
5259 /// overall stage separation factor \a alpha, the key mass \a Mstar,
5260 /// and the nulide's atomic mass \a M_i.
5261 double alphastar_i(double alpha, double Mstar, double M_i);
5262
5263 /// \{ Numeric Solver Functions
5264 /// \{
5265 /// These functions enable the numeric cascade solver.
5266
5267 /// Finds the total flow rate (L) over the feed flow rate (F), the number of
5268 /// enriching stages (N), and the number of stripping stages (M).
5269 /// \param orig_casc Original input cascade.
5270 /// \param tolerance Maximum numerical error allowed in L/F, N, and M.
5271 /// \param max_iter Maximum number of iterations for to perform.
5272 /// \return A cascade whose N & M coorespond to the L/F value.
5273 Cascade solve_numeric(Cascade & orig_casc, double tolerance=1.0E-7,
5274 int max_iter=100);
5275 /// So,ves for valid stage numbers N &nd M of a casc.
5276 /// \param casc Cascade instance, modified in-place.
5277 /// \param tolerance Maximum numerical error allowed in N and M.
5278 void _recompute_nm(Cascade & casc, double tolerance=1.0E-7);
5279 /// This function takes a given initial guess number of enriching and stripping
5280 /// stages for a given composition of fuel with a given jth key component, knowing
5281 /// the values that are desired in both Product and Tails streams. Having this it
5282 /// solves for what the actual N and M stage numbers are and also what the product
5283 /// and waste streams compositions are.
5284 /// \param casc Cascade instance, modified in-place.
5285 void _recompute_prod_tail_mats(Cascade & casc);
5286 /// This function solves the whole system of equations. It uses
5287 /// _recompute_prod_tail_mats() to find the roots for the enriching and stripping
5288 /// stage numbers. It then checks to see if the product and waste streams meet
5289 /// their target enrichments for the jth component like they should. If they don't
5290 /// then it trys other values of N and M varied by the Secant method.
5291 /// \param casc Input cascade.
5292 /// \param tolerance Maximum numerical error allowed in L/F, N, and M.
5293 /// \param max_iter Maximum number of iterations for to perform.
5294 /// \return A cascade whose N & M coorespond to the L/F value.
5295 Cascade _norm_comp_secant(Cascade & casc, double tolerance=1.0E-7, int max_iter=100);
5296 /// Solves for a stage separative power relevant to the ith component
5297 /// per unit of flow G. This is taken from Equation 31 divided by G
5298 /// from the paper "Wood, Houston G., Borisevich, V. D. and Sulaberidze, G. A.,
5299 /// 'On a Criterion Efficiency for Multi-Isotope Mixtures Separation',
5300 /// Separation Science and Technology, 34:3, 343 - 357"
5301 /// To link to this article: DOI: 10.1081/SS-100100654
5302 /// URL: http://dx.doi.org/10.1081/SS-100100654
5303 /// \param casc Input cascade.
5304 /// \param i nuclide in id form.
5305 double _deltaU_i_OverG(Cascade & casc, int i);
5306 /// \}
5307
5308 /// \name Multicomponent Functions
5309 /// \{
5310 /// Finds a value of Mstar by minimzing the seperative power.
5311 /// Note that Mstar on \a orig_casc represents an intial guess at what Mstar might
5312 /// be. This is the final function that actually solves for an optimized M* that
5313 /// makes the cascade!
5314 /// \param orig_casc Original input cascade.
5315 /// \param solver flag for solver to use, may be 'symbolic' or 'numeric'.
5316 /// \param tolerance Maximum numerical error allowed in L/F, N, and M.
5317 /// \param max_iter Maximum number of iterations for to perform.
5318 /// \return A cascade whose N & M coorespond to the L/F value.
5319 Cascade multicomponent(Cascade & orig_casc, char * solver,
5320 double tolerance=1.0E-7, int max_iter=100);
5321 Cascade multicomponent(Cascade & orig_casc, std::string solver="symbolic",
5322 double tolerance=1.0E-7, int max_iter=100);
5323 /// \}
5324
5325 /// Custom exception for when an enrichment solver has entered an infinite loop.
5326 class EnrichmentInfiniteLoopError: public std::exception
5327 {
5328 /// Returns a moderately helpful error message.
5329 virtual const char* what() const throw()
5330 {
5331 return "Inifinite loop found while calculating enrichment cascade.";
5332 }
5333 };
5334
5335 /// Custom exception for when an enrichment solver has reached its maximum
5336 /// number of iterations.
5337 class EnrichmentIterationLimit: public std::exception
5338 {
5339 /// Returns a moderately helpful error message.
5340 virtual const char* what() const throw()
5341 {
5342 return "Iteration limit hit durring enrichment calculation.";
5343 }
5344 };
5345
5346 /// Custom exception for when an enrichment solver iteration has produced a NaN.
5347 class EnrichmentIterationNaN: public std::exception
5348 {
5349 /// Returns a moderately helpful error message.
5350 virtual const char* what() const throw()
5351 {
5352 return "Iteration has hit a point where some values are not-a-number.";
5353 }
5354 };
5355
5356// end enrichment
5357}
5358// end pyne
5359}
5360
5361#endif
5362//
5363// end of src/enrichment.h
5364//
5365
5366
5367//
5368// start of src/enrichment_symbolic.h
5369//
5370
5371/// \file enrichment_symbolic.h
5372/// \author Anthony Scopatz (scopatz\@gmail.com)
5373///
5374/// \brief A multicomponent enrichment cascade solver using
5375/// a symbolic solution to the mass flow rate equations.
5376
5377/*********************************************************/
5378/*** Symbolic Enrichment Functions ***/
5379/*** WARNING: This file is auto-generated. ***/
5380/*** DO NOT MODIFY!!! ***/
5381/*********************************************************/
5382
5383#ifndef PYNE_OU4PO4TJDBDM5PY4VKAVL7JCSM
5384#define PYNE_OU4PO4TJDBDM5PY4VKAVL7JCSM
5385
5386#include <math.h>
5387
5388#ifndef PYNE_IS_AMALGAMATED
5389#include "enrichment_cascade.h"
5390#endif
5391
5392namespace pyne {
5393namespace enrichment {
5394
5395 /// A multicomponent enrichment cascade solver using
5396 /// a symbolic solution to the mass flow rate equations.
5397 /// \param orig_casc The original state of the cascade.
5398 /// \return A cascade solved for new N, M, and total flow
5399 /// rates.
5400 Cascade solve_symbolic(Cascade & orig_casc);
5401
5402// end enrichment
5403}
5404// end pyne
5405}
5406
5407#endif
5408//
5409// end of src/enrichment_symbolic.h
5410//
5411
5412
5413//
5414// start of src/_decay.h
5415//
5416#ifdef PYNE_DECAY_IS_DUMMY
5417#ifndef PYNE_GEUP5PGEJBFGNHGI36TRBB4WGM
5418#define PYNE_GEUP5PGEJBFGNHGI36TRBB4WGM
5419
5420// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5421// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5422// WARNING
5423// This file has been auto generated
5424// Do not modify directly. You have
5425// been warned. This is that warning
5426// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5427// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5428
5429#include <map>
5430//#include <cmath>
5431
5432#ifndef PYNE_IS_AMALGAMATED
5433#include "data.h"
5434#include "nucname.h"
5435#endif
5436
5437namespace pyne {
5438namespace decayers {
5439
5440extern const int all_nucs[4];
5441
5442std::map<int, double> decay(std::map<int, double> comp, double t);
5443
5444} // namespace decayers
5445} // namespace pyne
5446
5447#endif // PYNE_GEUP5PGEJBFGNHGI36TRBB4WGM
5448#endif // PYNE_DECAY_IS_DUMMY//
5449// end of src/_decay.h
5450//
5451
5452
5453#endif // PYNE_52BMSKGZ3FHG3NQI566D4I2ZLY
Writes a Value in JSON format with custom formatting.
Definition pyne.h:4697
virtual ~CustomWriter()
Definition pyne.h:4707
Outputs a Value in JSON format without formatting (not human friendly).
Definition pyne.h:4488
virtual ~FastWriter()
Definition pyne.h:4491
Configuration passed to reader and writer.
Definition pyne.h:3063
bool strictRoot_
true if root must be either an array or an object value. Default: false.
Definition pyne.h:3087
bool allowComments_
true if comments are allowed. Default: true.
Definition pyne.h:3084
Experimental and untested: represents an element of the "path" to access a node.
Definition pyne.h:3611
Experimental and untested: represents a "path" to access a node.
Definition pyne.h:3644
Value & make(Value &root) const
Creates the "path" to access the specified node and returns a reference on the node.
Definition pyne.cc:16035
Path(const std::string &path, const PathArgument &a1=PathArgument(), const PathArgument &a2=PathArgument(), const PathArgument &a3=PathArgument(), const PathArgument &a4=PathArgument(), const PathArgument &a5=PathArgument())
Definition pyne.cc:15914
const Value & resolve(const Value &root) const
Definition pyne.cc:15989
Unserialize a JSON document into a Value.
Definition pyne.h:4247
char Char
Definition pyne.h:4249
const Char * Location
Definition pyne.h:4250
Lightweight wrapper to tag static string.
Definition pyne.h:3176
const char * c_str() const
Definition pyne.h:3188
StaticString(const char *czstring)
Definition pyne.h:3178
Writes a Value in JSON format in a human friendly way, to a stream rather than to a string.
Definition pyne.h:4581
Writes a Value in JSON format in a human friendly way.
Definition pyne.h:4524
virtual ~StyledWriter()
Definition pyne.h:4527
const iterator for object and array value.
Definition pyne.h:4090
ValueConstIterator SelfType
Definition pyne.h:4097
SelfType & operator--()
Definition pyne.h:4126
const Value * pointer
Definition pyne.h:4096
unsigned int size_t
Definition pyne.h:4093
SelfType operator--(int)
Definition pyne.h:4119
SelfType & operator++()
Definition pyne.h:4132
const Value & reference
Definition pyne.h:4095
SelfType operator++(int)
Definition pyne.h:4112
SelfType & operator=(const ValueIteratorBase &other)
Definition pyne.cc:14324
reference operator*() const
Definition pyne.h:4138
base class for Value iterators.
Definition pyne.h:4020
bool isEqual(const SelfType &other) const
Definition pyne.cc:14221
bool operator==(const SelfType &other) const
Definition pyne.h:4034
Value key() const
Return either the index or the member name of the referenced value as a Value.
Definition pyne.cc:14248
void copy(const SelfType &other)
Definition pyne.cc:14236
UInt index() const
Return the index of the referenced Value. -1 if it is not an arrayValue.
Definition pyne.cc:14270
const char * memberName() const
Return the member name of the referenced Value. "" if it is not an objectValue.
Definition pyne.cc:14285
difference_type operator-(const SelfType &other) const
Definition pyne.h:4044
ValueIteratorBase SelfType
Definition pyne.h:4024
unsigned int size_t
Definition pyne.h:4022
Value & deref() const
Definition pyne.cc:14151
bool operator!=(const SelfType &other) const
Definition pyne.h:4039
difference_type computeDistance(const SelfType &other) const
Definition pyne.cc:14187
Iterator for object and array value.
Definition pyne.h:4148
SelfType operator--(int)
Definition pyne.h:4180
ValueIterator SelfType
Definition pyne.h:4155
unsigned int size_t
Definition pyne.h:4151
SelfType & operator--()
Definition pyne.h:4187
reference operator*() const
Definition pyne.h:4199
SelfType & operator++()
Definition pyne.h:4193
SelfType & operator=(const SelfType &other)
Definition pyne.cc:14365
SelfType operator++(int)
Definition pyne.h:4173
Value * pointer
Definition pyne.h:4154
Value & reference
Definition pyne.h:4153
Represents a JSON value.
Definition pyne.h:3225
std::map< CZString, Value > ObjectValues
Definition pyne.h:3297
Json::UInt UInt
Definition pyne.h:3235
Json::ArrayIndex ArrayIndex
Definition pyne.h:3243
Json::Int64 Int64
Definition pyne.h:3239
Json::LargestInt LargestInt
Definition pyne.h:3241
ValueIterator iterator
Definition pyne.h:3233
static const Int64 maxInt64
Maximum signed 64 bits int value that can be stored in a Json::Value.
Definition pyne.h:3263
static const Value null
Definition pyne.h:3245
Json::LargestUInt LargestUInt
Definition pyne.h:3242
static const Int minInt
Minimum signed int value that can be stored in a Json::Value.
Definition pyne.h:3254
static const Int64 minInt64
Minimum signed 64 bits int value that can be stored in a Json::Value.
Definition pyne.h:3261
static const LargestInt maxLargestInt
Maximum signed integer value that can be stored in a Json::Value.
Definition pyne.h:3249
Json::UInt64 UInt64
Definition pyne.h:3238
static const LargestUInt maxLargestUInt
Maximum unsigned integer value that can be stored in a Json::Value.
Definition pyne.h:3251
static const Int maxInt
Maximum signed int value that can be stored in a Json::Value.
Definition pyne.h:3256
Json::Int Int
Definition pyne.h:3236
std::vector< std::string > Members
Definition pyne.h:3232
static const UInt maxUInt
Maximum unsigned int value that can be stored in a Json::Value.
Definition pyne.h:3258
static const UInt64 maxUInt64
Maximum unsigned 64 bits int value that can be stored in a Json::Value.
Definition pyne.h:3265
static const LargestInt minLargestInt
Minimum signed integer value that can be stored in a Json::Value.
Definition pyne.h:3247
ValueConstIterator const_iterator
Definition pyne.h:3234
Abstract class for writers.
Definition pyne.h:4474
virtual std::string write(const Value &root)=0
Custom exception for when an existing file is not in a valid HDF5 format.
Definition pyne.h:371
virtual const char * what() const
helpful error message that includes the filename
Definition pyne.h:387
FileNotHDF5()
default constructor
Definition pyne.h:375
~FileNotHDF5()
default destructor
Definition pyne.h:378
FileNotHDF5(std::string fname)
constructor with the filename
Definition pyne.h:381
Custom exception for when a group cannot be found in an HDF5 file.
Definition pyne.h:403
virtual const char * what() const
helpful error message that includes the filename and the groupname
Definition pyne.h:419
GroupNotFound(std::string fname, std::string gname)
constructor with the filename and the groupname
Definition pyne.h:413
~GroupNotFound()
default destructor
Definition pyne.h:410
GroupNotFound()
default constructor
Definition pyne.h:407
Custom exception for HDF5 indexing errors.
Definition pyne.h:360
A class representing a high-level table contruct whose columns all have the same type T in C/C++ (and...
Definition pyne.h:651
std::map< std::string, std::vector< T > > data
mapping from column names to column data
Definition pyne.h:709
HomogenousTypeTable(hid_t h5file, std::string data_path, hid_t dtype=H5T_NATIVE_DOUBLE)
Constructor to load in data upon initialization.
Definition pyne.h:665
HomogenousTypeTable()
default constructor
Definition pyne.h:655
std::string path
path in file to the data
Definition pyne.h:705
std::vector< std::string > cols
column names
Definition pyne.h:707
std::vector< T > operator[](std::string col_name)
index into the table by column name (string)
Definition pyne.h:715
~HomogenousTypeTable()
default destructor
Definition pyne.h:658
int shape[2]
table shape, rows x columns.
Definition pyne.h:706
Custom exception for when a path is not found in an HDF5 file.
Definition pyne.h:435
PathNotFound()
default constructor
Definition pyne.h:439
virtual const char * what() const
helpful error message that includes the filename and the pathname
Definition pyne.h:452
PathNotFound(std::string fname, std::string pname)
constructor with the filename and the pathname
Definition pyne.h:445
~PathNotFound()
default destructor
Definition pyne.h:442
Custom exception to be thrown in the event that a required file is not able to be found.
Definition pyne.h:219
FileNotFound(std::string fname)
constructor with the filename fname.
Definition pyne.h:229
FileNotFound()
default constructor
Definition pyne.h:223
~FileNotFound()
default destructor
Definition pyne.h:226
virtual const char * what() const
Creates a helpful error message.
Definition pyne.h:235
Custom exception for declaring a simple_xs request invalid.
Definition pyne.h:2501
virtual const char * what() const
Exception returns the string passed when thrown.
Definition pyne.h:2508
InvalidSimpleXS(std::string msg)
Exception thrown if energy group or rxname are invalid.
Definition pyne.h:2506
Custom exception for invalid HDF5 protocol numbers.
Definition pyne.h:5110
Material composed of nuclides.
Definition pyne.h:4801
Material expand_elements()
Returns a copy of the current material where all natural elements in the composition are expanded to ...
Definition pyne.cc:18205
std::vector< std::pair< double, double > > normalize_radioactivity(std::vector< std::pair< double, double > > unnormed)
Takes a list of photon energies and intensities and normalizes them so the sum of the intensities is ...
Definition pyne.cc:18624
Material set_mat(std::set< int > nucset, double value)
Creates a new Material with the mass weights for all nuclides in nucset set to value.
Definition pyne.cc:18351
void norm_comp()
Normalizes the mass values in the composition.
Definition pyne.cc:17071
std::vector< std::pair< double, double > > xrays()
Returns a list of x-rays average energies in keV and intensities in decays/s material unnormalized.
Definition pyne.cc:18595
double number_density(double mass_dens=-1.0, double apm=-1.0)
Computes and returns the number density of the material using the mass density if mass_dens is greate...
Definition pyne.cc:18312
std::string fluka_material_line(int znum, double atomic_mass, int fid, std::string fluka_name)
Format information into a FLUKA material card.
Definition pyne.cc:17700
void from_text(char *filename)
Reads data from a plaintext file at filename into this Material instance.
Definition pyne.cc:17848
comp_map comp
composition, maps nuclides in id form to normalized mass weights.
Definition pyne.h:4953
void from_atom_frac(std::map< int, double > atom_fracs)
Sets the composition, mass, and atoms_per_molecule of this material to those calculated from atom_fra...
Definition pyne.cc:18545
std::vector< std::pair< double, double > > gammas()
Returns a list of gamma-rays energies in keV and intensities in decays/s/atom material unnormalized.
Definition pyne.cc:18576
Material del_range(int lower=0, int upper=10000000)
Creates a new Material with the all nuclides in the id range removed.
Definition pyne.cc:18461
Material del_mat(std::set< int > nucset)
Creates a new Material with the all nuclides in nucset removed.
Definition pyne.cc:18387
std::vector< std::pair< double, double > > photons(bool norm)
Returns a list of photon energies in keV and intensities in decays/s/atom material unnormalized.
Definition pyne.cc:18614
std::string fluka_material_component(int fid, int nucid, std::string fluka_name)
Intermediate level call to prepare final info and call material_line(..)
Definition pyne.cc:17681
std::string fluka_compound_str(int id, std::string frac_type="mass")
Return FLUKA compound card and the material card for the named compound but not the material cards of...
Definition pyne.cc:17758
void load_json(Json::Value)
Loads a JSON instance tree into this Material.
Definition pyne.cc:17943
Material sub_mat(std::set< int > nucset)
Creates a sub-Material with only the nuclides present in nucset.
Definition pyne.cc:18323
Material sub_fp()
Creates a sub-Material of only fission products.
Definition pyne.cc:18521
void _load_comp_protocol0(hid_t db, std::string datapath, int row)
Loads the matrial composition from an HDF5 file according to the layout defined by protocol 0.
Definition pyne.cc:17087
double molecular_mass(double apm=-1.0)
Calculates the atomic weight of this material based on the composition and the number of atoms per mo...
Definition pyne.cc:18182
Material operator*(double)
Multiplies a material's mass.
Definition pyne.cc:18681
std::string fluka(int id, std::string frac_type="mass")
Return a fluka input deck MATERIAL card as a string.
Definition pyne.cc:17623
double get_comp_sum()
Computes the total mass stored in the composition.
Definition pyne.cc:17060
void write_text(char *filename)
Writes the Material out to a simple plaintext file readable by from_text().
Definition pyne.cc:17905
double mass
mass (in arbitrary units) of the Material.
Definition pyne.h:4954
void from_json(char *filename)
Reads data from a JSON file at filename into this Material instance.
Definition pyne.cc:17972
double atoms_per_molecule
The number of atoms per molecule.
Definition pyne.h:4956
Material collapse_elements(std::set< int > exception_znum)
Definition pyne.cc:18247
std::map< int, double > to_atom_frac()
Returns a mapping of the nuclides in this material to their atom fractions.
Definition pyne.cc:18531
comp_map dose_per_g(std::string dose_type, int source=0)
Caclulates the dose per gram using the composition of the the material, the dose type desired,...
Definition pyne.cc:18148
void _load_comp_protocol1(hid_t db, std::string datapath, int row)
Loads the matrial composition from an HDF5 file according to the layout defined by protocol 1.
Definition pyne.cc:17125
void from_hdf5(char *filename, char *datapath, int row=-1, int protocol=1)
Loads a material from an HDF5 file into this object.
Definition pyne.cc:17230
double density
density (in arbitrary units) of the Material.
Definition pyne.h:4955
bool not_fluka_builtin(std::string fluka_name)
Convenience function to tell whether a given name needs a material card.
Definition pyne.cc:17615
Material operator+(double)
Adds mass to a material instance.
Definition pyne.cc:18651
Material sub_ma()
Creates a sub-Material of only minor actinides.
Definition pyne.cc:18514
Material sub_elem(int element)
Creates a sub-Material of only the given element.
Definition pyne.cc:18487
comp_map activity()
Calculates the activity of a material based on the composition and each nuclide's mass,...
Definition pyne.cc:18125
Material sub_tru()
Creates a sub-Material of only transuranics.
Definition pyne.cc:18507
void write_json(char *filename)
Writes the Material out to a JSON file.
Definition pyne.cc:17994
std::string fluka_format_field(float field)
Convenience function to format a single fluka field.
Definition pyne.cc:17734
std::string mcnp(std::string frac_type="mass")
Return an mcnp input deck record as a string.
Definition pyne.cc:17514
double mass_density(double num_dens=-1.0, double apm=-1.0)
Computes, sets, and returns the mass density when num_dens is greater than or equal zero.
Definition pyne.cc:18303
Material operator/(double)
Divides a material's mass.
Definition pyne.cc:18688
void normalize()
Normalizes the mass.
Definition pyne.cc:18105
comp_map mult_by_mass()
Returns a composition map that has been unnormalized by multiplying each mass weight by the actual ma...
Definition pyne.cc:18111
Material sub_lan()
Creates a sub-Material of only lanthanides.
Definition pyne.cc:18494
Material sub_act()
Creates a sub-Material of only actinides.
Definition pyne.cc:18501
void write_hdf5(char *filename, char *datapath, char *nucpath, float row=-0.0, int chunksize=100)
Writes this material out to an HDF5 file.
Definition pyne.cc:17285
std::map< int, double > to_atom_dens()
Returns a mapping of the nuclides in this material to their atom densities.
Definition pyne.cc:18563
~Material()
default destructor
Definition pyne.cc:18081
Material sub_range(int lower=0, int upper=10000000)
Creates a sub-Material based on a range of id-form integers.
Definition pyne.cc:18420
Json::Value metadata
container for arbitrary metadata, following the JSON rules.
Definition pyne.h:4958
std::string fluka_material_str(int id)
High level call to get details and call material_component(..)
Definition pyne.cc:17648
Json::Value dump_json()
Dumps the Material out to a JSON instance tree.
Definition pyne.cc:17958
Material set_range(int lower=0, int upper=10000000, double value=0.0)
Creates a new Material with the mass weights for all nuclides in the id range set to value.
Definition pyne.cc:18440
Material()
empty constructor
Definition pyne.cc:18016
comp_map decay_heat()
Calculates the decay heat of a material based on the composition and each nuclide's mass,...
Definition pyne.cc:18136
A set of physical parameters used to specify an enrichment cascade.
Definition pyne.h:5151
double swu_per_feed
This is the SWU for 1 kg of Feed material.
Definition pyne.h:5180
double l_t_per_feed
Total flow rate per feed rate.
Definition pyne.h:5179
~Cascade()
default destructor
Definition pyne.cc:18734
pyne::Material mat_tail
tails material
Definition pyne.h:5177
int j
Component to enrich (U-235), id form.
Definition pyne.h:5165
double x_feed_j
enrichment of the j-th isotope in the feed stream
Definition pyne.h:5171
double x_tail_j
enrichment of the j-th isotope in the tails stream
Definition pyne.h:5173
double alpha
stage separation factor
Definition pyne.h:5162
void _reset_xjs()
Sets x_feed_j to j-th value of mat_feed.
Definition pyne.cc:18738
double N
number of enriching stages
Definition pyne.h:5168
Cascade()
default constructors
Definition pyne.cc:18710
double M
number of stripping stages
Definition pyne.h:5169
double Mstar
mass separation factor
Definition pyne.h:5163
double swu_per_prod
This is the SWU for 1 kg of Product material.
Definition pyne.h:5181
int k
Component to de-enrich, or strip (U-238), id form.
Definition pyne.h:5166
pyne::Material mat_feed
feed material
Definition pyne.h:5175
pyne::Material mat_prod
product material
Definition pyne.h:5176
double x_prod_j
enrichment of the j-th isotope in the product stream
Definition pyne.h:5172
Custom exception for when an enrichment solver has entered an infinite loop.
Definition pyne.h:5327
Custom exception for when an enrichment solver has reached its maximum number of iterations.
Definition pyne.h:5338
Custom exception for when an enrichment solver iteration has produced a NaN.
Definition pyne.h:5348
Custom expection for declaring that a value represents one or more nuclides in one or more namig conv...
Definition pyne.h:938
IndeterminateNuclideForm(int wasptr, std::string nowptr)
Constructor given previous and current state of nulide name.
Definition pyne.h:967
IndeterminateNuclideForm(int wasptr, int nowptr)
Constructor given previous and current state of nulide name.
Definition pyne.h:976
IndeterminateNuclideForm(std::string wasptr, std::string nowptr)
Constructor given previous and current state of nulide name.
Definition pyne.h:949
IndeterminateNuclideForm(std::string wasptr, int nowptr)
Constructor given previous and current state of nulide name.
Definition pyne.h:958
virtual const char * what() const
Generates an informational message for the exception.
Definition pyne.h:984
IndeterminateNuclideForm()
default constructor
Definition pyne.h:941
~IndeterminateNuclideForm()
default destuctor
Definition pyne.h:944
Custom expection for declaring that a value does not follow a recognizable nuclide naming convention.
Definition pyne.h:870
NotANuclide(std::string wasptr, int nowptr)
Constructor given previous and current state of nulide name.
Definition pyne.h:890
~NotANuclide()
default destructor
Definition pyne.h:876
NotANuclide(std::string wasptr, std::string nowptr)
Constructor given previous and current state of nulide name.
Definition pyne.h:881
NotANuclide()
default constructor
Definition pyne.h:873
NotANuclide(int wasptr, int nowptr)
Constructor given previous and current state of nulide name.
Definition pyne.h:908
virtual const char * what() const
Generates an informational message for the exception.
Definition pyne.h:916
NotANuclide(int wasptr, std::string nowptr)
Constructor given previous and current state of nulide name.
Definition pyne.h:899
Custom exception for declaring a value not to be of ambiquous reaction form.
Definition pyne.h:1693
virtual const char * what() const
Returns a helpful error message containing prior and current reaction state.
Definition pyne.h:1735
IndeterminateReactionForm()
default constructor
Definition pyne.h:1697
~IndeterminateReactionForm()
default destructor
Definition pyne.h:1700
IndeterminateReactionForm(int wasptr, int nowptr)
Constructor using original reaction (wasptr) and the eventual state that PyNE calculated (nowptr).
Definition pyne.h:1728
IndeterminateReactionForm(std::string wasptr, int nowptr)
Constructor using original reaction (wasptr) and the eventual state that PyNE calculated (nowptr).
Definition pyne.h:1712
IndeterminateReactionForm(std::string wasptr, std::string nowptr)
Constructor using original reaction (wasptr) and the eventual state that PyNE calculated (nowptr).
Definition pyne.h:1704
IndeterminateReactionForm(int wasptr, std::string nowptr)
Constructor using original reaction (wasptr) and the eventual state that PyNE calculated (nowptr).
Definition pyne.h:1720
Custom exception for declaring a value not to be a valid reaction.
Definition pyne.h:1604
~NotAReaction()
default destructor
Definition pyne.h:1611
NotAReaction(std::string wasptr, int nowptr)
Constructor using original reaction (wasptr) and the eventual state that PyNE calculated (nowptr).
Definition pyne.h:1623
NotAReaction(std::string wasptr, std::string nowptr)
Constructor using original reaction (wasptr) and the eventual state that PyNE calculated (nowptr).
Definition pyne.h:1615
NotAReaction(unsigned int wasptr, unsigned int nowptr)
Constructor using original reaction (wasptr) and the eventual state that PyNE calculated (nowptr).
Definition pyne.h:1663
NotAReaction(int wasptr, std::string nowptr)
Constructor using original reaction (wasptr) and the eventual state that PyNE calculated (nowptr).
Definition pyne.h:1631
NotAReaction(int wasptr, int nowptr)
Constructor using original reaction (wasptr) and the eventual state that PyNE calculated (nowptr).
Definition pyne.h:1639
NotAReaction(std::string wasptr, unsigned int nowptr)
Constructor using original reaction (wasptr) and the eventual state that PyNE calculated (nowptr).
Definition pyne.h:1647
NotAReaction(unsigned int wasptr, std::string nowptr)
Constructor using original reaction (wasptr) and the eventual state that PyNE calculated (nowptr).
Definition pyne.h:1655
NotAReaction()
default constructor
Definition pyne.h:1608
virtual const char * what() const
Returns a helpful error message containing prior and current reaction state.
Definition pyne.h:1670
Data access functions.
Definition pyne.h:2117
bool operator()(const std::pair< int, double > &lhs, const std::pair< int, double > &rhs) const
This operator compares the second item in a pair first.
Definition pyne.cc:11418
JSON (JavaScript Object Notation).
Definition pyne.cc:13083
unsigned long long int UInt64
Definition pyne.h:2702
int Int
Definition pyne.h:2689
Int64 LargestInt
Definition pyne.h:2704
std::istream & operator>>(std::istream &sin, Value &root)
Read from 'sin' into 'root'.
Definition pyne.cc:13945
CommentPlacement
Definition pyne.h:3149
@ commentAfterOnSameLine
a comment just after a value on the same line
Definition pyne.h:3151
@ commentBefore
a comment placed on the line before a value
Definition pyne.h:3150
@ numberOfCommentPlacement
Definition pyne.h:3153
@ commentAfter
a comment on the line after a value (only make sense for root value)
Definition pyne.h:3152
static bool in(Reader::Char c, Reader::Char c1, Reader::Char c2, Reader::Char c3, Reader::Char c4)
Definition pyne.cc:13216
ValueType
Type of the value held by a Value object.
Definition pyne.h:3137
@ booleanValue
bool value
Definition pyne.h:3143
@ nullValue
'null' value
Definition pyne.h:3138
@ stringValue
UTF-8 string value.
Definition pyne.h:3142
@ realValue
double value
Definition pyne.h:3141
@ arrayValue
array value (ordered list)
Definition pyne.h:3144
@ intValue
signed integer value
Definition pyne.h:3139
@ objectValue
object value (collection of name/value pairs).
Definition pyne.h:3145
@ uintValue
unsigned integer value
Definition pyne.h:3140
unsigned int UInt
Definition pyne.h:2690
unsigned int ArrayIndex
Definition pyne.h:2751
std::ostream & operator<<(std::ostream &sout, const Value &root)
Output using the StyledStreamWriter.
Definition pyne.cc:16810
std::string valueToString(LargestInt value)
Definition pyne.cc:16102
std::string valueToQuotedString(const char *value)
Definition pyne.cc:16182
long long int Int64
Definition pyne.h:2701
UInt64 LargestUInt
Definition pyne.h:2705
Wrapper for standard HDF5 operations.
Definition pyne.h:357
std::vector< std::vector< T > > h5_array_to_cpp_vector_2d(hid_t h5file, std::string data_path, hid_t dtype=H5T_NATIVE_DOUBLE)
Reads in data from an HDF5 file as a 2 dimiensional vector.
Definition pyne.h:578
hid_t _get_PYTABLES_COMPLEX128()
Create an HDF5 data type for complex 128 bit data, which happens to match the complex data type that ...
Definition pyne.h:735
std::vector< std::vector< std::vector< T > > > h5_array_to_cpp_vector_3d(hid_t h5file, std::string data_path, hid_t dtype=H5T_NATIVE_DOUBLE)
Reads in data from an HDF5 file as a 3 dimiensional vector.
Definition pyne.h:613
static hid_t PYTABLES_COMPLEX128
The HDF5 id for a complex data type compatible with PyTables generated data.
Definition pyne.h:744
T get_array_index(hid_t dset, int n, hid_t dtype=H5T_NATIVE_DOUBLE)
Retrieves the nth index out of the dataset dset (which has an HDF5 datatype dtype).
Definition pyne.h:473
std::vector< T > h5_array_to_cpp_vector_1d(hid_t h5file, std::string data_path, hid_t dtype=H5T_NATIVE_DOUBLE)
Reads in data from an HDF5 file as a 1 dimiensional vector.
Definition pyne.h:548
std::set< T > h5_array_to_cpp_set(hid_t h5file, std::string data_path, hid_t dtype=H5T_NATIVE_DOUBLE)
Reads in data from an HDF5 file as a C++ set.
Definition pyne.h:517
bool path_exists(hid_t h5file, std::string path)
Determines if a path exists in an hdf5 file.
Definition pyne.h:751
const int all_nucs[4141]
Definition decay.cpp:154781
void _recompute_nm(Cascade &casc, double tolerance=1.0E-7)
So,ves for valid stage numbers N &nd M of a casc.
Definition pyne.cc:18845
Cascade multicomponent(Cascade &orig_casc, char *solver, double tolerance=1.0E-7, int max_iter=100)
Definition pyne.cc:19113
double prod_per_tail(double x_feed, double x_prod, double x_tail)
Computes the product per tails mass ratio for feed, product, and tails enrichments x_feed,...
Definition pyne.cc:18797
Cascade _norm_comp_secant(Cascade &casc, double tolerance=1.0E-7, int max_iter=100)
This function solves the whole system of equations.
Definition pyne.cc:18939
double tail_per_prod(double x_feed, double x_prod, double x_tail)
Computes the tails per product mass ratio for feed, product, and tails enrichments x_feed,...
Definition pyne.cc:18809
double feed_per_prod(double x_feed, double x_prod, double x_tail)
Computes the feed per product mass ratio for feed, product, and tails enrichments x_feed,...
Definition pyne.cc:18789
double swu_per_prod(double x_feed, double x_prod, double x_tail)
Computes the swu per product ratio for feed, product, and tails enrichments x_feed,...
Definition pyne.cc:18824
double swu_per_tail(double x_feed, double x_prod, double x_tail)
Computes the swu per tails ratio for feed, product, and tails enrichments x_feed, x_prod,...
Definition pyne.cc:18831
Cascade solve_numeric(Cascade &orig_casc, double tolerance=1.0E-7, int max_iter=100)
Finds the total flow rate (L) over the feed flow rate (F), the number of enriching stages (N),...
Definition pyne.cc:19066
Cascade default_uranium_cascade
a cascade instance with default values for a uranium enrichment.
double swu_per_feed(double x_feed, double x_prod, double x_tail)
Computes the swu per feed ratio for feed, product, and tails enrichments x_feed, x_prod,...
Definition pyne.cc:18817
double value_func(double x)
Computes the value or separation potential of an assay x.
Definition pyne.cc:18813
double tail_per_feed(double x_feed, double x_prod, double x_tail)
Computes the tails per feed mass ratio for feed, product, and tails enrichments x_feed,...
Definition pyne.cc:18805
double _deltaU_i_OverG(Cascade &casc, int i)
Solves for a stage separative power relevant to the ith component per unit of flow G.
Definition pyne.cc:19051
double feed_per_tail(double x_feed, double x_prod, double x_tail)
Computes the feed per tails mass ratio for feed, product, and tails enrichments x_feed,...
Definition pyne.cc:18793
double alphastar_i(double alpha, double Mstar, double M_i)
Computes the nuclide-specific stage separation factor from the overall stage separation factor alpha,...
Definition pyne.cc:18839
void _recompute_prod_tail_mats(Cascade &casc)
This function takes a given initial guess number of enriching and stripping stages for a given compos...
Definition pyne.cc:18899
double prod_per_feed(double x_feed, double x_prod, double x_tail)
Computes the product per feed mass ratio for feed, product, and tails enrichments x_feed,...
Definition pyne.cc:18801
Cascade solve_symbolic(Cascade &orig_casc)
A multicomponent enrichment cascade solver using a symbolic solution to the mass flow rate equations.
Definition pyne.cc:19268
Cascade _fill_default_uranium_cascade()
Greates a cascade instance with default values for a uranium enrichment.
Definition pyne.cc:18760
name_t LAN_array[15]
array of lanthanide names
Definition pyne.cc:2622
int mcnp_to_id(int nuc)
Definition pyne.cc:3229
zz_group name_to_zz_group(name_group eg)
Converts a name group to a Z number group.
Definition pyne.cc:2613
zzname_t get_zz_fluka()
Creates standard nucid to fluka-name mapping.
Definition pyne.cc:2596
int id(int nuc)
Definition pyne.cc:2716
int alara_to_id(const char *nuc)
Definition pyne.cc:3596
std::map< int, int > state_id_map
Definition pyne.cc:438
name_zz_t get_fluka_zz()
Creates standard fluka-name to nucid mapping.
Definition pyne.cc:2444
name_t MA_array[10]
array of minor actinide names
Definition pyne.cc:2645
int znum(int nuc)
Definition pyne.cc:2983
int sza_to_id(int nuc)
Definition pyne.cc:3655
std::set< zz_t > zz_group
Z number grouping type (for testing containment)
Definition pyne.h:834
int zzzaaa(int nuc)
Definition pyne.cc:3066
name_group LAN
lanthanide name group
name_group MA
minor actinide name group
zz_group act
actinide Z number group
Definition pyne.cc:2633
int nist_to_id(const char *nuc)
Definition pyne.cc:3455
name_group ACT
actinide name group
int sza(int nuc)
Definition pyne.cc:3636
zzname_t::iterator zzname_iter
Z num to name iter type.
Definition pyne.h:817
name_t FP_array[88]
array of fission product names
Definition pyne.cc:2653
zz_group lan
lanthanide Z number group
Definition pyne.cc:2626
std::map< name_t, zz_t > name_zz_t
name and Z num map type
Definition pyne.h:811
name_t ACT_array[15]
array of actinide names
Definition pyne.cc:2630
int cinder_to_id(int nuc)
Definition pyne.cc:3520
std::string alara(int nuc)
Definition pyne.cc:3544
int anum(int nuc)
Definition pyne.cc:2998
zzname_t zz_fluka
nucid to fluka-name map
Definition pyne.cc:2605
int zzzaaa_to_id(int nuc)
Definition pyne.cc:3085
zzname_t zz_name
Z num to name map.
Definition pyne.cc:2439
std::string name(int nuc)
Definition pyne.cc:2940
int cinder(int nuc)
Definition pyne.cc:3492
name_zz_t fluka_zz
fluka-name to nucid map
Definition pyne.cc:2592
int groundstate(int nuc)
Definition pyne.h:1364
name_group::iterator name_group_iter
name grouping iter type
Definition pyne.h:831
std::set< name_t > name_group
name grouping type (for testing containment)
Definition pyne.h:830
name_zz_t name_zz
name to Z num map
Definition pyne.cc:2426
name_zz_t get_name_zz()
Creates standard name to Z number mapping.
Definition pyne.cc:2306
int zzaaam_to_id(int nuc)
Definition pyne.cc:3049
int state_id_to_id(int state)
Definition pyne.cc:3683
bool isnuclide(std::string nuc)
Definition pyne.cc:2671
int fluka_to_id(std::string name)
Definition pyne.cc:3281
int mcnp(int nuc)
Definition pyne.cc:3197
bool iselement(std::string nuc)
Definition pyne.cc:2904
int serpent_to_id(const char *nuc)
Definition pyne.cc:3352
void _load_state_map()
Definition pyne.cc:3677
zz_group::iterator zz_group_iter
Z number grouping iter.
Definition pyne.h:835
int id_to_state_id(int nuc_id)
Definition pyne.cc:3704
std::string zzllaaam(int nuc)
Definition pyne.cc:3102
name_t TRU_array[22]
array of transuranic names
Definition pyne.cc:2636
std::string nist(int nuc)
Definition pyne.cc:3402
int zzaaam(int nuc)
Definition pyne.cc:3028
name_group FP
fission product name group
std::string fluka(int nuc)
Definition pyne.cc:3269
zz_group ma
minor actinide Z number group
Definition pyne.cc:2649
int snum(int nuc)
Definition pyne.cc:3013
int zzllaaam_to_id(const char *nuc)
Definition pyne.cc:3142
std::map< zz_t, name_t > zzname_t
Z num to name map type.
Definition pyne.h:816
std::string serpent(int nuc)
Definition pyne.cc:3296
int ensdf_to_id(const char *nuc)
Definition pyne.cc:3734
name_group TRU
transuranic name group
name_zz_t::iterator name_zz_iter
name and Z num iter type
Definition pyne.h:812
std::string name_t
name type
Definition pyne.h:808
zzname_t get_zz_name()
Creates standard Z number to name mapping.
Definition pyne.cc:2430
zz_group tru
transuranic Z number group
Definition pyne.cc:2641
zz_group fp
fission product Z number group
Definition pyne.cc:2663
int zz_t
Z number type.
Definition pyne.h:809
std::map< unsigned int, std::string > labels
Mapping from reaction ids to labels (short descriptions).
Definition pyne.cc:4349
std::map< unsigned int, std::string > docs
Mapping from reaction ids to documentation strings (long descriptions).
Definition pyne.cc:4350
std::set< std::string > names
Set of reaction names, must be valid variable names.
std::map< unsigned int, std::string > id_name
Mapping from reaction ids to reaction names.
Definition pyne.cc:4345
int child(int nuc, unsigned int rx, std::string z="n")
Definition pyne.cc:6594
int offset(int dz, int da, int ds=0)
A helper function to compute nuclide id offsets from z-, a-, and s- deltas.
Definition pyne.h:1455
std::string name(int n)
Definition pyne.cc:6367
void * _fill_maps()
A helper function to set the contents of the variables in this library.
Definition pyne.cc:4354
std::map< std::string, unsigned int > name_id
Mapping from reaction names to reaction ids.
Definition pyne.cc:4346
std::map< std::pair< std::string, int >, unsigned int > offset_id
Mapping from particle type and offset pairs to reaction ids.
Definition pyne.cc:4351
std::map< std::string, unsigned int > altnames
Mapping between alternative names for reactions and the reaction id.
Definition pyne.cc:4344
std::string doc(int x)
Definition pyne.cc:6557
std::string _names[NUM_RX_NAMES]
Raw array of reaction names.
Definition pyne.cc:3766
unsigned int hash(std::string s)
Definition pyne.cc:6323
std::map< unsigned int, unsigned int > id_mt
Mapping from reaction ids to MT numbers.
Definition pyne.cc:4347
int parent(int nuc, unsigned int rx, std::string z="n")
Definition pyne.cc:6621
unsigned int id(int x)
Definition pyne.cc:6409
void * _
A dummy variable used when calling _fill_maps().
Definition pyne.cc:6320
std::map< unsigned int, unsigned int > mt_id
Mapping from MT numbers to reaction names.
Definition pyne.cc:4348
unsigned int mt(int x)
Definition pyne.cc:6461
std::string label(int x)
Definition pyne.cc:6521
std::map< std::pair< std::string, unsigned int >, int > id_offset
Mapping from particle type and reaction ids to offsets.
Definition pyne.cc:4352
The 'pyne' namespace all PyNE functionality is included in.
Definition decay.cpp:23
std::vector< double > ecbp_endpoint_energy(int parent)
returns a list of electron capture/ beta plus decay endpoint energies from input parent nuclide
Definition pyne.cc:12625
double ext_air_dose(int nuc, int source)
Returns the dose factors of a nuclide.
Definition pyne.cc:10803
std::vector< int > ecbp_parent(double energy, double error)
Definition pyne.cc:12645
double coth(double x)
The hyperbolic cotangent function.
Definition pyne.cc:368
std::vector< std::pair< double, double > > gamma_xrays(int parent)
Definition pyne.cc:12363
std::map< std::pair< int, int >, ndsfpysub > ndsfpy_data
Definition pyne.cc:11268
std::string to_str(int t)
Definition pyne.cc:114
std::vector< int > beta_child(double energy, double error)
Definition pyne.cc:12553
std::vector< std::pair< double, double > > gamma_energy(int parent)
Definition pyne.cc:12232
const double cm2_per_barn
cm^2 per barn
Definition pyne.cc:10359
void _load_data< decay >()
Loads the decay data from the nuc_data.h5 file into memory.
std::vector< std::pair< double, double > > xrays(int parent)
Definition pyne.cc:12764
std::map< std::string, std::string > data_checksums
Mapping from nodes in nuc_data.h5 to hashes of nodes.
Definition pyne.cc:10384
double ext_soil_dose(int nuc, int source)
Function for External Soil Dose Factors.
Definition pyne.cc:10852
std::map< int, double > atomic_mass_error_map
Mapping from nuclides in id form to the associated error in abdundance.
std::vector< std::pair< double, double > > decay_half_lifes(int)
Definition pyne.cc:12092
int id_from_level(int nuc, double level)
Returns the nuc_id of an energy level.
Definition pyne.cc:11806
struct pyne::decay decay
a struct matching the '/decay/decays' table in nuc_data.h5.
std::map< int, xd_complex_t > b_incoherent_map
Mapping from nuclides in id form to their incoherent scattering length.
Definition pyne.cc:10978
double b(int nuc)
Computes the scattering length [cm] from the coherent and incoherent components.
Definition pyne.cc:11180
std::vector< double > decay_branch_ratios(int parent)
Definition pyne.cc:12110
double endftod_f(char *s)
Converts a string from ENDF format to a float.
Definition pyne.cc:202
void _load_atomic_mass_map_memory()
main function to be called when you whish to load the nuclide data into memory
Definition pyne.cc:6658
std::string replace_all_substrings(std::string s, std::string substr, std::string repstr)
Replaces all instance of substr in s with repstr.
Definition pyne.cc:281
std::vector< double > beta_endpoint_energy(int parent)
Definition pyne.cc:12533
void _load_data< atomic >()
std::map< std::pair< int, int >, double > wimsdfpy_data
Mapping from nuclides in id form to their scattering length.
Definition pyne.cc:11217
std::vector< std::pair< double, double > > ecbp_xrays(int parent)
Definition pyne.cc:12660
std::map< int, xd_complex_t > b_coherent_map
Mapping from nuclides in id form to their coherent scattering length.
Definition pyne.cc:10977
std::pair< double, double > decay_beta_branch_ratio(std::pair< int, int >)
Definition pyne.cc:12136
int metastable_id(int nuc, int m)
Returns the nuc_id of a metastable state.
Definition pyne.cc:11813
xd_complex_t b_incoherent(int nuc)
Finds the incoherent scattering length [cm] for a nuclide nuc.
Definition pyne.cc:11111
void use_fast_endftod()
Definition pyne.cc:212
void _load_wimsdfpy()
Loads the WIMSD fission product yield data from the nuc_data.h5 file into memory.
Definition pyne.cc:11220
std::vector< int > alpha_parent(double energy, double error)
Definition pyne.cc:12464
std::pair< double, double > decay_branch_ratio(std::pair< int, int >)
Definition pyne.cc:12104
const double sec_per_day
seconds per day
Definition pyne.cc:10360
void pyne_start()
Initializes PyNE based on environment.
Definition pyne.cc:81
struct pyne::scattering_lengths scattering_lengths
a struct matching the '/neutron/scattering_lengths' table in nuc_data.h5.
const double pi
pi = 3.14159265359
Definition pyne.cc:10356
const double Bq_per_Ci
Becquerel per Curie.
Definition pyne.cc:10363
std::map< std::pair< int, double >, ecbp > ecbp_data
A vector of structs containing ecbp data for access in memory.
Definition pyne.cc:12564
const double N_A
Avogadro's Number.
Definition pyne.cc:10357
double endftod_cpp(char *s)
Converts a string from ENDF format to a float.
Definition pyne.cc:147
double dose_ratio(int nuc, int source)
Dose Ratio.
Definition pyne.cc:10826
void _load_q_val_map()
Loads the q_value data from the nuc_data.h5 file into memory.
Definition pyne.cc:10558
static std::string digits
string of digit characters
Definition pyne.h:124
std::vector< int > decay_data_children(int parent)
Definition pyne.cc:12080
std::vector< int > beta_parent(double energy, double error)
Definition pyne.cc:12548
std::pair< double, double > decay_photon_branch_ratio(std::pair< int, int >)
Definition pyne.cc:12115
std::map< std::pair< int, double >, alpha > alpha_data
A vector of structs containing alpha data for access in memory.
Definition pyne.cc:12402
struct pyne::ecbp ecbp
A struct matching the '/decay/ecbp' table in nuc_data.h5.
static std::string alphabet
uppercase alphabetical characters
Definition pyne.h:126
struct pyne::ndsfpy ndsfpy
a struct matching the '/neutron/nds_fission_product' table in nuc_data.h5
std::vector< std::pair< double, double > > decay_photon_branch_ratios(int parent)
Definition pyne.cc:12123
void _load_scattering_lengths()
Loads the scattering length data from the nuc_data.h5 file into memory.
Definition pyne.cc:10982
std::map< std::pair< int, double >, gamma > gamma_data
Definition pyne.cc:12157
double tanh(double x)
The hyperbolic tangent function.
Definition pyne.cc:364
std::map< std::pair< int, double >, beta > beta_data
A vector of structs containing beta data for access in memory.
Definition pyne.cc:12479
bool ternary_ge(int a, int b, int c)
Returns true if a <= b <= c and flase otherwise.
Definition pyne.cc:305
struct pyne::atomic_mass_data atomic_mass_data
a struct matching the atomic_mass table in nuc_data.h5.
void _load_dose_map(std::map< int, dose > &dm, std::string source_path)
Loads the dose factor data from the nuc_data.h5 file into memory according to the user-input source.
Definition pyne.cc:10704
double to_dbl(std::string s)
Converts a valid string to a float using atof().
Definition pyne.cc:143
void _load_data< alpha >()
Loads the alpha decay data from the nuc_data.h5 file into memory.
void _insert_abund_map()
function to create mapping from nuclides in id form to their natural abundances
Definition pyne.cc:10048
double decay_const(int nuc)
Returns the decay constant for a nuclide nuc.
Definition pyne.cc:11914
bool toggle_warnings()
Toggles warnings on and off.
Definition pyne.cc:408
void _load_data()
std::map< std::string, std::map< int, std::map< int, double > > > simple_xs_map
map<energy, map<nuclide, map<rx, xs> > >
Definition pyne.cc:12861
struct pyne::q_val_data q_val_data
a struct matching the q_value table in nuc_data.h5.
struct pyne::wimsdfpy wimsdfpy
a struct matching the '/neutron/wimsd_fission_product' table in nuc_data.h5.
std::string PYNE_DATA
Path to the directory containing the PyNE data.
Definition pyne.cc:78
void _insert_atomic_mass_map()
function to create mapping from nuclides in id form to their atomic masses
Definition pyne.cc:6693
std::map< std::string, std::string > get_data_checksums()
Definition pyne.cc:10371
struct pyne::material_data material_data
A stuct for reprensenting fundemental data in a material.
std::vector< double > beta_intensity(int parent)
Definition pyne.cc:12543
std::map< int, double > comp_map
Nuclide-mass composition map type.
Definition pyne.h:4776
std::string capitalize(std::string s)
Returns a capitalized copy of the string.
Definition pyne.cc:231
double ingest_dose(int nuc, int source)
Functions for Ingestion Dose Factors and Fraction of activity that is absorbed by body fluids.
Definition pyne.cc:10880
std::vector< std::pair< double, double > > gammas(int parent_state_id)
Returns a list of energies and intensities normalized to branching ratios.
Definition pyne.cc:12703
std::map< int, dose > doe_dose_map
Definition pyne.cc:10794
std::vector< double > alpha_intensity(int parent)
Definition pyne.cc:12459
const double MeV_per_MJ
MeV per MJ.
Definition pyne.cc:10362
static std::string words
string of all valid word characters for variable names in programing languages.
Definition pyne.h:128
double solve_line(double x, double x2, double y2, double x1, double y1)
Solves the equation for the line y = mx + b, given x and the points that form the line: (x1,...
Definition pyne.cc:359
xd_complex_t b_coherent(int nuc)
Finds the coherent scattering length [cm] for a nuclide nuc.
Definition pyne.cc:11039
std::vector< int > gamma_parent(double energy, double error)
Definition pyne.cc:12348
std::string last_char(std::string s)
Returns the last character in a string.
Definition pyne.cc:293
std::map< int, dose > genii_dose_map
Definition pyne.cc:10795
std::set< int > decay_children(int nuc)
Returns a set of decay children of a nuc.
Definition pyne.cc:11843
double slope(double x2, double y2, double x1, double y1)
Finds the slope of a line from the points (x1, y1) and (x2, y2).
Definition pyne.cc:353
double half_life(int nuc)
Returns the half life for a nuclide nuc.
Definition pyne.cc:11940
double dose_fluid_frac(int nuc, int source)
Fluid Fraction.
Definition pyne.cc:10902
std::vector< double > alpha_energy(int parent)
Definition pyne.cc:12455
double q_val(int nuc)
Returns the q_value of a nuclide nuc.
Definition pyne.cc:10602
struct pyne::gamma gamma
a struct matching the '/decay/gammas' table in nuc_data.h5.
std::string to_upper(std::string s)
switches endftod to fast cpp version
Definition pyne.cc:216
void _load_data< ecbp >()
Loads the electron capture and beta plus decay data from the nuc_data.h5 file into memory.
std::vector< T > data_access(double emin, double emax, size_t valoffset, std::map< std::pair< int, double >, U > &data)
Access data in a std::map<std::pair<int, double> for a range of values of the second member of the pa...
Definition pyne.cc:11424
std::string natural_naming(std::string name)
Calculates a version of the string name that is also a valid variable name.
Definition pyne.cc:318
double natural_abund(int nuc)
Returns the natural abundance of a nuclide nuc.
Definition pyne.cc:10502
std::map< int, double > natural_abund_map
Mapping from nuclides in id form to their natural abundances.
Definition pyne.h:1892
std::map< std::pair< int, double >, level_data > level_data_lvl_map
Mapping from nuclides in id form to a struct containing data associated with that level.
Definition pyne.cc:11709
std::map< int, double > gamma_frac_map
Definition pyne.cc:10647
double(* endftod)(char *s)
endftod function pointer. defaults to fortran
Definition pyne.cc:210
struct pyne::beta beta
a struct matching the '/decay/betas' table in nuc_data.h5.
double atomic_mass(int nuc)
Returns the atomic mass of a nuclide nuc.
Definition pyne.cc:10440
bool USE_WARNINGS
Definition pyne.cc:406
struct pyne::ndsfpysub ndsfpysub
a struct for the nds data for fpyield
bool contains_substring(std::string s, std::string substr)
Returns true if substr is in s.
Definition pyne.cc:311
std::vector< double > ecbp_average_energy(int parent)
Definition pyne.cc:12630
static int FLUKA_MAT_NUM
Definition pyne.h:4797
double inhale_dose(int nuc, int source)
Functions for Inhalation Dose Factors and Lung Model used to obtain dose factors.
Definition pyne.cc:10929
std::vector< double > beta_average_energy(int parent)
Definition pyne.cc:12538
std::map< int, double > b_map
Mapping from nuclides in id form to their scattering length.
Definition pyne.cc:10979
std::vector< std::pair< int, int > > gamma_parent_child(double energy, double error)
Definition pyne.cc:12335
std::ostream & operator<<(std::ostream &os, Material mat)
Converts a Material to a string stream representation for canonical writing.
std::vector< std::pair< int, int > > gamma_from_to(int parent)
Definition pyne.cc:12309
std::string get_flag(char line[], int max_l)
Finds and returns the first white-space delimited token of a line.
Definition pyne.cc:244
void warning(std::string s)
Prints a warning message.
Definition pyne.cc:413
std::string slice_from_end(std::string s, int n=-1, int l=1)
Returns the slice of a string s using the negative index n and the length of the slice l.
Definition pyne.cc:299
void _load_data< beta >()
Loads the beta decay data from the nuc_data.h5 file into memory.
int to_int(std::string s)
Converts a string of digits to an int using atoi().
Definition pyne.cc:139
std::string NUC_DATA_PATH
Path to the nuc_data.h5 file.
Definition pyne.h:1848
std::map< int, atomic > atomic_data_map
Definition pyne.cc:11571
std::vector< int > ecbp_child(double energy, double error)
Definition pyne.cc:12650
std::map< std::pair< int, int >, decay > decay_data
Mapping from a pair of nuclides in id form to a struct containing data associated with the decay from...
Definition pyne.cc:12013
std::vector< int > gamma_child(double energy, double error)
Definition pyne.cc:12353
std::vector< double > ec_intensity(int parent)
Definition pyne.cc:12635
std::pair< double, double > decay_half_life(std::pair< int, int >)
Definition pyne.cc:12086
void _load_data< level_data >()
std::map< int, dose > epa_dose_map
Mapping from int to dose for 3 sources.
Definition pyne.cc:10793
const double barns_per_cm2
barns per cm^2
Definition pyne.cc:10358
bool file_exists(std::string strfilename)
Returns true if the file can be found.
Definition pyne.cc:376
std::map< int, double > atomic_mass_map
Mapping from nuclides in id form to their atomic masses.
Definition pyne.h:1857
std::vector< int > alpha_child(double energy, double error)
Definition pyne.cc:12469
std::string to_lower(std::string s)
Returns an all lower case copy of the string.
Definition pyne.cc:223
struct pyne::level_data level_data
a struct matching the '/decay/level_list' table in nuc_data.h5.
struct pyne::dose dose
A struct matching the dose factor table in nuc_data.h5.
struct pyne::alpha alpha
a struct matching the '/decay/alphas' table in nuc_data.h5.
double state_energy(int nuc)
Returns the excitation energy [MeV] of a nuc in a given state.
Definition pyne.cc:11889
struct pyne::atomic atomic
Structure for atomic data.
std::string remove_substring(std::string s, std::string substr)
Creates a copy of s with all instances of substr taken out.
Definition pyne.cc:261
std::map< std::pair< int, unsigned int >, level_data > level_data_rx_map
Definition pyne.cc:11711
std::string remove_characters(std::string s, std::string chars)
Removes all characters in the string chars from s.
Definition pyne.cc:272
std::vector< double > bp_intensity(int parent)
Definition pyne.cc:12640
std::vector< std::pair< double, double > > gamma_conversion_intensity(int parent)
Definition pyne.cc:12283
double gamma_frac(int nuc)
Definition pyne.cc:10649
std::vector< std::pair< double, double > > decay_beta_branch_ratios(int parent)
Definition pyne.cc:12144
std::string dose_lung_model(int nuc, int source)
Lung Model.
Definition pyne.cc:10951
std::vector< std::pair< double, double > > gamma_total_intensity(int parent)
Definition pyne.cc:12296
std::vector< std::pair< double, double > > betas(int parent_state_id)
Definition pyne.cc:12743
comp_map::iterator comp_iter
Nuclide-mass composition iter type.
Definition pyne.h:4777
void _load_data< gamma >()
Loads the gamma ray data from the nuc_data.h5 file into memory.
static std::string fluka_mat_strings[]
Definition pyne.h:4788
const double MeV_per_K
MeV per Kelvin.
Definition pyne.cc:10361
double branch_ratio(std::pair< int, int > from_to)
Returns the branch ratio for a parent/child nuclide pair.
Definition pyne.cc:11964
std::vector< std::pair< double, double > > gamma_photon_intensity(int parent)
Definition pyne.cc:12257
const double Ci_per_Bq
Curies per Becquerel.
Definition pyne.cc:10364
std::map< int, double > q_val_map
Mapping from nuclides in id form to their q_values and the fraction of Q that comes from gammas.
Definition pyne.cc:10600
void _load_ndsfpy()
Loads the NDS fission product yield data from the nuc_data.h5 file into memory.
Definition pyne.cc:11271
std::vector< std::pair< double, double > > alphas(int parent_state_id)
Definition pyne.cc:12724
std::vector< std::pair< double, double > > calculate_xray_data(int z, double k_conv, double l_conv)
Definition pyne.cc:11666
void _load_atomic_mass_map()
Loads the atomic mass and natural abundance data from the nuc_data.h5 file into memory.
Definition pyne.cc:10392
double fpyield(std::pair< int, int > from_to, int source, bool get_error)
Returns the fission product yield for a parent/child nuclide pair.
Definition pyne.cc:11338
struct simple_xs simple_xs
#define JSON_API
If defined, indicates that the source file is amalgated to prevent private header inclusion.
Definition pyne.h:2666
#define NUM_RX_NAMES
Number of reactions supported by default.
Definition pyne.h:1419
#define JSONCPP_DEPRECATED(message)
Definition pyne.h:2685
a struct matching the '/decay/alphas' table in nuc_data.h5.
Definition pyne.h:2380
double intensity
intensity of alpha decay
Definition pyne.h:2384
double energy
energy of alpha
Definition pyne.h:2383
int to_nuc
state id of child nuclide
Definition pyne.h:2382
int from_nuc
state id of parent nuclide
Definition pyne.h:2381
a struct matching the atomic_mass table in nuc_data.h5.
Definition pyne.h:1860
double mass
nuclide atomic mass [amu]
Definition pyne.h:1862
double error
error in atomic mass [amu]
Definition pyne.h:1863
double abund
natural abundance of nuclide [atom fraction]
Definition pyne.h:1864
int nuc
nuclide in id form
Definition pyne.h:1861
Structure for atomic data.
Definition pyne.h:2154
double prob
probability K shell hole is filled by L shell [fraction]
Definition pyne.h:2160
double ka1_x_ray_en
Ka1 X-ray energy [keV].
Definition pyne.h:2175
double mi_shell_be_err
M-shell binding energy error [fraction].
Definition pyne.h:2166
int z
number of protons [int]
Definition pyne.h:2155
double l_x_ray_en
L X-ray energy [keV].
Definition pyne.h:2180
double li_shell_be
L-shell binding energy [fraction].
Definition pyne.h:2163
double l_shell_fluor_error
L-shell fluorescence error [fraction].
Definition pyne.h:2159
double ni_shell_be
N-shell binding energy [fraction].
Definition pyne.h:2167
double ka2_to_ka1_err
Ka2 to Ka1 fluorescence error [fraction].
Definition pyne.h:2172
double l_shell_fluor
L-shell fluorescence [fraction].
Definition pyne.h:2158
double ka2_x_ray_en
Ka2 X-ray energy [keV].
Definition pyne.h:2177
double k_shell_be_err
K-shell binding energy error [fraction].
Definition pyne.h:2162
double kb_to_ka
ratio of Kb to Ka fluorescence [fraction]
Definition pyne.h:2169
double ka1_x_ray_en_err
Ka1 X-ray energy error [keV].
Definition pyne.h:2176
double k_shell_fluor
K-shell fluorescence [fraction].
Definition pyne.h:2156
double k_shell_be
K-shell binding energy [fraction].
Definition pyne.h:2161
double li_shell_be_err
L-shell binding energy error [fraction].
Definition pyne.h:2164
double kb_x_ray_en
Kb X-ray energy [keV].
Definition pyne.h:2179
double ka2_x_ray_en_err
Ka2 X-ray energy error [keV].
Definition pyne.h:2178
double ni_shell_be_err
N-shell binding energy error [fraction].
Definition pyne.h:2168
double ka2_to_ka1
Ka2 to Ka1 fluorescence ratio [fraction].
Definition pyne.h:2171
double l_auger
Auger electrons from l shell holes [fraction].
Definition pyne.h:2174
double mi_shell_be
M-shell binding energy [fraction].
Definition pyne.h:2165
double k_shell_fluor_error
K-shell fluorescence error [fraction].
Definition pyne.h:2157
double k_auger
Auger electrons from k shell holes [fraction].
Definition pyne.h:2173
double kb_to_ka_err
error in ratio of Kb to Ka fluorescence [fraction]
Definition pyne.h:2170
a struct matching the '/decay/betas' table in nuc_data.h5.
Definition pyne.h:2405
double endpoint_energy
beta decay endpoint energy
Definition pyne.h:2408
int to_nuc
state id of child nuclide
Definition pyne.h:2407
double intensity
beta intensity
Definition pyne.h:2410
int from_nuc
state id of parent nuclide
Definition pyne.h:2406
double avg_energy
beta decay average energy
Definition pyne.h:2409
a struct matching the '/decay/decays' table in nuc_data.h5.
Definition pyne.h:2284
double branch_ratio
branching ratio of this decay [fraction]
Definition pyne.h:2290
int parent
state id of decay parent
Definition pyne.h:2285
double photon_branch_ratio_error
photon branching ratio error of this decay [fraction]
Definition pyne.h:2295
double beta_branch_ratio
beta branching ratio of this decay [fraction]
Definition pyne.h:2297
double branch_ratio_error
branching ratio of this decay [fraction]
Definition pyne.h:2291
double photon_branch_ratio
photon branching ratio of this decay [fraction]
Definition pyne.h:2293
double half_life_error
half life error of the decay [s]
Definition pyne.h:2289
int child
state id of decay child
Definition pyne.h:2286
unsigned int decay
rx id of decay
Definition pyne.h:2287
double beta_branch_ratio_error
beta branching ratio error of this decay [fraction]
Definition pyne.h:2299
double half_life
half life of the decay [s]
Definition pyne.h:2288
A struct matching the dose factor table in nuc_data.h5.
Definition pyne.h:1944
double ingest_dose
nuclide dose factor due to ingestion [mrem/pCi]
Definition pyne.h:1949
double ratio
ratio of external air dose factor to dose factor due to inhalation
Definition pyne.h:1947
double ext_soil_dose
nuclide ext_soil dose factor [mrem/h per Ci/m^2]
Definition pyne.h:1948
double fluid_frac
fraction of activity abosorbed in body fluids
Definition pyne.h:1950
double inhale_dose
nuclide dose factor due to inhalation [mrem/pCi]
Definition pyne.h:1951
int nuc
nuclide in id form
Definition pyne.h:1945
double ext_air_dose
nuclide ext_air dose factor [mrem/h per Ci/m^3]
Definition pyne.h:1946
char lung_mod
model of lung used (time of biological half life– D, W, or Y)
Definition pyne.h:1952
A struct matching the '/decay/ecbp' table in nuc_data.h5.
Definition pyne.h:2432
int from_nuc
state id of parent nuclide
Definition pyne.h:2433
double avg_energy
beta decay average energy
Definition pyne.h:2436
double k_conv_e
k conversion electron fraction
Definition pyne.h:2439
double l_conv_e
l conversion electron fraction
Definition pyne.h:2440
double ec_intensity
intensity of electron capture
Definition pyne.h:2438
int to_nuc
state id of child nuclide
Definition pyne.h:2434
double endpoint_energy
beta decay endpoint energy
Definition pyne.h:2435
double beta_plus_intensity
intensity of beta plus decay
Definition pyne.h:2437
double m_conv_e
m conversion electron fraction
Definition pyne.h:2441
a struct matching the '/decay/gammas' table in nuc_data.h5.
Definition pyne.h:2322
int from_nuc
state id of starting level
Definition pyne.h:2323
double photon_intensity_err
photon intensity error
Definition pyne.h:2330
double conv_intensity_err
conversion intensity error
Definition pyne.h:2332
double total_intensity
total decay intensity
Definition pyne.h:2333
double photon_intensity
photon intensity
Definition pyne.h:2329
double m_conv_e
m conversion electron fraction
Definition pyne.h:2337
double conv_intensity
conversion intensity
Definition pyne.h:2331
double energy
energy of the photon [keV]
Definition pyne.h:2327
double total_intensity_err
total decay intensity error
Definition pyne.h:2334
int parent_nuc
state id of the primary decaying nucleus
Definition pyne.h:2325
double energy_err
energy error of the photon [keV]
Definition pyne.h:2328
int child_nuc
stateless id of the child nucleus
Definition pyne.h:2326
double k_conv_e
k conversion electron fraction
Definition pyne.h:2335
double l_conv_e
l conversion electron fraction
Definition pyne.h:2336
int to_nuc
state id of final level
Definition pyne.h:2324
a struct matching the '/decay/level_list' table in nuc_data.h5.
Definition pyne.h:2195
double half_life
half life [seconds]
Definition pyne.h:2198
unsigned int rx_id
rx id of reaction, 0 for basic level data
Definition pyne.h:2197
double branch_ratio
branch ratio [fraction]
Definition pyne.h:2200
int metastable
metastable level [int]
Definition pyne.h:2201
char special
special high-spin state [character]
Definition pyne.h:2202
int nuc_id
state id of nuclide
Definition pyne.h:2196
double level
level energy [keV]
Definition pyne.h:2199
A stuct for reprensenting fundemental data in a material.
Definition pyne.h:5101
double atoms_per_mol
material atoms per mole
Definition pyne.h:5104
double mass
material mass
Definition pyne.h:5102
double comp[1]
array of material composition mass weights.
Definition pyne.h:5105
double density
material density
Definition pyne.h:5103
a struct matching the '/neutron/nds_fission_product' table in nuc_data.h5
Definition pyne.h:2065
double yield_fast_err
fast yield error [fraction]
Definition pyne.h:2071
double yield_14MeV_err
14 MeV yield error [fraction]
Definition pyne.h:2073
double yield_14MeV
14 MeV yield [fraction]
Definition pyne.h:2072
double yield_thermal
thermal yield [fraction]
Definition pyne.h:2068
int from_nuc
id of fissioning nuclide
Definition pyne.h:2066
double yield_fast
fast yield [fraction]
Definition pyne.h:2070
int to_nuc
id of fission product
Definition pyne.h:2067
double yield_thermal_err
thermal yield error [fraction]
Definition pyne.h:2069
a struct for the nds data for fpyield
Definition pyne.h:2077
double yield_14MeV_err
14 MeV yield error [fraction]
Definition pyne.h:2083
double yield_thermal
thermal yield [fraction]
Definition pyne.h:2078
double yield_thermal_err
thermal yield error [fraction]
Definition pyne.h:2079
double yield_fast_err
fast yield error [fraction]
Definition pyne.h:2081
double yield_fast
fast yield [fraction]
Definition pyne.h:2080
double yield_14MeV
14 MeV yield [fraction]
Definition pyne.h:2082
a struct matching the q_value table in nuc_data.h5.
Definition pyne.h:1917
int nuc
nuclide in id form
Definition pyne.h:1918
double gamma_frac
fraction of q that comes from gammas
Definition pyne.h:1920
double q_val
nuclide q_value [MeV/fission]
Definition pyne.h:1919
a struct matching the '/neutron/scattering_lengths' table in nuc_data.h5.
Definition pyne.h:2005
int nuc
nuclide in id form
Definition pyne.h:2006
xd_complex_t b_coherent
coherent scattering length [cm]
Definition pyne.h:2007
xd_complex_t b_incoherent
incoherent scattering length [cm]
Definition pyne.h:2008
double xs_coherent
coherent scattering cross section
Definition pyne.h:2009
double xs
scattering cross section
Definition pyne.h:2011
double xs_incoherent
incoherent scattering cross section
Definition pyne.h:2010
a struct matching the '/neutron/wimsd_fission_product' table in nuc_data.h5.
Definition pyne.h:2055
double yields
fission product yield, fraction [unitless]
Definition pyne.h:2058
int to_nuc
from nuclide in id form
Definition pyne.h:2057
int from_nuc
from nuclide in id form
Definition pyne.h:2056
complex type struct, matching PyTables definition
Definition pyne.h:316
double im
imaginary part
Definition pyne.h:318
double re
real part
Definition pyne.h:317