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   public:
00167     Molecule();
00168     Molecule(const Molecule&);
00169     Molecule(StateIn&);
00171     Molecule(const Ref<KeyVal>&input);
00172 
00173     virtual ~Molecule();
00174 
00175     Molecule& operator=(const Molecule&);
00176 
00178     void add_atom(int Z,double x,double y,double z,
00179                   const char * = 0, double mass = 0.0,
00180                   int have_charge = 0, double charge = 0.0);
00181 
00183     virtual void print(std::ostream& =ExEnv::out0()) const;
00184     virtual void print_parsedkeyval(std::ostream& =ExEnv::out0(),
00185                                     int print_pg = 1,
00186                                     int print_unit = 1,
00187                                     int number_atoms = 1) const;
00188 
00190     int natom() const { return natoms_; }
00191 
00192     int Z(int atom) const { return Z_[atom]; }
00193     double &r(int atom, int xyz) { return r_[atom][xyz]; }
00194     const double &r(int atom, int xyz) const { return r_[atom][xyz]; }
00195     double *r(int atom) { return r_[atom]; }
00196     const double *r(int atom) const { return r_[atom]; }
00197     double mass(int atom) const;
00200     const char *label(int atom) const;
00201 
00204     int atom_at_position(double *, double tol = 0.05) const;
00205 
00208     int atom_label_to_index(const char *label) const;
00209 
00213     double *charges() const;
00214 
00216     double charge(int iatom) const;
00217 
00219     double nuclear_charge() const;
00220 
00222     void set_point_group(const Ref<PointGroup>&, double tol=1.0e-7);
00224     Ref<PointGroup> point_group() const;
00225 
00229     Ref<PointGroup> highest_point_group(double tol = 1.0e-8) const;
00230 
00233     int is_axis(SCVector3 &origin,
00234                 SCVector3 &udirection, int order, double tol=1.0e-8) const;
00235 
00238     int is_plane(SCVector3 &origin, SCVector3 &uperp, double tol=1.0e-8) const;
00239 
00241     int has_inversion(SCVector3 &origin, double tol = 1.0e-8) const;
00242 
00244     int is_linear(double tolerance = 1.0e-5) const;
00246     int is_planar(double tolerance = 1.0e-5) const;
00249     void is_linear_planar(int&linear,int&planar,double tol = 1.0e-5) const;
00250 
00253     SCVector3 center_of_mass() const;
00254 
00256     double nuclear_repulsion_energy();
00257     
00260     void nuclear_repulsion_1der(int center, double xyz[3]);
00261 
00263     void nuclear_efield(const double *position, double* efield);
00264 
00267     void nuclear_charge_efield(const double *charges,
00268                                const double *position, double* efield);
00269     
00275     void symmetrize(double tol = 0.5);
00276 
00278     void symmetrize(const Ref<PointGroup> &pg, double tol = 0.5);
00279 
00283     void cleanup_molecule(double tol = 0.1);
00284 
00285     void translate(const double *r);
00286     void move_to_com();
00287     void transform_to_principal_axes(int trans_frame=1);
00288     void transform_to_symmetry_frame();
00289     void print_pdb(std::ostream& =ExEnv::out0(), char *title =0) const;
00290 
00291     void read_pdb(const char *filename);
00292 
00295     void principal_moments_of_inertia(double *evals, double **evecs=0) const;
00296 
00298     int nunique() const { return nuniq_; }
00300     int unique(int iuniq) const { return equiv_[iuniq][0]; }
00302     int nequivalent(int iuniq) const { return nequiv_[iuniq]; }
00304     int equivalent(int iuniq, int j) const { return equiv_[iuniq][j]; }
00307     int atom_to_unique(int iatom) const { return atom_to_uniq_[iatom]; }
00310     int atom_to_unique_offset(int iatom) const;
00311 
00313     int n_core_electrons();
00314 
00316     int max_z();
00317 
00319     Ref<AtomInfo> atominfo() const { return atominfo_; }
00320 
00322     std::string atom_name(int iatom) const;
00323 
00325     std::string atom_symbol(int iatom) const;
00326 
00329     void set_include_q(bool iq) { include_q_ = iq; }
00331     bool include_q() const { return include_q_; }
00332 
00335     void set_include_qq(bool iqq) { include_qq_ = iqq; }
00337     bool include_qq() const { return include_qq_; }
00338 
00340     int n_q_atom() const { return q_atoms_.size(); }
00342     int q_atom(int i) const { return q_atoms_[i]; }
00343 
00345     int n_non_q_atom() const { return non_q_atoms_.size(); }
00347     int non_q_atom(int i) const { return non_q_atoms_[i]; }
00348 
00349     void save_data_state(StateOut&);
00350 };
00351 
00352 }
00353 
00354 #endif
00355 
00356 // Local Variables:
00357 // mode: c++
00358 // c-file-style: "CLJ"
00359 // End:

Generated at Sun Dec 10 18:20:43 2006 for MPQC 2.3.0 using the documentation package Doxygen 1.4.7.