-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pyscal solid liquid #414
Pyscal solid liquid #414
Changes from all commits
ddace68
9bf9948
0d769c2
587a8e3
5e16a53
4e42254
e48212e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,15 +43,10 @@ def get_steinhardt_parameter_structure(atoms, neighbor_method="cutoff", cutoff=0 | |
numpy.ndarray: (number of q's, number of atoms) shaped array of q parameters | ||
numpy.ndarray: If `clustering=True`, an additional per-atom array of cluster ids is also returned | ||
""" | ||
s.publication_add(publication()) | ||
sys = pyiron_to_pyscal_system(atoms) | ||
q = (4, 6) if q is None else q | ||
if clustering == False: | ||
n_clusters = None | ||
sys = pc.System() | ||
sys.read_inputfile( | ||
pyiron_atomistics.atomistics.structure.atoms.pyiron_to_ase(atoms), | ||
format='ase' | ||
) | ||
|
||
sys.find_neighbors( | ||
method=neighbor_method, | ||
|
@@ -90,9 +85,7 @@ def analyse_centro_symmetry(atoms, num_neighbors=12): | |
Returns: | ||
csm (list) : list of centrosymmetry parameter | ||
""" | ||
s.publication_add(publication()) | ||
sys = pc.System() | ||
sys.read_inputfile(atoms, format="ase") | ||
sys = pyiron_to_pyscal_system(atoms) | ||
return np.array(sys.calculate_centrosymmetry(nmax=num_neighbors)) | ||
|
||
|
||
|
@@ -113,9 +106,7 @@ def analyse_diamond_structure(atoms, mode="total", ovito_compatibility=False): | |
Returns: | ||
(depends on `mode`) | ||
""" | ||
s.publication_add(publication()) | ||
sys = pc.System() | ||
sys.read_inputfile(atoms, format="ase") | ||
sys = pyiron_to_pyscal_system(atoms) | ||
diamond_dict = sys.identify_diamond() | ||
|
||
ovito_identifiers = [ | ||
|
@@ -186,7 +177,7 @@ def analyse_cna_adaptive(atoms, mode="total", ovito_compatibility=False): | |
Returns: | ||
(depends on `mode`) | ||
""" | ||
s.publication_add(publication()) | ||
sys = pyiron_to_pyscal_system(atoms) | ||
if mode not in ["total", "numeric", "str"]: | ||
raise ValueError("Unsupported mode") | ||
|
||
|
@@ -199,8 +190,6 @@ def analyse_cna_adaptive(atoms, mode="total", ovito_compatibility=False): | |
'CommonNeighborAnalysis.counts.ICO' | ||
] | ||
|
||
sys = pc.System() | ||
sys.read_inputfile(atoms, format="ase") | ||
cna = sys.calculate_cna() | ||
|
||
if mode == "total": | ||
|
@@ -234,13 +223,63 @@ def analyse_voronoi_volume(atoms): | |
Args: | ||
atoms : (pyiron_atomistics.structure.atoms.Atoms): The structure to analyze. | ||
""" | ||
s.publication_add(publication()) | ||
sys = pc.System() | ||
sys.read_inputfile(atoms, format="ase") | ||
sys = pyiron_to_pyscal_system(atoms) | ||
sys.find_neighbors(method="voronoi") | ||
atoms = sys.atoms | ||
return np.array([atom.volume for atom in atoms]) | ||
|
||
def pyiron_to_pyscal_system(atoms): | ||
""" | ||
Converts atoms to ase atoms and than to a pyscal system. | ||
Also adds the pyscal publication. | ||
|
||
Args: | ||
atoms (pyiron atoms): Structure to convert. | ||
|
||
Returns: | ||
Pyscal system: See the pyscal documentation. | ||
""" | ||
s.publication_add(publication()) | ||
sys = pc.System() | ||
sys.read_inputfile( | ||
pyiron_atomistics.atomistics.structure.atoms.pyiron_to_ase(atoms), | ||
format="ase", | ||
) | ||
return sys | ||
|
||
def analyse_find_solids(atoms, neighbor_method="cutoff", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This returns the number of atoms that are inside a solid phase? If so it'd cool to also return an index array, that shows which are solid and which are liquid, maybe behind a switch, like the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This only returns the number by default, but when using return_system=True it returns the complete pyscal system object, which allows to get the indices. I thought this is the most simple in the default case and the most flexible approach when using the return_system option. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I had simply missed that while skimming. Since anything might happen while changing from pyiron to pyscal returning the full system is ok, I suppose. |
||
cutoff=0, bonds=0.5, | ||
threshold=0.5, avgthreshold=0.6, | ||
cluster=False, q=6, right=True, | ||
return_sys=False, | ||
): | ||
""" | ||
Get the number of solids or the corresponding pyscal system. | ||
Calls necessary pyscal methods as described in https://pyscal.org/en/latest/methods/03_solidliquid.html. | ||
|
||
Args: | ||
neighbor_method (str, optional): Method used to get neighborlist. See pyscal documentation. Defaults to "cutoff". | ||
cutoff (int, optional): Adaptive if 0. Defaults to 0. | ||
bonds (float, optional): Number or fraction of bonds to consider atom as solid. Defaults to 0.5. | ||
threshold (float, optional): See pyscal documentation. Defaults to 0.5. | ||
avgthreshold (float, optional): See pyscal documentation. Defaults to 0.6. | ||
cluster (bool, optional): See pyscal documentation. Defaults to False. | ||
q (int, optional): Steinhard parameter to calculate. Defaults to 6. | ||
right (bool, optional): See pyscal documentation. Defaults to True. | ||
return_sys (bool, optional): Whether to return number of solid atoms or pyscal system. Defaults to False. | ||
|
||
Returns: | ||
int: number of solids, | ||
pyscal system: pyscal system when return_sys=True | ||
""" | ||
sys = pyiron_to_pyscal_system(atoms) | ||
sys.find_neighbors(method=neighbor_method, cutoff=cutoff) | ||
sys.find_solids(bonds=bonds, threshold=threshold, avgthreshold=avgthreshold, q=q, cutoff=cutoff, cluster=cluster, right=right) | ||
if return_sys: | ||
return sys | ||
atoms = sys.atoms | ||
solids = [atom for atom in atoms if atom.solid] | ||
return len(solids) | ||
|
||
def publication(): | ||
return { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I misunderstood the method, I thought
or
should beof
or some such... I promise to read more carefully next time. ;)