Skip to content

Commit f75a359

Browse files
committed
Merge branch 'new_plugin' of https://github.com/justinGilmer/mbuild into new_plugin
2 parents 2fb94c7 + d8181be commit f75a359

File tree

13 files changed

+72
-53
lines changed

13 files changed

+72
-53
lines changed

mbuild/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
from mbuild.port import Port
88
from mbuild.recipes import *
99
from mbuild.lattice import Lattice
10-
10+
from mbuild.recipes import recipes
1111
from mbuild.version import version

mbuild/examples/alkane/alkane.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def __init__(self, n=3, cap_front=True, cap_end=True):
2525
n += 1
2626
if not cap_end:
2727
n += 1
28-
chain = Polymer(CH2(), n=n-2, port_labels=('up', 'down'))
28+
chain = mb.recipes.Polymer(CH2(), n=n-2, port_labels=('up', 'down'))
2929
self.add(chain, 'chain')
3030

3131
if cap_front:
@@ -44,4 +44,4 @@ def __init__(self, n=3, cap_front=True, cap_end=True):
4444
# Hoist port label to Alkane level.
4545
self.add(chain['down'], 'down', containment=False)
4646

47-
# -- ==alkane== --
47+
# -- ==alkane== --

mbuild/examples/alkane_monolayer/alkane_monolayer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from mbuild.examples.alkane_monolayer.alkylsilane import AlkylSilane
1111

1212

13-
class AlkaneMonolayer(Monolayer):
13+
class AlkaneMonolayer(mb.recipes.Monolayer):
1414
"""An akylsilane monolayer on beta-cristobalite. """
1515

1616
def __init__(self, pattern, tile_x=1, tile_y=1, chain_length=10):
@@ -35,4 +35,4 @@ def __init__(self, pattern, tile_x=1, tile_y=1, chain_length=10):
3535
pattern=pattern, tile_x=tile_x,
3636
tile_y=tile_y)
3737

38-
# -- ==alkane_monolayer== --
38+
# -- ==alkane_monolayer== --

mbuild/examples/pmpc/brush.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def __init__(self, chain_length=4, alpha=pi/4):
1717
# Add parts
1818
self.add(Silane(), label='silane')
1919
self.add(Initiator(), label='initiator')
20-
self.add(Polymer(MPC(alpha=alpha), n=chain_length,
20+
self.add(mb.recipes.Polymer(MPC(alpha=alpha), n=chain_length,
2121
port_labels=('up', 'down')), label='pmpc')
2222
self.add(CH3(), label='methyl')
2323

mbuild/examples/pmpc/pmpc_brush_layer.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66

77
from numpy import pi
88

9+
import mbuild as mb
910
from mbuild.lib.atoms import H
1011
from mbuild.lib.surfaces import Betacristobalite
1112
from mbuild.lib.recipes import Monolayer
1213
from mbuild.examples.pmpc.brush import Brush
1314

1415

15-
class PMPCLayer(Monolayer):
16+
class PMPCLayer(mb.recipes.Monolayer):
1617
"""Create a layer of grafted pMPC brushes on a beta-cristobalite surface."""
1718
def __init__(self, pattern, tile_x=1, tile_y=1, chain_length=4, alpha=pi / 4):
1819
surface = Betacristobalite()
@@ -22,4 +23,4 @@ def __init__(self, pattern, tile_x=1, tile_y=1, chain_length=4, alpha=pi / 4):
2223
pattern=pattern, tile_x=tile_x,
2324
tile_y=tile_y)
2425

25-
# -- ==pmpc_brush_layer== --
26+
# -- ==pmpc_brush_layer== --

mbuild/lib/recipes/monolayer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ def __init__(self, surface, chains, fractions=None, backfill=None, pattern=None,
3838
super(Monolayer, self).__init__()
3939

4040
# Replicate the surface.
41-
tiled_compound = TiledCompound(surface, n_tiles=(tile_x, tile_y, 1))
41+
tiled_compound = mb.recipes.TiledCompound(surface, n_tiles=(tile_x, tile_y, 1))
4242
self.add(tiled_compound, label='tiled_surface')
4343

4444
if pattern is None: # Fill the surface.
4545
pattern = mb.Random2DPattern(len(tiled_compound.referenced_ports()))
4646

4747
if isinstance(chains, mb.Compound):
4848
chains = [chains]
49-
49+
5050
if fractions:
5151
fractions = list(fractions)
5252
if len(chains) != len(fractions):

mbuild/lib/recipes/silica_interface.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ def _cleave_interface(self, bulk_silica, tile_x, tile_y, thickness):
6161
"""
6262
O_buffer = self._O_buffer
6363
tile_z = int(math.ceil((thickness + 2*O_buffer) / bulk_silica.periodicity[2]))
64-
bulk = TiledCompound(bulk_silica, n_tiles=(tile_x, tile_y, tile_z))
64+
bulk = mb.recipes.TiledCompound(bulk_silica, n_tiles=(tile_x, tile_y, tile_z))
6565

6666
interface = mb.Compound(periodicity=(bulk.periodicity[0],
6767
bulk.periodicity[1],
6868
0.0))
6969
for i, particle in enumerate(bulk.particles()):
70-
if ((particle.name == 'Si' and O_buffer < particle.pos[2] < (thickness + O_buffer)) or
70+
if ((particle.name == 'Si' and O_buffer < particle.pos[2] < (thickness + O_buffer)) or
7171
(particle.name == 'O' and particle.pos[2] < (thickness + 2*O_buffer))):
7272
interface_particle = mb.Compound(name=particle.name, pos=particle.pos)
7373
interface.add(interface_particle, particle.name + "_{}".format(i))
@@ -154,5 +154,5 @@ def _adjust_stoichiometry(self):
154154

155155
if __name__ == "__main__":
156156
from mbuild.lib.bulk_materials import AmorphousSilica
157-
silica_interface = SilicaInterface(bulk_silica=AmorphousSilica(), thickness=1.2)
157+
silica_interface = mb.recipes.SilicaInterface(bulk_silica=AmorphousSilica(), thickness=1.2)
158158
silica_interface.save('silica_interface.mol2', show_ports=True)

mbuild/lib/surfaces/betacristobalite.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def __init__(self):
3232
for particle in self.particles():
3333
if particle.name.startswith('O') and particle.pos[2] > 1.0:
3434
count += 1
35-
port = mb.Port(anchor=particle, orientation=[0, 0, 1],
35+
port = mb.Port(anchor=particle, orientation=[0, 0, 1],
3636
separation=0.1)
3737
self.add(port, 'port_{}'.format(count))
3838
particle.name = 'O' # Strip numbers required in .mol2 files.
@@ -41,5 +41,5 @@ def __init__(self):
4141

4242
if __name__ == "__main__":
4343
single = Betacristobalite()
44-
multiple = TiledCompound(single, n_tiles=(2, 1, 1), name="tiled")
44+
multiple = mb.recipes.TiledCompound(single, n_tiles=(2, 1, 1), name="tiled")
4545
multiple.save('betacristobalite.mol2')

mbuild/tests/test_monolayer.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ def test_monolayer(self, ch2):
1212
m = 8
1313
pattern = mb.Grid2DPattern(n, m)
1414

15-
chain = Polymer(ch2, n=10)
16-
monolayer = Monolayer(
17-
surface=Betacristobalite(),
18-
chains=chain,
19-
backfill=H(),
20-
pattern=pattern)
15+
chain = mb.recipes.Polymer(ch2, n=10)
16+
monolayer = mb.recipes.Monolayer(
17+
surface=Betacristobalite(),
18+
chains=chain,
19+
backfill=H(),
20+
pattern=pattern)
2121

2222
assert monolayer.n_particles == 1900 + n * m * (10*3) + (100 - n*m)
2323
assert monolayer.n_bonds == 2400 + n * m * (10 * 2 + 9 + 1) + (100 - n * m)
@@ -27,13 +27,13 @@ def test_pattern_kwargs(self, ch2):
2727
m = 8
2828
pattern = mb.Grid2DPattern(n, m)
2929

30-
chain = Polymer(ch2, n=10)
31-
monolayer = Monolayer(surface=Betacristobalite(),
32-
chains=H(),
33-
guest_port_name='up',
34-
backfill=chain,
35-
backfill_port_name='down',
36-
pattern=pattern)
30+
chain = mb.recipes.Polymer(ch2, n=10)
31+
monolayer = mb.recipes.Monolayer(surface=Betacristobalite(),
32+
chains=H(),
33+
guest_port_name='up',
34+
backfill=chain,
35+
backfill_port_name='down',
36+
pattern=pattern)
3737

3838
chains = 100 - (n*m)
3939

@@ -46,10 +46,10 @@ def test_mixed_monolayer(self, ch2):
4646
pattern = mb.Grid2DPattern(n, m)
4747
fractions = [0.75,0.25]
4848

49-
chain_a = Polymer(ch2, n=5)
50-
chain_b = Polymer(ch2, n=15)
51-
monolayer = Monolayer(surface=Betacristobalite(),
52-
chains=[chain_a, chain_b],
49+
chain_a = mb.recipes.Polymer(ch2, n=5)
50+
chain_b = mb.recipes.Polymer(ch2, n=15)
51+
monolayer = mb.recipes.Monolayer(surface=Betacristobalite(),
52+
chains=[chain_a, chain_b],
5353
fractions=fractions,
5454
backfill=H(),
5555
pattern=pattern)

mbuild/tests/test_plugins.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import pytest
2+
3+
from mbuild.tests.base_test import BaseTest
4+
5+
6+
class TestPlugins(BaseTest):
7+
def test_basic_import(self):
8+
import mbuild.recipes
9+
10+
@pytest.mark.parametrize(
11+
'recipe_name',
12+
['Monolayer', 'Polymer', 'SilicaInterface', 'TiledCompound'],
13+
)
14+
def test_recipes_contents(self, recipe_name):
15+
import mbuild.recipes
16+
recipe_name in dir(mbuild.recipes)

0 commit comments

Comments
 (0)