00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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
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
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
00281
00282
00283