Skip to content

Commit

Permalink
merge fixes to void particle method
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjonesBSU committed Jan 26, 2024
2 parents a337c3c + c0c60a4 commit 5b20dbb
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions flowermd/modules/welding/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,39 @@ def add_void_particles(
"""
void_axis = np.asarray(void_axis)
snapshot.particles.N += num_voids
snapshot.particles.position[-1] = (
void_axis * snapshot.configuration.box[0:3] / 2
# Set updated positions
void_pos = void_axis * snapshot.configuration.box[0:3] / 2
init_pos = snapshot.particles.position
new_pos = np.empty((init_pos.shape[0] + 1, 3))
new_pos[: init_pos.shape[0]] = init_pos
new_pos[-1] = void_pos
# snapshot.particles.position = new_pos
snapshot.particles.position = np.concatenate(
(init_pos, void_pos.reshape(1, 3)), axis=0
)
snapshot.particles.types = snapshot.particles.types + ["VOID"]
snapshot.particles.typeid[-1] = len(snapshot.particles.types) - 1
snapshot.particles.mass[-1] = 1

# Set updated types and type IDs
snapshot.particles.types.append("VOID")
void_id = len(snapshot.particles.types) - 1
init_ids = snapshot.particles.typeid
snapshot.particles.typeid = np.concatenate(
(init_ids, np.array([void_id])), axis=None
)
# Set updated mass and charges
init_mass = snapshot.particles.mass
snapshot.particles.mass = np.concatenate(
(init_mass, np.array([1])), axis=None
)
init_charges = snapshot.particles.charge
snapshot.particles.charge = np.concatenate(
(init_charges, np.array([0])), axis=None
)
# Updated LJ params
lj = [i for i in forcefield if isinstance(i, hoomd.md.pair.LJ)][0]
for ptype in snapshot.particles.types:
lj.params[(ptype, "VOID")] = {
"sigma": void_diameter,
"epsilon": epsilon,
}
lj.r_cut[(ptype, "VOID")] = r_cut

return snapshot, forcefield

0 comments on commit 5b20dbb

Please sign in to comment.