<commit_before># -*- coding: utf-8 -*-
"""
===============================================================================
Graphene structure classes (:mod:`sknano.structures._graphene`)
===============================================================================

.. currentmodule:: sknano.structures._graphene

"""
from __future__ import absolute_import, division, print_function
__docformat__ = 'restructuredtext en'

#import itertools

import numpy as np

from ..core.atoms import Atom
from ..core.math import Vector
from ..core.refdata import CCbond, dVDW, grams_per_Da

edge_types = {'armchair': 'AC', 'zigzag': 'ZZ'}

__all__ = ['GraphenePrimitiveCell', 'Graphene']


class GraphenePrimitiveCell(object):
    """Class for generating interactive Graphene primitive unit cell.

    Parameters
    ----------
    bond : float, optional
        bond length between nearest-neighbor atoms in **Angstroms**.

    """
    def __init__(self, bond=CCbond, **kwargs):
        self._bond = bond
        self._a = np.sqrt(3) * self._bond

        self._a1 = Vector(nd=2)
        self._a2 = Vector(nd=2)

        self._a1.x = self._a2.x = np.sqrt(3) / 2 * self._a
        self._a1.y = 1 / 2 * self._a
        self._a2.y = -self._a1.y

        self._b1 = Vector(nd=2)
        self._b2 = Vector(nd=2)

        self._b1.x = self._b2.x = 1 / np.sqrt(3) * 2 * np.pi / self._a
        self._b1.y = 2 * np.pi / self._a
        self._b2.y = -self._b1.y

    @property
    def a(self):
        """Length of graphene unit cell vector."""
        return self._a

    @property
    def a1(self):
        """:math:`a_1` unit vector."""
        return self._a1

    @property
    def a2(self):
        """:math:`a_2` unit vector."""
        return self._a2

    @property
    def b1(self):
        """:math:`b_1` reciprocal lattice vector."""
        return self._b1

    @property
    def b2(self):
        """:math:`b_2` reciprocal lattice vector."""
        return self._b2


class Graphene(object):
    """Class for generating interactive Graphene objects.

    Parameters
    ----------
    length : float, optional
        Length of graphene sheet in **nanometers**
    width : float, optional
        Width of graphene sheet in **nanometers**
    edge : {'AC', 'armchair', 'ZZ', 'zigzag'}, optional
        **A**\ rm\ **C**\ hair or **Z**\ ig\ **Z**\ ag edge along
        the `length` of the sheet.
    element1, element2 : {str, int}, optional
        Element symbol or atomic number of basis
        :class:`~sknano.core.atoms.Atom` 1 and 2
    bond : float, optional
        bond length between nearest-neighbor atoms in **Angstroms**.
    nlayers : int, optional
        Number of graphene layers.
    layer_spacing : float, optional
        Distance between layers in **Angstroms**.
    stacking_order : {'AA', 'AB'}, optional
        Stacking order of graphene layers
    verbose : bool, optional
        verbose output

    Notes
    -----
    For now, the graphene structure is generated using a
    conventional unit cell, not the primitive unit cell.

    .. todo::

       Add notes on unit cell calculation.

    """

    def __init__(self, length=None, width=None, edge=None, element1='C',
                 element2='C', bond=CCbond, nlayers=1, layer_spacing=dVDW,
                 layer_rotation_angles=None, stacking_order='AB',
                 verbose=False):

        self._length = length
        self._width = width
        if edge in ('armchair', 'zigzag'):
            edge = edge_types[edge]
        elif edge not in ('AC', 'ZZ'):
            print('unrecognized edge parameter: {}\n'.format(edge) +
                  'choosing one at random...\n')
            edge = np.random.choice(['AC', 'ZZ'])
            print('the randomly chosen edge type is: {}'.format(edge))
        self._edge = edge

        self._element1 = element1
        self._element2 = element2

        if bond is None:
            bond = CCbond

        self._bond = bond

        self._verbose = verbose

        self._Nx = 0
        self._Ny = 0

        self._layer_mass = None
        self._Natoms = 0
        self._Natoms_per_layer = None

        self._nlayers = nlayers
        self._layer_spacing = layer_spacing
        self._layer_rotation_angles = layer_rotation_angles
        self._stacking_order = stacking_order

        self._layer_shift = Vector()

        if nlayers > 1 and stacking_order == 'AB':
            if edge == 'AC':
                self._layer_shift.y = self._bond
            else:
                self._layer_shift.x = self._bond

        if edge == 'AC':
            # Set up the unit cell with the armchair edge aligned
            # along the `y`-axis.
            self._cell.x = np.sqrt(3) * bond
            self._cell.y = 3 * bond
        else:
            # Set up the unit cell with the zigzag edge aligned<commit_msg>adding missing attribute<commit_after># -*- coding: utf-8 -*-
"""
===============================================================================
Graphene structure classes (:mod:`sknano.structures._graphene`)
===============================================================================

.. currentmodule:: sknano.structures._graphene

"""
from __future__ import absolute_import, division, print_function
__docformat__ = 'restructuredtext en'

#import itertools

import numpy as np

from ..core.atoms import Atom
from ..core.math import Vector
from ..core.refdata import CCbond, dVDW, grams_per_Da

edge_types = {'armchair': 'AC', 'zigzag': 'ZZ'}

__all__ = ['GraphenePrimitiveCell', 'Graphene']


class GraphenePrimitiveCell(object):
    """Class for generating interactive Graphene primitive unit cell.

    Parameters
    ----------
    bond : float, optional
        bond length between nearest-neighbor atoms in **Angstroms**.

    """
    def __init__(self, bond=CCbond, **kwargs):
        self._bond = bond
        self._a = np.sqrt(3) * self._bond

        self._a1 = Vector(nd=2)
        self._a2 = Vector(nd=2)

        self._a1.x = self._a2.x = np.sqrt(3) / 2 * self._a
        self._a1.y = 1 / 2 * self._a
        self._a2.y = -self._a1.y

        self._b1 = Vector(nd=2)
        self._b2 = Vector(nd=2)

        self._b1.x = self._b2.x = 1 / np.sqrt(3) * 2 * np.pi / self._a
        self._b1.y = 2 * np.pi / self._a
        self._b2.y = -self._b1.y

    @property
    def a(self):
        """Length of graphene unit cell vector."""
        return self._a

    @property
    def a1(self):
        """:math:`a_1` unit vector."""
        return self._a1

    @property
    def a2(self):
        """:math:`a_2` unit vector."""
        return self._a2

    @property
    def b1(self):
        """:math:`b_1` reciprocal lattice vector."""
        return self._b1

    @property
    def b2(self):
        """:math:`b_2` reciprocal lattice vector."""
        return self._b2


class Graphene(object):
    """Class for generating interactive Graphene objects.

    Parameters
    ----------
    length : float, optional
        Length of graphene sheet in **nanometers**
    width : float, optional
        Width of graphene sheet in **nanometers**
    edge : {'AC', 'armchair', 'ZZ', 'zigzag'}, optional
        **A**\ rm\ **C**\ hair or **Z**\ ig\ **Z**\ ag edge along
        the `length` of the sheet.
    element1, element2 : {str, int}, optional
        Element symbol or atomic number of basis
        :class:`~sknano.core.atoms.Atom` 1 and 2
    bond : float, optional
        bond length between nearest-neighbor atoms in **Angstroms**.
    nlayers : int, optional
        Number of graphene layers.
    layer_spacing : float, optional
        Distance between layers in **Angstroms**.
    stacking_order : {'AA', 'AB'}, optional
        Stacking order of graphene layers
    verbose : bool, optional
        verbose output

    Notes
    -----
    For now, the graphene structure is generated using a
    conventional unit cell, not the primitive unit cell.

    .. todo::

       Add notes on unit cell calculation.

    """

    def __init__(self, length=None, width=None, edge=None, element1='C',
                 element2='C', bond=CCbond, nlayers=1, layer_spacing=dVDW,
                 layer_rotation_angles=None, stacking_order='AB',
                 verbose=False):

        self._length = length
        self._width = width
        if edge in ('armchair', 'zigzag'):
            edge = edge_types[edge]
        elif edge not in ('AC', 'ZZ'):
            print('unrecognized edge parameter: {}\n'.format(edge) +
                  'choosing one at random...\n')
            edge = np.random.choice(['AC', 'ZZ'])
            print('the randomly chosen edge type is: {}'.format(edge))
        self._edge = edge

        self._element1 = element1
        self._element2 = element2

        if bond is None:
            bond = CCbond

        self._bond = bond

        self._verbose = verbose

        self._Nx = 0
        self._Ny = 0

        self._layer_mass = None
        self._Natoms = 0
        self._Natoms_per_layer = None

        self._nlayers = nlayers
        self._layer_spacing = layer_spacing
        self._layer_rotation_angles = layer_rotation_angles
        self._stacking_order = stacking_order

        self._layer_shift = Vector()

        if nlayers > 1 and stacking_order == 'AB':
            if edge == 'AC':
                self._layer_shift.y = self._bond
            else:
                self._layer_shift.x = self._bond

        self._cell = Vector()
        if edge == 'AC':
            # Set up the unit cell with the armchair edge aligned
            # along the `y`-axis.
            self._cell.x = np.sqrt(3) * bond
            self._cell.y = 3 * bond
        else:
            # Set up the unit cell with the zigzag edge aligned
{'fraction_non_alphanumeric': 0.14883338472607668, 'fraction_numerical': 0.01171754548257786, 'mean_word_length': 2.1376975169300225, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3078596', 'n_tokens_mistral': 3007, 'n_tokens_neox': 2768, 'n_words': 829}