Skip to content

Commit

Permalink
Calculate Species.molecularWeight if not given
Browse files Browse the repository at this point in the history
  • Loading branch information
alongd committed Jun 13, 2018
1 parent e8f85a3 commit 7ac6569
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions rmgpy/cantherm/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ def species(label, *args, **kwargs):
if structure:
spec.molecule = [structure]
spec.conformer = Conformer(E0=E0, modes=modes, spinMultiplicity=spinMultiplicity, opticalIsomers=opticalIsomers)
if molecularWeight is None:
if structure is None:
raise ValueError("No molecularWeight was entered for species {0}. Since the structure wasn't given as"
" well, the molecularWeight cannot be reconstructed!".format(spec.label))
else:
molecularWeight = Quantity(sum([getElement(int(atom.number)).mass
for atom in spec.molecule[0].atoms]), 'kg/mol')
spec.molecularWeight = molecularWeight
spec.transportData = collisionModel
spec.energyTransferModel = energyTransferModel
Expand Down

0 comments on commit 7ac6569

Please sign in to comment.