source: ThirdParty/mpqc_open/src/lib/chemistry/qc/wfn/accum.cc

Candidate_v1.6.1
Last change on this file 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.8 KB
Line 
1//
2// accum.cc
3//
4// Copyright (C) 1996 Limit Point Systems, Inc.
5//
6// Author: Curtis Janssen <cljanss@limitpt.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 Library 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.LIB. 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 __GNUC__
29#pragma implementation
30#endif
31
32#include <util/state/stateio.h>
33#include <chemistry/qc/wfn/accum.h>
34#include <chemistry/qc/basis/integral.h>
35
36using namespace sc;
37
38///////////////////////////////////////////////////////////////////////////
39// AccumH
40
41static ClassDesc AccumH_cd(
42 typeid(AccumH),"AccumH",1,"public SavableState",
43 0, 0, 0);
44
45AccumH::AccumH()
46{
47}
48
49AccumH::AccumH(StateIn&s) :
50 SavableState(s)
51{
52 wfn_ << SavableState::restore_state(s);
53}
54
55AccumH::AccumH(const Ref<KeyVal>& keyval)
56{
57 wfn_ << keyval->describedclassvalue("wavefunction");
58}
59
60AccumH::~AccumH()
61{
62}
63
64void
65AccumH::save_data_state(StateOut& s)
66{
67 SavableState::save_state(wfn_.pointer(),s);
68}
69
70void
71AccumH::init(const Ref<Wavefunction>& w)
72{
73 wfn_ = w;
74}
75
76void
77AccumH::done()
78{
79 wfn_ = 0;
80}
81
82void
83AccumH::print_summary()
84{
85}
86
87double
88AccumH::e()
89{
90 return 0.0;
91}
92
93///////////////////////////////////////////////////////////////////////////
94// AccumHNull
95
96static ClassDesc AccumHNull_cd(
97 typeid(AccumHNull),"AccumHNull",1,"public AccumH",
98 create<AccumHNull>, create<AccumHNull>, create<AccumHNull>);
99
100AccumHNull::AccumHNull()
101{
102}
103
104AccumHNull::AccumHNull(StateIn&s) :
105 SavableState(s),
106 AccumH(s)
107{
108}
109
110AccumHNull::AccumHNull(const Ref<KeyVal>& keyval) :
111 AccumH(keyval)
112{
113}
114
115AccumHNull::~AccumHNull()
116{
117}
118
119void
120AccumHNull::save_data_state(StateOut& s)
121{
122 AccumH::save_data_state(s);
123}
124
125void
126AccumHNull::accum(const RefSymmSCMatrix& h)
127{
128}
129
130/////////////////////////////////////////////////////////////////////////////
131// SumAccumH
132
133static ClassDesc SumAccumH_cd(
134 typeid(SumAccumH),"SumAccumH",1,"public AccumH",
135 0, create<SumAccumH>, create<SumAccumH>);
136
137SumAccumH::SumAccumH(StateIn& s) :
138 SavableState(s),
139 AccumH(s)
140{
141 s.get(n_);
142 accums_ = new Ref<AccumH>[n_];
143 for (int i=0; i < n_; i++)
144 accums_[i] << SavableState::restore_state(s);
145}
146
147SumAccumH::SumAccumH(const Ref<KeyVal>& keyval) :
148 AccumH(keyval)
149{
150 n_ = keyval->count("accums");
151 accums_ = new Ref<AccumH>[n_];
152 for (int i=0; i < n_; i++)
153 accums_[i] << keyval->describedclassvalue("accums", i);
154}
155
156SumAccumH::~SumAccumH()
157{
158 if (accums_) {
159 delete[] accums_;
160 accums_=0;
161 }
162 n_=0;
163}
164
165void
166SumAccumH::save_data_state(StateOut& s)
167{
168 AccumH::save_data_state(s);
169 s.put(n_);
170 for (int i=0; i < n_; i++)
171 SavableState::save_state(accums_[i].pointer(),s);
172}
173
174void
175SumAccumH::init(const Ref<Wavefunction>& w)
176{
177 for (int i=0; i < n_; i++)
178 accums_[i]->init(w);
179}
180
181void
182SumAccumH::accum(const RefSymmSCMatrix& h)
183{
184 for (int i=0; i < n_; i++)
185 accums_[i]->accum(h);
186}
187
188void
189SumAccumH::done()
190{
191 for (int i=0; i < n_; i++)
192 accums_[i]->done();
193}
194
195double
196SumAccumH::e()
197{
198 double te = 0.0;
199
200 for (int i=0; i < n_; i++) {
201 te += accums_[i]->e();
202 }
203
204 return te;
205}
206
207/////////////////////////////////////////////////////////////////////////////
208
209// Local Variables:
210// mode: c++
211// c-file-style: "ETS"
212// End:
Note: See TracBrowser for help on using the repository browser.