"""
Test 10: Microphysical origin of L ∝ ρ

The cosmology result in Tests 7/8 depends on the assumption that the
"luminosity" (energy loss rate per unit volume) satisfies L ∝ ρ^n with
n = 1, i.e. L ∝ ρ. This test checks the three placeholder candidates
proposed in paper2_ideas.md:

    (A) Blackbody-analog: brane has effective temperature, ρ ~ T^4,
        dissipation rate per unit volume scales as T^4 → L ∝ ρ.

    (B) Gravitational bulk leakage: gravity not confined to brane;
        leakage rate into bulk scales with energy density. L ∝ ρ.

    (C) Brane-tension work: brane tension does mechanical work against
        bulk curvature as brane moves through ambient.

The question is: which (if any) of these gives L ∝ ρ^1 cleanly, without
adjustable parameters, and without being a circular re-labelling?

NOTE ON SCOPE:
This is a check-the-dimensional-analysis test, not a fundamental derivation.
None of (A)/(B)/(C) has a full microphysical model. What we can do is:
  - Check dimensional consistency
  - Check whether each gives n=1 or a different exponent
  - Check whether each is genuinely distinct or redundant
  - Flag circular reasoning where it appears.

HONEST VERDICT AT THE END: how much daylight is between "L ∝ ρ is
motivated" and "L ∝ ρ is assumed"?
"""

import numpy as np

print("=" * 72)
print("TEST 10: Microphysical candidates for L ∝ ρ")
print("=" * 72)

# -------------------------------------------------------------------
# Candidate A: Blackbody-analog dissipation
# -------------------------------------------------------------------
print("""
--------------------------------------------------------------------
CANDIDATE (A): Blackbody-analog dissipation
--------------------------------------------------------------------

CLAIM: The brane has effective temperature T. If the matter content is
radiation-like (ρ ∝ T^4, Stefan-Boltzmann) and the dissipation rate per
unit volume scales with T^4 (blackbody emissivity), then:

    L ∝ T^4 ∝ ρ   ⟹   n = 1.

PROBLEM 1: What does "dissipation" mean when radiation is blocked?
The whole point of the brane framework is that EM is confined to the
brane and CANNOT dissipate radiatively. If we then say "but there's
blackbody-like dissipation anyway", we've assumed the answer.

PROBLEM 2: The ρ ∝ T^4 relation is only true for pure radiation. For
dust (matter-dominated) we'd have ρ ∝ T^3 (or really, decoupled
temperatures). For a mixture, the relation is not a single power law.

PROBLEM 3: Stefan-Boltzmann is DERIVED from photon phase space +
black-body thermodynamics. Exporting the T^4 scaling to a non-radiative
channel requires a separate derivation.

VERDICT ON (A):
Dimensional analysis goes through IF you assume radiation-like scaling
for BOTH ρ(T) AND the loss rate. But the two "IF"s are the same "IF":
you've assumed the system behaves like radiation. That's not a
microphysical derivation; it's a restatement.

Status: CIRCULAR without an independent argument for why the dissipation
rate tracks ρ when the radiation channel is closed.
""")

# -------------------------------------------------------------------
# Candidate B: Gravitational bulk leakage
# -------------------------------------------------------------------
print("""
--------------------------------------------------------------------
CANDIDATE (B): Gravitational bulk leakage
--------------------------------------------------------------------

CLAIM: In Randall-Sundrum braneworlds, gravity is NOT confined to the
brane — gravitons can propagate in the bulk. If energy density ρ on
the brane generates gravitational fields that leak into the bulk at
a rate proportional to ρ, then L_leakage ∝ ρ.

Let's check this with a simple argument.

For a brane with tension σ in an RS-type setup, the leading graviton
coupling to matter gives a luminosity into the bulk per unit brane volume:
    L_grav ∼ G_{4+1} × (curvature sources)^2 ∼ G × ρ^2 / M_Pl^2
where G is 4D Newton's constant and M_Pl is the 4D Planck mass.

Wait. That gives L ∝ ρ^2, NOT ρ.

Hmm. Let me reconsider.

More carefully: gravitational radiation from a matter distribution
scales as (stress-energy)^2, not stress-energy. In the quadrupole
approximation for gravitational wave emission:
    dE/dt ∝ (d^3 I / dt^3)^2
where I is the quadrupole moment. This is quadratic in mass distribution,
not linear.

For bulk leakage specifically:
   - Tree-level graviton emission: linear coupling × phase space
     gives linear source, but the emission rate (which is what we
     want for L) involves |amplitude|^2, hence ρ^2.
   - Thermal graviton emission in a medium: for a thermal bath at
     temperature T, the graviton emission rate per unit volume scales
     as T^8 / M_Pl^4 (cf. supernova bounds on KK gravitons, Hannestad
     and collaborators). Since ρ ∝ T^4 for radiation,
     L_thermal_grav ∼ T^8 = ρ^2.

So in both cases we get L ∝ ρ^2, giving n = 2, which via
w_eff = 2(n-1)(1+w_internal) - 1 gives w_eff = 2(1)(1+w) - 1 = 1 + 2w.

For w_internal = 1/3 (radiation), w_eff = 5/3. That's a deeply wrong
equation of state — nothing like dark energy.

VERDICT ON (B):
Bulk gravitational leakage gives L ∝ ρ^2, NOT ρ. This is a genuinely
different scaling from what the framework needs. n = 2 produces an
equation of state incompatible with observations.

If this is the mechanism, paper 2's dark energy story is wrong.

Status: DOES NOT GIVE n = 1. Fails the required scaling.
""")

# Let's confirm the w_eff for n=2 case
n_vals = [0.5, 1.0, 1.5, 2.0]
w_internal_vals = [0.0, 1.0/3.0]  # matter, radiation
print("Confirming w_eff = 2(n-1)(1+w_int) - 1 for various n, w_int:")
print(f"{'n':>6} {'w_int':>8} {'w_eff':>10}")
print("-" * 26)
for n in n_vals:
    for w in w_internal_vals:
        w_eff = 2*(n-1)*(1+w) - 1
        print(f"{n:>6.2f} {w:>8.3f} {w_eff:>10.3f}")
print()
print("Only n=1 gives w_eff = -1 (de Sitter).")
print("n=2 gives w_eff = 1 (for dust) or 5/3 (for radiation).")
print("Neither is observationally viable.")
print()

# -------------------------------------------------------------------
# Candidate C: Brane-tension work
# -------------------------------------------------------------------
print("""
--------------------------------------------------------------------
CANDIDATE (C): Brane-tension work against bulk curvature
--------------------------------------------------------------------

CLAIM: The brane has surface tension σ (the cosmological-constant-like
brane tension in RS). As the brane moves / expands, work is done against
this tension. The rate of work depends on the brane's area change, which
scales with expansion rate H and brane volume.

Formally: for a brane of volume V with tension σ, the rate of energy
loss to tension work as the brane expands is:
    L_tension = σ × (dV/dt) / V × (something)
            = σ × 3H × (factor)
Per unit volume: L ∝ σ × H.

Now H itself is determined (via Friedmann-like equation) by ρ:
    H^2 ∝ ρ   ⟹   H ∝ ρ^{1/2}.

So L_tension ∝ σ × ρ^{1/2}, giving n = 1/2.

From w_eff = 2(n-1)(1+w) - 1, with n = 1/2:
    w_eff = 2(-1/2)(1+w) - 1 = -(1+w) - 1 = -(2+w).

For matter (w=0): w_eff = -2. That's PHANTOM dark energy (w < -1).
For radiation (w=1/3): w_eff = -7/3. More phantom.

Both phantom, both wrong — observed w is very close to -1.

Note: the sign of the deviation is wrong-side of -1, consistent with
n < 1 from the general formula. So this is not a near-de-Sitter
modification.

VERDICT ON (C):
Brane-tension work gives n = 1/2, which produces phantom-like w_eff well
away from -1. Not viable as a mechanism for dark energy.

Status: DOES NOT GIVE n = 1.
""")

# -------------------------------------------------------------------
# Summary table
# -------------------------------------------------------------------
print("""
--------------------------------------------------------------------
SUMMARY OF CANDIDATES
--------------------------------------------------------------------
""")

summary = [
    ("(A) Blackbody-analog", "n = 1 by assumption", "Circular — assumes what must be derived"),
    ("(B) Bulk graviton leakage", "n = 2", "Wrong scaling; gives w_eff = 1 or higher"),
    ("(C) Brane-tension work", "n = 1/2", "Gives phantom w_eff far from -1"),
]

print(f"{'Mechanism':<30} {'Exponent n':<22} {'Verdict':<40}")
print("-" * 92)
for name, exp, verdict in summary:
    print(f"{name:<30} {exp:<22} {verdict:<40}")

print("""

None of the three placeholder candidates gives L ∝ ρ^1 cleanly without
circularity. Candidate (A) gets n = 1 by assuming radiation-like behaviour,
which is exactly the assumption that needs justifying. Candidates (B) and
(C) give n = 2 and n = 1/2 respectively, both producing w_eff far from
the observed value.

--------------------------------------------------------------------
WHAT THIS MEANS FOR PAPER 2
--------------------------------------------------------------------

The cosmology result w_eff = -1 from L ∝ ρ is mathematically clean
(Tests 7, 8), but the assumption L ∝ ρ itself does NOT have microphysical
backing from the three candidates listed in paper2_ideas.md §3.2.

This moves the free parameter rather than eliminating it:
  - ΛCDM: assume Λ, get w = -1.
  - Paper 2: assume L ∝ ρ, get w = -1.

For Paper 2 to be meaningfully different from ΛCDM at the level of
mechanism (not just interpretation), one of the following needs to be
true:

  1. A different microphysical mechanism (not A/B/C) gives L ∝ ρ.
     Candidates worth looking at: thermal mass-energy coupling to w_4
     itself (the framework's own postulate), quantum vacuum polarisation
     on the brane, Casimir-like effects from brane boundary conditions.

  2. The L ∝ ρ assumption can be replaced by a different condition that
     also gives w = -1 and has independent motivation. E.g., a constraint
     from the brane action requiring a specific coupling form.

  3. The paper accepts that it's a different-labels version of ΛCDM at
     the w=-1 level, and the novelty is entirely in the associated
     Lorentz-emergence mechanism + correlated prediction. That's a
     weaker claim but still defensible.

The current state: paper 2's thermal-DE mechanism is not yet a derivation
of w = -1 from first principles. It's an energy-bookkeeping argument
with an assumed scaling exponent. This is ACKNOWLEDGED in
paper2_ideas.md §2 ("close to a tautology"), but Test 10 confirms that
none of the three candidate derivations delivers what's needed.

STATUS: OPEN GAP. Test 10 does not resolve it and arguably sharpens it.
""")
