/* []----------------------------------------[] | Bending.h | []----------------------------------------[] | | | AUTHOR: MFSomers 2005. | | USE: Bond bending interaction | | definitions... | | | []----------------------------------------[] */ // Copyright (C) 2005 M.F. Somers, Theoretical Chemistry Department, Leiden University // // This is free software; you can redistribute it and/or modify it under the terms of // the GNU Lesser General Public License as published by the Free Software Foundation. // // http://www.gnu.org/licenses/lgpl.txt #if !defined(__GENERALBENDING_INCLUDED__) #define __GENERALBENDING_INCLUDED__ #include #include "Global.h" #include "Vector.h" #include "Constants.h" #include "ClassicalDynamics.h" /* ----------------------------------------------------------------------- */ /* Definition of a bond bending interaction */ class BendingInteraction; typedef BendingInteraction *BendingInteractionPointer; class BendingInteraction : public Interaction { public: inline BendingInteraction( unsigned int TheId = GET_NEW_ID, Vector *UsePeriodicBox = NULL ) : Interaction( TheId, UsePeriodicBox ) { Type = AGeneralBendingInteraction; }; inline BendingInteraction( BendingInteraction& I ) : Interaction( I ) { } virtual BendingInteractionPointer Clone() { return( new BendingInteraction( (*this) ) ); } virtual BendingInteractionPointer Create( unsigned int TheId = GET_NEW_ID, Vector *UsePeriodicBox = NULL ) { return( new BendingInteraction( TheId, UsePeriodicBox ) ); } virtual double BendingPotential( double cosangle ); virtual double DerivativeOfBendingPotential( double cosangle ); virtual double BendingPotential( Particle& P1, Particle& P2, Particle& P3 ); virtual Vector BendingForce( Particle& P1, Particle& P2, Particle& P3, int p ); double BendingPotential( unsigned int ID1, unsigned int ID2, unsigned ID3 ); Vector BendingForce( unsigned int ID1, unsigned int ID2, unsigned ID3, int p ); virtual double InteractionPotential( void ); virtual Vector InteractionForce( unsigned int ID ); }; /* --------------------------------------------------------- */ /* Defines a harmonic bond bending interaction between particles */ class HarmonicBendingInteraction; typedef HarmonicBendingInteraction *HarmonicBendingInteractionPointer; class HarmonicBendingInteraction : public BendingInteraction { public: inline HarmonicBendingInteraction( double TheFactor, double TheAngle, unsigned int TheId = GET_NEW_ID, Vector *UsePeriodicBox = NULL ) : BendingInteraction( TheId, UsePeriodicBox ) { InteractionFactor = TheFactor; CosAngle = cos( TheAngle ); Type = AHarmonicBendingInteraction; }; inline HarmonicBendingInteraction( HarmonicBendingInteraction& I ) : BendingInteraction( I ) { InteractionFactor = I.InteractionFactor; CosAngle = I.CosAngle; } virtual HarmonicBendingInteraction& operator=( HarmonicBendingInteraction& I ) { if( &I == &(*this) ) return( (*this) ); BendingInteraction::operator=( I ); InteractionFactor = I.InteractionFactor; CosAngle = I.CosAngle; return( (*this) ); } virtual HarmonicBendingInteractionPointer Clone() { return( new HarmonicBendingInteraction( (*this) ) ); } virtual HarmonicBendingInteractionPointer Create( double TheFactor = 1.0, double TheAngle = 0.0, unsigned int TheId = GET_NEW_ID, Vector *UsePeriodicBox = NULL ) { return( new HarmonicBendingInteraction( TheFactor, acos( TheAngle ), TheId, UsePeriodicBox ) ); } virtual double BendingPotential( double cosangle ); virtual double DerivativeOfBendingPotential( double cosangle ); double InteractionFactor, CosAngle; /* V(cosangle) = 0.5 * TheFactor * (cosangle-CosAngle)^2 */ }; /* ----------------------------------------------------------------------- */ #endif