rmgpy.rmg.main.RMG¶
- class rmgpy.rmg.main.RMG(input_file=None, output_directory=None, profiler=None, stats_file=None)¶
A representation of a Reaction Mechanism Generator (RMG) job. The attributes are:
Attribute
Description
input_file
The path to the input file
profiler
A cProfile.Profile object for time profiling RMG
database_directory
The directory containing the RMG database
thermo_libraries
The thermodynamics libraries to load
reaction_libraries
The kinetics libraries to load
statmech_libraries
The statistical mechanics libraries to load
seed_mechanisms
The seed mechanisms included in the model
kinetics_families
The kinetics families to use for reaction generation
kinetics_depositories
The kinetics depositories to use for looking up kinetics in each family
kinetics_estimator
The method to use to estimate kinetics: currently, only ‘rate rules’ is supported
solvent
If solvation estimates are required, the name of the solvent.
solvent_data
The parameters assocciated with the solvent
liquid_volumetric_mass_transfer_coefficient_power_law
If kLA estimates are required, the coefficients for kLA power law
reaction_model
The core-edge reaction model generated by this job
reaction_systems
A list of the reaction systems used in this job
database
The RMG database used in this job
model_settings_list
List of ModelSettings objects containing information related to how to manage species/reaction movement
simulator_settings_list
List of SimulatorSettings objects containing information on how to run simulations
init_react_tuples
List of name tuples of species to react at beginning of run
trimolecular
True
to consider reactions between three species (i.e., if trimolecular reaction families are present)unimolecular_threshold
Array of flags indicating whether a species is above the unimolecular reaction threshold
bimolecular_threshold
Array of flags indicating whether two species are above the bimolecular reaction threshold
trimolecular_threshold
Array of flags indicating whether three species are above the trimolecular reaction threshold
unimolecular_react
Array of flags indicating whether a species should react unimolecularly in the enlarge step
bimolecular_react
Array of flags indicating whether two species should react in the enlarge step
trimolecular_react
Array of flags indicating whether three species should react in the enlarge step
termination
A list of termination targets (i.e
TerminationTime
andTerminationConversion
objects)species_constraints
Dictates the maximum number of atoms, carbons, electrons, etc. generated by RMG
output_directory
The directory used to save output files
verbosity
The level of logging verbosity for console output
units
The unit system to use to save output files (currently must be ‘si’)
generate_output_html
True
to draw pictures of the species and reactions, saving a visualized model in an output HTML file.False
otherwisegenerate_plots
True
to generate plots of the job execution statistics after each iteration,False
otherwiseverbose_comments
True
to keep the verbose comments for database estimates,False
otherwisesave_edge_species
True
to save chemkin and HTML files of the edge species,False
otherwisekeep_irreversible
True
to keep ireversibility of library reactions as is (‘<=>’ or ‘=>’).False
(default) to force all library reactions to be reversible (‘<=>’)trimolecular_product_reversible
True
(default) to allow families with trimolecular products to react in the reverse direction,False
otherwisepressure_dependence
Whether to process unimolecular (pressure-dependent) reaction networks
quantum_mechanics
Whether to apply quantum mechanical calculations instead of group additivity to certain molecular types.
ml_estimator
To use thermo estimation with machine learning
ml_settings
Settings for ML estimation
walltime
The maximum amount of CPU time in the form DD:HH:MM:SS to expend on this job; used to stop gracefully so we can still get profiling information
max_iterations
The maximum number of RMG iterations allowed, after which the job will terminate
kinetics_datastore
True
if storing details of each kinetic database entry in text file,False
otherwiseinitialization_time
The time at which the job was initiated, in seconds since the epoch (i.e. from time.time())
done
Whether the job has completed (there is nothing new to add)
- check_input()¶
Check for a few common mistakes in the input file.
- check_libraries()¶
Check unwanted use of libraries: Liquid phase libraries in Gas phase simulation. Loading a Liquid phase library obtained in another solvent than the one defined in the input file. Other checks can be added here.
- check_model()¶
Run checks on the RMG model
- clear()¶
Clear all loaded information about the job (except the file paths).
- execute(initialize=True, **kwargs)¶
Execute an RMG job using the command-line arguments args as returned by the
argparse
package.initialize
is abool
type flag used to determine whether to call self.initialize()
- finish()¶
Complete the model generation.
- generate_cantera_files(chemkin_file, **kwargs)¶
Convert a chemkin mechanism chem.inp file to a cantera mechanism file chem.yaml and save it in the cantera directory
- initialize(**kwargs)¶
Initialize an RMG job using the command-line arguments args as returned by the
argparse
package.
- initialize_seed_mech()¶
Initialize the process of saving the seed mechanism by performing the following:
Create the initial seed mechanism folder (the seed from a previous iterations will be deleted)
Save the restart-from-seed file (unless the current job is itself a restart job)
Ensure that we don’t overwrite existing libraries in the database that have the same name as this job
Create the previous_seeds directory to save intermediate seeds if the user gives a value for saveSeedModulus
- load_input(path=None)¶
Load an RMG job from the input file located at input_file, or from the input_file attribute if not given as a parameter.
- load_thermo_input(path=None)¶
Load an Thermo Estimation job from a thermo input file located at input_file, or from the input_file attribute if not given as a parameter.
- log_header(level=20)¶
Output a header containing identifying information about RMG to the log.
- make_seed_mech()¶
Save a seed mechanism (both core and edge) in the ‘seed’ sub-folder of the output directory. Additionally, save the filter tensors to the ‘seed/filters’ sub-folder so that the RMG job can be restarted from a seed mechanism. If self.save_seed_to_database is True then the seed mechanism is also saved as libraries (one each for the core and edge) in the RMG-database.
Notes
initialize_seed_mech should be called one time before this function is ever called.
- make_species_labels_independent(species)¶
This method looks at the core species labels and makes sure none of them conflict If a conflict occurs, the second occurance will have ‘-2’ added returns a list of the old labels
- process_pdep_networks(obj)¶
properly processes PDepNetwork objects and lists of PDepNetwork objects returned from simulate
- process_reactions_to_species(obj)¶
properly processes Reaction objects and lists of Reaction objects returned from simulate
- process_to_species_networks(obj)¶
breaks down the objects returned by simulate into Species and PDepNetwork components
- react_init_tuples()¶
Reacts tuples given in the react block
- register_listeners()¶
Attaches listener classes depending on the options found in the RMG input file.
- run_model_analysis(number=10)¶
Run sensitivity and uncertainty analysis if requested.
- run_uncertainty_analysis()¶
Run uncertainty analysis if proper settings are available.
- save_everything()¶
Saves the output HTML and the Chemkin file. If the job is being profiled this is saved as well.
- save_input(path=None)¶
Save an RMG job to the input file located at path.
- update_reaction_threshold_and_react_flags(rxn_sys_unimol_threshold=None, rxn_sys_bimol_threshold=None, rxn_sys_trimol_threshold=None, skip_update=False)¶
updates the length and boolean value of the unimolecular and bimolecular react and threshold flags
- rmgpy.rmg.main.initialize_log(verbose, log_file_name)¶
Set up a logger for RMG to use to print output to stdout. The verbose parameter is an integer specifying the amount of log text seen at the console; the levels correspond to those of the
logging
module.
- rmgpy.rmg.main.make_profile_graph(stats_file, force_graph_generation=False)¶
Uses gprof2dot to create a graphviz dot file of the profiling information.
This requires the gprof2dot package available via pip install gprof2dot. Render the result using the program ‘dot’ via a command like dot -Tps2 input.dot -o output.ps2.
Rendering the ps2 file to pdf requires an external pdf converter ps2pdf output.ps2 which produces a output.ps2.pdf file.
Will only generate a graph if a display is present as errors can occur otherwise. If force_graph_generation is True then the graph generation will be attempted either way
- rmgpy.rmg.main.process_profile_stats(stats_file, log_file)¶