Skip to content

Commit 6e2c173

Browse files
Merge pull request #96 from cmelab/surface-wetting
Add surface wetting module
2 parents 531cd82 + c8105bc commit 6e2c173

25 files changed

+1566
-51
lines changed

docs/source/modules.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ Modules
1515
:maxdepth: 1
1616

1717
welding
18+
surface_wetting

docs/source/surface_wetting.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Surface Wetting
2+
---------------
3+
4+
.. py:currentmodule:flowermd.modules
5+
6+
.. rubric:: Details
7+
8+
.. automodule:: flowermd.modules.surface_wetting
9+
:no-members:
10+
11+
.. autoclass:: DropletSimulation()
12+
:members:
13+
:no-index:
14+
15+
.. autoclass:: InterfaceBuilder()
16+
:members:
17+
:no-index:
18+
:show-inheritance:
19+
20+
.. autoclass:: WettingSimulation()
21+
:members:
22+
:no-index:
23+
:show-inheritance:

flowermd/base/molecule.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Molecule:
3131
Number of molecules to generate.
3232
force_field : flowermd.ForceField or a list of
3333
`hoomd.md.force.Force` objects, default=None
34-
The force field to be applied to the molecule for parameterization.
34+
The forcefield to be applied to the molecule for parameterization.
3535
Note that setting `force_field` does not actually apply the
3636
forcefield to the molecule. The forcefield in this step is mainly
3737
used for validation purposes.
@@ -430,8 +430,12 @@ class Polymer(Molecule):
430430
The smiles string of the monomer to generate.
431431
file : str, default None
432432
The file path to the monomer to generate.
433-
force_field : str, default None
434-
The force field to apply to the molecule.
433+
force_field : flowermd.ForceField or a list of
434+
`hoomd.md.force.Force` objects, default=None
435+
The forcefield to be applied to the molecule for parameterization.
436+
Note that setting `force_field` does not actually apply the
437+
forcefield to the molecule. The forcefield in this step is mainly
438+
used for validation purposes.
435439
bond_indices: list, default None
436440
The indices of the atoms to bond.
437441
bond_length: float, default None
@@ -502,13 +506,21 @@ class CoPolymer(Molecule):
502506
Class of the B-type monomer
503507
length : int, required
504508
The total number of monomers in the molecule
509+
num_mols : int, required
510+
Number of chains to generate.
505511
sequence : str, default None
506512
Manually define the sequence of 'A' and 'B' monomers.
507513
Leave as None if generating random sequences.
508514
Example: sequence = "AABAABAAB"
509515
AB_ratio : float, default 0.50
510516
The relative weight of A to B monomer types.
511517
Used when generating random sequences.
518+
force_field : flowermd.ForceField or a list of
519+
`hoomd.md.force.Force` objects, default=None
520+
The forcefield to be applied to the molecule for parameterization.
521+
Note that setting `force_field` does not actually apply the
522+
forcefield to the molecule. The forcefield in this step is mainly
523+
used for validation purposes.
512524
seed : int, default 24
513525
Set the seed used when generating random sequences
514526

flowermd/base/simulation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ def run_update_volume(
612612
Number of steps to run during volume update.
613613
period : int, required
614614
The number of steps ran between each box update iteration.
615-
kT : int or hoomd.variant.Ramp, required
615+
kT : float or hoomd.variant.Ramp, required
616616
The temperature to use during volume update.
617617
tau_kt : float, required
618618
Thermostat coupling period (in simulation time units).

flowermd/base/system.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -586,21 +586,27 @@ def apply_forcefield(
586586
if scale_charges and not remove_charges:
587587
self._scale_charges()
588588

589-
epsilons = [
590-
s.atom_type.parameters["epsilon"] for s in self.gmso_system.sites
591-
]
592-
sigmas = [
593-
s.atom_type.parameters["sigma"] for s in self.gmso_system.sites
594-
]
595-
masses = [s.mass for s in self.gmso_system.sites]
589+
if not self._reference_values:
590+
epsilons = [
591+
s.atom_type.parameters["epsilon"]
592+
for s in self.gmso_system.sites
593+
]
594+
sigmas = [
595+
s.atom_type.parameters["sigma"] for s in self.gmso_system.sites
596+
]
597+
masses = [s.mass for s in self.gmso_system.sites]
596598

597-
energy_scale = np.max(epsilons) if self.auto_scale else 1.0
598-
length_scale = np.max(sigmas) if self.auto_scale else 1.0
599-
mass_scale = np.max(masses) if self.auto_scale else 1.0
599+
energy_scale = np.max(epsilons) if self.auto_scale else 1.0
600+
length_scale = np.max(sigmas) if self.auto_scale else 1.0
601+
mass_scale = np.max(masses) if self.auto_scale else 1.0
600602

601-
self._reference_values["energy"] = energy_scale * epsilons[0].unit_array
602-
self._reference_values["length"] = length_scale * sigmas[0].unit_array
603-
self._reference_values["mass"] = mass_scale * masses[0].unit_array
603+
self._reference_values["energy"] = (
604+
energy_scale * epsilons[0].unit_array
605+
)
606+
self._reference_values["length"] = (
607+
length_scale * sigmas[0].unit_array
608+
)
609+
self._reference_values["mass"] = mass_scale * masses[0].unit_array
604610

605611
if remove_hydrogens:
606612
self.remove_hydrogens()

flowermd/library/surfaces.py

Lines changed: 62 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
"""Recipes to generate surfaces using mBuild."""
22

3+
import mbuild as mb
34
from mbuild.compound import Compound
45
from mbuild.lattice import Lattice
56

7+
from flowermd.base import Molecule, System
68

7-
class Graphene(Compound):
9+
10+
class Graphene(System):
811
"""Create a rectangular graphene layer or multiple layers.
912
1013
Parameters
@@ -15,10 +18,43 @@ class Graphene(Compound):
1518
Number of times to repeat graphene lattice in the y-direciton.
1619
n_layers: int, optional, default 1
1720
Number of times to repeat the complete layer in the normal direction.
21+
force_field: force_field : flowermd.ForceField
22+
The force field to be applied to the surface for paramaterizaiton.
23+
Note that setting `force_field` does not actually apply the forcefield
24+
to the molecule. The forcefield in this step is mainly used for
25+
validation purposes.
26+
reference_values : dict, required
27+
A dictionary of reference values for the surface. The keys of the
28+
dictionary are "length", "energy", and "mass". The values of the
29+
dictionary are unyt quantities.
30+
r_cut : float, required
31+
The cutoff radius for the Lennard-Jones interactions.
1832
periodicity : tuple of bools, length=3, optional, default=(True, True, False) # noqa: E501
1933
Whether the Compound is periodic in the x, y, and z directions.
2034
If None is provided, the periodicity is set to `(False, False, False)`
2135
which is non-periodic in all directions.
36+
auto_scale : bool, default=False
37+
Set to true to use reduced simulation units.
38+
distance, mass, and energy are scaled by the largest value
39+
present in the system for each.
40+
scale_charges : bool, default False
41+
Set to true to scale charges to net zero.
42+
remove_charges : bool, default False
43+
Set to true to remove charges from the system.
44+
remove_hydrogens : bool, default False
45+
Set to true to remove hydrogen atoms from the system.
46+
The masses and charges of the hydrogens are absorbed into
47+
the heavy atoms they were bonded to.
48+
pppm_resolution : tuple, default=(8, 8, 8)
49+
The resolution used in
50+
`hoomd.md.long_range.pppm.make_pppm_coulomb_force` representing
51+
number of grid points in the x, y, and z directions.
52+
ppmp_order : int, default=4
53+
The order used in
54+
`hoomd.md.long_range.pppm.make_pppm_coulomb_force` representing
55+
number of grid points in each direction to assign charges to.
56+
nlist_buffer : float, default=0.4
57+
Neighborlist buffer for simulation cell.
2258
2359
Notes
2460
-----
@@ -28,19 +64,38 @@ class Graphene(Compound):
2864
"""
2965

3066
def __init__(
31-
self, x_repeat, y_repeat, n_layers, periodicity=(True, True, False)
67+
self,
68+
x_repeat,
69+
y_repeat,
70+
n_layers,
71+
base_units=dict(),
72+
periodicity=(True, True, False),
3273
):
33-
super(Graphene, self).__init__(periodicity=periodicity)
74+
surface = mb.Compound(periodicity=periodicity)
3475
spacings = [0.425, 0.246, 0.35]
35-
points = [[1 / 6, 0, 0], [1 / 2, 0, 0], [0, 0.5, 0], [2 / 3, 1 / 2, 0]]
76+
points = [
77+
[1 / 6, 0, 0],
78+
[1 / 2, 0, 0],
79+
[0, 1 / 2, 0],
80+
[2 / 3, 1 / 2, 0],
81+
]
3682
lattice = Lattice(
3783
lattice_spacing=spacings,
3884
angles=[90, 90, 90],
3985
lattice_points={"A": points},
4086
)
41-
carbon = Compound(name="C")
87+
carbon = Compound(name="C", element="C")
4288
layers = lattice.populate(
4389
compound_dict={"A": carbon}, x=x_repeat, y=y_repeat, z=n_layers
4490
)
45-
self.add(layers)
46-
self.freud_generate_bonds("C", "C", dmin=0.14, dmax=0.145)
91+
surface.add(layers)
92+
surface.freud_generate_bonds("C", "C", dmin=0.14, dmax=0.145)
93+
surface_mol = Molecule(num_mols=1, compound=surface)
94+
super(Graphene, self).__init__(
95+
molecules=[surface_mol],
96+
density=1.0,
97+
base_units=base_units,
98+
)
99+
100+
def _build_system(self):
101+
return self.all_molecules[0]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"""Surface wetting module for FlowerMD."""
2+
from .surface_wetting import (
3+
DropletSimulation,
4+
InterfaceBuilder,
5+
WettingSimulation,
6+
)

0 commit comments

Comments
 (0)