diff --git a/Blatt3/23ss_MiM_Bonus_03.pdf b/Blatt3/23ss_MiM_Bonus_03.pdf new file mode 100644 index 0000000000000000000000000000000000000000..7a9a4d55fc5f6efc2bce8f2a54661ad8789a97e9 Binary files /dev/null and b/Blatt3/23ss_MiM_Bonus_03.pdf differ diff --git a/Blatt3/Diagramm.png b/Blatt3/Diagramm.png new file mode 100644 index 0000000000000000000000000000000000000000..f370e9fc65133036beacc4816678da524ad31656 Binary files /dev/null and b/Blatt3/Diagramm.png differ diff --git a/Blatt3/README.md b/Blatt3/README.md new file mode 100644 index 0000000000000000000000000000000000000000..3251eff93ab998457eb915d7aa977a45601d0453 --- /dev/null +++ b/Blatt3/README.md @@ -0,0 +1,20 @@ + + +Ergebnis: + + +Alle Straßen außer x2 können in Einbahnstraßen umgewandelt werden, da der Fluss immer positiv bzw. negativ bleibt. +Bei x2 wechselt der Fluss zweimal am Tag die Richtung (Vorzeichenwechsel). + + +L: [ + [ 1. 0. 0. 0.] + [-1. 1. 0. 0.] + [ 0. -1. 1. 0.] + [ 0. 2. 0. 1.]] + +U: [ + [-1 0 0 0] + [ 0 -1 0 0] + [-1 1 -1 0] + [ 2 -2 0 1]] \ No newline at end of file diff --git a/Blatt3/verkehr.py b/Blatt3/verkehr.py new file mode 100644 index 0000000000000000000000000000000000000000..9afa93aacb883c5316d9b756beb4b772cb44db8a --- /dev/null +++ b/Blatt3/verkehr.py @@ -0,0 +1,69 @@ +import numpy as np +from numpy import pi, sin +import scipy.linalg +import matplotlib.pyplot as plt + +A = np.array([ [-1, 0, 0, 0], + [ 1,-1, 0, 0], + [ 0, 1,-1, 0], + [ 0,-2, 0, 1]]) + +L = np.identity(4) +U = A + +param = np.array([1,1,-2]) + +for i in range(len(A)): + U[1,i] += U[0,i]*param[0] + U[2,i] += U[0,i]*param[1] + U[3,i] += U[0,i]*param[2] + +L[1,0] = -1*param[0] +L[2,1] = -1*param[1] +L[3,1] = -1*param[2] + +print("L:") +print(L) +print("U:") +print(U) + + + +x1 = [] +x2 = [] +x3 = [] +x4 = [] +time = [] + +for t in range(0, 24*60): # 1440 Minuten + t = t/60 # zu 24 Stunden + + zA = 610 - 100 * sin((pi / 12) * t ) + aA = 450 - 25 * sin((pi / 3) * t + 5) + zB = 400 - 20 * sin((pi / 3) * t - 1) + aB = 640 + 50 * sin((pi / 12) * t - 7) + zC = 600 + 10 * sin((pi / 6) * t + 4) + + b = np.array([aA-zA, aB-zB, -zC, 0]) + + y = scipy.linalg.solve(L, b) + x = scipy.linalg.solve(U, y) + + x1.append(x[0]) + x2.append(x[1]) + x3.append(x[2]) + x4.append(x[3]) + time.append(t) + + + +fig, ax = plt.subplots() +ax.plot(time, x1, label='x1') +ax.plot(time, x2, label='x2') +ax.plot(time, x3, label='x3') +ax.plot(time, x4, label='x4') +ax.plot([0,24], [0,0], label='Nulllinie', color='black', linewidth=0.5) +ax.set_xlabel('Zeit [h]') +ax.set_ylabel('Flussmenge') +ax.legend() +plt.show() \ No newline at end of file