@author: Tom This file tests if the Runge Kutta Ansatz is on track with the previous results, namely if it is about the same as the analytical solution. """ import numpy as np import matplotlib.pyplot as plt from PlotAssistance import plot_error, plot_nicely from Variables import r0x, r0y, v0x, v0y, m, k, g from Curve_Calculation import curve_analytical, curve_naive, curve_runge_kutta #############Runge Simulator Plotten und Vergleichen mit alten Resultaten################## ########################################################################################### t, p, s = curve_runge_kutta() x_rk, y_rk = zip(*p) plt.figure() x_math, y_math = curve_naive() plot_nicely(x_math, y_math, 'b', "Ohne Luftwiderstand") x_real, y_real = curve_analytical() plot_nicely(x_real, y_real, 'g', "Analytische Lösung") plot_nicely(x_rk, y_rk, 'r', 'RungeKutta 4. Ordn.') plt.axis('equal') plt.xlabel('x') plt.ylabel('y')
intervall_duration, pts_per_intervall, endpoint=False) for t in range(0, end_time, intervall_duration): self.calculate_pos_in_near_future(t, delta_t) sat = Satellit1(intervall_duration=1, end_time=25) ####Resultate Plotten#### timespan = np.linspace(0, 25, 1000, endpoint=False) #'echte kurve'## t, p, s = curve_runge_kutta(timespan) x_rk, y_rk = zip(*p) x_rk = np.array(x_rk) y_rk = np.array(y_rk) plt.figure() plt.title("Störungskorrektur Ordnung 1") plot_nicely(x_rk[::50], y_rk[::50], 'g*', 'Exakt per Runge Kutta berechnet') plot_nicely(sat.x, sat.y, 'r', 'Störungsapproximiert') plot_nicely(curve_naive()[0], curve_naive()[1], 'b', 'Ohne Luftwiderstand') plt.axis('equal') plt.xlabel('x') plt.ylabel('y') plt.legend() plt.grid() plt.savefig("figs/Ansatz2_Ordnung1_Curves.png")
plt.xlabel('x') plt.ylabel('y') plt.legend() plt.grid() plt.savefig("figs/Ansatz1_Just_Naive.png") plt.show() ########################Reguläre Bahnen plotten################## ################################################################# plt.figure() plt.title("Flugbahnen") x_naive, y_naive = curve_naive() plot_nicely(x_naive, y_naive, 'b', "Ohne Luftwiderstand") _, p, _ = curve_runge_kutta() x_rk, y_rk = zip(*p) plot_nicely(x_rk, y_rk, 'g', "Mit Luftwiderstand") plt.axis('equal') plt.xlabel('x') plt.ylabel('y') plt.legend() plt.grid() plt.savefig("figs/Ansatz1_Overview_of_curves.png") plt.show() #########################Lineare Störungskorrektur##################### ####################################################################### #Initial Values for t=0 - nothing to correct, no correcetion factors