00001 #include <iostream>
00002 #include <stdexcept>
00003 #include <cmath>
00004 #include <cstdlib>
00005 #include <limits>
00006 #include "dynamic/dynamic.h"
00007 using namespace std;
00008 const double pi = 3.14159265;
00009 const double g = 9.81;
00013 const double motor_inertia = 5;
00014 const double motor_torque_nominal = 1000;
00015 const double motor_torque_start = 1400;
00016 const double motor_torque_breakdown = 2100;
00017 const double flywheel_inertia = 200;
00018 const double flywheel_rigidity = 10;
00019 const double flywheel_damping = 1;
00020 const double flywheel_start_deflection = 0.0;
00021 const double flywheel_start_speed = 0.0;
00022 const double delta = 0.01;
00023 const double time_max = 5.0;
00027 int main(int argC, char* argV[])
00028 {
00029
00030 cout << endl;
00031 cout << "Dynamic library by Jakub Krasa, 2006" << endl;
00032 cout << "example dynamic two rotary masses, first mass is electromotor." << endl << endl;
00033 cout << "\t\tMass 1 \t\t\t\tMass 2" << endl;
00034 cout << "Time\t\t" << "defl.\t" << "speed\t" << "accel.\t\t" << "defl.\t" << "speed\t" << "accel." << endl;
00035 cout.precision(3);
00036 cout << right << fixed;
00037
00038 try
00039 {
00040 dynamic::meacas* p_motor = new dynamic::meacas(motor_inertia,motor_torque_nominal,motor_torque_start,motor_torque_breakdown,6);
00041 dynamic::rdo* p_flywheel = new dynamic::rdo(flywheel_inertia,flywheel_rigidity,flywheel_damping,
00042 flywheel_start_deflection,flywheel_start_speed);
00043 dynamic::Serial* p_system = new dynamic::Serial();
00044 p_system->push_back(p_motor);
00045 p_system->push_back(p_flywheel);
00046 double time = 0;
00047 do
00048 {
00049 time += delta;
00050 p_system->time_to(time);
00051 cout << p_system->time.get() << "\t\t"
00052 << p_motor->defle() << "\t" << p_motor->speed() << "\t" << p_motor->accel()
00053 << "\t\t"
00054 << p_flywheel->defle() << "\t" << p_flywheel->speed() << "\t" << p_flywheel->accel()
00055 << endl;
00056 }
00057 while((((time + delta/2)-time_max)/time_max) <= numeric_limits<double>::epsilon());
00058 delete p_system;
00059 delete p_motor;
00060 delete p_flywheel;
00061 }
00062 catch (invalid_argument& e)
00063 {
00064 cout << "Invalid argument: " << e.what() << endl;
00065
00066 return EXIT_FAILURE;
00067 }
00068 return EXIT_SUCCESS;
00069 }