// C++ Program #include #include /* pow */ #include using namespace std; // For real declaration typedef double R; const double g = 9.81 ; const double h0 = 1.0; const double v0 = 1.5 ; const double dt = 0.001 ; const int nb_it = 10000; const int freq_sauv = 10 ; const double x0 = 1.0 ; const double R0 = 0.15 ; const double Ff = 0.5 ; const double M = 0.1 ; const double Kn = 1.e+5 ; // FUNCTION Solution discrétisée void Dep_Vit_Acc(double &zi , double &vi , double &zf , double &vf , double &ai , double &af , int it) { double un, cn ; if (it == 0) { // INITIALISATION A t=0 } else if (it > 0) { // RESOLUTION DU PFD A t QCQ } } // FUNCTION Solution analytique void Sol_Theo(double &z_th , double &v_th , int it , double &temps) { temps = dt*it ; v_th = -g*temps + v0 ; z_th = -g*pow(temps,2)/2. + v0*temps + h0 ; } // MAIN PROGRAM int main() { double z0,v0,zt,vt,a0,af,zdt,vdt,tps; int itt ; ofstream Result_file("deplacement") ; ofstream My_data0("chuteNp") ; ofstream My_data1("chuteNp_at") ; ofstream My_data2("chutetime") ; ofstream My_data3("chutetime_at") ; for (itt = 0 ; itt <= nb_it ; ++itt) { Dep_Vit_Acc(z0,v0,zt,vt,a0,af,itt) ; Sol_Theo(zdt,vdt,itt,tps) ; if ( nb_it%freq_sauv == 0 ) { Result_file << tps << " " << zt << " " << zdt << " " << vt << " " << vdt << endl ; } if ( (itt%freq_sauv) == 0 ) { My_data0 << itt/freq_sauv << " " ; My_data0 << x0 << " " ; My_data0 << zt << " " ; My_data0 << R0 << " " ; My_data0 << endl ; My_data0 << " " << endl ; My_data0 << " " << endl ; } if ( (itt%freq_sauv) == 0 ) { My_data2 << itt/freq_sauv << " " ; My_data2 << tps << " " ; My_data2 << zt << " " ; My_data2 << 1.3*R0 << " " ; My_data2 << endl ; My_data2 << " " << endl ; My_data2 << " " << endl ; } if ( itt == 200 ) { My_data1 << tps << " " ; My_data1 << x0 << " " ; My_data1 << zt << " " ; My_data1 << R0 << " " ; My_data1 << endl ; My_data3 << tps << " " ; My_data3 << tps << " " ; My_data3 << zt << " " ; My_data3 << R0 << " " ; My_data3 << endl ; } } }