Solve HM2 exercise
This commit is contained in:
parent
61f4cd61d3
commit
f0b4559954
|
@ -0,0 +1,84 @@
|
||||||
|
# %%
|
||||||
|
from numpy import pi, sin
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
from IPython import get_ipython
|
||||||
|
|
||||||
|
def draw3D(x, y, z, title, xlabel, ylabel, zlabel):
|
||||||
|
fig = plt.figure()
|
||||||
|
|
||||||
|
surface = fig.add_subplot(projection="3d")
|
||||||
|
plot = surface.plot_surface(x, y, z, cmap="rainbow")
|
||||||
|
fig.colorbar(plot, shrink=0.5, aspect=5)
|
||||||
|
|
||||||
|
fig = plt.figure()
|
||||||
|
wireframe = fig.add_subplot(projection="3d")
|
||||||
|
wireframe.plot_wireframe(x, y, z)
|
||||||
|
|
||||||
|
for axes in [surface, wireframe]:
|
||||||
|
axes.set_title(title)
|
||||||
|
axes.set_xlabel(xlabel)
|
||||||
|
axes.set_ylabel(ylabel)
|
||||||
|
axes.set_zlabel(zlabel)
|
||||||
|
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
def drawContour(x, y, z, title, xlabel, ylabel):
|
||||||
|
fig = plt.figure()
|
||||||
|
axes = fig.add_subplot()
|
||||||
|
plot = axes.contour(x, y, z, cmap="rainbow")
|
||||||
|
fig.colorbar(plot, shrink=0.5, aspect=5)
|
||||||
|
axes.set_title(title)
|
||||||
|
axes.set_xlabel(xlabel)
|
||||||
|
axes.set_ylabel(ylabel)
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
def drawPlots(x, y, z, title, xlabel, ylabel, zlabel):
|
||||||
|
draw3D(x, y, z, title, xlabel, ylabel, zlabel)
|
||||||
|
drawContour(x, y, z, title, xlabel, ylabel)
|
||||||
|
|
||||||
|
# %%
|
||||||
|
g = 9.81
|
||||||
|
|
||||||
|
def W(v, a):
|
||||||
|
return ((v ** 2) * sin(a * 2)) / g
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
[v, a] = np.meshgrid(np.linspace(0, 100), np.linspace(0, pi / 2))
|
||||||
|
z = W(v, a)
|
||||||
|
|
||||||
|
get_ipython().run_cell("%matplotlib widget")
|
||||||
|
drawPlots(v, a, z, "Wurfdistanz", "v_0", "alpha", "W")
|
||||||
|
# %%
|
||||||
|
|
||||||
|
R = 3.81
|
||||||
|
|
||||||
|
def calcP(V, T):
|
||||||
|
return (R * T) / V
|
||||||
|
|
||||||
|
def calcV(p, T):
|
||||||
|
return (R * T) / p
|
||||||
|
|
||||||
|
def calcT(p, V):
|
||||||
|
return (p * V) / R
|
||||||
|
|
||||||
|
# %%
|
||||||
|
|
||||||
|
[V, T] = np.meshgrid(np.linspace(0, 0.2), np.linspace(0, 10 ** 4))
|
||||||
|
p = calcP(V, T)
|
||||||
|
|
||||||
|
drawPlots(V, T, p, "Druck", "V", "T", "p")
|
||||||
|
|
||||||
|
# %%
|
||||||
|
|
||||||
|
[p, T] = np.meshgrid(np.linspace(10 ** 4, 10 ** 5), np.linspace(0, 10 ** 4))
|
||||||
|
V = calcV(p, T)
|
||||||
|
drawPlots(p, T, V, "Volumen", "p", "T", "V")
|
||||||
|
|
||||||
|
# %%
|
||||||
|
|
||||||
|
[p, V] = np.meshgrid(np.linspace(10 ** 4, 10 ** 6), np.linspace(0, 10))
|
||||||
|
T = calcT(p, V)
|
||||||
|
drawPlots(p, V, T, "Temperatur in K°", "p", "V", "T")
|
||||||
|
|
||||||
|
# %%
|
1
Pipfile
1
Pipfile
|
@ -11,6 +11,7 @@ scipy = "*"
|
||||||
pexpect = "*"
|
pexpect = "*"
|
||||||
pandas = "*"
|
pandas = "*"
|
||||||
ipympl = "*"
|
ipympl = "*"
|
||||||
|
sympy = "*"
|
||||||
|
|
||||||
[dev-packages]
|
[dev-packages]
|
||||||
|
|
||||||
|
|
17
Pipfile.lock
generated
17
Pipfile.lock
generated
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"_meta": {
|
"_meta": {
|
||||||
"hash": {
|
"hash": {
|
||||||
"sha256": "feb57859ef42912639d544346f6a70df45acd233855c030f52a04d4069257a88"
|
"sha256": "8c86c6849809fd6594aed0bf17bcfecc16e4e0e68b7949900346649d7b23c60a"
|
||||||
},
|
},
|
||||||
"pipfile-spec": 6,
|
"pipfile-spec": 6,
|
||||||
"requires": {
|
"requires": {
|
||||||
|
@ -353,6 +353,13 @@
|
||||||
"markers": "python_version >= '3.5'",
|
"markers": "python_version >= '3.5'",
|
||||||
"version": "==0.1.6"
|
"version": "==0.1.6"
|
||||||
},
|
},
|
||||||
|
"mpmath": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:604bc21bd22d2322a177c73bdb573994ef76e62edd595d17e00aff24b0667e5c",
|
||||||
|
"sha256:79ffb45cf9f4b101a807595bcb3e72e0396202e0b1d25d689134b48c4216a81a"
|
||||||
|
],
|
||||||
|
"version": "==1.2.1"
|
||||||
|
},
|
||||||
"nest-asyncio": {
|
"nest-asyncio": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:b9a953fb40dceaa587d109609098db21900182b16440652454a146cffb06e8b8",
|
"sha256:b9a953fb40dceaa587d109609098db21900182b16440652454a146cffb06e8b8",
|
||||||
|
@ -747,6 +754,14 @@
|
||||||
],
|
],
|
||||||
"version": "==0.6.2"
|
"version": "==0.6.2"
|
||||||
},
|
},
|
||||||
|
"sympy": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:938f984ee2b1e8eae8a07b884c8b7a1146010040fccddc6539c54f401c8f6fcf",
|
||||||
|
"sha256:e32380dce63cb7c0108ed525570092fd45168bdae2faa17e528221ef72e88658"
|
||||||
|
],
|
||||||
|
"index": "pypi",
|
||||||
|
"version": "==1.11.1"
|
||||||
|
},
|
||||||
"tornado": {
|
"tornado": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:1d54d13ab8414ed44de07efecb97d4ef7c39f7438cf5e976ccd356bebb1b5fca",
|
"sha256:1d54d13ab8414ed44de07efecb97d4ef7c39f7438cf5e976ccd356bebb1b5fca",
|
||||||
|
|
Loading…
Reference in a new issue