⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mpqcin.cc

📁 大型并行量子化学软件;支持密度泛函(DFT)。可以进行各种量子化学计算。支持CHARMM并行计算。非常具有应用价值。
💻 CC
📖 第 1 页 / 共 2 页
字号:
  if (a == 0) a = new std::vector<int>;  a->push_back(m);  return a;}intMPQCIn::check_string(const char *s){  checking_ = 1;#ifdef HAVE_SSTREAM  istringstream in(s);#else  istrstream in(s);#endif  lexer_->switch_streams(&in, &ExEnv::outn());  int token;  while ((token = ylex())) {      if (token == T_OO_INPUT_KEYWORD) return 0;    }  checking_ = 0;  return 1;}char *MPQCIn::parse_string(const char *s){  // read in easy input#ifdef HAVE_SSTREAM  istringstream in(s);#else  istrstream in(s);#endif  lexer_->switch_streams(&in, &ExEnv::outn());  yparse();  // form the oo input#ifdef HAVE_SSTREAM  ostringstream ostrs;#else  ostrstream ostrs;#endif  SCFormIO::init_ostream(ostrs);  ostrs << decindent;  if (mol_.null()) error("no molecule given");  if (symmetry_.set() && strcmp(symmetry_.val(),"auto") != 0) {      mol_->symmetrize(new PointGroup(symmetry_.val()));    }  ostrs << indent << "molecule<Molecule>: (" << endl;  ostrs << incindent;  ostrs << indent << "symmetry = "        << (symmetry_.set()?symmetry_.val():"auto") << endl;  ostrs << indent << "unit = \""        << (molecule_bohr_.val()?"bohr":"angstrom")        << "\"" << endl;  mol_->print_parsedkeyval(ostrs, 0, 0, 0);  ostrs << decindent;  ostrs << indent << ")" << endl;  write_basis_object(ostrs, "basis", basis_.val());  ostrs << indent << "mpqc: (" << endl;  ostrs << incindent;  ostrs << indent << "do_gradient = " << gradient_.val() << endl;  ostrs << indent << "optimize = " << optimize_.val() << endl;  ostrs << indent << "restart = " << restart_.val() << endl;  ostrs << indent << "checkpoint = " << checkpoint_.val() << endl;  ostrs << indent << "savestate = " << checkpoint_.val() << endl;  write_energy_object(ostrs, "mole", method_.val(), 0, optimize_.val());  if (optimize_.val()) {      const char *coortype = "SymmMolecularCoor";      if (opt_type_.val() == T_CARTESIAN) coortype = "CartMolecularCoor";      else if (redund_coor_.val()) coortype = "RedundMolecularCoor";      ostrs << indent << "coor<" << coortype << ">: (" << endl;      ostrs << indent << "  molecule = $:molecule" << endl;      if (opt_type_.val() == T_INTERNAL) {          ostrs << indent << "  generator<IntCoorGen>: (" << endl;          ostrs << indent << "    molecule = $:molecule" << endl;          ostrs << indent << "  )" << endl;        }      ostrs << indent << ")" << endl;      ostrs << indent << "opt<QNewtonOpt>: (" << endl;      ostrs << indent << "  function = $:mpqc:mole" << endl;      ostrs << indent << "  update<BFGSUpdate>: ()" << endl;      ostrs << indent << "  convergence<MolEnergyConvergence>: (" << endl;      ostrs << indent << "    cartesian = yes" << endl;      ostrs << indent << "    energy = $:mpqc:mole" << endl;      ostrs << indent << "  )" << endl;      ostrs << indent << ")" << endl;    }  if (frequencies_.val()) {      ostrs << indent << "freq<MolecularFrequencies>: (" << endl;      ostrs << indent << "  molecule = $:molecule" << endl;      ostrs << indent << ")" << endl;    }  ostrs << decindent;  ostrs << indent << ")" << endl;  ostrs << ends;#ifdef HAVE_SSTREAM  int n = 1 + strlen(ostrs.str().c_str());  char *in_char_array = strcpy(new char[n],ostrs.str().c_str());#else  char *in_char_array = ostrs.str();#endif  return in_char_array;}voidMPQCIn::write_vector(ostream &ostrs,                     const char *keyvalname,                     const char *name, MPQCInDatum<std::vector<int> *>&vec,                     int require_nirrep){  if (vec.set()) {      ostrs << indent << keyvalname << " = ";      if (!require_nirrep && vec.val()->size() == 1) {          ostrs << (*vec.val())[0] << endl;        }      else if (nirrep_ && vec.val()->size() == nirrep_) {          ostrs << "[";              for (int i=0; i<nirrep_; i++) {                  ostrs << " " << (*vec.val())[i];                }          ostrs << "]" << endl;        }      else {          if (!require_nirrep) error2("need 1 or n_irrep elements in ", name);          else {              error2("need n_irrep (must give symmetry) elements in ", name);            }        }    }}voidMPQCIn::write_energy_object(ostream &ostrs,                            const char *keyword,                            const char *method,                            const char *basis,                            int coor, bool need_cints){  int nelectron = int(mol_->nuclear_charge()+1e-6) - charge_.val();  if (nelectron < 0) {      error("charge is impossibly large");    }  if (nelectron%2 == 0 && mult_.val()%2 == 0      ||nelectron%2 == 1 && mult_.val()%2 == 1) {      error("given multiplicity is not possible");    }  const char *method_object = 0;  const char *reference_method = 0;  const char *guess_method = method;  const char *auxbasis_key = 0;  int dft = 0;  int uscf = 0;  ostringstream o_extra;  if (method) {      // Hartree-Fock methods      if (!strcmp(method, "HF")) {          if (mult_.val() == 1) method_object = "CLHF";          else { uscf = 1; method_object = "UHF"; }        }      else if (!strcmp(method, "RHF")) {          if (mult_.val() == 1) method_object = "CLHF";          else method_object = "HSOSHF";        }      else if (!strcmp(method, "UHF")) {          method_object = "UHF";          uscf = 1;        }      // Density Functional Methods      else if (!strcmp(method, "KS")) {          guess_method = "HF";          if (mult_.val() == 1) method_object = "CLKS";          else { uscf = 1; method_object = "UKS"; }          dft = 1;        }      else if (!strcmp(method, "RKS")) {          guess_method = "RHF";          if (mult_.val() == 1) method_object = "CLKS";          else method_object = "HSOSKS";          dft = 1;        }      else if (!strcmp(method, "UKS")) {          guess_method = "UHF";          method_object = "UKS";          dft = 1;          uscf = 1;        }      // Perturbation Theory      else if (!strcmp(method, "MP2")) {          guess_method = 0;          method_object = "MBPT2";          reference_method = "HF";          if (mult_.val() != 1) {              error("MP2 can only be used with multiplicity 1: try ZAPT2");            }        }      // Perturbation Theory      else if (!strcmp(method, "MP2-R12/A")) {          need_cints = true;          auxbasis_key = "aux_basis";          guess_method = 0;          method_object = "MBPT2_R12";          reference_method = "HF";          o_extra << "stdapprox = \"A\"" << endl;          if (mult_.val() != 1) {              error("MP2-R12 can only be used with multiplicity 1");            }        }      // Perturbation Theory      else if (!strcmp(method, "MP2-R12/A'")) {          need_cints = true;          auxbasis_key = "aux_basis";          guess_method = 0;          method_object = "MBPT2_R12";          reference_method = "HF";          o_extra << "stdapprox = \"A'\"" << endl;          if (mult_.val() != 1) {              error("MP2-R12 can only be used with multiplicity 1");            }        }      else if (!strcmp(method, "ZAPT2")) {          guess_method = 0;          method_object = "MBPT2";          reference_method = "RHF";          if (mult_.val() == 1) {              error("ZAPT2 can only be used with multiplicity != 1: try MP2");            }          if (optimize_.val() || gradient_.val() || frequencies_.val()) {              error("cannot do a gradient or optimization with ZAPT2");            }        }      else error2("invalid method: ", method);    }  else error("no method given");  ostrs << indent << keyword << "<" << method_object << ">: (" << endl;  ostrs << incindent;  if (o_extra.str() != "") ostrs << indent << o_extra.str();  if (auxbasis_key      && auxbasis_.val() != 0      && strcmp(auxbasis_.val(),basis_.val()) != 0) write_basis_object(ostrs, auxbasis_key, auxbasis_.val());  if (need_cints) ostrs << indent << "integrals<IntegralCints>: ()" << endl;  ostrs << indent << "total_charge = " << charge_.val() << endl;  ostrs << indent << "molecule = $:molecule" << endl;  if (memory_.val()) ostrs << indent << "memory = " << memory_.val() << endl;  if (!strcmp(keyword, "mole") && !reference_method) {      ostrs << indent << "print_npa = 1" << endl;    }  if (reference_method) {      write_vector(ostrs, "nfzc", "frozen_docc", frozen_docc_, 0);      write_vector(ostrs, "nfzv", "frozen_uocc", frozen_uocc_, 0);    }  else {      if (uscf && (docc_.set() || socc_.set())) {          error("cannot set docc or socc for unrestricted methods"                " (use alpha and beta)");        }      else if (uscf) {          write_vector(ostrs, "alpha", "alpha", alpha_, 1);          write_vector(ostrs, "beta", "beta", beta_, 1);        }      else if (alpha_.set() || beta_.set()) {          error("cannot set alpha or beta for restricted methods"                " (use docc and socc)");        }      else {          write_vector(ostrs, "docc", "docc", docc_, 1);          write_vector(ostrs, "socc", "socc", socc_, 1);        }    }  if (coor) ostrs << indent << "coor = $:mpqc:coor" << endl;  if (basis) {      write_basis_object(ostrs, "basis", basis);    }  else {      ostrs << indent << "basis = $:basis" << endl;    }  if (dft) {      if (method_xc_.set()) {          ostrs << indent << "functional<StdDenFunctional>: ( name = \""                << method_xc_.val()                << "\" )" << endl;        }      else error("no exchange-correlation functional given");      if (method_grid_.set()) {          ostrs << indent << "integrator<RadialAngularIntegrator>: ( grid = \""                << method_grid_.val()                << "\" )" << endl;        }    }  if (dft || (!(basis                && !strncmp("STO",basis,3))              && !(basis                   && !strncmp("DZ",basis,2))              && strncmp("STO",basis_.val(),3)              && guess_method)) {      if (frequencies_.val()) {          ostrs << indent << "keep_guess_wavefunction = 1" << endl;;        }      const char *guess_basis;      if (need_cints) guess_basis = "DZ (Dunning)";      else guess_basis = "STO-3G";      write_energy_object(ostrs, "guess_wavefunction",                          guess_method, guess_basis, 0, need_cints);    }  if (reference_method) {      ostrs << indent << "nfzc = auto" << endl;;      write_energy_object(ostrs, "reference",                          reference_method, 0, 0, need_cints);    }  ostrs << decindent;  ostrs << indent << ")" << endl;}voidMPQCIn::write_basis_object(ostream &ostrs,                           const char *keyword,                           const char *basis){  if (!basis) error("no basis given");  ostrs << indent << keyword << "<GaussianBasisSet>: (" << endl;  ostrs << incindent;  ostrs << indent << "molecule = $:molecule" << endl;  ostrs << indent << "name = \"" << basis << "\"" << endl;  ostrs << decindent;  ostrs << indent << ")" << endl;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -