mirror of https://github.com/E-Almqvist/hsf
parent
cc12437725
commit
02e3548c6b
@ -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 |
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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 |
||||
|
@ -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 = 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) |
||||
|
||||
self.energy = |
||||
return psi * time_factor |
||||
|
||||
|
||||
|
||||
|
@ -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) |
||||
|
||||
|
||||
|
Loading…
Reference in new issue