Skip to content

Commit f921a52

Browse files
authored
Merge pull request #2813 from Kyamaguchi16/fix-liquid-afm
Fix AFM fragment crash in LiquidReactor
2 parents 4d5f058 + d04c9e0 commit f921a52

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

rmgpy/kinetics/diffusionLimited.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@
3333
import numpy as np
3434

3535
import rmgpy.constants as constants
36+
from rmgpy.molecule.fragment import Fragment
37+
from rmgpy.species import Species
3638

39+
def _to_molecule(obj):
40+
"""Return plain Molecule; accept Molecule or (Molecule, mapping) tuple."""
41+
return obj[0] if isinstance(obj, tuple) else obj
3742

3843
class DiffusionLimited(object):
3944

@@ -119,7 +124,19 @@ def get_diffusion_limit(self, T, reaction, forward=True):
119124
radii = 0.0
120125
diffusivities = []
121126
for spec in reacting:
122-
solute_data = self.database.get_solute_data(spec)
127+
# --- ① Fragment (AFM) → representative Molecule ---------------
128+
if isinstance(spec, Fragment):
129+
# Replace R/L dummy atoms with hydrogen
130+
rep_mol = _to_molecule(spec.get_representative_molecule())
131+
spec_for_solv = Species(molecule=[rep_mol])
132+
elif isinstance(spec, Species) and isinstance(spec.molecule[0], Fragment):
133+
rep_mol = _to_molecule(spec.molecule[0].get_representative_molecule())
134+
spec_for_solv = Species(molecule=[rep_mol])
135+
else:
136+
spec_for_solv = spec
137+
138+
# --- ② look-up solvation / diffusivity -------------------------
139+
solute_data = self.database.get_solute_data(spec_for_solv)
123140
# calculate radius with the McGowan volume and assuming sphere
124141
radius = ((75 * solute_data.V / constants.pi / constants.Na) ** (1. / 3)) / 100 # m
125142
diff = solute_data.get_stokes_diffusivity(T, self.get_solvent_viscosity(T))

0 commit comments

Comments
 (0)