serie 01 and 02
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -174,3 +174,5 @@ cython_debug/
|
||||
# PyPI configuration file
|
||||
.pypirc
|
||||
|
||||
/.idea/misc.xml
|
||||
/.idea/
|
||||
BIN
Kuengjoe_S01.zip
Normal file
BIN
Kuengjoe_S01.zip
Normal file
Binary file not shown.
162
Kuengjoe_S01/Kuengjoe_S2_Aufg1.py
Normal file
162
Kuengjoe_S01/Kuengjoe_S2_Aufg1.py
Normal file
@@ -0,0 +1,162 @@
|
||||
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from matplotlib import cm
|
||||
from mpl_toolkits.mplot3d import Axes3D
|
||||
|
||||
|
||||
#a): Die Reichweite W erreicht ihr Maximum bei einem Winkel alpha = 45 Grad.
|
||||
|
||||
g = 9.81
|
||||
|
||||
v0_values = np.linspace(0, 100)
|
||||
alpha_deg_values = np.linspace(0, 90)
|
||||
|
||||
[v0_grid, alpha_deg_grid] = np.meshgrid(v0_values, alpha_deg_values)
|
||||
alpha_rad_grid = np.deg2rad(alpha_deg_grid)
|
||||
|
||||
W = (v0_grid**2) * np.sin(2 * alpha_rad_grid) / g
|
||||
|
||||
|
||||
fig = plt.figure(0)
|
||||
cont = plt.contour(v0_grid, alpha_deg_grid, W, cmap=cm.coolwarm)
|
||||
fig.colorbar(cont, shrink=0.5, aspect=5)
|
||||
plt.title('Wurfweite W(v0, α) – Höhenlinien')
|
||||
plt.xlabel('v0 [m/s]')
|
||||
plt.ylabel('α [deg]')
|
||||
plt.show()
|
||||
|
||||
|
||||
fig = plt.figure(1)
|
||||
ax = fig.add_subplot(111, projection='3d')
|
||||
surf = ax.plot_surface(v0_grid, alpha_deg_grid, W, cmap=cm.coolwarm, linewidth=0, antialiased=False)
|
||||
fig.colorbar(surf, shrink=0.5, aspect=5)
|
||||
plt.title('Wurfweite W(v0, α) – Oberfläche')
|
||||
ax.set_xlabel('v0 [m/s]')
|
||||
ax.set_ylabel('α [deg]')
|
||||
ax.set_zlabel('W [m]')
|
||||
plt.show()
|
||||
|
||||
|
||||
fig = plt.figure(2)
|
||||
ax = fig.add_subplot(111, projection='3d')
|
||||
ax.plot_wireframe(v0_grid, alpha_deg_grid, W, rstride=5, cstride=5)
|
||||
plt.title('Wurfweite W(v0, α) – Gitter')
|
||||
ax.set_xlabel('v0 [m/s]')
|
||||
ax.set_ylabel('α [deg]')
|
||||
ax.set_zlabel('W [m]')
|
||||
plt.show()
|
||||
|
||||
|
||||
|
||||
R = 8.31
|
||||
|
||||
|
||||
V_values = np.linspace(1e-6, 0.2)
|
||||
T_values = np.linspace(0, 1e4)
|
||||
|
||||
[V_grid, T_grid] = np.meshgrid(V_values, T_values)
|
||||
p = R * T_grid / V_grid
|
||||
|
||||
fig = plt.figure(3)
|
||||
cont = plt.contour(V_grid, T_grid, p, cmap=cm.coolwarm)
|
||||
fig.colorbar(cont, shrink=0.5, aspect=5)
|
||||
plt.title('p(V, T) = R T / V – Höhenlinien')
|
||||
plt.xlabel('V [m^3]')
|
||||
plt.ylabel('T [K]')
|
||||
plt.show()
|
||||
|
||||
|
||||
fig = plt.figure(4)
|
||||
ax = fig.add_subplot(111, projection='3d')
|
||||
surf = ax.plot_surface(V_grid, T_grid, p, cmap=cm.coolwarm, linewidth=0, antialiased=False)
|
||||
fig.colorbar(surf, shrink=0.5, aspect=5)
|
||||
plt.title('p(V, T) = R T / V – Oberfläche')
|
||||
ax.set_xlabel('V [m^3]')
|
||||
ax.set_ylabel('T [K]')
|
||||
ax.set_zlabel('p [N/m^2]')
|
||||
plt.show()
|
||||
|
||||
fig = plt.figure(5)
|
||||
ax = fig.add_subplot(111, projection='3d')
|
||||
ax.plot_wireframe(V_grid, T_grid, p, rstride=5, cstride=5)
|
||||
plt.title('p(V, T) = R T / V – Gitter')
|
||||
ax.set_xlabel('V [m^3]')
|
||||
ax.set_ylabel('T [K]')
|
||||
ax.set_zlabel('p [N/m^2]')
|
||||
plt.show()
|
||||
|
||||
|
||||
# 2)
|
||||
p_values = np.linspace(1e4, 1e5)
|
||||
T_values = np.linspace(0, 1e4)
|
||||
|
||||
[p_grid, T_grid] = np.meshgrid(p_values, T_values)
|
||||
V = R * T_grid / p_grid
|
||||
|
||||
|
||||
fig = plt.figure(6)
|
||||
cont = plt.contour(p_grid, T_grid, V, cmap=cm.coolwarm)
|
||||
fig.colorbar(cont, shrink=0.5, aspect=5)
|
||||
plt.title('V(p, T) = R T / p – Höhenlinien')
|
||||
plt.xlabel('p [N/m^2]')
|
||||
plt.ylabel('T [K]')
|
||||
plt.show()
|
||||
|
||||
|
||||
fig = plt.figure(7)
|
||||
ax = fig.add_subplot(111, projection='3d')
|
||||
surf = ax.plot_surface(p_grid, T_grid, V, cmap=cm.coolwarm, linewidth=0, antialiased=False)
|
||||
fig.colorbar(surf, shrink=0.5, aspect=5)
|
||||
plt.title('V(p, T) = R T / p – Oberfläche')
|
||||
ax.set_xlabel('p [N/m^2]')
|
||||
ax.set_ylabel('T [K]')
|
||||
ax.set_zlabel('V [m^3]')
|
||||
plt.show()
|
||||
|
||||
|
||||
fig = plt.figure(8)
|
||||
ax = fig.add_subplot(111, projection='3d')
|
||||
ax.plot_wireframe(p_grid, T_grid, V, rstride=5, cstride=5)
|
||||
plt.title('V(p, T) = R T / p – Gitter')
|
||||
ax.set_xlabel('p [N/m^2]')
|
||||
ax.set_ylabel('T [K]')
|
||||
ax.set_zlabel('V [m^3]')
|
||||
plt.show()
|
||||
|
||||
|
||||
# 3)
|
||||
p_values = np.linspace(1e4, 1e6)
|
||||
V_values = np.linspace(0, 10)
|
||||
|
||||
[p_grid, V_grid] = np.meshgrid(p_values, V_values)
|
||||
T = (p_grid * V_grid) / R
|
||||
|
||||
|
||||
fig = plt.figure(9)
|
||||
cont = plt.contour(p_grid, V_grid, T, cmap=cm.coolwarm)
|
||||
fig.colorbar(cont, shrink=0.5, aspect=5)
|
||||
plt.title('T(p, V) = p V / R – Höhenlinien')
|
||||
plt.xlabel('p [N/m^2]')
|
||||
plt.ylabel('V [m^3]')
|
||||
plt.show()
|
||||
|
||||
fig = plt.figure(10)
|
||||
ax = fig.add_subplot(111, projection='3d')
|
||||
surf = ax.plot_surface(p_grid, V_grid, T, cmap=cm.coolwarm, linewidth=0, antialiased=False)
|
||||
fig.colorbar(surf, shrink=0.5, aspect=5)
|
||||
plt.title('T(p, V) = p V / R – Oberfläche')
|
||||
ax.set_xlabel('p [N/m^2]')
|
||||
ax.set_ylabel('V [m^3]')
|
||||
ax.set_zlabel('T [K]')
|
||||
plt.show()
|
||||
|
||||
|
||||
fig = plt.figure(11)
|
||||
ax = fig.add_subplot(111, projection='3d')
|
||||
ax.plot_wireframe(p_grid, V_grid, T, rstride=5, cstride=5)
|
||||
plt.title('T(p, V) = p V / R – Gitter')
|
||||
ax.set_xlabel('p [N/m^2]')
|
||||
ax.set_ylabel('V [m^3]')
|
||||
ax.set_zlabel('T [K]')
|
||||
plt.show()
|
||||
BIN
Kuengjoe_S02/Kuengjoe_S02_Aufg1.pdf
Normal file
BIN
Kuengjoe_S02/Kuengjoe_S02_Aufg1.pdf
Normal file
Binary file not shown.
36
Kuengjoe_S02/Kuengjoe_S2_Aufg2.py
Normal file
36
Kuengjoe_S02/Kuengjoe_S2_Aufg2.py
Normal file
@@ -0,0 +1,36 @@
|
||||
import sympy as sp
|
||||
|
||||
x1, x2, x3 = sp.symbols("x1 x2 x3", real=True)
|
||||
|
||||
|
||||
f_a = sp.Matrix([
|
||||
5 * x1 * x2,
|
||||
x1**2 * x2**2 + x1 + 2 * x2
|
||||
])
|
||||
|
||||
D_f_a = f_a.jacobian(sp.Matrix([x1, x2]))
|
||||
D_f_a_at_point = D_f_a.subs({x1: 1, x2: 2})
|
||||
|
||||
print("D_f_a(x) =")
|
||||
sp.pprint(D_f_a)
|
||||
|
||||
|
||||
print("Aufgabe 2a:")
|
||||
|
||||
sp.pprint(D_f_a_at_point)
|
||||
|
||||
|
||||
f_b = sp.Matrix([
|
||||
sp.log(x1**2 + x2**2) + x3**2,
|
||||
sp.exp(x2**2 + x3**2) + x1**2,
|
||||
1 / (x3**2 + x1**2) + x2**2
|
||||
])
|
||||
|
||||
D_f_b = f_b.jacobian(sp.Matrix([x1, x2, x3]))
|
||||
D_f_b_at_point = D_f_b.subs({x1: 1, x2: 2, x3: 3})
|
||||
|
||||
print("\nD_f_b(x) =")
|
||||
sp.pprint(D_f_b)
|
||||
|
||||
print("\nAufgabe 2b:")
|
||||
sp.pprint(sp.simplify(D_f_b_at_point))
|
||||
43
Kuengjoe_S02/Kuengjoe_S2_Aufg3.py
Normal file
43
Kuengjoe_S02/Kuengjoe_S2_Aufg3.py
Normal file
@@ -0,0 +1,43 @@
|
||||
import sympy as sp
|
||||
|
||||
x1, x2, x3 = sp.symbols("x1 x2 x3", real=True)
|
||||
|
||||
x = sp.Matrix([x1, x2, x3])
|
||||
|
||||
f = sp.Matrix([
|
||||
x1 + x2**2 - x3**2 - 13,
|
||||
sp.log(x2 / 4) + sp.exp(sp.Rational(1, 2) * x3 - 1) - 1,
|
||||
(x2 - 3)**2 - x3**3 + 7
|
||||
])
|
||||
|
||||
x0 = sp.Matrix([
|
||||
sp.Rational(3, 2),
|
||||
3,
|
||||
sp.Rational(5, 2)
|
||||
])
|
||||
|
||||
substitution_dictionary = {
|
||||
x1: x0[0],
|
||||
x2: x0[1],
|
||||
x3: x0[2]
|
||||
}
|
||||
|
||||
function_value_at_x0 = f.subs(substitution_dictionary)
|
||||
jacobian_matrix = f.jacobian(x)
|
||||
jacobian_matrix_at_x0 = jacobian_matrix.subs(substitution_dictionary)
|
||||
|
||||
linearized_function = sp.simplify(
|
||||
function_value_at_x0 + jacobian_matrix_at_x0 * (x - x0)
|
||||
)
|
||||
|
||||
print("f(x0) =")
|
||||
sp.pprint(function_value_at_x0)
|
||||
|
||||
print("\nDf(x) =")
|
||||
sp.pprint(jacobian_matrix)
|
||||
|
||||
print("\nDf(x0) =")
|
||||
sp.pprint(jacobian_matrix_at_x0)
|
||||
|
||||
print("\nL(x) =")
|
||||
sp.pprint(linearized_function)
|
||||
16
main.py
Normal file
16
main.py
Normal file
@@ -0,0 +1,16 @@
|
||||
# This is a sample Python script.
|
||||
|
||||
# Press ⌃R to execute it or replace it with your code.
|
||||
# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings.
|
||||
|
||||
|
||||
def print_hi(name):
|
||||
# Use a breakpoint in the code line below to debug your script.
|
||||
print(f'Hi, {name}') # Press ⌘F8 to toggle the breakpoint.
|
||||
|
||||
|
||||
# Press the green button in the gutter to run the script.
|
||||
if __name__ == '__main__':
|
||||
print_hi('PyCharm')
|
||||
|
||||
# See PyCharm help at https://www.jetbrains.com/help/pycharm/
|
||||
Reference in New Issue
Block a user