import os
import fastatomstruct as fs
from black import format_str, FileMode
from pyo3_stubgen import genentry
out = [
"from typing import List, Tuple, Union, Optional\n",
"import ase",
"import fastatomstruct",
"import numpy as np\n",
]
out.append(
"""class Filter:
\"\"\"Filter atoms based on tags.
On creation of a :code:`Filter`, you have to specify which atoms
should be regarded as "center" atoms and as "other" atoms, respectively.
Atoms that have a tag other than :code:`center` or :code:`other`
will be disregarded. The last argument (:code:`center_is_other`, a boolean)
specifies whether "center" atoms should also be regarded as "other" atoms.
Examples
--------
Suppose that we have a NaCl system and want to calculate the **partial
Na-Na, Na-Cl and Cl-Cl pair correlation functions**. This can be achieved
by first tagging all Cl atoms with tag 1:
>>> from ase.build import bulk
>>> a = 5.64
>>> nacl = bulk("NaCl", "rocksalt", a=a) * (5, 5, 5)
>>> nacl.rattle()
>>> tags = nacl.get_tags()
>>> tags[nacl.numbers == 17] = 1
>>> nacl.set_tags(tags)
For the partial Na-Cl correlation function, we can then use
:code:`Filter(0, 1, False)`:
>>> import fastatomstruct as fs
>>> r_na_cl, rdf_na_cl = fs.radial_distribution_function(
>>> nacl, 10, 200, fs.Filter(0, 1, False)
>>> )
Analogously, the Na-Na pair correlation function is
>>> import fastatomstruct as fs
>>> r_na_na, rdf_na_na = fs.radial_distribution_function(
>>> nacl, 10, 200, fs.Filter(0, 0, False)
>>> )
The :code:`center_is_other` argument will not matter in this case.
Now suppose you want to calculate the **partial three-body correlation**
around the Na atoms (including atoms of any kind around those atoms).
This can be achieved as follows:
>>> tbc = fs.tbc(nacl, 3, 10, 250, fs.Filter(0, 1, True)))
\"\"\"
...
"""
)
for f in [
fs.q_l_global,
fs.q_l,
fs.q_l_dot,
fs.q_tetrahedral,
fs.bond_length_ratio,
fs.bond_length_ratio_list,
fs.altbc,
fs.tbc,
fs.distances,
fs.all_distances,
fs.r_theta_phi,
fs.distance_vectors,
fs.all_distance_vectors,
fs.neighbour_lists,
fs.coordination_numbers,
fs.bond_angle_distribution,
fs.radial_distribution_function,
fs.mean_squared_displacement_single,
fs.squared_displacement_single,
fs.non_gaussian_alpha2,
fs.non_gaussian_alpha2_single,
fs.incoherent_intermediate_scattering,
fs.coherent_intermediate_scattering,
fs.overlap_q,
fs.overlap_q_self,
fs.overlap_q_self_atomic,
fs.overlap_q_distinct,
fs.overlap_q_single,
fs.overlap_q_single_self,
fs.overlap_q_single_distinct,
fs.fourpoint_susceptibility,
fs.fourpoint_susceptibility_self,
fs.vacf,
fs.viscosity,
fs.viscosity_average,
]:
pyi = genentry(f)
pyi = pyi.splitlines()
pyi = "\n".join(["\ndef" + pyi[2][3:] + ":", " \"\"\"" + pyi[4], *pyi[5:]])
out.append(pyi)
out.append(" ...\n")
pyi = "\n".join(out)
with open("python/fastatomstruct/fastatomstruct.pyi", "w") as f:
f.write(pyi)
os.system("pyright --createstub fastatomstruct")
os.rename("typings/fastatomstruct/__init__.pyi", "python/fastatomstruct/__init__.pyi")
os.remove("typings/fastatomstruct/fastatomstruct.pyi")
os.removedirs("typings/fastatomstruct")
os.system("black python/fastatomstruct")