PyNE C++
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
pyne::Material Class Reference

Material composed of nuclides. More...

#include <material.h>

Public Member Functions

 Material ()
 
 Material (comp_map cm, double m=-1.0, double d=-1.0, double apm=-1.0, Json::Value attributes=Json::Value(Json::objectValue))
 
 Material (char *filename, double m=-1.0, double d=-1.0, double apm=-1.0, Json::Value attributes=Json::Value(Json::objectValue))
 
 Material (std::string filename, double m=-1.0, double d=-1.0, double apm=-1.0, Json::Value attributes=Json::Value(Json::objectValue))
 
 ~Material ()
 default destructor
 
void norm_comp ()
 Normalizes the mass values in the composition.
 
void _load_comp_protocol0 (hid_t db, std::string datapath, int row)
 
void _load_comp_protocol1 (hid_t db, std::string datapath, int row)
 
void _load_comp_protocol1 (hid_t db, std::string datapath, std::string nucpath, int row)
 
void from_hdf5 (char *filename, char *datapath, int row=-1, int protocol=1)
 
void from_hdf5 (std::string filename, std::string datapath="/mat_name", int row=-1, int protocol=1)
 
void write_hdf5 (std::string filename, std::string datapath="/mat_name", float row=-0.0, int chunksize=DEFAULT_MAT_CHUNKSIZE)
 
std::vector< int > write_hdf5_nucpath (hid_t db, std::string nucpath)
 
void write_hdf5_datapath (hid_t db, std::string datapath, float row, int chunksize, std::vector< int > nuclides)
 
void deprecated_write_hdf5 (char *filename, char *datapath, char *nucpath, float row=-0.0, int chunksize=DEFAULT_MAT_CHUNKSIZE)
 
void deprecated_write_hdf5 (hid_t db, std::string datapath, std::string nucpath, float row=-0.0, int chunksize=DEFAULT_MAT_CHUNKSIZE)
 
void deprecated_write_hdf5 (std::string filename, std::string datapath, std::string nucpath, float row=-0.0, int chunksize=DEFAULT_MAT_CHUNKSIZE)
 
std::string openmc (std::string fact_type="mass")
 Return an openmc xml material element as a string.
 
std::string mcnp (std::string frac_type="mass", bool mult_den=true)
 Return an mcnp input deck record as a string. More...
 
std::string phits (std::string frac_type="mass", bool mult_den=true)
 Return an phits input deck record as a string. More...
 
std::string mcnp_frac (std::map< int, double > fracs, std::string frac_type="")
 return the compo fraction writen ala "mcnp"
 
std::string get_uwuw_name ()
 Return an uwuw name. More...
 
std::string fluka (int id, std::string frac_type="mass")
 Return a fluka input deck MATERIAL card as a string. More...
 
bool not_fluka_builtin (std::string fluka_name)
 Convenience function to tell whether a given name needs a material card. More...
 
std::string fluka_material_str (int id)
 High level call to get details and call material_component(..) More...
 
std::string fluka_material_component (int fid, int nucid, std::string fluka_name)
 Intermediate level call to prepare final info and call material_line(..) More...
 
std::string fluka_material_line (int znum, double atomic_mass, int fid, std::string fluka_name)
 Format information into a FLUKA material card. More...
 
std::string fluka_format_field (float field)
 Convenience function to format a single fluka field. More...
 
std::string fluka_compound_str (int id, std::string frac_type="mass")
 
void from_text (char *filename)
 Reads data from a plaintext file at filename into this Material instance.
 
void from_text (std::string filename)
 Reads data from a plaintext file at filename into this Material instance.
 
void write_text (char *filename)
 Writes the Material out to a simple plaintext file readable by from_text().
 
void write_text (std::string filename)
 Writes the Material out to a simple plaintext file readable by from_text().
 
void load_json (Json::Value)
 Loads a JSON instance tree into this Material.
 
Json::Value dump_json ()
 Dumps the Material out to a JSON instance tree.
 
void from_json (char *filename)
 Reads data from a JSON file at filename into this Material instance.
 
void from_json (std::string filname)
 Reads data from a JSON file at filename into this Material instance.
 
void write_json (char *filename)
 Writes the Material out to a JSON file.
 
void write_json (std::string filename)
 Writes the Material out to a JSON file.
 
void normalize ()
 
comp_map mult_by_mass ()
 
double molecular_mass (double apm=-1.0)
 
comp_map activity ()
 
comp_map decay_heat ()
 
comp_map dose_per_g (std::string dose_type, int source=0)
 
Material expand_elements (std::set< int > exception_ids)
 
Material expand_elements (int **int_ptr_arry=NULL)
 
Material collapse_elements (std::set< int > exception_znum)
 
Material collapse_elements (int **int_ptr_arry)
 
double mass_density (double num_dens=-1.0, double apm=-1.0)
 
std::map< int, double > get_density_frac (std::string frac_type="atom", bool mult_den=true)
 
double number_density (double mass_dens=-1.0, double apm=-1.0)
 
Material sub_mat (std::set< int > nucset)
 
Material sub_mat (std::set< std::string > nucset)
 
Material set_mat (std::set< int > nucset, double value)
 
Material set_mat (std::set< std::string > nucset, double value)
 
Material del_mat (std::set< int > nucset)
 
Material del_mat (std::set< std::string > nucset)
 
Material sub_range (int lower=0, int upper=10000000)
 Creates a sub-Material based on a range of id-form integers.
 
Material set_range (int lower=0, int upper=10000000, double value=0.0)
 
Material del_range (int lower=0, int upper=10000000)
 Creates a new Material with the all nuclides in the id range removed.
 
Material sub_elem (int element)
 
Material sub_lan ()
 Creates a sub-Material of only lanthanides.
 
Material sub_act ()
 Creates a sub-Material of only actinides.
 
Material sub_tru ()
 Creates a sub-Material of only transuranics.
 
Material sub_ma ()
 Creates a sub-Material of only minor actinides.
 
Material sub_fp ()
 Creates a sub-Material of only fission products.
 
std::map< int, double > to_atom_frac ()
 
void from_atom_frac (std::map< int, double > atom_fracs)
 
std::map< int, double > to_atom_dens ()
 
std::vector< std::pair< double, double > > gammas ()
 
std::vector< std::pair< double, double > > xrays ()
 
std::vector< std::pair< double, double > > photons (bool norm)
 
std::vector< std::pair< double, double > > normalize_radioactivity (std::vector< std::pair< double, double > > unnormed)
 
void from_activity (std::map< int, double > activities)
 
Material decay (double t)
 Decays this material for a given amount of time in seconds.
 
Material cram (std::vector< double > A, const int order=14)
 
Material operator+ (double)
 Adds mass to a material instance.
 
Material operator+ (Material)
 Adds two materials together.
 
Material operator* (double)
 Multiplies a material's mass.
 
Material operator/ (double)
 Divides a material's mass.
 

Public Attributes

comp_map comp
 composition, maps nuclides in id form to normalized mass weights.
 
double mass
 mass (in arbitrary units) of the Material.
 
double density
 density (in arbitrary units) of the Material.
 
double atoms_per_molecule
 
Json::Value metadata
 container for arbitrary metadata, following the JSON rules.
 

Protected Member Functions

double get_comp_sum ()
 Computes the total mass stored in the composition.
 

Detailed Description

Material composed of nuclides.

Constructor & Destructor Documentation

◆ Material() [1/4]

pyne::Material::Material ( )

empty constructor

◆ Material() [2/4]

pyne::Material::Material ( pyne::comp_map  cm,
double  m = -1.0,
double  d = -1.0,
double  apm = -1.0,
Json::Value  attributes = Json::Value(Json::objectValue) 
)

Constructor from composition map

Parameters
cmcomposition map
mmass value, the mass is set to the sum of the values in the composition if m is negative.
ddensity value
apmatoms per mole
attributesinitial metadata

◆ Material() [3/4]

pyne::Material::Material ( char *  filename,
double  m = -1.0,
double  d = -1.0,
double  apm = -1.0,
Json::Value  attributes = Json::Value(Json::objectValue) 
)

Constructor from file

Parameters
filenamepath to file on disk, this file may be either in plaintext or HDF5 format.
mmass value, the mass is set to the sum of the values in the composition if m is negative, may be overridden by the value from disk.
ddensity value, may be overridden by the value from disk.
apmatoms per mole, may be overridden by the value from disk.
attributesinitial metadata, may be overridden by the value from disk.

◆ Material() [4/4]

pyne::Material::Material ( std::string  filename,
double  m = -1.0,
double  d = -1.0,
double  apm = -1.0,
Json::Value  attributes = Json::Value(Json::objectValue) 
)

Constructor from file

Parameters
filenamepath to file on disk, this file may be either in plaintext or HDF5 format.
mmass value, the mass is set to the sum of the values in the composition if m is negative, may be overridden by the value from disk.
ddensity value, may be overridden by the value from disk.
apmatoms per mole, may be overridden by the value from disk.
attributesinitial metadata, may be overridden by the value from disk.

Member Function Documentation

◆ _load_comp_protocol0()

void pyne::Material::_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. This protocol is depratacted.

Parameters
dbHDF5 id for the open HDF5 file.
datapathPath to the base node for the material in db.
rowThe index to read out, may be negative.

◆ _load_comp_protocol1() [1/2]

void pyne::Material::_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. This protocol should be used in favor of protocol 0.

Parameters
dbHDF5 id for the open HDF5 file.
datapathPath to the base node for the material in db.
rowThe index to read out, may be negative.

◆ _load_comp_protocol1() [2/2]

void pyne::Material::_load_comp_protocol1 ( hid_t  db,
std::string  datapath,
std::string  nucpath,
int  row 
)

Loads the matrial composition from an HDF5 file according to the layout defined by protocol 1. This protocol should be used in favor of protocol 0.

Parameters
dbHDF5 id for the open HDF5 file.
datapathPath to the base node for the material in a db.
nucpathPath to the base node for nuclide list in a db.
rowThe index to read out, may be negative.

◆ activity()

pyne::comp_map pyne::Material::activity ( )

Calculates the activity of a material based on the composition and each nuclide's mass, decay_const, and atmoic_mass.

◆ cram()

pyne::Material pyne::Material::cram ( std::vector< double >  A,
const int  order = 14 
)

Transmutes the material via the CRAM method.

Parameters
AThe transmutation matrix [unitless]
orderThe CRAM approximation order (default 14).
Returns
A new material which has been transmuted.

◆ decay_heat()

pyne::comp_map pyne::Material::decay_heat ( )

Calculates the decay heat of a material based on the composition and each nuclide's mass, q_val, decay_const, and atomic_mass. This assumes input mass of grams. Return values is in megawatts.

◆ del_mat() [1/2]

pyne::Material pyne::Material::del_mat ( std::set< int >  nucset)

Creates a new Material with the all nuclides in nucset removed. Elements of nucset may be either in id form or simple Z numbers.

◆ del_mat() [2/2]

pyne::Material pyne::Material::del_mat ( std::set< std::string >  nucset)

Creates a new Material with the all nuclides in nucset removed. Elements of nucset may be in any form.

◆ deprecated_write_hdf5() [1/3]

void pyne::Material::deprecated_write_hdf5 ( char *  filename,
char *  datapath,
char *  nucpath,
float  row = -0.0,
int  chunksize = DEFAULT_MAT_CHUNKSIZE 
)

Writes this material out to an HDF5 file in the old data structure format. Now deprecated, as material data structure in HDF5 format has been refactored. Only used when adding material in a file containing old material data structure. This happens according to protocol 1.

Parameters
filenamePath on disk to the HDF5 file.
datapathPath to the the material in the file.
nucpathPath to the nuclides set in the file.
rowThe index to read out, may be negative. Also note that this is a float. A value of -0.0 indicates that the material should be appended to the end of the dataset.
chunksizeThe chunksize for all material data on disk.

◆ deprecated_write_hdf5() [2/3]

void pyne::Material::deprecated_write_hdf5 ( hid_t  db,
std::string  datapath,
std::string  nucpath,
float  row = -0.0,
int  chunksize = DEFAULT_MAT_CHUNKSIZE 
)

Writes this material out to an HDF5 file in the old data structure format. Now deprecated, as material data structure in HDF5 format has been refactored. Only used when adding material in a file containing old material data structure. This happens according to protocol 1.

Parameters
dbHDF5 id for the open HDF5 file.
datapathPath to the the material in the file.
nucpathPath to the nuclides set in the file.
rowThe index to read out, may be negative. Also note that this is a float. A value of -0.0 indicates that the material should be appended to the end of the dataset.
chunksizeThe chunksize for all material data on disk.

◆ deprecated_write_hdf5() [3/3]

void pyne::Material::deprecated_write_hdf5 ( std::string  filename,
std::string  datapath,
std::string  nucpath,
float  row = -0.0,
int  chunksize = DEFAULT_MAT_CHUNKSIZE 
)

Writes this material out to an HDF5 file. This happens according to protocol 1.

Parameters
filenamePath on disk to the HDF5 file.
datapathPath to the the material in the file.
nucpathPath to the nuclides list in the file.
rowThe index to read out, may be negative. Also note that this is a float. A value of -0.0 indicates that the material should be appended to the end of the dataset.
chunksizeThe chunksize for all material data on disk.

◆ dose_per_g()

pyne::comp_map pyne::Material::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, and the source for dose factors dose_type is one of: ext_air – returns mrem/h per g per m^3 ext_soil – returns mrem/h per g per m^2 ingest – returns mrem per g inhale – returns mrem per g source is: {EPA=0, DOE=1, GENII=2}, default is EPA

◆ expand_elements()

pyne::Material pyne::Material::expand_elements ( std::set< int >  exception_ids)

Returns a copy of the current material where all natural elements in the composition are expanded to their natural isotopic abundances.

◆ fluka()

std::string pyne::Material::fluka ( int  id,
std::string  frac_type = "mass" 
)

Return a fluka input deck MATERIAL card as a string.

------------------------------------------------------------------------—// fluka ------------------------------------------------------------------------—// Main external call

◆ fluka_compound_str()

std::string pyne::Material::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 the components

------------------------------------------------------------------------—// fluka_compound_str ------------------------------------------------------------------------—// Returns – MATERIAL line for compound – COMPOUND lines

◆ fluka_format_field()

std::string pyne::Material::fluka_format_field ( float  field)

Convenience function to format a single fluka field.

------------------------------------------------------------------------—// fluka_format_field ------------------------------------------------------------------------—// Convenience function that returns a 10-character formatted string 999 -> 999. 999.12 -> 999.12 999.123 -> 999.123 999.1234 -> 999.123

◆ fluka_material_component()

std::string pyne::Material::fluka_material_component ( int  fid,
int  nucid,
std::string  fluka_name 
)

Intermediate level call to prepare final info and call material_line(..)

------------------------------------------------------------------------—// fluka_material_component ------------------------------------------------------------------------—// Material has only one component, Density is either object density or it is ignored ==> use object density This function is not called for a compound, but it is called on the material-ized components of compounds

◆ fluka_material_line()

std::string pyne::Material::fluka_material_line ( int  znum,
double  atomic_mass,
int  fid,
std::string  fluka_name 
)

Format information into a FLUKA material card.

------------------------------------------------------------------------—// fluka_material_line ------------------------------------------------------------------------—// Given all the info, return the Material string

◆ fluka_material_str()

std::string pyne::Material::fluka_material_str ( int  id)

High level call to get details and call material_component(..)

------------------------------------------------------------------------—// fluka_material_str ------------------------------------------------------------------------—//

Requirement: the material upon which this function is called has exactly one nucid component, i.e. it is elemental Do not assume fluka_name is defined in the metadata. This function may be called from a user-defined material, i.e. on that is not read out of a UW^2-tagged geometry file, and thus does not have certain metadata.

◆ from_activity()

void pyne::Material::from_activity ( std::map< int, double >  activities)

Sets the composition, mass, and atoms_per_molecule of this material to those calculated from activities, a mapping of radionuclides to activities.

◆ from_atom_frac()

void pyne::Material::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_fracs, a mapping of nuclides to atom fractions values.

◆ from_hdf5() [1/2]

void pyne::Material::from_hdf5 ( char *  filename,
char *  datapath,
int  row = -1,
int  protocol = 1 
)

Loads a material from an HDF5 file into this object.

Parameters
filenamePath on disk to the HDF5 file.
datapathPath to the the material in the file.
rowThe index to read out, may be negative.
protocolFlag for layout of material on disk.

◆ from_hdf5() [2/2]

void pyne::Material::from_hdf5 ( std::string  filename,
std::string  datapath = "/mat_name",
int  row = -1,
int  protocol = 1 
)

Loads a material from an HDF5 file into this object.

Parameters
filenamePath on disk to the HDF5 file.
datapathPath to the the material in the file.
rowThe index to read out, may be negative.
protocolFlag for layout of material on disk.

◆ gammas()

std::vector< std::pair< double, double > > pyne::Material::gammas ( )

Returns a list of gamma-rays energies in keV and intensities in decays/s/atom material unnormalized

◆ get_density_frac()

std::map< int, double > pyne::Material::get_density_frac ( std::string  frac_type = "atom",
bool  mult_den = true 
)

Computes, sets, and returns the mass density if mult_den is true otherwise return mass fraction. Fraction density is returned per atom (default) in atom per barn cm or as a mass density.

◆ get_uwuw_name()

std::string pyne::Material::get_uwuw_name ( )

Return an uwuw name.

------------------------------------------------------------------------—//

◆ mass_density()

double pyne::Material::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. If num_dens is negative, this simply returns the current value of the density member variable. You may also use / set the atoms per molecule (atoms_per_molecule) in this function using apm.

◆ mcnp()

std::string pyne::Material::mcnp ( std::string  frac_type = "mass",
bool  mult_den = true 
)

Return an mcnp input deck record as a string.

------------------------------------------------------------------------—//

◆ molecular_mass()

double pyne::Material::molecular_mass ( double  apm = -1.0)

Calculates the atomic weight of this material based on the composition and the number of atoms per mol. If apm is non-negative then it is used (and stored on the instance) as the atoms_per_molecule for this calculation. If apm and atoms_per_molecule on this instance are both negative, then the best guess value calculated from the normailized composition is used here.

◆ mult_by_mass()

pyne::comp_map pyne::Material::mult_by_mass ( )

Returns a composition map that has been unnormalized by multiplying each mass weight by the actual mass of the material.

◆ normalize()

void pyne::Material::normalize ( )

Normalizes the mass.

◆ normalize_radioactivity()

std::vector< std::pair< double, double > > pyne::Material::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 one

◆ not_fluka_builtin()

bool pyne::Material::not_fluka_builtin ( std::string  fluka_name)

Convenience function to tell whether a given name needs a material card.

------------------------------------------------------------------------—// not_fluka_builtin ------------------------------------------------------------------------—// Convenience function This is written as a negative because that is what we care about

◆ number_density()

double pyne::Material::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 greater than or equal to zero. If mass_dens is negative, the denisty member variable is used instead. You may also use / set the atoms per molecule (atoms_per_molecule) in this function using apm.

◆ phits()

std::string pyne::Material::phits ( std::string  frac_type = "mass",
bool  mult_den = true 
)

Return an phits input deck record as a string.

------------------------------------------------------------------------—//

◆ photons()

std::vector< std::pair< double, double > > pyne::Material::photons ( bool  norm)

Returns a list of photon energies in keV and intensities in decays/s/atom material unnormalized

◆ set_mat() [1/2]

pyne::Material pyne::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. Elements of nucset may be either in id form or simple Z numbers.

◆ set_mat() [2/2]

pyne::Material pyne::Material::set_mat ( std::set< std::string >  nucset,
double  value 
)

Creates a new Material with the mass weights for all nuclides in nucset set to value. Elements of nucset may be in any form.

◆ set_range()

pyne::Material pyne::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.

◆ sub_elem()

pyne::Material pyne::Material::sub_elem ( int  element)

Creates a sub-Material of only the given element. Assumes element is id form.

◆ sub_mat() [1/2]

pyne::Material pyne::Material::sub_mat ( std::set< int >  nucset)

Creates a sub-Material with only the nuclides present in nucset. Elements of this set may be either in id form or simple Z numbers.

◆ sub_mat() [2/2]

pyne::Material pyne::Material::sub_mat ( std::set< std::string >  nucset)

Creates a sub-Material with only the nuclides present in nucset. Elements of this set may be in any form.

◆ to_atom_dens()

std::map< int, double > pyne::Material::to_atom_dens ( )

Returns a mapping of the nuclides in this material to their atom densities. This calculation is based off of the material's density.

◆ to_atom_frac()

std::map< int, double > pyne::Material::to_atom_frac ( )

Returns a mapping of the nuclides in this material to their atom fractions. This calculation is based off of the material's molecular weight.

◆ write_hdf5()

void pyne::Material::write_hdf5 ( std::string  filename,
std::string  datapath = "/mat_name",
float  row = -0.0,
int  chunksize = DEFAULT_MAT_CHUNKSIZE 
)

Writes this material out to an HDF5 file. This happens according to protocol 1.

Parameters
filenamePath on disk to the HDF5 file.
datapathPath to the the material in the file.
rowThe index to read out, may be negative. Also note that this is a float. A value of -0.0 indicates that the material should be appended to the end of the dataset.
chunksizeThe chunksize for all material data on disk. New write_hdf5 which fallback on the old one when required

◆ write_hdf5_datapath()

void pyne::Material::write_hdf5_datapath ( hid_t  db,
std::string  datapath,
float  row,
int  chunksize,
std::vector< int >  nuclides 
)

Writes this datapath to an HDF5 file. This happens according to protocol 1.

Parameters
dbHDF5 id for the open HDF5 file.
datapathPath to the the material in the file.
nucpathPath to the nuclides list in the file.
rowThe index to read out, may be negative. Also note that this is a float. A value of -0.0 indicates that the material should be appended to the end of the dataset.
chunksizeThe chunksize for all material data on disk. Only the nuclides present in the nuclides list can be part of the composition of the material, additional nuclides will be ignored, and a warning will be thrown

◆ write_hdf5_nucpath()

std::vector< int > pyne::Material::write_hdf5_nucpath ( hid_t  db,
std::string  nucpath 
)

Writes this nucpath to an HDF5 file. This happens according to protocol 1.

Parameters
dbHDF5 id for the open HDF5 file.
nucpathPath to the nuclides list in the file.
Returns
list of nuclide writen in the file (or the existing list if the nuclides list was already in the file

◆ xrays()

std::vector< std::pair< double, double > > pyne::Material::xrays ( )

Returns a list of x-rays average energies in keV and intensities in decays/s material unnormalized

Member Data Documentation

◆ atoms_per_molecule

double pyne::Material::atoms_per_molecule

The number of atoms per molecule.


The documentation for this class was generated from the following files: