@tellegen/engine 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -6
- package/dist/generated/contracts.d.ts +35 -17
- package/dist/generated/contracts.d.ts.map +1 -1
- package/dist/generated/contracts.js +3 -3
- package/dist/generated/study-contracts.d.ts +426 -0
- package/dist/generated/study-contracts.d.ts.map +1 -0
- package/dist/generated/study-contracts.js +4 -0
- package/dist/generated/study-contracts.js.map +1 -0
- package/dist/generated/study-schema.d.ts +2 -0
- package/dist/generated/study-schema.d.ts.map +1 -0
- package/dist/generated/study-schema.js +3 -0
- package/dist/generated/study-schema.js.map +1 -0
- package/dist/host.d.ts +12 -0
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +71 -17
- package/dist/host.js.map +1 -1
- package/dist/index.d.ts +360 -96
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +407 -89
- package/dist/index.js.map +1 -1
- package/dist/input-limit.d.ts +8 -0
- package/dist/input-limit.d.ts.map +1 -0
- package/dist/input-limit.js +14 -0
- package/dist/input-limit.js.map +1 -0
- package/dist/module.d.ts +1 -0
- package/dist/module.d.ts.map +1 -1
- package/dist/module.js.map +1 -1
- package/dist/protocol.d.ts +105 -20
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +67 -18
- package/dist/protocol.js.map +1 -1
- package/dist/study-document.d.ts +46 -0
- package/dist/study-document.d.ts.map +1 -0
- package/dist/study-document.js +183 -0
- package/dist/study-document.js.map +1 -0
- package/dist/study-document.test.d.ts +2 -0
- package/dist/study-document.test.d.ts.map +1 -0
- package/dist/study-document.test.js +119 -0
- package/dist/study-document.test.js.map +1 -0
- package/dist/wasm-pkg/tellegen.d.ts +191 -55
- package/dist/wasm-pkg/tellegen.js +754 -97
- package/dist/wasm-pkg/tellegen_bg.wasm +0 -0
- package/dist/wasm-pkg/tellegen_bg.wasm.d.ts +30 -6
- package/dist/worker.js +27 -3
- package/dist/worker.js.map +1 -1
- package/package.json +26 -4
package/dist/index.d.ts
CHANGED
|
@@ -5,12 +5,37 @@
|
|
|
5
5
|
import { type EngineHost } from "./host.js";
|
|
6
6
|
import type { BranchRatingDeltas, BrowserFormulation, DemandDeltas, NetworkBranch, NetworkBus, ProblemCaps, SensitivityColumn, Solution, SolveRequest, SolveResponse, SolveIteration } from "./generated/contracts.js";
|
|
7
7
|
export { CONTRACT_SOURCE_SHA256, CONTRACT_VERSION, FORMULATION_IDS, SOLVE_STATUSES, } from "./generated/contracts.js";
|
|
8
|
+
export { MAX_ENGINE_INPUT_BYTES } from "./input-limit.js";
|
|
8
9
|
export type { BranchRatingDeltas, BrowserFormulation, CaseSummary, DemandDeltas, Network, NetworkBranch, NetworkBus, ProblemCaps, SensRequest, SensitivityColumn, SensitivityMatrix, Solution, SolveIteration, SolveRequest, SolveResponse, } from "./generated/contracts.js";
|
|
10
|
+
/** One structured PowerIO finding. */
|
|
11
|
+
export interface PowerIoDiagnostic {
|
|
12
|
+
code: string;
|
|
13
|
+
severity: "note" | "remark" | "warning" | "error";
|
|
14
|
+
message: string;
|
|
15
|
+
id?: string;
|
|
16
|
+
target?: string;
|
|
17
|
+
spans?: {
|
|
18
|
+
source: string;
|
|
19
|
+
byte_start: number;
|
|
20
|
+
byte_end: number;
|
|
21
|
+
}[];
|
|
22
|
+
related?: string[];
|
|
23
|
+
details?: Record<string, unknown>;
|
|
24
|
+
suggested_action?: string;
|
|
25
|
+
}
|
|
26
|
+
/** Compact display spelling for a structured PowerIO finding. */
|
|
27
|
+
export declare function formatPowerIoDiagnostic(diagnostic: PowerIoDiagnostic): string;
|
|
9
28
|
export interface CaseFileSummary {
|
|
10
29
|
name: string;
|
|
11
30
|
base_mva: number;
|
|
31
|
+
/** Canonical typed PowerIO bus rows. */
|
|
12
32
|
n_bus: number;
|
|
33
|
+
/** Canonical typed PowerIO branch rows. */
|
|
13
34
|
n_branch: number;
|
|
35
|
+
/** Rendered buses after analysis lowering; absent on older engine builds. */
|
|
36
|
+
n_analysis_bus?: number;
|
|
37
|
+
/** Rendered branches after analysis lowering; absent on older engine builds. */
|
|
38
|
+
n_analysis_branch?: number;
|
|
14
39
|
n_gen: number;
|
|
15
40
|
load_mw: number;
|
|
16
41
|
gen_mw: number;
|
|
@@ -20,19 +45,26 @@ export interface CaseFileSummary {
|
|
|
20
45
|
* package echoes the kind it was saved with), `synthetic_pending` when the
|
|
21
46
|
* case awaits placement. */
|
|
22
47
|
coords_kind: "file" | "synthetic_pending" | "synthetic" | "manual";
|
|
48
|
+
/** Findings produced while PowerIO parsed the retained module. */
|
|
49
|
+
diagnostics: PowerIoDiagnostic[];
|
|
50
|
+
/** Tellegen display notes, such as omitted unlocated analysis rows. */
|
|
23
51
|
warnings: string[];
|
|
24
52
|
}
|
|
25
53
|
export interface TopologyBus {
|
|
26
54
|
id: number;
|
|
27
|
-
/**
|
|
28
|
-
uid: string;
|
|
55
|
+
/** PowerIO row uid when the source carries one. */
|
|
56
|
+
uid: string | null;
|
|
57
|
+
/** False for a display-only row synthesized by analysis lowering. */
|
|
58
|
+
editable?: boolean;
|
|
29
59
|
demand_mw: number;
|
|
30
60
|
gen_mw: number;
|
|
31
61
|
}
|
|
32
62
|
export interface TopologyBranch {
|
|
33
63
|
id: number;
|
|
34
|
-
/**
|
|
35
|
-
uid: string;
|
|
64
|
+
/** PowerIO row uid when the source carries one. */
|
|
65
|
+
uid: string | null;
|
|
66
|
+
/** False for a display-only row synthesized by analysis lowering. */
|
|
67
|
+
editable?: boolean;
|
|
36
68
|
from: number;
|
|
37
69
|
to: number;
|
|
38
70
|
rate_mw: number;
|
|
@@ -45,9 +77,13 @@ export interface Topology {
|
|
|
45
77
|
/** One parse per dropped file: summary stats, plus map geometry when the
|
|
46
78
|
* file carries coordinates and topology for synthetic placement otherwise. */
|
|
47
79
|
export interface IngestedCase extends CaseFileSummary {
|
|
48
|
-
|
|
80
|
+
/** Calculation declared by a typed problem instance. */
|
|
81
|
+
formulation?: Formulation;
|
|
82
|
+
/** Generation 2 PowerIO IR used for display edits and every solver Study. */
|
|
83
|
+
module_json: string;
|
|
49
84
|
topology: Topology;
|
|
50
85
|
view: {
|
|
86
|
+
coordinate_space?: "geographic" | "diagram";
|
|
51
87
|
buses: NetworkBus[];
|
|
52
88
|
branches: NetworkBranch[];
|
|
53
89
|
} | null;
|
|
@@ -69,6 +105,8 @@ export interface DistGraphBus {
|
|
|
69
105
|
id: string;
|
|
70
106
|
terminals: string[];
|
|
71
107
|
grounded: string[];
|
|
108
|
+
/** Declared or conservative conventional neutral terminal, when present. */
|
|
109
|
+
neutral_terminal?: string | null;
|
|
72
110
|
xy?: [number, number];
|
|
73
111
|
load_kw: number;
|
|
74
112
|
gen_kw: number;
|
|
@@ -92,13 +130,12 @@ export interface DistGraph {
|
|
|
92
130
|
buses: DistGraphBus[];
|
|
93
131
|
edges: DistGraphEdge[];
|
|
94
132
|
}
|
|
95
|
-
/**
|
|
96
|
-
* load and generation (kW), parse warnings, coordinate provenance, and the
|
|
97
|
-
* bus/terminal graph. No solve, no network JSON — distribution cases are viewed,
|
|
98
|
-
* not solved. `coords_kind` tells the frontend how to place buses: `geographic`
|
|
99
|
-
* drops `xy` straight onto the map, `planar` fits provided positions into a box
|
|
100
|
-
* at a placement center, `synthetic` runs the force layout. */
|
|
133
|
+
/** Multiconductor case data, terminal graph, and retained PowerIO IR. */
|
|
101
134
|
export interface IngestedDistCase {
|
|
135
|
+
module_json?: string;
|
|
136
|
+
geo_layer?: string;
|
|
137
|
+
mc_pf_enabled?: boolean;
|
|
138
|
+
mc_pf_unavailable_reason?: string | null;
|
|
102
139
|
name: string | null;
|
|
103
140
|
model: "multiconductor";
|
|
104
141
|
n_bus: number;
|
|
@@ -111,6 +148,10 @@ export interface IngestedDistCase {
|
|
|
111
148
|
n_ibr: number;
|
|
112
149
|
n_source: number;
|
|
113
150
|
n_shunt: number;
|
|
151
|
+
/** Capacitor banks read as their own type, which only the BMOPF reader does.
|
|
152
|
+
* A `.dss` or PMD capacitor counts in `n_shunt` instead. Optional because an
|
|
153
|
+
* older compatible engine payload can omit it. */
|
|
154
|
+
n_capacitor?: number;
|
|
114
155
|
load_kw: number;
|
|
115
156
|
gen_kw: number;
|
|
116
157
|
base_frequency: number;
|
|
@@ -118,66 +159,137 @@ export interface IngestedDistCase {
|
|
|
118
159
|
placed_buses: number;
|
|
119
160
|
coords_space: "geographic" | "projected" | "diagram" | "unknown" | "none";
|
|
120
161
|
coords_kind: "geographic" | "planar" | "synthetic";
|
|
121
|
-
|
|
162
|
+
diagnostics: PowerIoDiagnostic[];
|
|
122
163
|
graph: DistGraph;
|
|
164
|
+
/** Explicit capability from the reader; absent means inspection only. */
|
|
165
|
+
mc_pf_supported?: boolean;
|
|
166
|
+
/** Reader explanation for an inspection-only distribution payload. */
|
|
167
|
+
mc_pf_reason?: string;
|
|
123
168
|
}
|
|
124
|
-
/** A
|
|
125
|
-
*
|
|
126
|
-
* bus id and `rates` by branch id — the numeric keys the sliders use. */
|
|
127
|
-
export interface LoadedPackage extends IngestedCase {
|
|
128
|
-
formulation: Formulation;
|
|
129
|
-
options: {
|
|
130
|
-
shed: boolean;
|
|
131
|
-
warm_start: boolean;
|
|
132
|
-
};
|
|
133
|
-
deltas: DemandDeltas;
|
|
134
|
-
rates: BranchRatingDeltas;
|
|
135
|
-
}
|
|
136
|
-
/** A study state written to a target format: the serialized case text, the writer's
|
|
137
|
-
* fidelity warnings (empty when the conversion is faithful), and the format token and
|
|
138
|
-
* file extension so a caller can name the download. */
|
|
169
|
+
/** A materialized case written to a target format: the serialized case text,
|
|
170
|
+
* this output operation's diagnostics, and the format token and file extension. */
|
|
139
171
|
export interface ExportedCase {
|
|
140
172
|
text: string;
|
|
141
|
-
|
|
173
|
+
diagnostics: PowerIoDiagnostic[];
|
|
142
174
|
format: string;
|
|
143
175
|
extension: string;
|
|
144
176
|
}
|
|
177
|
+
/** One weighted LMP objective term, addressed by its PowerIO bus id. */
|
|
178
|
+
export interface CapacityPlanBusWeightJson {
|
|
179
|
+
bus: number;
|
|
180
|
+
weight: number;
|
|
181
|
+
}
|
|
182
|
+
export type ImplicitObjectiveJson = {
|
|
183
|
+
kind: "weighted_lmp";
|
|
184
|
+
weights: CapacityPlanBusWeightJson[];
|
|
185
|
+
};
|
|
186
|
+
/** Capacity increases considered by the bounded planning search. */
|
|
187
|
+
export interface CapacityPlanSpecJson {
|
|
188
|
+
objective: ImplicitObjectiveJson;
|
|
189
|
+
candidates: string[];
|
|
190
|
+
max_increase_per_branch_mw: number;
|
|
191
|
+
budget_mw: number;
|
|
192
|
+
increment_mw: number;
|
|
193
|
+
max_changed_lines: number;
|
|
194
|
+
exact_solve_budget: number;
|
|
195
|
+
}
|
|
196
|
+
export interface CapacityPlanRatingChangeJson {
|
|
197
|
+
branch: string;
|
|
198
|
+
delta_mw: number;
|
|
199
|
+
}
|
|
200
|
+
/** One recorded search step: the gradient direction, the trial, the first
|
|
201
|
+
* order prediction, the exact outcome, and whether the step was kept. */
|
|
202
|
+
export interface CapacityPlanIterationJson {
|
|
203
|
+
gradient: Array<{
|
|
204
|
+
branch: string;
|
|
205
|
+
value: number;
|
|
206
|
+
}>;
|
|
207
|
+
delta_mw: CapacityPlanRatingChangeJson[];
|
|
208
|
+
predicted_phi_delta: number;
|
|
209
|
+
exact_phi_delta: number | null;
|
|
210
|
+
first_order_error: number | null;
|
|
211
|
+
first_order_error_rel: number | null;
|
|
212
|
+
accepted: boolean;
|
|
213
|
+
reason: string;
|
|
214
|
+
}
|
|
215
|
+
export interface CapacityPlanResultSummaryJson {
|
|
216
|
+
phi: number;
|
|
217
|
+
declared_objective: number;
|
|
218
|
+
/** One-based position in this planning operation's exact solve budget. */
|
|
219
|
+
exact_solve: number;
|
|
220
|
+
}
|
|
221
|
+
/** The outcome of one bounded planning search and its unapplied
|
|
222
|
+
* proposal. */
|
|
223
|
+
export interface CapacityPlanOutcomeJson {
|
|
224
|
+
baseline: CapacityPlanResultSummaryJson;
|
|
225
|
+
exact_verified_result: CapacityPlanResultSummaryJson;
|
|
226
|
+
baseline_phi: number;
|
|
227
|
+
final_phi: number;
|
|
228
|
+
proposal: CapacityPlanRatingChangeJson[];
|
|
229
|
+
spent_budget_mw: number;
|
|
230
|
+
exact_solves: number;
|
|
231
|
+
iterations: CapacityPlanIterationJson[];
|
|
232
|
+
}
|
|
145
233
|
export declare function preloadEngine(): Promise<void>;
|
|
234
|
+
export type JsonDropKind = "module" | "transmission" | "distribution" | "ambiguous" | "unknown";
|
|
235
|
+
export interface JsonDropClassification {
|
|
236
|
+
kind: JsonDropKind;
|
|
237
|
+
format: string | null;
|
|
238
|
+
}
|
|
239
|
+
/** A JSON drop classified and ingested in one engine request. Unknown and
|
|
240
|
+
* ambiguous documents carry no payload; every recognized family carries the
|
|
241
|
+
* same typed payload returned by its dedicated ingest API. */
|
|
242
|
+
export type IngestedJsonDrop = {
|
|
243
|
+
/** A generation 2 `pio-ir` document; the payload family follows the
|
|
244
|
+
* network family carried by the module value. */
|
|
245
|
+
kind: "module";
|
|
246
|
+
format: null;
|
|
247
|
+
payload: IngestedCase | IngestedDistCase;
|
|
248
|
+
} | {
|
|
249
|
+
kind: "transmission";
|
|
250
|
+
format: string;
|
|
251
|
+
payload: IngestedCase;
|
|
252
|
+
} | {
|
|
253
|
+
kind: "distribution";
|
|
254
|
+
format: string;
|
|
255
|
+
payload: IngestedDistCase;
|
|
256
|
+
} | {
|
|
257
|
+
kind: "ambiguous" | "unknown";
|
|
258
|
+
format: null;
|
|
259
|
+
payload: null;
|
|
260
|
+
};
|
|
261
|
+
/** Classify JSON bytes through powerio's Rust routing table. A stored module
|
|
262
|
+
* passes the strict module reader so the payload family is authoritative. */
|
|
263
|
+
export declare function classifyJson(bytes: Uint8Array): Promise<JsonDropClassification>;
|
|
264
|
+
/** Classify and ingest one dropped JSON document in the same engine request.
|
|
265
|
+
* This avoids parsing a recognized package once to classify it and again to
|
|
266
|
+
* consume it. */
|
|
267
|
+
export declare function ingestJsonDrop(bytes: Uint8Array): Promise<IngestedJsonDrop>;
|
|
146
268
|
/** powerio format token from a file name; null for non-case files. */
|
|
147
269
|
export declare function formatOf(name: string): string | null;
|
|
148
|
-
|
|
270
|
+
/** Parse a balanced case file for viewing. Takes the upload's bytes rather than
|
|
271
|
+
* decoded text: powerio refuses a text format whose bytes are not UTF-8, where
|
|
272
|
+
* `File.text()` would have replaced each offending byte with U+FFFD. */
|
|
273
|
+
export declare function ingestCase(bytes: Uint8Array, format: string): Promise<IngestedCase>;
|
|
149
274
|
/** Parse a multiconductor distribution case for viewing. `format` is a
|
|
150
275
|
* distribution reader token (`dss`, `bmopf`, `pmd`) or `pio` for a `.pio.json`
|
|
151
276
|
* package carrying a multiconductor payload. Rejects on malformed input or a
|
|
152
277
|
* balanced package (which the study-restore path handles). */
|
|
153
278
|
export declare function ingestDistCase(text: string, format: string): Promise<IngestedDistCase>;
|
|
154
|
-
/**
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
export interface DisplayPreview {
|
|
159
|
-
substations: {
|
|
160
|
-
number: number;
|
|
161
|
-
name: string;
|
|
162
|
-
x: number;
|
|
163
|
-
y: number;
|
|
164
|
-
lon: number;
|
|
165
|
-
lat: number;
|
|
166
|
-
}[];
|
|
167
|
-
canvas_width: number;
|
|
168
|
-
canvas_height: number;
|
|
169
|
-
}
|
|
279
|
+
/** Byte entry point for a dropped distribution case or package. */
|
|
280
|
+
export declare function ingestDistCaseBytes(bytes: Uint8Array, format: string): Promise<IngestedDistCase>;
|
|
281
|
+
/** A PowerWorld drawing decoded in its declared diagram coordinate system. */
|
|
282
|
+
export type DisplayPreview = ParsedGeoLayer;
|
|
170
283
|
/** True for binary display files (PowerWorld .pwd), read via parseDisplay.
|
|
171
284
|
* Kept separate from formatOf: a .pwd is display data, not a case format. */
|
|
172
285
|
export declare function isDisplayFile(name: string): boolean;
|
|
173
286
|
export declare function parseDisplay(bytes: Uint8Array): Promise<DisplayPreview>;
|
|
174
287
|
/** A parsed geographic sidecar: the layer as its canonical `.geo.json`
|
|
175
288
|
* document (hand it to {@link applyGeo} or `BrowserStudy.applyGeoLayer`),
|
|
176
|
-
* the
|
|
177
|
-
* counts. */
|
|
289
|
+
* the reader's structured diagnostics, and the feature counts. */
|
|
178
290
|
export interface ParsedGeoLayer {
|
|
179
291
|
layer: string;
|
|
180
|
-
|
|
292
|
+
diagnostics: PowerIoDiagnostic[];
|
|
181
293
|
n_points: number;
|
|
182
294
|
n_routes: number;
|
|
183
295
|
}
|
|
@@ -188,9 +300,12 @@ export interface GeoApplyReport {
|
|
|
188
300
|
unmatched_features: number;
|
|
189
301
|
notes: string[];
|
|
190
302
|
}
|
|
191
|
-
/** The refreshed ingest payload after a geo apply: `
|
|
303
|
+
/** The refreshed ingest payload after a geo apply: `module_json`, the view,
|
|
192
304
|
* and the summary all reflect the applied coordinates, and `report` carries
|
|
193
305
|
* the matched/unmatched counts for the warnings panel. */
|
|
306
|
+
export interface AppliedMcGeoCase extends IngestedDistCase {
|
|
307
|
+
report: GeoApplyReport;
|
|
308
|
+
}
|
|
194
309
|
export interface AppliedGeoCase extends IngestedCase {
|
|
195
310
|
report: GeoApplyReport;
|
|
196
311
|
}
|
|
@@ -208,36 +323,159 @@ export declare function parseGeo(bytes: Uint8Array, hint: string): Promise<Parse
|
|
|
208
323
|
/** Apply a parsed layer onto a case network (matching by uid, external id,
|
|
209
324
|
* name, and the unordered branch endpoint pair). Rejects when nothing
|
|
210
325
|
* matched. */
|
|
211
|
-
export declare function applyGeo(
|
|
326
|
+
export declare function applyGeo(moduleJson: string, layer: string): Promise<AppliedGeoCase>;
|
|
327
|
+
/** Apply geographic or drawing coordinates to a multiconductor case. */
|
|
328
|
+
export declare function applyMcGeo(moduleJson: string, layer: string): Promise<AppliedMcGeoCase>;
|
|
212
329
|
/** Stamp a computed layout (bus id => [lon, lat]) onto a case network with
|
|
213
330
|
* its provenance, so saves and exports carry it. */
|
|
214
|
-
export declare function applyLayout(
|
|
331
|
+
export declare function applyLayout(moduleJson: string, coords: Record<number, [number, number]>, kind: "synthetic" | "manual"): Promise<StampedLayoutCase>;
|
|
215
332
|
/** A case's coordinates as a canonical `.geo.json` document. Rejects when the
|
|
216
333
|
* case carries none. */
|
|
217
|
-
export declare function extractGeo(
|
|
334
|
+
export declare function extractGeo(moduleJson: string): Promise<string>;
|
|
218
335
|
/** Fill case coordinates from a PowerWorld `.pwd` sibling: substation symbols
|
|
219
336
|
* project to approximate longitude/latitude and join onto buses through the
|
|
220
337
|
* `SubNum` extras key. Rejects when no bus joined. */
|
|
221
|
-
export declare function applyDisplayGeo(
|
|
338
|
+
export declare function applyDisplayGeo(moduleJson: string, bytes: Uint8Array): Promise<AppliedGeoCase>;
|
|
222
339
|
export declare function capabilities(): Promise<ProblemCaps[]>;
|
|
223
|
-
export declare function
|
|
340
|
+
export declare function solveModule(moduleJson: string, request?: SolveRequest): Promise<SolveResponse>;
|
|
341
|
+
/** Portable terminal-aware result returned by the multiconductor fixed-point
|
|
342
|
+
* BMOPF entry point. Complex quantities use `{re, im}` so the JSON remains
|
|
343
|
+
* lossless across the wasm boundary. */
|
|
344
|
+
export interface McPfOptions {
|
|
345
|
+
tolerance?: number;
|
|
346
|
+
max_iterations?: number;
|
|
347
|
+
damping?: number;
|
|
348
|
+
zero_voltage_tolerance?: number;
|
|
349
|
+
/** Absolute physical KCL floor in amperes; default 1e-6. */
|
|
350
|
+
absolute_kcl_tolerance?: number;
|
|
351
|
+
/** Relative KCL tolerance against prepared incident current. */
|
|
352
|
+
relative_kcl_tolerance?: number;
|
|
353
|
+
/** Apply the OpenDSS-style bounded-voltage load envelope; default true. */
|
|
354
|
+
voltage_envelope?: boolean;
|
|
355
|
+
/** Nominal-impedance breakpoint in per unit; default 0.5. */
|
|
356
|
+
v_low_pu?: number;
|
|
357
|
+
/** Lower edge of the normal load-model range; default 0.85. */
|
|
358
|
+
v_min_pu?: number;
|
|
359
|
+
/** Upper edge of the normal load-model range; default 1.15. */
|
|
360
|
+
v_max_pu?: number;
|
|
361
|
+
}
|
|
362
|
+
export interface McComplex {
|
|
363
|
+
re: number;
|
|
364
|
+
im: number;
|
|
365
|
+
}
|
|
366
|
+
export interface McElementPort {
|
|
367
|
+
element: string;
|
|
368
|
+
kind: string;
|
|
369
|
+
branch: number;
|
|
370
|
+
bus: string;
|
|
371
|
+
terminal: string;
|
|
372
|
+
current_into_element: McComplex;
|
|
373
|
+
power_into_element: McComplex;
|
|
374
|
+
}
|
|
375
|
+
export interface McSourceReaction {
|
|
376
|
+
source: string;
|
|
377
|
+
terminal: string;
|
|
378
|
+
current_into_network: McComplex;
|
|
379
|
+
power_into_network: McComplex;
|
|
380
|
+
}
|
|
381
|
+
export interface McPfResult {
|
|
382
|
+
converged: boolean;
|
|
383
|
+
voltage_valid: boolean;
|
|
384
|
+
min_voltage_pu: number | null;
|
|
385
|
+
max_voltage_pu: number | null;
|
|
386
|
+
voltage_violations: Array<{
|
|
387
|
+
load: string;
|
|
388
|
+
branch: number;
|
|
389
|
+
bus: string;
|
|
390
|
+
voltage: number;
|
|
391
|
+
nominal_voltage: number;
|
|
392
|
+
voltage_pu: number;
|
|
393
|
+
bound: "minimum" | "maximum";
|
|
394
|
+
}>;
|
|
395
|
+
iterations: number;
|
|
396
|
+
factorization_count: number;
|
|
397
|
+
matrix_dimension: number;
|
|
398
|
+
matrix_nonzeros: number;
|
|
399
|
+
voltage_change: number;
|
|
400
|
+
physical_kcl_residual: number;
|
|
401
|
+
scaled_kcl_residual: number;
|
|
402
|
+
terminals: Array<{
|
|
403
|
+
bus: string;
|
|
404
|
+
terminal: string;
|
|
405
|
+
voltage: McComplex;
|
|
406
|
+
current_into_network: McComplex;
|
|
407
|
+
power_into_network: McComplex;
|
|
408
|
+
}>;
|
|
409
|
+
element_ports: McElementPort[];
|
|
410
|
+
source_reactions: McSourceReaction[];
|
|
411
|
+
}
|
|
412
|
+
/** Self-contained saved Study result for a supported distribution AC PF.
|
|
413
|
+
* The input and solution modules make this replayable; `result` is the rich
|
|
414
|
+
* terminal/element view rendered by the Study panel. */
|
|
415
|
+
export interface McStudySnapshot {
|
|
416
|
+
schema: "tellegen-mc-pf-study";
|
|
417
|
+
version: 1;
|
|
418
|
+
id: string;
|
|
419
|
+
title: string;
|
|
420
|
+
formulation: "mc_ac_pf";
|
|
421
|
+
input_module: string;
|
|
422
|
+
solution_module: string;
|
|
423
|
+
options: McPfOptions;
|
|
424
|
+
result: McPfResult;
|
|
425
|
+
}
|
|
426
|
+
export interface McLoadPowerEdit {
|
|
427
|
+
load: string;
|
|
428
|
+
branch: number;
|
|
429
|
+
p_w: number;
|
|
430
|
+
q_var: number;
|
|
431
|
+
}
|
|
432
|
+
export interface McLoadBranchState extends McLoadPowerEdit {
|
|
433
|
+
bus: string;
|
|
434
|
+
base_p_w: number;
|
|
435
|
+
base_q_var: number;
|
|
436
|
+
}
|
|
437
|
+
/** A live fixed-point current-injection solver retained in the shared engine
|
|
438
|
+
* worker. Load edits reuse its sparse LU and previous converged phasors. */
|
|
439
|
+
export declare class BrowserMcPfSession {
|
|
440
|
+
private readonly host;
|
|
441
|
+
private readonly handle;
|
|
442
|
+
constructor(host: EngineHost, handle: number);
|
|
443
|
+
result(): Promise<McPfResult>;
|
|
444
|
+
loadBranches(): Promise<McLoadBranchState[]>;
|
|
445
|
+
replaceLoadPowers(edits: McLoadPowerEdit[]): Promise<McPfResult>;
|
|
446
|
+
inputModule(): Promise<string>;
|
|
447
|
+
snapshot(studyId: string, studyTitle: string): Promise<McStudySnapshot>;
|
|
448
|
+
free(): void;
|
|
449
|
+
}
|
|
450
|
+
/** Parse, prepare, factor, and solve a persistent multiconductor PF session. */
|
|
451
|
+
export declare function createMcPfSession(moduleJson: string, options?: McPfOptions, signal?: AbortSignal): Promise<BrowserMcPfSession>;
|
|
452
|
+
/** Parse and solve a raw BMOPF multiconductor case in the wasm module. */
|
|
453
|
+
export declare function solveMcBmopf(text: string, options?: McPfOptions): Promise<McPfResult>;
|
|
454
|
+
/** Solve a stored PowerIO multiconductor module through the same PF engine. */
|
|
455
|
+
export declare function solveMcModule(moduleJson: string, options?: McPfOptions, signal?: AbortSignal): Promise<McPfResult>;
|
|
456
|
+
/** Solve a supported multiconductor Study input and return a replayable
|
|
457
|
+
* snapshot containing the typed input, PowerIO solution, and rich result. */
|
|
458
|
+
export declare function solveMcStudy(moduleJson: string, studyId: string, studyTitle: string, options?: McPfOptions, signal?: AbortSignal): Promise<McStudySnapshot>;
|
|
459
|
+
/** Validate and canonicalize a saved multiconductor Study snapshot without
|
|
460
|
+
* running the solver again. */
|
|
461
|
+
export declare function replayMcStudy(snapshotJson: string): Promise<McStudySnapshot>;
|
|
462
|
+
/** Update both saved modules with matching positions while retaining the solved values. */
|
|
463
|
+
export declare function applyMcStudyGeo(snapshot: McStudySnapshot, layer: string): Promise<McStudySnapshot>;
|
|
224
464
|
export { errorText } from "./errors.js";
|
|
225
465
|
/** True when the engine wasm module has failed to load in a way it can never
|
|
226
466
|
* recover from in this browser. Nothing solves client side when this is true;
|
|
227
467
|
* the caller decides whether a server fallback exists. */
|
|
228
468
|
export declare function isPermanentEngineFailure(message: string): boolean;
|
|
229
|
-
/** The sensitivity selection target: a bus (the
|
|
230
|
-
* branch (the
|
|
469
|
+
/** The sensitivity selection target: a bus (the nodal-value/demand column at that bus) or a
|
|
470
|
+
* branch (the nodal-value/rating column at that branch). Ids are the external element
|
|
231
471
|
* ids; `BrowserStudy` translates them to the engine's dense indices. */
|
|
232
472
|
export type SensTarget = {
|
|
233
473
|
bus: number;
|
|
234
474
|
} | {
|
|
235
475
|
branch: number;
|
|
236
476
|
};
|
|
237
|
-
/**
|
|
238
|
-
*
|
|
239
|
-
* are the engine's serde-lowercase `Problem` variants accepted by `new Study(json, tag)`.
|
|
240
|
-
* `dcopf` is the default (zero regression from the prior fixed behavior). */
|
|
477
|
+
/** Calculation names accepted by the browser engine. Power flow returns voltages
|
|
478
|
+
* and flows; OPF calculations also return an objective and LMPs. */
|
|
241
479
|
export type Formulation = BrowserFormulation;
|
|
242
480
|
/** UI-facing formulation menu: tag, a short label, and a one-line description. The order
|
|
243
481
|
* is the menu order; `dcopf` is first and is the default. */
|
|
@@ -247,87 +485,113 @@ export declare const FORMULATIONS: ReadonlyArray<{
|
|
|
247
485
|
hint: string;
|
|
248
486
|
disabled?: boolean;
|
|
249
487
|
}>;
|
|
250
|
-
/**
|
|
488
|
+
/** DC OPF is the default calculation. */
|
|
251
489
|
export declare const DEFAULT_FORMULATION: Formulation;
|
|
252
|
-
/**
|
|
253
|
-
* parsed and the model built when the Study is created; `commit` solves exactly
|
|
490
|
+
/** Browser transport for the reactive demand drag. The retained PowerIO module
|
|
491
|
+
* is parsed and the model built when the Study is created; `commit` solves exactly
|
|
254
492
|
* at the UI's absolute demand delta state and `preview` returns a first-order
|
|
255
493
|
* linearization toward an absolute demand delta state, neither re-parsing the
|
|
256
494
|
* network. The wasm Study lives behind the engine host (a dedicated worker
|
|
257
495
|
* when the browser allows one), so every method is async. */
|
|
258
496
|
export declare class BrowserStudy {
|
|
259
497
|
#private;
|
|
260
|
-
constructor(host: EngineHost, handle: number);
|
|
498
|
+
constructor(host: EngineHost, handle: number, formulation?: Formulation, planningHost?: () => EngineHost);
|
|
261
499
|
/** Exact solve at demand = base + `deltas` and ratings = base + `rates`, replacing
|
|
262
|
-
* the committed point. When `target` names a bus or branch, its
|
|
500
|
+
* the committed point. When `target` names a bus or branch, its nodal-value/parameter
|
|
263
501
|
* column is computed in the *same* solve and returned (no second round-trip);
|
|
264
502
|
* otherwise `sensitivity` is null. `caseId` labels the returned column. Returns the
|
|
265
503
|
* UI Solution, the solver iterates, and the column. */
|
|
266
|
-
commit(caseId: string, deltas: DemandDeltas, rates: BranchRatingDeltas, target: SensTarget | null): Promise<{
|
|
504
|
+
commit(caseId: string, deltas: DemandDeltas, rates: BranchRatingDeltas, target: SensTarget | null, signal?: AbortSignal): Promise<{
|
|
267
505
|
solution: Solution;
|
|
268
506
|
iterations: SolveIteration[];
|
|
269
507
|
sensitivity: SensitivityColumn | null;
|
|
270
508
|
}>;
|
|
271
|
-
/** The
|
|
509
|
+
/** The nodal-value/parameter column at `target` for this study's formulation, computed by
|
|
272
510
|
* an exact re-solve at the edited point (the same one-call path `commit` uses, but
|
|
273
511
|
* returning only the column). Used when a bus or branch is selected so the overlay
|
|
274
512
|
* matches the active formulation rather than always the DC sensitivity. `caseId`
|
|
275
513
|
* labels the column; returns null when no recognized column comes back. */
|
|
276
514
|
sensitivity(caseId: string, deltas: DemandDeltas, rates: BranchRatingDeltas, target: SensTarget): Promise<SensitivityColumn | null>;
|
|
277
|
-
/** First
|
|
515
|
+
/** First order nodal value preview for replacing the committed point with
|
|
278
516
|
* demand = base + `deltas` and ratings = base + `rates`, with no re-solve:
|
|
279
|
-
* predicted per-bus
|
|
517
|
+
* predicted per-bus nodal value changes and the predicted objective change. */
|
|
280
518
|
preview(deltas: DemandDeltas, rates?: BranchRatingDeltas): Promise<{
|
|
281
|
-
|
|
519
|
+
prices: {
|
|
282
520
|
bus: number;
|
|
283
|
-
|
|
521
|
+
value: number;
|
|
284
522
|
}[];
|
|
285
523
|
objectiveDelta: number | null;
|
|
524
|
+
units: string | null;
|
|
286
525
|
}>;
|
|
287
526
|
/** The Study's current exact solution. Called immediately after Study creation
|
|
288
527
|
* to cache the base point for formulation comparisons. */
|
|
528
|
+
currentView(): Promise<import("./generated/study-contracts.js").SolveResponse>;
|
|
289
529
|
currentSolution(): Promise<Solution>;
|
|
290
|
-
/**
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
530
|
+
/** Materialize the current case as generation 2 PowerIO IR. */
|
|
531
|
+
saveModule(): Promise<string>;
|
|
532
|
+
/** Preserve the materialized instance's inner objective and constraints in PowerIO IR. */
|
|
533
|
+
saveInstanceModule(): Promise<string>;
|
|
534
|
+
/** Serialize the current exact DC OPF result as a PowerIO solution module.
|
|
535
|
+
* Its embedded problem instance contains the materialized case that was
|
|
536
|
+
* solved. */
|
|
537
|
+
saveSolutionModule(): Promise<string>;
|
|
538
|
+
/** Write the current materialized case to one PowerIO target format. */
|
|
539
|
+
export(format: string): Promise<ExportedCase>;
|
|
540
|
+
/** Run a bounded differentiable planning search over the committed
|
|
541
|
+
* operating point. Read only: the committed case, edits, and revision are
|
|
542
|
+
* untouched; the returned outcome carries the unapplied proposal and the
|
|
543
|
+
* search trace (gradient, per step prediction, exact result, first
|
|
544
|
+
* order error, accept or reject reason). Rejects on a non-DC formulation
|
|
545
|
+
* or an unknown element key. Worker hosts stop the solve on cancellation;
|
|
546
|
+
* the synchronous fallback finishes the wasm call but rejects its result. */
|
|
547
|
+
plan(spec: CapacityPlanSpecJson, signal?: AbortSignal): Promise<CapacityPlanOutcomeJson>;
|
|
295
548
|
/** Apply a parsed geographic layer (the canonical `.geo.json` from
|
|
296
549
|
* `parseGeo` or `applyLayout`) onto this study's base network, so the next
|
|
297
|
-
* `
|
|
550
|
+
* `saveModule` or export carries the coordinates on screen. Locations are
|
|
298
551
|
* metadata the model never reads; nothing re-solves. */
|
|
299
552
|
applyGeoLayer(layer: string): Promise<GeoApplyReport>;
|
|
300
553
|
/** Release the wasm Study; call when discarding it (e.g. the case's
|
|
301
|
-
*
|
|
554
|
+
* module input changed, or the case was removed). Fire and forget: the
|
|
302
555
|
* handle is invalid from this call on. */
|
|
303
556
|
free(): void;
|
|
304
557
|
}
|
|
305
|
-
export declare function createStudy(
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
export declare function loadPackage(text: string): Promise<LoadedPackage>;
|
|
310
|
-
/** Export a saved study package at commit `commit` to a powerio `format` (`matpower`,
|
|
311
|
-
* `psse`, `powerio-json`, ...). Returns the serialized case text, the writer's fidelity
|
|
312
|
-
* warnings, and the format token and file extension. */
|
|
313
|
-
export declare function exportStudy(packageJson: string, commit: number, format: string): Promise<ExportedCase>;
|
|
558
|
+
export declare function createStudy(moduleJson: string, formulation?: Formulation, options?: {
|
|
559
|
+
isolated?: boolean;
|
|
560
|
+
signal?: AbortSignal;
|
|
561
|
+
}): Promise<BrowserStudy>;
|
|
314
562
|
export interface EngineTransport {
|
|
315
563
|
preloadEngine(): Promise<void>;
|
|
316
|
-
|
|
564
|
+
classifyJson(bytes: Uint8Array): Promise<JsonDropClassification>;
|
|
565
|
+
ingestJsonDrop(bytes: Uint8Array): Promise<IngestedJsonDrop>;
|
|
566
|
+
ingestCase(bytes: Uint8Array, format: string): Promise<IngestedCase>;
|
|
317
567
|
ingestDistCase(text: string, format: string): Promise<IngestedDistCase>;
|
|
568
|
+
ingestDistCaseBytes(bytes: Uint8Array, format: string): Promise<IngestedDistCase>;
|
|
318
569
|
parseDisplay(bytes: Uint8Array): Promise<DisplayPreview>;
|
|
319
570
|
parseGeo(bytes: Uint8Array, hint: string): Promise<ParsedGeoLayer>;
|
|
320
|
-
applyGeo(
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
571
|
+
applyGeo(moduleJson: string, layer: string): Promise<AppliedGeoCase>;
|
|
572
|
+
applyMcGeo?(moduleJson: string, layer: string): Promise<AppliedMcGeoCase>;
|
|
573
|
+
applyLayout(moduleJson: string, coords: Record<number, [number, number]>, kind: "synthetic" | "manual"): Promise<StampedLayoutCase>;
|
|
574
|
+
extractGeo(moduleJson: string): Promise<string>;
|
|
575
|
+
applyDisplayGeo(moduleJson: string, bytes: Uint8Array): Promise<AppliedGeoCase>;
|
|
324
576
|
capabilities(): Promise<ProblemCaps[]>;
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
577
|
+
solveModule(moduleJson: string, request?: SolveRequest): Promise<SolveResponse>;
|
|
578
|
+
solveMcBmopf(text: string, options?: McPfOptions): Promise<McPfResult>;
|
|
579
|
+
solveMcModule(moduleJson: string, options?: McPfOptions, signal?: AbortSignal): Promise<McPfResult>;
|
|
580
|
+
solveMcStudy(moduleJson: string, studyId: string, studyTitle: string, options?: McPfOptions, signal?: AbortSignal): Promise<McStudySnapshot>;
|
|
581
|
+
createMcPfSession(moduleJson: string, options?: McPfOptions, signal?: AbortSignal): Promise<BrowserMcPfSession>;
|
|
582
|
+
replayMcStudy(snapshotJson: string): Promise<McStudySnapshot>;
|
|
583
|
+
applyMcStudyGeo?(snapshot: McStudySnapshot, layer: string): Promise<McStudySnapshot>;
|
|
584
|
+
createStudy(moduleJson: string, formulation?: Formulation, options?: {
|
|
585
|
+
isolated?: boolean;
|
|
586
|
+
signal?: AbortSignal;
|
|
587
|
+
}): Promise<BrowserStudy>;
|
|
329
588
|
}
|
|
330
589
|
export declare const browserWasmTransport: EngineTransport;
|
|
331
590
|
export declare function createBrowserWasmTransport(): EngineTransport;
|
|
332
591
|
export { BrowserStudy as Study };
|
|
592
|
+
export { IndexedDbStudyStore, StudyDocumentController, studyBackend, } from "./study-document.js";
|
|
593
|
+
export type { StudyBackend, StudyStore } from "./study-document.js";
|
|
594
|
+
export type { CreateStudy, StudyBundle, StudyDocument, StudyRequest, StudyOperation, StudyOperationResult, GoalRevision, DecisionSpace, StudyObjective, StateNode, Comparison, } from "./generated/study-contracts.js";
|
|
595
|
+
export type { ModelDetails, SolveResponse as StudyView, SearchOptions, StudySummary, } from "./generated/study-contracts.js";
|
|
596
|
+
export { studySchema } from "./generated/study-schema.js";
|
|
333
597
|
//# sourceMappingURL=index.d.ts.map
|