📄 mpqcin.cc
字号:
#include <scconfig.h>#ifdef HAVE_SSTREAM# include <sstream>#else# include <strstream.h>#endif#include <stdlib.h>#include <util/misc/formio.h>using namespace std;using namespace sc;#undef yyFlexLexer#define yyFlexLexer MPQCInFlexLexer#include <FlexLexer.h>#include "mpqcin.h"#include "parse.h"int MPQCIn::checking_ = 0;MPQCIn::MPQCIn(): nirrep_(0), mult_(1), charge_(0), basis_(0), auxbasis_(0), method_(0), optimize_(0), gradient_(0), frequencies_(0), opt_type_(T_INTERNAL), redund_coor_(0), restart_(0), checkpoint_(1), atom_charge_(0), method_xc_(0), method_grid_(0), symmetry_(0), memory_(0), molecule_bohr_(0), alpha_(0), beta_(0), docc_(0), socc_(0), frozen_docc_(0), frozen_uocc_(0){ lexer_ = new MPQCInFlexLexer;}MPQCIn::~MPQCIn(){ delete lexer_; if (basis_.val()) free(basis_.val()); if (auxbasis_.val()) free(auxbasis_.val()); if (method_.val()) free(method_.val()); if (method_xc_.val()) free(method_xc_.val()); if (method_grid_.val()) free(method_grid_.val()); if (symmetry_.val()) free(symmetry_.val()); if (memory_.val()) free(memory_.val()); if (alpha_.val()) free(alpha_.val()); if (beta_.val()) free(beta_.val()); if (docc_.val()) free(docc_.val()); if (socc_.val()) free(socc_.val()); if (frozen_docc_.val()) free(frozen_docc_.val()); if (frozen_uocc_.val()) free(frozen_uocc_.val());}voidMPQCIn::error(const char* s){ ExEnv::outn() << ExEnv::program_name() << ": error: " << s << endl; abort();}voidMPQCIn::error2(const char* s, const char *s2){ ExEnv::outn() << ExEnv::program_name() << ": error: " << s << "\"" << s2 << "\"" << endl; abort();}voidMPQCIn::yerror(const char* s){ ExEnv::outn() << ExEnv::program_name() << ": " << s << " at line " << lexer_->lineno()+1 << endl; abort();}voidMPQCIn::yerror2(const char* s, const char *s2){ ExEnv::outn() << ExEnv::program_name() << ": " << s << " \"" << s2 << "\" at line " << lexer_->lineno()+1 << endl; abort();}intMPQCIn::ylex(){ return lexer_->yylex();}voidMPQCIn::begin_molecule(){ if (mol_.nonnull()) { ExEnv::outn() << ExEnv::program_name() << ": error: second molecule given at line " << lexer_->lineno()+1 << endl; abort(); } mol_ = new Molecule;}voidMPQCIn::end_molecule(){ //double symtol = 1e-4; //mol_->set_point_group(mol_->highest_point_group(symtol), symtol*10.0);}voidMPQCIn::add_atom(char *sym, char *xs, char *ys, char *zs){ int Z = AtomInfo::string_to_Z(sym, 0); if (Z == 0) yerror2("bad element", sym); free(sym); char *xse; double x = strtod(xs,&xse); if (xse == xs) yerror2("bad x coordinate", xs); free(xs); char *yse; double y = strtod(ys,&yse); if (yse == ys) yerror2("bad y coordinate", ys); free(ys); char *zse; double z = strtod(zs,&zse); if (zse == zs) yerror2("bad z coordinate", zs); free(zs); mol_->add_atom(Z, x, y, z, 0, 0, atom_charge_.set(), atom_charge_.val()); atom_charge_.reset(0);}voidMPQCIn::set_charge(char *cs){ char *cse; int c = strtol(cs,&cse,10); if (cse == cs) yerror2("bad charge", cs); charge_ = c; free(cs);}voidMPQCIn::set_atom_charge(char *cs){ char *cse; int c = strtol(cs,&cse,10); if (cse == cs) yerror2("bad atom charge", cs); atom_charge_ = c; free(cs);}voidMPQCIn::set_method(char *m){ method_ = m;}voidMPQCIn::set_method_xc(char *m){ method_xc_ = m;}voidMPQCIn::set_method_grid(char *m){ method_grid_ = m;}voidMPQCIn::set_molecule_bohr(int i){ molecule_bohr_ = i;}voidMPQCIn::set_basis(char *b){ basis_ = b;}voidMPQCIn::set_auxbasis(char *b){ auxbasis_ = b;}voidMPQCIn::set_symmetry(char *s){ symmetry_ = s; if (strcmp(s,"auto")) { Ref<PointGroup> p = new PointGroup(s); nirrep_ = p->char_table().nirrep(); }}voidMPQCIn::set_memory(char *s){ memory_ = s;}voidMPQCIn::set_multiplicity(char *ms){ char *mse; int m = strtol(ms,&mse,10); if (mse == ms || m <= 0) yerror2("bad multiplicity", ms); mult_ = m; free(ms);}voidMPQCIn::set_optimize(int i){ optimize_ = i;}voidMPQCIn::set_gradient(int i){ gradient_ = i;}voidMPQCIn::set_frequencies(int i){ frequencies_ = i;}voidMPQCIn::set_restart(int i){ restart_ = i;}voidMPQCIn::set_checkpoint(int i){ checkpoint_ = i;}voidMPQCIn::set_redund_coor(int i){ redund_coor_ = i;}voidMPQCIn::set_opt_type(int i){ opt_type_ = i;}voidMPQCIn::set_docc(std::vector<int> *a){ docc_ = a;}voidMPQCIn::set_socc(std::vector<int> *a){ socc_ = a;}voidMPQCIn::set_alpha(std::vector<int> *a){ alpha_ = a;}voidMPQCIn::set_beta(std::vector<int> *a){ beta_ = a;}voidMPQCIn::set_frozen_docc(std::vector<int> *a){ frozen_docc_ = a;}voidMPQCIn::set_frozen_uocc(std::vector<int> *a){ frozen_uocc_ = a;}std::vector<int> *MPQCIn::make_nnivec(std::vector<int> *a, char *ms){ if (ms == 0) return new std::vector<int>; char *mse; int m = strtol(ms,&mse,10); if (mse == ms || m < 0) yerror2("bad positive integer", ms); free(ms);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -