Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import numpy as np
|
| 3 |
-
|
| 4 |
|
| 5 |
st.set_page_config(page_title="Quantum EM Cognition Simulator", layout="wide")
|
| 6 |
|
|
@@ -33,39 +33,55 @@ mass_distribution = st.sidebar.slider("Mass Distribution", 0.1, 2.0, 1.0, 0.01)
|
|
| 33 |
temporal_factor = st.sidebar.slider("Temporal Factor", 0.1, 2.0, 1.0, 0.01)
|
| 34 |
|
| 35 |
# Create particle system
|
| 36 |
-
num_particles =
|
| 37 |
positions = np.random.uniform(-5, 5, (num_particles, 3))
|
| 38 |
-
colors = np.random.random((num_particles, 3))
|
| 39 |
|
| 40 |
# Update particle positions based on parameters
|
| 41 |
-
def update_particles(positions
|
| 42 |
-
positions += np.array([electric_field["x"], electric_field["y"], electric_field["z"]]) * 0.
|
| 43 |
|
| 44 |
phase = psi * np.sin(positions[:, 0] * h_bar)
|
| 45 |
-
positions[:, 0] += np.cos(phase) * 0.
|
| 46 |
-
positions[:, 1] += np.sin(phase) * 0.
|
| 47 |
|
| 48 |
mass_effect = mass_distribution * np.sin(positions[:, 0])
|
| 49 |
temporal_effect = temporal_factor * np.cos(np.random.random(num_particles) * 2 * np.pi)
|
| 50 |
-
positions[:, 0] += mass_effect * temporal_effect * 0.
|
| 51 |
-
|
| 52 |
-
colors = (positions + 5) / 10
|
| 53 |
|
| 54 |
positions[np.abs(positions) > 5] *= -0.9
|
| 55 |
|
| 56 |
-
return positions
|
| 57 |
|
| 58 |
-
positions
|
| 59 |
|
| 60 |
-
#
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
-
|
|
|
|
| 69 |
|
| 70 |
# Tutorial
|
| 71 |
st.sidebar.markdown("---")
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import numpy as np
|
| 3 |
+
import plotly.graph_objects as go
|
| 4 |
|
| 5 |
st.set_page_config(page_title="Quantum EM Cognition Simulator", layout="wide")
|
| 6 |
|
|
|
|
| 33 |
temporal_factor = st.sidebar.slider("Temporal Factor", 0.1, 2.0, 1.0, 0.01)
|
| 34 |
|
| 35 |
# Create particle system
|
| 36 |
+
num_particles = 1000 # Reduced number of particles for better performance
|
| 37 |
positions = np.random.uniform(-5, 5, (num_particles, 3))
|
|
|
|
| 38 |
|
| 39 |
# Update particle positions based on parameters
|
| 40 |
+
def update_particles(positions):
|
| 41 |
+
positions += np.array([electric_field["x"], electric_field["y"], electric_field["z"]]) * 0.1
|
| 42 |
|
| 43 |
phase = psi * np.sin(positions[:, 0] * h_bar)
|
| 44 |
+
positions[:, 0] += np.cos(phase) * 0.1
|
| 45 |
+
positions[:, 1] += np.sin(phase) * 0.1
|
| 46 |
|
| 47 |
mass_effect = mass_distribution * np.sin(positions[:, 0])
|
| 48 |
temporal_effect = temporal_factor * np.cos(np.random.random(num_particles) * 2 * np.pi)
|
| 49 |
+
positions[:, 0] += mass_effect * temporal_effect * 0.1
|
|
|
|
|
|
|
| 50 |
|
| 51 |
positions[np.abs(positions) > 5] *= -0.9
|
| 52 |
|
| 53 |
+
return positions
|
| 54 |
|
| 55 |
+
positions = update_particles(positions)
|
| 56 |
|
| 57 |
+
# Create the 3D scatter plot
|
| 58 |
+
fig = go.Figure(data=[go.Scatter3d(
|
| 59 |
+
x=positions[:, 0],
|
| 60 |
+
y=positions[:, 1],
|
| 61 |
+
z=positions[:, 2],
|
| 62 |
+
mode='markers',
|
| 63 |
+
marker=dict(
|
| 64 |
+
size=2,
|
| 65 |
+
color=positions[:, 2],
|
| 66 |
+
colorscale='Viridis',
|
| 67 |
+
opacity=0.8
|
| 68 |
+
)
|
| 69 |
+
)])
|
| 70 |
+
|
| 71 |
+
# Update the layout
|
| 72 |
+
fig.update_layout(
|
| 73 |
+
width=800,
|
| 74 |
+
height=800,
|
| 75 |
+
scene=dict(
|
| 76 |
+
xaxis_title='X',
|
| 77 |
+
yaxis_title='Y',
|
| 78 |
+
zaxis_title='Z',
|
| 79 |
+
aspectmode='cube'
|
| 80 |
+
)
|
| 81 |
+
)
|
| 82 |
|
| 83 |
+
# Display the plot
|
| 84 |
+
st.plotly_chart(fig)
|
| 85 |
|
| 86 |
# Tutorial
|
| 87 |
st.sidebar.markdown("---")
|