1 | //
|
---|
2 | // scfden.cc
|
---|
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 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 <math/scmat/offset.h>
|
---|
33 | #include <math/scmat/blkiter.h>
|
---|
34 |
|
---|
35 | #include <chemistry/qc/scf/scfops.h>
|
---|
36 |
|
---|
37 | using namespace sc;
|
---|
38 |
|
---|
39 | SCFEnergy::SCFEnergy()
|
---|
40 | : eelec(0), deferred_(0)
|
---|
41 | {
|
---|
42 | }
|
---|
43 |
|
---|
44 | SCFEnergy::~SCFEnergy()
|
---|
45 | {
|
---|
46 | }
|
---|
47 |
|
---|
48 | int
|
---|
49 | SCFEnergy::has_collect()
|
---|
50 | {
|
---|
51 | return 1;
|
---|
52 | }
|
---|
53 |
|
---|
54 | void
|
---|
55 | SCFEnergy::defer_collect(int h)
|
---|
56 | {
|
---|
57 | deferred_=h;
|
---|
58 | }
|
---|
59 |
|
---|
60 | void
|
---|
61 | SCFEnergy::collect(const Ref<MessageGrp>&grp)
|
---|
62 | {
|
---|
63 | if (!deferred_)
|
---|
64 | grp->sum(eelec);
|
---|
65 | }
|
---|
66 |
|
---|
67 | double
|
---|
68 | SCFEnergy::result()
|
---|
69 | {
|
---|
70 | return eelec;
|
---|
71 | }
|
---|
72 |
|
---|
73 | void
|
---|
74 | SCFEnergy::reset()
|
---|
75 | {
|
---|
76 | eelec=0.0;
|
---|
77 | }
|
---|
78 |
|
---|
79 | void
|
---|
80 | SCFEnergy::process(SCMatrixBlockIter&i, SCMatrixBlockIter&j)
|
---|
81 | {
|
---|
82 | for (i.reset(), j.reset(); i && j; i++, j++) {
|
---|
83 | int ii=i.i(); int jj=j.j();
|
---|
84 | eelec += (ii==jj) ? 0.5*j.get()*i.get() : i.get()*j.get();
|
---|
85 | }
|
---|
86 | }
|
---|
87 |
|
---|
88 | //////////////////////////////////////////////////////////////////////////////
|
---|
89 |
|
---|
90 | LevelShift::LevelShift(SCF *s) :
|
---|
91 | scf_(s)
|
---|
92 | {
|
---|
93 | shift=0.0;
|
---|
94 | }
|
---|
95 |
|
---|
96 | LevelShift::~LevelShift()
|
---|
97 | {
|
---|
98 | }
|
---|
99 |
|
---|
100 | int
|
---|
101 | LevelShift::has_side_effects()
|
---|
102 | {
|
---|
103 | return 1;
|
---|
104 | }
|
---|
105 |
|
---|
106 | void
|
---|
107 | LevelShift::set_shift(double s)
|
---|
108 | {
|
---|
109 | shift=s;
|
---|
110 | }
|
---|
111 |
|
---|
112 | void
|
---|
113 | LevelShift::process(SCMatrixBlockIter& i)
|
---|
114 | {
|
---|
115 | int ir=current_block();
|
---|
116 | for (i.reset(); i; i++) {
|
---|
117 | if (i.i() != i.j())
|
---|
118 | continue;
|
---|
119 |
|
---|
120 | double occi = scf_->occupation(ir,i.i());
|
---|
121 |
|
---|
122 | if (occi==scf_->occupation(ir,0))
|
---|
123 | i.set(i.get()-shift);
|
---|
124 | else if (occi>0.0)
|
---|
125 | i.set(i.get()-0.5*shift);
|
---|
126 | }
|
---|
127 | }
|
---|
128 |
|
---|
129 | ALevelShift::ALevelShift(SCF *s) :
|
---|
130 | LevelShift(s)
|
---|
131 | {
|
---|
132 | }
|
---|
133 |
|
---|
134 | ALevelShift::~ALevelShift()
|
---|
135 | {
|
---|
136 | }
|
---|
137 |
|
---|
138 | void
|
---|
139 | ALevelShift::process(SCMatrixBlockIter& i)
|
---|
140 | {
|
---|
141 | int ir=current_block();
|
---|
142 | for (i.reset(); i; i++) {
|
---|
143 | if (i.i() != i.j())
|
---|
144 | continue;
|
---|
145 |
|
---|
146 | double occi = scf_->alpha_occupation(ir,i.i());
|
---|
147 |
|
---|
148 | if (occi==scf_->alpha_occupation(ir,0))
|
---|
149 | i.set(i.get()-shift);
|
---|
150 | else if (occi>0.0)
|
---|
151 | i.set(i.get()-0.5*shift);
|
---|
152 | }
|
---|
153 | }
|
---|
154 |
|
---|
155 | BLevelShift::BLevelShift(SCF *s) :
|
---|
156 | LevelShift(s)
|
---|
157 | {
|
---|
158 | }
|
---|
159 |
|
---|
160 | BLevelShift::~BLevelShift()
|
---|
161 | {
|
---|
162 | }
|
---|
163 |
|
---|
164 | void
|
---|
165 | BLevelShift::process(SCMatrixBlockIter& i)
|
---|
166 | {
|
---|
167 | int ir=current_block();
|
---|
168 | for (i.reset(); i; i++) {
|
---|
169 | if (i.i() != i.j())
|
---|
170 | continue;
|
---|
171 |
|
---|
172 | double occi = scf_->beta_occupation(ir,i.i());
|
---|
173 |
|
---|
174 | if (occi==scf_->beta_occupation(ir,0))
|
---|
175 | i.set(i.get()-shift);
|
---|
176 | else if (occi>0.0)
|
---|
177 | i.set(i.get()-0.5*shift);
|
---|
178 | }
|
---|
179 | }
|
---|
180 |
|
---|
181 | //////////////////////////////////////////////////////////////////////////////
|
---|
182 |
|
---|
183 | MOLagrangian::MOLagrangian(SCF *s) :
|
---|
184 | scf_(s)
|
---|
185 | {
|
---|
186 | }
|
---|
187 |
|
---|
188 | MOLagrangian::~MOLagrangian()
|
---|
189 | {
|
---|
190 | }
|
---|
191 |
|
---|
192 | int
|
---|
193 | MOLagrangian::has_side_effects()
|
---|
194 | {
|
---|
195 | return 1;
|
---|
196 | }
|
---|
197 |
|
---|
198 | void
|
---|
199 | MOLagrangian::process(SCMatrixBlockIter& bi1, SCMatrixBlockIter& bi2)
|
---|
200 | {
|
---|
201 | int ir=current_block();
|
---|
202 |
|
---|
203 | for (bi1.reset(), bi2.reset(); bi1 && bi2; bi1++, bi2++) {
|
---|
204 | double occi = scf_->occupation(ir,bi1.i());
|
---|
205 | double occj = scf_->occupation(ir,bi1.j());
|
---|
206 |
|
---|
207 | if (occi > 0.0 && occi < 2.0 && occj > 0.0 && occj < 2.0)
|
---|
208 | bi1.set(bi2.get());
|
---|
209 | else if (occi==0.0)
|
---|
210 | bi1.set(0.0);
|
---|
211 | }
|
---|
212 | }
|
---|
213 |
|
---|
214 | /////////////////////////////////////////////////////////////////////////////
|
---|
215 |
|
---|
216 | // Local Variables:
|
---|
217 | // mode: c++
|
---|
218 | // c-file-style: "ETS"
|
---|
219 | // End:
|
---|