**********************************
Estimating Species Thermochemistry
**********************************

Species thermochemistry can be estimated based on 2 approaches:
1. Benson group additivity (GA)
2. On-the-fly quantum-chemical methods based on the explicit 3D structure of the molecule.

For the on-the-fly methods, a number of QM packages [G03, OpenMopac, MM4] and a number of levels of theory [PM3, MM4, MM4HR] are supported.
Since the accuracy of Benson GA for acyclic molecules is generally superior than for the QM methods, acyclic molecules are always estimated through GA.

For cyclic molecules 3 different strategies can be chosen:
1. BensonOnly
2. QMforCyclics
3. Hybrid

The BensonOnly strategy only uses the Benson Group Additivity framework to estimate thermochemistry of species. 
For compounds containing one or more rings, it identifies the smallest set of smallest rings in the molecules and perceives whether fused ring atoms are present,
that indicate that a polycyclic ring system is present.
Then, the databases of ring corrections and polycyclic ring corrections are used to search an adequate (polycyclic) ring correction. 
If an apt ring correction is not found, a warning is printed, but the thermochemistry without the ring correction is kept.

The QMforCyclics strategy preferentially choses the on-the-fly semi-empirical methods to estimate thermochemistry. If repeated failures occur for the QM methods,
this strategy falls back to the BensonOnly strategy.

In the hybrid strategy, first, the Benson databases are searched for an adequate (polycyclic) ring correction. If such a correction is not found, 
this strategy falls back to the QMforCyclics strategy.

The thermochemistry calculated from on-the-fly quantum methods are now saved to $RMG_QM_LIBRARY, which defaults as QMThermoLibrary in the working directory.
These results can be inputted into subsequent RMG runs by copying QMThermoLibrary from a previous run into the working directory of the new run.

The ``ThermoDataEstimator`` utility produces thermochemistry estimates without running RMG.

Instructions for Use
--------------------

1. Create a text file named :file:`input.txt` in any directory that you like.  
   The text file should begin with a block to specify the desired Database.
   
   The next section allows to use on-the-fly generation QM techniques to estimate TD
   properties, rather than group additivity methods.
   
   The first flag defines the strategy to estimate thermochemistry:
   e.g.::

   	//thermo strategy? [BensonOnly/QMforCyclics/Hybrid]
   	Hybrid
   
   The following lines are not required if the ``BensonOnly`` flag is used:

       The QM package to be used, is specified: either choose "both", "gaussian03", "mopac", 
       "mm4", or "mm4hr"
       e.g.::

       	//QM method: [both/gaussian03/mopac/mm4/mm4hr] 
       	gaussian03
       
       
       Limit the use of on-the-fly methods to only species with less than the specified number
       of unpaired electrons. E.g. "0", implies that radical species will not computed using
       on-the-fly QM methods.
       e.g.::

       	//maxradnumforQM?
       	0  
       
       A check of the connectivity of the passed-in 3D structure can be performed ensuring
       that the quantumchemical data returned by the QM package is based on a 3D structure with
       correct connectivity. 
       e.g.::
       
           //CheckConnectivity? [off/check/confirm]
           check
        
       Specify whether to keep all output files from Gaussian03 or Mopac. If no enviornment
       variable for qmCalculationsDir is set, the output files will be kept in $WorkDir/QMFiles. 

           //KeepQMFiles? [yes/no]
           yes
 
   The next section allows the user to set atom constraints on the species to be processed
   by the ThermoDataEstimator, beyond the default values hard-coded in TDE. 
   Only species that satisfy the set atom constraints, will be processed by TDE.
   Uncomment (//) the desired atom constraint, to set a particular constraint.
   
   E.g.::

   	MaxCarbonNumberPerSpecies:     40
   	//MaxOxygenNumberPerSpecies:     10
   	//MaxRadicalNumberPerSpecies:    10
   	//MaxSulfurNumberPerSpecies:     10
   	//MaxSiliconNumberPerSpecies:    10
   	//MaxHeavyAtomNumberPerSpecies: 100
   	//MaxCycleNumberPerSpecies:      10
   	END 
   
   The next field should be the PrimaryThermoLibrary, which may be left empty if desired::

	Database: RMG_database
	
	PrimaryThermoLibrary:
	END

   Next, in the text file, create the adjacency list(s) corresponding to the molecule(s) of interest using the same syntax used to define a species in the :file:`condition.txt` input file (see RMG manual). Hydrogens can be omitted for simplicity. For example, the adjacency list for 2,2,4,4-tetramethylpentane could be written as::

	1 C 0 {2,S}
	2 C 0 {1,S} {3,S} {4,S} {5,S}
	3 C 0 {2,S}
	4 C 0 {2,S}
	5 C 0 {2,S} {6,S}
	6 C 0 {5,S} {7,S} {8,S} {9,S}
	7 C 0 {6,S}
	8 C 0 {6,S}
	9 C 0 {6,S}

   An complete example can be found in the :file:`examples/ThermoDataEstimator` directory.


2. At the command prompt, change directory to the location of the :file:`input.txt` file and then, if you are using a unix-based operating system, execute the command ::

	 $ java -classpath $RMG/bin/RMG.jar ThermoDataEstimator input.txt > RMG.log

   Or if you are using a Windows operating system you can instead run the batch file :file:`ThermoDataEstimator.bat`. Either double-click it or at the command propmpt type::

     > ThermoDataEstimator.bat

  The output of the program will automatically be written to :file:`RMG.log`

3. The program will read RMG's thermodynamics database, count groups, and output the NASA polynomials in CHEMKIN format, as well as another set of values labeled ThermoData. The format for ThermoData is

	ΔH\ :sub:`f,298` S\ :sub:`298` C\ :sub:`p,300` C\ :sub:`p,400` C\ :sub:`p,500` C\ :sub:`p,600` C\ :sub:`p,800` C\ :sub:`p,1000` C\ :sub:`p,1500`

   Units are kcal/mol for ΔH\ :sub:`f,298` and cal/mol*K for the other quantities (entropy and heat capacity). The symmetry number (including contributions from internal rotations) will also be displayed.