More errors

master
E. Almqvist 3 years ago
parent 08ee4d429a
commit c2e56926d7
  1. 5
      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. 7
      mas/shrodequ_superpos/phys/particle.py
  5. 11
      mas/shrodequ_superpos/phys/quantum_systems.py

@ -11,13 +11,12 @@ p2 = particle(electron_mass, system, 2)
x = np.arange(0, BOX_LENGTH, 0.00001)
t = np.arange(0, 1, 0.01)
#
X, T = np.meshgrid(x, t)
P = system.get_superpos(X, T)
P = system.plot_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.plot_surface(X, T, P, rstride=1, cstride=1, cmap='viridis', edgecolor='none')
ax.set_xlabel('x [m]')
ax.set_ylabel('time [s]')
ax.set_zlabel('probability [frac]');

@ -1,4 +1,3 @@
from phys.func import psi, prob
from phys.const import energy, psi_k
from phys.quantum_systems import *
@ -21,13 +20,13 @@ class particle:
self.system.add_particle(self)
def psi(self, x: float):
def psi(self, x):
return self.system.norm_factor * np.sin(self.psi_k * x)
def wave(self, x: float, time: float) -> complex:
def wave(self, x, time) -> complex:
z_coef = -( (2*np.pi*self.energy*time)/Planck ) # exponent coef
z = complex(0, z_coef) # full coef (complex)
time_factor = cmath.exp(z) # TODO: cmath.exp is weird, verify...
time_factor = cmath.exp(z)
psi = self.system.norm_factor * np.sin(self.psi_k * x)
return psi * time_factor

@ -16,7 +16,7 @@ class infbox(quantum_system):
self.length = length
self.norm_factor = np.sqrt(2/self.length)
def get_superpos(self, x: float, t: float) -> float:
def get_superpos(self, x, t) -> float:
waves = []
for part in self.particles:
waves.append( part.wave(x, t) )
@ -25,7 +25,16 @@ class infbox(quantum_system):
# normalize the superpos #TODO: ?????
# superpos_wave *= 1/abs(superpos_wave)
# superpos_wave = np.exp(superpos_wave)
return abs(superpos_wave) ** 2
def plot_superpos(self, X, T):
plots = {}
for x in X:
for t in T:
plots[(x, t)] = self.get_superpos(x, t)
return plots

Loading…
Cancel
Save