Old high school files. Lessson notes/codes/projects etc.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hsf/mas/shrodequ_superpos/phys/particle.py

36 lines
1.1 KiB

from phys.const import energy, psi_k
from phys.quantum_systems import *
import numpy as np
import cmath
from scipy.constants import Planck
3 years ago
class particle:
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
3 years ago
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)
3 years ago
def psi(self, x):
return self.system.norm_factor * np.sin(self.psi_k * x)
3 years ago
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)
3 years ago
time_factor = cmath.exp(z)
psi = self.system.norm_factor * np.sin(self.psi_k * x)
return psi * time_factor
3 years ago