Skip to content

Commit

Permalink
Merge pull request #67 from chrisjonesBSU/graphene
Browse files Browse the repository at this point in the history
Add graphene surface to library
  • Loading branch information
chrisjonesBSU committed Oct 3, 2023
2 parents 265e633 + d0af69f commit 133d7d8
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
1 change: 1 addition & 0 deletions hoomd_organics/library/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@
PolyEthylene,
)
from .simulations.tensile import Tensile
from .surfaces import Graphene
46 changes: 46 additions & 0 deletions hoomd_organics/library/surfaces.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""Recipes to generate surfaces using mBuild."""

from mbuild.compound import Compound
from mbuild.lattice import Lattice


class Graphene(Compound):
"""Create a rectangular graphene layer or multiple layers.
Parameters
----------
x_repeat : int, required
Number of times to repeat graphene lattice in the x-direciton.
y_repeat: int, required
Number of times to repeat graphene lattice in the y-direciton.
n_layers: int, optional, default 1
Number of times to repeat the complete layer in the normal direction.
periodicity : tuple of bools, length=3, optional, default=(True, True, False) # noqa: E501
Whether the Compound is periodic in the x, y, and z directions.
If None is provided, the periodicity is set to `(False, False, False)`
which is non-periodic in all directions.
Notes
-----
To create bonds along periodic boundaries of the layers in the x and y
directions, set `periodicity = (True, True, False)`
"""

def __init__(
self, x_repeat, y_repeat, n_layers, periodicity=(True, True, False)
):
super(Graphene, self).__init__(periodicity=periodicity)
spacings = [0.425, 0.246, 0.35]
points = [[1 / 6, 0, 0], [1 / 2, 0, 0], [0, 0.5, 0], [2 / 3, 1 / 2, 0]]
lattice = Lattice(
lattice_spacing=spacings,
angles=[90, 90, 90],
lattice_points={"A": points},
)
carbon = Compound(name="C")
layers = lattice.populate(
compound_dict={"A": carbon}, x=x_repeat, y=y_repeat, z=n_layers
)
self.add(layers)
self.freud_generate_bonds("C", "C", dmin=0.14, dmax=0.145)
21 changes: 21 additions & 0 deletions hoomd_organics/tests/library/test_surfaces.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from hoomd_organics.library import Graphene


class TestSurfaces:
def test_create_graphene_surface(self):
surface = Graphene(
x_repeat=2,
y_repeat=2,
n_layers=3,
periodicity=(False, False, False),
)
assert surface.n_particles == 4 * 2 * 2 * 3
assert surface.n_bonds == 54

def test_graphene_with_periodicity(self):
surface = Graphene(
x_repeat=2, y_repeat=2, n_layers=3, periodicity=(True, True, False)
)
assert surface.n_particles == 4 * 2 * 2 * 3
assert surface.periodicity == (True, True, False)
assert surface.n_bonds == 72

0 comments on commit 133d7d8

Please sign in to comment.