Commit b7c75b6c authored by pmla's avatar pmla
Browse files

Added compute for Polyhedral Template Matching

parent a33f45f1
Loading
Loading
Loading
Loading
+6.67 KiB
Loading image diff...
+21 −0
Original line number Diff line number Diff line
\documentclass[12pt,article]{article}

\usepackage{indentfirst}
\usepackage{amsmath}

\newcommand{\set}[1]{\ensuremath{\mathbf{#1}}}
\newcommand{\mean}[1]{\ensuremath{\overline{#1}}}
\newcommand{\norm}[1]{\ensuremath{\left|\left|{#1}\right|\right|}}

\begin{document}

\begin{equation*}
\text{RMSD}(\set{u}, \set{v}) = \min_{s, \set{Q}} \sqrt{\frac{1}{N} \sum\limits_{i=1}^{N}
\norm{
s[\vec{u_i} - \mean{\set{u}}]
-
\set{Q} \vec{v_i}
}^2}
\end{equation*}

\end{document}
+117 −0
Original line number Diff line number Diff line
"LAMMPS WWW Site"_lws - "LAMMPS Documentation"_ld - "LAMMPS Commands"_lc :c

:link(lws,http://lammps.sandia.gov)
:link(ld,Manual.html)
:link(lc,Section_commands.html#comm)

:line

compute ptm/atom command :h3

[Syntax:]

compute ID group-ID ptm/atom structures threshold :pre

ID, group-ID are documented in "compute"_compute.html command
ptm/atom = style name of this compute command
structures = structure types to search for
threshold = lattice distortion threshold (RMSD) :ul

[Examples:]

compute 1 all ptm/atom default 0.1
compute 1 all ptm/atom fcc-hcp-dcub-dhex 0.15
compute 1 all ptm/atom all 0 :pre

[Description:]

Define a computation that determines the local lattice structure
around an atom using the PTM (Polyhedral Template Matching) method.
The PTM method is described in "(Larsen)"_#Larsen.

Currently, there are seven lattice structures PTM recognizes:

fcc = 1
hcp = 2
bcc = 3
ico (icosahedral) = 4
sc (simple cubic) = 5
dcub (diamond cubic) = 6
dhex (diamond hexagonal) = 7
other = 8 :ul

The value of the PTM structure will be 0 for atoms not in the specified
compute group.  The choice of structures to search for can be specified using the "structures"
argument, which is a hyphen-separated list of structure keywords.
Two convenient pre-set options are provided:

default: fcc-hcp-bcc-ico
all: fcc-hcp-bcc-ico-sc-dcub-dhex :ul

The 'default' setting detects the same structures as the Common Neighbor Analysis method.
The 'all' setting searches for all structure types.  A small performance penalty is
incurred for the diamond structures, so it is not recommended to use this option if
it is known that the simulation does not contain diamond structures.


PTM identifies structures using two steps.  First, a graph isomorphism test is used
to identify potential structure matches.  Next, the deviation is computed between the
local structure (in the simulation) and a template of the ideal lattice structure.
The deviation is calculated as:

:c,image(Eqs/ptm_rmsd.jpg)

Here, u and v contain the coordinates of the local and ideal structures respectively,
s is a scale factor, and Q is a rotation.  The best match is identified by the
lowest RMSD value, using the optimal scaling, rotation, and correspondence between the
points.

The 'threshold' keyword sets an upper limit on the maximum permitted deviation before
a local structure is identified as disordered.  Typical values are in the range 0.1-0.15,
but larger values may be desirable at higher temperatures.
A value of 0 is equivalent to infinity and can be used if no threshold is desired.


The neighbor list needed to compute this quantity is constructed each
time the calculation is performed (e.g. each time a snapshot of atoms
is dumped).  Thus it can be inefficient to compute/dump this quantity
too frequently or to have multiple compute/dump commands, each with a
{ptm/atom} style.

[Output info:]

This compute calculates a per-atom array, which can be accessed by
any command that uses per-atom values from a compute as input.  See
"Section 6.15"_Section_howto.html#howto_15 for an overview of
LAMMPS output options.

Results are stored in the per-atom array in the following order:

type
rmsd
interatomic distance
qw
qx
qy
qw :ul

The type is a number from 0 to 8.  The rmsd is a positive real number.
The interatomic distance is computed from the scale factor in the RMSD equation.
The (qw,qx,qy,qz) parameters represent the orientation of the local structure
in quaternion form.  The reference coordinates for each template (from which the
orientation is determined) can be found in the {ptm_constants.h} file in the PTM source directory.

[Restrictions:] none

[Related commands:]

"compute centro/atom"_compute_centro_atom.html
"compute cna/atom"_compute_cna_atom.html

[Default:] none

:line

:link(Larsen)
[(Larsen)] Larsen, Schmidt, Schiøtz, Modelling Simul Mater Sci Eng, 24, 055007 (2016).

src/USER-PTM/LICENSE

0 → 100644
+7 −0
Original line number Diff line number Diff line
Copyright (c) 2016 PM Larsen

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+101 −0
Original line number Diff line number Diff line
#include <algorithm>
#include "ptm_constants.h"
#include "initialize_data.h"


#define NUM_ALLOY_TYPES 3
static uint32_t typedata[NUM_ALLOY_TYPES][3] = {
	{PTM_MATCH_FCC, PTM_ALLOY_L10,    0x000001fe},
	{PTM_MATCH_FCC, PTM_ALLOY_L12_CU, 0x0000001e},
	{PTM_MATCH_FCC, PTM_ALLOY_L12_AU, 0x00001ffe},
};

static bool test_pure(int num_nbrs, int32_t* numbers)
{
	for (int i=1;i<num_nbrs + 1;i++)
		if (numbers[i] != numbers[0])
			return false;
	return true;
}

static bool test_binary(int num_nbrs, int32_t* numbers)
{
	int a = numbers[0], b = -1;
	for (int i=1;i<num_nbrs + 1;i++)
	{
		if (numbers[i] != a)
		{
			if (b == -1)
				b = numbers[i];
			else if (numbers[i] != b)
				return false;
		}
	}

	return true;
}

static bool test_shell_structure(const refdata_t* ref, int8_t* mapping, int32_t* numbers, int num_inner)
{
	int8_t binary[PTM_MAX_POINTS];
	for (int i=0;i<ref->num_nbrs+1;i++)
		binary[i] = numbers[mapping[i]] == numbers[0] ? 0 : 1;

	for (int i=1;i<num_inner + 1;i++)
		if (binary[i] == binary[0])
			return false;

	for (int i=num_inner+1;i<ref->num_nbrs+1;i++)
		if (binary[i] != binary[0])
			return false;

	return true;
}

static int32_t canonical_alloy_representation(const refdata_t* ref, int8_t* mapping, int32_t* numbers)
{
	int8_t binary[PTM_MAX_POINTS];
	for (int i=0;i<ref->num_nbrs+1;i++)
		binary[i] = numbers[mapping[i]] == numbers[0] ? 0 : 1;

	int8_t temp[PTM_MAX_POINTS];
	uint32_t best = 0xFFFFFFFF;
	for (int j=0;j<ref->num_mappings;j++)
	{
		for (int i=0;i<ref->num_nbrs+1;i++)
			temp[ref->mapping[j][i]] = binary[i];

		uint32_t code = 0;
		for (int i=0;i<ref->num_nbrs+1;i++)
			code |= (temp[i] << i);

		best = std::min(best, code);
	}

	return best;
}

int32_t find_alloy_type(const refdata_t* ref, int8_t* mapping, int32_t* numbers)
{
	if (test_pure(ref->num_nbrs, numbers))
		return PTM_ALLOY_PURE;

	if (!test_binary(ref->num_nbrs, numbers))
		return PTM_ALLOY_NONE;

	uint32_t code = canonical_alloy_representation(ref, mapping, numbers);
	for (int i=0;i<NUM_ALLOY_TYPES;i++)
		if ((uint32_t)ref->type == typedata[i][0] && code == typedata[i][2])
			return typedata[i][1];

	if (ref->type == PTM_MATCH_BCC)
		if (test_shell_structure(ref, mapping, numbers, 8))
			return PTM_ALLOY_B2;

	if (ref->type == PTM_MATCH_DCUB || ref->type == PTM_MATCH_DHEX)
		if (test_shell_structure(ref, mapping, numbers, 4))
			return PTM_ALLOY_SIC;

	return PTM_ALLOY_NONE;
}
Loading