Skip to content

Commit

Permalink
Merge pull request #93 from chrisjonesBSU/fix-surface
Browse files Browse the repository at this point in the history
`Graphene` now inherits from `Molecule`
  • Loading branch information
chrisjonesBSU authored Nov 14, 2023
2 parents 93d486b + cb3ef58 commit 4bf2472
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
18 changes: 15 additions & 3 deletions flowermd/base/molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Molecule:
Number of molecules to generate.
force_field : flowermd.ForceField or a list of
`hoomd.md.force.Force` objects, default=None
The force field to be applied to the molecule for parameterization.
The forcefield to be applied to the molecule for parameterization.
Note that setting `force_field` does not actually apply the
forcefield to the molecule. The forcefield in this step is mainly
used for validation purposes.
Expand Down Expand Up @@ -430,8 +430,12 @@ class Polymer(Molecule):
The smiles string of the monomer to generate.
file : str, default None
The file path to the monomer to generate.
force_field : str, default None
The force field to apply to the molecule.
force_field : flowermd.ForceField or a list of
`hoomd.md.force.Force` objects, default=None
The forcefield to be applied to the molecule for parameterization.
Note that setting `force_field` does not actually apply the
forcefield to the molecule. The forcefield in this step is mainly
used for validation purposes.
bond_indices: list, default None
The indices of the atoms to bond.
bond_length: float, default None
Expand Down Expand Up @@ -502,13 +506,21 @@ class CoPolymer(Molecule):
Class of the B-type monomer
length : int, required
The total number of monomers in the molecule
num_mols : int, required
Number of chains to generate.
sequence : str, default None
Manually define the sequence of 'A' and 'B' monomers.
Leave as None if generating random sequences.
Example: sequence = "AABAABAAB"
AB_ratio : float, default 0.50
The relative weight of A to B monomer types.
Used when generating random sequences.
force_field : flowermd.ForceField or a list of
`hoomd.md.force.Force` objects, default=None
The forcefield to be applied to the molecule for parameterization.
Note that setting `force_field` does not actually apply the
forcefield to the molecule. The forcefield in this step is mainly
used for validation purposes.
seed : int, default 24
Set the seed used when generating random sequences
Expand Down
28 changes: 22 additions & 6 deletions flowermd/library/surfaces.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
"""Recipes to generate surfaces using mBuild."""

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

from flowermd.base import Molecule

class Graphene(Compound):

class Graphene(Molecule):
"""Create a rectangular graphene layer or multiple layers.
Parameters
Expand All @@ -15,6 +18,11 @@ class Graphene(Compound):
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.
force_field: force_field : flowermd.ForceField
The force field to be applied to the surface for paramaterizaiton.
Note that setting `force_field` does not actually apply the forcefield
to the molecule. The forcefield in this step is mainly used for
validation purposes.
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)`
Expand All @@ -28,19 +36,27 @@ class Graphene(Compound):
"""

def __init__(
self, x_repeat, y_repeat, n_layers, periodicity=(True, True, False)
self,
x_repeat,
y_repeat,
n_layers,
force_field=None,
periodicity=(True, True, False),
):
super(Graphene, self).__init__(periodicity=periodicity)
surface = mb.Compound(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")
carbon = Compound(name="C", element="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)
surface.add(layers)
surface.freud_generate_bonds("C", "C", dmin=0.14, dmax=0.145)
super(Graphene, self).__init__(
compound=surface, num_mols=1, force_field=force_field
)

0 comments on commit 4bf2472

Please sign in to comment.