mirror of
https://gitlab.gwdg.de/j.hahn02/university.git
synced 2025-12-31 22:34:25 -05:00
week 25 of the year
This commit is contained in:
136
S2/AnaMech/other/Hahn_AM_9A5.py
Normal file
136
S2/AnaMech/other/Hahn_AM_9A5.py
Normal file
@@ -0,0 +1,136 @@
|
||||
# Blatt 9 Aufgabe 5
|
||||
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
# Const
|
||||
m1 = 1.0 # kg
|
||||
m2 = 1.0 # kg
|
||||
l = 1.0 # m
|
||||
g = 9.81 # m/s^2
|
||||
|
||||
# Params
|
||||
T = 30.0#s
|
||||
dt = 1e-4 # Timestep
|
||||
dt2 = 1e-5 # Timestep 2 (very long times)
|
||||
|
||||
# Initial conditions
|
||||
theta1_0 = np.pi / 2
|
||||
theta2_0 = np.pi
|
||||
omega1_0 = 0.0
|
||||
omega2_0 = 0.0
|
||||
|
||||
def a(theta, omega):
|
||||
# Unpack the params
|
||||
theta1, theta2 = theta
|
||||
omega1, omega2 = omega
|
||||
delta = theta1 - theta2
|
||||
|
||||
# Represent the equation in terms of M and Q
|
||||
# L, m1, m2 not used for the matrix equation ??
|
||||
# Do I need to use the result from task a) ?
|
||||
M = np.array([
|
||||
[2, np.cos(delta)],
|
||||
[np.cos(delta), 1]
|
||||
])
|
||||
Q = np.array([
|
||||
-omega2**2 * np.sin(delta) - 2 * g * np.sin(theta1),
|
||||
omega1**2 * np.sin(delta) - g * np.sin(theta2)
|
||||
])
|
||||
|
||||
# TODO: better method?
|
||||
return np.linalg.solve(M, Q) # Return the acc in a theta double dot vector
|
||||
|
||||
# Run the main simulation
|
||||
def run_simulation(theta0, omega0, dt):
|
||||
# Setup state arrays
|
||||
times = np.arange(0, T, dt)
|
||||
theta = np.zeros((len(times), 2))
|
||||
omega = np.zeros((len(times), 2))
|
||||
energy = np.zeros(len(times))
|
||||
|
||||
# Initialize
|
||||
theta[0] = theta0
|
||||
omega[0] = omega0
|
||||
acc = a(theta[0], omega[0])
|
||||
print(acc)
|
||||
|
||||
# Iterate
|
||||
for i in range(1, len(times)):
|
||||
# VV-step
|
||||
theta[i] = theta[i-1] + omega[i-1] * dt + 0.5 * acc * dt**2
|
||||
a_new = a(theta[i], omega[i-1])
|
||||
omega[i] = omega[i-1] + 0.5 * (acc + a_new) * dt
|
||||
acc = a_new
|
||||
|
||||
# Energy
|
||||
theta1, theta2 = theta[i]
|
||||
omega1, omega2 = omega[i]
|
||||
E_kin = 0.5 * m1 * (l * omega1)**2 + 0.5 * m2 * (
|
||||
(l * omega1)**2 + (l * omega2)**2 +
|
||||
2 * l**2 * omega1 * omega2 * np.cos(theta1 - theta2)
|
||||
)
|
||||
E_pot = - (m1 + m2) * g * l * np.cos(theta1) - m2 * g * l * np.cos(theta2)
|
||||
|
||||
# Save the total energy
|
||||
energy[i] = E_kin + E_pot
|
||||
|
||||
# Return timeline
|
||||
return times, theta, omega, energy
|
||||
|
||||
# Start simulation
|
||||
theta0 = [theta1_0, theta2_0]
|
||||
omega0 = [omega1_0, omega2_0]
|
||||
times, theta, _, energy = run_simulation(theta0, omega0, dt)
|
||||
|
||||
theta0 = [theta1_0 + 10 ** -7, theta2_0]
|
||||
omega0 = [omega1_0, omega2_0]
|
||||
_, theta2, _, _ = run_simulation(theta0, omega0, dt)
|
||||
|
||||
theta0 = [theta1_0, theta2_0]
|
||||
omega0 = [omega1_0, omega2_0]
|
||||
times3, theta3, _, energy3 = run_simulation(theta0, omega0, dt2) # Smaller timestep
|
||||
|
||||
# Quick plotting
|
||||
|
||||
# Energy
|
||||
plt.figure(figsize=(12, 6))
|
||||
plt.plot(times, energy, label='Total energy', color='blue')
|
||||
plt.plot(times3, energy3, label='Total energy smaller dt', color='blue', linestyle="--")
|
||||
plt.xlabel('Time [s]')
|
||||
plt.ylabel('Energy [J]')
|
||||
plt.title('Total energy of the double pendulum')
|
||||
plt.grid(True)
|
||||
plt.legend()
|
||||
plt.tight_layout()
|
||||
plt.savefig("double_energy.svg")
|
||||
|
||||
# Angles
|
||||
plt.figure(figsize=(12, 6))
|
||||
|
||||
# Reduce angles
|
||||
theta_mod = (theta + np.pi) % (2 * np.pi) - np.pi
|
||||
theta2_mod = (theta2 + np.pi) % (2 * np.pi) - np.pi
|
||||
|
||||
# Plot with module (less information)
|
||||
#plt.figure(figsize=(12, 6))
|
||||
#plt.plot(times, theta_mod[:, 0], label=r'$\theta_1(t)$', color='red')
|
||||
#plt.plot(times, theta_mod[:, 1], label=r'$\theta_2(t)$', color='green')
|
||||
#plt.plot(times, theta2_mod[:, 0], label=r'$\theta_1(t)$ (small change)', color='blue')
|
||||
#plt.plot(times, theta2_mod[:, 1], label=r'$\theta_2(t)$ (small change)', color='gold')
|
||||
|
||||
plt.plot(times, theta[:, 0] , label=r'$\theta_1(t)$', color='red')
|
||||
plt.plot(times, theta[:, 1] , label=r'$\theta_2(t)$', color='green')
|
||||
plt.plot(times3, theta3[:, 0] , label=r'$\theta_1(t)$ smaller dt', color='red', linestyle="--")
|
||||
plt.plot(times3, theta3[:, 1] , label=r'$\theta_2(t)$ smaller dt', color='green', linestyle="--")
|
||||
plt.plot(times, theta2[:, 0] , label=r'$\theta_1(t)$ changed', color='blue')
|
||||
plt.plot(times, theta2[:, 1] , label=r'$\theta_2(t)$ changed', color='yellow')
|
||||
|
||||
plt.xlabel('Time [s]')
|
||||
plt.ylabel('Angle [rad]')
|
||||
plt.title('Trajectories of both pendulums')
|
||||
plt.legend()
|
||||
plt.grid(True)
|
||||
plt.tight_layout()
|
||||
plt.savefig("double_angles.svg")
|
||||
|
||||
@@ -9,7 +9,7 @@ plt.semilogy(theta*180/np.pi, cs)
|
||||
plt.xlabel(r"Streuwinkel $\theta$ [deg]")
|
||||
plt.ylabel(r"$\csc^4(\theta/2)$")
|
||||
plt.title("Differentieller Wirkungsquerschnitt für $U(r) = \\alpha/r^2$")
|
||||
plt.show()
|
||||
plt.savefig("querschnitt.svg")
|
||||
|
||||
# Task
|
||||
# Calculate the differential Wirkungsquerschnitt ds/dOm fuer das repulsive
|
||||
|
||||
18
S2/AnaMech/other/Makefile
Normal file
18
S2/AnaMech/other/Makefile
Normal file
@@ -0,0 +1,18 @@
|
||||
9:
|
||||
cd build && python ../Hahn_AM_9A5.py
|
||||
|
||||
5:
|
||||
cd build && python ../Hahn_Blatt5A5.py
|
||||
|
||||
fir:
|
||||
cd build && python ../Hahn_AM_EX5.py
|
||||
|
||||
nix:
|
||||
nix-shell
|
||||
|
||||
t:
|
||||
typst compile --root ../../.. AnaMech_Hahn_Penning_Zettel_1.typ build/Zettel1.pdf
|
||||
|
||||
clean:
|
||||
rm -rf build/
|
||||
|
||||
3894
S2/AnaMech/other/build/double_angles.svg
Normal file
3894
S2/AnaMech/other/build/double_angles.svg
Normal file
File diff suppressed because it is too large
Load Diff
|
After Width: | Height: | Size: 97 KiB |
1472
S2/AnaMech/other/build/double_energy.svg
Normal file
1472
S2/AnaMech/other/build/double_energy.svg
Normal file
File diff suppressed because it is too large
Load Diff
|
After Width: | Height: | Size: 36 KiB |
1254
S2/AnaMech/other/build/querschnitt.svg
Normal file
1254
S2/AnaMech/other/build/querschnitt.svg
Normal file
File diff suppressed because it is too large
Load Diff
|
After Width: | Height: | Size: 33 KiB |
29
S2/DiffII/VL/DiIIVL14.typ
Normal file
29
S2/DiffII/VL/DiIIVL14.typ
Normal file
@@ -0,0 +1,29 @@
|
||||
// Main VL template
|
||||
#import "../preamble.typ": *
|
||||
|
||||
// Fix theorems to be shown the right way in this document
|
||||
#import "@preview/ctheorems:1.1.3": *
|
||||
#show: thmrules
|
||||
|
||||
// Main settings call
|
||||
#show: conf.with(
|
||||
// May add more flags here in the future
|
||||
num: 5,
|
||||
type: 0, // 0 normal, 1 exercise
|
||||
date: datetime.today().display(),
|
||||
//date: datetime(
|
||||
// year: 2025,
|
||||
// month: 5,
|
||||
// day: 1,
|
||||
//).display(),
|
||||
)
|
||||
|
||||
= Uebersicht
|
||||
|
||||
#theorem[
|
||||
Sei $U subset RR^n times RR^n $ offen, $(a,b) in U, f: U -> RR^n $ stetig diffbar mit $f (a,b) = 0$ und $det (partial_(y) f^(i) )_(1 <= i, j <= n) .. (a,b) != 0 $. Dann gibt es eine difbare Funnktion $g: U' -> U''$ sodass gilt
|
||||
$
|
||||
f (x,y) = 0 "fuer ein " x in U', y in U'' <=> y = g (x).
|
||||
$
|
||||
]
|
||||
|
||||
126
S2/ExPhyII/VL/ExIIVL16.typ
Normal file
126
S2/ExPhyII/VL/ExIIVL16.typ
Normal file
@@ -0,0 +1,126 @@
|
||||
// Main VL template
|
||||
#import "../preamble.typ": *
|
||||
|
||||
// Fix theorems to be shown the right way in this document
|
||||
#import "@preview/ctheorems:1.1.3": *
|
||||
#show: thmrules
|
||||
|
||||
// Main settings call
|
||||
#show: conf.with(
|
||||
// May add more flags here in the future
|
||||
num: 16,
|
||||
type: 0, // 0 normal, 1 exercise
|
||||
date: datetime.today().display(),
|
||||
//date: datetime(
|
||||
// year: 2025,
|
||||
// month: 5,
|
||||
// day: 1,
|
||||
//).display(),
|
||||
)
|
||||
|
||||
E: 18.06.2025
|
||||
|
||||
= Magnetfelder einer Spule
|
||||
|
||||
Es gilt fuer den Laplace-Operator
|
||||
$
|
||||
Delta arrow(A) = - mu_0 arrow(j) \
|
||||
Delta = arrow(nabla) ^2 = (partial_ (x) ^2 + partial_(y) + partial_(z) ^2 ) \
|
||||
=> Delta arrow(A) = vec(partial_(x) ^2 A_(x) + partial_(y) ^2 A_(x) + partial_(z) ^2 A_(x), partial_(x) ^2 A_(y) + partial_(y) ^2 A_(y) + partial_(z) ^2 A_(y), partial_(x) ^2 A_(z) + partial_(y) ^2 A_(z) + partial_(z) ^2 A_(z)) \
|
||||
Delta f = (partial_(x) ^2 + partial_(y) ^2 + partial_(z) ^2 )f = arrow(nabla) (arrow(nabla) f).
|
||||
$
|
||||
|
||||
Fuer eine Ampere'sche Schleife gilt
|
||||
$
|
||||
integral.cont arrow(B) d arrow(s) = integral_(a)^(b) arrow(B) d arrow(s) + integral_(c)^(d) arrow(B) d arrow(s) \
|
||||
= (B_1 - B_2 ) L = mu_0 I = 0 \
|
||||
=> B_1 = B_2.
|
||||
$
|
||||
Bei unendlich langen Spulen ist das Magnetfeld aussen gleich Null.
|
||||
In der gegebenen Abbildung ist doch nur eine kleine Spule dargestellt.
|
||||
|
||||
=== 3.4.1 Realisierung homogener Magnetfelder
|
||||
|
||||
Ausserhalb einer Spule kann ein homogenes Magnetfeld durch ein Helmholtzspulenpaar erstellt werden. Dazu siehe die Abbildung.
|
||||
|
||||
=== 3.4.2 Magnetfeld einer beliebigen Stromverteilung
|
||||
|
||||
Das Amperesche Gesetz fuer stationare Stroeme ist eimmer gueltig, aber nur in speziellen Situationen anwendbar.
|
||||
Dies gilt nur wenn $B$ vor das Integral gezogen werden kann, z.B. in einem unendlich langen Leiter.
|
||||
Ansonsten benoetigen wir einen allgemeinen Zusammenhang zwischen Strom und Magnetfeld.
|
||||
Allgemeine gilt die Gleichung
|
||||
$
|
||||
Delta arrow(A) = - mu_0 arrow(j).
|
||||
$
|
||||
Diese kann mittels der Green-Funktion geloest werden.
|
||||
|
||||
#theorem[
|
||||
Biot-Savart Gesetz.
|
||||
|
||||
Es gilt
|
||||
|
||||
$
|
||||
arrow(A) (arrow(r)) = (mu_0 ) / (4 pi) integral (arrow(j) (arrow(r)')) / (abs(arrow(r)- arrow(r)')) d V'.
|
||||
$
|
||||
Aequivalent gilt dann durch $arrow(B) = arrow(nabla) times arrow(A)$
|
||||
$
|
||||
arrow(B) (arrow(r)) = (mu_0) / (4 pi) integral (arrow(j) (arrow(r)') times (arrow(r)- arrow(r)')) / (abs(arrow(r) - arrow(r)')^3 ) d V'.
|
||||
$
|
||||
] <bio>
|
||||
|
||||
Dieses Gesetz in @bio kann vereinfacht werden, falls der Strom nur in einem duennen linienfoermigen Leiter fliesst, zu
|
||||
$
|
||||
arrow(B) (arrow(r)) = (mu_0 I) / (4 pi) integral ((d arrow(l) times hat(r))) / (r^2 ).
|
||||
$
|
||||
Hier gilt also
|
||||
$
|
||||
integral arrow(j) * d V' = integral d arrow(s)' underbrace(integral arrow(j) * d A', = I) = I integral d arrow(s)'.
|
||||
$
|
||||
#remark[
|
||||
Das Biot-Savart Gesetz gilt _nicht_ fuer einzeln bewegte Ladungen, da es nur fuer stationaere Stroeme gilt.
|
||||
]
|
||||
|
||||
=== 3.4.3 Anwendung des Biot-Savart Gesetzes
|
||||
|
||||
Dies erfolgt am Beispiel einer kreisfoermigen Stromschleife.
|
||||
Die Berechnung erfolgt nur fuer Punkte auf der Symetrieachse, da es anderswo komplizierter ist.
|
||||
|
||||
Zunaechst betrachten wir
|
||||
$
|
||||
integral (d arrow(s)' times (arrow(r) - arrow(r)')) / (abs(arrow(r)- arrow(r)')^3 ) \
|
||||
arrow(r) = z * hat(z) \
|
||||
arrow(r) - arrow(r)' = vec(0, 0, z) - a vec(cos phi, sin phi, 0) = vec(-a cos phi, - a sin phi, z) \
|
||||
d arrow(s)' = a * d phi * hat(phi) \
|
||||
hat(phi) = vec(- sin phi, cos phi, 0)
|
||||
=> d arrow(s)' = a * d phi * vec(- sin phi, cos phi, 0).
|
||||
$
|
||||
Dadurch folgt durch zusammensetzen
|
||||
$
|
||||
d arrow(s)' times (arrow(r) - arrow(r)') = a d phi vec(- sin phi, cos phi, 0) times vec(-a cos phi, -a sin phi, z) = a * d phi * vec(z cos phi, z sin phi, a).
|
||||
$
|
||||
Berechne $B_(x) , B_(y) , B_(z) $ einzeln
|
||||
$
|
||||
B_(x) = (mu_0 I) / (4 pi) integral _(0) ^(2 pi) (z cos phi * a * d phi) / (a ^2 + z ^2) ^(3/2) =^("Integral") 0 \
|
||||
|
||||
=> ^("Rotationssymetrie") B_(y) = 0.
|
||||
$
|
||||
Betrachte die $B_(z) $ Komponente des Kreuzproduktes und berechne
|
||||
$
|
||||
B_(z) = (mu_0 I ) / ( 4 pi) integral_(0)^(2 pi) (a^2 * d phi ) / ((a^2 + z^2 )^(3/2) ) = 1/2 mu_0 I (a^2 ) / ((a^2 + z^2 )^(3/2) ).
|
||||
$
|
||||
Fuer $z >> a$ ergibt sich dann
|
||||
$
|
||||
B_(z) approx 1/2 mu_0 I a^2 /z^3.
|
||||
$
|
||||
Dies laesst sich mit der Kreisflaeche des Leiters $arrow(A) = pi a ^2 hat(z)$ umformen zu
|
||||
$
|
||||
arrow(B) = mu_0/(2 pi) (I arrow(A)) / (z^3 ),
|
||||
$
|
||||
wobei $arrow(A)$ hier natuerlich nicht das Vektorpotential ist. Die Groesse $arrow(p)_(m) = I arrow(A)$
|
||||
wird magnetisches Dipolmoment genannt, hier also das einer Stromschleife. $arrow(A)$ ist hier wieder die Flaeche. Es folgt also fuer die Naeherung
|
||||
$
|
||||
arrow(B) = (mu_0 arrow(p)_(m) ) / (2 pi z^3 ).
|
||||
$
|
||||
Der Strom selber ist ein Skalar und die Stromdichte ist eine Vektorielle Groesse.
|
||||
Die Vektorielle Groesse kann mittels der Eigenschaft eines nicht ausgerichteten Stroms eliminiert werden.
|
||||
|
||||
22
S2/Neuro/VL/NeuroVL8.typ
Normal file
22
S2/Neuro/VL/NeuroVL8.typ
Normal file
@@ -0,0 +1,22 @@
|
||||
// Main VL template
|
||||
#import "../preamble.typ": *
|
||||
|
||||
// Fix theorems to be shown the right way in this document
|
||||
#import "@preview/ctheorems:1.1.3": *
|
||||
#show: thmrules
|
||||
|
||||
// Main settings call
|
||||
#show: conf.with(
|
||||
// May add more flags here in the future
|
||||
num: 8,
|
||||
type: 0, // 0 normal, 1 exercise
|
||||
date: datetime.today().display(),
|
||||
//date: datetime(
|
||||
// year: 2025,
|
||||
// month: 5,
|
||||
// day: 1,
|
||||
//).display(),
|
||||
)
|
||||
|
||||
= Uebersicht
|
||||
|
||||
Reference in New Issue
Block a user