Skip to content

Commit 41f65ba

Browse files
committed
[Solvation] Added excluded species and libraries
to solvation
1 parent 74e498d commit 41f65ba

File tree

1 file changed

+34
-23
lines changed

1 file changed

+34
-23
lines changed

rmgpy/rmg/input.py

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def catalyst_properties(bindingEnergies=None,
134134
metal_db.load(os.path.join(settings['database.directory'], 'surface'))
135135

136136
if metal and (bindingEnergies or surfaceSiteDensity):
137-
raise InputError("In catalyst_properties section you should only specify a 'metal' shortcut "
137+
raise InputError("In catalyst_properties section you should only specify a 'metal' shortcut "
138138
"or the surfaceSiteDensity and bindingEnergies, but not both.")
139139

140140
if metal:
@@ -151,7 +151,7 @@ def catalyst_properties(bindingEnergies=None,
151151
logging.info("Using default binding energies, Pt(111)")
152152
else:
153153
rmg.binding_energies = convert_binding_energies(bindingEnergies)
154-
154+
155155

156156
if surfaceSiteDensity is None:
157157
rmg.surface_site_density = metal_db.get_surface_site_density("Pt111")
@@ -171,8 +171,8 @@ def catalyst_properties(bindingEnergies=None,
171171
def convert_binding_energies(binding_energies):
172172
"""
173173
Process binding_energies dictionary from the input file
174-
175-
It converts the values into Energy quantities, and checks that
174+
175+
It converts the values into Energy quantities, and checks that
176176
all elements C,H,O, and N are present.
177177
178178
:param binding_energies: a dictionary of element symbol: binding energy pairs
@@ -406,7 +406,7 @@ def simple_reactor(temperature,
406406
logging.debug(" {0}".format(const_spc))
407407
if const_spc not in species_dict:
408408
raise InputError('Species {0} not found in the input file'.format(const_spc))
409-
409+
410410
if not isinstance(T, list):
411411
sensitivityTemperature = T
412412
if not isinstance(P, list):
@@ -512,9 +512,9 @@ def constant_V_ideal_gas_reactor(temperature,
512512
termination.append(TerminationRateRatio(terminationRateRatio))
513513
if len(termination) == 0:
514514
raise InputError('No termination conditions specified for reaction system #{0}.'.format(len(rmg.reaction_systems) + 2))
515-
515+
516516
initial_cond = initialMoleFractions
517-
initial_cond["T"] = T
517+
initial_cond["T"] = T
518518
initial_cond["P"] = P
519519
system = ConstantVIdealGasReactor(rmg.reaction_model.core.phase_system,rmg.reaction_model.edge.phase_system,initial_cond,termination)
520520
system.T = Quantity(T)
@@ -805,7 +805,7 @@ def constant_T_V_liquid_reactor(temperature,
805805
if outlet_volumetric_flow_rate:
806806
if outlet_volumetric_flow_rate != outletVolumetricFlowRate:
807807
raise InputError(' Inconsistent residence time and inlet volumetric flow rate')
808-
808+
809809
outlet_volumetric_flow_rate = Quantity(outletVolumetricFlowRate).value_si
810810

811811
if inletConcentrations:
@@ -907,7 +907,7 @@ def constant_T_V_liquid_reactor(temperature,
907907
evap_cond_conditions[key] = item
908908
evap_cond_conditions["P"] = vapor_pressure
909909
evap_cond_conditions["T"] = initial_conditions["T"]
910-
910+
911911
system = ConstantTVLiquidReactor(rmg.reaction_model.core.phase_system,
912912
rmg.reaction_model.edge.phase_system,
913913
initial_conditions,
@@ -1162,19 +1162,30 @@ def simulator(atol, rtol, sens_atol=1e-6, sens_rtol=1e-4):
11621162
rmg.simulator_settings_list.append(SimulatorSettings(atol, rtol, sens_atol, sens_rtol))
11631163

11641164

1165-
def solvation(solvent,solventData=None):
1165+
def solvation(solvent, solventData=None, excludedSpecies=None, excludedLibraries=None):
11661166
# If solvation module in input file, set the RMG solvent variable
1167-
#either a string corresponding to the solvent database or a olvent object
1168-
if isinstance(solvent, str):
1169-
rmg.solvent = solvent
1170-
else:
1171-
raise InputError("Solvent not specified properly, solvent must be string")
1167+
# either a string corresponding to the solvent database or a solvent object
1168+
# The user can define a list of species labels or thermo library names
1169+
# to skip solvation correction. This will be useful when explicit solvation
1170+
# effects of a library species are already accounted for.
1171+
if not isinstance(solvent, str):
1172+
raise InputError("Solvent must be a string corresponding to a solvent in the database.")
11721173

1173-
if isinstance(solventData, SolventData) or solventData is None:
1174-
rmg.solvent_data = solventData
1175-
else:
1176-
raise InputError("Solvent not specified properly, solventData must be None or SolventData object")
1174+
if not (isinstance(solventData, SolventData) or solventData is None):
1175+
raise InputError("solventData must be a SolventData object or None.")
1176+
1177+
if excludedSpecies is not None:
1178+
if not (isinstance(excludedSpecies, list) and all(isinstance(s, str) for s in excludedSpecies)):
1179+
raise InputError("excludedSpecies must be a list of strings or None.")
1180+
1181+
if excludedLibraries is not None:
1182+
if not (isinstance(excludedLibraries, list) and all(isinstance(l, str) for l in excludedLibraries)):
1183+
raise InputError("excludedLibraries must be a list of strings or None.")
11771184

1185+
rmg.solvent = solvent
1186+
rmg.solvent_data = solventData
1187+
rmg.solvation_excluded_species = excludedSpecies if excludedSpecies is not None else []
1188+
rmg.solvation_excluded_libraries = excludedLibraries if excludedLibraries is not None else []
11781189

11791190
def model(toleranceMoveToCore=None, toleranceRadMoveToCore=np.inf,
11801191
toleranceMoveEdgeReactionToCore=np.inf, toleranceKeepInEdge=0.0,
@@ -1191,7 +1202,7 @@ def model(toleranceMoveToCore=None, toleranceRadMoveToCore=np.inf,
11911202
toleranceTransitoryDict={}, transitoryStepPeriod=20,
11921203
toleranceReactionToCoreDeadendRadical=0.0):
11931204
"""
1194-
How to generate the model. `toleranceMoveToCore` must be specified.
1205+
How to generate the model. `toleranceMoveToCore` must be specified.
11951206
toleranceMoveReactionToCore and toleranceReactionInterruptSimulation refers to an additional criterion for forcing an edge reaction to be included in the core
11961207
by default this criterion is turned off
11971208
Other parameters are optional and control the pruning.
@@ -1521,7 +1532,7 @@ def set_global_rmg(rmg0):
15211532

15221533
def read_input_file(path, rmg0):
15231534
"""
1524-
Read an RMG input file at `path` on disk into the :class:`RMG` object
1535+
Read an RMG input file at `path` on disk into the :class:`RMG` object
15251536
`rmg`.
15261537
"""
15271538
global rmg, species_dict, mol_to_frag
@@ -1620,7 +1631,7 @@ def read_input_file(path, rmg0):
16201631

16211632
def read_thermo_input_file(path, rmg0):
16221633
"""
1623-
Read an thermo estimation input file at `path` on disk into the :class:`RMG` object
1634+
Read an thermo estimation input file at `path` on disk into the :class:`RMG` object
16241635
`rmg`.
16251636
"""
16261637

@@ -1679,7 +1690,7 @@ def read_thermo_input_file(path, rmg0):
16791690

16801691
def save_input_file(path, rmg):
16811692
"""
1682-
Save an RMG input file at `path` on disk from the :class:`RMG` object
1693+
Save an RMG input file at `path` on disk from the :class:`RMG` object
16831694
`rmg`.
16841695
"""
16851696

0 commit comments

Comments
 (0)