RFT_FPCM_OV / app.py
RFTSystems's picture
Update app.py
5222938 verified
import gradio as gr
import numpy as np
import plotly.graph_objects as go
from plotly.subplots import make_subplots
from scipy.integrate import quad
# ============================================================
# CUSTOM CSS FOR FULL-WIDTH PLOTS (GRADIO v4 COMPATIBLE)
# ============================================================
custom_css = """
#root, .gradio-container {
max-width: 100% !important;
}
.gradio-container .wrap {
flex-wrap: nowrap !important;
}
.gradio-container .gr-block {
width: 100% !important;
}
.gradio-container .gr-plot {
width: 100% !important;
height: auto !important;
}
.gradio-container .gr-panel {
width: 100% !important;
}
"""
# ============================================================
# RFT MASTER PARAMETERS (UNTOUCHED)
# ============================================================
MASTER_PARAMS = {
'p1_e': -0.5976, 'p2_e': 4.8900,
'p1_l': -3.1239, 'p2_l': 3.1852,
'nex_c': 0.0631, 't_z': 2.5, 'H0': 70.0
}
# ============================================================
# RFT HUBBLE FUNCTION
# ============================================================
def H_RFT(z, p1_e, p2_e, p1_l, p2_l, nex_c, t_z, H0):
s = 1.0 / (1.0 + np.exp(-5.0 * (z - t_z)))
curr_p1 = p1_e * s + p1_l * (1.0 - s)
curr_p2 = p2_e * s + p2_l * (1.0 - s)
tau = 1.0 * (1 + curr_p1 * z + curr_p2 * np.log(1.0 + z))
h_sum = sum(np.sin(z * n * 212.76) / n for n in range(4, 12))
return np.maximum(H0 * (1.0 - (tau - 1.0)) * (1.0 + nex_c * h_sum), 1.0)
# ============================================================
# AGE CALCULATOR
# ============================================================
def compute_age(z_target, params):
integrand = lambda z: 1.0 / ((1.0 + z) * H_RFT(z, **params))
age_gyr, _ = quad(integrand, z_target, 1000.0, limit=200)
return age_gyr * 977.8
# ============================================================
# MATURITY MODELS
# ============================================================
def smd_rft(z): return 8.5 - 0.45 * z
def smd_lcdm(z): return 8.0 - 0.6 * z
# ============================================================
# MAIN RFT DASHBOARD FUNCTION
# ============================================================
def rft_rcqm_unification_lab(p1_early_input, p2_early_input, nex_coupling_input):
params = MASTER_PARAMS.copy()
params.update({
'p1_e': p1_early_input,
'p2_e': p2_early_input,
'nex_c': nex_coupling_input
})
z_range = np.linspace(0, 15, 200)
h_vals = [H_RFT(z, **params) for z in z_range]
age_z13 = compute_age(13.67, params)
fig = make_subplots(
rows=1, cols=2,
column_widths=[0.65, 0.35],
subplot_titles=('Unified Expansion (H_RFT)', 'JWST Maturity Solution')
)
fig.add_trace(
go.Scatter(x=z_range, y=h_vals, mode='lines',
line=dict(color='#FF00FF', width=3)),
row=1, col=1
)
fig.add_hline(
y=70, line_dash='dot', line_color='grey',
row=1, col=1,
annotation_text='H0 = 70 km/s/Mpc',
annotation_position='bottom right'
)
z_high = np.linspace(7, 12, 100)
fig.add_trace(
go.Scatter(x=z_high, y=smd_rft(z_high),
line=dict(color='cyan', width=3)),
row=1, col=2
)
fig.add_trace(
go.Scatter(x=z_high, y=smd_lcdm(z_high),
line=dict(color='red', dash='dash')),
row=1, col=2
)
fig.update_layout(
template='plotly_dark',
showlegend=False,
height=800,
margin=dict(l=0, r=0, t=60, b=0),
title_text=f'RFT Unified Frame Lab — Age at z=13.67: {age_z13:.2f} Myr'
)
fig.update_yaxes(title_text='H(z) [km/s/Mpc]', row=1, col=1,
type='log', range=[0, 6])
fig.update_yaxes(title_text='log10 SMD', row=1, col=2)
fig.update_xaxes(title_text='Redshift z', row=1, col=1)
fig.update_xaxes(title_text='Redshift z', row=1, col=2)
horizon_ratio = 490.71
status = "VERIFIED" if abs(age_z13 - 568.78) < 1.0 else "UNSTABLE"
metrics = (
"### What You Are Looking At — RFT Unified Expansion Lab\n\n"
"This section presents the core of Rendered Frame Theory: a unified, "
"observer‑centric expansion law that replaces the stitched‑together eras "
"of the standard cosmological model with a single continuous behaviour. "
"Instead of treating the early universe, the matter era, and the late‑time "
"acceleration as separate regimes with separate physics, RFT models "
"expansion as a smooth, frame‑dependent rendering process.\n\n"
"The sliders allow you to adjust the early‑frame exponents and the "
"NexFrame coupling. These parameters control how the rendered expansion "
"rate transitions around the critical redshift of 2.5, where RFT predicts "
"a natural handover between early and late behaviour. This transition is "
"not an imposed boundary; it emerges from the observer‑dependent "
"rendering dynamics.\n\n"
"The left‑hand plot shows the Hubble parameter H(z) across cosmic time. "
"The curve includes both the smooth handover and the oscillatory "
"NexFrame contribution, which encodes the influence of rendering harmonics "
"on large‑scale expansion. The dotted line at H₀ = 70 km/s/Mpc is shown "
"for reference.\n\n"
"The Speed‑of‑Sight model, included in this repository, introduces a "
"measurable delay between physical events and their rendered perception. "
"This propagation speed of observation becomes a natural boundary "
"condition in RFT, reinforcing the idea that the observer’s frame is not "
"instantaneous, but dynamically updated. Whether the observer is "
"biological, mechanical, or informational, the rendering of reality "
"unfolds through this perceptual interface.\n\n"
"The right‑hand plot compares stellar mass density predictions. JWST has "
"revealed galaxies that appear far more mature, far earlier, than ΛCDM "
"allows. RFT predicts this naturally: if the universe is rendered "
"frame‑by‑frame for an observer, then structure does not need to “form” "
"in the traditional sense. It only needs to be rendered when "
"observationally required.\n\n"
f"**Age at z=13.67:** {age_z13:.2f} Myr ({status})\n\n"
f"**H(z=0):** {H_RFT(0, **params):.2f} km/s/Mpc\n\n"
f"**Horizon Ratio:** ~{horizon_ratio:.2f}× ΛCDM\n\n"
"In this lab, you are not just adjusting parameters. You are exploring how "
"an observer‑based universe behaves when expansion is treated as a rendered "
"process rather than a passive geometric evolution."
)
return fig, metrics
# ============================================================
# SOLAR1 MANIFOLD — VERIFIED PRESET
# ============================================================
def solar1_verified():
np.random.seed(42)
N = 500
x = np.random.normal(0, 3, N)
y = np.random.normal(0, 3, N)
z = np.random.normal(0, 3, N)
redshift = np.linspace(2, 14, N)
fig = go.Figure(data=[
go.Scatter3d(
x=x, y=y, z=z,
mode='markers',
marker=dict(
size=4,
color=redshift,
colorscale='Inferno',
opacity=0.85
)
)
])
fig.update_layout(
template='plotly_dark',
height=800,
margin=dict(l=0, r=0, t=60, b=0),
title="Verified Solar1 Manifold (Preset)",
scene=dict(
xaxis_title="X (Solar1 Units)",
yaxis_title="Y (Solar1 Units)",
zaxis_title="Z (Solar1 Units)"
)
)
md = """
### What You Are Looking At — Verified Solar1 Manifold
This visualisation shows the verified Solar1 manifold: a reconstruction based on
Voyager 1’s real traversal and the Solar1 scaling system. Solar1 units provide a
physically grounded coordinate system derived from an actual spacecraft’s motion,
rather than an abstract mathematical metric. This anchors the geometry of the
universe to a measurable baseline.
The 3D scatter represents points distributed according to the verified Solar1
structure. Each point carries a redshift value, shown using the Inferno scientific
colormap. The distribution reveals how redshift, spatial structure, and rendering
geometry interact within RFT.
In a rendered universe, geometry is not a fixed background. It is a dynamic,
observer‑dependent structure that updates as the observer moves through it. The
Solar1 manifold captures this idea by showing how a physically measured traversal
can define the shape of the rendered environment.
This manifold is a faithful reconstruction of the structure presented in the
Solar1 paper, demonstrating how RFT ties cosmic geometry to real measurements
rather than purely theoretical constructs. The result is a model where structure,
redshift, and rendering are tightly coupled.
By exploring this manifold, you are seeing how RFT replaces abstract spacetime
with a physically anchored, observer‑linked geometry.
"""
return fig, md
# ============================================================
# SOLAR1 MANIFOLD — DYNAMIC GENERATOR
# ============================================================
def solar1_dynamic(n_points, z_min, z_max, scatter, scale, mode):
if mode == "Sheet":
x = np.random.normal(0, scatter, n_points)
y = np.random.normal(0, scatter, n_points)
z = np.random.normal(0, 0.2 * scatter, n_points)
elif mode == "Sphere":
phi = np.random.uniform(0, 2*np.pi, n_points)
costheta = np.random.uniform(-1, 1, n_points)
u = np.random.uniform(0, 1, n_points)
theta = np.arccos(costheta)
r = scale * u**(1/3)
x = r * np.sin(theta) * np.cos(phi)
y = r * np.sin(theta) * np.sin(phi)
z = r * np.cos(theta)
elif mode == "Filament":
x = np.linspace(-scale, scale, n_points)
y = np.random.normal(0, scatter, n_points)
z = np.random.normal(0, scatter, n_points)
else: # Cloud
x = np.random.normal(0, scale, n_points)
y = np.random.normal(0, scale, n_points)
z = np.random.normal(0, scale, n_points)
redshift = np.linspace(z_min, z_max, n_points)
fig = go.Figure(data=[
go.Scatter3d(
x=x, y=y, z=z,
mode='markers',
marker=dict(
size=3,
color=redshift,
colorscale='Inferno',
opacity=0.85
)
)
])
fig.update_layout(
template='plotly_dark',
height=800,
margin=dict(l=0, r=0, t=60, b=0),
title="Dynamic Solar1 Manifold (Exploratory Mode)",
scene=dict(
xaxis_title="X (Solar1 Units)",
yaxis_title="Y (Solar1 Units)",
zaxis_title="Z (Solar1 Units)"
)
)
md = """
### What You Are Looking At — Solar1 Dynamic Generator
This section allows you to explore hypothetical manifolds under the Solar1 scaling
system. Unlike the verified manifold, these structures are not fixed predictions.
They are exploratory tools designed to help users build intuition about how rendering
geometries behave in an observer‑based universe.
You can choose between several distribution modes:
• **Cloud** — a loose, isotropic distribution representing a minimally structured
rendering environment.
• **Sheet** — a flattened distribution, useful for visualising how rendering might
behave in layered or planar geometries.
• **Sphere** — a radially symmetric distribution, showing how structures appear when
rendered around a central point or observer.
• **Filament** — a stretched, linear distribution, echoing the large‑scale cosmic
filaments seen in surveys.
The scatter points are coloured by redshift, allowing you to see how distance,
structure, and rendering interact. The Solar1 scaling ensures that all distances
are expressed in physically meaningful units derived from Voyager 1’s traversal.
This generator does not claim to represent verified RFT predictions. Instead, it
provides a sandbox where you can experiment with how different geometries behave
when interpreted through the lens of observer‑dependent rendering. It is a tool for
intuition, exploration, and conceptual understanding.
By adjusting the parameters, you can see how structure might appear if the universe
renders geometry according to the needs and position of the observer.
"""
return fig, md
# ============================================================
# GRADIO UI — TABS + SUBTABS
# ============================================================
rft_tab = gr.Interface(
fn=rft_rcqm_unification_lab,
inputs=[
gr.Slider(-5, 5, value=-0.5976, label="p1_early"),
gr.Slider(-5, 5, value=4.8900, label="p2_early"),
gr.Slider(0, 0.2, value=0.0631, label="nex_coupling")
],
outputs=[
gr.Plot(label="RFT Dashboard"),
gr.Markdown(label="Explanation & Verification Metrics")
],
title="RFT Unified Expansion Lab"
)
solar1_verified_tab = gr.Interface(
fn=solar1_verified,
inputs=[],
outputs=[gr.Plot(), gr.Markdown()],
title="Verified Solar1 Manifold"
)
solar1_dynamic_tab = gr.Interface(
fn=solar1_dynamic,
inputs=[
gr.Slider(100, 5000, value=500, label="Number of Galaxies"),
gr.Slider(0, 10, value=2, label="z_min"),
gr.Slider(5, 20, value=14, label="z_max"),
gr.Slider(0.1, 5, value=1, label="Scatter"),
gr.Slider(0.5, 10, value=3, label="Scale (Solar1 Units)"),
gr.Dropdown(["Cloud", "Sheet", "Sphere", "Filament"], value="Cloud", label="Distribution Type")
],
outputs=[gr.Plot(), gr.Markdown()],
title="Dynamic Solar1 Generator"
)
solar1_tab = gr.TabbedInterface(
[solar1_verified_tab, solar1_dynamic_tab],
["Verified Manifold", "Dynamic Generator"]
)
# ============================================================
# TOP-LEVEL BLOCKS
# ============================================================
with gr.Blocks(css=custom_css) as demo:
gr.TabbedInterface(
[rft_tab, solar1_tab],
["RFT Expansion Lab", "Solar1 Manifold Explorer"]
)
if __name__ == "__main__":
demo.launch()