source: ThirdParty/mpqc_open/src/lib/chemistry/molecule/redund.cc@ 7516f6

Action_Thermostats Adding_MD_integration_tests Adding_StructOpt_integration_tests AutomationFragmentation_failures Candidate_v1.6.1 ChemicalSpaceEvaluator Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Exclude_Hydrogens_annealWithBondGraph Fix_Verbose_Codepatterns ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion Gui_displays_atomic_force_velocity JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool PythonUI_with_named_parameters Recreated_GuiChecks StoppableMakroAction TremoloParser_IncreasedPrecision
Last change on this file since 7516f6 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.4 KB
Line 
1//
2// redund.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#include <math.h>
29
30#include <util/state/stateio.h>
31#include <math/scmat/matrix.h>
32#include <math/scmat/local.h>
33#include <chemistry/molecule/molecule.h>
34#include <chemistry/molecule/coor.h>
35#include <chemistry/molecule/simple.h>
36
37#include <util/container/bitarray.h>
38
39using namespace sc;
40
41///////////////////////////////////////////////////////////////////////////
42// members of RedundMolecularCoor
43
44static ClassDesc RedundMolecularCoor_cd(
45 typeid(RedundMolecularCoor),"RedundMolecularCoor",1,"public IntMolecularCoor",
46 0, create<RedundMolecularCoor>, create<RedundMolecularCoor>);
47
48RedundMolecularCoor::RedundMolecularCoor(Ref<Molecule>&mol):
49 IntMolecularCoor(mol)
50{
51 init();
52}
53
54RedundMolecularCoor::RedundMolecularCoor(const Ref<KeyVal>& keyval):
55 IntMolecularCoor(keyval)
56{
57 init();
58}
59
60RedundMolecularCoor::RedundMolecularCoor(StateIn& s):
61 IntMolecularCoor(s)
62{
63}
64
65RedundMolecularCoor::~RedundMolecularCoor()
66{
67}
68
69void
70RedundMolecularCoor::save_data_state(StateOut&s)
71{
72 IntMolecularCoor::save_data_state(s);
73}
74
75void
76RedundMolecularCoor::form_coordinates(int keep_variable)
77{
78 if (!keep_variable) variable_ = all_;
79
80 if (form_print_simples_) print_simples(ExEnv::out0());
81 if (form_print_variable_) print_variable(ExEnv::out0());
82 if (form_print_constant_) print_constant(ExEnv::out0());
83}
84
85void
86RedundMolecularCoor::guess_hessian(RefSymmSCMatrix&hessian)
87{
88 variable_->guess_hessian(molecule_,hessian);
89}
90
91RefSymmSCMatrix
92RedundMolecularCoor::inverse_hessian(RefSymmSCMatrix& hessian)
93{
94 RefSCDimension dredun = hessian.dim();
95
96 // form bmat for variable coordinates (ie all the simples)
97 RefSCMatrix bmat(dredun,dnatom3_,matrixkit_);
98 variable_->bmat(molecule_,bmat);
99
100 // and form G = (B*B+)
101 RefSymmSCMatrix bmbt(dredun,matrixkit_);
102 bmbt.assign(0.0);
103 bmbt.accumulate_symmetric_product(bmat);
104
105 // free bmat, and allocate storage for the projection matrix p
106 bmat = 0;
107
108 RefSCMatrix p(dredun,dredun,matrixkit_);
109 p.assign(0.0);
110
111 // form p = G- * G
112 for (int i=0; i < dredun->n(); i++)
113 p.set_element(i,i,1.0);
114 p = bmbt * p;
115 p = bmbt.gi()*p;
116
117 // accumulate (p*hessian*p).gi() into bmbt
118 bmbt.assign(0.0);
119 bmbt.accumulate_transform(p,hessian);
120 bmbt = bmbt.gi();
121
122 // finally return hinv = p*(p*h*p)-*p
123 RefSymmSCMatrix thess = hessian.clone();
124 thess.assign(0.0);
125 thess.accumulate_transform(p,bmbt);
126 return thess;
127}
128
129/////////////////////////////////////////////////////////////////////////////
130
131// Local Variables:
132// mode: c++
133// c-file-style: "ETS"
134// End:
Note: See TracBrowser for help on using the repository browser.