Skip to content

Commit

Permalink
Merge pull request #2570 from hwpang/afm_refactor_hwpang
Browse files Browse the repository at this point in the history
Getting structure information correctly for fragment
  • Loading branch information
JacksonBurns committed Nov 2, 2023
2 parents d33585f + de6cbaa commit ba00728
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 40 deletions.
9 changes: 0 additions & 9 deletions rmgpy/molecule/fragment.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,15 +322,6 @@ def is_subgraph_isomorphic(
result = Graph.is_subgraph_isomorphic(self.mol_repr, other, new_initial_map)
return result

def get_molecular_weight(self):
"""
Return the fragmental weight of the fragment in kg/mol.
"""
mass = 0
for vertex in self.vertices:
mass += vertex.element.mass
return mass

def calculate_cp0(self):
"""
Return the value of the heat capacity at zero temperature in J/mol*K.
Expand Down
44 changes: 13 additions & 31 deletions rmgpy/rmg/reactors.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,38 +680,20 @@ def to_rms(obj, species_names=None, rms_species_list=None, rmg_species=None):
elif isinstance(obj, NASA):
return rms.NASA([to_rms(poly) for poly in obj.polynomials], rms.EmptyThermoUncertainty())
elif isinstance(obj, Species):
atomnums = dict()
for atm in obj.molecule[0].atoms:
try:
if atomnums.get(atm.element.symbol):
atomnums[atm.element.symbol] += 1
else:
atomnums[atm.element.symbol] = 1
except AttributeError:
# means it is fragment's cutting label
pass
bondnum = len(obj.molecule[0].get_all_edges())


if isinstance(obj.molecule[0], Fragment):
th = obj.get_thermo_data()
thermo = to_rms(th)
return rms.Species(
name=obj.label,
index=obj.index,
inchi="",
smiles="",
adjlist="",
thermo=thermo,
atomnums=atomnums,
bondnum=bondnum,
diffusion=rms.EmptyDiffusivity(),
radius=0.0,
radicalelectrons=obj.molecule[0].multiplicity - 1,
molecularweight=0.0,
henrylawconstant=rms.EmptyHenryLawConstant(),
liquidvolumetricmasstransfercoefficient=rms.EmptyLiquidVolumetricMassTransferCoefficient(),
comment=obj.thermo.comment,
)
obj.molecule[0].assign_representative_molecule()
mol = obj.molecule[0].mol_repr
else:
mol = obj.molecule[0]

atomnums = dict()
for atm in mol.atoms:
if atomnums.get(atm.element.symbol):
atomnums[atm.element.symbol] += 1
else:
atomnums[atm.element.symbol] = 1
bondnum = len(mol.get_all_edges())

if not obj.molecule[0].contains_surface_site():
rad = rms.getspeciesradius(atomnums, bondnum)
Expand Down

0 comments on commit ba00728

Please sign in to comment.