Skip to content

Commit 10331e7

Browse files
committed
Remove some old RMG-java loading feature
This was deprecated a long time ago.
1 parent ea6ff0f commit 10331e7

1 file changed

Lines changed: 1 addition & 186 deletions

File tree

rmgpy/rmg/main.py

Lines changed: 1 addition & 186 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
from scipy.optimize import brute
5353

5454
import rmgpy.util as util
55-
from rmgpy.rmg.model import Species, CoreEdgeReactionModel
55+
from rmgpy.rmg.model import Species
5656
from rmgpy.rmg.pdep import PDepNetwork
5757
from rmgpy import settings
5858
from rmgpy.chemkin import ChemkinWriter
@@ -2031,191 +2031,6 @@ def log_header(self, level=logging.INFO):
20312031
logging.log(level, database_conda_package)
20322032
logging.log(level, '')
20332033

2034-
def load_rmg_java_input(self, path):
2035-
"""
2036-
Load an RMG-Java job from the input file located at `input_file`, or
2037-
from the `input_file` attribute if not given as a parameter.
2038-
"""
2039-
warnings.warn("The RMG-Java input is no longer supported and may be"
2040-
" removed in version 2.3.", DeprecationWarning)
2041-
# NOTE: This function is currently incomplete!
2042-
# It only loads a subset of the available information.
2043-
2044-
self.reaction_model = CoreEdgeReactionModel()
2045-
self.initial_species = []
2046-
self.reaction_systems = []
2047-
2048-
T_list = []
2049-
P_list = []
2050-
concentration_list = []
2051-
species_dict = {}
2052-
termination = []
2053-
2054-
with open(path, 'r') as f:
2055-
line = self.read_meaningful_line_java(f)
2056-
while line != '':
2057-
2058-
if line.startswith('TemperatureModel:'):
2059-
tokens = line.split()
2060-
units = tokens[2][1:-1]
2061-
assert units in ['C', 'F', 'K']
2062-
if units == 'C':
2063-
T_list = [float(T) + 273.15 for T in tokens[3:]]
2064-
elif units == 'F':
2065-
T_list = [(float(T) + 459.67) * 5. / 9. for T in tokens[3:]]
2066-
else:
2067-
T_list = [float(T) for T in tokens[3:]]
2068-
2069-
elif line.startswith('PressureModel:'):
2070-
tokens = line.split()
2071-
units = tokens[2][1:-1]
2072-
assert units in ['atm', 'bar', 'Pa', 'torr']
2073-
if units == 'atm':
2074-
P_list = [float(P) * 101325. for P in tokens[3:]]
2075-
elif units == 'bar':
2076-
P_list = [float(P) * 100000. for P in tokens[3:]]
2077-
elif units == 'torr':
2078-
P_list = [float(P) / 760. * 101325. for P in tokens[3:]]
2079-
else:
2080-
P_list = [float(P) for P in tokens[3:]]
2081-
2082-
elif line.startswith('InitialStatus:'):
2083-
label = ''
2084-
concentrations = []
2085-
adjlist = ''
2086-
2087-
line = self.read_meaningful_line_java(f)
2088-
while line != 'END':
2089-
2090-
if line == '' and label != '':
2091-
species = Species(label=label, molecule=[Molecule().from_adjacency_list(adjlist)])
2092-
self.initial_species.append(species)
2093-
species_dict[label] = species
2094-
concentration_list.append(concentrations)
2095-
label = ''
2096-
concentrations = []
2097-
adjlist = ''
2098-
2099-
elif line != '' and label == '':
2100-
tokens = line.split()
2101-
label = tokens[0]
2102-
units = tokens[1][1:-1]
2103-
if tokens[-1] in ['Unreactive', 'ConstantConcentration']:
2104-
tokens.pop(-1)
2105-
assert units in ['mol/cm3', 'mol/m3', 'mol/l']
2106-
if units == 'mol/cm3':
2107-
concentrations = [float(C) * 1.0e6 for C in tokens[2:]]
2108-
elif units == 'mol/l':
2109-
concentrations = [float(C) * 1.0e3 for C in tokens[2:]]
2110-
else:
2111-
concentrations = [float(C) for C in tokens[2:]]
2112-
2113-
elif line != '':
2114-
adjlist += line + '\n'
2115-
2116-
line = f.readline().strip()
2117-
if '//' in line:
2118-
line = line[0:line.index('//')]
2119-
2120-
elif line.startswith('InertGas:'):
2121-
2122-
line = self.read_meaningful_line_java(f)
2123-
while line != 'END':
2124-
2125-
tokens = line.split()
2126-
label = tokens[0]
2127-
assert label in ['N2', 'Ar', 'He', 'Ne']
2128-
if label == 'Ne':
2129-
smiles = '[Ne]'
2130-
elif label == 'Ar':
2131-
smiles = '[Ar]'
2132-
elif label == 'He':
2133-
smiles = '[He]'
2134-
else:
2135-
smiles = 'N#N'
2136-
units = tokens[1][1:-1]
2137-
assert units in ['mol/cm3', 'mol/m3', 'mol/l']
2138-
if units == 'mol/cm3':
2139-
concentrations = [float(C) * 1.0e6 for C in tokens[2:]]
2140-
elif units == 'mol/l':
2141-
concentrations = [float(C) * 1.0e3 for C in tokens[2:]]
2142-
else:
2143-
concentrations = [float(C) for C in tokens[2:]]
2144-
2145-
species = Species(label=label, reactive=False, molecule=[Molecule().from_smiles(smiles)])
2146-
self.initial_species.append(species)
2147-
species_dict[label] = species
2148-
concentration_list.append(concentrations)
2149-
2150-
line = self.read_meaningful_line_java(f)
2151-
2152-
elif line.startswith('FinishController:'):
2153-
2154-
# First meaningful line is a termination time or conversion
2155-
line = self.read_meaningful_line_java(f)
2156-
tokens = line.split()
2157-
if tokens[2].lower() == 'conversion:':
2158-
label = tokens[3]
2159-
conversion = float(tokens[4])
2160-
termination.append(TerminationConversion(spec=species_dict[label], conv=conversion))
2161-
elif tokens[2].lower() == 'reactiontime:':
2162-
time = float(tokens[3])
2163-
units = tokens[4][1:-1]
2164-
assert units in ['sec', 'min', 'hr', 'day']
2165-
if units == 'min':
2166-
time *= 60.
2167-
elif units == 'hr':
2168-
time *= 60. * 60.
2169-
elif units == 'day':
2170-
time *= 60. * 60. * 24.
2171-
termination.append(TerminationTime(time=time))
2172-
2173-
# Second meaningful line is the error tolerance
2174-
# We're not doing anything with this information yet!
2175-
line = self.read_meaningful_line_java(f)
2176-
2177-
line = self.read_meaningful_line_java(f)
2178-
2179-
assert len(T_list) > 0
2180-
assert len(P_list) > 0
2181-
concentration_list = np.array(concentration_list)
2182-
# An arbitrary number of concentrations is acceptable, and should be run for each reactor system
2183-
if not concentration_list.shape[1] > 0:
2184-
raise AssertionError()
2185-
2186-
# Make a reaction system for each (T,P) combination
2187-
for T in T_list:
2188-
for P in P_list:
2189-
for i in range(concentration_list.shape[1]):
2190-
concentrations = concentration_list[:, i]
2191-
total_conc = np.sum(concentrations)
2192-
initial_mole_fractions = dict([(self.initial_species[i], concentrations[i] / total_conc) for i in
2193-
range(len(self.initial_species))])
2194-
reaction_system = SimpleReactor(T, P, initial_mole_fractions=initial_mole_fractions,
2195-
termination=termination)
2196-
self.reaction_systems.append(reaction_system)
2197-
2198-
def read_meaningful_line_java(self, f):
2199-
"""
2200-
Read a meaningful line from an RMG-Java condition file object `f`,
2201-
returning the line with any comments removed.
2202-
"""
2203-
warnings.warn("The RMG-Java input is no longer supported and may be"
2204-
" removed in version 2.3.", DeprecationWarning)
2205-
line = f.readline()
2206-
if line != '':
2207-
line = line.strip()
2208-
if '//' in line:
2209-
line = line[0:line.index('//')]
2210-
while line == '':
2211-
line = f.readline()
2212-
if line == '':
2213-
break
2214-
line = line.strip()
2215-
if '//' in line:
2216-
line = line[0:line.index('//')]
2217-
return line
2218-
22192034

22202035
################################################################################
22212036

0 commit comments

Comments
 (0)