Skip to content

Commit

Permalink
Modifiers for structure analysis.
Browse files Browse the repository at this point in the history
  • Loading branch information
ab5424 committed Nov 16, 2021
1 parent 41e4e94 commit d5e911b
Show file tree
Hide file tree
Showing 7 changed files with 194 additions and 19 deletions.
81 changes: 81 additions & 0 deletions autogabi/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,87 @@ def perform_voroni_analysis(self):
# https://tess.readthedocs.io/en/stable/
# https://github.com/materialsproject/pymatgen/blob/v2022.0.14/pymatgen/analysis/structure_analyzer.py#L61-L174

def perform_ptm(self, enabled: list = ['fcc', 'hpc', 'bcc'], compute: bool=True, *args, **kwargs):
"""
Args:
enabled (list): List of strings for enabled structure types. Possible values:
fcc-hcp-bcc-ico-sc-dcub-dhex-graphene
output_deformation_gradient = False
output_interatomic_distance = False
output_ordering = False
output_orientation = False
output_rmsd = False
rmsd_cutoff = 0.1
Returns:
"""

if self.backend == 'ovito':

from ovito.plugins.ParticlesPython import PolyhedralTemplateMatchingModifier
ptm = PolyhedralTemplateMatchingModifier(*args, **kwargs)

# Enabled by default: FCC, HCP, BCC
if 'fcc' not in enabled:
ptm.structures[PolyhedralTemplateMatchingModifier.Type.FCC].enabled = False
if 'hcp' not in enabled:
ptm.structures[PolyhedralTemplateMatchingModifier.Type.HCP].enabled = False
if 'bcc' not in enabled:
ptm.structures[PolyhedralTemplateMatchingModifier.Type.BCC].enabled = False
if 'ico' in enabled:
ptm.structures[PolyhedralTemplateMatchingModifier.Type.ICO].enabled = True
if 'sc' in enabled:
ptm.structures[PolyhedralTemplateMatchingModifier.Type.SC].enabled = True
if 'dcub' in enabled:
ptm.structures[PolyhedralTemplateMatchingModifier.Type.CUBIC_DIAMOND].enabled = True
if 'dhex' in enabled:
ptm.structures[PolyhedralTemplateMatchingModifier.Type.HEX_DIAMOND].enabled = True
if 'graphene' in enabled:
ptm.structures[PolyhedralTemplateMatchingModifier.Type.GRAPHENE].enabled = True

self.pipeline.modifiers.append(ptm)

if compute:
self.data = self.pipeline.compute()

elif self.backend == 'lammps':
# https://docs.lammps.org/compute_ptm_atom.html
pass
else:
# print error
pass

def perform_ajm(self):
# AcklandJonesModifier
pass

def get_distinct_grains(self, *args, **kwargs):
"""
Get distinct grains from the structure.
Args:
ovito:
algorithm = GrainSegmentationModifier.Algorithm.GraphClusteringAuto
color_particles = True
handle_stacking_faults = True
merging_threshold = 0.0
min_grain_size = 100
orphan_adoption = True
Returns:
"""

if self.backend == 'ovito':
from ovito.plugins.CrystalAnalysisPython import GrainSegmentationModifier
gsm = GrainSegmentationModifier(*args, **kwargs)
self.pipeline.modifiers.append(gsm)
self.data = self.pipeline.compute()



def set_analysis(self):

if self.backend == 'ovito':
Expand Down
Empty file removed autogabi/io/__init__.py
Empty file.
Empty file removed autogabi/io/inputs.py
Empty file.
Empty file removed autogabi/io/outputs.py
Empty file.
2 changes: 1 addition & 1 deletion autogabi/minimiser.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Minimiser for lammps, vasp, gulp
# Minimiser for lammps, vasp, gulp
37 changes: 19 additions & 18 deletions autogabi/orientation.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# Get grain orientation

# https://github.com/paulhof/GraDe-A
# Centrosymetric parameter


# Polyhedral template matching is implemented in ovito, ASAP, and LAMMPS
# P. M. Larsen, S. Schmidt, J. Schiøtz, Modelling Simul. Mater. Sci. Eng. 2016, 24, 055007.
# https://docs.lammps.org/compute_ptm_atom.html

def get_grain_orientation(backend):
if backend == 'ovito':
# First, perform PTM
# Iterate over all ions to get grains
# Pick one fcc ion, if > 2 ffc neighbors, count to grain, otherwise disregard
# Get average

return None
# Get grain orientation

# https://github.com/paulhof/GraDe-A
# Centrosymetric parameter


# Polyhedral template matching is implemented in ovito, ASAP, and LAMMPS
# P. M. Larsen, S. Schmidt, J. Schiøtz, Modelling Simul. Mater. Sci. Eng. 2016, 24, 055007.
# https://docs.lammps.org/compute_ptm_atom.html

def get_grain_orientation(backend):
if backend == 'ovito':

# First, perform PTM
# Iterate over all ions to get grains
# Pick one fcc ion, if > 2 ffc neighbors, count to grain, otherwise disregard
# Get average

return None
93 changes: 93 additions & 0 deletions examples/grain_analysis.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"collapsed": true,
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"This notebook demonstrates how Auto-GABI can be used to get distinct grains and their properties"
]
},
{
"cell_type": "code",
"execution_count": 1,
"outputs": [],
"source": [
"from analysis import GBStructure\n",
"import numpy as np"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "markdown",
"source": [],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 4,
"outputs": [],
"source": [
"gb = GBStructure('ovito', 'LSF_supercell_md3.lmp')\n",
"gb.delete_particles('O')\n",
"gb.perform_ptm(\n",
" enabled = ['bcc'],\n",
" output_orientation=True,\n",
" rmsd_cutoff = 0.15)\n",
"gb.set_analysis()"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 5,
"outputs": [],
"source": [
"gb.get_distinct_grains(min_grain_size=10)"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
}
],
"metadata": {
"kernelspec": {
"name": "pycharm-1f46a509",
"language": "python",
"display_name": "PyCharm (03_postprocessing)"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 0
}

0 comments on commit d5e911b

Please sign in to comment.