Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add graphene surface to library #67

Merged
merged 5 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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):
"""Creates a rectangular graphene layer or multiple layers.
chrisjonesBSU marked this conversation as resolved.
Show resolved Hide resolved

Parameters
----------
x_repeat : int, required
Number of times to repeat graphene lattice in the x-direciton
chrisjonesBSU marked this conversation as resolved.
Show resolved Hide resolved
y_repeat: int, required
Number of times to repeat graphene lattice in the y-direciton
chrisjonesBSU marked this conversation as resolved.
Show resolved Hide resolved
n_layers: int, optional, default 1
Number of times to repeat the complete layer in the normal direction
chrisjonesBSU marked this conversation as resolved.
Show resolved Hide resolved
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)
chrisjonesBSU marked this conversation as resolved.
Show resolved Hide resolved
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 to (True, True, False)
chrisjonesBSU marked this conversation as resolved.
Show resolved Hide resolved

"""

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
Loading