Changeset bab0b1 for src/bin


Ignore:
Timestamp:
Jul 10, 2012, 1:15:51 PM (13 years ago)
Author:
Frederik Heber <heber@…>
Children:
5ef341
Parents:
d392067
git-author:
Frederik Heber <heber@…> (07/06/12 20:04:27)
git-committer:
Frederik Heber <heber@…> (07/10/12 13:15:51)
Message:

Extracted performing frequency calculation into own function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/bin/mpqc/mpqc.cc

    rd392067 rbab0b1  
    960960}
    961961
     962/** Performs frequency calculation.
     963 *
     964 * \param mole molecular energy object
     965 * \param molhess molecular hessian object
     966 * \param molfreq molecular frequency object
     967 */
     968void performFrequencyCalculation(
     969    Ref<MolecularEnergy> &mole,
     970    Ref<MolecularHessian> &molhess,
     971    Ref<MolecularFrequencies> &molfreq
     972
     973    )
     974{
     975  RefSymmSCMatrix xhessian;
     976  if (molhess.nonnull()) {
     977    // if "hess" input was given, use it to compute the hessian
     978    xhessian = molhess->cartesian_hessian();
     979  }
     980  else if (mole->hessian_implemented()) {
     981    // if mole can compute the hessian, use that hessian
     982    xhessian = mole->get_cartesian_hessian();
     983  }
     984  else if (mole->gradient_implemented()) {
     985    // if mole can compute gradients, use gradients at finite
     986    // displacements to compute the hessian
     987    molhess = new FinDispMolecularHessian(mole);
     988    xhessian = molhess->cartesian_hessian();
     989  }
     990  else {
     991    ExEnv::out0() << "mpqc: WARNING: Frequencies cannot be computed" << endl;
     992  }
     993
     994  if (xhessian.nonnull()) {
     995    char *hessfile = SCFormIO::fileext_to_filename(".hess");
     996    MolecularHessian::write_cartesian_hessian(hessfile,
     997                                              mole->molecule(), xhessian);
     998    delete[] hessfile;
     999
     1000    molfreq->compute_frequencies(xhessian);
     1001    // DEGENERACY IS NOT CORRECT FOR NON-SINGLET CASES:
     1002    molfreq->thermochemistry(1);
     1003  }
     1004}
     1005
    9621006int
    9631007try_main(int argc, char *argv[])
     
    12051249  // Frequency calculation.
    12061250  if (ready_for_freq && molfreq.nonnull()) {
    1207     RefSymmSCMatrix xhessian;
    1208     if (molhess.nonnull()) {
    1209       // if "hess" input was given, use it to compute the hessian
    1210       xhessian = molhess->cartesian_hessian();
    1211     }
    1212     else if (mole->hessian_implemented()) {
    1213       // if mole can compute the hessian, use that hessian
    1214       xhessian = mole->get_cartesian_hessian();
    1215     }
    1216     else if (mole->gradient_implemented()) {
    1217       // if mole can compute gradients, use gradients at finite
    1218       // displacements to compute the hessian
    1219       molhess = new FinDispMolecularHessian(mole);
    1220       xhessian = molhess->cartesian_hessian();
    1221     }
    1222     else {
    1223       ExEnv::out0() << "mpqc: WARNING: Frequencies cannot be computed" << endl;
    1224     }
    1225 
    1226     if (xhessian.nonnull()) {
    1227       char *hessfile = SCFormIO::fileext_to_filename(".hess");
    1228       MolecularHessian::write_cartesian_hessian(hessfile,
    1229                                                 mole->molecule(), xhessian);
    1230       delete[] hessfile;
    1231 
    1232       molfreq->compute_frequencies(xhessian);
    1233       // DEGENERACY IS NOT CORRECT FOR NON-SINGLET CASES:
    1234       molfreq->thermochemistry(1);
    1235     }
     1251    performFrequencyCalculation(mole, molhess, molfreq);
    12361252  }
    12371253
Note: See TracChangeset for help on using the changeset viewer.