File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2397,6 +2397,12 @@ def _initialise_gpu_memory(self):
23972397 "Could not find the GhostNonGhostNonbondedForce in the system"
23982398 )
23992399
2400+ # Resolve the unit conversions once. Doing this per atom, by
2401+ # formatting and re-parsing a string, dominates the setup time for
2402+ # large systems.
2403+ nm_to_angstrom = _sr .u ("1 nm" ).to ("angstrom" )
2404+ kj_per_mol_to_kcal_per_mol = _sr .u ("1 kJ/mol" ).to ("kcal/mol" )
2405+
24002406 # Get the parameters for the GhostNonGhostNonbondedForce.
24012407 charges = _np .zeros (self ._num_atoms , dtype = _np .float32 )
24022408 sigmas = _np .zeros (self ._num_atoms , dtype = _np .float32 )
@@ -2410,10 +2416,8 @@ def _initialise_gpu_memory(self):
24102416 # Charge in |e|, sigma in nm, epsilon in kJ/mol.
24112417 charges [i ] = q
24122418 # Rescale and convert units.
2413- sigmas [i ] = _sr .u (f"{ 2.0 * half_sigma } nm" ).to ("angstrom" )
2414- epsilons [i ] = _sr .u (f"{ (0.5 * two_sqrt_epsilon ) ** 2 } kJ/mol" ).to (
2415- "kcal/mol"
2416- )
2419+ sigmas [i ] = 2.0 * half_sigma * nm_to_angstrom
2420+ epsilons [i ] = (0.5 * two_sqrt_epsilon ) ** 2 * kj_per_mol_to_kcal_per_mol
24172421 # Store the softening parameter.
24182422 alphas [i ] = alpha
24192423
You can’t perform that action at this time.
0 commit comments