Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,35 +2,69 @@ import gradio as gr
|
|
| 2 |
import numpy as np
|
| 3 |
|
| 4 |
# ============================================================
|
| 5 |
-
# RFT-Ω HARMONIC VALIDATION INTERFACE
|
| 6 |
-
#
|
| 7 |
# ============================================================
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
elif choice == "Metrics":
|
| 23 |
-
return metrics()
|
| 24 |
-
else:
|
| 25 |
-
return {"error": "Invalid selection"}
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
demo = gr.Interface(
|
| 28 |
-
fn=
|
| 29 |
-
inputs=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
outputs="json",
|
| 31 |
-
title="RFT-Ω Harmonic Validation Interface",
|
| 32 |
-
description=
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
)
|
| 34 |
|
|
|
|
| 35 |
if __name__ == "__main__":
|
| 36 |
demo.launch()
|
|
|
|
| 2 |
import numpy as np
|
| 3 |
|
| 4 |
# ============================================================
|
| 5 |
+
# RFT-Ω HARMONIC VALIDATION INTERFACE v2
|
| 6 |
+
# (Interactive profiles + adjustable noise)
|
| 7 |
# ============================================================
|
| 8 |
|
| 9 |
+
# --- base metric generator ----------------------------------
|
| 10 |
+
def run_simulation(profile, noise_scale):
|
| 11 |
+
"""
|
| 12 |
+
Simulate harmonic stability (QΩ) and synchronisation (ζ_sync)
|
| 13 |
+
under synthetic noise for selected system profile.
|
| 14 |
+
"""
|
| 15 |
|
| 16 |
+
# baseline ranges for profiles (mean_QΩ, mean_ζ)
|
| 17 |
+
baselines = {
|
| 18 |
+
"AI / Neural": (0.86, 0.80),
|
| 19 |
+
"SpaceX / Aerospace": (0.84, 0.79),
|
| 20 |
+
"Energy / RHES": (0.83, 0.78),
|
| 21 |
+
"Extreme Perturbation": (0.82, 0.77)
|
| 22 |
+
}
|
| 23 |
+
base_q, base_z = baselines.get(profile, (0.84, 0.79))
|
| 24 |
|
| 25 |
+
# apply synthetic Gaussian noise
|
| 26 |
+
q_noise = np.random.normal(0, noise_scale)
|
| 27 |
+
z_noise = np.random.normal(0, noise_scale * 0.8)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
+
# compute final readings, clamped to [0,1]
|
| 30 |
+
q_omega = np.clip(base_q + q_noise, 0.0, 1.0)
|
| 31 |
+
z_sync = np.clip(base_z + z_noise, 0.0, 1.0)
|
| 32 |
+
|
| 33 |
+
# derive qualitative status
|
| 34 |
+
var = abs(q_noise) + abs(z_noise)
|
| 35 |
+
status = "nominal"
|
| 36 |
+
if var > 0.12: status = "critical"
|
| 37 |
+
elif var > 0.06: status = "perturbed"
|
| 38 |
+
|
| 39 |
+
return {
|
| 40 |
+
"System": profile,
|
| 41 |
+
"Noise Scale": round(noise_scale, 3),
|
| 42 |
+
"QΩ": round(q_omega, 3),
|
| 43 |
+
"ζ_sync": round(z_sync, 3),
|
| 44 |
+
"status": status
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
# --- Gradio user interface ----------------------------------
|
| 48 |
demo = gr.Interface(
|
| 49 |
+
fn=run_simulation,
|
| 50 |
+
inputs=[
|
| 51 |
+
gr.Radio(
|
| 52 |
+
["AI / Neural", "SpaceX / Aerospace", "Energy / RHES", "Extreme Perturbation"],
|
| 53 |
+
label="Select System Profile",
|
| 54 |
+
value="AI / Neural"
|
| 55 |
+
),
|
| 56 |
+
gr.Slider(0.0, 0.2, value=0.05, step=0.005,
|
| 57 |
+
label="Synthetic Noise Level (σ)")
|
| 58 |
+
],
|
| 59 |
outputs="json",
|
| 60 |
+
title="RFT-Ω Harmonic Validation Interface v2",
|
| 61 |
+
description=(
|
| 62 |
+
"Simulate QΩ (stability) and ζ_sync (coherence) under controlled synthetic noise.\n"
|
| 63 |
+
"Choose an environment profile and adjust noise to test harmonic resilience.\n"
|
| 64 |
+
"Typical stable ranges: QΩ 0.82–0.89 | ζ_sync 0.75–0.88"
|
| 65 |
+
)
|
| 66 |
)
|
| 67 |
|
| 68 |
+
# --- launch -------------------------------------------------
|
| 69 |
if __name__ == "__main__":
|
| 70 |
demo.launch()
|