1- from .lj_softcore import LJSoftCoreModification
2- import openmm .unit as _unit
1+ import logging
2+ from typing import List , Optional , Union
3+
34import openmm as _mm
4- from openff . toolkit . typing . engines . smirnoff import ForceField as _ForceField
5+ import openmm . unit as _unit
56from openff .toolkit .topology import Topology as _Topology
7+ from openff .toolkit .typing .engines .smirnoff import ForceField as _ForceField
68
79from .base_modification import BaseModification , BaseModificationFactory
8- import logging
9- from typing import List , Optional , Union
10+ from .lj_softcore import LJSoftCoreModification
1011
1112logger = logging .getLogger (__name__ )
1213
14+
1315class CustomLJModificationFactory (BaseModificationFactory ):
1416 """Factory for creating CustomLJModification instances."""
1517
@@ -54,7 +56,7 @@ def apply(
5456 alchemical_atoms : List[int]
5557 A list of the indices of the alchemical atoms.
5658 lambda_value : float
57- The value of the alchemical state parameter.
59+ The value of the alchemical state parameter.
5860 original_offxml : List[str]
5961 A list of paths to the original OFFXML files.
6062 lj_offxml : str
@@ -77,21 +79,26 @@ def apply(
7779 opt_params = {}
7880 for p in force_field_opt .get_parameter_handler ("vdW" ):
7981 opt_params [p .id ] = {
80- "epsilon" : p .epsilon .to_openmm ().value_in_unit (_unit .kilojoules_per_mole ),
81- "sigma" : p .sigma .to_openmm ().value_in_unit (_unit .nanometer )
82- }
82+ "epsilon" : p .epsilon .to_openmm ().value_in_unit (
83+ _unit .kilojoules_per_mole
84+ ),
85+ "sigma" : p .sigma .to_openmm ().value_in_unit (_unit .nanometer ),
86+ }
8387
84- # Update the Lennard-Jones parameters in the CustomNonbondedForce
88+ # Update the Lennard-Jones parameters in the CustomNonbondedForce
8589 force_field = _ForceField (* original_offxml )
8690 labels = force_field .label_molecules (topology_off )
8791 index = 0
8892 for mol in labels :
8993 for _ , val in mol ["vdW" ].items ():
9094 atom_type = val .id
9195 # Get the original Lennard-Jones parameters
92- parameters = [opt_params [atom_type ]["sigma" ], opt_params [atom_type ]["epsilon" ]]
96+ parameters = [
97+ opt_params [atom_type ]["sigma" ],
98+ opt_params [atom_type ]["epsilon" ],
99+ ]
93100 # Update the Lennard-Jones parameters
94101 custom_nb_force .setParticleParameters (index , parameters )
95102 index += 1
96103
97- return system
104+ return system
0 commit comments