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
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 int *fragments_;
00138
00139
00140 int nuniq_;
00141 int *nequiv_;
00142 int **equiv_;
00143 int *atom_to_uniq_;
00144 void init_symmetry_info(double tol=0.5);
00145 void clear_symmetry_info();
00146
00147
00148 double *mass_;
00149 char **labels_;
00150
00151
00152 int q_Z_;
00153
00154
00155 bool include_q_;
00156
00157
00158
00159 bool include_qq_;
00160
00161
00162
00163 std::vector<int> q_atoms_;
00164 std::vector<int> non_q_atoms_;
00165
00166 void clear();
00167
00168
00169
00170 void throw_if_atom_duplicated(int begin=0, double tol = 1e-3);
00171 public:
00172 Molecule();
00173 Molecule(const Molecule&);
00174 Molecule(StateIn&);
00279 Molecule(const Ref<KeyVal>&input);
00280
00281 virtual ~Molecule();
00282
00283 Molecule& operator=(const Molecule&);
00284
00286 void add_atom(int Z,double x,double y,double z,
00287 const std::string & label = "", double mass = 0.0,
00288 int have_charge = 0, double charge = 0.0,
00289 int have_fragment = 0, int fragment = 0);
00290
00292 virtual void print(std::ostream& =ExEnv::out0()) const;
00293 virtual void print_parsedkeyval(std::ostream& =ExEnv::out0(),
00294 int print_pg = 1,
00295 int print_unit = 1,
00296 int number_atoms = 1) const;
00297
00299 int natom() const { return natoms_; }
00300
00301 int Z(int atom) const { return Z_[atom]; }
00302 double &r(int atom, int xyz) { return r_[atom][xyz]; }
00303 const double &r(int atom, int xyz) const { return r_[atom][xyz]; }
00304 double *r(int atom) { return r_[atom]; }
00305 const double *r(int atom) const { return r_[atom]; }
00306 double mass(int atom) const;
00309 const char *label(int atom) const;
00311 int fragment(int atom) const;
00312
00315 int atom_at_position(double *, double tol = 0.05) const;
00316
00319 int atom_label_to_index(const std::string &label) const;
00320
00324 double *charges() const;
00325
00327 double charge(int iatom) const;
00328
00330 double nuclear_charge() const;
00331
00333 void set_point_group(const Ref<PointGroup>&, double tol=1.0e-7);
00335 const Ref<PointGroup>& point_group() const;
00336
00340 Ref<PointGroup> highest_point_group(double tol = 1.0e-8) const;
00341
00344 int is_axis(SCVector3 &origin,
00345 SCVector3 &udirection, int order, double tol=1.0e-8) const;
00346
00349 int is_plane(SCVector3 &origin, SCVector3 &uperp, double tol=1.0e-8) const;
00350
00352 int has_inversion(SCVector3 &origin, double tol = 1.0e-8) const;
00353
00355 int is_linear(double tolerance = 1.0e-5) const;
00357 int is_planar(double tolerance = 1.0e-5) const;
00360 void is_linear_planar(int&linear,int&planar,double tol = 1.0e-5) const;
00361
00364 SCVector3 center_of_mass() const;
00365
00367 double nuclear_repulsion_energy();
00368
00371 void nuclear_repulsion_1der(int center, double xyz[3]);
00372
00374 void nuclear_efield(const double *position, double* efield);
00375
00378 void nuclear_charge_efield(const double *charges,
00379 const double *position, double* efield);
00380
00386 void symmetrize(double tol = 0.5);
00387
00389 void symmetrize(const Ref<PointGroup> &pg, double tol = 0.5);
00390
00394 void cleanup_molecule(double tol = 0.1);
00395
00396 void translate(const double *r);
00397 void move_to_com();
00398 void transform_to_principal_axes(int trans_frame=1);
00399 void transform_to_symmetry_frame();
00400 void print_pdb(std::ostream& =ExEnv::out0(), char *title =0) const;
00401
00402 void read_pdb(const char *filename);
00403
00406 void principal_moments_of_inertia(double *evals, double **evecs=0) const;
00407
00409 int nunique() const { return nuniq_; }
00411 int unique(int iuniq) const { return equiv_[iuniq][0]; }
00413 int nequivalent(int iuniq) const { return nequiv_[iuniq]; }
00415 int equivalent(int iuniq, int j) const { return equiv_[iuniq][j]; }
00418 int atom_to_unique(int iatom) const { return atom_to_uniq_[iatom]; }
00421 int atom_to_unique_offset(int iatom) const;
00422
00424 int n_core_electrons();
00425
00427 int max_z();
00428
00430 Ref<AtomInfo> atominfo() const { return atominfo_; }
00431
00433 std::string atom_name(int iatom) const;
00434
00436 std::string atom_symbol(int iatom) const;
00437
00440 void set_include_q(bool iq) { include_q_ = iq; }
00442 bool include_q() const { return include_q_; }
00443
00446 void set_include_qq(bool iqq) { include_qq_ = iqq; }
00448 bool include_qq() const { return include_qq_; }
00449
00451 int n_q_atom() const { return q_atoms_.size(); }
00453 int q_atom(int i) const { return q_atoms_[i]; }
00454
00456 int n_non_q_atom() const { return non_q_atoms_.size(); }
00458 int non_q_atom(int i) const { return non_q_atoms_[i]; }
00459
00460 void save_data_state(StateOut&);
00461 };
00462
00463 }
00464
00465 #endif
00466
00467
00468
00469
00470