abs_hamiltonian.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // $Id: abs_hamiltonian.h,v 3.5 2006/12/25 21:40:17 bjoo Exp $
00003 /*! \file
00004  * \brief Abstract Hamiltonian
00005  *
00006  * Abstract Hamiltonian
00007  */
00008 
00009 #ifndef abs_hamiltonian_h
00010 #define abs_hamiltonian_h
00011 
00012 #include "chromabase.h"
00013 #include "update/molecdyn/field_state.h"
00014 #include "update/molecdyn/monomial/abs_monomial.h"
00015 #include "io/xmllog_io.h"
00016 
00017 namespace Chroma 
00018 { 
00019 
00020 
00021   //! New Abstract Hamiltonian
00022   /*! @ingroup hamilton
00023    *
00024    * Abstraction for Hamiltonians. They can refresh Internal 
00025    * fields and measure energies.
00026    */
00027   template<typename P, typename Q>
00028   class AbsHamiltonian 
00029   {
00030   public:
00031     
00032     //! virtual descructor:
00033     virtual ~AbsHamiltonian() {}
00034 
00035     //! Refresh pseudofermsions (if any)
00036     virtual void refreshInternalFields(const AbsFieldState<P,Q>& s) =0;
00037     
00038     //! Compute the energies 
00039     //! The total energy
00040     virtual void  mesE(const AbsFieldState<P,Q>& s, Double& KE, Double& PE) const 
00041     {
00042       START_CODE();
00043 
00044       // Self Description Rule
00045       XMLWriter& xml_out = TheXMLLogWriter::Instance();
00046       push(xml_out, "mesE");
00047 
00048       KE = mesKE(s);
00049       PE = mesPE(s);
00050 
00051       pop(xml_out);
00052 
00053       END_CODE();
00054     }
00055         
00056     //! The Kinetic Energy
00057     virtual Double mesKE(const AbsFieldState<P,Q>& s) const 
00058     {
00059       START_CODE();
00060 
00061       XMLWriter& xml_out = TheXMLLogWriter::Instance();
00062       push(xml_out, "mesKE");
00063 
00064       // Return 1/2 sum pi^2
00065       // may need to loop over the indices of P?
00066       Double KE=norm2(s.getP());
00067 
00068       write(xml_out, "KE", KE);
00069       pop(xml_out);  // pop(mesKE);
00070     
00071       END_CODE();
00072       return KE;
00073     }
00074     
00075     //! The Potential Energy 
00076     virtual Double mesPE(const AbsFieldState<P,Q>& s) const = 0;
00077    
00078   };
00079 
00080 } // End namespace Chroma
00081 #endif

Generated on Sun Nov 22 04:28:48 2009 for CHROMA by  doxygen 1.4.7