-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from chrisjonesBSU/graphene
Add graphene surface to library
- Loading branch information
Showing
3 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,4 @@ | |
PolyEthylene, | ||
) | ||
from .simulations.tensile import Tensile | ||
from .surfaces import Graphene |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |