Exemplo n.º 1
0
import time

from psm.graph.clockwise import clockwise_traversal
from psm.build import lattice_traversal
from psm.graph.graphutils import find_clockwise
from psm.graph.traversal_slow import clockwise_traversal as clockwise_traversal_slow

a = [1, 0]
b = [0, 1]

structures = lattice_traversal(a, b, max_depth=3)
points = structures.points
adjacency = structures.adjacency
clockwise = find_clockwise(points, adjacency)
edge = (0, 1)

N = 10000

start = time.time()
for i in range(N):
    traversal = clockwise_traversal_slow(edge, adjacency, clockwise)
end = time.time()
print((end - start) / N)

start = time.time()
for i in range(N):
    traversal = clockwise_traversal(edge, adjacency, clockwise)
end = time.time()
print((end - start) / N)
A = .008
tol = 1e-4
show_plots = False

a = np.array([0, 1])
b = np.array([1, 0])

points = build_lattice_points(a, b, 60)

points = displacements(points, W, A)

adjacency = urquhart(points)

structures = traverse_from_all(points, adjacency, max_depth=2)

templates = lattice_traversal(a, b, max_depth=2)

rmsd_calc = RMSD(pivot='front')

rmsd_calc.register(templates, structures)

strain, rotation = rmsd_calc.calc_strain(structures)

exx, eyy, exy = strain[:, 0, 0], strain[:, 1, 1], strain[:, 0, 1]

exx_exact, eyy_exact, exy_exact = continuum_strain(structures.fronts, W, A)

if not show_plots:
    assert np.nanmean(np.abs(exx - exx_exact)) < tol
    assert np.nanmean(np.abs(eyy - eyy_exact)) < tol
    assert np.nanmean(np.abs(exy - exy_exact)) < tol
Exemplo n.º 3
0
from psm.geometry import transform
from psm.graph import urquhart
from psm.register import RMSD
from psm.structures import traverse_from_all

points = np.load('data/poly_graphene.npy')

adjacency = urquhart(points)

structures = traverse_from_all(points, adjacency, max_depth=3)

a = [0, 1]
b = [np.sin(2 / 3 * np.pi), np.cos(2 / 3 * np.pi)]
basis = [[0, 0], [1 / np.sqrt(3), 0]]

templates = lattice_traversal(a, b, basis, max_depth=3, graph_func=urquhart)

rmsd_calc = RMSD(transform='similarity', pivot='cop')

rmsd = rmsd_calc.register(templates, structures)

_, best_rmsd = rmsd_calc.best_matches(structures)

strain, rotation = rmsd_calc.calc_strain(structures)

planar = transform.planar_strain(transform.zero_median(strain))

rotation = (rotation - .4) % (np.pi / 3)

# --- Plot results ---