1.0-northcote/cs/Sharpen/Encounter.cs
/// <summary>
/// Processes the calculation file and stores energy values.
/// </summary>
/// <param name="filename">Counterpoise correction calculation file.</param>
/// <exception cref="System.ApplicationException">Exception thrown</exception>
/// <exception cref="System.ArgumentException">Exception thrown if the file is not a Gaussian counterpoise correction calculation.</exception>
Processes the calculation file and stores energy values.
Processes the calculation file and stores energy values .
public void SetEnergies(string filename)
        {
            StreamReader reader = new StreamReader(filename);
            string line = null;
            bool gaussianCalc = false;
            int hyphenLines = 0;
            bool descriptionFound = false;
            this._description = string.Empty;
            if (this.energyStrings.Count != 0)
            {
                this.energyStrings.Clear();
            }
            while ((line = reader.ReadLine()) != null)
            {
                if (!line.StartsWith(" Entering Gaussian System") && !gaussianCalc)
                {
                    reader.Close();
                    throw new ArgumentException("This is not a Gaussian calculation");
                }
                else
                {
                    gaussianCalc = true;
                }
                if (hyphenLines == 5)
                {
                    this._description = line.Trim();
                    hyphenLines = 0;
                    descriptionFound = true;
                }
                if (line.StartsWith(" ----") && !descriptionFound)
                {
                    hyphenLines++;
                }
                if (line.StartsWith(" # ") && !line.Contains("counterpoise=2"))
                {
                    reader.Close();
                    throw new ArgumentException("This is not a counterpoise calculation");
                }
                if (line.StartsWith(" SCF Done:"))
                {
                    Match energy = this.energyExpression.Match(line);
                    this.energyStrings.Add(energy.ToString());
                }
            }
            reader.Close();
            if (this.energyStrings.Count == 0)
            {
                throw new ApplicationException("No energy values found");
            }
            if (this.energyStrings.Count >= 1)
            {
                this._dimer = double.Parse(this.energyStrings[0]);
            }
            if (this.energyStrings.Count >= 2)
            {
                this._monAdimer = double.Parse(this.energyStrings[1]);
            }
            if (this.energyStrings.Count < 3)
            {
                throw new ApplicationException("Incomplete dataset found, from which interaction energy cannot be calculated");
            }
            if (this.energyStrings.Count >= 3)
            {
                this._monBdimer = double.Parse(this.energyStrings[2]);
            }
            if (this.energyStrings.Count >= 4)
            {
                this._monAmonA = double.Parse(this.energyStrings[3]);
            }
            if (this.energyStrings.Count < 5)
            {
                throw new ApplicationException("Incomplete dataset found, but interaction energy can be calculated");
            }
            if (this.energyStrings.Count == 5)
            {
                this._monBmonB = double.Parse(this.energyStrings[4]);
            }
        }
public void SetEnergies ( string filename ) { StreamReader reader = new StreamReader ( filename ) ; string line = null ; bool gaussianCalc = false ; int hyphenLines = 0 ; bool descriptionFound = false ; this . _description = string . Empty ; if ( this . energyStrings . Count != 0 ) { this . energyStrings . Clear ( ) ; } while ( ( line = reader . ReadLine ( ) ) != null ) { if ( ! line . StartsWith ( " " ) && ! gaussianCalc ) { reader . Close ( ) ; throw new ArgumentException ( " " ) ; } else { gaussianCalc = true ; } if ( hyphenLines == 5 ) { this . _description = line . Trim ( ) ; hyphenLines = 0 ; descriptionFound = true ; } if ( line . StartsWith ( " " ) && ! descriptionFound ) { hyphenLines ++ ; } if ( line . StartsWith ( " " ) && ! line . Contains ( " " ) ) { reader . Close ( ) ; throw new ArgumentException ( " " ) ; } if ( line . StartsWith ( " " ) ) { Match energy = this . energyExpression . Match ( line ) ; this . energyStrings . Add ( energy . ToString ( ) ) ; } } reader . Close ( ) ; if ( this . energyStrings . Count == 0 ) { throw new ApplicationException ( " " ) ; } if ( this . energyStrings . Count >= 1 ) { this . _dimer = double . Parse ( this . energyStrings [ 0 ] ) ; } if ( this . energyStrings . Count >= 2 ) { this . _monAdimer = double . Parse ( this . energyStrings [ 1 ] ) ; } if ( this . energyStrings . Count < 3 ) { throw new ApplicationException ( " " ) ; } if ( this . energyStrings . Count >= 3 ) { this . _monBdimer = double . Parse ( this . energyStrings [ 2 ] ) ; } if ( this . energyStrings . Count >= 4 ) { this . _monAmonA = double . Parse ( this . energyStrings [ 3 ] ) ; } if ( this . energyStrings . Count < 5 ) { throw new ApplicationException ( " " ) ; } if ( this . energyStrings . Count == 5 ) { this . _monBmonB = double . Parse ( this . energyStrings [ 4 ] ) ; } }
Processes the calculation file and stores energy values.
Processes the calculation file and stores energy values .
// Requires Checking!
None
Exception thrown if the file is not a Gaussian counterpoise correction calculation.
Exception thrown if the file is not a Gaussian counterpoise correction calculation .
filename
string
Counterpoise correction calculation file.
Counterpoise correction calculation file .