/*
    Eksempel på klasser:
    Nyhoff: pp. 560
*/

#include <iostream>
using namespace std;

#include "2_particle.hpp"

int main()
{
   Particle a(10,1,1.0);    // x=10, v=1  and m=1
   double dt=0.01;
   double T=100;
   
   ofstream fo("damped_driven_oscillation.t");

   double k=2;      // Spring constant
   double g=3;      // Friction coefficient
   double wd=10;    // Driving cyclic frequency
   double f0 = 1;   // Force amplitude
   
   for (double t=0.0; t<T ; t+=dt)
      {
          double fspring = -k*a.GetPos();
          double fdamp   = -g*a.GetVelocity();
          double fdrive  = f0*cos(wd*t);

          a.Euler(dt, fspring+fdamp+fdrive );

          cout << t << "\t" << a.GetPos() << " " << a.GetVelocity() << "\n";
          fo   << t << "\t" << a.GetPos() << " " << a.GetVelocity() << "\n";
      }
   fo.close();

   return 0;
}
