MPQC
2.3.1
Main Page
Related Pages
Classes
Files
File List
src
lib
chemistry
molecule
energy.h
1
//
2
// energy.h
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
#ifndef _chemistry_molecule_energy_h
29
#define _chemistry_molecule_energy_h
30
31
#ifdef __GNUC__
32
#pragma interface
33
#endif
34
35
#include <iostream>
36
37
#include <math/optimize/function.h>
38
#include <math/optimize/conv.h>
39
#include <chemistry/molecule/molecule.h>
40
#include <chemistry/molecule/coor.h>
41
#include <chemistry/molecule/hess.h>
42
43
namespace
sc {
44
48
class
MolecularEnergy
:
public
Function
{
49
private
:
50
RefSCDimension
moldim_;
// the number of cartesian variables
51
Ref<MolecularCoor>
mc_;
52
Ref<Molecule>
mol_;
53
Ref<MolecularHessian>
hess_;
54
Ref<MolecularHessian>
guesshess_;
55
56
RefSCVector
cartesian_gradient_;
57
RefSymmSCMatrix
cartesian_hessian_;
58
60
bool
ckpt_;
62
char
*ckpt_file_;
64
int
ckpt_freq_;
65
66
protected
:
67
Ref<PointGroup>
initial_pg_;
68
69
void
failure(
const
char
*);
70
72
virtual
void
set_energy
(
double
);
73
76
virtual
void
set_gradient
(
RefSCVector
&);
77
virtual
void
set_hessian(
RefSymmSCMatrix
&);
78
79
void
x_to_molecule();
80
void
molecule_to_x();
81
82
int
print_molecule_when_changed_;
83
public
:
84
MolecularEnergy
(
const
MolecularEnergy
&);
135
MolecularEnergy
(
const
Ref<KeyVal>
&);
136
MolecularEnergy
(
StateIn
&);
137
~
MolecularEnergy
();
138
139
void
save_data_state
(
StateOut
&);
140
142
void
set_checkpoint
();
143
void
set_checkpoint_file(
const
char
*);
144
void
set_checkpoint_freq(
int
freq);
146
bool
if_to_checkpoint
()
const
;
147
const
char
* checkpoint_file()
const
;
148
int
checkpoint_freq()
const
;
149
150
MolecularEnergy
& operator=(
const
MolecularEnergy
&);
151
153
virtual
double
energy
();
154
155
virtual
Ref<Molecule>
molecule()
const
;
156
virtual
RefSCDimension
moldim()
const
;
157
158
void
guess_hessian
(
RefSymmSCMatrix
&);
159
RefSymmSCMatrix
inverse_hessian(
RefSymmSCMatrix
&);
160
163
RefSymmSCMatrix
hessian
();
164
int
hessian_implemented()
const
;
165
166
void
set_x
(
const
RefSCVector
&);
167
169
RefSCVector
get_cartesian_x
();
171
RefSCVector
get_cartesian_gradient
();
173
RefSymmSCMatrix
get_cartesian_hessian
();
174
175
Ref<MolecularCoor>
molecularcoor() {
return
mc_; }
176
179
virtual
void
symmetry_changed
();
180
181
Ref<NonlinearTransform>
change_coordinates
();
182
184
void
print_natom_3
(
const
RefSCVector
&,
185
const
char
*t=0, std::ostream&o=
ExEnv::out0
())
const
;
186
void
print_natom_3
(
double
**,
const
char
*t=0, std::ostream&o=
ExEnv::out0
())
const
;
187
void
print_natom_3
(
double
*,
const
char
*t=0, std::ostream&o=
ExEnv::out0
())
const
;
188
189
virtual
void
print
(std::ostream& =
ExEnv::out0
())
const
;
190
};
191
192
193
class
SumMolecularEnergy
:
public
MolecularEnergy
{
194
protected
:
195
int
n_;
196
Ref<MolecularEnergy>
*mole_;
197
double
*coef_;
198
void
compute
();
199
public
:
200
SumMolecularEnergy
(
const
Ref<KeyVal>
&);
201
SumMolecularEnergy
(
StateIn
&);
202
~
SumMolecularEnergy
();
203
204
void
save_data_state
(
StateOut
&);
205
206
int
value_implemented
()
const
;
207
int
gradient_implemented()
const
;
208
int
hessian_implemented()
const
;
209
210
void
set_x
(
const
RefSCVector
&);
211
};
212
213
214
/* The MolEnergyConvergence class derives from the Convergence class. The
215
MolEnergyConvergence class allows the user to request that cartesian
216
coordinates be used in evaluating the convergence criteria. This is
217
useful, since the internal coordinates can be somewhat arbitary. If the
218
optimization is constrained, then the fixed internal coordinates will be
219
projected out of the cartesian gradients. The input is similar to that for
220
Convergence class with the exception that giving none of the convergence
221
criteria keywords is the same as providing the following input to the
222
KeyVal constructor:
223
224
<pre>
225
conv<MolEnergyConvergence>: (
226
max_disp = 1.0e-4
227
max_grad = 1.0e-4
228
graddisp = 1.0e-4
229
)
230
</pre>
231
232
For MolEnergyConverence to work, the Function object given to the Optimizer
233
object must derive from MolecularEnergy.
234
*/
235
class
MolEnergyConvergence
:
public
Convergence
{
236
protected
:
237
Ref<MolecularEnergy>
mole_;
238
int
cartesian_;
239
240
void
set_defaults();
241
public
:
242
// Standard constructors and destructor.
243
MolEnergyConvergence
();
244
MolEnergyConvergence
(
StateIn
&);
262
MolEnergyConvergence
(
const
Ref<KeyVal>
&);
263
virtual
~
MolEnergyConvergence
();
264
265
void
save_data_state
(
StateOut
&);
266
267
// Set the current gradient and position information. These
268
//will possibly grab the cartesian infomation if we have a
269
//MolecularEnergy.
270
void
get_grad
(
const
Ref<Function>
&);
271
void
get_x(
const
Ref<Function>
&);
272
void
set_nextx(
const
RefSCVector
&);
273
274
// Return nonzero if the optimization has converged.
275
int
converged
();
276
};
277
278
}
279
280
#endif
281
282
// Local Variables:
283
// mode: c++
284
// c-file-style: "CLJ"
285
// End:
Generated at Tue Aug 20 2013 22:06:58 for
MPQC
2.3.1 using the documentation package
Doxygen
1.8.3.1.