jarvis.core.utils

Set of useful utility functions.

Module Contents

Functions

xml_to_dict(fname)

Parse XML file.

get_factors(x[, start])

Get factors of a number.

get_counts([array])

Get number of unique elements and their counts.

gcd(a, b)

Calculate the Greatest Common Divisor of a and b.

ext_gcd(a, b)

GCD module from ase.

rand_select([x])

Select randomly with index info.

rec_dict()

Make a recursion dictionary.

random_colors([number_of_colors])

Generate random colors for atom coloring.

get_angle([a, b, c])

Get angle between three vectors.

recast_array_on_uniq_array_elements([uniq, arr])

Recast array on uniq array elements.

lorentzian(x, y, x0, gamma)

Get Lorentzian of a function.

stringdict_to_xml([d, enforce_string])

Convert string dictionary to XML.

array_to_string([arr])

Convert 1D arry to string.

chunks(lst, n)

Split successive n-sized chunks from list.

check_match(a, b[, tol])

Check if a and b are the same, taking into account PBCs.

update_dict([main, extra])

Return update dictionary.

get_new_coord_for_xyz_sym([frac_coord, xyz_string])

Obtain new coord from xyz string.

check_duplicate_coords([coords, coord])

Check if a coordinate exists.

parse_xyz_string(xyz_string)

Convert xyz info to translation and rotation vectors.

operate_affine([cart_coord, affine_matrix])

Operate affine method.

gaussian(x, sigma)

Get Gaussian profile.

lorentzian2(x, gamma)

Get Lorentziann profile.

digitize_array([values, max_len])

Digitze an array.

bond_angle(dist1, dist2, bondx1, bondx2, bondy1, ...)

Get an angle.

check_url_exists([url])

Check if a url exists.

volumetric_grid_reshape([data, final_grid])

Reshape volumetric data.

cos_formula(a, b, c)

Get angle between three edges for oblique triangles.

jarvis.core.utils.xml_to_dict(fname)[source]

Parse XML file.

jarvis.core.utils.get_factors(x, start=2)[source]

Get factors of a number.

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.ext_gcd(a, b)[source]

GCD module from ase.

jarvis.core.utils.rand_select(x=[])[source]

Select randomly with index info.

jarvis.core.utils.rec_dict()[source]

Make a recursion dictionary.

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.lorentzian(x, y, x0, gamma)[source]

Get Lorentzian of a function.

jarvis.core.utils.stringdict_to_xml(d={}, enforce_string=False)[source]

Convert string dictionary to XML.

jarvis.core.utils.array_to_string(arr=[])[source]

Convert 1D arry to string.

jarvis.core.utils.chunks(lst, n)[source]

Split successive n-sized chunks from list.

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.update_dict(main={}, extra={})[source]

Return update dictionary.

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.operate_affine(cart_coord=[], affine_matrix=[])[source]

Operate affine method.

jarvis.core.utils.gaussian(x, sigma)[source]

Get Gaussian profile.

jarvis.core.utils.lorentzian2(x, gamma)[source]

Get Lorentziann profile.

jarvis.core.utils.digitize_array(values=[], max_len=10)[source]

Digitze an array.

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.

jarvis.core.utils.volumetric_grid_reshape(data=[], final_grid=[50, 50, 50])[source]

Reshape volumetric data.

jarvis.core.utils.cos_formula(a, b, c)[source]

Get angle between three edges for oblique triangles.