Material database module.¶
This module provides access to the material database.
The material database is a collection of material records. Each record describes a material and contains the following fields:
name
: material nametype
: material type, eithercrystal
oramorphous
density
: material density in g/cm^3atoms
: list of atoms in the material. Each atom is described by a dictionary with the following fields:symbol
: atom symbolx
: x coordinate of the atom in the unit celly
: y coordinate of the atom in the unit cellz
: z coordinate of the atom in the unit cellocc
: occupancy of the atom in the unit cellrepeat
: number of atoms in the unit cell
The material database is stored in a YAML file. The file contains a list of material records. The user can add new records to the database by editing a copy of the YAML material database file.
To get a copy of the material database file, use the copy_db()
method.
- Example:
>>> from escape.scattering.mdb import copy_db >>> copy_db()
The copy of the material database file is stored in the current working directory.
In order to compile the new material database, the user should create an instance of the new material database using
mdb()
method. This method will look for the YAML material database file in the current working directory and will
compile the material database from the YAML file. The compiled material database is stored in the current working
directory and is used by default. If the local MDB file is not found, the method will look for the MDB file in the
specific folder of the package.
- escape.scattering.mdb.mdb(mdbdir=None)¶
Create a material database object.
- Parameters:
- mdbdirstr
Path to the directory with the material database file.
- Returns:
Material database object.
- escape.scattering.mdb.copy_db(overwrite=False)¶
Copy the material database file to the current working directory.
- escape.scattering.mdb.neutrons(wavelength, units='angstrom', name='Neutron source')¶
Create a neutron source object.
- Parameters:
- wavelengthfloat
Wavelength of the neutron radiation.
- unitsstr
Units of the wavelength, ‘angstrom’ or ‘nm’.
- Returns:
Neutron source object.
- escape.scattering.mdb.xrays(wavelength, units='angstrom', name='X-ray source')¶
Create an X-ray source object.
- Parameters:
- wavelengthfloat
Wavelength of the X-ray radiation.
- unitsstr
Units of the wavelength, ‘angstrom’ or ‘nm’.
- Returns:
X-ray source object.
- class escape.scattering.mdb.mdb_obj¶
This object represents a material database.
- ABSORPTION_WAVELENGTH = 1.798¶
- DATADIR = 'mdb'¶
- ELEMENTSDBFN = 'elements.db'¶
- MATERIALSDBFN = 'materials.db'¶
- MATERIALSYAMLFN = 'materials.yaml'¶
- add(self, dict rec)¶
Add a material record to the database.
- Parameters:
- recdict
Material record.
- amorph_density(self, unicode amorph)¶
- amorphs¶
Returns list of amorphous materials names in the database. :returns:
list of strings
- compile_elements_db(self, datadir, dbfn)¶
Compile the elements database from the data files in the given directory.
- Parameters:
- datadirstr
Path to the directory with the data files.
- dbfnstr
Name of the elements database file.
- compile_materials_db(self, datadir, mdbfn)¶
Compile the materials database from the data files in the given directory.
- Parameters:
- datadirstr
Path to the directory with the data files.
- mdbfnstr
Name of the materials database file.
- copy_db(type cls, overwrite=False)¶
Copy the material database file to the current working directory.
- crystal_density(self, unicode crystal)¶
- crystals¶
Returns list of crystal materials names in the database. :returns:
list of strings
- load_elements_db(self, unicode dbrelpath, unicode escdir)¶
- load_materials_db(self, unicode datadir, unicode dbfn, unicode escdir)¶
- parse_element(self, symbol)¶
- sf(self, unicode element, source_obj src, Q=None)¶
- class escape.scattering.mdb.source_obj¶
This object represents a source of radiation.
- type¶
Returns type of the source. :returns:
string value
- units¶
Returns units of the source. :returns:
string value
- wavelength¶
Returns wavelength of the source. :returns:
double value
- exception escape.scattering.mdb.MdbError¶