TASK: Produce a deterministic function-level design for simulation with RK4 + nested CPL. INPUT DATA: - MODEL_SPEC from Prompt 1 - TTE_SPEC from Prompt 2 - Scenario definition: provides u(t) = [L(t),C(t),N(t),Ψ(t),T_a(t)] for any t - Initial state x0 = [z0, v_p0, T_b0, S0, w0] - Fixed constants: dt, t_max METHODOLOGY: Define these pure functions (no side effects): 1) params_to_constitutive(x, params): returns V_oc, R0, Q_eff at current state (with guards z_eff, floors) 2) power_mapping(u, x, params): returns P_tot 3) current_cpl(V_oc, v_p, R0, P_tot): returns Δ and I using the specified quadratic root 4) rhs(t, x, u, params): computes dx/dt using I(t) found by CPL closure RK4 step (must be spelled out exactly): Given (t_n, x_n): - Compute u_n = scenario.u(t_n) - Stage 1 uses rhs(t_n, x_n, u_n) - Stage 2 uses rhs(t_n+dt/2, x_n + dt*k1/2, u(t_n+dt/2)) - Stage 3 uses rhs(t_n+dt/2, x_n + dt*k2/2, u(t_n+dt/2)) - Stage 4 uses rhs(t_n+dt, x_n + dt*k3, u(t_n+dt)) - x_{n+1} = x_n + dt*(k1 + 2k2 + 2k3 + k4)/6 After updating, clamp states to bounds (z,S,w) as per MODEL_SPEC. Event evaluation: At each grid point, store V_term, z, Δ. After each step, check crossings using TTE_SPEC. DELIVERABLES: A) A complete “SIM_API_v1” specification listing: - Function signatures - Inputs/outputs (including units) - Exactly what arrays are stored each step - Termination output bundle B) A single canonical output schema: "trajectory" table columns exactly: t, z, v_p, T_b, S, w, V_oc, R0, Q_eff, P_tot, Δ, I, V_term plus metadata: dt, t_max, termination_reason, t_star, TTE_seconds VALIDATION: - Must state the convergence requirement: step-halving: compare dt vs dt/2 with: max|z_dt - z_dt2| < 1e-4 and relative TTE error < 1% (exactly these thresholds) - Must include feasibility guard: if Δ becomes negative at any rhs evaluation, trigger event DELTA_ZERO. OUTPUT FORMAT: Return YAML only with keys: SIM_API_v1, OutputSchema, ValidationPlan. No prose.