diff --git a/mas/shrodequ_superpos/main.py b/mas/shrodequ_superpos/main.py index d05a823..fac4444 100755 --- a/mas/shrodequ_superpos/main.py +++ b/mas/shrodequ_superpos/main.py @@ -3,19 +3,21 @@ import matplotlib.pyplot as plt import numpy as np from phys import * -x = np.arange(0, BOX_LENGTH, 0.00001) -n = np.arange(1, 10, 1) +quantum_system = box(0.001) # box with inf walls -X, N = np.meshgrid(x, n) -P = prob(X, N) - -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 = np.arange(0, BOX_LENGTH, 0.00001) +# n = np.arange(1, 10, 1) +# +# X, N = np.meshgrid(x, n) +# P = prob(X, N) +# +# 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() diff --git a/mas/shrodequ_superpos/phys/__init__.py b/mas/shrodequ_superpos/phys/__init__.py index 24de9b4..0453745 100644 --- a/mas/shrodequ_superpos/phys/__init__.py +++ b/mas/shrodequ_superpos/phys/__init__.py @@ -1,4 +1,4 @@ from phys.func import * from phys.const import * -from phys.box import box +from phys.quantum_systems import * from phys.particle import particle diff --git a/mas/shrodequ_superpos/phys/__pycache__/__init__.cpython-310.pyc b/mas/shrodequ_superpos/phys/__pycache__/__init__.cpython-310.pyc index 95dbd8d..4dc7702 100644 Binary files a/mas/shrodequ_superpos/phys/__pycache__/__init__.cpython-310.pyc and b/mas/shrodequ_superpos/phys/__pycache__/__init__.cpython-310.pyc differ diff --git a/mas/shrodequ_superpos/phys/__pycache__/const.cpython-310.pyc b/mas/shrodequ_superpos/phys/__pycache__/const.cpython-310.pyc index ff4b286..d292ebc 100644 Binary files a/mas/shrodequ_superpos/phys/__pycache__/const.cpython-310.pyc and b/mas/shrodequ_superpos/phys/__pycache__/const.cpython-310.pyc differ diff --git a/mas/shrodequ_superpos/phys/__pycache__/func.cpython-310.pyc b/mas/shrodequ_superpos/phys/__pycache__/func.cpython-310.pyc index fc4dc39..475579c 100644 Binary files a/mas/shrodequ_superpos/phys/__pycache__/func.cpython-310.pyc and b/mas/shrodequ_superpos/phys/__pycache__/func.cpython-310.pyc differ diff --git a/mas/shrodequ_superpos/phys/__pycache__/particle.cpython-310.pyc b/mas/shrodequ_superpos/phys/__pycache__/particle.cpython-310.pyc index 28d76dc..6e78f4b 100644 Binary files a/mas/shrodequ_superpos/phys/__pycache__/particle.cpython-310.pyc and b/mas/shrodequ_superpos/phys/__pycache__/particle.cpython-310.pyc differ diff --git a/mas/shrodequ_superpos/phys/__pycache__/quantum_systems.cpython-310.pyc b/mas/shrodequ_superpos/phys/__pycache__/quantum_systems.cpython-310.pyc new file mode 100644 index 0000000..97b024b Binary files /dev/null and b/mas/shrodequ_superpos/phys/__pycache__/quantum_systems.cpython-310.pyc differ diff --git a/mas/shrodequ_superpos/phys/box.py b/mas/shrodequ_superpos/phys/box.py deleted file mode 100644 index 4b0f2fb..0000000 --- a/mas/shrodequ_superpos/phys/box.py +++ /dev/null @@ -1,9 +0,0 @@ -from phys.particle import particle - -class box: - def __init__(self, length: float): - self.length = length - - def add_particle(pobj: particle): - pass - diff --git a/mas/shrodequ_superpos/phys/const.py b/mas/shrodequ_superpos/phys/const.py index f1b529b..4afbd48 100644 --- a/mas/shrodequ_superpos/phys/const.py +++ b/mas/shrodequ_superpos/phys/const.py @@ -13,14 +13,14 @@ def energy(n): return (((h*n)/BOX_LENGTH)**2)*(1/(8*m)) # Wave func inner coef -def k(n): +def psi_k(n): return np.sqrt( (8 * ((np.pi)**2) * m * energy(n))/(h**2) ) # pre calculate energy states -energy_states = [] +energy_def = [] for n in range(0, 11): - energy_states.append( energy(n) ) + energy_def.append( energy(n) ) -psi_k = [] +psi_k_def = [] for n in range(0, 11): - psi_k.append( k(n) ) + psi_k_def.append( psi_k(n) ) diff --git a/mas/shrodequ_superpos/phys/func.py b/mas/shrodequ_superpos/phys/func.py index a63247e..34c139e 100644 --- a/mas/shrodequ_superpos/phys/func.py +++ b/mas/shrodequ_superpos/phys/func.py @@ -1,4 +1,3 @@ -import cmath import numpy as np from phys.const import * diff --git a/mas/shrodequ_superpos/phys/particle.py b/mas/shrodequ_superpos/phys/particle.py index 72db7a5..868d8d6 100644 --- a/mas/shrodequ_superpos/phys/particle.py +++ b/mas/shrodequ_superpos/phys/particle.py @@ -1,11 +1,36 @@ -from phys.func import psi, prob, E +from phys.func import psi, prob +from phys.const import energy, psi_k +from phys.quantum_systems import * + +import numpy as np +import cmath +from scipy.constants import Planck class particle: - def __init__(self, mass: float, n_state: int): - self.mass = mass - self.n_state = n_state + def __init__(self, mass: float, system: infbox, n_state: int=1): + if n_state < 1: + print(f"Particle energy state index must be 1 or more! {n_state=}") + return + + self.mass = mass # particle mass + self.n_state = n_state # energy state index + self.system = system # quantum system - self.energy = + self.energy = energy(self.n_state) # total energy "for" the particle + self.psi_k = psi_k(self.n_state) # wave function coeff- + + self.system.add_particle(self) + + def psi(self, x: float): + return self.system.norm_factor * np.sin(self.psi_k * x) + + def wave(self, x: float, time: float) -> 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... + psi = self.system.norm_factor * np.sin(self.psi_k * x) + + return psi * time_factor diff --git a/mas/shrodequ_superpos/phys/quantum_systems.py b/mas/shrodequ_superpos/phys/quantum_systems.py new file mode 100644 index 0000000..bf31a46 --- /dev/null +++ b/mas/shrodequ_superpos/phys/quantum_systems.py @@ -0,0 +1,21 @@ +from phys.particle import particle +import numpy as np + +class quantum_system: + def __init__(self, name: str): + self.name = name + self.particles = [] + + def add_particle(particle: particle): + self.particles.append(particle) + print(f"Added particle {particle} to quantum system '{self.name}'") + +class infbox(quantum_system): + def __init__(self, length: float): + super + self.name = "Inf Box" + self.length = length + self.norm_factor = np.sqrt(2/self.length) + + +