# Simulation Freier Fall mit graphischer Ausgabe

## Konstanten:
g =	       9.81 # m/s² (Fallbeschleunigung Erde)

## Anfangsbedingungen:
s_0 =    100    # m    (Anfangshöhe)
v_0 =      0    # m/s  (Anfangsgeschwindigkeit)

## Genauigkeit:
dt =       0.2  # s    (Zeitschritt)

## Simulation:
list_t = []
list_s = []
a = -g
s = s_0
v = v_0
t = 0
while s > 0:
    list_t.append(t)
    list_s.append(s)
    s += v * dt # neues s aus dem alten Wert von v berechnen
    v += a * dt # neues v aus dem alten Wert von a berechnen
    t += dt

## Textausgabe:
print("Falldauer: ", round(t,3), " s")
print("Endgeschwindigkeit:", round(v,3), "m/s")

## Diagramm:
import matplotlib.pyplot as plt
plt.plot(list_t, list_s, 'ro')
plt.ylabel('Höhe (m)')
plt.xlabel('Zeit (s)')
plt.title('Simulation: Freier Fall aus '+str(s_0)+'m')
plt.show()
