quantumclouds 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
quantumclouds/engine.py
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import matplotlib.pyplot as plt
|
|
3
|
+
from .constants import Z_EFF
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class AtomicOrbital:
|
|
7
|
+
def __init__(self, element="H", grid_size=65, scale=None, l=1, m=0):
|
|
8
|
+
"""Initializes a digitized 3D space dynamically optimized for the orbital scale."""
|
|
9
|
+
self.element = element.upper()
|
|
10
|
+
self.grid_size = grid_size
|
|
11
|
+
self.l = l
|
|
12
|
+
self.m = m
|
|
13
|
+
|
|
14
|
+
self.Z_eff = Z_EFF.get(self.element, 1.0)
|
|
15
|
+
|
|
16
|
+
# WORKSPACE BOX CALIBRATION
|
|
17
|
+
if scale is None:
|
|
18
|
+
if self.l == 0:
|
|
19
|
+
self.scale = 3.5 / self.Z_eff
|
|
20
|
+
elif self.l >= 3:
|
|
21
|
+
self.scale = (5.0 * (self.l + 1)) / self.Z_eff
|
|
22
|
+
else:
|
|
23
|
+
self.scale = 6.0 / self.Z_eff
|
|
24
|
+
else:
|
|
25
|
+
self.scale = scale
|
|
26
|
+
|
|
27
|
+
self.axis = np.linspace(-self.scale, self.scale, self.grid_size)
|
|
28
|
+
self.x, self.y, self.z = np.meshgrid(self.axis, self.axis, self.axis, indexing='ij')
|
|
29
|
+
|
|
30
|
+
self.r = np.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2)
|
|
31
|
+
self.r[self.r == 0] = 1e-10
|
|
32
|
+
|
|
33
|
+
self.probability_density = None
|
|
34
|
+
|
|
35
|
+
def compute(self):
|
|
36
|
+
"""Computes pure math wavefunctions cleanly across quantum numbers l=0 to l=4."""
|
|
37
|
+
if self.l == 0:
|
|
38
|
+
self.m = 0
|
|
39
|
+
|
|
40
|
+
# l = 0: s-orbital
|
|
41
|
+
if self.l == 0:
|
|
42
|
+
psi = np.exp(-self.Z_eff * self.r / 1.0)
|
|
43
|
+
|
|
44
|
+
# l = 1: p-orbitals
|
|
45
|
+
elif self.l == 1:
|
|
46
|
+
if self.m == 0:
|
|
47
|
+
psi = self.z * np.exp(-self.Z_eff * self.r / 2.0)
|
|
48
|
+
else:
|
|
49
|
+
psi = (self.x + 1j * self.y) * np.exp(-self.Z_eff * self.r / 2.0)
|
|
50
|
+
|
|
51
|
+
# l = 2: d-orbitals
|
|
52
|
+
elif self.l == 2:
|
|
53
|
+
if self.m == 0:
|
|
54
|
+
psi = (2 * self.z ** 2 - self.x ** 2 - self.y ** 2) * np.exp(-self.Z_eff * self.r / 3.0)
|
|
55
|
+
elif abs(self.m) == 1:
|
|
56
|
+
psi = self.x * self.z * np.exp(-self.Z_eff * self.r / 3.0)
|
|
57
|
+
else:
|
|
58
|
+
psi = (self.x ** 2 - self.y ** 2) * np.exp(-self.Z_eff * self.r / 3.0)
|
|
59
|
+
|
|
60
|
+
# l = 3: f-orbitals
|
|
61
|
+
elif self.l == 3:
|
|
62
|
+
if self.m == 0:
|
|
63
|
+
psi = self.z * (5 * self.z ** 2 - 3 * self.r ** 2) * np.exp(-self.Z_eff * self.r / 4.0)
|
|
64
|
+
else:
|
|
65
|
+
psi = self.x * (self.x ** 2 - 3 * self.y ** 2) * np.exp(-self.Z_eff * self.r / 4.0)
|
|
66
|
+
|
|
67
|
+
# l = 4: g-orbitals
|
|
68
|
+
elif self.l == 4:
|
|
69
|
+
psi = (35 * self.z ** 4 - 30 * self.z ** 2 * self.r ** 2 + 3 * self.r ** 4) * np.exp(
|
|
70
|
+
-self.Z_eff * self.r / 5.0)
|
|
71
|
+
|
|
72
|
+
else:
|
|
73
|
+
psi = self.z * self.r ** (self.l - 1) * np.exp(-self.Z_eff * self.r / float(self.l + 1))
|
|
74
|
+
|
|
75
|
+
self.probability_density = np.real(psi * np.conj(psi))
|
|
76
|
+
return self
|
|
77
|
+
|
|
78
|
+
def plot2d(self, cmap='magma'):
|
|
79
|
+
"""Renders a flawlessly smooth 2D cross-section slice within the 3D space."""
|
|
80
|
+
if self.probability_density is None:
|
|
81
|
+
raise ValueError("Execution Error: Run compute() before plotting!")
|
|
82
|
+
|
|
83
|
+
fig = plt.figure(figsize=(8, 8))
|
|
84
|
+
ax = fig.add_subplot(111, projection='3d')
|
|
85
|
+
ax.view_init(elev=0, azim=-90)
|
|
86
|
+
|
|
87
|
+
mid_idx = self.grid_size // 2
|
|
88
|
+
|
|
89
|
+
contour = ax.contourf(
|
|
90
|
+
self.x[:, mid_idx, :],
|
|
91
|
+
self.probability_density[:, mid_idx, :],
|
|
92
|
+
self.z[:, mid_idx, :],
|
|
93
|
+
zdir='y', offset=0, levels=100, cmap=cmap
|
|
94
|
+
)
|
|
95
|
+
fig.colorbar(contour, ax=ax, label='Relative Electron Probability Density')
|
|
96
|
+
|
|
97
|
+
ax.set_xlim(-self.scale, self.scale)
|
|
98
|
+
ax.set_ylim(-self.scale, self.scale)
|
|
99
|
+
ax.set_zlim(-self.scale, self.scale)
|
|
100
|
+
plt.show()
|
|
101
|
+
|
|
102
|
+
def plot3d(self, cmap='magma'):
|
|
103
|
+
"""
|
|
104
|
+
Renders a beautifully glowing, crash-proof VisPy engine.
|
|
105
|
+
Perfectly zoomed out with the magma color theme active by default.
|
|
106
|
+
"""
|
|
107
|
+
import vispy
|
|
108
|
+
vispy.use(app='pyqt6')
|
|
109
|
+
|
|
110
|
+
from vispy import app, scene
|
|
111
|
+
from vispy.scene import visuals
|
|
112
|
+
|
|
113
|
+
if self.probability_density is None:
|
|
114
|
+
raise ValueError("Execution Error: Run compute() before plotting!")
|
|
115
|
+
|
|
116
|
+
x_flat = self.x.flatten()
|
|
117
|
+
y_flat = self.y.flatten()
|
|
118
|
+
z_flat = self.z.flatten()
|
|
119
|
+
prob_flat = self.probability_density.flatten()
|
|
120
|
+
|
|
121
|
+
# Balance density dynamically so the canvas pops perfectly
|
|
122
|
+
threshold_ratio = 0.005 if self.l == 0 else (0.02 if self.l >= 3 else 0.08)
|
|
123
|
+
|
|
124
|
+
mask = prob_flat > (np.max(prob_flat) * threshold_ratio)
|
|
125
|
+
x_filt = x_flat[mask]
|
|
126
|
+
y_filt = y_flat[mask]
|
|
127
|
+
z_filt = z_flat[mask]
|
|
128
|
+
prob_filt = prob_flat[mask]
|
|
129
|
+
|
|
130
|
+
# Map color values cleanly
|
|
131
|
+
norm_colors = prob_filt / np.max(prob_filt)
|
|
132
|
+
rgba_colors = plt.get_cmap(cmap)(norm_colors)
|
|
133
|
+
|
|
134
|
+
# GLOW ENGINE TUNING: Additive blending core
|
|
135
|
+
rgba_colors[:, 3] = 0.35
|
|
136
|
+
|
|
137
|
+
canvas = scene.SceneCanvas(
|
|
138
|
+
keys='interactive',
|
|
139
|
+
show=True,
|
|
140
|
+
size=(900, 900),
|
|
141
|
+
title=f"quantumpy Engine [VisPy Core] | {self.element} State (l={self.l})"
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
view = canvas.central_widget.add_view()
|
|
145
|
+
view.bgcolor = '#09090d' # Space charcoal background
|
|
146
|
+
|
|
147
|
+
view.camera = 'turntable'
|
|
148
|
+
view.camera.fov = 45
|
|
149
|
+
view.camera.center = (0, 0, 0)
|
|
150
|
+
|
|
151
|
+
# CAMERA DISTANCE CALIBRATION: Optimized to capture multi-lobed structures beautifully
|
|
152
|
+
view.camera.distance = self.scale * 4.5
|
|
153
|
+
|
|
154
|
+
# Jitter implementation to organically scatter grid vectors
|
|
155
|
+
grid_spacing = (2 * self.scale) / self.grid_size
|
|
156
|
+
x_jit = x_filt + np.random.uniform(-0.5, 0.5, size=x_filt.shape) * grid_spacing
|
|
157
|
+
y_jit = y_filt + np.random.uniform(-0.5, 0.5, size=y_filt.shape) * grid_spacing
|
|
158
|
+
z_jit = z_filt + np.random.uniform(-0.5, 0.5, size=z_filt.shape) * grid_spacing
|
|
159
|
+
|
|
160
|
+
# Create the Electron Cloud Markers
|
|
161
|
+
markers = visuals.Markers()
|
|
162
|
+
initial_pos = np.column_stack((x_jit, y_jit, z_jit)).astype(np.float32)
|
|
163
|
+
marker_size = 4.5 if self.l == 0 else 3.0
|
|
164
|
+
markers.set_data(initial_pos, face_color=rgba_colors, edge_color=None, size=marker_size, symbol='disc')
|
|
165
|
+
|
|
166
|
+
# CRASH BYPASS & GLOW EQUATION
|
|
167
|
+
markers.set_gl_state(
|
|
168
|
+
blend=True,
|
|
169
|
+
depth_test=False,
|
|
170
|
+
blend_func=('src_alpha', 'one')
|
|
171
|
+
)
|
|
172
|
+
view.add(markers)
|
|
173
|
+
|
|
174
|
+
# Precompute radial system attributes for frame transitions
|
|
175
|
+
r_spatial = np.sqrt(x_filt ** 2 + y_filt ** 2 + z_filt ** 2)
|
|
176
|
+
theta_spatial = np.arccos(np.clip(z_filt / (r_spatial + 1e-15), -1.0, 1.0))
|
|
177
|
+
phi_base = np.arctan2(y_filt, x_filt)
|
|
178
|
+
|
|
179
|
+
anim_state = {'frame': 0}
|
|
180
|
+
|
|
181
|
+
def on_timer_update(event):
|
|
182
|
+
anim_state['frame'] += 1
|
|
183
|
+
velocity = self.m if self.m != 0 else 0.5
|
|
184
|
+
time_phase = anim_state['frame'] * 0.025 * velocity
|
|
185
|
+
|
|
186
|
+
phi_current = phi_base + time_phase
|
|
187
|
+
x_curr = r_spatial * np.sin(theta_spatial) * np.cos(phi_current)
|
|
188
|
+
y_curr = r_spatial * np.sin(theta_spatial) * np.sin(phi_current)
|
|
189
|
+
|
|
190
|
+
x_curr_jit = x_curr + np.random.uniform(-0.2, 0.2, size=x_curr.shape) * grid_spacing
|
|
191
|
+
y_curr_jit = y_curr + np.random.uniform(-0.2, 0.2, size=y_curr.shape) * grid_spacing
|
|
192
|
+
z_curr_jit = z_jit + np.random.uniform(-0.2, 0.2, size=z_jit.shape) * grid_spacing
|
|
193
|
+
|
|
194
|
+
new_pos = np.column_stack((x_curr_jit, y_curr_jit, z_curr_jit)).astype(np.float32)
|
|
195
|
+
markers.set_data(new_pos, face_color=rgba_colors, edge_color=None, size=marker_size, symbol='disc')
|
|
196
|
+
canvas.update()
|
|
197
|
+
|
|
198
|
+
timer = app.Timer(interval=0.033, connect=on_timer_update, start=True)
|
|
199
|
+
app.run()
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: quantumclouds
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A GPU-accelerated 3D atomic orbital visualizer using VisPy and Matplotlib
|
|
5
|
+
Author-email: Your Name <your.email@example.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.9
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
Requires-Dist: numpy>=1.22.0
|
|
13
|
+
Requires-Dist: matplotlib>=3.5.0
|
|
14
|
+
Requires-Dist: vispy>=0.14.0
|
|
15
|
+
Requires-Dist: pyqt6>=6.4.0
|
|
16
|
+
|
|
17
|
+
# quantumclouds
|
|
18
|
+
|
|
19
|
+
A high-performance, GPU-accelerated 3D atomic orbital visualizer built entirely in Python using VisPy and Matplotlib.
|
|
20
|
+
|
|
21
|
+
`quantumclouds` solves the time-independent Schrödinger equation for hydrogen-like atoms analytically, computes the
|
|
22
|
+
quantum probability density grids across various subshells, and uses advanced OpenGL blending profiles to render
|
|
23
|
+
organic, glowing electron probability clouds that simulate actual quantum behaviors smoothly.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## ✨ Features
|
|
28
|
+
|
|
29
|
+
* **GPU-Accelerated Point Clouds:** Utilizes `VisPy` and custom OpenGL blending equations to render hundreds of
|
|
30
|
+
thousands of probability coordinate points interactively at ultra-high frame rates.
|
|
31
|
+
* **Organic Vector Jittering:** Implements real-time coordinates micro-jittering to eliminate artificial box/grid
|
|
32
|
+
banding artifacts, creating perfectly organic-looking orbital shapes.
|
|
33
|
+
* **Dynamic Node Phase Animation:** Animates probability cloud frame transitions using quantum azimuthal phase
|
|
34
|
+
velocities based on the magnetic quantum number ($m$).
|
|
35
|
+
* **Cross-Section Analysis:** Built-in `plot2d` engine to cut flat slices straight through the 3D grid space for
|
|
36
|
+
classical, precise probability density tracking.
|
|
37
|
+
* **Optimized Deep Space Aesthetics:** Defaults completely to the dark, high-contrast `magma` color spectrum to
|
|
38
|
+
emphasize multi-lobed structures cleanly against a space-charcoal backdrop.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## 🛠️ Installation
|
|
43
|
+
|
|
44
|
+
### Prerequisites
|
|
45
|
+
|
|
46
|
+
* **Python:** `>= 3.9`
|
|
47
|
+
* **Operating System:** macOS (Optimized for Apple Silicon / M-Series via PyQt6), Windows, or Linux.
|
|
48
|
+
|
|
49
|
+
### Installing From PyPI
|
|
50
|
+
|
|
51
|
+
Once the package is released to the public, you can install it globally with a single command:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pip install quantumclouds
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
quantumclouds/__init__.py,sha256=bn8psaW60u0BcuzkkzS16lHtTRQdfTjrpBdc6mU-TEQ,127
|
|
2
|
+
quantumclouds/constants.py,sha256=0FbfY3ifnsQ6c1Et6l2Jm33dgZc591zH3jgzQE3pzK0,165
|
|
3
|
+
quantumclouds/engine.py,sha256=Ieiw_z6B2EhIwyhNXSUr9GBdMDXH0dweoEE1bEQtJM0,7585
|
|
4
|
+
quantumclouds-0.1.0.dist-info/METADATA,sha256=SvnbDbCoBa1wqe_VnD4fiEXjIHi0-wsq31x4D3UpGiY,2251
|
|
5
|
+
quantumclouds-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
6
|
+
quantumclouds-0.1.0.dist-info/top_level.txt,sha256=EwjXmQCIONQk9Km9jw_Codmik-N9e65QNJSqHp0lvLk,14
|
|
7
|
+
quantumclouds-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
quantumclouds
|