source: ThirdParty/mpqc_open/src/lib/chemistry/qc/scf/scftest.cc@ a844d8

Candidate_v1.6.1
Last change on this file since a844d8 was 860145, checked in by Frederik Heber <heber@…>, 8 years ago

Merge commit '0b990dfaa8c6007a996d030163a25f7f5fc8a7e7' as 'ThirdParty/mpqc_open'

  • Property mode set to 100644
File size: 3.9 KB
Line 
1//
2// scftest.cc --- test program
3//
4// Copyright (C) 1996 Limit Point Systems, Inc.
5//
6// Author: Edward Seidl <seidl@janed.com>
7// Maintainer: LPS
8//
9// This file is part of the SC Toolkit.
10//
11// The SC Toolkit is free software; you can redistribute it and/or modify
12// it under the terms of the GNU General Public License as published by
13// the Free Software Foundation; either version 2, or (at your option)
14// any later version.
15//
16// The SC Toolkit is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU Library General Public License for more details.
20//
21// You should have received a copy of the GNU Library General Public License
22// along with the SC Toolkit; see the file COPYING. If not, write to
23// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24//
25// The U.S. Government is granted a limited license as per AL 91-7.
26//
27
28#ifdef HAVE_CONFIG_H
29#include <scconfig.h>
30#endif
31
32#include <string.h>
33
34#include <sys/stat.h>
35#include <unistd.h>
36#include <new>
37
38#include <util/keyval/keyval.h>
39#include <util/group/message.h>
40#include <util/group/pregtime.h>
41#include <util/misc/bug.h>
42#include <util/misc/formio.h>
43#include <util/state/state_bin.h>
44
45#include <math/optimize/opt.h>
46
47#include <chemistry/molecule/coor.h>
48#include <chemistry/molecule/energy.h>
49
50// Force linkages:
51#include <chemistry/qc/scf/linkage.h>
52
53using namespace std;
54using namespace sc;
55
56Ref<RegionTimer> tim;
57Ref<MessageGrp> grp;
58
59static Ref<MessageGrp>
60init_mp(const Ref<KeyVal>& keyval)
61{
62 // if we are on a paragon then use a ParagonMessageGrp
63 // otherwise read the message group from the input file
64 grp << keyval->describedclassvalue("message");
65
66 if (grp.nonnull()) MessageGrp::set_default_messagegrp(grp);
67 else grp = MessageGrp::get_default_messagegrp();
68
69 Ref<Debugger> debugger; debugger << keyval->describedclassvalue(":debug");
70 // Let the debugger know the name of the executable and the node
71 if (debugger.nonnull()) {
72 debugger->set_exec("scftest");
73 debugger->set_prefix(grp->me());
74 debugger->debug("curt is a hog");
75 }
76
77 tim = new ParallelRegionTimer(grp,"scftest",1,0);
78 RegionTimer::set_default_regiontimer(tim);
79
80 SCFormIO::set_printnode(0);
81 //SCFormIO::set_debug(1);
82
83 SCFormIO::setindent(cout, 2);
84 SCFormIO::setindent(cerr, 2);
85
86 return grp;
87}
88
89main(int argc, char**argv)
90{
91 const char *input = (argc > 1)? argv[1] : SRCDIR "/mpqc.in";
92 const char *keyword = (argc > 2)? argv[2] : "mole";
93 const char *optkeyword = (argc > 3)? argv[3] : "opt";
94
95 // open keyval input
96 Ref<KeyVal> rpkv(new ParsedKeyVal(input));
97
98 init_mp(rpkv);
99
100 tim->enter("input");
101
102 if (rpkv->exists("matrixkit")) {
103 Ref<SCMatrixKit> kit; kit << rpkv->describedclassvalue("matrixkit");
104 SCMatrixKit::set_default_matrixkit(kit);
105 }
106
107 struct stat sb;
108 Ref<MolecularEnergy> mole;
109 Ref<Optimize> opt;
110
111 if (stat("scftest.ckpt",&sb)==0 && sb.st_size) {
112 StateInBin si("scftest.ckpt");
113 opt << SavableState::restore_state(si);
114 mole << opt->function();
115 } else {
116 mole << rpkv->describedclassvalue(keyword);
117 opt << rpkv->describedclassvalue(optkeyword);
118 if (opt.nonnull()) {
119 opt->set_checkpoint();
120 opt->set_checkpoint_file("scftest.ckpt");
121 }
122 }
123
124 tim->exit("input");
125
126 if (mole.nonnull()) {
127 if (mole->gradient_implemented()) {
128 if (opt.nonnull()) {
129 opt->optimize();
130 } else {
131 mole->gradient().print("gradient");
132 }
133 } else if (mole->value_implemented()) {
134 ExEnv::out0() << indent
135 << scprintf("value of mole is %15.10f\n\n", mole->energy());
136 }
137 }
138
139 mole->print(ExEnv::out0());
140
141 StateOutBin so("scftest.wfn");
142 SavableState::save_state(mole.pointer(),so);
143
144 tim->print(ExEnv::out0());
145
146 return 0;
147}
148
149/////////////////////////////////////////////////////////////////////////////
150
151// Local Variables:
152// mode: c++
153// c-file-style: "ETS"
154// End:
Note: See TracBrowser for help on using the repository browser.