ArmonicOscillator Class Reference

#include <orsa_interaction.h>

Inheritance diagram for ArmonicOscillator:

Inheritance graph
[legend]
Collaboration diagram for ArmonicOscillator:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ArmonicOscillator (const double free_length_in, const double k_in)
 ArmonicOscillator (const ArmonicOscillator &)
void Acceleration (const Frame &, std::vector< Vector > &)
double PotentialEnergy (const Frame &)
Interactionclone () const
InteractionType GetType () const
virtual bool depends_on_velocity () const
void SkipJPLPlanets (const bool b)
bool IsSkippingJPLPlanets () const

Protected Attributes

bool skip_JPL_planets

Constructor & Destructor Documentation

ArmonicOscillator const double  free_length_in,
const double  k_in
 

Definition at line 712 of file orsa_interaction.cc.

Referenced by ArmonicOscillator::clone().

00712                                                                                      : Interaction(), free_length(free_length_in), k(k_in) {
00713     
00714   }

ArmonicOscillator const ArmonicOscillator  ) 
 

Definition at line 716 of file orsa_interaction.cc.

00716                                                                   : Interaction(), free_length(i.free_length), k(i.k) {
00717     
00718   }


Member Function Documentation

void Acceleration const Frame ,
std::vector< Vector > & 
[virtual]
 

Implements Interaction.

Definition at line 724 of file orsa_interaction.cc.

References Vector::IsZero(), Vector::Length(), ORSA_WARNING, and Vector::Set().

00724                                                                         {
00725     
00726     if (f.size() < 2) return;
00727     
00728     a.resize(f.size());
00729     
00730     unsigned int i,j;
00731     
00732     Vector d, da;
00733 
00734     double ls;
00735     
00736     for (i=0;i<f.size();++i)
00737       a[i].Set(0,0,0);
00738     
00739     for (i=1;i<f.size();++i) {
00740       
00741       if (f[i].mass()==0) continue;
00742       
00743       for (j=0;j<i;++j) {
00744         
00745         // if ((f[i].mass==0) || (f[j].mass==0)) continue;
00746         
00747         // assert(i!=j);
00748         
00749         // d  =  f[i].position;
00750         // d -=  f[j].position;
00751         
00752         d = f[i].DistanceVector(f[j]);
00753 
00754         ls = d.Length();
00755         
00756         if (d.IsZero()) {
00757           ORSA_WARNING("two objects in the same position! (%s and %s)",f[i].name().c_str(),f[j].name().c_str());
00758           continue;
00759         }
00760         
00761         da = d*(ls-free_length)/ls;
00762         
00763         a[i] += da;
00764         a[j] -= da;
00765         
00766       } 
00767     }  
00768     
00769     for (i=0;i<a.size();++i) 
00770       if (f[i].mass() != 0) a[i] *= k/f[i].mass();
00771     
00772   }

Here is the call graph for this function:

Interaction * clone  )  const [virtual]
 

Implements Interaction.

Definition at line 720 of file orsa_interaction.cc.

References ArmonicOscillator::ArmonicOscillator().

00720                                                {
00721     return new ArmonicOscillator(*this);
00722   }

Here is the call graph for this function:

virtual bool depends_on_velocity  )  const [inline, virtual, inherited]
 

Reimplemented in Newton, and Relativistic.

Definition at line 92 of file orsa_interaction.h.

00092 { return false; }

InteractionType GetType  )  const [inline, virtual]
 

Implements Interaction.

Definition at line 413 of file orsa_interaction.h.

References orsa::ARMONICOSCILLATOR.

00413                                     {
00414       return ARMONICOSCILLATOR;
00415     }

bool IsSkippingJPLPlanets  )  const [inline, inherited]
 

Definition at line 98 of file orsa_interaction.h.

References Interaction::skip_JPL_planets.

Referenced by Evolution::Integrate().

00098                                       {
00099       return skip_JPL_planets;
00100     }

double PotentialEnergy const Frame  )  [virtual]
 

Implements Interaction.

Definition at line 774 of file orsa_interaction.cc.

References Vector::IsZero(), Vector::Length(), and ORSA_WARNING.

00774                                                           {
00775     
00776     double energy=0.0;
00777     
00778     if (f.size() < 2) return(0.0);
00779     
00780     unsigned int i,j;
00781     
00782     Vector d;
00783     
00784     double ls;
00785     
00786     for (i=1;i<f.size();++i) {
00787       
00788       if (f[i].mass()==0) continue;
00789       
00790       for (j=0;j<i;++j) {
00791         
00792         // if ((f[i].mass==0) && (f[j].mass==0)) continue;
00793         
00794         // d  =  f[i].position;
00795         // d -=  f[j].position;
00796         
00797         d = f[i].DistanceVector(f[j]);
00798         
00799         if (d.IsZero()) {
00800           ORSA_WARNING("two objects in the same position! (%s and %s)",f[i].name().c_str(),f[j].name().c_str());
00801           continue;
00802         }
00803         
00804         // ls = secure_pow(d.Length()-free_length,2);
00805         ls = pow(d.Length()-free_length,2); // don't use the secure version for performance reasons
00806         
00807         energy += ls/2.0;
00808         
00809       } 
00810     }  
00811     
00812     return (energy*k);
00813     
00814   }

Here is the call graph for this function:

void SkipJPLPlanets const bool  b  )  [inline, inherited]
 

Definition at line 95 of file orsa_interaction.h.

References Interaction::skip_JPL_planets.

Referenced by OrsaFile::Read().

00095                                       {
00096       skip_JPL_planets = b;
00097     }


Member Data Documentation

bool skip_JPL_planets [protected, inherited]
 

Definition at line 102 of file orsa_interaction.h.

Referenced by Interaction::IsSkippingJPLPlanets(), and Interaction::SkipJPLPlanets().


The documentation for this class was generated from the following files:
Generated on Tue Jan 11 15:29:21 2005 for liborsa by  doxygen 1.4.0