# plant-model PWR plant model (point kinetics + lumped thermal-hydraulics) and mode-specific continuous controllers for the HAHACS preliminary example. ## Overview A 10-state coupled neutronics + thermal-hydraulics model in MATLAB: - 6 delayed neutron precursor groups (U-235 thermal fission, Keepin) - Lumped fuel, core coolant, and SG/cold-leg thermal nodes - Steam generator heat removal `Q_sg(t)` as the bounded disturbance input - Doppler and moderator temperature reactivity feedback - External rod reactivity `u` as the controllable input State vector: `x = [n; C1..C6; T_f; T_c; T_cold]` (10 states). See `CLAUDE.md` for the naming convention. ## Quick Start Open MATLAB in this directory and run: ```matlab main ``` The default scenario runs two simulations of a 100% → 80% SG demand step: once with `ctrl_null` (plant feedback only) and once with `ctrl_operation` (proportional rod reactivity on T_avg error), and plots the comparison. ## Files | File | Role | |------|------| | `main.m` | Entry point — scenario config and run | | `pke_params.m` | Plant parameters and steady-state derivation | | `pke_th_rhs.m` | Dynamics `ẋ = f(t, x, plant, Q_sg, u)` | | `pke_initial_conditions.m` | Analytic steady-state `x0` | | `pke_solver.m` | Closed-loop driver — takes a controller function handle | | `plot_pke_results.m` | 4-panel results plot | | `load_profile.m` | SG heat demand shapes | | `controllers/ctrl_null.m` | `u = 0` baseline | | `controllers/ctrl_operation.m` | Stabilizing mode: P on `T_avg` | ## Controllers Controllers share a single signature: ```matlab u = ctrl_(t, x, plant, ref) ``` Returns scalar `u` (external rod reactivity in `dk/k`). The solver swaps controllers via function handle: ```matlab [t, X, U] = pke_solver(plant, Q_sg, @ctrl_operation, ref, tspan); ``` Additional modes (`ctrl_heatup`, `ctrl_scram`, `ctrl_shutdown`) will land in `controllers/` following the same signature. ## Running Different Scenarios Swap `Q_sg` in `main.m`: ```matlab % Step down to 90% at t = 10s Q_sg = @(t) plant.P0 * (1.0 - 0.1 * (t >= 10)); % Interpolated time series t_data = [0, 100, 200, 300]; q_data = [1.0, 0.85, 0.9, 1.0] * plant.P0; Q_sg = @(t) interp1(t_data, q_data, t, 'linear', 'extrap'); ``` Swap the controller: ```matlab [t, X, U] = pke_solver(plant, Q_sg, @ctrl_null, [], tspan); ``` Change the reference (for modes that use one): ```matlab ref.T_avg = plant.T_c0 + 5; % track 5 C above nominal ``` ## Requirements MATLAB (R2020b or newer, tested on R2025b). Uses `ode15s` from base MATLAB — no toolboxes required.