mirror of https://github.com/E-Almqvist/hsf
parent
2099f715c9
commit
cc12437725
Binary file not shown.
Binary file not shown.
@ -0,0 +1,21 @@ |
|||||||
|
#!/usr/bin/python3 |
||||||
|
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) |
||||||
|
|
||||||
|
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() |
||||||
|
|
||||||
|
|
@ -0,0 +1,4 @@ |
|||||||
|
from phys.func import * |
||||||
|
from phys.const import * |
||||||
|
from phys.box import box |
||||||
|
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.
@ -0,0 +1,9 @@ |
|||||||
|
from phys.particle import particle |
||||||
|
|
||||||
|
class box: |
||||||
|
def __init__(self, length: float): |
||||||
|
self.length = length |
||||||
|
|
||||||
|
def add_particle(pobj: particle): |
||||||
|
pass |
||||||
|
|
@ -0,0 +1,26 @@ |
|||||||
|
import numpy as np |
||||||
|
from scipy.constants import Planck, electron_mass |
||||||
|
|
||||||
|
# constants |
||||||
|
BOX_LENGTH = 0.01 # box length (meters) |
||||||
|
h = Planck # plancks constant |
||||||
|
|
||||||
|
D = np.sqrt(2/BOX_LENGTH) # norm factor |
||||||
|
m = electron_mass # mass |
||||||
|
|
||||||
|
# total energy function |
||||||
|
def energy(n): |
||||||
|
return (((h*n)/BOX_LENGTH)**2)*(1/(8*m)) |
||||||
|
|
||||||
|
# Wave func inner coef |
||||||
|
def k(n): |
||||||
|
return np.sqrt( (8 * ((np.pi)**2) * m * energy(n))/(h**2) ) |
||||||
|
|
||||||
|
# pre calculate energy states |
||||||
|
energy_states = [] |
||||||
|
for n in range(0, 11): |
||||||
|
energy_states.append( energy(n) ) |
||||||
|
|
||||||
|
psi_k = [] |
||||||
|
for n in range(0, 11): |
||||||
|
psi_k.append( k(n) ) |
@ -0,0 +1,17 @@ |
|||||||
|
import cmath |
||||||
|
import numpy as np |
||||||
|
from phys.const import * |
||||||
|
|
||||||
|
# wave function |
||||||
|
def psi(x, n) -> float: |
||||||
|
return D * np.sin( k(n) * x ) |
||||||
|
|
||||||
|
def psi_opt(x, n) -> float: # optimized version |
||||||
|
return D * np.sin( psi_k[n] * x ) |
||||||
|
|
||||||
|
# probability density function |
||||||
|
def prob(x, n) -> float: |
||||||
|
return (psi(x, n))**2 |
||||||
|
|
||||||
|
def prob_opt(x, n) -> float: # optimized version |
||||||
|
return abs(psi_opt(x,n)) ** 2 |
@ -0,0 +1,11 @@ |
|||||||
|
from phys.func import psi, prob, E |
||||||
|
|
||||||
|
class particle: |
||||||
|
def __init__(self, mass: float, n_state: int): |
||||||
|
self.mass = mass |
||||||
|
self.n_state = n_state |
||||||
|
|
||||||
|
self.energy = |
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in new issue