Skip to content

Commit

Permalink
Add files
Browse files Browse the repository at this point in the history
  • Loading branch information
ab5424 committed Nov 4, 2021
1 parent 696c82d commit 41e4e94
Show file tree
Hide file tree
Showing 16 changed files with 150 additions and 83,396 deletions.
70 changes: 52 additions & 18 deletions autogabi/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,33 @@

class GBStructure:
"""
This class The :py:class:`polypy.read.Trajectory` class evaluates the positions
of all atoms in the simulation.
Args:
backend (:py:class:`str`): List of unique atom names in trajectory.
filename (:py:attr:`str`): Datatype of the original dataset
e.g. DL_POLY HISTORY or CONFIG.
This is the fundamental class of a grain boundary object.
"""

def __init__(self, backend, filename):
self.backend = backend
self.filename = filename
self.data = None

if self.backend not in ['ovito', 'pymatgen', 'babel', 'pyiron', 'ase']:
if self.backend not in ['ovito', 'pymatgen', 'babel', 'pyiron', 'ase', 'lammps']:
# Put error here
pass

if self.backend == 'ovito':
from ovito.io import import_file
self.pipeline = import_file(str(filename))

if self.backend == 'pymatgen':
from pymatgen.core import Structure
self.data.structure = Structure.from_file(filename)

def delete_particles(self, particle_type):
"""
Deletes a specific type of particles from a structure. This can be particularly useful if there is a mobile type
in the structure. Note that for ovito structures you need to make sure that type information is included.
Args:
particle_type (:py:class:`str`): Timestep of desired CONFIG.
particle_type (:py:class:`str`):
Returns:
config_trajectory (:py:class:`polypy.read.Trajectory`):
Trajectory object for desired CONFIG.
"""
if self.backend == "ovito":
from ovito.plugins.StdModPython import SelectTypeModifier, DeleteSelectedModifier
Expand All @@ -54,7 +51,7 @@ def assign_particle_types(frame, data):

self.pipeline.modifiers.append(assign_particle_types)

# Select oxygen ions and delete them
# Select atoms and delete them
self.pipeline.modifiers.append(SelectTypeModifier(
operate_on="particles",
property="Particle Type",
Expand All @@ -64,18 +61,19 @@ def assign_particle_types(frame, data):
self.pipeline.modifiers.append(DeleteSelectedModifier())

elif self.backend == 'pymatgen':
pass
self.data.structure.remove_species(particle_type)

elif self.backend == 'babel':
pass

def select_particles(self, list_ids, invert=False, delete=True, expand=True, expand_cutoff=3.2, neighbors=None,
iterations=1):
def select_particles(self, list_ids, invert=True, delete=True, expand=False, expand_cutoff=3.2,
nearest_neighbors=None, iterations=1):
"""
Selects particles by ID
Args:
nearest_neighbors:
delete:
iterations:
neighbors:
expand_cutoff:
expand:
invert:
Expand All @@ -95,10 +93,10 @@ def modify(frame, data):

if expand:
from ovito.plugins.ParticlesPython import ExpandSelectionModifier
if neighbors:
if nearest_neighbors:
self.pipeline.modifiers.append(
ExpandSelectionModifier(mode=ExpandSelectionModifier.ExpansionMode.Nearest,
num_neighbors=neighbors,
num_neighbors=nearest_neighbors,
iterations=iterations))
else:
self.pipeline.modifiers.append(
Expand All @@ -115,6 +113,7 @@ def _invert_selection(self, list_ids=None):
if self.backend == 'ovito':
from ovito.plugins.StdModPython import InvertSelectionModifier
self.pipeline.modifiers.append(InvertSelectionModifier())

if self.backend == 'pymatgen':
# Todo: Look which ids are in the list and invert by self.structure
pass
Expand Down Expand Up @@ -172,7 +171,7 @@ def set_analysis(self):
if self.backend == 'ovito':
self.data = self.pipeline.compute()

def get_bulk_ions(self):
def get_gb_atoms(self):

if self.backend == 'ovito':
if 'Structure Type' in self.data.particles.keys():
Expand All @@ -182,14 +181,49 @@ def get_bulk_ions(self):
df_gb = df[df['Structure Type'] == 0]
return list(df_gb['Particle Identifier'])

def get_bulk_atoms(self):

if self.backend == 'ovito':
if 'Structure Type' in self.data.particles.keys():
df = pd.DataFrame(list(zip(self.data.particles['Particle Identifier'],
self.data.particles['Structure Type'], )),
columns=['Particle Identifier', 'Structure Type'])
df_gb = df[df['Structure Type'] != 0]
return list(df_gb['Particle Identifier'])

def get_type(self, atom_type):

if self.backend == 'ovito':
# Currently doesn't work!
# def assign_particle_types(frame, data):
# atom_types = data.particles_.particle_types_
#
# self.pipeline.modifiers.append(assign_particle_types)
# self.set_analysis()
df = pd.DataFrame(list(zip(self.data.particles['Particle Identifier'],
self.data.particles['Particle Type'], )),
columns=['Particle Identifier', 'Particle Type'])
df_atom = df[df['Particle Type'].eq(atom_type)]
return list(df_atom['Particle Identifier'])

# Todo: Verkippungswinkel
# Todo: Grain Index

def get_fraction(self, numerator, denominator):

if self.backend == 'ovito':
num = sum([len(self.get_type(i)) for i in numerator])
den = sum([len(self.get_type(i)) for i in denominator])
return num/den



class GBStructureTimeseries(GBStructure):
"""
This is a class containing multiple snapshots from a time series.
"""
# Todo: get diffusion data
# Todo: differentiate between along/across GB

def remove_timesteps(self, timesteps_to_exclude):
"""
Expand Down
Empty file added autogabi/io/__init__.py
Empty file.
1 change: 1 addition & 0 deletions autogabi/minimiser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Minimiser for lammps, vasp, gulp
18 changes: 18 additions & 0 deletions autogabi/orientation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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
7 changes: 7 additions & 0 deletions autogabi/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,10 @@ def plot_face_order(data=None):

hist_plot = sns.displot(df, x="Max Face Order", discrete=True)
return hist_plot.fig


# TODO: Visualize Misorientation distribution function
# https://www.osti.gov/pages/servlets/purl/1657149
# https://mtex-toolbox.github.io/index.html

# TODO: get RDFs https://github.com/by256/rdfpy https://rdfpy.readthedocs.io/en/latest/introduction_and_examples.html#example-rdf-of-a-crystal-structure
91 changes: 72 additions & 19 deletions examples/basics_ovito.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit 41e4e94

Please sign in to comment.