~ubuntu-branches/ubuntu/oneiric/mpqc/oneiric

« back to all changes in this revision

Viewing changes to src/lib/chemistry/molecule/coor.cc

  • Committer: Bazaar Package Importer
  • Author(s): Michael Banck
  • Date: 2005-11-27 11:41:49 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051127114149-zgz9r3gk50w8ww2q
Tags: 2.3.0-1
* New upstream release.
* debian/rules (SONAME): Activate awk snippet for automatic so-name
  detection again, resulting in a bump to `7' and making a `c2a' for
  the C++ allocator change unnecessary; closes: #339232.
* debian/patches/00list (08_gcc-4.0_fixes): Removed, no longer needed.
* debian/rules (test): Remove workarounds, do not abort build if tests
  fail.
* debian/ref: Removed.
* debian/control.in (libsc): Added Conflict against libsc6c2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
 
32
32
#include <set>
33
33
 
34
 
#include <math.h>
 
34
#include <util/misc/math.h>
35
35
 
 
36
#include <util/class/scexception.h>
36
37
#include <util/misc/formio.h>
37
38
#include <util/state/stateio.h>
38
39
#include <math/scmat/matrix.h>
50
51
// members of IntCoor
51
52
 
52
53
double IntCoor::bohr_conv = 0.52917706;
53
 
double IntCoor::radian_conv = 180.0/3.14159265358979323846;
 
54
double IntCoor::radian_conv = 180.0/M_PI;
54
55
 
55
56
static ClassDesc IntCoor_cd(
56
57
  typeid(IntCoor),"IntCoor",1,"public SavableState",
75
76
  label_ = keyval->pcharvalue("label");
76
77
  value_ = keyval->doublevalue("value");
77
78
 
78
 
  char* unit = keyval->pcharvalue("unit");
79
 
  if (unit) {
80
 
      if (!strcmp(unit, "bohr")) {
 
79
  if (keyval->exists("unit")) {
 
80
      std::string unit(keyval->stringvalue("unit"));
 
81
      if (unit == "bohr") {
81
82
        }
82
 
      else if (!strcmp(unit, "angstrom")) {
 
83
      else if (unit == "angstrom") {
83
84
          value_ /= bohr_conv;
84
85
        }
85
 
      else if (!strcmp(unit, "radian")) {
 
86
      else if (unit == "radian") {
86
87
        }
87
 
      else if (!strcmp(unit, "degree")) {
 
88
      else if (unit == "degree") {
88
89
          value_ *= M_PI/180.0;
89
90
        }
90
91
      else {
91
 
          ExEnv::err0() << indent
92
 
               << "IntCoor::IntCoor(KeyVal): unknown unit = \""
93
 
               << unit << "\"\n";
94
 
          abort();
 
92
        throw InputError("unrecognized unit value",
 
93
                         __FILE__, __LINE__,
 
94
                         "unit", unit.c_str(),
 
95
                         this->class_desc());
95
96
        }
96
 
      delete[] unit;
97
97
    }
98
98
}
99
99
 
176
176
  Ref<IntCoorGen> gen; gen << keyval->describedclassvalue("generator");
177
177
 
178
178
  if (gen.null() && !n) {
179
 
      ExEnv::err0() << indent << "SetIntCoor::SetIntCoor: bad input\n";
180
 
      abort();
 
179
      throw InputError("not a vector and no generator given",
 
180
                       __FILE__, __LINE__,
 
181
                       0, 0,
 
182
                       class_desc());
181
183
    }
182
184
 
183
185
  if (gen.nonnull()) {
385
387
  static const char* coef = "coef";
386
388
  int n = keyval->count(coor);
387
389
  int ncoef = keyval->count(coef);
388
 
  if (n != ncoef || !n) {
389
 
      ExEnv::err0() << indent << "SumIntCoor::SumIntCoor: bad input\n";
390
 
      abort();
 
390
  if (n != ncoef) {
 
391
    throw InputError("coor and coef do not have the same dimension",
 
392
                     __FILE__, __LINE__, 0, 0, class_desc());
 
393
    }
 
394
  if (!n) {
 
395
    throw InputError("coor and coef are zero length",
 
396
                     __FILE__, __LINE__, 0, 0, class_desc());
391
397
    }
392
398
 
393
399
  for (int i=0; i<n; i++) {
579
585
  molecule_ << keyval->describedclassvalue("molecule");
580
586
 
581
587
  if (molecule_.null()) {
582
 
      ExEnv::err0() << indent
583
 
           << "MolecularCoor(const Ref<KeyVal>&keyval): molecule not found\n";
584
 
      abort();
 
588
      throw InputError("missing input", __FILE__, __LINE__,
 
589
                       "molecule", 0, class_desc());
585
590
    }
586
591
 
587
592
  debug_ = keyval->intvalue("debug");
593
598
 
594
599
  if (dnatom3_.null()) dnatom3_ = new SCDimension(3*molecule_->natom());
595
600
  else if (dnatom3_->n() != 3 * molecule_->natom()) {
596
 
      ExEnv::err0() << indent << "MolecularCoor(KeyVal): bad dnatom3 value\n";
597
 
      abort();
 
601
    throw InputError("natom3 given but not consistent with molecule",
 
602
                     __FILE__, __LINE__, "natom3", 0, class_desc());
598
603
    }
599
604
}
600
605
 
699
704
      for (int i=0; i<nextra_bonds_*2; i++) {
700
705
          extra_bonds_[i] = keyval->intvalue("extra_bonds",i);
701
706
          if (keyval->error() != KeyVal::OK) {
702
 
              ExEnv::err0() << indent
703
 
                   << "IntCoorGen:: keyval CTOR: problem reading "
704
 
                   << "\"extra_bonds:" << i << "\"\n";
705
 
              abort();
 
707
            throw InputError("missing an expected integer value",
 
708
                             __FILE__, __LINE__, "extra_bonds", 0,
 
709
                             class_desc());
706
710
            }
707
711
        }
708
712
    }
853
857
          }
854
858
        }
855
859
      if (nearest_bound == -1) {
856
 
        ExEnv::out0() << indent
857
 
             << "ERROR: impossible error generating coordinates"
858
 
             << endl;
859
 
        abort();
 
860
        throw ProgrammingError("impossible error generating coordinates",
 
861
                               __FILE__, __LINE__);
860
862
        }
861
863
      // add all bound atoms within a certain distance of nearest_unbound
862
864
      // --- should really do this for all atoms that nearest_unbound