MaterSim / PyXtal

A code to generate atomic structure with symmetry
MIT License
252 stars 67 forks source link

Tolerance_matrix class #40

Closed scottfredericks closed 5 years ago

scottfredericks commented 5 years ago

@qzhu2017 As discussed in person, I would like to create a tolerance matrix class for custom distance checking. This will allow users to use different inter-atomic distance tolerances, or check distances for specific systems like metals. Some desired features are:

Also, within the random_crystal and molecular_crystal classes, we should implement a custom print function which shows the used tolerances. We can have an attribute 'random_crystal.tolerances' that prints the tolerances for the atom-atom pairs which are present within the crystal.

qzhu2017 commented 5 years ago

@scottfredericks This is exactly what I want!

scottfredericks commented 5 years ago

@qzhu2017 I have implemented this class as "Tol_matrix". By default, we simply use the average of the covalent radii between two atoms. The class stores the tolerance matrix, the custom values used, and the atomic radius type. There is a print_all function which displays this information. You may specify custom values in 3 ways:

1) by using the method set_tol(species1, species2, value). This automatically sets the inverse pair as well - for example, specifying the C-H bond is equivalent to specifying the H-C bond 2) during initialization, by passing a list of tuples which can be passed to set_tol 3) using tol_matrix.from_radii, which creates a custom tol_matrix object using a list of atomic radii, starting with Hydrogen

For all methods in the class, you are free to specify an atomic specie using the atomic number, atomic symbol, atomic name, Element object, or pymatgen Specie object.

I will try to add this to the documentation tonight, similar to the current explanation of the Lattice class.

Also, I would like to add a "metallic" profile to the Tol_matrix class. For now, I will just use the data from the Wikipedia page: https://en.wikipedia.org/wiki/Atomic_radii_of_the_elements_(data_page) and just use the covalent radius for atoms without metallic radius data. If you know of a better source, please let me know.

Also, I want to double check that the following information is correct:

1) For atomic crystals, we use the average of the covalent radii: tol = 0.5 * (r1 + r2)

2) For molecular crystals, we 1.2 times the sum of the covalent radii: tol = 1.2 * (r1 + r2)

3) For metallic crystals, we use the average of the metallic radii: tol = 0.5 * (r1 + r2)

scottfredericks commented 5 years ago

@qzhu2017 I have added a metallic prototype. Also, I have added to_file and from_file methods. These just use np.load and np.save. Since the files are only about 100 kb, I think this shouldn't be an issue. I have added these changes to the documentation.