From 02e3548c6b74906e08049eb3b2bdc6006ee5b48a Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Thu, 31 Mar 2022 10:18:14 +0200 Subject: [PATCH] Quantum systems and classes --- mas/shrodequ_superpos/main.py | 28 +++++++------- mas/shrodequ_superpos/phys/__init__.py | 2 +- .../phys/__pycache__/__init__.cpython-310.pyc | Bin 294 -> 290 bytes .../phys/__pycache__/const.cpython-310.pyc | Bin 771 -> 781 bytes .../phys/__pycache__/func.cpython-310.pyc | Bin 777 -> 760 bytes .../phys/__pycache__/particle.cpython-310.pyc | Bin 559 -> 1459 bytes .../quantum_systems.cpython-310.pyc | Bin 0 -> 1222 bytes mas/shrodequ_superpos/phys/box.py | 9 ----- mas/shrodequ_superpos/phys/const.py | 10 ++--- mas/shrodequ_superpos/phys/func.py | 1 - mas/shrodequ_superpos/phys/particle.py | 35 +++++++++++++++--- mas/shrodequ_superpos/phys/quantum_systems.py | 21 +++++++++++ 12 files changed, 72 insertions(+), 34 deletions(-) create mode 100644 mas/shrodequ_superpos/phys/__pycache__/quantum_systems.cpython-310.pyc delete mode 100644 mas/shrodequ_superpos/phys/box.py create mode 100644 mas/shrodequ_superpos/phys/quantum_systems.py 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 95dbd8dfc5a61aab28f202c8d9fd0e19ea90bb3d..4dc77025e5f704d90e4ab152f954015ab71da9e0 100644 GIT binary patch delta 155 zcmZ3+w1|l}pO=@50SJ%>t*B3=jG*M0D?17u1W42d3zbz*;4aTi_$A6&taU-%34sI89&*CDN&0HA{w8P kns$q|C^0WRwTK(2?G{^NK|yL>N)#tZWj089@;)Y40L8l<1^@s6 delta 81 zcmeBWYi8rk=jG*M0D_z0u1R_ud3za|7+ohXWSq{(IN6pdQIj_{FSRJWGQPMZu_U$l j7Hd&rUV3T~H&DYZw#0&h)V!2itOdoH@!6A4Fu4K%mWml- diff --git a/mas/shrodequ_superpos/phys/__pycache__/func.cpython-310.pyc b/mas/shrodequ_superpos/phys/__pycache__/func.cpython-310.pyc index fc4dc392bf6de4a0dcf9838ef0ed4474f570184f..475579c6a890283bc3febae161bd4467cb6f6c39 100644 GIT binary patch delta 159 zcmeBV`@zba&&$ij00gP=u1RGRd1ZZkfSeSD6viBeC`KU7l*1IlkiwkGoW_*GlET`; z62$`Lv8AvBd8|+#M+zs9#|GtbrEmjz>=WyDF|tm!WUOW6n7o}aiIHcr6jPoMKhTC^ hCLkfiSR@LhG&v?OWC|1D0WvulI2ieufsjRr830dQ9j^cY delta 176 zcmeyt+R4V7&&$ij00cqdu1U=kd1XUFfSeSD6viBeCo|2qG}A>=P~9u5x93z+(M z06_%JNkJo8u!vFgSQVBF2v7L8MEEx> z>I>&J34?n$n}p2rT4&a&RW%34lciK|x7LNl_$s89KAQo0mw8gAS1E=(96mTNVCvrh zB#EdX5ff*ENiMi_gd^RBCtTs(x)CHG`GSc+bZ(upzbu#M%rG&)NcS9F6b3e0|Rt5{3H9sZYYxV znl!W_F>N>?YZxFmPD57k9&E?BCmSt(=QZT>Au{AM)q%5jKVBa4o9y|Tv1n;( z0vt-XsJAwVZRsXuu=zO9#vX=VUM0qQS-F^38_QA1 zD3*N+c%Awd;ooMpR@<=vUf{Q*(Fn*n9S)yxg-$rI9aQASVqK>Dqp)SR+b*V6sm+7$ zW8AJnQl(iJ@%}GCTen;n^|s|(eS^VgI?d|sMH>xUwL;5l08~n5{`4?=Q9s-QW Nhz7t|K>PGD`v+@vNGJdR literal 559 zcmYjOy-ve05Vjqsq!pD410w@lmPTSms1icmDkLVdSZVCiASX`kWGL!JUxNqWmAo?X z3QXLE7IM;k_WkJdcV{ymj|f=&biaIu^Am%<1rW@@-4%c&l4?@Yl$I=Il+1}_GT0Lt zysU& zz4eh0MO8FH;J6N9Ku7fT?62ooU*M2JR9UHn@FO8gBU_F4Qz15OrVo{HrA^lOpr{&) zpVsN^!4Px!4lbj6Fd`SU%PeB$8$y(|oEEt52m$Ac`<=j8t&zGO6y00@0-Tn{ zOErRuYVhM@(xXqgkLBR52_~VKS76o&ctu9kldzNWE2x%+2%w85)##``b5WtHV>|wj zbXXB5W?qA_1fC2Mk9zts8(ebWv#> 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) + + +