Google

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 
00046 namespace sc {
00047 
00099 class Molecule: public SavableState
00100 {
00101   protected:
00102     int natoms_;
00103     Ref<AtomInfo> atominfo_;
00104     Ref<PointGroup> pg_;
00105     Ref<Units> geometry_units_;
00106     double **r_;
00107     int *Z_;
00108     double *charges_;
00109 
00110     // symmetry equiv info
00111     int nuniq_;
00112     int *nequiv_;
00113     int **equiv_;
00114     int *atom_to_uniq_;
00115     void init_symmetry_info(double tol=0.5);
00116     void clear_symmetry_info();
00117 
00118     // these are optional
00119     double *mass_;
00120     char **labels_;
00121 
00122     void clear();
00123   public:
00124     Molecule();
00125     Molecule(const Molecule&);
00126     Molecule(StateIn&);
00128     Molecule(const Ref<KeyVal>&input);
00129 
00130     virtual ~Molecule();
00131 
00132     Molecule& operator=(const Molecule&);
00133 
00135     void add_atom(int Z,double x,double y,double z,
00136                   const char * = 0, double mass = 0.0,
00137                   int have_charge = 0, double charge = 0.0);
00138 
00140     virtual void print(std::ostream& =ExEnv::out0()) const;
00141     virtual void print_parsedkeyval(std::ostream& =ExEnv::out0(),
00142                                     int print_pg = 1,
00143                                     int print_unit = 1,
00144                                     int number_atoms = 1) const;
00145 
00147     int natom() const { return natoms_; }
00148 
00149     int Z(int atom) const { return Z_[atom]; }
00150     double &r(int atom, int xyz) { return r_[atom][xyz]; }
00151     const double &r(int atom, int xyz) const { return r_[atom][xyz]; }
00152     double *r(int atom) { return r_[atom]; }
00153     const double *r(int atom) const { return r_[atom]; }
00154     double mass(int atom) const;
00157     const char *label(int atom) const;
00158 
00161     int atom_at_position(double *, double tol = 0.05) const;
00162 
00165     int atom_label_to_index(const char *label) const;
00166 
00170     double *charges() const;
00171 
00173     double charge(int iatom) const;
00174 
00176     double nuclear_charge() const;
00177 
00179     void set_point_group(const Ref<PointGroup>&, double tol=1.0e-7);
00181     Ref<PointGroup> point_group() const;
00182 
00186     Ref<PointGroup> highest_point_group(double tol = 1.0e-8) const;
00187 
00190     int is_axis(SCVector3 &origin,
00191                 SCVector3 &udirection, int order, double tol=1.0e-8) const;
00192 
00195     int is_plane(SCVector3 &origin, SCVector3 &uperp, double tol=1.0e-8) const;
00196 
00198     int has_inversion(SCVector3 &origin, double tol = 1.0e-8) const;
00199 
00201     int is_linear(double tolerance = 1.0e-5) const;
00203     int is_planar(double tolerance = 1.0e-5) const;
00206     void is_linear_planar(int&linear,int&planar,double tol = 1.0e-5) const;
00207 
00210     SCVector3 center_of_mass() const;
00211 
00213     double nuclear_repulsion_energy();
00214     
00217     void nuclear_repulsion_1der(int center, double xyz[3]);
00218 
00220     void nuclear_efield(const double *position, double* efield);
00221 
00224     void nuclear_charge_efield(const double *charges,
00225                                const double *position, double* efield);
00226     
00232     void symmetrize(double tol = 0.5);
00233 
00235     void symmetrize(const Ref<PointGroup> &pg, double tol = 0.5);
00236 
00240     void cleanup_molecule(double tol = 0.1);
00241 
00242     void translate(const double *r);
00243     void move_to_com();
00244     void transform_to_principal_axes(int trans_frame=1);
00245     void transform_to_symmetry_frame();
00246     void print_pdb(std::ostream& =ExEnv::out0(), char *title =0) const;
00247 
00248     void read_pdb(const char *filename);
00249 
00252     void principal_moments_of_inertia(double *evals, double **evecs=0) const;
00253 
00255     int nunique() const { return nuniq_; }
00257     int unique(int iuniq) const { return equiv_[iuniq][0]; }
00259     int nequivalent(int iuniq) const { return nequiv_[iuniq]; }
00261     int equivalent(int iuniq, int j) const { return equiv_[iuniq][j]; }
00264     int atom_to_unique(int iatom) const { return atom_to_uniq_[iatom]; }
00267     int atom_to_unique_offset(int iatom) const;
00268 
00270     int n_core_electrons();
00271 
00273     int max_z();
00274 
00276     Ref<AtomInfo> atominfo() const { return atominfo_; }
00277 
00278     void save_data_state(StateOut&);
00279 };
00280 
00281 }
00282 
00283 #endif
00284 
00285 // Local Variables:
00286 // mode: c++
00287 // c-file-style: "CLJ"
00288 // End:

Generated at Fri Jan 10 08:14:09 2003 for MPQC 2.1.3 using the documentation package Doxygen 1.2.14.