PyNE C++
Public Types | Public Member Functions | List of all members
pyne::MaterialLibrary Class Reference

Public Types

typedef mat_map::iterator iterator
 
typedef mat_map::const_iterator const_iterator
 

Public Member Functions

 MaterialLibrary (const std::string &fname, const std::string &datapath)
 Constructor from file. More...
 
void from_hdf5 (const std::string &filename, const std::string &datapath)
 loads the pyne materials in map of name vs Material More...
 
void from_json (const std::string &filename)
 loads the pyne materials in map of name vs Material / More...
 
void load_json (Json::Value json)
 
Json::Value dump_json ()
 
void write_json (const std::string &filename)
 
void write_hdf5 (const std::string &filename, const std::string &datapath="/materials", bool h5_overwrite=false) const
 Writes MaterialLibrary out to an HDF5 file. This happens according to protocol 1. Writting in a file already containing This might cause issue to read material already present in the datapath, and for the new materials if written in the same datapath. More...
 
void write_hdf5_nucpath (hid_t db, std::string nucpath) const
 Writes this nucpath to an HDF5 file. This happens according to protocol 1. More...
 
void merge (const pyne::MaterialLibrary &mat_lib)
 Merge a material library into the current one. More...
 
void merge (pyne::MaterialLibrary *mat_lib)
 Merge a material library into the current one. More...
 
void add_material (pyne::Material mat)
 Add a material to the library. More...
 
void add_material (const std::string &mat_name, const pyne::Material &mat)
 Add a material to the library. More...
 
void del_material (const std::string &mat_name)
 remove a material of the Library by name More...
 
pyne::Material get_material (const std::string &mat_name) const
 remove a material of the Library by name More...
 
pyne::shr_mat_ptr get_material_ptr (const std::string &mat_name) const
 Get a material of the Library by name. More...
 
std::string ensure_material_name_and_number (pyne::Material &mat) const
 Return a material material number, ensure it exist if it does not exist build it using the material number, if material number is not defined, define it accordingly to the material library. More...
 
int ensure_material_number (pyne::Material &mat) const
 Return a material material number, ensure it exist as an int, if it exist as a string convert it into int and update the material. More...
 
pyne::mat_map get_mat_library () const
 Get the material library itself. More...
 
pyne::matname_set get_keylist () const
 Get the list of materials in the Library. More...
 
pyne::nuc_set get_nuclist () const
 Get the list of nuclides in the Library. More...
 
iterator begin ()
 
iterator end ()
 
const_iterator cbegin () const
 
const_iterator cend () const
 
std::size_t size () const
 
bool emtpy () const
 
std::size_t count (std::string mat_name) const
 
std::shared_ptr< Material > & operator[] (const std::string &k)
 
std::shared_ptr< Material > & operator[] (std::string &&k)
 

Member Typedef Documentation

◆ iterator

typedef mat_map::iterator pyne::MaterialLibrary::iterator

Set of method allowing MaterialLibrary to behave like a undordered_map, pointing directly to the nested material_library

Constructor & Destructor Documentation

◆ MaterialLibrary()

pyne::MaterialLibrary::MaterialLibrary ( const std::string &  fname,
const std::string &  datapath 
)

Constructor from file.

Parameters
filenamepath to file on disk, this file may be either in plaintext or HDF5 format.
datapathPath to the materials in the file.

Member Function Documentation

◆ add_material() [1/2]

void pyne::MaterialLibrary::add_material ( pyne::Material  mat)

Add a material to the library.

Parameters
matmaterial to add

◆ add_material() [2/2]

void pyne::MaterialLibrary::add_material ( const std::string &  mat_name,
const pyne::Material mat 
)

Add a material to the library.

Parameters
mat_namename of the material to add(will overwrite material name if it already has one)
matmaterial to add

◆ del_material()

void pyne::MaterialLibrary::del_material ( const std::string &  mat_name)

remove a material of the Library by name

Parameters
mat_namename of the material to remove

◆ ensure_material_name_and_number()

std::string pyne::MaterialLibrary::ensure_material_name_and_number ( pyne::Material mat) const

Return a material material number, ensure it exist if it does not exist build it using the material number, if material number is not defined, define it accordingly to the material library.

Parameters
matmaterial to check
Returns
std::string

◆ ensure_material_number()

int pyne::MaterialLibrary::ensure_material_number ( pyne::Material mat) const

Return a material material number, ensure it exist as an int, if it exist as a string convert it into int and update the material.

Parameters
matmaterial to check
Returns
int

◆ from_hdf5()

void pyne::MaterialLibrary::from_hdf5 ( const std::string &  filename,
const std::string &  datapath 
)

loads the pyne materials in map of name vs Material

Parameters
filenamePath on disk to the HDF5 file.
datapathPath to the materials in the file.
protocolFlag for layout of material on disk.

◆ from_json()

void pyne::MaterialLibrary::from_json ( const std::string &  filename)

loads the pyne materials in map of name vs Material /

Parameters
filenamePath on disk to the json file.

◆ get_keylist()

pyne::matname_set pyne::MaterialLibrary::get_keylist ( ) const
inline

Get the list of materials in the Library.

Returns
std::set<std::string>

◆ get_mat_library()

pyne::mat_map pyne::MaterialLibrary::get_mat_library ( ) const
inline

Get the material library itself.

Returns
std::map<std::string, pyne::Material>

◆ get_material()

pyne::Material pyne::MaterialLibrary::get_material ( const std::string &  mat_name) const

remove a material of the Library by name

Parameters
mat_namename of the material to remove

◆ get_material_ptr()

pyne::shr_mat_ptr pyne::MaterialLibrary::get_material_ptr ( const std::string &  mat_name) const

Get a material of the Library by name.

Parameters
mat_namename of the material to return

◆ get_nuclist()

pyne::nuc_set pyne::MaterialLibrary::get_nuclist ( ) const
inline

Get the list of nuclides in the Library.

Returns
std::set<int>

◆ merge() [1/2]

void pyne::MaterialLibrary::merge ( const pyne::MaterialLibrary mat_lib)

Merge a material library into the current one.

Parameters
mat_librarypyne material library to merge

◆ merge() [2/2]

void pyne::MaterialLibrary::merge ( pyne::MaterialLibrary mat_lib)

Merge a material library into the current one.

Parameters
mat_librarypointer to the pyne material library to merge

◆ write_hdf5()

void pyne::MaterialLibrary::write_hdf5 ( const std::string &  filename,
const std::string &  datapath = "/materials",
bool  h5_overwrite = false 
) const

Writes MaterialLibrary out to an HDF5 file. This happens according to protocol 1. Writting in a file already containing This might cause issue to read material already present in the datapath, and for the new materials if written in the same datapath.

Parameters
filenamePath on disk to the HDF5 file.
datapathPath to the the material in the file.
h5_overwritebool to decide if existing path should be overwritten

◆ write_hdf5_nucpath()

void pyne::MaterialLibrary::write_hdf5_nucpath ( hid_t  db,
std::string  nucpath 
) const

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.

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