More superpos stuff

master
E. Almqvist 3 years ago
parent 02e3548c6b
commit 8522316370
  1. 32
      mas/shrodequ_superpos/main.py
  2. BIN
      mas/shrodequ_superpos/phys/__pycache__/particle.cpython-310.pyc
  3. BIN
      mas/shrodequ_superpos/phys/__pycache__/quantum_systems.cpython-310.pyc
  4. 20
      mas/shrodequ_superpos/phys/quantum_systems.py

@ -2,22 +2,26 @@
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import numpy as np import numpy as np
from phys import * from phys import *
from scipy.constants import electron_mass
quantum_system = box(0.001) # box with inf walls system = infbox(0.001) # box with inf walls
# x = np.arange(0, BOX_LENGTH, 0.00001) p1 = particle(electron_mass, system, 1)
# n = np.arange(1, 10, 1) p2 = particle(electron_mass, system, 2)
#
# X, N = np.meshgrid(x, n) x = np.arange(0, BOX_LENGTH, 0.00001)
# P = prob(X, N) t = np.arange(0, 1, 0.01)
#
# fig = plt.figure()
# ax = plt.axes(projection='3d')
# ax.plot_surface(X, N, P, rstride=1, cstride=1, cmap='viridis', edgecolor='none')
# ax.set_xlabel('x [m]')
# ax.set_ylabel('n [int]')
# ax.set_zlabel('probability [frac]');
# #
# plt.show() X, T = np.meshgrid(x, t)
P = system.get_superpos(X, T)
fig = plt.figure()
ax = plt.axes(projection='3d')
ax.plot_surface(X, N, P, rstride=1, cstride=1, cmap='viridis', edgecolor='none')
ax.set_xlabel('x [m]')
ax.set_ylabel('time [s]')
ax.set_zlabel('probability [frac]');
plt.show()

@ -1,4 +1,4 @@
from phys.particle import particle #from phys.particle import particle
import numpy as np import numpy as np
class quantum_system: class quantum_system:
@ -6,16 +6,26 @@ class quantum_system:
self.name = name self.name = name
self.particles = [] self.particles = []
def add_particle(particle: particle): def add_particle(self, particle):
self.particles.append(particle) self.particles.append(particle)
print(f"Added particle {particle} to quantum system '{self.name}'") print(f"Added particle {particle} to quantum system '{self.name}' ({self})")
class infbox(quantum_system): class infbox(quantum_system):
def __init__(self, length: float): def __init__(self, length: float):
super super().__init__("Inf Box")
self.name = "Inf Box"
self.length = length self.length = length
self.norm_factor = np.sqrt(2/self.length) self.norm_factor = np.sqrt(2/self.length)
def get_superpos(self, x: float, t: float) -> float:
waves = []
for part in self.particles:
waves.append( part.wave(x, t) )
superpos_wave = sum(waves)
# normalize the superpos #TODO: ?????
# superpos_wave *= 1/abs(superpos_wave)
return abs(superpos_wave) ** 2

Loading…
Cancel
Save