Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/config.cpp

    • Property mode changed from 100755 to 100644
    r2746be ra1fe77  
    2323  configpath[0]='\0';
    2424  configname[0]='\0';
    25   basis="3-21G";
    2625 
    2726  FastParsing = false;
     
    3635  DoFullCurrent=0;
    3736  DoWannier=0;
     37  DoConstrainedMD=0;
    3838  CommonWannier=0;
    3939  SawtoothStart=0.01;
     
    518518  }
    519519 
     520  if (ParseForParameter(verbose,file,"DoConstrainedMD", 0, 1, 1, int_type, &(config::DoConstrainedMD), 1, optional))
     521    if (config::DoConstrainedMD < 0)
     522      config::DoConstrainedMD = 0;
    520523  ParseForParameter(verbose,file,"MaxOuterStep", 0, 1, 1, int_type, &(config::MaxOuterStep), 1, critical);
    521524  if (!ParseForParameter(verbose,file,"Deltat", 0, 1, 1, double_type, &(config::Deltat), 1, optional))
     
    972975
    973976/** Stores all elements of config structure from which they can be re-read.
    974  * \param *filename name of file
     977 * \param output open output *file stream to write to
    975978 * \param *periode pointer to a periodentafel class with all elements
    976979 * \param *mol pointer to molecule containing all atoms of the molecule
    977980 */
    978 bool config::Save(const char *filename, periodentafel *periode, molecule *mol) const
     981bool config::Save(ofstream *output, periodentafel *periode, molecule *mol) const
    979982{
    980983  bool result = true;
    981984        // bring MaxTypes up to date
    982985        mol->CountElements();
    983   ofstream *output = NULL;
    984   output = new ofstream(filename, ios::out);
    985986  if (output != NULL) {
    986987    *output << "# ParallelCarParinello - main configuration file - created with molecuilder" << endl;
     
    9991000    *output << "DoPerturbation\t" << config::DoPerturbation << "\t# Do perturbation calculate and determine susceptibility and shielding" << endl;
    10001001    *output << "DoFullCurrent\t" << config::DoFullCurrent << "\t# Do full perturbation" << endl;
     1002    *output << "DoConstrainedMD\t" << config::DoConstrainedMD << "\t# Do perform a constrained (>0, relating to current MD step) instead of unconstrained (0) MD" << endl;
    10011003    *output << "CommonWannier\t" << config::CommonWannier << "\t# Put virtual centers at indivual orbits, all common, merged by variance, to grid point, to cell center" << endl;
    10021004    *output << "SawtoothStart\t" << config::SawtoothStart << "\t# Absolute value for smooth transition at cell border " << endl;
     
    10701072    else
    10711073      result = result && mol->OutputTrajectories(output);
    1072     output->close();
    1073     output->clear();
    1074     delete(output);
    10751074    return result;
    10761075  } else
     
    10801079/** Stores all elements in a MPQC input file.
    10811080 * Note that this format cannot be parsed again.
    1082  * \param *filename name of file (without ".in" suffix!)
     1081 * \param output open output *file stream to write to
    10831082 * \param *mol pointer to molecule containing all atoms of the molecule
    10841083 */
    1085 bool config::SaveMPQC(const char *filename, molecule *mol) const
     1084bool config::SaveMPQC(ofstream *output, molecule *mol) const
    10861085{
    10871086  int ElementNo = 0;
    10881087  int AtomNo;
    10891088  atom *Walker = NULL;
    1090   element *runner = NULL;
     1089  element *runner = mol->elemente->start;
    10911090  Vector *center = NULL;
    1092   ofstream *output = NULL;
    1093   stringstream *fname = NULL;
    1094  
    1095   // first without hessian
    1096   fname = new stringstream;
    1097   *fname << filename << ".in";
    1098   output = new ofstream(fname->str().c_str(), ios::out);
     1091
    10991092  *output << "% Created by MoleCuilder" << endl;
    11001093  *output << "mpqc: (" << endl;
     
    11021095  *output << "\tdo_gradient = yes" << endl;
    11031096  *output << "\tmole<CLHF>: (" << endl;
    1104   *output << "\t\tmaxiter = 200" << endl;
    1105   *output << "\t\tbasis = $:basis" << endl;
    1106   *output << "\t\tmolecule = $:molecule" << endl;
    1107   *output << "\t)" << endl;
    1108   *output << ")" << endl;
    1109   *output << "molecule<Molecule>: (" << endl;
    1110   *output << "\tunit = " << (IsAngstroem ? "angstrom" : "bohr" ) << endl;
    1111   *output << "\t{ atoms geometry } = {" << endl;
     1097  *output << "\t\tmolecule<Molecule>: (" << endl;
     1098  *output << "\t\t\tunit = " << (IsAngstroem ? "angstrom" : "bohr" ) << endl;
     1099  *output << "\t\t\t{ atoms geometry } = {" << endl;
    11121100  center = mol->DetermineCenterOfAll(output);
    11131101  // output of atoms
    1114   runner = mol->elemente->start;
    11151102  while (runner->next != mol->elemente->end) { // go through every element
    11161103    runner = runner->next;
     
    11231110        if (Walker->type == runner) { // if this atom fits to element
    11241111          AtomNo++;
    1125           *output << "\t\t" << Walker->type->symbol << " [ " << Walker->x.x[0]-center->x[0] << "\t" << Walker->x.x[1]-center->x[1] << "\t" << Walker->x.x[2]-center->x[2] << " ]" << endl;
     1112          *output << "\t\t\t\t" << Walker->type->symbol << " [ " << Walker->x.x[0]-center->x[0] << "\t" << Walker->x.x[1]-center->x[1] << "\t" << Walker->x.x[2]-center->x[2] << " ]" << endl;
    11261113        }
    11271114      }
     
    11291116  }
    11301117  delete(center);
    1131   *output << "\t}" << endl;
    1132   *output << ")" << endl;
    1133   *output << "basis<GaussianBasisSet>: (" << endl;
    1134   *output << "\tname = \"" << basis << "\"" << endl;
    1135   *output << "\tmolecule = $:molecule" << endl;
    1136   *output << ")" << endl;
    1137   output->close();
    1138   delete(output);
    1139   delete(fname);
    1140 
    1141   // second with hessian
    1142   fname = new stringstream;
    1143   *fname << filename << ".hess.in";
    1144   output = new ofstream(fname->str().c_str(), ios::out);
    1145   *output << "% Created by MoleCuilder" << endl;
    1146   *output << "mpqc: (" << endl;
    1147   *output << "\tsavestate = no" << endl;
    1148   *output << "\tdo_gradient = yes" << endl;
    1149   *output << "\tmole<CLHF>: (" << endl;
    1150   *output << "\t\tmaxiter = 200" << endl;
    1151   *output << "\t\tbasis = $:basis" << endl;
    1152   *output << "\t\tmolecule = $:molecule" << endl;
    1153   *output << "\t)" << endl;
    1154   *output << "\tfreq<MolecularFrequencies>: (" << endl;
    1155   *output << "\t\tmolecule=$:molecule" << endl;
     1118  *output << "\t\t\t}" << endl;
     1119  *output << "\t\t)" << endl;
     1120  *output << "\t\tbasis<GaussianBasisSet>: (" << endl;
     1121  *output << "\t\t\tname = \"STO-3G\"" << endl;
     1122  *output << "\t\t\tmolecule = $:mpqc:mole:molecule" << endl;
     1123  *output << "\t\t)" << endl;
    11561124  *output << "\t)" << endl;
    11571125  *output << ")" << endl;
    1158   *output << "molecule<Molecule>: (" << endl;
    1159   *output << "\tunit = " << (IsAngstroem ? "angstrom" : "bohr" ) << endl;
    1160   *output << "\t{ atoms geometry } = {" << endl;
    1161   center = mol->DetermineCenterOfAll(output);
    1162   // output of atoms
    1163   runner = mol->elemente->start;
    1164   while (runner->next != mol->elemente->end) { // go through every element
    1165     runner = runner->next;
    1166     if (mol->ElementsInMolecule[runner->Z]) { // if this element got atoms
    1167       ElementNo++;
    1168       AtomNo = 0;
    1169       Walker = mol->start;
    1170       while (Walker->next != mol->end) { // go through every atom of this element
    1171         Walker = Walker->next;
    1172         if (Walker->type == runner) { // if this atom fits to element
    1173           AtomNo++;
    1174           *output << "\t\t" << Walker->type->symbol << " [ " << Walker->x.x[0]-center->x[0] << "\t" << Walker->x.x[1]-center->x[1] << "\t" << Walker->x.x[2]-center->x[2] << " ]" << endl;
    1175         }
    1176       }
    1177     }
    1178   }
    1179   delete(center);
    1180   *output << "\t}" << endl;
    1181   *output << ")" << endl;
    1182   *output << "basis<GaussianBasisSet>: (" << endl;
    1183   *output << "\tname = \"3-21G\"" << endl;
    1184   *output << "\tmolecule = $:molecule" << endl;
    1185   *output << ")" << endl;
    1186   output->close();
    1187   delete(output);
    1188   delete(fname);
    1189  
    11901126  return true;
    11911127};
Note: See TracChangeset for help on using the changeset viewer.