+
+ Winter import
+
+ {computing ? "..." : winterImport != null ? fmtMw(winterImport) : "–"} / 2×160.1 MW
- {worst?.name ?? "not solved yet"}
-
+
+
+
+
+ Summer import
+
+ {computing ? "..." : summerImport != null ? `${fmtMw(summerImport)} / 2×110.8` : "–"} MW
+
+
+
+
+
+
+ {worst && worst.winterPct !== null && worst.summerPct !== null ? (
+ <>
+
+ Worst winter
+ 100 ? C.red : worst.winterPct > 90 ? C.amber : C.ink }}>
+ {computing ? "..." : `${Math.round(worst.winterPct)}%`}
+
+ {worst.winterName}
+
+
+ Worst summer
+ 100 ? C.red : worst.summerPct > 90 ? C.amber : C.ink }}>
+ {computing ? "..." : `${Math.round(worst.summerPct)}%`}
+
+ {worst.summerName}
+
+ >
+ ) : (
+
+ )}
Voltage band
- {yr ? yr.min_vm_pu.toFixed(3) : "–"}
- to {yr ? yr.max_vm_pu.toFixed(3) : "–"} pu · {yr?.voltage_violation_bus_ids.length ? `${yr.voltage_violation_bus_ids.length} outside band` : "statutory bands"}
+ {hasWinterVoltage && hasSummerVoltage && yr ? (
+ <>
+ {yr.min_vm_winter!.toFixed(3)} (W)
+ to {yr.max_vm_winter!.toFixed(3)} pu (W) · {yr.min_vm_summer!.toFixed(3)} (S) to {yr.max_vm_summer!.toFixed(3)} pu (S)
+ >
+ ) : (
+ <>
+ {computing ? "..." : yr ? yr.min_vm_pu.toFixed(3) : "–"}
+
+ {computing ? "computing" : <>to {yr ? yr.max_vm_pu.toFixed(3) : "–"} pu · {yr?.voltage_violation_bus_ids.length ? `${yr.voltage_violation_bus_ids.length} outside band` : "statutory bands"}>}
+
+ >
+ )}
Peak demand
- ×{yr ? yr.growth.toFixed(2) : "–"}
+ ×{computing ? "..." : yr ? yr.growth.toFixed(2) : "–"}
vs today, by {yr?.year ?? s.year}
N-1 findings
-
- {yr ? `${yr.n1_violations.length} / ${yr.n1_screened}` : "–"}
+
+ {computing ? "..." : yr ? `${yr.n1_violations.length} / ${yr.n1_screened}` : "–"}
132 kV outages screened, reported only
@@ -148,6 +277,97 @@ function Readings({ planner, gsp, limit, gspHot }: { planner: LeftCardsPlanner;
);
}
+/** Compact readings for short windows (< 760px tall): critical stats in a minimal card. */
+function CompactReadings({ planner, gsp, limit, gspHot, worst, vMin, vMax, worstPct }: {
+ planner: LeftCardsPlanner;
+ gsp: number | null;
+ limit: number | null;
+ gspHot: boolean;
+ worst: ReturnType
;
+ vMin: string;
+ vMax: string;
+ worstPct: number | null;
+}) {
+ const { s, derived } = planner;
+ const { yr } = derived;
+ const computing = s.refreshing || s.running;
+
+ const winterImport = yr?.gsp_import_winter_mw !== undefined ? yr.gsp_import_winter_mw : null;
+ const summerImport = yr?.gsp_import_summer_mw !== undefined ? Math.max(0, yr.gsp_import_summer_mw) : null;
+ const winterLimit = s.boundary?.import_limit_mw.winter ?? null;
+ const summerLimit = s.boundary?.import_limit_mw.summer ?? null;
+ const winterHot = winterImport != null && winterLimit && winterImport > 0 ? winterImport / winterLimit > 0.9 : false;
+ const summerHot = summerImport != null && summerLimit && summerImport > 0 ? summerImport / summerLimit > 0.9 : false;
+
+ // Voltage range with each case's own voltage (treat 0 as no data)
+ const hasWinterVoltage = !!(yr?.min_vm_winter && yr?.max_vm_winter);
+ const hasSummerVoltage = !!(yr?.min_vm_summer && yr?.max_vm_summer);
+ // Show winter and summer voltages separately when both available
+ const vDisplay = computing ? "..." : hasWinterVoltage && hasSummerVoltage && yr
+ ? `${yr.min_vm_winter!.toFixed(3)}(W)–${yr.max_vm_winter!.toFixed(3)}(W) ${yr.min_vm_summer!.toFixed(3)}(S)–${yr.max_vm_summer!.toFixed(3)}(S)`
+ : `${vMin}–${vMax}`;
+
+ return (
+
+
+
+
+ GSP export{yr?.gsp_export_case ? ` (${yr.gsp_export_case === "winter_peak" ? "W" : "S"})` : ""}
+
+
+ {computing ? "..." : gsp != null && limit != null ? `${Math.round(gsp)} / ${Math.round(limit)}` : "–"}
+
+
+
+ Winter import
+
+ {computing ? "..." : winterImport != null ? `${Math.round(winterImport)} / 2×160.1` : "–"}
+
+
+
+ Summer import
+
+ {computing ? "..." : summerImport != null ? `${Math.round(summerImport)} / 2×110.8` : "–"}
+
+
+
+ Voltage
+
+ {vDisplay}
+
+
+ {worst && worst.winterPct !== null && worst.summerPct !== null ? (
+ <>
+
+ Worst winter
+ 100 ? C.red : worst.winterPct > 90 ? C.amber : C.ink, fontSize: 10 }}>
+ {computing ? "..." : `${Math.round(worst.winterPct)}% ${worst.winterName}`}
+
+
+
+ Worst summer
+ 100 ? C.red : worst.summerPct > 90 ? C.amber : C.ink, fontSize: 10 }}>
+ {computing ? "..." : `${Math.round(worst.summerPct)}% ${worst.summerName}`}
+
+
+ >
+ ) : (
+
+ Worst
+ 100 ? C.red : worstPct && worstPct > 90 ? C.amber : C.ink }}>
+ {computing ? "..." : !worst ? "–" :
+ worst.case && worst.winterPct !== null && worst.case === "winter peak" ? `${Math.round(worst.winterPct)}%(W)` :
+ worst.case && worst.summerPct !== null && worst.case === "summer min" ? `${Math.round(worst.summerPct)}%(S)` :
+ worstPct != null ? `${worstPct}%` : "–"
+ }
+
+
+ )}
+
+
+ );
+}
+
/** One line: the year's demand-side alerts by level; opens the Demand layer on the worst region. */
function CustomerAlerts({ planner }: { planner: LeftCardsPlanner }) {
const { actions, derived } = planner;
diff --git a/apps/web/src/lib/derive.test.ts b/apps/web/src/lib/derive.test.ts
index 146a54f..2f586ef 100644
--- a/apps/web/src/lib/derive.test.ts
+++ b/apps/web/src/lib/derive.test.ts
@@ -134,7 +134,7 @@ describe("naming and readings", () => {
it("names lines by the places they join and finds the worst element", () => {
expect(lineName(ix, 10)).toBe("Boston to Bicker Fen 132 kV");
const w = worstElement(year(2030, { line_loading: { "10": 61, "11": 88 }, trafo_loading: { "5": 92 } }), ix);
- expect(w).toEqual({ pct: 92, name: "Bicker Fen 132/33 kV transformer", sel: { kind: "trafo", id: 5 } });
+ expect(w).toEqual({ pct: 92, name: "Bicker Fen 132/33 kV transformer", sel: { kind: "trafo", id: 5 }, winterPct: null, winterName: null, summerPct: null, summerName: null, case: null });
});
it("fills the GSP gauge, the last ticks amber", () => {
const t = gspTicks(500, 527);
diff --git a/apps/web/src/lib/derive.ts b/apps/web/src/lib/derive.ts
index b34a383..596b439 100644
--- a/apps/web/src/lib/derive.ts
+++ b/apps/web/src/lib/derive.ts
@@ -269,16 +269,89 @@ export interface WorstElement {
pct: number;
name: string;
sel: ElementSel;
+ winterPct: number | null;
+ winterName: string | null;
+ summerPct: number | null;
+ summerName: string | null;
+ case: "winter peak" | "summer min" | null;
}
-/** The most loaded line or transformer in a year (worst case across the two study cases). */
+/** The most loaded line or transformer in a year (finds worst winter and worst summer separately). */
export function worstElement(yr: YearResult | null, ix: ModelIndex | null): WorstElement | null {
if (!yr || !ix) return null;
- let best: WorstElement | null = null;
- for (const [id, v] of Object.entries(yr.line_loading ?? {}))
- if (!best || v > best.pct) best = { pct: v, name: lineName(ix, +id), sel: { kind: "line", id: +id } };
- for (const [id, v] of Object.entries(yr.trafo_loading ?? {}))
- if (!best || v > best.pct) best = { pct: v, name: trafoName(ix, +id), sel: { kind: "trafo", id: +id } };
- return best;
+
+ // Find worst winter loading
+ let worstWinterPct: number | null = null;
+ let worstWinterName: string | null = null;
+ let worstWinterSel: ElementSel | null = null;
+
+ for (const [id, v] of Object.entries(yr.line_loading_winter ?? {})) {
+ if (worstWinterPct === null || v > worstWinterPct) {
+ worstWinterPct = v;
+ worstWinterName = lineName(ix, +id);
+ worstWinterSel = { kind: "line", id: +id };
+ }
+ }
+ for (const [id, v] of Object.entries(yr.trafo_loading_winter ?? {})) {
+ if (worstWinterPct === null || v > worstWinterPct) {
+ worstWinterPct = v;
+ worstWinterName = trafoName(ix, +id);
+ worstWinterSel = { kind: "trafo", id: +id };
+ }
+ }
+
+ // Find worst summer loading
+ let worstSummerPct: number | null = null;
+ let worstSummerName: string | null = null;
+ let worstSummerSel: ElementSel | null = null;
+
+ for (const [id, v] of Object.entries(yr.line_loading_summer ?? {})) {
+ if (worstSummerPct === null || v > worstSummerPct) {
+ worstSummerPct = v;
+ worstSummerName = lineName(ix, +id);
+ worstSummerSel = { kind: "line", id: +id };
+ }
+ }
+ for (const [id, v] of Object.entries(yr.trafo_loading_summer ?? {})) {
+ if (worstSummerPct === null || v > worstSummerPct) {
+ worstSummerPct = v;
+ worstSummerName = trafoName(ix, +id);
+ worstSummerSel = { kind: "trafo", id: +id };
+ }
+ }
+
+ // If no seasonal data, fall back to envelope
+ if (worstWinterPct === null && worstSummerPct === null) {
+ let best: { pct: number; name: string; sel: ElementSel } | null = null;
+ for (const [id, v] of Object.entries(yr.line_loading ?? {})) {
+ if (!best || v > best.pct) {
+ best = { pct: v, name: lineName(ix, +id), sel: { kind: "line", id: +id } };
+ }
+ }
+ for (const [id, v] of Object.entries(yr.trafo_loading ?? {})) {
+ if (!best || v > best.pct) {
+ best = { pct: v, name: trafoName(ix, +id), sel: { kind: "trafo", id: +id } };
+ }
+ }
+ if (!best) return null;
+ return { pct: best.pct, name: best.name, sel: best.sel, winterPct: null, winterName: null, summerPct: null, summerName: null, case: null };
+ }
+
+ // Return with both worst winter and worst summer
+ const overallWorst = (worstWinterPct ?? 0) >= (worstSummerPct ?? 0) ? worstWinterPct! : worstSummerPct!;
+ const overallSel = (worstWinterPct ?? 0) >= (worstSummerPct ?? 0) ? worstWinterSel! : worstSummerSel!;
+ const overallName = (worstWinterPct ?? 0) >= (worstSummerPct ?? 0) ? worstWinterName! : worstSummerName!;
+ const winningCase = (worstWinterPct ?? 0) >= (worstSummerPct ?? 0) ? "winter peak" : "summer min";
+
+ return {
+ pct: overallWorst,
+ name: overallName,
+ sel: overallSel,
+ winterPct: worstWinterPct,
+ winterName: worstWinterName,
+ summerPct: worstSummerPct,
+ summerName: worstSummerName,
+ case: winningCase,
+ };
}
/** GSP export gauge: 24 ticks, cyan, the last ones amber above 90 %. */
@@ -296,6 +369,8 @@ export interface ElementInfo {
loadLabel: string;
load: string;
loadPct: number | null;
+ winterLoadPct: number | null;
+ summerLoadPct: number | null;
ll: [number, number] | null;
}
export function elementInfo(sel: ElementSel, ix: ModelIndex, yr: YearResult | null, year: number): ElementInfo | null {
@@ -303,6 +378,8 @@ export function elementInfo(sel: ElementSel, ix: ModelIndex, yr: YearResult | nu
const l = ix.line.get(sel.id);
if (!l) return null;
const pct = yr?.line_loading?.[sel.id] ?? null;
+ const winterPct = yr?.line_loading_winter?.[sel.id] ?? null;
+ const summerPct = yr?.line_loading_summer?.[sel.id] ?? null;
return {
name: lineName(ix, sel.id),
short: lineShort(ix, sel.id),
@@ -311,6 +388,8 @@ export function elementInfo(sel: ElementSel, ix: ModelIndex, yr: YearResult | nu
loadLabel: `Loading in ${year}`,
load: pct == null ? "–" : `${Math.round(pct)}%`,
loadPct: pct,
+ winterLoadPct: winterPct,
+ summerLoadPct: summerPct,
ll: [(l.from_lon + l.to_lon) / 2, (l.from_lat + l.to_lat) / 2],
};
}
@@ -318,6 +397,8 @@ export function elementInfo(sel: ElementSel, ix: ModelIndex, yr: YearResult | nu
const t = ix.trafo.get(sel.id);
if (!t) return null;
const pct = yr?.trafo_loading?.[sel.id] ?? null;
+ const winterPct = yr?.trafo_loading_winter?.[sel.id] ?? null;
+ const summerPct = yr?.trafo_loading_summer?.[sel.id] ?? null;
return {
name: trafoName(ix, sel.id),
short: `${trafoSub(t).slice(0, 8)} T${t.trafo_id}`,
@@ -326,6 +407,8 @@ export function elementInfo(sel: ElementSel, ix: ModelIndex, yr: YearResult | nu
loadLabel: `Loading in ${year}`,
load: pct == null ? "–" : `${Math.round(pct)}%`,
loadPct: pct,
+ winterLoadPct: winterPct,
+ summerLoadPct: summerPct,
ll: [t.hv_lon, t.hv_lat],
};
}
@@ -339,6 +422,8 @@ export function elementInfo(sel: ElementSel, ix: ModelIndex, yr: YearResult | nu
loadLabel: "Output at summer min",
load: g.technology === "battery" ? "exporting" : "full",
loadPct: null,
+ winterLoadPct: null,
+ summerLoadPct: null,
ll: [g.lon, g.lat],
};
}
diff --git a/apps/web/src/types.ts b/apps/web/src/types.ts
index 1a24ae3..3dfad9e 100644
--- a/apps/web/src/types.ts
+++ b/apps/web/src/types.ts
@@ -185,11 +185,22 @@ export interface PhaseResult {
max_vm_pu: number;
overloaded_line_ids: number[];
line_loading: Record;
+ line_loading_winter?: Record;
+ line_loading_summer?: Record;
+ trafo_loading_winter?: Record;
+ trafo_loading_summer?: Record;
bus_vm: Record;
voltage_violation_bus_ids: number[];
gsp_export_mw: number;
+ gsp_export_case?: string | null;
gsp_import_mw: number;
+ gsp_import_winter_mw?: number;
+ gsp_import_summer_mw?: number;
gsp_limit_mw: number | null;
+ min_vm_winter?: number;
+ max_vm_winter?: number;
+ min_vm_summer?: number;
+ max_vm_summer?: number;
n1_screened: number;
n1_violations: N1Violation[];
}
diff --git a/packages/optimizer/src/gridforge_optimizer/network.py b/packages/optimizer/src/gridforge_optimizer/network.py
index f9623a4..85e3074 100644
--- a/packages/optimizer/src/gridforge_optimizer/network.py
+++ b/packages/optimizer/src/gridforge_optimizer/network.py
@@ -440,12 +440,24 @@ def feasibility(net) -> tuple[bool, Reason | None, dict]:
reason: Reason | None = None
gsp_export = gsp_import = 0.0
export_case = binding_case = None
+ winter_line = winter_trafo = summer_line = summer_trafo = None
+ winter_import = summer_import = 0.0
+ winter_vm = summer_vm = None
for case, load_scale, rating_ratio in _study_cases(net):
res = _run_case(net, case, load_scale, rating_ratio)
if res is None:
return False, Reason(type="non_convergent", case=case,
message=f"power flow did not converge at {_CASE_LABEL[case]}"), {}
vm, line_pct, trafo_pct, p = res["vm"], res["line_pct"], res["trafo_pct"], res["p_ext_mw"]
+ # Capture per-case loading, import, and voltage
+ if case == "winter_peak":
+ winter_line, winter_trafo = line_pct, trafo_pct
+ winter_import = p
+ winter_vm = vm
+ elif case == "summer_min":
+ summer_line, summer_trafo = line_pct, trafo_pct
+ summer_import = p
+ summer_vm = vm
if -p > gsp_export:
gsp_export, export_case = -p, case
gsp_import = max(gsp_import, p)
@@ -471,9 +483,20 @@ def feasibility(net) -> tuple[bool, Reason | None, dict]:
"max_line_pct": float(env_line.max()) if len(env_line) else 0.0,
"max_trafo_pct": float(env_trafo.max()) if len(env_trafo) else 0.0,
"gsp_export_mw": round(gsp_export, 1),
+ "gsp_export_case": export_case,
"gsp_import_mw": round(gsp_import, 1),
+ "gsp_import_winter_mw": round(winter_import, 1),
+ "gsp_import_summer_mw": round(summer_import, 1),
"gsp_limit_mw": gsp_export_limit(net),
"binding_case": binding_case,
+ "line_loading_winter": winter_line,
+ "line_loading_summer": summer_line,
+ "trafo_loading_winter": winter_trafo,
+ "trafo_loading_summer": summer_trafo,
+ "min_vm_winter": float(winter_vm.min()) if winter_vm is not None else 0.0,
+ "max_vm_winter": float(winter_vm.max()) if winter_vm is not None else 0.0,
+ "min_vm_summer": float(summer_vm.min()) if summer_vm is not None else 0.0,
+ "max_vm_summer": float(summer_vm.max()) if summer_vm is not None else 0.0,
}
return reason is None, reason, metrics
@@ -490,10 +513,16 @@ def line_loadings(net) -> dict[int, float]:
return {int(i): round(float(v), 1) for i, v in lp.items()}
+def _loading_dict(series) -> dict[int, float]:
+ """Convert a pandas Series of loading_percent to a dict, filtering NaN."""
+ if series is None:
+ return {}
+ return {int(i): round(float(v), 1) for i, v in series.items() if v == v}
+
+
def trafo_loadings(net) -> dict[int, float]:
"""Per-transformer loading_percent from the last solve."""
- tp = net.res_trafo["loading_percent"]
- return {int(i): round(float(v), 1) for i, v in tp.items() if v == v}
+ return _loading_dict(net.res_trafo["loading_percent"])
def bus_voltages(net) -> dict[int, float]:
diff --git a/packages/optimizer/src/gridforge_optimizer/types.py b/packages/optimizer/src/gridforge_optimizer/types.py
index 05777f2..a769d20 100644
--- a/packages/optimizer/src/gridforge_optimizer/types.py
+++ b/packages/optimizer/src/gridforge_optimizer/types.py
@@ -83,12 +83,23 @@ class PhaseResult(BaseModel):
min_vm_pu: float
max_vm_pu: float
overloaded_line_ids: list[int]
- line_loading: dict[int, float] = {} # line_id -> loading_percent, for the map heat overlay
+ line_loading: dict[int, float] = {} # line_id -> loading_percent (envelope), for the map heat overlay
+ line_loading_winter: dict[int, float] = {} # line_id -> loading at winter_peak
+ line_loading_summer: dict[int, float] = {} # line_id -> loading at summer_min
+ trafo_loading_winter: dict[int, float] = {} # trafo_id -> loading at winter_peak
+ trafo_loading_summer: dict[int, float] = {} # trafo_id -> loading at summer_min
bus_vm: dict[int, float] = {} # bus_id -> voltage pu, for the map voltage overlay
voltage_violation_bus_ids: list[int] = [] # buses outside the voltage band
gsp_export_mw: float = 0.0 # peak power pushed UP through the GSP to transmission (worst case)
+ gsp_export_case: str | None = None # which case produced the export: "winter_peak" or "summer_min"
gsp_import_mw: float = 0.0 # peak power drawn DOWN from transmission (worst case)
+ gsp_import_winter_mw: float = 0.0 # import at winter_peak
+ gsp_import_summer_mw: float = 0.0 # import at summer_min
gsp_limit_mw: float | None = None # the GSP's export limit to transmission; None = unlimited
+ min_vm_winter: float = 0.0 # minimum voltage at winter_peak
+ max_vm_winter: float = 0.0 # maximum voltage at winter_peak
+ min_vm_summer: float = 0.0 # minimum voltage at summer_min
+ max_vm_summer: float = 0.0 # maximum voltage at summer_min
n1_screened: int = 0 # EHV elements outaged one at a time in the N-1 screen
n1_violations: list[dict] = [] # {outage_type, outage_id, outage_name, type, element_id, value, message}
diff --git a/packages/optimizer/src/gridforge_optimizer/years.py b/packages/optimizer/src/gridforge_optimizer/years.py
index 3bf9ba1..240cd89 100644
--- a/packages/optimizer/src/gridforge_optimizer/years.py
+++ b/packages/optimizer/src/gridforge_optimizer/years.py
@@ -101,6 +101,10 @@ def evaluate_year(
studies = study_windows(net, [o for o in outages if o.year == year], screen=n1_screen if n1 else None)
screen = n1_screen(net) if n1 else {"screened": 0, "violations": []}
_, _, m = feasibility(net) # the intact envelope the map and readings show
+ # Helper to convert pandas Series to dict[int, float]
+ def _loading_dict(s):
+ return {int(k): round(float(v), 1) for k, v in s.items()} if s is not None else {}
+
yr = YearResult(
year=year,
growth=round(growth, 4),
@@ -112,12 +116,23 @@ def evaluate_year(
max_vm_pu=round(m.get("max_vm", 0.0), 4),
overloaded_line_ids=overloaded_line_ids(net),
line_loading=line_loadings(net),
+ line_loading_winter=_loading_dict(m.get("line_loading_winter")),
+ line_loading_summer=_loading_dict(m.get("line_loading_summer")),
trafo_loading=trafo_loadings(net),
+ trafo_loading_winter=_loading_dict(m.get("trafo_loading_winter")),
+ trafo_loading_summer=_loading_dict(m.get("trafo_loading_summer")),
bus_vm=bus_voltages(net),
voltage_violation_bus_ids=voltage_violation_bus_ids(net),
gsp_export_mw=m.get("gsp_export_mw", 0.0),
+ gsp_export_case=m.get("gsp_export_case"),
gsp_import_mw=m.get("gsp_import_mw", 0.0),
+ gsp_import_winter_mw=m.get("gsp_import_winter_mw", 0.0),
+ gsp_import_summer_mw=m.get("gsp_import_summer_mw", 0.0),
gsp_limit_mw=m.get("gsp_limit_mw"),
+ min_vm_winter=round(m.get("min_vm_winter", 0.0), 4),
+ max_vm_winter=round(m.get("max_vm_winter", 0.0), 4),
+ min_vm_summer=round(m.get("min_vm_summer", 0.0), 4),
+ max_vm_summer=round(m.get("max_vm_summer", 0.0), 4),
n1_screened=screen["screened"],
n1_violations=screen["violations"],
outage_studies=studies,