Skip to content

Commit

Permalink
Merge pull request #49 from chrisjonesBSU/weld-tutorial
Browse files Browse the repository at this point in the history
Finish welding tutorial
  • Loading branch information
chrisjonesBSU authored Oct 4, 2023
2 parents 317a353 + 113a8e0 commit 120e6f9
Show file tree
Hide file tree
Showing 7 changed files with 1,131 additions and 20 deletions.
1 change: 1 addition & 0 deletions environment-cpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ channels:
dependencies:
- boltons
- foyer
- fresnel
- freud>=2.13.1
- gsd>=3.0
- hoomd=4.1=*cpu*
Expand Down
1 change: 1 addition & 0 deletions environment-gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ channels:
dependencies:
- boltons
- foyer
- fresnel
- freud>=2.13.1
- gsd>=3.0
- hoomd=4.1=*gpu*
Expand Down
10 changes: 4 additions & 6 deletions hoomd_organics/library/simulations/tensile.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def strain(self):
)
return delta_L / self.initial_length

def run_tensile(self, strain, n_steps, period):
def run_tensile(self, strain, n_steps, kT, tau_kt, period):
"""Run a tensile test simulation.
Parameters
Expand All @@ -88,6 +88,8 @@ def run_tensile(self, strain, n_steps, period):
The strain to apply to the simulation.
n_steps : int, required
The number of steps to run the simulation for.
tau_kt : float, required
Thermostat coupling period (in simulation time units).
period : int, required
The period of the strain application.
Expand Down Expand Up @@ -119,8 +121,4 @@ def run_tensile(self, strain, n_steps, period):
)
self.operations.updaters.append(box_resizer)
self.operations.updaters.append(particle_updater)
self.set_integrator_method(
integrator_method=hoomd.md.methods.ConstantVolume,
method_kwargs={"filter": self.integrate_group},
)
self.run(n_steps + 1)
self.run_NVT(n_steps=n_steps + 1, kT=kT, tau_kt=tau_kt)
23 changes: 12 additions & 11 deletions hoomd_organics/modules/welding.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ def __init__(
wall_epsilon=1.0,
wall_r_cut=2.5,
wall_r_extrap=0,
r_cut=2.5,
reference_values=dict(),
dt=0.0001,
r_cut=2.5,
device=hoomd.device.auto_select(),
seed=42,
gsd_write_freq=1e4,
Expand All @@ -175,8 +175,8 @@ def __init__(
super(SlabSimulation, self).__init__(
initial_state=initial_state,
forcefield=forcefield,
r_cut=r_cut,
reference_values=reference_values,
r_cut=r_cut,
dt=dt,
device=device,
seed=seed,
Expand All @@ -186,8 +186,7 @@ def __init__(
log_file_name=log_file_name,
thermostat=thermostat,
)
self.interface_axis = interface_axis
# self._axis_index = np.where(interface_axis != 0)[0]
self.interface_axis = np.asarray(interface_axis)
self.add_walls(
self.interface_axis,
wall_sigma,
Expand All @@ -208,14 +207,14 @@ def __init__(
self,
initial_state,
forcefield,
interface_axis="x",
interface_axis=(1, 0, 0),
wall_sigma=1.0,
wall_epsilon=1.0,
wall_r_cut=2.5,
wall_r_extrap=0,
r_cut=2.5,
reference_values=dict(),
dt=0.0001,
r_cut=2.5,
device=hoomd.device.auto_select(),
seed=42,
gsd_write_freq=1e4,
Expand All @@ -227,9 +226,9 @@ def __init__(
super(WeldSimulation, self).__init__(
initial_state=initial_state,
forcefield=forcefield,
r_cut=r_cut,
reference_values=reference_values,
dt=dt,
r_cut=r_cut,
device=device,
seed=seed,
gsd_write_freq=gsd_write_freq,
Expand All @@ -238,9 +237,11 @@ def __init__(
log_file_name=log_file_name,
thermostat=thermostat,
)
axis_dict = {"x": (1, 0, 0), "y": (0, 1, 0), "z": (0, 0, 1)}
self.interface_axis = interface_axis.lower()
self.wall_axis = axis_dict[self.interface_axis]
self.interface_axis = interface_axis
self.add_walls(
self.wall_axis, wall_sigma, wall_epsilon, wall_r_cut, wall_r_extrap
self.interface_axis,
wall_sigma,
wall_epsilon,
wall_r_cut,
wall_r_extrap,
)
4 changes: 3 additions & 1 deletion hoomd_organics/tests/library/test_tensile.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@ def test_tensile(self):
log_write_freq=1e6,
gsd_write_freq=1e6,
)
tensile_sim.run_tensile(strain=0.05, n_steps=1e3, period=10)
tensile_sim.run_tensile(
strain=0.05, kT=2.0, n_steps=1e3, period=10, tau_kt=0.001
)
assert np.allclose(tensile_sim.strain, 0.05, 1e-4)
8 changes: 6 additions & 2 deletions hoomd_organics/tests/modules/test_weld.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@

from hoomd_organics import Simulation
from hoomd_organics.modules.utils import add_void_particles
from hoomd_organics.modules.welding import Interface, SlabSimulation
from hoomd_organics.modules.welding import (
Interface,
SlabSimulation,
WeldSimulation,
)
from hoomd_organics.tests.base_test import BaseTest


Expand Down Expand Up @@ -92,7 +96,7 @@ def test_weld_sim(self, polyethylene_system):
interface = Interface(
gsd_file="restart.gsd", interface_axis="x", gap=0.1
)
sim = SlabSimulation(
sim = WeldSimulation(
initial_state=interface.hoomd_snapshot,
forcefield=polyethylene_system.hoomd_forcefield,
)
Expand Down
Loading

0 comments on commit 120e6f9

Please sign in to comment.