# -*- coding: utf-8 -*- """ Created on Thu Aug 26 12:12:10 2021 @author: 9706809E """ import numpy import matplotlib.pyplot as plt import math import pandas as pd import numpy as np import time plt.close('all') factor = 1 / 3 w2 = (2 * numpy.pi * factor)**2 def f_air(v): mass = 430e3 A = 0.6325 B = 7.55e-3 C = 1.244e-4 alpha = mass*A*1e-2 # N beta = mass*B*1e-2*3.6 # N/(m/s) gamma = mass*C*1e-2*(3.6**2) # N/(m/s)**2 force_friction = alpha + beta*v + gamma*v**2 return force_friction def f(v): traction_df = pd.read_csv ('TRACTION_2TGVDASYEUM.csv') traction_data = traction_df.to_numpy() effort_speed_v = (1/3.6)*traction_data[:, 0] effort_speed_F = traction_data[:, 2] force_motor = np.interp(v,effort_speed_v,effort_speed_F) return force_motor def oscillateur(Y, t): mass = 430e3 return numpy.array([Y[1], (f(Y[1]) - f_air(Y[1]))/mass]) def pas_euler(system, h, tn, Yn): deriv = system(Yn, tn) return Yn + h * deriv def pas_euler_cauchy(system, h, tn, Yn): deriv = system(Yn, tn) Y_mid = Yn + h * deriv deriv_mid = system(Y_mid, tn + h) return Yn + (h / 2) * (deriv + deriv_mid) def pas_RK4(system, h, tn, Yn): k1 = system(Yn, tn) k2 = system(Yn + (h/2) * k1, tn + h/2) k3 = system(Yn + (h/2) * k2, tn + h/2) k4 = system(Yn + h * k3, tn + h) return Yn + (h/6) * (k1 + 2 * k2 + 2 * k3 + k4) def pas_adams(system, h, tn, Yn, tn_1, Yn_1): deriv_n = system(Yn, tn) deriv_n_1 = system(Yn_1, tn_1) return Yn + (h/2) * (3 * deriv_n - deriv_n_1) def pas_adams_3(system, h, tn, Yn, tn_1, Yn_1, tn_2, Yn_2): deriv_n = system(Yn, tn) deriv_n_1 = system(Yn_1, tn_1) deriv_n_2 = system(Yn_2, tn_2) return Yn + (h/12) * (23 * deriv_n - 16 * deriv_n_1 + 5 * deriv_n_2) def euler(system, Yi, T, h): Y = Yi t = 0.0 liste_y = [Y] liste_t = [t] while t