1 | //
|
---|
2 | // File: MPQC_ChemistryOpt_CoordinateModel_Impl.hh
|
---|
3 | // Symbol: MPQC.ChemistryOpt_CoordinateModel-v0.2
|
---|
4 | // Symbol Type: class
|
---|
5 | // Babel Version: 0.10.2
|
---|
6 | // Description: Server-side implementation for MPQC.ChemistryOpt_CoordinateModel
|
---|
7 | //
|
---|
8 | // WARNING: Automatically generated; only changes within splicers preserved
|
---|
9 | //
|
---|
10 | // babel-version = 0.10.2
|
---|
11 | //
|
---|
12 |
|
---|
13 | #ifndef included_MPQC_ChemistryOpt_CoordinateModel_Impl_hh
|
---|
14 | #define included_MPQC_ChemistryOpt_CoordinateModel_Impl_hh
|
---|
15 |
|
---|
16 | #ifndef included_sidl_cxx_hh
|
---|
17 | #include "sidl_cxx.hh"
|
---|
18 | #endif
|
---|
19 | #ifndef included_MPQC_ChemistryOpt_CoordinateModel_IOR_h
|
---|
20 | #include "MPQC_ChemistryOpt_CoordinateModel_IOR.h"
|
---|
21 | #endif
|
---|
22 | //
|
---|
23 | // Includes for all method dependencies.
|
---|
24 | //
|
---|
25 | #ifndef included_Chemistry_QC_Model_hh
|
---|
26 | #include "Chemistry_QC_Model.hh"
|
---|
27 | #endif
|
---|
28 | #ifndef included_MPQC_ChemistryOpt_CoordinateModel_hh
|
---|
29 | #include "MPQC_ChemistryOpt_CoordinateModel.hh"
|
---|
30 | #endif
|
---|
31 | #ifndef included_gov_cca_CCAException_hh
|
---|
32 | #include "gov_cca_CCAException.hh"
|
---|
33 | #endif
|
---|
34 | #ifndef included_gov_cca_Services_hh
|
---|
35 | #include "gov_cca_Services.hh"
|
---|
36 | #endif
|
---|
37 | #ifndef included_sidl_BaseInterface_hh
|
---|
38 | #include "sidl_BaseInterface.hh"
|
---|
39 | #endif
|
---|
40 | #ifndef included_sidl_ClassInfo_hh
|
---|
41 | #include "sidl_ClassInfo.hh"
|
---|
42 | #endif
|
---|
43 |
|
---|
44 |
|
---|
45 | // DO-NOT-DELETE splicer.begin(MPQC.ChemistryOpt_CoordinateModel._includes)
|
---|
46 | #include <Chemistry_MoleculeViewer.hh>
|
---|
47 | #include <Chemistry_QC_ModelFactory.hh>
|
---|
48 | #include <chemistry/molecule/coor.h>
|
---|
49 | #include "CoordinateModel.h"
|
---|
50 | #include "Chemistry_Chemistry_Molecule.hh"
|
---|
51 | #include "cca.h"
|
---|
52 | #include "dc/babel/babel-cca/server/ccaffeine_TypeMap.hh"
|
---|
53 | #include "dc/babel/babel-cca/server/ccaffeine_ports_PortTranslator.hh"
|
---|
54 | #include "util/IO.h"
|
---|
55 | #include "jc++/jc++.h"
|
---|
56 | #include "jc++/util/jc++util.h"
|
---|
57 | #include "parameters/parametersStar.h"
|
---|
58 | #include "port/portInterfaces.h"
|
---|
59 | #include "port/supportInterfaces.h"
|
---|
60 | // DO-NOT-DELETE splicer.end(MPQC.ChemistryOpt_CoordinateModel._includes)
|
---|
61 |
|
---|
62 | namespace MPQC {
|
---|
63 |
|
---|
64 | /**
|
---|
65 | * Symbol "MPQC.ChemistryOpt_CoordinateModel" (version 0.2)
|
---|
66 | */
|
---|
67 | class ChemistryOpt_CoordinateModel_impl
|
---|
68 | // DO-NOT-DELETE splicer.begin(MPQC.ChemistryOpt_CoordinateModel._inherits)
|
---|
69 | : public CcaChemGeneric::CoordinateModel
|
---|
70 |
|
---|
71 | /** IntegralEvaluatorFactory_impl implements a component interface for
|
---|
72 | coordinate-aware chemistry models.
|
---|
73 |
|
---|
74 | This is an implementation of a SIDL interface.
|
---|
75 | The stub code is generated by the Babel tool. Do not make
|
---|
76 | modifications outside of splicer blocks, as these will be lost.
|
---|
77 | This is a server implementation for a Babel class, the Babel
|
---|
78 | client code is provided by the cca-chem-generic package.
|
---|
79 |
|
---|
80 | For use directly in a framework, the parameter port recognizes
|
---|
81 | the following parameters:
|
---|
82 | <dl>
|
---|
83 |
|
---|
84 | <dt><tt>double grad_rms</tt><dd> RMS gradient convergence criterion.
|
---|
85 | The default is 0.00030.
|
---|
86 |
|
---|
87 | <dt><tt>double grad_max</tt><dd> Max gradient convergence criterion.
|
---|
88 | The default is 0.00045.
|
---|
89 |
|
---|
90 | <dt><tt>double disp_rms</tt><dd> RMS displacement convergence criterion.
|
---|
91 | The default is 0.00120.
|
---|
92 |
|
---|
93 | <dt><tt>double disp_max</tt><dd> Max displacement convergence criterion.
|
---|
94 | The default is 0.00180.
|
---|
95 |
|
---|
96 | <dt><tt>bool multiple_guess_h</tt><dd> Whether a new guess Hessian is
|
---|
97 | computed each time <tt>guess_hessian_sovle()</tt> is called.
|
---|
98 | The default is true.
|
---|
99 |
|
---|
100 | <dt><tt>bool use_current_geom</tt><dd> Whether the guess Hessian is
|
---|
101 | computed at the current geometry or the geometry of the first correction
|
---|
102 | pair. Only meaningful if <tt>multiple_guess_h = true</tt>.
|
---|
103 | The default is false.
|
---|
104 |
|
---|
105 | <dt><tt>string coordinate_type</tt><dd> Type of coordinates to use for
|
---|
106 | optimization: <tt>cartesian</tt>, <tt>symmetrized</tt>, or
|
---|
107 | <tt>redundant</tt>. The default is <tt>symmetrized</tt>.
|
---|
108 |
|
---|
109 | <dt><tt>string extra_bonds</tt><dd> Vector specifying centers between
|
---|
110 | which bonds should be added. There is no default.
|
---|
111 |
|
---|
112 | </dl>
|
---|
113 |
|
---|
114 | These parameters must be set by the client for embedded use.
|
---|
115 |
|
---|
116 | */
|
---|
117 |
|
---|
118 | // DO-NOT-DELETE splicer.end(MPQC.ChemistryOpt_CoordinateModel._inherits)
|
---|
119 | {
|
---|
120 |
|
---|
121 | private:
|
---|
122 | // Pointer back to IOR.
|
---|
123 | // Use this to dispatch back through IOR vtable.
|
---|
124 | ChemistryOpt_CoordinateModel self;
|
---|
125 |
|
---|
126 | // DO-NOT-DELETE splicer.begin(MPQC.ChemistryOpt_CoordinateModel._implementation)
|
---|
127 | gov::cca::Services services_;
|
---|
128 | CcaChemGeneric::CoordinateModel genericModel_;
|
---|
129 | Chemistry::QC::Model model_;
|
---|
130 | Chemistry::Chemistry_Molecule molecule_;
|
---|
131 | sc::Ref<sc::MolecularCoor> scCoor_;
|
---|
132 | sc::Ref<sc::Molecule> scMol_;
|
---|
133 | sc::Ref<sc::SCMatrixKit> kit_;
|
---|
134 | sc::Ref<sc::SCMatrixKit> rkit_;
|
---|
135 | sc::RefSymmSCMatrix ihess_;
|
---|
136 | DoubleParameter *grad_rms_, *grad_max_, *disp_rms_, *disp_max_;
|
---|
137 | BoolParameter *multiple_guess_h_, *use_current_geom_;
|
---|
138 | StringParameter *coordinates_;
|
---|
139 | StringParameter *extra_bonds_;
|
---|
140 | double convFrom_;
|
---|
141 | bool have_guess_h_;
|
---|
142 | enum {cart,symm,redund};
|
---|
143 | int coorType_;
|
---|
144 | int numCoor_;
|
---|
145 | int natom3_;
|
---|
146 |
|
---|
147 | ConfigurableParameterPort*
|
---|
148 | setup_parameters(ConfigurableParameterFactory *);
|
---|
149 |
|
---|
150 | void draw();
|
---|
151 | // DO-NOT-DELETE splicer.end(MPQC.ChemistryOpt_CoordinateModel._implementation)
|
---|
152 |
|
---|
153 | private:
|
---|
154 | // private default constructor (required)
|
---|
155 | ChemistryOpt_CoordinateModel_impl()
|
---|
156 | {}
|
---|
157 |
|
---|
158 | public:
|
---|
159 | // sidl constructor (required)
|
---|
160 | // Note: alternate Skel constructor doesn't call addref()
|
---|
161 | // (fixes bug #275)
|
---|
162 | ChemistryOpt_CoordinateModel_impl( struct
|
---|
163 | MPQC_ChemistryOpt_CoordinateModel__object * s ) : self(s,
|
---|
164 | true) { _ctor(); }
|
---|
165 |
|
---|
166 | // user defined construction
|
---|
167 | void _ctor();
|
---|
168 |
|
---|
169 | // virtual destructor (required)
|
---|
170 | virtual ~ChemistryOpt_CoordinateModel_impl() { _dtor(); }
|
---|
171 |
|
---|
172 | // user defined destruction
|
---|
173 | void _dtor();
|
---|
174 |
|
---|
175 | // static class initializer
|
---|
176 | static void _load();
|
---|
177 |
|
---|
178 | public:
|
---|
179 |
|
---|
180 |
|
---|
181 | /**
|
---|
182 | * Registers and gets ports, and requests Model object(s) from the
|
---|
183 | * ModelFactory component(s). This must be the first method called
|
---|
184 | * following instantiation.
|
---|
185 | */
|
---|
186 | int32_t
|
---|
187 | initialize() throw ()
|
---|
188 | ;
|
---|
189 |
|
---|
190 | /**
|
---|
191 | * Releases and unregisters ports. This should be called when the
|
---|
192 | * CoordinateModel object is no longer needed.
|
---|
193 | */
|
---|
194 | int32_t
|
---|
195 | finalize() throw ()
|
---|
196 | ;
|
---|
197 |
|
---|
198 | /**
|
---|
199 | * Sets the contained chemistry Model object (currently unused as the
|
---|
200 | * chemistry Model object is normally obtained from a ModelFactory
|
---|
201 | * during initialization).
|
---|
202 | * @param model The chemistry model object.
|
---|
203 | */
|
---|
204 | void
|
---|
205 | set_model (
|
---|
206 | /* in */ ::Chemistry::QC::Model model
|
---|
207 | )
|
---|
208 | throw ()
|
---|
209 | ;
|
---|
210 |
|
---|
211 |
|
---|
212 | /**
|
---|
213 | * Returns the contained chemistry Model object.
|
---|
214 | * @return The chemistry Model object.
|
---|
215 | */
|
---|
216 | ::Chemistry::QC::Model
|
---|
217 | get_model() throw ()
|
---|
218 | ;
|
---|
219 |
|
---|
220 | /**
|
---|
221 | * Returns the number of coordinates.
|
---|
222 | * @return The number of coordinates.
|
---|
223 | */
|
---|
224 | int32_t
|
---|
225 | get_n_coor() throw ()
|
---|
226 | ;
|
---|
227 |
|
---|
228 | /**
|
---|
229 | * Returns the array of (cartesian or internal) coordinates which are
|
---|
230 | * being optimized.
|
---|
231 | * @return The array of coordinates which are being optimized.
|
---|
232 | */
|
---|
233 | ::sidl::array<double>
|
---|
234 | get_coor() throw ()
|
---|
235 | ;
|
---|
236 |
|
---|
237 | /**
|
---|
238 | * Returns the energy of the currently contained model with the values
|
---|
239 | * of the optimization coordinates given in x. This requires
|
---|
240 | * that the CoordinateModel updates the cartesian coordinates of a
|
---|
241 | * contained Molecule object (possibly requiring transformation) and set
|
---|
242 | * this Molecule object on a contained Model object, prior to calling
|
---|
243 | * get_energy() on the Model object.
|
---|
244 | * @param x The optimization coordinate values.
|
---|
245 | * @return The energy of the chemistry model at x.
|
---|
246 | */
|
---|
247 | double
|
---|
248 | get_energy (
|
---|
249 | /* in */ ::sidl::array<double> x
|
---|
250 | )
|
---|
251 | throw ()
|
---|
252 | ;
|
---|
253 |
|
---|
254 |
|
---|
255 | /**
|
---|
256 | * Returns the energy gradient of the currently contained model with
|
---|
257 | * the values of the optimization coordinates given in x. This requires
|
---|
258 | * that the CoordinateModel updates the cartesian coordinates of a
|
---|
259 | * contained Molecule object (possibly requiring transformation) and set
|
---|
260 | * this Molecule object on a contained Model object, prior to calling
|
---|
261 | * get_gradient() on the Model object. If the optimization coordinate
|
---|
262 | * system is not cartesian, the gradient is transformed.
|
---|
263 | * @param x The optimization coordinate values.
|
---|
264 | * @return The energy gradient of the chemistry model at x.
|
---|
265 | */
|
---|
266 | ::sidl::array<double>
|
---|
267 | get_gradient (
|
---|
268 | /* in */ ::sidl::array<double> x
|
---|
269 | )
|
---|
270 | throw ()
|
---|
271 | ;
|
---|
272 |
|
---|
273 |
|
---|
274 | /**
|
---|
275 | * Returns the energy Hessian of the currently contained model with
|
---|
276 | * the values of the optimization coordinates given in x. This requires
|
---|
277 | * that the CoordinateModel updates the cartesian coordinates of a
|
---|
278 | * contained Molecule object (possibly requiring transformation) and set
|
---|
279 | * this Molecule object on a contained Model object, prior to calling
|
---|
280 | * get_hessian() on the Model object. If the optimization coordinate
|
---|
281 | * system is not cartesian, the Hessian is transformed.
|
---|
282 | * @param x The optimization coordinate values.
|
---|
283 | * @return The energy Hessian of the chemistry model at x.
|
---|
284 | */
|
---|
285 | ::sidl::array<double>
|
---|
286 | get_hessian (
|
---|
287 | /* in */ ::sidl::array<double> x
|
---|
288 | )
|
---|
289 | throw ()
|
---|
290 | ;
|
---|
291 |
|
---|
292 |
|
---|
293 | /**
|
---|
294 | * Sets f and g to the energy and energy gradient, respectively,
|
---|
295 | * of the chemistry model at x. This is similar to calling
|
---|
296 | * get_energy() and get_gradient() separately, but set_molecule()
|
---|
297 | * must be called on the Model object only once. This is necessary
|
---|
298 | * for some model implementations, as a second molecule update
|
---|
299 | * would invalidate results from an energy computation. An alternative
|
---|
300 | * would be to always return the energy as well when get_gradient() is
|
---|
301 | * called.
|
---|
302 | * @param x The optimization coordinate values.
|
---|
303 | * @param f Variable that energy will be assigned to.
|
---|
304 | * @param g Array that the gradient will be assigned to.
|
---|
305 | */
|
---|
306 | void
|
---|
307 | get_energy_and_gradient (
|
---|
308 | /* in */ ::sidl::array<double> x,
|
---|
309 | /* out */ double& f,
|
---|
310 | /* in */ ::sidl::array<double> g
|
---|
311 | )
|
---|
312 | throw ()
|
---|
313 | ;
|
---|
314 |
|
---|
315 |
|
---|
316 | /**
|
---|
317 | * Returns the product of the guess hessian inverse and an effective
|
---|
318 | * gradient. Probably unique to TAO's limited memory variable metric
|
---|
319 | * algorithm, which uses this method to accomodate dense guess hessians.
|
---|
320 | * "first_geom_ptr" provides the Cartesian coordinates for which the
|
---|
321 | * guess Hessian should be computed (first_geom_ptr=0 for current
|
---|
322 | * geometry).
|
---|
323 | * @param effective_grad An effective gradient.
|
---|
324 | * @param effective_step Array that effective step is assigned to.
|
---|
325 | * @param first_geom Pointer to array of Cartesians
|
---|
326 | */
|
---|
327 | void
|
---|
328 | guess_hessian_solve (
|
---|
329 | /* in */ ::sidl::array<double> effective_grad,
|
---|
330 | /* in */ ::sidl::array<double> effective_step,
|
---|
331 | /* in */ void* first_geom
|
---|
332 | )
|
---|
333 | throw ()
|
---|
334 | ;
|
---|
335 |
|
---|
336 |
|
---|
337 | /**
|
---|
338 | * Determines if the optimization has converged, flag is set to 1
|
---|
339 | * if convergence has been achieved and 0 otherwise.
|
---|
340 | * @param flag Variable that convergence value is assigned to.
|
---|
341 | */
|
---|
342 | void
|
---|
343 | checkConvergence (
|
---|
344 | /* inout */ int32_t& flag
|
---|
345 | )
|
---|
346 | throw ()
|
---|
347 | ;
|
---|
348 |
|
---|
349 |
|
---|
350 | /**
|
---|
351 | * For visualization, possibly unused (?). CoordinateModel objects
|
---|
352 | * may callback to viewers that implement the Chemistry.MoleculeViewer
|
---|
353 | * interface, such as the cca-chem python GUI, making this method
|
---|
354 | * unnecessary.
|
---|
355 | */
|
---|
356 | void
|
---|
357 | monitor() throw ()
|
---|
358 | ;
|
---|
359 |
|
---|
360 | /**
|
---|
361 | * Starts up a component presence in the calling framework.
|
---|
362 | * @param Svc the component instance's handle on the framework world.
|
---|
363 | * Contracts concerning Svc and setServices:
|
---|
364 | *
|
---|
365 | * The component interaction with the CCA framework
|
---|
366 | * and Ports begins on the call to setServices by the framework.
|
---|
367 | *
|
---|
368 | * This function is called exactly once for each instance created
|
---|
369 | * by the framework.
|
---|
370 | *
|
---|
371 | * The argument Svc will never be nil/null.
|
---|
372 | *
|
---|
373 | * Those uses ports which are automatically connected by the framework
|
---|
374 | * (so-called service-ports) may be obtained via getPort during
|
---|
375 | * setServices.
|
---|
376 | */
|
---|
377 | void
|
---|
378 | setServices (
|
---|
379 | /* in */ ::gov::cca::Services services
|
---|
380 | )
|
---|
381 | throw (
|
---|
382 | ::gov::cca::CCAException
|
---|
383 | );
|
---|
384 |
|
---|
385 | }; // end class ChemistryOpt_CoordinateModel_impl
|
---|
386 |
|
---|
387 | } // end namespace MPQC
|
---|
388 |
|
---|
389 | // DO-NOT-DELETE splicer.begin(MPQC.ChemistryOpt_CoordinateModel._misc)
|
---|
390 | // Put miscellaneous things here...
|
---|
391 | // DO-NOT-DELETE splicer.end(MPQC.ChemistryOpt_CoordinateModel._misc)
|
---|
392 |
|
---|
393 | #endif
|
---|