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