source: src/molecule_template.hpp@ 5f612ee

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since 5f612ee was 1c51c8, checked in by Tillmann Crueger <crueger@…>, 15 years ago

Added methods for querying molecules using descriptors

  • Property mode set to 100644
File size: 16.4 KB
Line 
1/*
2 * molecule_template.hpp
3 *
4 * Created on: Oct 6, 2009
5 * Author: heber
6 */
7
8#ifndef MOLECULE_TEMPLATE_HPP_
9#define MOLECULE_TEMPLATE_HPP_
10
11/*********************************************** includes ***********************************/
12
13// include config.h
14#ifdef HAVE_CONFIG_H
15#include <config.h>
16#endif
17
18#include "atom.hpp"
19/********************************************** declarations *******************************/
20
21// ================== Acting on all Vectors ========================== //
22
23// zero arguments
24template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() ) const
25 {
26 atom *Walker = start;
27 while (Walker->next != end) {
28 Walker = Walker->next;
29 ((Walker->node)->*f)();
30 }
31};
32template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() const ) const
33 {
34 atom *Walker = start;
35 while (Walker->next != end) {
36 Walker = Walker->next;
37 ((Walker->node)->*f)();
38 }
39};
40// one argument
41template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T), T t ) const
42{
43 atom *Walker = start;
44 while (Walker->next != end) {
45 Walker = Walker->next;
46 ((Walker->node)->*f)(t);
47 }
48};
49template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T) const, T t ) const
50{
51 atom *Walker = start;
52 while (Walker->next != end) {
53 Walker = Walker->next;
54 ((Walker->node)->*f)(t);
55 }
56};
57// two arguments
58template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const
59{
60 atom *Walker = start;
61 while (Walker->next != end) {
62 Walker = Walker->next;
63 ((Walker->node)->*f)(t, u);
64 }
65};
66template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u ) const
67{
68 atom *Walker = start;
69 while (Walker->next != end) {
70 Walker = Walker->next;
71 ((Walker->node)->*f)(t, u);
72 }
73};
74// three arguments
75template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v) const
76{
77 atom *Walker = start;
78 while (Walker->next != end) {
79 Walker = Walker->next;
80 ((Walker->node)->*f)(t, u, v);
81 }
82};
83template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V) const, T t, U u, V v) const
84{
85 atom *Walker = start;
86 while (Walker->next != end) {
87 Walker = Walker->next;
88 ((Walker->node)->*f)(t, u, v);
89 }
90};
91
92// ========================= Summing over each Atoms =================================== //
93
94// zero arguments
95template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() ) const
96{
97 res result = 0;
98 atom *Walker = start;
99 while (Walker->next != end) {
100 Walker = Walker->next;
101 result += (Walker->*f)();
102 }
103 return result;
104};
105template <typename res, typename typ> res molecule::SumPerAtom(res (typ::*f)() const ) const
106{
107 res result = 0;
108 atom *Walker = start;
109 while (Walker->next != end) {
110 Walker = Walker->next;
111 result += (Walker->*f)();
112 }
113 return result;
114};
115// one argument
116template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T), T t ) const
117{
118 res result = 0;
119 atom *Walker = start;
120 while (Walker->next != end) {
121 Walker = Walker->next;
122 result += (Walker->*f)(t);
123 }
124 return result;
125};
126template <typename res, typename typ, typename T> res molecule::SumPerAtom(res (typ::*f)(T) const, T t ) const
127{
128 res result = 0;
129 atom *Walker = start;
130 while (Walker->next != end) {
131 Walker = Walker->next;
132 result += (Walker->*f)(t);
133 }
134 return result;
135};
136
137
138// ================== Acting with each Atoms on same molecule ========================== //
139
140// zero arguments
141template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *)) const
142{
143 atom *Walker = start;
144 while (Walker->next != end) {
145 Walker = Walker->next;
146 (*f)(Walker);
147 }
148};
149template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *) const) const
150{
151 atom *Walker = start;
152 while (Walker->next != end) {
153 Walker = Walker->next;
154 (*f)(Walker);
155 }
156};
157
158// ================== Acting with each Atoms on copy molecule ========================== //
159
160// zero arguments
161template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) , molecule *copy) const
162{
163 atom *Walker = start;
164 while (Walker->next != end) {
165 Walker = Walker->next;
166 (copy->*f)(Walker);
167 }
168};
169template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) const, molecule *copy) const
170{
171 atom *Walker = start;
172 while (Walker->next != end) {
173 Walker = Walker->next;
174 (copy->*f)(Walker);
175 }
176};
177
178// ================== Acting with each Atoms on copy molecule if true ========================== //
179
180// zero arguments
181template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () ) const
182{
183 atom *Walker = start;
184 while (Walker->next != end) {
185 Walker = Walker->next;
186 if ((Walker->*condition)())
187 (copy->*f)(Walker);
188 }
189};
190template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () const ) const
191{
192 atom *Walker = start;
193 while (Walker->next != end) {
194 Walker = Walker->next;
195 if ((Walker->*condition)())
196 (copy->*f)(Walker);
197 }
198};
199template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) () ) const
200{
201 atom *Walker = start;
202 while (Walker->next != end) {
203 Walker = Walker->next;
204 if ((Walker->*condition)())
205 (copy->*f)(Walker);
206 }
207};
208template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) () const ) const
209{
210 atom *Walker = start;
211 while (Walker->next != end) {
212 Walker = Walker->next;
213 if ((Walker->*condition)())
214 (copy->*f)(Walker);
215 }
216};
217// one argument
218template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T), T t ) const
219{
220 atom *Walker = start;
221 while (Walker->next != end) {
222 Walker = Walker->next;
223 if ((Walker->*condition)(t))
224 (copy->*f)(Walker);
225 }
226};
227template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T) const, T t ) const
228{
229 atom *Walker = start;
230 while (Walker->next != end) {
231 Walker = Walker->next;
232 if ((Walker->*condition)(t))
233 (copy->*f)(Walker);
234 }
235};
236template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T), T t ) const
237{
238 atom *Walker = start;
239 while (Walker->next != end) {
240 Walker = Walker->next;
241 if ((Walker->*condition)(t))
242 (copy->*f)(Walker);
243 }
244};
245template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T) const, T t ) const
246{
247 atom *Walker = start;
248 while (Walker->next != end) {
249 Walker = Walker->next;
250 if ((Walker->*condition)(t))
251 (copy->*f)(Walker);
252 }
253};
254// two arguments
255template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U), T t, U u ) const
256{
257 atom *Walker = start;
258 while (Walker->next != end) {
259 Walker = Walker->next;
260 if ((Walker->*condition)(t,u))
261 (copy->*f)(Walker);
262 }
263};
264template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U) const, T t, U u ) const
265{
266 atom *Walker = start;
267 while (Walker->next != end) {
268 Walker = Walker->next;
269 if ((Walker->*condition)(t,u))
270 (copy->*f)(Walker);
271 }
272};
273template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U), T t, U u ) const
274{
275 atom *Walker = start;
276 while (Walker->next != end) {
277 Walker = Walker->next;
278 if ((Walker->*condition)(t,u))
279 (copy->*f)(Walker);
280 }
281};
282template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U) const, T t, U u ) const
283{
284 atom *Walker = start;
285 while (Walker->next != end) {
286 Walker = Walker->next;
287 if ((Walker->*condition)(t,u))
288 (copy->*f)(Walker);
289 }
290};
291// three arguments
292template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v ) const
293{
294 atom *Walker = start;
295 while (Walker->next != end) {
296 Walker = Walker->next;
297 if ((Walker->*condition)(t,u,v))
298 (copy->*f)(Walker);
299 }
300};
301template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V) const, T t, U u, V v ) const
302{
303 atom *Walker = start;
304 while (Walker->next != end) {
305 Walker = Walker->next;
306 if ((Walker->*condition)(t,u,v))
307 (copy->*f)(Walker);
308 }
309};
310template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v ) const
311{
312 atom *Walker = start;
313 while (Walker->next != end) {
314 Walker = Walker->next;
315 if ((Walker->*condition)(t,u,v))
316 (copy->*f)(Walker);
317 }
318};
319template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U, V) const, T t, U u, V v ) const
320{
321 atom *Walker = start;
322 while (Walker->next != end) {
323 Walker = Walker->next;
324 if ((Walker->*condition)(t,u,v))
325 (copy->*f)(Walker);
326 }
327};
328
329// ================== Acting on all Atoms ========================== //
330
331// zero arguments
332template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)()) const
333{
334 atom *Walker = start;
335 while (Walker->next != end) {
336 Walker = Walker->next;
337 (Walker->*f)();
338 }
339};
340template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)() const) const
341{
342 atom *Walker = start;
343 while (Walker->next != end) {
344 Walker = Walker->next;
345 (Walker->*f)();
346 }
347};
348// one argument
349template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T), T t ) const
350{
351 atom *Walker = start;
352 while (Walker->next != end) {
353 Walker = Walker->next;
354 (Walker->*f)(t);
355 }
356};
357template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T) const, T t ) const
358{
359 atom *Walker = start;
360 while (Walker->next != end) {
361 Walker = Walker->next;
362 (Walker->*f)(t);
363 }
364};
365// two argument
366template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U), T t, U u ) const
367{
368 atom *Walker = start;
369 while (Walker->next != end) {
370 Walker = Walker->next;
371 (Walker->*f)(t, u);
372 }
373};
374template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u ) const
375{
376 atom *Walker = start;
377 while (Walker->next != end) {
378 Walker = Walker->next;
379 (Walker->*f)(t, u);
380 }
381};
382// three argument
383template <typename res, typename typ, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V), T t, U u, V v) const
384{
385 atom *Walker = start;
386 while (Walker->next != end) {
387 Walker = Walker->next;
388 (Walker->*f)(t, u, v);
389 }
390};
391template <typename res, typename typ, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V) const, T t, U u, V v) const
392{
393 atom *Walker = start;
394 while (Walker->next != end) {
395 Walker = Walker->next;
396 (Walker->*f)(t, u, v);
397 }
398};
399// four arguments
400template <typename res, typename typ, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V, W), T t, U u, V v, W w) const
401{
402 atom *Walker = start;
403 while (Walker->next != end) {
404 Walker = Walker->next;
405 (Walker->*f)(t, u, v, w);
406 }
407};
408template <typename res, typename typ, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V, W) const, T t, U u, V v, W w) const
409{
410 atom *Walker = start;
411 while (Walker->next != end) {
412 Walker = Walker->next;
413 (Walker->*f)(t, u, v, w);
414 }
415};
416
417// ===================== Accessing arrays indexed by some integer for each atom ======================
418
419// for atom ints
420template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *) ) const
421{
422 atom *Walker = start;
423 int inc = 1;
424 while (Walker->next != end) {
425 Walker = Walker->next;
426 (*Setor) (&array[(Walker->*index)], &inc);
427 }
428};
429template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T value ) const
430{
431 atom *Walker = start;
432 while (Walker->next != end) {
433 Walker = Walker->next;
434 (*Setor) (&array[(Walker->*index)], &value);
435 }
436};
437template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T *value ) const
438{
439 atom *Walker = start;
440 while (Walker->next != end) {
441 Walker = Walker->next;
442 (*Setor) (&array[(Walker->*index)], value);
443 }
444};
445// for element ints
446template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *) ) const
447{
448 atom *Walker = start;
449 int inc = 1;
450 while (Walker->next != end) {
451 Walker = Walker->next;
452 (*Setor) (&array[(Walker->type->*index)], &inc);
453 }
454};
455template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T value ) const
456{
457 atom *Walker = start;
458 while (Walker->next != end) {
459 Walker = Walker->next;
460 (*Setor) (&array[(Walker->type->*index)], &value);
461 }
462};
463template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T *value ) const
464{
465 atom *Walker = start;
466 while (Walker->next != end) {
467 Walker = Walker->next;
468 (*Setor) (&array[(Walker->type->*index)], value);
469 }
470};
471
472template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ atom::*value ) const
473{
474 atom *Walker = start;
475 while (Walker->next != end) {
476 Walker = Walker->next;
477 array[(Walker->*index)] = (Walker->*Setor) (Walker->*value);
478 }
479};
480template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ atom::*value ) const
481{
482 atom *Walker = start;
483 while (Walker->next != end) {
484 Walker = Walker->next;
485 array[(Walker->*index)] = (Walker->*Setor) (Walker->*value);
486 }
487};
488template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ &vect ) const
489{
490 atom *Walker = start;
491 while (Walker->next != end) {
492 Walker = Walker->next;
493 array[(Walker->*index)] = (Walker->*Setor) (vect);
494 }
495};
496template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ &vect ) const
497{
498 atom *Walker = start;
499 while (Walker->next != end) {
500 Walker = Walker->next;
501 array[(Walker->*index)] = (Walker->*Setor) (vect);
502 }
503};
504template <typename T, typename typ, typename typ2> void molecule::SetAtomValueToIndexedArray ( T *array, int typ::*index, T typ2::*value ) const
505{
506 atom *Walker = start;
507 while (Walker->next != end) {
508 Walker = Walker->next;
509 Walker->*value = array[(Walker->*index)];
510 //Log() << Verbose(2) << *Walker << " gets " << (Walker->*value); << endl;
511 }
512};
513
514template <typename T, typename typ> void molecule::SetAtomValueToValue ( T value, T typ::*ptr ) const
515{
516 atom *Walker = start;
517 while (Walker->next != end) {
518 Walker = Walker->next;
519 Walker->*ptr = value;
520 //Log() << Verbose(2) << *Walker << " gets " << (Walker->*ptr) << endl;
521 }
522};
523
524
525#endif /* MOLECULE_TEMPLATE_HPP_ */
Note: See TracBrowser for help on using the repository browser.