| [0b990d] | 1 | //
 | 
|---|
 | 2 | // imcoor.cc
 | 
|---|
 | 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 | #include <math.h>
 | 
|---|
 | 29 | 
 | 
|---|
 | 30 | #include <util/class/scexception.h>
 | 
|---|
 | 31 | #include <util/misc/formio.h>
 | 
|---|
 | 32 | #include <util/state/stateio.h>
 | 
|---|
 | 33 | #include <math/scmat/matrix.h>
 | 
|---|
 | 34 | #include <math/scmat/elemop.h>
 | 
|---|
 | 35 | #include <chemistry/molecule/localdef.h>
 | 
|---|
 | 36 | #include <chemistry/molecule/molecule.h>
 | 
|---|
 | 37 | #include <chemistry/molecule/coor.h>
 | 
|---|
 | 38 | #include <chemistry/molecule/simple.h>
 | 
|---|
 | 39 | 
 | 
|---|
 | 40 | #include <util/container/bitarray.h>
 | 
|---|
 | 41 | 
 | 
|---|
 | 42 | using namespace std;
 | 
|---|
 | 43 | using namespace sc;
 | 
|---|
 | 44 | 
 | 
|---|
 | 45 | #define DEFAULT_SIMPLE_TOLERANCE 1.0e-3
 | 
|---|
 | 46 | 
 | 
|---|
 | 47 | ///////////////////////////////////////////////////////////////////////////
 | 
|---|
 | 48 | // members of IntMolecularCoor
 | 
|---|
 | 49 | 
 | 
|---|
 | 50 | static ClassDesc IntMolecularCoor_cd(
 | 
|---|
 | 51 |   typeid(IntMolecularCoor),"IntMolecularCoor",6,"public MolecularCoor",
 | 
|---|
 | 52 |   0, 0, 0);
 | 
|---|
 | 53 | 
 | 
|---|
 | 54 | IntMolecularCoor::IntMolecularCoor(Ref<Molecule>&mol):
 | 
|---|
 | 55 |   MolecularCoor(mol),
 | 
|---|
 | 56 |   update_bmat_(0),
 | 
|---|
 | 57 |   only_totally_symmetric_(1),
 | 
|---|
 | 58 |   symmetry_tolerance_(1.0e-5),
 | 
|---|
 | 59 |   simple_tolerance_(DEFAULT_SIMPLE_TOLERANCE),
 | 
|---|
 | 60 |   coordinate_tolerance_(1.0e-7),
 | 
|---|
 | 61 |   cartesian_tolerance_(1.0e-12),
 | 
|---|
 | 62 |   scale_bonds_(1.0),
 | 
|---|
 | 63 |   scale_bends_(1.0),
 | 
|---|
 | 64 |   scale_tors_(1.0),
 | 
|---|
 | 65 |   scale_outs_(1.0),
 | 
|---|
 | 66 |   given_fixed_values_(0),
 | 
|---|
 | 67 |   decouple_bonds_(0),
 | 
|---|
 | 68 |   decouple_bends_(0),
 | 
|---|
 | 69 |   max_update_steps_(100),
 | 
|---|
 | 70 |   max_update_disp_(0.5),
 | 
|---|
 | 71 |   form_print_simples_(0),
 | 
|---|
 | 72 |   form_print_variable_(0),
 | 
|---|
 | 73 |   form_print_constant_(0),
 | 
|---|
 | 74 |   form_print_molecule_(0)
 | 
|---|
 | 75 | {
 | 
|---|
 | 76 |   new_coords();
 | 
|---|
 | 77 |   generator_ = new IntCoorGen(mol);
 | 
|---|
 | 78 | }
 | 
|---|
 | 79 | 
 | 
|---|
 | 80 | IntMolecularCoor::IntMolecularCoor(const Ref<KeyVal>& keyval):
 | 
|---|
 | 81 |   MolecularCoor(keyval),
 | 
|---|
 | 82 |   update_bmat_(0),
 | 
|---|
 | 83 |   only_totally_symmetric_(1),
 | 
|---|
 | 84 |   symmetry_tolerance_(1.0e-5),
 | 
|---|
 | 85 |   simple_tolerance_(DEFAULT_SIMPLE_TOLERANCE),
 | 
|---|
 | 86 |   coordinate_tolerance_(1.0e-7),
 | 
|---|
 | 87 |   cartesian_tolerance_(1.0e-12),
 | 
|---|
 | 88 |   scale_bonds_(1.0),
 | 
|---|
 | 89 |   scale_bends_(1.0),
 | 
|---|
 | 90 |   scale_tors_(1.0),
 | 
|---|
 | 91 |   scale_outs_(1.0),
 | 
|---|
 | 92 |   decouple_bonds_(0),
 | 
|---|
 | 93 |   decouple_bends_(0)
 | 
|---|
 | 94 | {
 | 
|---|
 | 95 |   // intialize the coordinate sets
 | 
|---|
 | 96 |   new_coords();
 | 
|---|
 | 97 | 
 | 
|---|
 | 98 |   // actually read the keyval info
 | 
|---|
 | 99 |   read_keyval(keyval);
 | 
|---|
 | 100 | }
 | 
|---|
 | 101 | 
 | 
|---|
 | 102 | IntMolecularCoor::IntMolecularCoor(StateIn& s):
 | 
|---|
 | 103 |   MolecularCoor(s)
 | 
|---|
 | 104 | {
 | 
|---|
 | 105 |   generator_ << SavableState::restore_state(s);
 | 
|---|
 | 106 | 
 | 
|---|
 | 107 |   if (s.version(::class_desc<IntMolecularCoor>()) >= 3) {
 | 
|---|
 | 108 |       s.get(decouple_bonds_);
 | 
|---|
 | 109 |       s.get(decouple_bends_);
 | 
|---|
 | 110 |     }
 | 
|---|
 | 111 |   else {
 | 
|---|
 | 112 |       decouple_bonds_ = 0;
 | 
|---|
 | 113 |       decouple_bends_ = 0;
 | 
|---|
 | 114 |     }
 | 
|---|
 | 115 |   
 | 
|---|
 | 116 |   if (s.version(::class_desc<IntMolecularCoor>()) >= 2) {
 | 
|---|
 | 117 |     s.get(max_update_steps_);
 | 
|---|
 | 118 |     s.get(max_update_disp_);
 | 
|---|
 | 119 |     s.get(given_fixed_values_);
 | 
|---|
 | 120 |   } else {
 | 
|---|
 | 121 |     max_update_steps_ = 100;
 | 
|---|
 | 122 |     max_update_disp_ = 0.5;
 | 
|---|
 | 123 |     given_fixed_values_ = 0;
 | 
|---|
 | 124 |   }
 | 
|---|
 | 125 |   
 | 
|---|
 | 126 |   if (s.version(::class_desc<IntMolecularCoor>()) >= 4) {
 | 
|---|
 | 127 |     s.get(form_print_simples_);
 | 
|---|
 | 128 |     s.get(form_print_variable_);
 | 
|---|
 | 129 |     s.get(form_print_constant_);
 | 
|---|
 | 130 |   } else {
 | 
|---|
 | 131 |     form_print_simples_ = 0;
 | 
|---|
 | 132 |     form_print_variable_ = 0;
 | 
|---|
 | 133 |     form_print_constant_ = 0;
 | 
|---|
 | 134 |   }
 | 
|---|
 | 135 |   
 | 
|---|
 | 136 |   if (s.version(::class_desc<IntMolecularCoor>()) >= 5) {
 | 
|---|
 | 137 |     s.get(form_print_molecule_);
 | 
|---|
 | 138 |   } else {
 | 
|---|
 | 139 |     form_print_molecule_ = 0;
 | 
|---|
 | 140 |   }
 | 
|---|
 | 141 | 
 | 
|---|
 | 142 |   dim_ << SavableState::restore_state(s);
 | 
|---|
 | 143 |   dvc_ << SavableState::restore_state(s);
 | 
|---|
 | 144 | 
 | 
|---|
 | 145 |   all_ << SavableState::restore_state(s);
 | 
|---|
 | 146 | 
 | 
|---|
 | 147 |   variable_ << SavableState::restore_state(s);
 | 
|---|
 | 148 |   constant_ << SavableState::restore_state(s);
 | 
|---|
 | 149 | 
 | 
|---|
 | 150 |   fixed_ << SavableState::restore_state(s);
 | 
|---|
 | 151 |   followed_ << SavableState::restore_state(s);
 | 
|---|
 | 152 | 
 | 
|---|
 | 153 |   if (s.version(::class_desc<IntMolecularCoor>()) >= 6)
 | 
|---|
 | 154 |       watched_ << SavableState::restore_state(s);
 | 
|---|
 | 155 | 
 | 
|---|
 | 156 |   bonds_ << SavableState::restore_state(s);
 | 
|---|
 | 157 |   bends_ << SavableState::restore_state(s);
 | 
|---|
 | 158 |   tors_ << SavableState::restore_state(s);
 | 
|---|
 | 159 |   outs_ << SavableState::restore_state(s);
 | 
|---|
 | 160 |   extras_ << SavableState::restore_state(s);
 | 
|---|
 | 161 | 
 | 
|---|
 | 162 |   s.get(update_bmat_);
 | 
|---|
 | 163 |   s.get(only_totally_symmetric_);
 | 
|---|
 | 164 |   s.get(scale_bonds_);
 | 
|---|
 | 165 |   s.get(scale_bends_);
 | 
|---|
 | 166 |   s.get(scale_tors_);
 | 
|---|
 | 167 |   s.get(scale_outs_);
 | 
|---|
 | 168 |   s.get(simple_tolerance_);
 | 
|---|
 | 169 |   s.get(symmetry_tolerance_);
 | 
|---|
 | 170 |   s.get(coordinate_tolerance_);
 | 
|---|
 | 171 |   s.get(cartesian_tolerance_);
 | 
|---|
 | 172 | }
 | 
|---|
 | 173 | 
 | 
|---|
 | 174 | void
 | 
|---|
 | 175 | IntMolecularCoor::new_coords()
 | 
|---|
 | 176 | {
 | 
|---|
 | 177 |   // intialize the coordinate sets
 | 
|---|
 | 178 |   all_ = new SetIntCoor; // all redundant coors
 | 
|---|
 | 179 |   variable_ = new SetIntCoor; // internal coors to be varied
 | 
|---|
 | 180 |   constant_ = new SetIntCoor; // internal coors to be fixed
 | 
|---|
 | 181 |   bonds_ = new SetIntCoor;
 | 
|---|
 | 182 |   bends_ = new SetIntCoor;
 | 
|---|
 | 183 |   tors_ = new SetIntCoor;
 | 
|---|
 | 184 |   outs_ = new SetIntCoor;
 | 
|---|
 | 185 |   extras_ = new SetIntCoor;
 | 
|---|
 | 186 |   fixed_ = new SetIntCoor;
 | 
|---|
 | 187 |   followed_ = 0;
 | 
|---|
 | 188 |   watched_ = 0;
 | 
|---|
 | 189 | }
 | 
|---|
 | 190 | 
 | 
|---|
 | 191 | void
 | 
|---|
 | 192 | IntMolecularCoor::read_keyval(const Ref<KeyVal>& keyval)
 | 
|---|
 | 193 | {
 | 
|---|
 | 194 |   variable_ << keyval->describedclassvalue("variable");
 | 
|---|
 | 195 |   if (variable_.null()) variable_ = new SetIntCoor;
 | 
|---|
 | 196 |   fixed_ << keyval->describedclassvalue("fixed");
 | 
|---|
 | 197 |   if (fixed_.null()) fixed_ = new SetIntCoor;
 | 
|---|
 | 198 |   followed_ << keyval->describedclassvalue("followed");
 | 
|---|
 | 199 |   watched_ << keyval->describedclassvalue("watched");
 | 
|---|
 | 200 | 
 | 
|---|
 | 201 |   decouple_bonds_ = keyval->booleanvalue("decouple_bonds");
 | 
|---|
 | 202 |   decouple_bends_ = keyval->booleanvalue("decouple_bends");
 | 
|---|
 | 203 | 
 | 
|---|
 | 204 |   given_fixed_values_ = keyval->booleanvalue("have_fixed_values");
 | 
|---|
 | 205 | 
 | 
|---|
 | 206 |   max_update_steps_ = keyval->intvalue("max_update_steps");
 | 
|---|
 | 207 |   if (keyval->error() != KeyVal::OK) max_update_steps_ = 100;
 | 
|---|
 | 208 | 
 | 
|---|
 | 209 |   max_update_disp_ = keyval->doublevalue("max_update_disp");
 | 
|---|
 | 210 |   if (keyval->error() != KeyVal::OK) max_update_disp_ = 0.5;
 | 
|---|
 | 211 | 
 | 
|---|
 | 212 |   generator_ << keyval->describedclassvalue("generator");
 | 
|---|
 | 213 | 
 | 
|---|
 | 214 |   if (generator_.null()) {
 | 
|---|
 | 215 |       // the extra_bonds list is given as a vector of atom numbers
 | 
|---|
 | 216 |       // (atom numbering starts at 1)
 | 
|---|
 | 217 |       int nextra_bonds = keyval->count("extra_bonds");
 | 
|---|
 | 218 |       nextra_bonds /= 2;
 | 
|---|
 | 219 |       int *extra_bonds;
 | 
|---|
 | 220 |       if (nextra_bonds) {
 | 
|---|
 | 221 |           extra_bonds = new int[nextra_bonds*2];
 | 
|---|
 | 222 |           for (int i=0; i<nextra_bonds*2; i++) {
 | 
|---|
 | 223 |               extra_bonds[i] = keyval->intvalue("extra_bonds",i);
 | 
|---|
 | 224 |               if (keyval->error() != KeyVal::OK) {
 | 
|---|
 | 225 |                   throw InputError("missing an expected integer value",
 | 
|---|
 | 226 |                                    __FILE__, __LINE__, "extra_bonds", 0,
 | 
|---|
 | 227 |                                    class_desc());
 | 
|---|
 | 228 |                 }
 | 
|---|
 | 229 |             }
 | 
|---|
 | 230 |         }
 | 
|---|
 | 231 |       else {
 | 
|---|
 | 232 |           extra_bonds = 0;
 | 
|---|
 | 233 |         }
 | 
|---|
 | 234 |       generator_ = new IntCoorGen(molecule_, nextra_bonds, extra_bonds);
 | 
|---|
 | 235 |     }
 | 
|---|
 | 236 |           
 | 
|---|
 | 237 | 
 | 
|---|
 | 238 |   update_bmat_ = keyval->booleanvalue("update_bmat");
 | 
|---|
 | 239 | 
 | 
|---|
 | 240 |   only_totally_symmetric_ = keyval->booleanvalue("only_totally_symmetric");
 | 
|---|
 | 241 |   if (keyval->error() != KeyVal::OK) only_totally_symmetric_ = 1;
 | 
|---|
 | 242 | 
 | 
|---|
 | 243 |   double tmp;
 | 
|---|
 | 244 |   tmp = keyval->doublevalue("scale_bonds");
 | 
|---|
 | 245 |   if (keyval->error() == KeyVal::OK) scale_bonds_ = tmp;
 | 
|---|
 | 246 |   tmp = keyval->doublevalue("scale_bends");
 | 
|---|
 | 247 |   if (keyval->error() == KeyVal::OK) scale_bends_ = tmp;
 | 
|---|
 | 248 |   tmp = keyval->doublevalue("scale_tors");
 | 
|---|
 | 249 |   if (keyval->error() == KeyVal::OK) scale_tors_ = tmp;
 | 
|---|
 | 250 |   tmp = keyval->doublevalue("scale_outs");
 | 
|---|
 | 251 |   if (keyval->error() == KeyVal::OK) scale_outs_ = tmp;
 | 
|---|
 | 252 |   tmp = keyval->doublevalue("symmetry_tolerance");
 | 
|---|
 | 253 |   if (keyval->error() == KeyVal::OK) symmetry_tolerance_ = tmp;
 | 
|---|
 | 254 |   tmp = keyval->doublevalue("simple_tolerance");
 | 
|---|
 | 255 |   if (keyval->error() == KeyVal::OK) simple_tolerance_ = tmp;
 | 
|---|
 | 256 |   tmp = keyval->doublevalue("coordinate_tolerance");
 | 
|---|
 | 257 |   if (keyval->error() == KeyVal::OK) coordinate_tolerance_ = tmp;
 | 
|---|
 | 258 |   tmp = keyval->doublevalue("cartesian_tolerance");
 | 
|---|
 | 259 |   if (keyval->error() == KeyVal::OK) cartesian_tolerance_ = tmp;
 | 
|---|
 | 260 | 
 | 
|---|
 | 261 |   form_print_simples_ = keyval->booleanvalue("form:print_simple");
 | 
|---|
 | 262 |   if (keyval->error() != KeyVal::OK) form_print_simples_ = 0;
 | 
|---|
 | 263 |   form_print_variable_ = keyval->booleanvalue("form:print_variable");
 | 
|---|
 | 264 |   if (keyval->error() != KeyVal::OK) form_print_variable_ = 0;
 | 
|---|
 | 265 |   form_print_constant_ = keyval->booleanvalue("form:print_constant");
 | 
|---|
 | 266 |   if (keyval->error() != KeyVal::OK) form_print_constant_ = 0;
 | 
|---|
 | 267 |   form_print_molecule_ = keyval->booleanvalue("form:print_molecule");
 | 
|---|
 | 268 |   if (keyval->error() != KeyVal::OK) form_print_molecule_ = 0;
 | 
|---|
 | 269 | }
 | 
|---|
 | 270 | 
 | 
|---|
 | 271 | void
 | 
|---|
 | 272 | IntMolecularCoor::init()
 | 
|---|
 | 273 | {
 | 
|---|
 | 274 |   Ref<SetIntCoor> redundant = new SetIntCoor;
 | 
|---|
 | 275 |   generator_->generate(redundant);
 | 
|---|
 | 276 | 
 | 
|---|
 | 277 |   // sort out the simple coordinates by type
 | 
|---|
 | 278 |   int i;
 | 
|---|
 | 279 |   for (i=0; i<redundant->n(); i++) {
 | 
|---|
 | 280 |       Ref<IntCoor> coor = redundant->coor(i);
 | 
|---|
 | 281 |       if (coor->class_desc()
 | 
|---|
 | 282 |           == ::class_desc<StreSimpleCo>()) {
 | 
|---|
 | 283 |           bonds_->add(coor);
 | 
|---|
 | 284 |         }
 | 
|---|
 | 285 |       else if (coor->class_desc() == ::class_desc<BendSimpleCo>()
 | 
|---|
 | 286 |                || coor->class_desc() == ::class_desc<LinIPSimpleCo>()
 | 
|---|
 | 287 |                || coor->class_desc() == ::class_desc<LinOPSimpleCo>()) {
 | 
|---|
 | 288 |           bends_->add(coor);
 | 
|---|
 | 289 |         }
 | 
|---|
 | 290 |       else if (coor->class_desc()
 | 
|---|
 | 291 |                == ::class_desc<TorsSimpleCo>()
 | 
|---|
 | 292 |                || coor->class_desc()
 | 
|---|
 | 293 |                == ::class_desc<ScaledTorsSimpleCo>()) {
 | 
|---|
 | 294 |           tors_->add(coor);
 | 
|---|
 | 295 |         }
 | 
|---|
 | 296 |       else if (coor->class_desc()
 | 
|---|
 | 297 |                == ::class_desc<OutSimpleCo>()) {
 | 
|---|
 | 298 |           outs_->add(coor);
 | 
|---|
 | 299 |         }
 | 
|---|
 | 300 |       else {
 | 
|---|
 | 301 |           extras_->add(coor);
 | 
|---|
 | 302 |         }
 | 
|---|
 | 303 |     }
 | 
|---|
 | 304 | 
 | 
|---|
 | 305 |   all_->add(bonds_);
 | 
|---|
 | 306 |   all_->add(bends_);
 | 
|---|
 | 307 |   all_->add(tors_);
 | 
|---|
 | 308 |   all_->add(outs_);
 | 
|---|
 | 309 |   all_->add(extras_);
 | 
|---|
 | 310 | 
 | 
|---|
 | 311 |   // don't let form_coordinates create new variables coordinates
 | 
|---|
 | 312 |   // if they were given by the user
 | 
|---|
 | 313 |   int keep_variable = (variable_->n() != 0);
 | 
|---|
 | 314 | 
 | 
|---|
 | 315 |   if (given_fixed_values_) {
 | 
|---|
 | 316 |       // save the given coordinate values
 | 
|---|
 | 317 |       RefSCDimension original_dfixed
 | 
|---|
 | 318 |           = new SCDimension(fixed_->n(),"Nfix");
 | 
|---|
 | 319 |       RefSCVector given_fixed_coords(original_dfixed,matrixkit_);
 | 
|---|
 | 320 |       for (i=0; i<original_dfixed.n(); i++) {
 | 
|---|
 | 321 |           given_fixed_coords(i) = fixed_->coor(i)->value();
 | 
|---|
 | 322 |         }
 | 
|---|
 | 323 | 
 | 
|---|
 | 324 |       // find the current fixed coordinates
 | 
|---|
 | 325 |       RefSCVector current_fixed_coords(original_dfixed,matrixkit_);
 | 
|---|
 | 326 |       fixed_->update_values(molecule_);
 | 
|---|
 | 327 |       for (i=0; i<original_dfixed.n(); i++) {
 | 
|---|
 | 328 |           current_fixed_coords(i) = fixed_->coor(i)->value();
 | 
|---|
 | 329 |         }
 | 
|---|
 | 330 | 
 | 
|---|
 | 331 |       // the difference between current fixed and desired fixed
 | 
|---|
 | 332 |       RefSCVector diff_fixed_coords = given_fixed_coords-current_fixed_coords;
 | 
|---|
 | 333 | 
 | 
|---|
 | 334 |       // break up the displacement into several manageable steps
 | 
|---|
 | 335 |       double maxabs = diff_fixed_coords.maxabs();
 | 
|---|
 | 336 |       int nstep = int(maxabs/max_update_disp_) + 1;
 | 
|---|
 | 337 |       diff_fixed_coords.scale(1.0/nstep);
 | 
|---|
 | 338 |       ExEnv::out0() << indent << "IntMolecularCoor: "
 | 
|---|
 | 339 |            << "displacing fixed coordinates to the requested values in "
 | 
|---|
 | 340 |            << nstep << " steps\n";
 | 
|---|
 | 341 |       for (int istep=1; istep<=nstep; istep++) {
 | 
|---|
 | 342 |           form_coordinates(keep_variable);
 | 
|---|
 | 343 | 
 | 
|---|
 | 344 |           dim_ = new SCDimension(variable_->n(), "Nvar");
 | 
|---|
 | 345 |           dvc_ = new SCDimension(variable_->n()+constant_->n(),
 | 
|---|
 | 346 |                              "Nvar+Nconst");
 | 
|---|
 | 347 | 
 | 
|---|
 | 348 |           RefSCVector new_internal_coordinates(dvc_,matrixkit_);
 | 
|---|
 | 349 |           for (i=0; i<variable_->n(); i++) {
 | 
|---|
 | 350 |               new_internal_coordinates(i) = variable_->coor(i)->value();
 | 
|---|
 | 351 |             }
 | 
|---|
 | 352 |           int j;
 | 
|---|
 | 353 |           for (j=0; j<original_dfixed.n(); j++,i++) {
 | 
|---|
 | 354 |               new_internal_coordinates(i)
 | 
|---|
 | 355 |                   = current_fixed_coords(j)+istep*double(diff_fixed_coords(j));
 | 
|---|
 | 356 |             }
 | 
|---|
 | 357 |           for (; j<constant_->n(); i++,j++) {
 | 
|---|
 | 358 |               new_internal_coordinates(i) = constant_->coor(j)->value();
 | 
|---|
 | 359 |             }
 | 
|---|
 | 360 | 
 | 
|---|
 | 361 |           all_to_cartesian(molecule_, new_internal_coordinates);
 | 
|---|
 | 362 |         }
 | 
|---|
 | 363 | 
 | 
|---|
 | 364 |       // make sure that the coordinates have exactly the
 | 
|---|
 | 365 |       // original values to avoid round-off error
 | 
|---|
 | 366 |       for (i=0; i<original_dfixed.n(); i++) {
 | 
|---|
 | 367 |           fixed_->coor(i)->set_value(given_fixed_coords(i));
 | 
|---|
 | 368 |         }
 | 
|---|
 | 369 |     }
 | 
|---|
 | 370 | 
 | 
|---|
 | 371 |   form_coordinates(keep_variable);
 | 
|---|
 | 372 | 
 | 
|---|
 | 373 |   dim_ = new SCDimension(variable_->n(), "Nvar");
 | 
|---|
 | 374 |   dvc_ = new SCDimension(variable_->n()+constant_->n(),
 | 
|---|
 | 375 |                          "Nvar+Nconst");
 | 
|---|
 | 376 | 
 | 
|---|
 | 377 | #if 0 // this will always think the rank has changed with redundant coordinates
 | 
|---|
 | 378 |     {
 | 
|---|
 | 379 |       const double epsilon = 0.001;
 | 
|---|
 | 380 | 
 | 
|---|
 | 381 |       // compute the condition number
 | 
|---|
 | 382 |       RefSCMatrix B(dim_, dnatom3_,matrixkit_);
 | 
|---|
 | 383 |       variable_->bmat(molecule_, B);
 | 
|---|
 | 384 | 
 | 
|---|
 | 385 |       // Compute the singular value decomposition of B
 | 
|---|
 | 386 |       RefSCMatrix U(dim_,dim_,matrixkit_);
 | 
|---|
 | 387 |       RefSCMatrix V(dnatom3_,dnatom3_,matrixkit_);
 | 
|---|
 | 388 |       RefSCDimension min;
 | 
|---|
 | 389 |       if (dnatom3_.n()<dim_.n()) min = dnatom3_;
 | 
|---|
 | 390 |       else min = dim_;
 | 
|---|
 | 391 |       int nmin = min.n();
 | 
|---|
 | 392 |       RefDiagSCMatrix sigma(min,matrixkit_);
 | 
|---|
 | 393 |       B.svd(U,sigma,V);
 | 
|---|
 | 394 | 
 | 
|---|
 | 395 |       // Compute the epsilon rank of B
 | 
|---|
 | 396 |       int i, rank = 0;
 | 
|---|
 | 397 |       for (i=0; i<nmin; i++) {
 | 
|---|
 | 398 |           if (sigma(i) > epsilon) rank++;
 | 
|---|
 | 399 |         }
 | 
|---|
 | 400 | 
 | 
|---|
 | 401 |       if (rank != dim_.n()) {
 | 
|---|
 | 402 |           ExEnv::out0() << indent << "IntMolecularCoor::init: rank changed\n";
 | 
|---|
 | 403 |           sigma.print("sigma");
 | 
|---|
 | 404 |         }
 | 
|---|
 | 405 | 
 | 
|---|
 | 406 |       double kappa2 = sigma(0)/sigma(dim_.n()-1);
 | 
|---|
 | 407 | 
 | 
|---|
 | 408 |       ExEnv::out0() << indent
 | 
|---|
 | 409 |            << scprintf("IntMolecularCoor::init: condition number = %14.8f\n",
 | 
|---|
 | 410 |                        kappa2);
 | 
|---|
 | 411 |     }
 | 
|---|
 | 412 | #endif
 | 
|---|
 | 413 | 
 | 
|---|
 | 414 |   if (watched_.nonnull()) {
 | 
|---|
 | 415 |       ExEnv::out0() << endl
 | 
|---|
 | 416 |            << indent << "Watched coordinate(s):\n" << incindent;
 | 
|---|
 | 417 |       watched_->update_values(molecule_);
 | 
|---|
 | 418 |       watched_->print_details(molecule_,ExEnv::out0());
 | 
|---|
 | 419 |       ExEnv::out0() << decindent;
 | 
|---|
 | 420 |     }
 | 
|---|
 | 421 | }
 | 
|---|
 | 422 | 
 | 
|---|
 | 423 | static int
 | 
|---|
 | 424 | count_nonzero(const RefSCVector &vec, double eps)
 | 
|---|
 | 425 | {
 | 
|---|
 | 426 |   int nz=0, i, n=vec.n();
 | 
|---|
 | 427 |   for (i=0; i<n; i++) {
 | 
|---|
 | 428 |       if (fabs(vec(i)) > eps) nz++;
 | 
|---|
 | 429 |     }
 | 
|---|
 | 430 |   return nz;
 | 
|---|
 | 431 | }
 | 
|---|
 | 432 | 
 | 
|---|
 | 433 | static RefSymmSCMatrix
 | 
|---|
 | 434 | form_partial_K(const Ref<SetIntCoor>& coor, Ref<Molecule>& molecule,
 | 
|---|
 | 435 |                const RefSCVector& geom,
 | 
|---|
 | 436 |                double epsilon,
 | 
|---|
 | 437 |                const RefSCDimension& dnatom3,
 | 
|---|
 | 438 |                const Ref<SCMatrixKit>& matrixkit,
 | 
|---|
 | 439 |                RefSCMatrix& projection,
 | 
|---|
 | 440 |                RefSCVector& totally_symmetric,
 | 
|---|
 | 441 |                RefSCMatrix& K,int debug)
 | 
|---|
 | 442 | {
 | 
|---|
 | 443 |   if (debug) {
 | 
|---|
 | 444 |       ExEnv::out0() << indent << "form_partial_K:" << endl;
 | 
|---|
 | 445 |       ExEnv::out0() << incindent;
 | 
|---|
 | 446 |     }
 | 
|---|
 | 447 | 
 | 
|---|
 | 448 |   // Compute the B matrix for the coordinates
 | 
|---|
 | 449 |   RefSCDimension dcoor = new SCDimension(coor->n());
 | 
|---|
 | 450 |   RefSCMatrix B(dcoor, dnatom3,matrixkit);
 | 
|---|
 | 451 |   coor->bmat(molecule, B);
 | 
|---|
 | 452 | 
 | 
|---|
 | 453 |   if (debug) B.print("B");
 | 
|---|
 | 454 | 
 | 
|---|
 | 455 |   // Project out the previously discovered internal coordinates
 | 
|---|
 | 456 |   if (projection.nonnull()) {
 | 
|---|
 | 457 |       B = B * projection;
 | 
|---|
 | 458 |       if (debug) B.print("Projected B");
 | 
|---|
 | 459 |     }
 | 
|---|
 | 460 | 
 | 
|---|
 | 461 |   // Compute the singular value decomposition of B
 | 
|---|
 | 462 |   RefSCMatrix U(dcoor,dcoor,matrixkit);
 | 
|---|
 | 463 |   RefSCMatrix V(dnatom3,dnatom3,matrixkit);
 | 
|---|
 | 464 |   RefSCDimension min;
 | 
|---|
 | 465 |   if (dnatom3.n()<dcoor.n()) min = dnatom3;
 | 
|---|
 | 466 |   else min = dcoor;
 | 
|---|
 | 467 |   int nmin = min.n();
 | 
|---|
 | 468 |   RefDiagSCMatrix sigma(min,matrixkit);
 | 
|---|
 | 469 |   B.svd(U,sigma,V);
 | 
|---|
 | 470 | 
 | 
|---|
 | 471 |   // Compute the epsilon rank of B
 | 
|---|
 | 472 |   int i, rank = 0;
 | 
|---|
 | 473 |   for (i=0; i<nmin; i++) {
 | 
|---|
 | 474 |       if (sigma(i) > epsilon) rank++;
 | 
|---|
 | 475 |     }
 | 
|---|
 | 476 | 
 | 
|---|
 | 477 |   if (debug)
 | 
|---|
 | 478 |       ExEnv::out0() << indent << "rank(" << epsilon << ",B) = " << rank
 | 
|---|
 | 479 |            << endl;
 | 
|---|
 | 480 | 
 | 
|---|
 | 481 |   RefSCMatrix SIGMA(dcoor, dnatom3,matrixkit);
 | 
|---|
 | 482 |   SIGMA.assign(0.0);
 | 
|---|
 | 483 |   for (i=0; i<nmin; i++) {
 | 
|---|
 | 484 |       SIGMA(i,i) = sigma(i);
 | 
|---|
 | 485 |     }
 | 
|---|
 | 486 | 
 | 
|---|
 | 487 |   // return if there are no new coordinates
 | 
|---|
 | 488 |   if (rank==0) {
 | 
|---|
 | 489 |       if (debug) ExEnv::out0() << decindent;
 | 
|---|
 | 490 |       return 0;
 | 
|---|
 | 491 |     }
 | 
|---|
 | 492 | 
 | 
|---|
 | 493 |   // Find an orthogonal matrix that spans the range of B
 | 
|---|
 | 494 |   RefSCMatrix Ur;
 | 
|---|
 | 495 |   RefSCDimension drank = new SCDimension(rank);
 | 
|---|
 | 496 |   if (rank) {
 | 
|---|
 | 497 |       Ur = matrixkit->matrix(dcoor,drank);
 | 
|---|
 | 498 |       Ur.assign_subblock(U,0, dcoor.n()-1, 0, drank.n()-1, 0, 0);
 | 
|---|
 | 499 |     }
 | 
|---|
 | 500 | 
 | 
|---|
 | 501 |   // Find an orthogonal matrix that spans the null space of B
 | 
|---|
 | 502 |   int rank_tilde = dnatom3.n() - rank;
 | 
|---|
 | 503 |   RefSCMatrix Vr_tilde;
 | 
|---|
 | 504 |   RefSCDimension drank_tilde = new SCDimension(rank_tilde);
 | 
|---|
 | 505 |   if (rank_tilde) {
 | 
|---|
 | 506 |       Vr_tilde = matrixkit->matrix(dnatom3,drank_tilde);
 | 
|---|
 | 507 |       Vr_tilde.assign_subblock(V,0, dnatom3.n()-1, 0, drank_tilde.n()-1,
 | 
|---|
 | 508 |                                0, drank.n());
 | 
|---|
 | 509 |     }
 | 
|---|
 | 510 | 
 | 
|---|
 | 511 |   // Find an orthogonal matrix that spans the null(B) perp
 | 
|---|
 | 512 |   RefSCMatrix Vr;
 | 
|---|
 | 513 |   if (rank) {
 | 
|---|
 | 514 |       Vr = matrixkit->matrix(dnatom3,drank);
 | 
|---|
 | 515 |       Vr.assign_subblock(V,0, dnatom3.n()-1, 0, drank.n()-1, 0, 0);
 | 
|---|
 | 516 |     }
 | 
|---|
 | 517 | 
 | 
|---|
 | 518 |   // compute the projection into the null space of B
 | 
|---|
 | 519 |   RefSymmSCMatrix proj_nullspace_B;
 | 
|---|
 | 520 |   if (rank_tilde) {
 | 
|---|
 | 521 |       proj_nullspace_B = matrixkit->symmmatrix(dnatom3);
 | 
|---|
 | 522 |       proj_nullspace_B.assign(0.0);
 | 
|---|
 | 523 |       proj_nullspace_B.accumulate_symmetric_product(Vr_tilde);
 | 
|---|
 | 524 |     }
 | 
|---|
 | 525 | 
 | 
|---|
 | 526 |   // compute the projection into the null(B) perp
 | 
|---|
 | 527 |   RefSymmSCMatrix proj_nullspace_B_perp;
 | 
|---|
 | 528 |   if (rank) {
 | 
|---|
 | 529 |       proj_nullspace_B_perp = matrixkit->symmmatrix(dnatom3);
 | 
|---|
 | 530 |       proj_nullspace_B_perp.assign(0.0);
 | 
|---|
 | 531 |       proj_nullspace_B_perp.accumulate_symmetric_product(Vr);
 | 
|---|
 | 532 |     }
 | 
|---|
 | 533 | 
 | 
|---|
 | 534 |   if (Ur.nonnull()) {
 | 
|---|
 | 535 |       // totally_symmetric will be nonzero for totally symmetric coordinates
 | 
|---|
 | 536 |       totally_symmetric = Ur.t() * B * geom;
 | 
|---|
 | 537 | 
 | 
|---|
 | 538 |       if (debug) {
 | 
|---|
 | 539 |           Ur.print("Ur");
 | 
|---|
 | 540 |           geom.print("geom");
 | 
|---|
 | 541 |           totally_symmetric.print("totally_symmetric = Ur.t()*B*geom");
 | 
|---|
 | 542 | 
 | 
|---|
 | 543 |           int ntotally_symmetric = count_nonzero(totally_symmetric,0.001);
 | 
|---|
 | 544 |           ExEnv::out0() << indent << "found " << ntotally_symmetric
 | 
|---|
 | 545 |                << " totally symmetric coordinates\n";
 | 
|---|
 | 546 |         }
 | 
|---|
 | 547 | 
 | 
|---|
 | 548 |       // compute the cumulative projection
 | 
|---|
 | 549 |       if (projection.null()) {
 | 
|---|
 | 550 |           projection = matrixkit->matrix(dnatom3,dnatom3);
 | 
|---|
 | 551 |           projection->unit();
 | 
|---|
 | 552 |         }
 | 
|---|
 | 553 |       projection = projection * proj_nullspace_B;
 | 
|---|
 | 554 |     }
 | 
|---|
 | 555 | 
 | 
|---|
 | 556 |   // give Ur to caller
 | 
|---|
 | 557 |   K = Ur;
 | 
|---|
 | 558 | 
 | 
|---|
 | 559 |   if (debug) ExEnv::out0() << decindent;
 | 
|---|
 | 560 | 
 | 
|---|
 | 561 |   return proj_nullspace_B_perp;
 | 
|---|
 | 562 | }
 | 
|---|
 | 563 | 
 | 
|---|
 | 564 | // this allocates storage for and computes K and is_totally_symmetric
 | 
|---|
 | 565 | void
 | 
|---|
 | 566 | IntMolecularCoor::form_K_matrix(RefSCDimension& dredundant,
 | 
|---|
 | 567 |                                 RefSCDimension& dfixed,
 | 
|---|
 | 568 |                                 RefSCMatrix& K,
 | 
|---|
 | 569 |                                 int*& is_totally_symmetric)
 | 
|---|
 | 570 | {
 | 
|---|
 | 571 |   int i,j;
 | 
|---|
 | 572 | 
 | 
|---|
 | 573 |   // The cutoff for whether or not a coordinate is considered totally symmetric
 | 
|---|
 | 574 |   double ts_eps = 0.0001;
 | 
|---|
 | 575 | 
 | 
|---|
 | 576 |   // The geometry will be needed to check for totally symmetric
 | 
|---|
 | 577 |   // coordinates
 | 
|---|
 | 578 |   RefSCVector geom(dnatom3_,matrixkit_);
 | 
|---|
 | 579 |   for(i=0; i < geom.n()/3; i++) {
 | 
|---|
 | 580 |       geom(3*i  ) = molecule_->r(i,0);
 | 
|---|
 | 581 |       geom(3*i+1) = molecule_->r(i,1);
 | 
|---|
 | 582 |       geom(3*i+2) = molecule_->r(i,2);
 | 
|---|
 | 583 |     }
 | 
|---|
 | 584 | 
 | 
|---|
 | 585 |   RefSCDimension dcoor = new SCDimension(all_->n());
 | 
|---|
 | 586 | 
 | 
|---|
 | 587 |   // this keeps track of the total projection for the b matrices
 | 
|---|
 | 588 |   RefSCMatrix projection;
 | 
|---|
 | 589 |   if (dfixed.n()) {
 | 
|---|
 | 590 |       ExEnv::out0() << indent
 | 
|---|
 | 591 |            << "Forming fixed optimization coordinates:" << endl;
 | 
|---|
 | 592 |       RefSCMatrix Ktmp;
 | 
|---|
 | 593 |       RefSCVector totally_symmetric_fixed;
 | 
|---|
 | 594 |       RefSymmSCMatrix null_bfixed_perp
 | 
|---|
 | 595 |           = form_partial_K(fixed_, molecule_, geom, 0.001, dnatom3_,
 | 
|---|
 | 596 |                            matrixkit_, projection, totally_symmetric_fixed,
 | 
|---|
 | 597 |                            Ktmp,debug_);
 | 
|---|
 | 598 |       // require that the epsilon rank equal the number of fixed coordinates
 | 
|---|
 | 599 |       if (Ktmp.nrow() != dfixed.n()) {
 | 
|---|
 | 600 |           throw AlgorithmException("nfixed != rank",
 | 
|---|
 | 601 |                                    __FILE__, __LINE__,
 | 
|---|
 | 602 |                                    class_desc());
 | 
|---|
 | 603 |         }
 | 
|---|
 | 604 |       // check that fixed coordinates be totally symmetric
 | 
|---|
 | 605 |       //if (Ktmp.nrow() != count_nonzero(totally_symmetric_fixed, ts_eps)) {
 | 
|---|
 | 606 |       //    ExEnv::err0() << indent
 | 
|---|
 | 607 |       //         << scprintf("WARNING: only %d of %d fixed coordinates are"
 | 
|---|
 | 608 |       //                     " totally symmetric\n",
 | 
|---|
 | 609 |       //                     count_nonzero(totally_symmetric_fixed, ts_eps),
 | 
|---|
 | 610 |       //                     dfixed.n());
 | 
|---|
 | 611 |       //  }
 | 
|---|
 | 612 |     }
 | 
|---|
 | 613 | 
 | 
|---|
 | 614 |   ExEnv::out0() << indent << "Forming optimization coordinates:" << endl;
 | 
|---|
 | 615 | 
 | 
|---|
 | 616 |   int n_total = 0;
 | 
|---|
 | 617 | 
 | 
|---|
 | 618 |   RefSCVector totally_symmetric_bond;
 | 
|---|
 | 619 |   RefSCMatrix Kbond;
 | 
|---|
 | 620 |   if (decouple_bonds_) {
 | 
|---|
 | 621 |       ExEnv::out0() << indent << "looking for bonds" << endl;
 | 
|---|
 | 622 |       form_partial_K(bonds_, molecule_, geom, 0.1, dnatom3_, matrixkit_,
 | 
|---|
 | 623 |                      projection, totally_symmetric_bond, Kbond, debug_);
 | 
|---|
 | 624 |       if (Kbond.nonnull()) n_total += Kbond.ncol();
 | 
|---|
 | 625 |     }
 | 
|---|
 | 626 | 
 | 
|---|
 | 627 |   RefSCVector totally_symmetric_bend;
 | 
|---|
 | 628 |   RefSCMatrix Kbend;
 | 
|---|
 | 629 |   if (decouple_bends_) {
 | 
|---|
 | 630 |       ExEnv::out0() << indent << "looking for bends" << endl;
 | 
|---|
 | 631 |       form_partial_K(bends_, molecule_, geom, 0.1, dnatom3_, matrixkit_,
 | 
|---|
 | 632 |                      projection, totally_symmetric_bend, Kbend, debug_);
 | 
|---|
 | 633 |       if (Kbend.nonnull()) n_total += Kbend.ncol();
 | 
|---|
 | 634 |     }
 | 
|---|
 | 635 | 
 | 
|---|
 | 636 |   if (decouple_bonds_ || decouple_bends_) {
 | 
|---|
 | 637 |       ExEnv::out0() << indent << "looking for remaining coordinates" << endl;
 | 
|---|
 | 638 |     }
 | 
|---|
 | 639 |   RefSCVector totally_symmetric_all;
 | 
|---|
 | 640 |   RefSCMatrix Kall;
 | 
|---|
 | 641 |   // I hope the IntCoorSet keeps the ordering
 | 
|---|
 | 642 |   form_partial_K(all_, molecule_, geom, 0.001, dnatom3_, matrixkit_,
 | 
|---|
 | 643 |                  projection, totally_symmetric_all, Kall, debug_);
 | 
|---|
 | 644 |   if (Kall.nonnull()) n_total += Kall.ncol();
 | 
|---|
 | 645 | 
 | 
|---|
 | 646 |   // This requires that all_ coordinates is made up of first bonds,
 | 
|---|
 | 647 |   // bends, and finally the rest of the coordinates.
 | 
|---|
 | 648 |   RefSCDimension dtot = new SCDimension(n_total);
 | 
|---|
 | 649 |   K = matrixkit_->matrix(dcoor, dtot);
 | 
|---|
 | 650 |   K.assign(0.0);
 | 
|---|
 | 651 |   int istart=0, jstart=0;
 | 
|---|
 | 652 |   if (Kbond.nonnull()) {
 | 
|---|
 | 653 |       if (debug_) Kbond.print("Kbond");
 | 
|---|
 | 654 |       K.assign_subblock(Kbond, 0, Kbond.nrow()-1, 0, Kbond.ncol()-1, 0, 0);
 | 
|---|
 | 655 |       istart += Kbond.nrow();
 | 
|---|
 | 656 |       jstart += Kbond.ncol();
 | 
|---|
 | 657 |     }
 | 
|---|
 | 658 |   if (Kbend.nonnull()) {
 | 
|---|
 | 659 |       if (debug_) Kbend.print("Kbend");
 | 
|---|
 | 660 |       K.assign_subblock(Kbend, istart, istart+Kbend.nrow()-1,
 | 
|---|
 | 661 |                         jstart, jstart+Kbend.ncol()-1, 0, 0);
 | 
|---|
 | 662 |       istart += Kbend.nrow();
 | 
|---|
 | 663 |       jstart += Kbend.ncol();
 | 
|---|
 | 664 |     }
 | 
|---|
 | 665 |   if (Kall.nonnull()) {
 | 
|---|
 | 666 |       if (debug_) Kall.print("Kall");
 | 
|---|
 | 667 |       K.assign_subblock(Kall, 0, Kall.nrow()-1,
 | 
|---|
 | 668 |                         jstart, jstart+Kall.ncol()-1, 0, 0);
 | 
|---|
 | 669 |     }
 | 
|---|
 | 670 |   if (debug_) K.print("K");
 | 
|---|
 | 671 | 
 | 
|---|
 | 672 |   is_totally_symmetric = new int[K.ncol()];
 | 
|---|
 | 673 |   j=0;
 | 
|---|
 | 674 |   if (Kbond.nonnull()) {
 | 
|---|
 | 675 |       for (i=0; i<Kbond.ncol(); i++,j++) {
 | 
|---|
 | 676 |           if (fabs(totally_symmetric_bond(i)) > ts_eps)
 | 
|---|
 | 677 |               is_totally_symmetric[j] = 1;
 | 
|---|
 | 678 |           else is_totally_symmetric[j] = 0;
 | 
|---|
 | 679 |         }
 | 
|---|
 | 680 |     }
 | 
|---|
 | 681 |   if (Kbend.nonnull()) {
 | 
|---|
 | 682 |       for (i=0; i<Kbend.ncol(); i++,j++) {
 | 
|---|
 | 683 |           if (fabs(totally_symmetric_bend(i)) > ts_eps)
 | 
|---|
 | 684 |               is_totally_symmetric[j] = 1;
 | 
|---|
 | 685 |           else is_totally_symmetric[j] = 0;
 | 
|---|
 | 686 |         }
 | 
|---|
 | 687 |     }
 | 
|---|
 | 688 |   if (Kall.nonnull()) {
 | 
|---|
 | 689 |       for (i=0; i<Kall.ncol(); i++,j++) {
 | 
|---|
 | 690 |           if (fabs(totally_symmetric_all(i)) > ts_eps)
 | 
|---|
 | 691 |               is_totally_symmetric[j] = 1;
 | 
|---|
 | 692 |           else is_totally_symmetric[j] = 0;
 | 
|---|
 | 693 |         }
 | 
|---|
 | 694 |     }
 | 
|---|
 | 695 | }
 | 
|---|
 | 696 | 
 | 
|---|
 | 697 | IntMolecularCoor::~IntMolecularCoor()
 | 
|---|
 | 698 | {
 | 
|---|
 | 699 | }
 | 
|---|
 | 700 | 
 | 
|---|
 | 701 | void
 | 
|---|
 | 702 | IntMolecularCoor::save_data_state(StateOut&s)
 | 
|---|
 | 703 | {
 | 
|---|
 | 704 |   MolecularCoor::save_data_state(s);
 | 
|---|
 | 705 | 
 | 
|---|
 | 706 |   SavableState::save_state(generator_.pointer(),s);
 | 
|---|
 | 707 | 
 | 
|---|
 | 708 |   s.put(decouple_bonds_);
 | 
|---|
 | 709 |   s.put(decouple_bends_);
 | 
|---|
 | 710 | 
 | 
|---|
 | 711 |   s.put(max_update_steps_);
 | 
|---|
 | 712 |   s.put(max_update_disp_);
 | 
|---|
 | 713 |   s.put(given_fixed_values_);
 | 
|---|
 | 714 | 
 | 
|---|
 | 715 |   s.put(form_print_simples_);
 | 
|---|
 | 716 |   s.put(form_print_variable_);
 | 
|---|
 | 717 |   s.put(form_print_constant_);
 | 
|---|
 | 718 |   s.put(form_print_molecule_);
 | 
|---|
 | 719 | 
 | 
|---|
 | 720 |   SavableState::save_state(dim_.pointer(),s);
 | 
|---|
 | 721 |   SavableState::save_state(dvc_.pointer(),s);
 | 
|---|
 | 722 | 
 | 
|---|
 | 723 |   SavableState::save_state(all_.pointer(),s);
 | 
|---|
 | 724 |   
 | 
|---|
 | 725 |   SavableState::save_state(variable_.pointer(),s);
 | 
|---|
 | 726 |   SavableState::save_state(constant_.pointer(),s);
 | 
|---|
 | 727 | 
 | 
|---|
 | 728 |   SavableState::save_state(fixed_.pointer(),s);
 | 
|---|
 | 729 |   SavableState::save_state(followed_.pointer(),s);
 | 
|---|
 | 730 |   SavableState::save_state(watched_.pointer(),s);
 | 
|---|
 | 731 | 
 | 
|---|
 | 732 |   SavableState::save_state(bonds_.pointer(),s);
 | 
|---|
 | 733 |   SavableState::save_state(bends_.pointer(),s);
 | 
|---|
 | 734 |   SavableState::save_state(tors_.pointer(),s);
 | 
|---|
 | 735 |   SavableState::save_state(outs_.pointer(),s);
 | 
|---|
 | 736 |   SavableState::save_state(extras_.pointer(),s);
 | 
|---|
 | 737 | 
 | 
|---|
 | 738 |   s.put(update_bmat_);
 | 
|---|
 | 739 |   s.put(only_totally_symmetric_);
 | 
|---|
 | 740 |   s.put(scale_bonds_);
 | 
|---|
 | 741 |   s.put(scale_bends_);
 | 
|---|
 | 742 |   s.put(scale_tors_);
 | 
|---|
 | 743 |   s.put(scale_outs_);
 | 
|---|
 | 744 |   s.put(simple_tolerance_);
 | 
|---|
 | 745 |   s.put(symmetry_tolerance_);
 | 
|---|
 | 746 |   s.put(coordinate_tolerance_);
 | 
|---|
 | 747 |   s.put(cartesian_tolerance_);
 | 
|---|
 | 748 | }
 | 
|---|
 | 749 | 
 | 
|---|
 | 750 | RefSCDimension
 | 
|---|
 | 751 | IntMolecularCoor::dim()
 | 
|---|
 | 752 | {
 | 
|---|
 | 753 |   return dim_;
 | 
|---|
 | 754 | }
 | 
|---|
 | 755 | 
 | 
|---|
 | 756 | int
 | 
|---|
 | 757 | IntMolecularCoor::all_to_cartesian(const Ref<Molecule> &mol,
 | 
|---|
 | 758 |                                    RefSCVector&new_internal)
 | 
|---|
 | 759 | {
 | 
|---|
 | 760 |   // get a reference to Molecule for convenience
 | 
|---|
 | 761 |   Molecule& molecule = *(mol.pointer());
 | 
|---|
 | 762 | 
 | 
|---|
 | 763 |   // don't bother updating the bmatrix when the error is less than this
 | 
|---|
 | 764 |   const double update_tolerance = 1.0e-6;
 | 
|---|
 | 765 | 
 | 
|---|
 | 766 |   // compute the internal coordinate displacements
 | 
|---|
 | 767 |   RefSCVector old_internal(dvc_,matrixkit_);
 | 
|---|
 | 768 | 
 | 
|---|
 | 769 |   RefSCMatrix internal_to_cart_disp;
 | 
|---|
 | 770 |   double maxabs_cart_diff = 0.0;
 | 
|---|
 | 771 |   for (int step = 0; step < max_update_steps_; step++) {
 | 
|---|
 | 772 |       // compute the old internal coordinates
 | 
|---|
 | 773 |       all_to_internal(mol, old_internal);
 | 
|---|
 | 774 | 
 | 
|---|
 | 775 |       if (debug_) {
 | 
|---|
 | 776 |           ExEnv::out0()
 | 
|---|
 | 777 |                << indent << "Coordinates on step " << step << ":" << endl;
 | 
|---|
 | 778 |           variable_->print_details(0,ExEnv::out0());
 | 
|---|
 | 779 |         }
 | 
|---|
 | 780 | 
 | 
|---|
 | 781 |       // the displacements
 | 
|---|
 | 782 |       RefSCVector displacement = new_internal - old_internal;
 | 
|---|
 | 783 |       if (debug_ && step == 0) {
 | 
|---|
 | 784 |           displacement.print("Step 0 Internal Coordinate Displacement");
 | 
|---|
 | 785 |         }
 | 
|---|
 | 786 | 
 | 
|---|
 | 787 |       if ((update_bmat_ && maxabs_cart_diff>update_tolerance)
 | 
|---|
 | 788 |           || internal_to_cart_disp.null()) {
 | 
|---|
 | 789 |           if (debug_) {
 | 
|---|
 | 790 |               ExEnv::out0() << indent << "updating bmatrix" << endl;
 | 
|---|
 | 791 |             }
 | 
|---|
 | 792 | 
 | 
|---|
 | 793 |           int i;
 | 
|---|
 | 794 |           RefSCMatrix bmat(dvc_,dnatom3_,matrixkit_);
 | 
|---|
 | 795 | 
 | 
|---|
 | 796 |           // form the set of all coordinates
 | 
|---|
 | 797 |           Ref<SetIntCoor> variable_and_constant = new SetIntCoor();
 | 
|---|
 | 798 |           variable_and_constant->add(variable_);
 | 
|---|
 | 799 |           variable_and_constant->add(constant_);
 | 
|---|
 | 800 | 
 | 
|---|
 | 801 |           // form the bmatrix
 | 
|---|
 | 802 |           variable_and_constant->bmat(mol,bmat);
 | 
|---|
 | 803 | 
 | 
|---|
 | 804 |           // Compute the singular value decomposition of B
 | 
|---|
 | 805 |           RefSCMatrix U(dvc_,dvc_,matrixkit_);
 | 
|---|
 | 806 |           RefSCMatrix V(dnatom3_,dnatom3_,matrixkit_);
 | 
|---|
 | 807 |           RefSCDimension min;
 | 
|---|
 | 808 |           if (dnatom3_.n()<dvc_.n()) min = dnatom3_;
 | 
|---|
 | 809 |           else min = dvc_;
 | 
|---|
 | 810 |           int nmin = min.n();
 | 
|---|
 | 811 |           RefDiagSCMatrix sigma(min,matrixkit_);
 | 
|---|
 | 812 |           bmat.svd(U,sigma,V);
 | 
|---|
 | 813 | 
 | 
|---|
 | 814 |           // compute the epsilon rank of B
 | 
|---|
 | 815 |           int rank = 0;
 | 
|---|
 | 816 |           for (i=0; i<nmin; i++) {
 | 
|---|
 | 817 |               if (fabs(sigma(i)) > 0.0001) rank++;
 | 
|---|
 | 818 |             }
 | 
|---|
 | 819 | 
 | 
|---|
 | 820 |           RefSCDimension drank = new SCDimension(rank);
 | 
|---|
 | 821 |           RefDiagSCMatrix sigma_i(drank,matrixkit_);
 | 
|---|
 | 822 |           for (i=0; i<rank; i++) {
 | 
|---|
 | 823 |               sigma_i(i) = 1.0/sigma(i);
 | 
|---|
 | 824 |             }
 | 
|---|
 | 825 |           RefSCMatrix Ur(dvc_, drank, matrixkit_);
 | 
|---|
 | 826 |           RefSCMatrix Vr(dnatom3_, drank, matrixkit_);
 | 
|---|
 | 827 |           Ur.assign_subblock(U,0, dvc_.n()-1, 0, drank.n()-1, 0, 0);
 | 
|---|
 | 828 |           Vr.assign_subblock(V,0, dnatom3_.n()-1, 0, drank.n()-1, 0, 0);
 | 
|---|
 | 829 |           internal_to_cart_disp = Vr * sigma_i * Ur.t();
 | 
|---|
 | 830 | 
 | 
|---|
 | 831 |         }
 | 
|---|
 | 832 | 
 | 
|---|
 | 833 |       // compute the cartesian displacements
 | 
|---|
 | 834 |       RefSCVector cartesian_displacement = internal_to_cart_disp*displacement;
 | 
|---|
 | 835 |       if (debug_ && step == 0) {
 | 
|---|
 | 836 |           internal_to_cart_disp.print("Internal to Cartesian Transform");
 | 
|---|
 | 837 |           cartesian_displacement.print("Step 0 Cartesian Displacment");
 | 
|---|
 | 838 |         }
 | 
|---|
 | 839 |       // update the geometry
 | 
|---|
 | 840 |       for (int i=0; i < dnatom3_.n(); i++) {
 | 
|---|
 | 841 | #if OLD_BMAT
 | 
|---|
 | 842 |           molecule.r(i/3,i%3) += cartesian_displacement(i) * 1.88972666;
 | 
|---|
 | 843 | #else        
 | 
|---|
 | 844 |           molecule.r(i/3,i%3) += cartesian_displacement(i);
 | 
|---|
 | 845 | #endif          
 | 
|---|
 | 846 |         }
 | 
|---|
 | 847 | 
 | 
|---|
 | 848 |       // fix symmetry breaking due to numerical round-off
 | 
|---|
 | 849 |       molecule.cleanup_molecule();
 | 
|---|
 | 850 | 
 | 
|---|
 | 851 |       // check for convergence
 | 
|---|
 | 852 |       Ref<SCElementMaxAbs> maxabs = new SCElementMaxAbs();
 | 
|---|
 | 853 |       Ref<SCElementOp> op = maxabs.pointer();
 | 
|---|
 | 854 |       cartesian_displacement.element_op(op);
 | 
|---|
 | 855 |       maxabs_cart_diff = maxabs->result();
 | 
|---|
 | 856 |       if (maxabs_cart_diff < cartesian_tolerance_) {
 | 
|---|
 | 857 | 
 | 
|---|
 | 858 |           constant_->update_values(mol);
 | 
|---|
 | 859 |           variable_->update_values(mol);
 | 
|---|
 | 860 | 
 | 
|---|
 | 861 |           return 0;
 | 
|---|
 | 862 |         }
 | 
|---|
 | 863 |     }
 | 
|---|
 | 864 | 
 | 
|---|
 | 865 |   ExEnv::err0() << indent
 | 
|---|
 | 866 |        << "WARNING: IntMolecularCoor::all_to_cartesian(RefSCVector&):"
 | 
|---|
 | 867 |        << " too many iterations in geometry update" << endl;
 | 
|---|
 | 868 | 
 | 
|---|
 | 869 |   new_internal.print("desired internal coordinates");
 | 
|---|
 | 870 |   (new_internal
 | 
|---|
 | 871 |    - old_internal).print("difference of desired and actual coordinates");
 | 
|---|
 | 872 | 
 | 
|---|
 | 873 |   return -1;
 | 
|---|
 | 874 | }
 | 
|---|
 | 875 | 
 | 
|---|
 | 876 | int
 | 
|---|
 | 877 | IntMolecularCoor::to_cartesian(const Ref<Molecule> &mol,
 | 
|---|
 | 878 |                                const RefSCVector&new_internal)
 | 
|---|
 | 879 | {
 | 
|---|
 | 880 |   if (new_internal.dim().n() != dim_.n()
 | 
|---|
 | 881 |       || dvc_.n() != variable_->n() + constant_->n()
 | 
|---|
 | 882 |       || new_internal.dim().n() != variable_->n()) {
 | 
|---|
 | 883 |       throw ProgrammingError("to_cartesian: internal error in dim",
 | 
|---|
 | 884 |                              __FILE__, __LINE__, class_desc());
 | 
|---|
 | 885 |     }
 | 
|---|
 | 886 | 
 | 
|---|
 | 887 |   RefSCVector all_internal(dvc_,matrixkit_);
 | 
|---|
 | 888 | 
 | 
|---|
 | 889 |   int i,j;
 | 
|---|
 | 890 | 
 | 
|---|
 | 891 |   for (i=0; i<variable_->n(); i++) all_internal(i) = new_internal(i);
 | 
|---|
 | 892 |   for (j=0; j<constant_->n(); i++,j++) {
 | 
|---|
 | 893 |       all_internal(i) = constant_->coor(j)->value();
 | 
|---|
 | 894 |     }
 | 
|---|
 | 895 | 
 | 
|---|
 | 896 |   int ret = all_to_cartesian(mol, all_internal);
 | 
|---|
 | 897 | 
 | 
|---|
 | 898 |   if (watched_.nonnull()) {
 | 
|---|
 | 899 |       ExEnv::out0() << endl
 | 
|---|
 | 900 |            << indent << "Watched coordinate(s):\n" << incindent;
 | 
|---|
 | 901 |       watched_->update_values(mol);
 | 
|---|
 | 902 |       watched_->print_details(mol,ExEnv::out0());
 | 
|---|
 | 903 |       ExEnv::out0() << decindent;
 | 
|---|
 | 904 |     }
 | 
|---|
 | 905 |   
 | 
|---|
 | 906 |   return ret;
 | 
|---|
 | 907 | }
 | 
|---|
 | 908 | 
 | 
|---|
 | 909 | int
 | 
|---|
 | 910 | IntMolecularCoor::all_to_internal(const Ref<Molecule> &mol,RefSCVector&internal)
 | 
|---|
 | 911 | {
 | 
|---|
 | 912 |   if (internal.dim().n() != dvc_.n()
 | 
|---|
 | 913 |       || dim_.n() != variable_->n()
 | 
|---|
 | 914 |       || dvc_.n() != variable_->n() + constant_->n()) {
 | 
|---|
 | 915 |       throw ProgrammingError("all_to_internal: internal error in dim",
 | 
|---|
 | 916 |                              __FILE__, __LINE__, class_desc());
 | 
|---|
 | 917 |     }
 | 
|---|
 | 918 | 
 | 
|---|
 | 919 |   variable_->update_values(mol);
 | 
|---|
 | 920 |   constant_->update_values(mol);
 | 
|---|
 | 921 |    
 | 
|---|
 | 922 |   int n = dim_.n();
 | 
|---|
 | 923 |   int i;
 | 
|---|
 | 924 |   for (i=0; i<n; i++) {
 | 
|---|
 | 925 |       internal(i) = variable_->coor(i)->value();
 | 
|---|
 | 926 |     }
 | 
|---|
 | 927 |   n = dvc_.n();
 | 
|---|
 | 928 |   for (int j=0; i<n; i++,j++) {
 | 
|---|
 | 929 |       internal(i) = constant_->coor(j)->value();
 | 
|---|
 | 930 |     }
 | 
|---|
 | 931 | 
 | 
|---|
 | 932 |   return 0;
 | 
|---|
 | 933 | }
 | 
|---|
 | 934 | 
 | 
|---|
 | 935 | int
 | 
|---|
 | 936 | IntMolecularCoor::to_internal(RefSCVector&internal)
 | 
|---|
 | 937 | {
 | 
|---|
 | 938 |   if (internal.dim().n() != dim_.n()
 | 
|---|
 | 939 |       || dim_.n() != variable_->n()) {
 | 
|---|
 | 940 |       throw ProgrammingError("to_internal: internal error in dim",
 | 
|---|
 | 941 |                              __FILE__, __LINE__, class_desc());
 | 
|---|
 | 942 |     }
 | 
|---|
 | 943 | 
 | 
|---|
 | 944 |   variable_->update_values(molecule_);
 | 
|---|
 | 945 |    
 | 
|---|
 | 946 |   int n = dim_.n();
 | 
|---|
 | 947 |   for (int i=0; i<n; i++) {
 | 
|---|
 | 948 |       internal(i) = variable_->coor(i)->value();
 | 
|---|
 | 949 |     }
 | 
|---|
 | 950 | 
 | 
|---|
 | 951 |   return 0;
 | 
|---|
 | 952 | }
 | 
|---|
 | 953 | 
 | 
|---|
 | 954 | int
 | 
|---|
 | 955 | IntMolecularCoor::to_cartesian(RefSCVector&gradient,RefSCVector&internal)
 | 
|---|
 | 956 | {
 | 
|---|
 | 957 |   RefSCMatrix bmat(dim_,gradient.dim(),matrixkit_);
 | 
|---|
 | 958 |   variable_->bmat(molecule_,bmat);
 | 
|---|
 | 959 | 
 | 
|---|
 | 960 |   gradient = bmat.t() * internal;
 | 
|---|
 | 961 |   
 | 
|---|
 | 962 |   return 0;
 | 
|---|
 | 963 | }
 | 
|---|
 | 964 | 
 | 
|---|
 | 965 | // converts the gradient in cartesian coordinates to internal coordinates
 | 
|---|
 | 966 | int
 | 
|---|
 | 967 | IntMolecularCoor::to_internal(RefSCVector&internal,RefSCVector&gradient)
 | 
|---|
 | 968 | {
 | 
|---|
 | 969 |   RefSCMatrix bmat(dvc_,gradient.dim(),matrixkit_);
 | 
|---|
 | 970 |   RefSymmSCMatrix bmbt(dvc_,matrixkit_);
 | 
|---|
 | 971 | 
 | 
|---|
 | 972 |   Ref<SetIntCoor> variable_and_constant = new SetIntCoor();
 | 
|---|
 | 973 |   variable_and_constant->add(variable_);
 | 
|---|
 | 974 |   variable_and_constant->add(constant_);
 | 
|---|
 | 975 | 
 | 
|---|
 | 976 |   // form the bmatrix
 | 
|---|
 | 977 |   variable_and_constant->bmat(molecule_,bmat);
 | 
|---|
 | 978 |   
 | 
|---|
 | 979 |   // form the inverse of bmatrix * bmatrix_t
 | 
|---|
 | 980 |   bmbt.assign(0.0);
 | 
|---|
 | 981 |   bmbt.accumulate_symmetric_product(bmat);
 | 
|---|
 | 982 |   bmbt = bmbt.gi();
 | 
|---|
 | 983 | 
 | 
|---|
 | 984 | #if OLD_BMAT  
 | 
|---|
 | 985 |   RefSCVector all_internal = bmbt*bmat*(gradient*8.2388575);
 | 
|---|
 | 986 | #else
 | 
|---|
 | 987 |   RefSCVector all_internal = bmbt*bmat*gradient;
 | 
|---|
 | 988 | #endif  
 | 
|---|
 | 989 | 
 | 
|---|
 | 990 |   // put the variable coordinate gradients into internal
 | 
|---|
 | 991 |   int n = variable_->n();
 | 
|---|
 | 992 |   for (int i=0; i<n; i++) {
 | 
|---|
 | 993 |       internal.set_element(i,all_internal.get_element(i));
 | 
|---|
 | 994 |     }
 | 
|---|
 | 995 | 
 | 
|---|
 | 996 |   return 0;
 | 
|---|
 | 997 | }
 | 
|---|
 | 998 | 
 | 
|---|
 | 999 | int
 | 
|---|
 | 1000 | IntMolecularCoor::to_cartesian(RefSymmSCMatrix&cart,RefSymmSCMatrix&internal)
 | 
|---|
 | 1001 | {
 | 
|---|
 | 1002 |   cart.assign(0.0);
 | 
|---|
 | 1003 |   RefSCMatrix bmat(dim_,cart.dim(),matrixkit_);
 | 
|---|
 | 1004 |   variable_->bmat(molecule_,bmat);
 | 
|---|
 | 1005 |   cart.accumulate_transform(bmat.t(),internal);
 | 
|---|
 | 1006 |   return 0;
 | 
|---|
 | 1007 | }
 | 
|---|
 | 1008 | 
 | 
|---|
 | 1009 | int
 | 
|---|
 | 1010 | IntMolecularCoor::to_internal(RefSymmSCMatrix&internal,RefSymmSCMatrix&cart)
 | 
|---|
 | 1011 | {
 | 
|---|
 | 1012 |   // form bmat
 | 
|---|
 | 1013 |   RefSCMatrix bmat(dim_,cart.dim(),matrixkit_);
 | 
|---|
 | 1014 |   variable_->bmat(molecule_,bmat);
 | 
|---|
 | 1015 |   // and (B*B+)^-1
 | 
|---|
 | 1016 |   RefSymmSCMatrix bmbt(dim_,matrixkit_);
 | 
|---|
 | 1017 |   bmbt.assign(0.0);
 | 
|---|
 | 1018 |   bmbt.accumulate_symmetric_product(bmat);
 | 
|---|
 | 1019 |   bmbt = bmbt.gi();
 | 
|---|
 | 1020 | 
 | 
|---|
 | 1021 |   internal.assign(0.0);
 | 
|---|
 | 1022 |   internal.accumulate_transform(bmbt*bmat,cart);
 | 
|---|
 | 1023 |   return 0;
 | 
|---|
 | 1024 | }
 | 
|---|
 | 1025 | 
 | 
|---|
 | 1026 | int
 | 
|---|
 | 1027 | IntMolecularCoor::nconstrained()
 | 
|---|
 | 1028 | {
 | 
|---|
 | 1029 |   return fixed_->n();
 | 
|---|
 | 1030 | }
 | 
|---|
 | 1031 | 
 | 
|---|
 | 1032 | void
 | 
|---|
 | 1033 | IntMolecularCoor::print(ostream& os) const
 | 
|---|
 | 1034 | {
 | 
|---|
 | 1035 |   all_->update_values(molecule_);
 | 
|---|
 | 1036 | 
 | 
|---|
 | 1037 |   os << indent << "IntMolecularCoor Parameters:\n" << incindent
 | 
|---|
 | 1038 |      << indent << "update_bmat = " << (update_bmat_?"yes":"no") << endl
 | 
|---|
 | 1039 |      << indent << "scale_bonds = " << scale_bonds_ << endl
 | 
|---|
 | 1040 |      << indent << "scale_bends = " << scale_bends_ << endl
 | 
|---|
 | 1041 |      << indent << "scale_tors = " << scale_tors_ << endl
 | 
|---|
 | 1042 |      << indent << "scale_outs = " << scale_outs_ << endl
 | 
|---|
 | 1043 |      << indent << scprintf("symmetry_tolerance = %e\n",symmetry_tolerance_)
 | 
|---|
 | 1044 |      << indent << scprintf("simple_tolerance = %e\n",simple_tolerance_)
 | 
|---|
 | 1045 |      << indent << scprintf("coordinate_tolerance = %e\n",coordinate_tolerance_)
 | 
|---|
 | 1046 |      << indent << "have_fixed_values = " << given_fixed_values_ << endl
 | 
|---|
 | 1047 |      << indent << "max_update_steps = " << max_update_steps_ << endl
 | 
|---|
 | 1048 |      << indent << scprintf("max_update_disp = %f\n",max_update_disp_)
 | 
|---|
 | 1049 |      << indent << "have_fixed_values = " << given_fixed_values_ << endl
 | 
|---|
 | 1050 |      << decindent << endl;
 | 
|---|
 | 1051 | 
 | 
|---|
 | 1052 |   molecule_->print(os);
 | 
|---|
 | 1053 |   os << endl;
 | 
|---|
 | 1054 | 
 | 
|---|
 | 1055 |   print_simples(os);
 | 
|---|
 | 1056 |   os << endl;
 | 
|---|
 | 1057 | 
 | 
|---|
 | 1058 |   if (form_print_variable_) {
 | 
|---|
 | 1059 |       print_variable(os);
 | 
|---|
 | 1060 |       os << endl;
 | 
|---|
 | 1061 |     }
 | 
|---|
 | 1062 | 
 | 
|---|
 | 1063 |   if (form_print_constant_) {
 | 
|---|
 | 1064 |       print_constant(os);
 | 
|---|
 | 1065 |       os << endl;
 | 
|---|
 | 1066 |     }
 | 
|---|
 | 1067 | }
 | 
|---|
 | 1068 | 
 | 
|---|
 | 1069 | void
 | 
|---|
 | 1070 | IntMolecularCoor::print_simples(ostream& os) const
 | 
|---|
 | 1071 | {
 | 
|---|
 | 1072 |   if (matrixkit()->messagegrp()->me()==0) {
 | 
|---|
 | 1073 |     if (bonds_->n()) {
 | 
|---|
 | 1074 |       os << indent << "Bonds:\n" << incindent;
 | 
|---|
 | 1075 |       bonds_->print_details(molecule_,os);
 | 
|---|
 | 1076 |       os << decindent;
 | 
|---|
 | 1077 |     }
 | 
|---|
 | 1078 |     if (bends_->n()) {
 | 
|---|
 | 1079 |       os << indent << "Bends:\n" << incindent;
 | 
|---|
 | 1080 |       bends_->print_details(molecule_,os);
 | 
|---|
 | 1081 |       os << decindent;
 | 
|---|
 | 1082 |     }
 | 
|---|
 | 1083 |     if (tors_->n()) {
 | 
|---|
 | 1084 |       os << indent << "Torsions:\n" << incindent;
 | 
|---|
 | 1085 |       tors_->print_details(molecule_,os);
 | 
|---|
 | 1086 |       os << decindent;
 | 
|---|
 | 1087 |     }
 | 
|---|
 | 1088 |     if (outs_->n()) {
 | 
|---|
 | 1089 |       os << indent << "Out of Plane:\n" << incindent;
 | 
|---|
 | 1090 |       outs_->print_details(molecule_,os);
 | 
|---|
 | 1091 |       os << decindent;
 | 
|---|
 | 1092 |     }
 | 
|---|
 | 1093 |     if (extras_->n()) {
 | 
|---|
 | 1094 |       os << indent << "Extras:\n" << incindent;
 | 
|---|
 | 1095 |       extras_->print_details(molecule_,os);
 | 
|---|
 | 1096 |       os << decindent;
 | 
|---|
 | 1097 |     }
 | 
|---|
 | 1098 |     if (fixed_->n()) {
 | 
|---|
 | 1099 |       os << indent << "Fixed:\n" << incindent;
 | 
|---|
 | 1100 |       fixed_->print_details(molecule_,os);
 | 
|---|
 | 1101 |       os << decindent;
 | 
|---|
 | 1102 |     }
 | 
|---|
 | 1103 |     if (followed_.nonnull()) {
 | 
|---|
 | 1104 |       os << indent << "Followed:\n" << incindent;
 | 
|---|
 | 1105 |       followed_->print_details(molecule_,os);
 | 
|---|
 | 1106 |       os << decindent;
 | 
|---|
 | 1107 |     }
 | 
|---|
 | 1108 |     if (watched_.nonnull()) {
 | 
|---|
 | 1109 |       os << indent << "Watched:\n" << incindent;
 | 
|---|
 | 1110 |       watched_->print_details(molecule_,os);
 | 
|---|
 | 1111 |       os << decindent;
 | 
|---|
 | 1112 |     }
 | 
|---|
 | 1113 |   }
 | 
|---|
 | 1114 | }
 | 
|---|
 | 1115 | 
 | 
|---|
 | 1116 | void
 | 
|---|
 | 1117 | IntMolecularCoor::print_variable(ostream& os) const
 | 
|---|
 | 1118 | {
 | 
|---|
 | 1119 |   if (variable_->n() == 0) return;
 | 
|---|
 | 1120 |   os << indent
 | 
|---|
 | 1121 |      << "Variable Coordinates:" << endl;
 | 
|---|
 | 1122 |   os << incindent;
 | 
|---|
 | 1123 |   variable_->print_details(molecule_,os);
 | 
|---|
 | 1124 |   os << decindent;
 | 
|---|
 | 1125 | }
 | 
|---|
 | 1126 | 
 | 
|---|
 | 1127 | void
 | 
|---|
 | 1128 | IntMolecularCoor::print_constant(ostream& os) const
 | 
|---|
 | 1129 | {
 | 
|---|
 | 1130 |   if (constant_->n() == 0) return;
 | 
|---|
 | 1131 |   os << indent
 | 
|---|
 | 1132 |      << "Constant Coordinates:" << endl;
 | 
|---|
 | 1133 |   os << incindent;
 | 
|---|
 | 1134 |   constant_->print_details(molecule_,os);
 | 
|---|
 | 1135 |   os << decindent;
 | 
|---|
 | 1136 | }
 | 
|---|
 | 1137 | 
 | 
|---|
 | 1138 | /////////////////////////////////////////////////////////////////////////////
 | 
|---|
 | 1139 | 
 | 
|---|
 | 1140 | // Local Variables:
 | 
|---|
 | 1141 | // mode: c++
 | 
|---|
 | 1142 | // c-file-style: "CLJ"
 | 
|---|
 | 1143 | // End:
 | 
|---|