jarvis.core.utils
¶
Set of useful utility functions.
Module Contents¶
Functions¶
|
Parse XML file. |
|
Get factors of a number. |
|
Get number of unique elements and their counts. |
|
Calculate the Greatest Common Divisor of a and b. |
|
GCD module from ase. |
|
Select randomly with index info. |
|
Make a recursion dictionary. |
|
Generate random colors for atom coloring. |
|
Get angle between three vectors. |
|
Recast array on uniq array elements. |
|
Get Lorentzian of a function. |
|
Convert string dictionary to XML. |
|
Convert 1D arry to string. |
|
Split successive n-sized chunks from list. |
|
Check if a and b are the same, taking into account PBCs. |
|
Return update dictionary. |
|
Obtain new coord from xyz string. |
|
Check if a coordinate exists. |
|
Convert xyz info to translation and rotation vectors. |
|
Operate affine method. |
|
Get Gaussian profile. |
|
Get Lorentziann profile. |
|
Digitze an array. |
|
Get an angle. |
|
Check if a url exists. |
|
Reshape volumetric data. |
|
Get angle between three edges for oblique triangles. |
- jarvis.core.utils.get_counts(array=['W', 'W', 'Mo', 'Mo', 'S', 'S'])[source]¶
Get number of unique elements and their counts.
Uses OrderedDict.
- Args:
array of elements
- Returns:
ordereddict, e.g.OrderedDict([(‘W’, 2), (‘Mo’, 2), (‘S’, 2)])
- jarvis.core.utils.gcd(a, b)[source]¶
Calculate the Greatest Common Divisor of a and b.
Unless b==0, the result will have the same sign as b (so that when b is divided by it, the result comes out positive).
- jarvis.core.utils.random_colors(number_of_colors=110)[source]¶
Generate random colors for atom coloring.
- jarvis.core.utils.get_angle(a=np.array([1, 2, 3]), b=np.array([4, 5, 6]), c=np.array([7, 8, 9]))[source]¶
Get angle between three vectors.
- jarvis.core.utils.recast_array_on_uniq_array_elements(uniq=['Si', 'Al', 'O'], arr=['Si', 'Si', 'Al', 'Al', 'Si', 'O', 'O', 'O', 'O'])[source]¶
Recast array on uniq array elements.
- jarvis.core.utils.stringdict_to_xml(d={}, enforce_string=False)[source]¶
Convert string dictionary to XML.
- jarvis.core.utils.check_match(a, b, tol=1e-08)[source]¶
Check if a and b are the same, taking into account PBCs.
- jarvis.core.utils.get_new_coord_for_xyz_sym(frac_coord=[], xyz_string='')[source]¶
Obtain new coord from xyz string.
- jarvis.core.utils.check_duplicate_coords(coords=[], coord=[])[source]¶
Check if a coordinate exists.
- jarvis.core.utils.parse_xyz_string(xyz_string)[source]¶
Convert xyz info to translation and rotation vectors.
Adapted from pymatgen. Args:
- xyz_string: string of the form ‘x, y, z’, ‘-x, -y, z’,
‘-2y+1/2, 3x+1/2, z-y+1/2’, etc.
- Returns:
translation and rotation vectors.
- jarvis.core.utils.bond_angle(dist1, dist2, bondx1, bondx2, bondy1, bondy2, bondz1, bondz2)[source]¶
Get an angle.
- jarvis.core.utils.check_url_exists(url='https://www.ctcms.nist.gov/~knc6/static/JARVIS-DFT/JVASP-77580.xml')[source]¶
Check if a url exists.