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

bem.h

00001 //
00002 // bem.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_solvent_bem_h
00029 #define _chemistry_solvent_bem_h
00030 
00031 #include <util/class/class.h>
00032 #include <util/state/state.h>
00033 #include <util/keyval/keyval.h>
00034 #include <math/isosurf/volume.h>
00035 #include <math/isosurf/surf.h>
00036 #include <math/scmat/matrix.h>
00037 #include <chemistry/molecule/molecule.h>
00038 
00039 // This represents a solvent by a polarization charge on a dielectric
00040 // boundary surface.
00041 class BEMSolvent: public DescribedClass {
00042   private:
00043     int debug_;
00044 
00045     Ref<Molecule> solute_;
00046     Ref<Molecule> solvent_;
00047     double solvent_density_;
00048     double dielectric_constant_;
00049     Ref<SCMatrixKit> matrixkit_;
00050     RefSCMatrix system_matrix_i_;
00051     double f_;
00052     Ref<MessageGrp> grp_;
00053 
00054     double area_;
00055     double volume_;
00056     double computed_enclosed_charge_;
00057     double edisp_;
00058     double erep_;
00059 
00060     Ref<TriangulatedImplicitSurface> surf_;
00061 
00062     double** alloc_array(int n, int m);
00063     void free_array(double**);
00064 
00065     // This holds the area associated with each vertex.  It is used
00066     // to convert charges to charge densities and back.
00067     double* vertex_area_;
00068 
00069     // Given charges compute surface charge density.
00070     void charges_to_surface_charge_density(double *charges);
00071 
00072     // Given surface charge density compute charges.
00073     void surface_charge_density_to_charges(double *charges);
00074   public:
00075     BEMSolvent(const Ref<KeyVal>&);
00076     virtual ~BEMSolvent();
00077 
00078     // This should be called after everything is setup--the
00079     // molecule has the correct the geometry and all of the
00080     // parameters have been adjusted.
00081     void init();
00082     // This gets rid of the system matrix inverse and, optionally, the surface.
00083     void done(int clear_surface = 1);
00084 
00085     int ncharge() { return surf_->nvertex(); }
00086 
00087     Ref<Molecule> solvent() { return solvent_ ;}
00088     double solvent_density() { return solvent_density_ ;}
00089 
00090     // NOTE: call allocation routines after init and free routines before done
00091     double** alloc_charge_positions() { return alloc_array(ncharge(), 3); }
00092     void free_charge_positions(double**a) { free_array(a); }
00093 
00094     double** alloc_normals()  { return alloc_array(ncharge(), 3); }
00095     void free_normals(double**a) { free_array(a); }
00096 
00097     double* alloc_efield_dot_normals()  { return new double[ncharge()]; }
00098     void free_efield_dot_normals(double*a) { delete[] a; }
00099 
00100     double* alloc_charges() { return new double[ncharge()]; }
00101     void free_charges(double*a) { delete[] a; }
00102 
00103     void charge_positions(double**);
00104     void normals(double**);
00105 
00106     // Given the efield dotted with the normals at the charge positions this
00107     // will compute a new set of charges.
00108     void compute_charges(double* efield_dot_normals, double* charge);
00109 
00110     // Given a set of charges and a total charge, this will normalize
00111     // the integrated charge to the charge that would be expected on
00112     // the surface if the given total charge were enclosed within it.
00113     void normalize_charge(double enclosed_charge, double* charges);
00114 
00115     // Given charges and nuclear charges compute their interation energy.
00116     double nuclear_charge_interaction_energy(double *nuclear_charge,
00117                                              double** charge_positions,
00118                                              double* charge);
00119 
00120     // Given charges compute the interaction energy between the nuclei
00121     // and the point charges.
00122     double nuclear_interaction_energy(double** charge_positions,
00123                                       double* charge);
00124 
00125     // Given charges compute the interaction energy for just the surface.
00126     double self_interaction_energy(double** charge_positions, double *charge);
00127     
00128     // Given the charges, return the total polarization charge on the surface.
00129     double polarization_charge(double* charge);
00130 
00131     // Return the area (available after compute_charges called).
00132     double area() const { return area_; }
00133     // Return the volume (available after compute_charges called).
00134     double volume() const { return volume_; }
00135     // Return the enclosed charge (available after compute_charges called).
00136     double computed_enclosed_charge() const {
00137       return computed_enclosed_charge_;
00138     }
00139 
00140     double disp() {return edisp_;}
00141     double rep()  {return erep_;}
00142     double disprep();
00143 
00144     // this never needs to be called explicitly, but is here now for debugging
00145     void init_system_matrix();
00146 
00147     Ref<TriangulatedImplicitSurface> surface() const { return surf_; }
00148 
00149     Ref<SCMatrixKit> matrixkit() { return matrixkit_; }
00150 };
00151 
00152 
00153 #endif
00154 
00155 // Local Variables:
00156 // mode: c++
00157 // c-file-style: "CLJ"
00158 // End:

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