source: ThirdParty/mpqc_open/src/lib/chemistry/qc/scf/scfops.cc@ 1513599

Action_Thermostats Add_AtomRandomPerturbation Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests AutomationFragmentation_failures Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_ChronosMutex Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion GeometryObjects Gui_displays_atomic_force_velocity IndependentFragmentGrids_IntegrationTest JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks RotateToPrincipalAxisSystem_UndoRedo StoppableMakroAction Subpackage_levmar Subpackage_vmg ThirdParty_MPQC_rebuilt_buildsystem TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes stable
Last change on this file since 1513599 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// 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
37using namespace sc;
38
39SCFEnergy::SCFEnergy()
40 : eelec(0), deferred_(0)
41{
42}
43
44SCFEnergy::~SCFEnergy()
45{
46}
47
48int
49SCFEnergy::has_collect()
50{
51 return 1;
52}
53
54void
55SCFEnergy::defer_collect(int h)
56{
57 deferred_=h;
58}
59
60void
61SCFEnergy::collect(const Ref<MessageGrp>&grp)
62{
63 if (!deferred_)
64 grp->sum(eelec);
65}
66
67double
68SCFEnergy::result()
69{
70 return eelec;
71}
72
73void
74SCFEnergy::reset()
75{
76 eelec=0.0;
77}
78
79void
80SCFEnergy::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
90LevelShift::LevelShift(SCF *s) :
91 scf_(s)
92{
93 shift=0.0;
94}
95
96LevelShift::~LevelShift()
97{
98}
99
100int
101LevelShift::has_side_effects()
102{
103 return 1;
104}
105
106void
107LevelShift::set_shift(double s)
108{
109 shift=s;
110}
111
112void
113LevelShift::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
129ALevelShift::ALevelShift(SCF *s) :
130 LevelShift(s)
131{
132}
133
134ALevelShift::~ALevelShift()
135{
136}
137
138void
139ALevelShift::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
155BLevelShift::BLevelShift(SCF *s) :
156 LevelShift(s)
157{
158}
159
160BLevelShift::~BLevelShift()
161{
162}
163
164void
165BLevelShift::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
183MOLagrangian::MOLagrangian(SCF *s) :
184 scf_(s)
185{
186}
187
188MOLagrangian::~MOLagrangian()
189{
190}
191
192int
193MOLagrangian::has_side_effects()
194{
195 return 1;
196}
197
198void
199MOLagrangian::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:
Note: See TracBrowser for help on using the repository browser.