Skip to content

Commit

Permalink
Get mechanism name from its path.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwest committed Oct 19, 2019
1 parent 014619a commit 7620926
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions importChemkin.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,17 @@ def __init__(self, args=None):
self.kineticsLibrary = None
"""An rmgpy.data.kinetics.KineticsLibrary object containing chemkin-defined reactions of identified species"""


# Determine what to call this model, based on its path
location = os.path.abspath(self.args.reactions or self.args.species)
name = os.path.split(location)[0]
try:
name = name[(name.index('RMG-models') + 11):]
except ValueError:
pass
self.name = name
"The name of the model (based on its source path)"

def loadSpecies(self, species_file):
"""
Load the chemkin list of species
Expand Down Expand Up @@ -1806,7 +1817,6 @@ def main(self):
known_species_file = args.known or species_file + '.SMILES.txt'
self.known_species_file = known_species_file
self.blocked_matches_file = os.path.splitext(known_species_file)[0] + '-BLOCKED.txt'

self.outputThermoFile = os.path.splitext(thermo_file)[0] + '.thermo.py'
self.outputKineticsFile = os.path.splitext(reactions_file)[0] + '.kinetics.py'

Expand Down Expand Up @@ -1841,15 +1851,15 @@ def main(self):

self.thermoLibrary = rmgpy.data.thermo.ThermoLibrary(
label=thermo_file.replace('"', ''),
name=thermo_file.replace('"', ''),
name=self.name,
solvent=None,
shortDesc=os.path.abspath(thermo_file).replace('"', ''),
longDesc=source.strip(),
)

self.kineticsLibrary = rmgpy.data.kinetics.KineticsLibrary(
label=reactions_file.replace('"', ''),
name=reactions_file.replace('"', ''),
name=self.name,
solvent=None,
shortDesc=os.path.abspath(reactions_file).replace('"', ''),
longDesc=source.strip(),
Expand Down Expand Up @@ -2096,12 +2106,7 @@ def _img(self, species):
@cherrypy.expose
def index(self):
location = os.path.abspath(self.args.reactions or self.args.species)
name = os.path.split(location)[0]
try:
name = name[(name.index('RMG-models')+11):]
except ValueError:
pass

name = self.name
output = [self.html_head() , """
<script>
function alsoUpdate(json) {
Expand All @@ -2112,7 +2117,7 @@ def index(self):
$('#thermomatches_count').html("("+json.thermomatches+")");
}
</script>
<h1>Mechanism importer:"""+name+"""</h1>
<h1>Mechanism importer: """ + name + """</h1>
<ul>
<li><a href="species.html">All species.</a> (Sorted by <a href="species.html?sort=name">name</a> or <a href="species.html?sort=formula">formula</a>.)</li>
<li><a href="identified.html">Identified species.</a> <span id="identified_count"></span></li>
Expand Down Expand Up @@ -2890,11 +2895,7 @@ def progress_json(self):

def html_head(self):
location = os.path.abspath(self.args.reactions or self.args.species)
name = os.path.split(location)[0]
try:
name = name[(name.index('RMG-models') + 11):]
except ValueError:
pass
name = self.name
return """
<html>
<head>
Expand Down

0 comments on commit 7620926

Please sign in to comment.