Source code for aim2dat.strct.ext_analysis.ffprint_order_p
"""Calculate f-fingerprint order parameters."""# Standard library importsfromtypingimportList,Tuple# Third party library importsimportnumpyasnp# Internal library importsfromaim2dat.strct.strctimportStructurefromaim2dat.strct.ext_analysis.decoratorimportexternal_analysis_methodfromaim2dat.strct.strct_prdfimport_calculate_weights
[docs]@external_analysis_methoddefcalculate_ffingerprint_order_p(structure:Structure,r_max:float=15.0,delta_bin:float=0.005,sigma:float=0.05,distinguish_kinds:bool=False,)->Tuple[float,List[float]]:""" Calculate order parameters for the total structure and for each individual site. The calculation is based on equation (5) in :doi:`10.1016/j.cpc.2010.06.007`. Parameters ---------- structure : aim2dat.strct.Structure Structure object. r_max : float (optional) Cut-off value for the maximum distance between two atoms in angstrom. delta_bin : float (optional) Bin size to descritize the function in angstrom. sigma : float (optional) Smearing parameter for the Gaussian function. distinguish_kinds: bool (optional) Whether different kinds should be distinguished e.g. Ni0 and Ni1 would be considered as different elements if ``True``. Returns ------- total_order_p : float Order parameter of the structure. atomic_fingerprints : list List of order parameters for each atomic site. """def_calc_order_p(delta_bin,fprint,weights,cell_v,n_atoms):order_p=0.0forel_pairinfprint["fingerprints"].keys():prefactor=weights[el_pair]*delta_bin*(cell_v/n_atoms)**(1.0/3.0)order_p+=prefactor*np.linalg.norm(np.array(fprint["fingerprints"][el_pair]))**2returnorder_pfprints=structure.calculate_ffingerprint(r_max=r_max,delta_bin=delta_bin,sigma=sigma,distinguish_kinds=distinguish_kinds)element_dict=structure._element_dictifdistinguish_kinds:element_dict=structure._kind_dictcell_v=structure["cell_volume"]weights=_calculate_weights(element_dict)n_atoms=sum(len(sites)forsitesinelement_dict.values())el_order_p=_calc_order_p(delta_bin,fprints[0],weights,cell_v,n_atoms)site_order_p=[_calc_order_p(delta_bin,fprint,weights,cell_v,n_atoms)forfprintinfprints[1]]returnel_order_p,(el_order_p,site_order_p)