/* ** ** PSI Input Class ** ** This helper class will set up input decks for the PSI suite of ** ab initio quantum chemistry programs. ** ** David Sherrill & Justin Fermann ** Center for Computational Quantum Chemistry, University of Georgia ** */ #ifdef __GNUG__ #pragma implementation #endif #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; namespace sc { PsiInput::PsiInput(const string& name) : file_() { filename_ = string(name); indentation_ = 0; } PsiInput::~PsiInput() { } void PsiInput::open() { file_.open(filename_.c_str(),ios::out); indentation_ = 0; } void PsiInput::close() { file_.close(); indentation_ = 0; } void PsiInput::write_indent() { for (int i=0; i 0) indentation_ += i; } void PsiInput::decindent(int i) { if (i > 0) indentation_ -= i; } void PsiInput::begin_section(const char * s) { write_indent(); file_ << s << ":(" << endl; incindent(2); } void PsiInput::end_section(void) { decindent(2); write_indent(); file_ << ")" << endl; write_string("\n"); } void PsiInput::write_keyword(const char *keyword, const char *value) { write_indent(); file_ << scprintf("%s = %s",keyword,value) << endl; } void PsiInput::write_keyword(const char *keyword, int value) { write_indent(); file_ << scprintf("%s = %d",keyword,value) << endl; } void PsiInput::write_keyword(const char *keyword, double value) { write_indent(); file_ << scprintf("%s = %20.15lf",keyword,value) << endl; } void PsiInput::write_keyword_array(const char *keyword, int num, int *values) { write_indent(); file_ << scprintf("%s = (", keyword); for (int i=0; i& mol) { // If the highest symmetry group is not the actual group - use subgroup keyword if (!mol->point_group()->equiv(mol->highest_point_group())) { write_keyword("subgroup",mol->point_group()->symbol()); } write_keyword("units","bohr"); write_string("geometry = (\n"); for (int i=0; i < mol->natom(); i++) { write_string(" ("); char *s; file_ << mol->atom_symbol(i) << scprintf(" %14.12lf %14.12lf %14.12lf",mol->r(i,0),mol->r(i,1),mol->r(i,2)) << ")" << endl; } write_string(")\n"); } void PsiInput::write_basis(const Ref& basis) { Ref molecule = basis->molecule(); int natom = molecule->natom(); write_string("basis = (\n"); incindent(2); for(int atom=0; atomatom_to_unique(atom); // Replace all spaces with underscores in order for Psi libipv1 to parse properly char *name = strdup(basis->name()); int len = strlen(name); for (int i=0; iname()) + ((int)ceil(log10((long double)uatom+2))) + 5]; sprintf(basisname,"\"%s%d\" \n",name,uatom); write_string(basisname); delete[] name; } decindent(2); write_string(")\n"); } void PsiInput::write_basis_sets(const Ref& basis) { begin_section("basis"); Ref molecule = basis->molecule(); Ref atominfo = basis->molecule()->atominfo(); int nunique = molecule->nunique(); for(int uatom=0; uatomunique(uatom); std::string atomname = atominfo->name(molecule->Z(atom)); // Replace all spaces with underscores in order for Psi libipv1 to parse properly char *name = strdup(basis->name()); int len = strlen(name); for (int i=0; iname()) + ((int)ceil(log10((long double)uatom+2))) + 9]; sprintf(psibasisname,"%s:\"%s%d\" = (\n",atomname.c_str(),name,uatom); write_string(psibasisname); delete[] name; incindent(2); int nshell = basis->nshell_on_center(atom); for(int sh=0;shshell_on_center(atom,sh); GaussianShell& Shell = basis->shell(shell); int ncon = Shell.ncontraction(); int nprim = Shell.nprimitive(); for(int con=0; con& exenv, const char *dertype) { begin_section("psi"); write_key_wq("label"," "); write_keyword("dertype",dertype); begin_section("files"); begin_section("default"); write_key_wq("name",(exenv->get_fileprefix()).c_str()); int nscratch = exenv->get_nscratch(); write_keyword("nvolume",nscratch); char *scrname; scrname = new char[10]; for(int i=0; iget_scratch(i)).c_str()); } delete[] scrname; end_section(); write_string("file32: ( nvolume = 1 volume1 = \"./\" )\n"); end_section(); end_section(); } void PsiInput::print(ostream& o) { } }