import numpy as np
import escape as esc
esc.require('0.9.7')
Loading material database from /home/dkor/Data/Development/workspace_escape/escape/notebooks/repository/scattering/materials.db
Overview of Material Database Module (MDB)¶
Material database module escape.scattering.mdb
provides a set of tools to create and manage material database with xrays and neutrons scattering data. The module creates instance of the default database default_mdb
, which is used by other modules of ESCAPE
package. There are two types of materials supported by the MDB
: amorphous and crystal. In the next releases of ESCAPE
package, the module will be extended to support alloys.
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 materials.yaml
. 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 :meth:copy_db
method.
esc.copy_db(overwrite=True)
Material database file materials.yaml has been successfully copied to /home/dkor/Data/Development/workspace_escape/escape/notebooks/repository/scattering
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.
In the newly created materials.yaml file, the user can add new material records or edit existing ones.
As an example we add a new record:
---
name: Polybutadiene_custom
type: amorphous
density: 0.436
atoms:
- C:
repeat: 4
- H:
repeat: 6
In order to use it, we need to create a new instance of the material database:
custom_mdb = esc.mdb()
mat = esc.amorphous("Polybutadiene_custom", density="mdb", mdb=custom_mdb)
print(mat)
Loading material database from /home/dkor/Data/Development/workspace_escape/escape/notebooks/repository/scattering/materials.db Name: Polybutadiene_custom Parameters number: 1 Parameter Value +- Error Units Fixed Polybutadiene_custom density 0.436 +- 0 g/cm^3 0
The new material records can be added inline to the default or custom material database using the :meth:add_material
method.
In this case the new material record is not stored in the YAML file, but is added to the material database instance.
It is useful for testing purposes or if the user prefers to work with temporary material records only.
The information about new material records is lost when the material database instance is deleted.
from escape.scattering.mdb import default_mdb
rec = {
"name": "Polybutadiene_custom",
"type": "amorphous",
"density": 0.436,
"atoms":[
{"C": {"repeat":4}},
{"H": {"repeat":6}},
]
}
default_mdb.add(rec)
# mdb=default_mdb by default
mat = esc.amorphous("Polybutadiene_custom", density="mdb")
print(mat)
Name: Polybutadiene_custom Parameters number: 1 Parameter Value +- Error Units Fixed Polybutadiene_custom density 0.436 +- 0 g/cm^3 0