MPQC 2.3.1

- Main Page
- Related Pages
- Classes
- Files

- File List

molecule.h

    00001 //
    00002 // molecule.h
    00003 //
    00004 // Copyright (C) 1996 Limit Point Systems, Inc.
    00005 //
    00006 // Author: Curtis Janssen <cljanss@limitpt.com>
    00007 // Maintainer: LPS
    00008 //
    00009 // This file is part of the SC Toolkit.
    00010 //
    00011 // The SC Toolkit is free software; you can redistribute it and/or modify
    00012 // it under the terms of the GNU Library General Public License as published by
    00013 // the Free Software Foundation; either version 2, or (at your option)
    00014 // any later version.
    00015 //
    00016 // The SC Toolkit is distributed in the hope that it will be useful,
    00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00019 // GNU Library General Public License for more details.
    00020 //
    00021 // You should have received a copy of the GNU Library General Public License
    00022 // along with the SC Toolkit; see the file COPYING.LIB.  If not, write to
    00023 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
    00024 //
    00025 // The U.S. Government is granted a limited license as per AL 91-7.
    00026 //
    00027
    00028 #ifndef _chemistry_molecule_molecule_h
    00029 #define _chemistry_molecule_molecule_h
    00030
    00031 #ifdef __GNUC__
    00032 #pragma interface
    00033 #endif
    00034
    00035 #include <stdio.h>
    00036 #include <iostream>
    00037 #include <util/class/class.h>
    00038 #include <util/state/state.h>
    00039 #include <util/keyval/keyval.h>
    00040 #include <util/misc/units.h>
    00041 #include <math/symmetry/pointgrp.h>
    00042 #include <math/scmat/vector3.h>
    00043 #include <math/scmat/matrix.h>
    00044 #include <chemistry/molecule/atominfo.h>
    00045
    00046 namespace sc {
    00047
    00127 class Molecule: public SavableState
    00128 {
    00129   protected:
    00130     int natoms_;
    00131     Ref<AtomInfo> atominfo_;
    00132     Ref<PointGroup> pg_;
    00133     Ref<Units> geometry_units_;
    00134     double **r_;
    00135     int *Z_;
    00136     double *charges_;
    00137
    00138     // symmetry equiv info
    00139     int nuniq_;
    00140     int *nequiv_;
    00141     int **equiv_;
    00142     int *atom_to_uniq_;
    00143     void init_symmetry_info(double tol=0.5);
    00144     void clear_symmetry_info();
    00145
    00146     // these are optional
    00147     double *mass_;
    00148     char **labels_;
    00149
    00150     // The Z that represents a "Q" type atom.
    00151     int q_Z_;
    00152
    00153     // If true, include the q terms in the charge and efield routines
    00154     bool include_q_;
    00155
    00156     // If true, include the coupling between q-q pairs when
    00157     // computing nuclear repulsion energy and gradients.
    00158     bool include_qq_;
    00159
    00160     // These vectors contain the atom indices of atoms that are not type
    00161     // "Q" and those that are.
    00162     std::vector<int> q_atoms_;
    00163     std::vector<int> non_q_atoms_;
    00164
    00165     void clear();
    00166
    00167     // Throw an exception if an atom is duplicated.  The
    00168     // atoms in the range [begin, natom_) are checked.
    00169     void throw_if_atom_duplicated(int begin=0, double tol = 1e-3);
    00170   public:
    00171     Molecule();
    00172     Molecule(const Molecule&);
    00173     Molecule(StateIn&);
    00269     Molecule(const Ref<KeyVal>&input);
    00270
    00271     virtual ~Molecule();
    00272
    00273     Molecule& operator=(const Molecule&);
    00274
    00276     void add_atom(int Z,double x,double y,double z,
    00277                   const char * = 0, double mass = 0.0,
    00278                   int have_charge = 0, double charge = 0.0);
    00279
    00281     virtual void print(std::ostream& =ExEnv::out0()) const;
    00282     virtual void print_parsedkeyval(std::ostream& =ExEnv::out0(),
    00283                                     int print_pg = 1,
    00284                                     int print_unit = 1,
    00285                                     int number_atoms = 1) const;
    00286
    00288     int natom() const { return natoms_; }
    00289
    00290     int Z(int atom) const { return Z_[atom]; }
    00291     double &r(int atom, int xyz) { return r_[atom][xyz]; }
    00292     const double &r(int atom, int xyz) const { return r_[atom][xyz]; }
    00293     double *r(int atom) { return r_[atom]; }
    00294     const double *r(int atom) const { return r_[atom]; }
    00295     double mass(int atom) const;
    00298     const char *label(int atom) const;
    00299
    00302     int atom_at_position(double *, double tol = 0.05) const;
    00303
    00306     int atom_label_to_index(const char *label) const;
    00307
    00311     double *charges() const;
    00312
    00314     double charge(int iatom) const;
    00315
    00317     double nuclear_charge() const;
    00318
    00320     void set_point_group(const Ref<PointGroup>&, double tol=1.0e-7);
    00322     Ref<PointGroup> point_group() const;
    00323
    00327     Ref<PointGroup> highest_point_group(double tol = 1.0e-8) const;
    00328
    00331     int is_axis(SCVector3 &origin,
    00332                 SCVector3 &udirection, int order, double tol=1.0e-8) const;
    00333
    00336     int is_plane(SCVector3 &origin, SCVector3 &uperp, double tol=1.0e-8) const;
    00337
    00339     int has_inversion(SCVector3 &origin, double tol = 1.0e-8) const;
    00340
    00342     int is_linear(double tolerance = 1.0e-5) const;
    00344     int is_planar(double tolerance = 1.0e-5) const;
    00347     void is_linear_planar(int&linear,int&planar,double tol = 1.0e-5) const;
    00348
    00351     SCVector3 center_of_mass() const;
    00352
    00355     SCVector3 center_of_charge() const;
    00356
    00358     double nuclear_repulsion_energy();
    00359
    00362     void nuclear_repulsion_1der(int center, double xyz[3]);
    00363
    00365     void nuclear_efield(const double *position, double* efield);
    00366
    00369     void nuclear_charge_efield(const double *charges,
    00370                                const double *position, double* efield);
    00371
    00377     void symmetrize(double tol = 0.5);
    00378
    00380     void symmetrize(const Ref<PointGroup> &pg, double tol = 0.5);
    00381
    00385     void cleanup_molecule(double tol = 0.1);
    00386
    00387     void translate(const double *r);
    00388     void move_to_com();
    00389     void transform_to_principal_axes(int trans_frame=1);
    00390     void transform_to_symmetry_frame();
    00391     void print_pdb(std::ostream& =ExEnv::out0(), char *title =0) const;
    00392
    00393     void read_pdb(const char *filename);
    00394
    00397     void principal_moments_of_inertia(double *evals, double **evecs=0) const;
    00398
    00400     int nunique() const { return nuniq_; }
    00402     int unique(int iuniq) const { return equiv_[iuniq][0]; }
    00404     int nequivalent(int iuniq) const { return nequiv_[iuniq]; }
    00406     int equivalent(int iuniq, int j) const { return equiv_[iuniq][j]; }
    00409     int atom_to_unique(int iatom) const { return atom_to_uniq_[iatom]; }
    00412     int atom_to_unique_offset(int iatom) const;
    00413
    00415     int n_core_electrons();
    00416
    00418     int max_z();
    00419
    00421     Ref<AtomInfo> atominfo() const { return atominfo_; }
    00422
    00424     std::string atom_name(int iatom) const;
    00425
    00427     std::string atom_symbol(int iatom) const;
    00428
    00431     void set_include_q(bool iq) { include_q_ = iq; }
    00433     bool include_q() const { return include_q_; }
    00434
    00437     void set_include_qq(bool iqq) { include_qq_ = iqq; }
    00439     bool include_qq() const { return include_qq_; }
    00440
    00442     int n_q_atom() const { return q_atoms_.size(); }
    00444     int q_atom(int i) const { return q_atoms_[i]; }
    00445
    00447     int n_non_q_atom() const { return non_q_atoms_.size(); }
    00449     int non_q_atom(int i) const { return non_q_atoms_[i]; }
    00450
    00451     void save_data_state(StateOut&);
    00452 };
    00453
    00454 }
    00455
    00456 #endif
    00457
    00458 // Local Variables:
    00459 // mode: c++
    00460 // c-file-style: "CLJ"
    00461 // End: