Dane Sabo 72143bcff5 predicates: add heatup rate invariant as a linear halfspace
Earlier placeholder claimed ramp-rate limits weren't expressible as
state halfspaces without augmentation. That was wrong: dT_c/dt is
linear in (T_f, T_c, T_cold) directly from pke_th_rhs (no neutronics
coupling), so |dT_c/dt| <= r_max is two clean halfspaces over x.

Coefficients from pke_params:
  a_f    = hA / (M_c*c_c)            = +0.4587 /s
  a_c    = -(hA + 2*W*c_c)/(M_c*c_c) = -0.9587 /s
  a_cold = 2*W*c_c / (M_c*c_c)       = +0.5000 /s
  Sum   = 0 exact (equilibrium when all T's equal).

Limit chosen: +/- 50 C/hr (tech-spec 28 C/hr + transient overshoot
budget). Verified on actual heatup sim: max dT_c/dt = 48.5 C/hr, min
= 0 C/hr. Passes our placeholder but tight — a strict 28 C/hr tech-
spec invariant would be violated by current ctrl_heatup tuning
(overshoot factor ~1.7x during mid-ramp).

Generalized load_predicates.m to accept multi-coefficient halfspace
rows via "row": [[state_idx, coeff], ...] format, in addition to the
existing single-coefficient {state_index, coeff} form. Backward
compatible.

inv1_holds now conjoins fuel_centerline, cold_leg_subcooled, and the
two rate halfspaces. DNBR still not modeled (would need an
augmented predicate with a correlation-based safety margin).

Hacker-Split: Dane asked about heatup rate invariant; realizing
my earlier 'needs state augmentation' claim was wrong and the rate
constraint is already linear. Fix it, verify against actual sim.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-20 16:16:53 -04:00
..

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:

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:

u = ctrl_<mode>(t, x, plant, ref)

Returns scalar u (external rod reactivity in dk/k). The solver swaps controllers via function handle:

[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:

% 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:

[t, X, U] = pke_solver(plant, Q_sg, @ctrl_null, [], tspan);

Change the reference (for modes that use one):

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.