Debian Codegraph @

exportccdlg.cpp

raw symbols SCIP
1 #include "exportccdlg.h"
2 #include <QLabel>
3
4 ExportCCDlg::ExportCCDlg(QString _dirName, Molecule *_mole, QString fn){
5 mole=_mole;
6 dirName=_dirName;
7 V3 Vo=V3(0,0,0);
8 //double a0= 1.0 / 0.5291772109;
9 f.setFileName(fn);
10 QFileInfo fileInfo(f.fileName());
11 filenameQM = fileInfo.baseName();
12
13 //QDialog *dlg = new QDialog();
14 setWindowTitle(QString("Export coordinates for Gaussian"));
15 glt = new QGridLayout(this);
16 titlE = new QLineEdit(QString("from:%1").arg(dirName),this);
17 pe = new QPlainTextEdit(this);
18 QFont font;
19 font.setFamily(FONTFAM);
20 font.setFixedPitch(true);
21 font.setPointSize(11);
22 pe->setFont(font);
23 calcbox = new QComboBox(this);
24 nproc = new QSpinBox(this);
25 mem = new QSpinBox(this);
26 charge = new QSpinBox(this);
27 multipl = new QSpinBox(this);
28 membx = new QComboBox(this);
29 theorbox = new QComboBox(this);
30 basisbox = new QComboBox(this);
31 outputLevel = new QComboBox(this);
32 sve = new QCheckBox("save scratch files",this);
33 chk = new QCheckBox("Checkpoint:",this);
34 spec = new QCheckBox("Special opt:",this);
35 bb = new QDialogButtonBox( QDialogButtonBox::Save | QDialogButtonBox::Cancel);
36
37 if (fn.isEmpty()) {
38 emit rejected();
39 done(QDialog::Rejected);
40 close();
41 }
42
43 calcbox->addItems(QStringList()<<"Single Point Energy"<<"Geometry Optimization"<<"Frequencies");
44 calcbox->setCurrentIndex(2);
45 nproc->setMaximum(99);
46 nproc->setMinimum(1);
47 nproc->setValue(4);
48 mem->setMaximum(1024);
49 mem->setMinimum(1);
50 mem->setValue(200);
51 charge->setMinimum(-99);
52 charge->setMaximum(99);
53 charge->setValue(0);
54 multipl->setMinimum(1);
55 multipl->setMaximum(99);
56 multipl->setValue(1);
57 membx->addItems(QStringList()<<"KB"<<"MB"<<"GB"<<"TB"<<"KW"<<"MW"<<"GW"<<"TW");
58 membx->setCurrentIndex(1);
59 pe->setWordWrapMode(QTextOption::NoWrap);
60 theorbox->addItems(QStringList()<<"AM1"<<"PM3"<<"HF"<<"B3LYP"<<"PBE0BPE"<<"MP2"<<"CCSD");
61 theorbox->setCurrentIndex(3);
62 basisbox->addItems(QStringList()<<"3-21G+"<<"6-21G**"<<"4-31G**"<<"6-31G3pd++"<<"6-311G3pd++"<<"D953pd++"<<"D95V(d,p)++"<<"SHC*"<<"CEP-4G*"<<"CEP-31G*"<<"CEP-121G*"<<"LanL2MB"<<
63 "LanL2DZ"<<"SDD"<<"SDDAll"<<"cc-pVDZ"<<"cc-pVTZ"<<"cc-pVQZ"<<"cc-pV5Z"<<"cc-pV6Z"<<"SV"<<"SVP"<<"TZV"<<"TZVP"<<"QZVP"<<
64 "Def2SV"<<"Def2SVP"<<"Def2SVPP"<<"Def2TZV"<<"Def2TZVP"<<"Def2TZVPP"<<"Def2QZV"<<"Def2QZVP"<<"Def2QZVPP"<<
65 "MidiX"<<"EPR-II"<<"EPR-III"<<
66 "UGBS2++"<<"MTSmall"<<"DGDZVP"<<"DGDZVP2"<<"DGTZVP"<<"CBSB7++");
67 basisbox->setCurrentIndex(26);
68 outputLevel->addItems(QStringList()<<"Normal print level"<<"Additional output"<<"Terse output");
69 sve->setCheckable(true);
70 sve->setChecked(true);
71 chk->setCheckable(true);
72 chk->setChecked(true);
73 spec->setCheckable(true);
74 spec->setChecked(true);
75 //toggled ( bool checked )
76
77 glt->addWidget(new QLabel("Title"),0,0,1,1);
78 glt->addWidget(titlE ,0,1,1,10);
79 glt->addWidget(new QLabel("Calculation:"),1,0,1,1);
80 glt->addWidget(calcbox,1,1,1,1);
81 glt->addWidget(new QLabel("Processors:"),1,2,1,1);
82 glt->addWidget(nproc,1,3,1,1);
83 glt->addWidget(new QLabel("Memory:"),1,4,1,1);
84 glt->addWidget(mem,1,5,1,1);
85 glt->addWidget(membx,1,6,1,1);
86 glt->addWidget(new QLabel("Theory:"),2,0,1,1);
87 glt->addWidget(theorbox,2,1,1,1);
88 glt->addWidget(new QLabel("Basis:"),2,2,1,1);
89 glt->addWidget(basisbox,2,3,1,1);
90 glt->addWidget(sve,2,4,1,1);
91 glt->addWidget(chk,2,5,1,1);
92 glt->addWidget(new QLabel("Charge:"),3,0,1,1);
93 glt->addWidget(charge,3,1,1,1);
94 glt->addWidget(new QLabel("Multiplicity:"),3,2,1,1);
95 glt->addWidget(multipl,3,3,1,1);
96 glt->addWidget(outputLevel,3,4,1,1);
97 glt->addWidget(spec,3,5,1,1);
98 glt->addWidget(pe,15,0,1,10);
99 connect(bb, SIGNAL(accepted()), this, SLOT(accept()));
100 connect(bb, SIGNAL(rejected()), this, SLOT(reject()));
101 glt->addWidget(bb,16,0,1,10);
102
103 // center of molecule
104 int visCount=0;
105 for (int i=0; i<mole->showatoms.size();i++) {
106 if (mole->showatoms.at(i).an<0) continue; //ignore none atoms
107 if ((mole->nopm1)&&(mole->showatoms.at(i).symmGroup)&&(mole->showatoms.at(i).part<-0)) continue; // ignore hidden parts (-1)
108 if (mole->showatoms.at(i).hidden) continue;
109 visCount++;
110 Vo+=mole->showatoms.at(i).pos;
111 }
112 Vo*=1.0/visCount;
113
114
115 // atoms themselves
116 for (int i=0; i< mole->showatoms.size(); i++){
117 if ((mole->showatoms.at(i).an<0)&&(mole->showatoms.at(i).an!=-66)) continue; //ignore none atoms
118 if ((mole->nopm1)&&(mole->showatoms.at(i).symmGroup)&&(mole->showatoms.at(i).part<-0)) continue; // ignore hidden parts (-1)
119 if (mole->showatoms.at(i).hidden) continue;
120 bodyQM.append(QString("%1 %2 %3 %4 \n")
121 .arg((mole->showatoms.at(i).an!=-66)?mole->pse(mole->showatoms.at(i).an):"X",-2)
122 .arg(mole->showatoms.at(i).pos.x-Vo.x,13,'f',10)
123 .arg(mole->showatoms.at(i).pos.y-Vo.y,13,'f',10)
124 .arg(mole->showatoms.at(i).pos.z-Vo.z,13,'f',10) );
125
126 }
127
128
129 footerQM.append(QString("\n\n"));
130
131 makeHeader();
132
133 connect(sve,SIGNAL(toggled(bool)),this,SLOT(makeHeader()));
134 connect(chk,SIGNAL(toggled(bool)),this,SLOT(makeHeader()));
135 connect(spec,SIGNAL(toggled(bool)),this,SLOT(makeHeader()));
136 connect(charge,SIGNAL(valueChanged(int)),this,SLOT(makeHeader()));
137 connect(multipl,SIGNAL(valueChanged(int)),this,SLOT(makeHeader()));
138 connect(mem,SIGNAL(valueChanged(int)),this,SLOT(makeHeader()));
139 connect(nproc,SIGNAL(valueChanged(int)),this,SLOT(makeHeader()));
140 connect(calcbox,SIGNAL(currentIndexChanged(int)),this,SLOT(makeHeader()));
141 connect(membx,SIGNAL(currentIndexChanged(int)),this,SLOT(makeHeader()));
142 connect(theorbox,SIGNAL(currentIndexChanged(int)),this,SLOT(makeHeader()));
143 connect(basisbox,SIGNAL(currentIndexChanged(int)),this,SLOT(makeHeader()));
144 connect(outputLevel,SIGNAL(currentIndexChanged(int)),this,SLOT(makeHeader()));
145 connect(titlE,SIGNAL(editingFinished()),this,SLOT(makeHeader()));
146
147
148
149 }
150 void ExportCCDlg::accept(){
151 bool success = f.open(QIODevice::WriteOnly|QIODevice::Text);
152 if (success){
153 if (pe->toPlainText().isEmpty()) pe->setPlainText(QString("%1%2%3").arg(headerQM).arg(bodyQM).arg(footerQM));
154 f.write(pe->toPlainText().toLatin1());
155 f.close();
156 }
157 done(QDialog::Accepted);
158 }
159 void ExportCCDlg::makeHeader(){
160 headerQM.clear();
161 QString outlev="N";
162 if (outputLevel->currentIndex()==1) outlev="P";
163 if (outputLevel->currentIndex()==2) outlev="T";
164 QString calct = "SP";
165 if (calcbox->currentIndex()==1) calct = "Opt";
166 if (calcbox->currentIndex()==2) calct = "Opt Freq";
167 QString gfout;
168 QString gfin;
169 if (nproc->value()>1) headerQM.append(QString("%NProcShared=%1\n").arg(nproc->value()));
170 if (sve->isChecked()) headerQM.append(QString("%SAVE\n"));
171 if (chk->isChecked()) headerQM.append(QString("%CHK=%1.chk\n").arg(filenameQM));
172 headerQM.append(QString("%MEM=%1%2\n").arg(mem->value()).arg(membx->currentText()));
173 headerQM.append(QString("#%1 %2 %3 %4\n").arg(outlev).arg(calct).arg(gfout).arg(gfin));
174 if (spec->isChecked())headerQM.append(QString("# INT=(GRID=99590) SCF=(MAXCYCLE=250,TIGHT)\n"));
175 headerQM.append(QString("# %1/%2\n\n").arg(theorbox->currentText()).arg(basisbox->currentText()));
176 headerQM.append(QString("%1\n\n").arg(titlE->text()));
177 headerQM.append(QString("%1 %21\n").arg(charge->value()).arg(multipl->value()));
178 pe->setPlainText(QString("%1%2%3").arg(headerQM).arg(bodyQM).arg(footerQM));
179 }