source: ThirdParty/mpqc_open/src/lib/chemistry/qc/intcca/int1e.cc@ aae63a

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 aae63a 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: 7.4 KB
Line 
1//
2// int1e.cc
3//
4// Copyright (C) 2004 Sandia National Laboratories.
5//
6// Author: Joseph Kenny <jpkenny@sandia.gov>
7// Maintainer: Joseph Kenny
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 __GNUG__
29#pragma implementation
30#endif
31
32#include <chemistry/qc/intcca/int1e.h>
33#include <util/class/scexception.h>
34#include <Chemistry_Chemistry_QC_GaussianBasis_DerivCenters.hh>
35
36using namespace std;
37using namespace sc;
38using namespace Chemistry;
39using namespace Chemistry::QC::GaussianBasis;
40
41Int1eCCA::Int1eCCA(Integral *integral,
42 const Ref<GaussianBasisSet>&b1,
43 const Ref<GaussianBasisSet>&b2,
44 int order, IntegralEvaluatorFactory eval_factory,
45 std::string int_type, bool use_opaque):
46 bs1_(b1), bs2_(b2),
47 overlap_ptr_(0), kinetic_ptr_(0),
48 nuclear_ptr_(0), hcore_ptr_(0),
49 integral_(integral), eval_factory_(eval_factory), use_opaque_(use_opaque)
50{
51
52 int scratchsize=0,nshell2;
53
54 /* The efield routines look like derivatives so bump up order if
55 * it is zero to allow efield integrals to be computed.
56 */
57 if (order == 0) order = 1;
58
59 nshell2 = bs1_->max_ncartesian_in_shell()*bs2_->max_ncartesian_in_shell();
60
61 if (order == 0)
62 scratchsize = nshell2;
63 else if (order == 1)
64 scratchsize = nshell2*3;
65 else
66 throw InputError("invalid derivative level",
67 __FILE__,__LINE__);
68
69 if( !use_opaque_ )
70 buff_ = new double[scratchsize];
71
72 // create cca basis sets
73 cca_bs1_ = GaussianBasis_Molecular::_create();
74 cca_bs1_.initialize( bs1_.pointer(), bs1_->name() );
75 if( bs1_.pointer() != bs2_.pointer() ) {
76 cca_bs2_ = GaussianBasis_Molecular::_create();
77 cca_bs2_.initialize( bs2_.pointer(), bs2_->name() );
78 }
79 else
80 cca_bs2_ = cca_bs1_;
81
82 cca_dc_ = Chemistry_QC_GaussianBasis_DerivCenters::_create();
83
84 if( int_type == "overlap" ) {
85 overlap_ = eval_factory_.get_integral_evaluator2( "overlap", 0,
86 cca_bs1_, cca_bs2_ );
87 overlap_ptr_ = &overlap_;
88 if( use_opaque_ )
89 buff_ = static_cast<double*>( overlap_ptr_->get_buffer() );
90 }
91
92 else if( int_type == "overlap_1der" ) {
93 overlap_1der_ = eval_factory_.get_integral_evaluator2( "overlap", 1,
94 cca_bs1_, cca_bs2_ );
95 overlap_1der_ptr_ = &overlap_1der_;
96 if( use_opaque_ )
97 buff_ = static_cast<double*>( overlap_1der_ptr_->get_buffer() );
98 }
99
100 else if( int_type == "kinetic" ) {
101 kinetic_ = eval_factory_.get_integral_evaluator2( "kinetic", 0,
102 cca_bs1_, cca_bs2_ );
103 kinetic_ptr_ = &kinetic_;
104 if( use_opaque_ )
105 buff_ = static_cast<double*>( kinetic_ptr_->get_buffer() );
106 }
107
108 else if( int_type == "kinetic_1der" ) {
109 kinetic_1der_ = eval_factory_.get_integral_evaluator2( "kinetic", 1,
110 cca_bs1_, cca_bs2_ );
111 kinetic_1der_ptr_ = &kinetic_1der_;
112 if( use_opaque_ )
113 buff_ = static_cast<double*>( kinetic_1der_ptr_->get_buffer() );
114 }
115
116 else if( int_type == "nuclear" ) {
117 nuclear_ = eval_factory_.get_integral_evaluator2( "potential", 0,
118 cca_bs1_, cca_bs2_ );
119 nuclear_ptr_ = &nuclear_;
120 if( use_opaque_ )
121 buff_ = static_cast<double*>( nuclear_ptr_->get_buffer() );
122 }
123
124 else if( int_type == "nuclear_1der" ) {
125 nuclear_1der_ = eval_factory_.get_integral_evaluator2( "potential", 1,
126 cca_bs1_, cca_bs2_ );
127 nuclear_1der_ptr_ = &nuclear_1der_;
128 if( use_opaque_ )
129 buff_ = static_cast<double*>( nuclear_1der_ptr_->get_buffer() );
130 }
131
132 else if( int_type == "hcore" ) {
133 hcore_ = eval_factory_.get_integral_evaluator2( "1eham", 0,
134 cca_bs1_, cca_bs2_ );
135 hcore_ptr_ = &hcore_;
136 if( use_opaque_ )
137 buff_ = static_cast<double*>( hcore_ptr_->get_buffer() );
138 }
139
140 else if( int_type == "hcore_1der" ) {
141 hcore_1der_ = eval_factory_.get_integral_evaluator2( "1eham", 1,
142 cca_bs1_, cca_bs2_ );
143 hcore_1der_ptr_ = &hcore_1der_;
144 if( use_opaque_ )
145 buff_ = static_cast<double*>( hcore_1der_ptr_->get_buffer() );
146 }
147
148}
149
150Int1eCCA::~Int1eCCA()
151{
152}
153
154void
155Int1eCCA::overlap( int ish, int jsh )
156{
157 cca_dc_.clear();
158 if( use_opaque_ )
159 overlap_ptr_->compute( ish, jsh, 0, cca_dc_ );
160 else {
161 sidl_buffer_ = overlap_ptr_->compute_array( ish, jsh, 0, cca_dc_ );
162 copy_buffer();
163 }
164}
165
166void
167Int1eCCA::overlap_1der(int ish, int jsh,
168 Chemistry_QC_GaussianBasis_DerivCenters &dc)
169{
170 if( use_opaque_ )
171 overlap_1der_ptr_->compute( ish, jsh, 1, dc );
172 else {
173 sidl_buffer_ = overlap_1der_ptr_->compute_array( ish, jsh, 1, dc );
174 copy_buffer();
175 }
176}
177
178void
179Int1eCCA::kinetic( int ish, int jsh )
180{
181 cca_dc_.clear();
182 if( use_opaque_ )
183 kinetic_ptr_->compute( ish, jsh, 0, cca_dc_ );
184 else {
185 sidl_buffer_ = kinetic_ptr_->compute_array( ish, jsh, 0, cca_dc_ );
186 copy_buffer();
187 }
188}
189
190void
191Int1eCCA::kinetic_1der(int ish, int jsh,
192 Chemistry_QC_GaussianBasis_DerivCenters &dc)
193{
194 if( use_opaque_ )
195 kinetic_1der_ptr_->compute( ish, jsh, 1, dc );
196 else {
197 sidl_buffer_ = kinetic_1der_ptr_->compute_array( ish, jsh, 1, dc );
198 copy_buffer();
199 }
200}
201
202
203void
204Int1eCCA::nuclear( int ish, int jsh )
205{
206 cca_dc_.clear();
207 if( use_opaque_ )
208 nuclear_ptr_->compute( ish, jsh, 0, cca_dc_ );
209 else {
210 sidl_buffer_ = nuclear_ptr_->compute_array( ish, jsh, 0, cca_dc_ );
211 copy_buffer();
212 }
213}
214
215void
216Int1eCCA::nuclear_1der(int ish, int jsh,
217 Chemistry_QC_GaussianBasis_DerivCenters &dc)
218{
219 if( use_opaque_ )
220 nuclear_1der_ptr_->compute( ish, jsh, 1, dc );
221 else {
222 sidl_buffer_ = nuclear_1der_ptr_->compute_array( ish, jsh, 1, dc );
223 copy_buffer();
224 }
225}
226
227void
228Int1eCCA::hcore( int ish, int jsh )
229{
230 cca_dc_.clear();
231 if( use_opaque_ )
232 hcore_ptr_->compute( ish, jsh, 0, cca_dc_ );
233 else {
234 sidl_buffer_ = hcore_ptr_->compute_array( ish, jsh, 0, cca_dc_ );
235 copy_buffer();
236 }
237}
238
239void
240Int1eCCA::hcore_1der(int ish, int jsh,
241 Chemistry_QC_GaussianBasis_DerivCenters &dc)
242{
243 if( use_opaque_ )
244 hcore_1der_ptr_->compute( ish, jsh, 1, dc );
245 else {
246 sidl_buffer_ = hcore_1der_ptr_->compute_array( ish, jsh, 1, dc );
247 copy_buffer();
248 }
249}
250
251void
252Int1eCCA::copy_buffer()
253{
254 int sidl_size = 1 + sidl_buffer_.upper(0) - sidl_buffer_.lower(0);
255 for(int i=0; i<sidl_size; ++i)
256 buff_[i] = sidl_buffer_.get(i);
257}
258
259
260/////////////////////////////////////////////////////////////////////////////
261
262// Local Variables:
263// mode: c++
264// End:
Note: See TracBrowser for help on using the repository browser.