Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

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 
00097 class Molecule: public SavableState
00098 {
00099   protected:
00100     int natoms_;
00101     Ref<AtomInfo> atominfo_;
00102     Ref<PointGroup> pg_;
00103     Ref<Units> geometry_units_;
00104     double **r_;
00105     int *Z_;
00106     double *charges_;
00107 
00108     // symmetry equiv info
00109     int nuniq_;
00110     int *nequiv_;
00111     int **equiv_;
00112     int *atom_to_uniq_;
00113     void init_symmetry_info(double tol=0.5);
00114     void clear_symmetry_info();
00115 
00116     // these are optional
00117     double *mass_;
00118     char **labels_;
00119 
00120     void clear();
00121   public:
00122     Molecule();
00123     Molecule(const Molecule&);
00124     Molecule(StateIn&);
00126     Molecule(const Ref<KeyVal>&input);
00127 
00128     virtual ~Molecule();
00129 
00130     Molecule& operator=(const Molecule&);
00131 
00133     void add_atom(int Z,double x,double y,double z,
00134                   const char * = 0, double mass = 0.0,
00135                   int have_charge = 0, double charge = 0.0);
00136 
00138     virtual void print(std::ostream& =ExEnv::out()) const;
00139     virtual void print_parsedkeyval(std::ostream& =ExEnv::out(),
00140                                     int print_pg = 1,
00141                                     int print_unit = 1,
00142                                     int number_atoms = 1) const;
00143 
00145     int natom() const { return natoms_; }
00146 
00147     int Z(int atom) const { return Z_[atom]; }
00148     double &r(int atom, int xyz) { return r_[atom][xyz]; }
00149     const double &r(int atom, int xyz) const { return r_[atom][xyz]; }
00150     double *r(int atom) { return r_[atom]; }
00151     const double *r(int atom) const { return r_[atom]; }
00152     double mass(int atom) const;
00153     const char *label(int atom) const;
00154 
00157     int atom_at_position(double *, double tol = 0.05) const;
00158 
00161     int atom_label_to_index(const char *label) const;
00162 
00166     double *charges() const;
00167 
00169     double charge(int iatom) const;
00170 
00172     double nuclear_charge() const;
00173 
00175     void set_point_group(const Ref<PointGroup>&, double tol=1.0e-7);
00177     Ref<PointGroup> point_group() const;
00178 
00182     Ref<PointGroup> highest_point_group(double tol = 1.0e-8) const;
00183 
00186     int is_axis(SCVector3 &origin,
00187                 SCVector3 &udirection, int order, double tol=1.0e-8) const;
00188 
00191     int is_plane(SCVector3 &origin, SCVector3 &uperp, double tol=1.0e-8) const;
00192 
00194     int has_inversion(SCVector3 &origin, double tol = 1.0e-8) const;
00195 
00197     int is_linear(double tolerance = 1.0e-5) const;
00199     int is_planar(double tolerance = 1.0e-5) const;
00202     void is_linear_planar(int&linear,int&planar,double tol = 1.0e-5) const;
00203 
00206     SCVector3 center_of_mass() const;
00207 
00209     double nuclear_repulsion_energy();
00210     
00213     void nuclear_repulsion_1der(int center, double xyz[3]);
00214 
00216     void nuclear_efield(const double *position, double* efield);
00217 
00220     void nuclear_charge_efield(const double *charges,
00221                                const double *position, double* efield);
00222     
00228     void symmetrize(double tol = 0.5);
00229 
00231     void symmetrize(const Ref<PointGroup> &pg, double tol = 0.5);
00232 
00236     void cleanup_molecule(double tol = 0.1);
00237 
00238     void translate(const double *r);
00239     void move_to_com();
00240     void transform_to_principal_axes(int trans_frame=1);
00241     void transform_to_symmetry_frame();
00242     void print_pdb(std::ostream& =ExEnv::out(), char *title =0) const;
00243 
00244     void read_pdb(const char *filename);
00245 
00248     void principal_moments_of_inertia(double *evals, double **evecs=0) const;
00249 
00251     int nunique() const { return nuniq_; }
00253     int unique(int iuniq) const { return equiv_[iuniq][0]; }
00255     int nequivalent(int iuniq) const { return nequiv_[iuniq]; }
00257     int equivalent(int iuniq, int j) const { return equiv_[iuniq][j]; }
00260     int atom_to_unique(int iatom) const { return atom_to_uniq_[iatom]; }
00263     int atom_to_unique_offset(int iatom) const;
00264 
00266     int n_core_electrons();
00267 
00269     int max_z();
00270 
00272     Ref<AtomInfo> atominfo() const { return atominfo_; }
00273 
00274     void save_data_state(StateOut&);
00275 };
00276 
00277 
00278 #endif
00279 
00280 // Local Variables:
00281 // mode: c++
00282 // c-file-style: "CLJ"
00283 // End:

Generated at Thu Oct 4 18:08:46 2001 for MPQC 2.0.0 using the documentation package Doxygen 1.2.5.