Exemple #1
0
def read_structure(structure_file):
    structure = orm.StructureData(ase=aseread(structure_file))
    structure.store()
    print(
        'Structure {} read and stored with pk {}.'.format(
            structure.get_formula(), structure.pk
        )
    )
    return structure
import numpy as np
from ase.io import read as aseread
from matscipy.neighbours import neighbour_list
import networkx as nx
from sys import argv

from fundef import minimal_cycles
from itertools import combinations
import _matscipy

########################################################################
########################################################################


at = aseread('../data/bilayer_TSmin.xyz', format='extxyz')

top = at[np.where(at.positions[:,2] > -.5)[0]]
top_si = top[np.where(top.get_atomic_numbers() == 14)[0]]
top_o = top[np.where(top.get_atomic_numbers() == 8)[0]]

cutoff = 1.97
ii, jj = neighbour_list('ij', top, cutoff)
neighbour_si = []
neighbour_o = []
angles = []
graph = nx.Graph()
for atom in top:
    if atom.number == 8:
        neighs = np.where(ii == atom.index)[0]
        for Si_1, Si_2 in combinations(jj[neighs], 2):
            graph.add_edge(Si_1, Si_2)
import numpy as np
from ase.io import read as aseread
import networkx as nx
import itertools
import pandas as pd
from bokeh import palettes
import matplotlib.pyplot as plt

from fundef import atoms_to_nxgraph, minimal_cycles, cycle_dual_graph

########################################################################
########################################################################

at = aseread('../data/reduced_1ayer.xyz', format='extxyz')
do_plots = True

top = at[np.where(at.positions[:,2] > -.5)[0]]
at = top[np.where(top.get_atomic_numbers() == 14)[0]]
cutoff = 3.8 # 2 * 1.6 + some extra for elongation. visual inspection first!

graph = atoms_to_nxgraph(at, cutoff)

all_cycles = minimal_cycles(graph, cutoff=9)

graph_dual = cycle_dual_graph(all_cycles)

cycle_n_nodes = {}
for i, c in enumerate(all_cycles):
    cycle_n_nodes[i] = len(c)
nx.set_node_attributes(graph_dual, 'cycle_size', cycle_n_nodes)
def cycle_dual_graph(all_cycles):
    # create the network of connected cycles
    cycle_adjacency = np.zeros((len(all_cycles), len(all_cycles))).astype(np.int)
    for i, ci in enumerate(all_cycles):
        for j, cj in enumerate(all_cycles):
            if j > i:
                if len(ci.intersection(cj)) > 0:
                    cycle_adjacency[i,j] = 1
    cycle_adjacency += cycle_adjacency.T
    # create the dual network: a node is a minimal ring, an edge is a shared edge between two rings (e.g. an O atom in the real system)
    graph_dual = nx.from_numpy_matrix(cycle_adjacency)
    return graph_dual

########################################################################
########################################################################

at = aseread('../SiO2_bilayer.xyz', format='extxyz')

at.positions[:,2] -= at.get_positions()[:,2].mean()
indices = np.where(np.logical_and(at.positions[:,2] > .2, at.get_atomic_numbers() == 14))[0]
atsiup = at[indices]
atsiup.write('atsiup.xyz', format='extxyz')

cutoff = 3.8 # 2 * 1.6 + some extra for elongation. visual inspection first!
graph = atoms_to_nxgraph(atsiup, cutoff)

all_cycles = minimal_cycles(graph, cutoff=9)

graph_dual = cycle_dual_graph(all_cycles)

Exemple #5
0
# Codenames for pw.x, pw2wannier90.x, projwfc.x and wannier90.x
# Please modify these according to your machine
pw_code = Code.get_from_string("<CODE LABEL>")  # e.g. 'qe-6.5-pw@localhost'
pw2wan_code = Code.get_from_string(
    "<CODE LABEL>")  # e.g. 'qe-6.5-pw2wannier90@localhost'
projwfc_code = Code.get_from_string(
    "<CODE LABEL>")  # e.g. 'qe-6.5-projwfc@localhost'
wan_code = Code.get_from_string(
    "<CODE LABEL>")  # e.g. 'wannier90-3.1.0-wannier@localhost'

# The 1st commandline argument specifies the structure to be calculated
xsf_file = sys.argv[1]  # e.g. 'CsH.xsf'

# Read xsf file and convert into a stored StructureData
structure = StructureData(ase=aseread(xsf_file))

# Prepare the builder to launch the workchain
builder = Wannier90BandsWorkChain.get_builder()
builder.structure = structure
builder.code = {
    'pw': pw_code,
    'pw2wannier90': pw2wan_code,
    'projwfc': projwfc_code,
    'wannier90': wan_code
}
# For this tutorial, we are using the 'testing' protocol,
# with all cutoffs halved, to speed up the simulations
builder.protocol = Dict(dict={'name': 'testing'})
# Flags to control the workchain behaviour
builder.controls = {