Skip to content
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

Optimizes construction of attraction strength CVs #99

Merged
merged 1 commit into from
May 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions cvpack/attraction_strength.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import typing as t

import numpy as np
import openmm
from openmm import unit as mmunit

Expand Down Expand Up @@ -205,11 +206,14 @@ def __init__( # pylint: disable=too-many-locals
self.setCutoffDistance(cutoff)
for parameter in ("charge", "sigma", "epsilon") + ("sign",) * contrasting:
self.addPerParticleParameter(parameter)
for atom in range(nonbondedForce.getNumParticles()):
contrast_atoms = np.zeros(nonbondedForce.getNumParticles(), dtype=bool)
if contrasting:
contrast_atoms[contrastGroup] = True
for atom, in_group in enumerate(contrast_atoms):
charge, sigma, epsilon = nonbondedForce.getParticleParameters(atom)
if contrasting:
sign = -1 if atom in contrastGroup else 1
scale = contrastScaling if atom in contrastGroup else 1
sign = -1 if in_group else 1
scale = contrastScaling if in_group else 1
self.addParticle([charge * scale, sigma, epsilon * scale**2, sign])
else:
self.addParticle([charge, sigma, epsilon])
Expand Down
Loading