-
Notifications
You must be signed in to change notification settings - Fork 1
Hack in bonded interactions #236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
047da30
b1ba252
6e2694e
1e9b4c9
7fbecd5
ccfff2d
f8bd8cc
3d326dc
fad8cd0
3a0ca1b
09b3ebd
1d19b93
d05147b
0a9ad40
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,8 +70,8 @@ def _call_v3(self, sim): | |
# parse masses by type | ||
snap = sim["engine"]["_hoomd"].state.get_snapshot() | ||
sim.masses = self._get_masses_from_snapshot(sim, snap) | ||
sim[self]["_bonds"] = self._get_bonds_from_snapshot(sim, snap) | ||
self._assert_dimension_safe(sim, snap) | ||
|
||
# create the potentials, defer attaching until later | ||
neighbor_list = hoomd.md.nlist.Tree(buffer=sim.potentials.pair.neighbor_buffer) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add in exclusions=('bond', 'angle') |
||
pair_potential = hoomd.md.pair.Table(nlist=neighbor_list) | ||
|
@@ -159,6 +159,9 @@ def _get_masses_from_snapshot(self, sim, snap): | |
masses.update(masses_) | ||
return masses | ||
|
||
def _get_bonds_from_snapshot(self, sim, snap): | ||
return snap.bonds.group | ||
|
||
def _assert_dimension_safe(self, sim, snap): | ||
if sim.dimension == 3: | ||
dim_safe = True | ||
|
@@ -953,6 +956,7 @@ def _pre_run_v3(self, sim, sim_op): | |
system=sim["engine"]["_hoomd"].state, | ||
rdf_params=self._get_rdf_params(sim), | ||
constraints=self._get_constrained_quantities(sim, sim_op), | ||
bonds=sim[sim.initializer]["_bonds"], | ||
) | ||
sim[self]["_hoomd_thermo_callback"] = hoomd.write.CustomWriter( | ||
trigger=self.every, | ||
|
@@ -1137,7 +1141,14 @@ class EnsembleAverageAction(Action): | |
flags = [Action.Flags.PRESSURE_TENSOR] | ||
|
||
def __init__( | ||
self, types, dimension, thermo, system, rdf_params=None, constraints=None | ||
self, | ||
types, | ||
dimension, | ||
thermo, | ||
system, | ||
rdf_params=None, | ||
constraints=None, | ||
bonds=None, | ||
): | ||
if dimension not in (2, 3): | ||
raise ValueError("Only 2 or 3 dimensions supported") | ||
|
@@ -1148,6 +1159,7 @@ def __init__( | |
self.system = system | ||
self.rdf_params = rdf_params | ||
self.constraints = constraints if constraints is not None else {} | ||
self.bonds = bonds | ||
|
||
# this method handles all the initialization | ||
self.reset() | ||
|
@@ -1228,11 +1240,27 @@ def act(self, timestep): | |
for i, j in self._rdf: | ||
query_args = dict(self._rdf[i, j].default_query_args) | ||
query_args.update(exclude_ii=(i == j)) | ||
neighbors = ( | ||
aabbs[j] | ||
.query( | ||
snap.particles.position[type_masks[i]], query_args | ||
mphoward marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
.toNeighborList() | ||
) | ||
if snap.bonds is not None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here you would add a check if bonds are in the exclusion list as well. Probably you need to have that forwarded to this action though, since we would normally grab it from the |
||
bonds = numpy.vstack( | ||
[self.bonds, numpy.flip(self.bonds, axis=1)] | ||
) | ||
# list intersect method from: | ||
# https://stackoverflow.com/a/67113105 | ||
filter = ~(neighbors[:, None] == bonds).all(-1).any(1) | ||
else: | ||
filter = numpy.full((len(neighbors[:])), True) | ||
mphoward marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# resetting when the samples are zero clears the RDF | ||
self._rdf[i, j].compute( | ||
aabbs[j], | ||
snap.particles.position[type_masks[i]], | ||
neighbors=query_args, | ||
neighbors=neighbors.filter(filter), | ||
mphoward marked this conversation as resolved.
Show resolved
Hide resolved
|
||
reset=(self.num_samples == 0), | ||
) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing we do still want to do is make sure we can specify the neighbor list exclusions, and then only do the exclusions in the thermo if they are active. I think we talked about adding that as an argument / property of the
PairPotentialTabulator
, like theneighbor_buffer
, and then we would set it here by setting theexclusions
option.