oltc-selector 1.3.0 → 2.1.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.
Files changed (3) hide show
  1. package/README.md +17 -5
  2. package/bin/oltc.js +448 -98
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  填工况,给出 2025 目录里**最低满足**的型号。网页和 `oltc` CLI 共用同一份 `selectOltc` 引擎。
4
4
 
5
- **CLI:** `npx -y oltc-selector@1.3.0`,命令是 `oltc`。Agent 技能包另放,不在这个仓库里。
5
+ **CLI:** `npx -y oltc-selector@2.1.0`,命令是 `oltc`。Agent 技能包另放,不在这个仓库里。
6
6
  **网页:** [oltc-selector.vercel.app](https://oltc-selector.vercel.app/) · [GitHub Pages](https://erict16.github.io/oltc-selector/)
7
7
 
8
8
  私人辅助,不是厂家官网。型号是起点,出 OS 前要工程确认。
@@ -21,7 +21,13 @@ oltc --iu 350 --um 40.5 --conn D --reg W --pm 8
21
21
 
22
22
  oltc --octc --iu 800 --um 72.5 --conn D --series II --contact 6x5
23
23
  oltc --iu 600 --um 72.5 --conn Y --reg W --pm 8 --structure combined
24
- oltc --mva 25 --kv 110 --conn Y --reg W --pm 8
24
+ oltc --mva 25 --kv 110 --tap neutral --reg W --pm 8
25
+ oltc --mva 16 --kv 22 --tap line --winding star
26
+ # CV2III-600D/40.5-10193W
27
+
28
+ # Autotransformer tapped at the series/common junction (sized on the HV side)
29
+ oltc --mva 125 --kind auto --hv 225 --mv 115 --tap junction
30
+ # 3xCM2I-500/252D-10193W
25
31
  ```
26
32
 
27
33
  | Flag | Meaning | Default |
@@ -29,9 +35,14 @@ oltc --mva 25 --kv 110 --conn Y --reg W --pm 8
29
35
  | `--iu` / `--imax` | Max through-current Imax (A). **No** safety factor. | required unless `--mva` |
30
36
  | `--mva` `--kv` | Transformer MVA + tap-side kV → Imax (min tap + `--k`) | |
31
37
  | `--k` | Safety factor ≥ 1, **capacity path only** | 1.0 |
38
+ | `--kind two\|auto` | Transformer kind (`--auto` = `--kind auto`) | two-winding |
39
+ | `--tap` | Where the OLTC sits: `neutral` / `line` (two-winding), `junction` / `mv-line` (autotransformer). Sets current, Ust and Um. | neutral |
40
+ | `--winding star\|delta` | Tapped winding connection (two-winding) | star |
41
+ | `--hv` `--mv` | Autotransformer HV / MV rated kV | |
42
+ | `--earth-um` | OLTC insulation to earth from the OS; overrides the rule | |
32
43
  | `--um` | Equipment Um (kV) | derived from `--kv` on MVA path |
33
44
  | `--ust` | Step voltage (V) | 0, or derived on MVA path |
34
- | `--conn Y\|D` | Switch star / delta (not Dyn11) | Y |
45
+ | `--conn Y\|D` | Switch star / delta on the `--iu` path (with `--mva`, use `--tap`) | Y |
35
46
  | `--reg W\|G\|0` | Reversing / coarse-fine / linear | W |
36
47
  | `--pm` | ± steps | 8 |
37
48
  | `--octc` | Off-circuit 无载 (WSL/WSG) | on-load |
@@ -54,10 +65,11 @@ oltc --mva 25 --kv 110 --conn Y --reg W --pm 8
54
65
  6. **WSL / WDL existence is 2025-list row keys without prices** (`lib/listIndex.data.json`). Missing rows (no `WSLIV-2000D/126`, no `7x6E` @ 72.5) are not emitted.
55
66
  7. **WSG** is catalogue axes only (no 2025 list sheet in the index).
56
67
  8. **Typing Imax (`--iu`) does not apply a safety factor.** `--k` only applies on the transformer-capacity (`--mva`) path.
68
+ 9. **Um is set where the tap changer sits** (`lib/transformer.ts`). Line end: the winding system's class (132 kV → 145, 220 kV → 252). Neutral: the full class up to 72.5; above that 72.5 is assumed and flagged. Autotransformer: the HV system's class, combined types only (no CV / CV2 / SV).
57
69
 
58
70
  ## Web app
59
71
 
60
- 预选 66 / 110 / 220 kV 带常用工况。默认真变压器容量,星/角推出 Imax(最低分接和安全系数)。调压侧电压推出 Um。点「选型」之后才出型号。
72
+ 预选 66 / 110 / 220 kV 带常用工况。默认真变压器容量,星/角推出 Imax(最低分接和安全系数)。调压侧电压推出 Um。型号随参数实时更新,结果卡把工况和型号额定并排列出(电流、级电压、级容量、开关绝缘)。开关一组默认折叠,折叠时一行显示当前取值。手机上型号固定在底栏,点箭头跳到完整结果。
61
73
 
62
74
  ```bash
63
75
  npm install
@@ -68,7 +80,7 @@ npm run pack:cli
68
80
 
69
81
  GitHub Pages:`npm run build:gh`(`GH_PAGES=true`)。Vercel 根路径,不要设 `GH_PAGES`。
70
82
 
71
- 语言:中文、English、Tiếng Việt、Español、Türkçe、Русский。
83
+ 语言:中文、English、Tiếng Việt、Español、Türkçe、Bahasa Indonesia。
72
84
 
73
85
  ## OS regression
74
86
 
package/bin/oltc.js CHANGED
@@ -14,71 +14,6 @@ function parseDecimal(raw) {
14
14
  return { ok: true, value: n };
15
15
  }
16
16
 
17
- // lib/deriveUm.ts
18
- var RATED_TO_WINDING_UM = {
19
- 33: 40.5,
20
- 35: 40.5,
21
- 66: 72.5,
22
- 69: 72.5,
23
- 110: 126,
24
- 115: 126,
25
- 132: 145,
26
- 138: 145,
27
- 150: 170,
28
- 220: 252,
29
- 230: 252,
30
- 330: 363
31
- };
32
- var SNAP_UN = Object.keys(RATED_TO_WINDING_UM).map(Number).sort(
33
- (a, b) => a - b
34
- );
35
- function snapRatedKv(ratedKv) {
36
- if (!Number.isFinite(ratedKv) || ratedKv <= 0) return ratedKv;
37
- if (RATED_TO_WINDING_UM[ratedKv] != null) return ratedKv;
38
- let best = SNAP_UN[0];
39
- let bestDist = Math.abs(ratedKv - best);
40
- for (const u of SNAP_UN) {
41
- const d = Math.abs(ratedKv - u);
42
- if (d < bestDist) {
43
- best = u;
44
- bestDist = d;
45
- }
46
- }
47
- const rel = bestDist / Math.max(ratedKv, 1);
48
- if (rel <= 0.12 || bestDist <= 8) return best;
49
- return ratedKv;
50
- }
51
- function windingUmFromRatedKv(ratedKv) {
52
- const snapped = snapRatedKv(ratedKv);
53
- return RATED_TO_WINDING_UM[snapped] ?? snapped;
54
- }
55
- function deriveOltcUm(windingUmKv, connection) {
56
- if (connection !== "Y") return windingUmKv;
57
- if (windingUmKv >= 125.9 && windingUmKv <= 170.1) return 72.5;
58
- return windingUmKv;
59
- }
60
- function oltcUmFromRatedKv(ratedKv, connection) {
61
- return deriveOltcUm(windingUmFromRatedKv(ratedKv), connection);
62
- }
63
- function throughCurrentFromRated(mva, ratedKv, connection) {
64
- if (!(mva > 0) || !(ratedKv > 0)) return NaN;
65
- if (connection === "D") return mva * 1e3 / (3 * ratedKv);
66
- return mva * 1e3 / (Math.sqrt(3) * ratedKv);
67
- }
68
- function stepVoltageFromPercent(ratedKv, stepPercent, connection) {
69
- if (!(ratedKv > 0) || !(stepPercent > 0)) return NaN;
70
- const windingV = connection === "D" ? ratedKv * 1e3 : ratedKv * 1e3 / Math.sqrt(3);
71
- return windingV * stepPercent;
72
- }
73
- function maxThroughCurrent(ratedA, minusSteps, stepPercent) {
74
- if (!(ratedA > 0)) return NaN;
75
- if (!(minusSteps > 0) || !(stepPercent > 0)) return ratedA;
76
- const drop = minusSteps * stepPercent;
77
- if (drop <= 0) return ratedA;
78
- const denom = 1 - Math.min(drop, 0.45);
79
- return ratedA / denom;
80
- }
81
-
82
17
  // lib/tapCode.ts
83
18
  var PITCHES = [10, 12, 14, 16, 18];
84
19
  var W_DIAGRAMS = [
@@ -267,7 +202,7 @@ function resolveTapFields(input) {
267
202
  return row != null && row.pitch === pitch2;
268
203
  };
269
204
  if (reg === "linear") {
270
- const positions2 = input.positions ?? 9;
205
+ const positions2 = input.positions ?? (input.plusMinusSteps != null && input.plusMinusSteps > 0 ? 2 * input.plusMinusSteps + 1 : 9);
271
206
  const pitch2 = input.pitch ?? defaultPitch(positions2, reg);
272
207
  const mid2 = 0;
273
208
  return {
@@ -1503,6 +1438,21 @@ function selectOltc(input) {
1503
1438
  return s.connections.includes(input.connection) || s.connections.includes("any");
1504
1439
  });
1505
1440
  const wantStruct = input.preferStructure;
1441
+ if (input.transformerKind === "auto" && !wantOctc) {
1442
+ if (wantStruct === "compound") {
1443
+ return {
1444
+ ok: false,
1445
+ results: [],
1446
+ errorsEn: [
1447
+ "Autotransformers take combined types only: compound types (CV/CV2/SV) stop at 200 kV across the tap winding."
1448
+ ],
1449
+ errorsZh: [
1450
+ "\u81EA\u8026\u53D8\u53EA\u7528\u7EC4\u5408\u5F0F\uFF1A\u590D\u5408\u5F0F\uFF08CV/CV2/SV\uFF09\u8DE8\u8C03\u538B\u7ED5\u7EC4\u51B2\u51FB\u4E0A\u9650 200 kV\u3002"
1451
+ ]
1452
+ };
1453
+ }
1454
+ candidates = candidates.filter((s) => s.structure !== "compound");
1455
+ }
1506
1456
  if (wantStruct && wantStruct !== "auto") {
1507
1457
  candidates = candidates.filter((s) => s.structure === wantStruct);
1508
1458
  }
@@ -1976,6 +1926,222 @@ function optionsWithInsurance(results, dutyA, stepVoltageV, n = 3, need) {
1976
1926
  return step ? [step].slice(0, n) : [];
1977
1927
  }
1978
1928
 
1929
+ // lib/deriveUm.ts
1930
+ var RATED_TO_WINDING_UM = {
1931
+ 33: 40.5,
1932
+ 35: 40.5,
1933
+ 66: 72.5,
1934
+ 69: 72.5,
1935
+ 110: 126,
1936
+ 115: 126,
1937
+ 132: 145,
1938
+ 138: 145,
1939
+ 150: 170,
1940
+ 220: 252,
1941
+ 230: 252,
1942
+ 330: 363
1943
+ };
1944
+ var SNAP_UN = Object.keys(RATED_TO_WINDING_UM).map(Number).sort(
1945
+ (a, b) => a - b
1946
+ );
1947
+ var IEC_UM = [
1948
+ 3.6,
1949
+ 7.2,
1950
+ 12,
1951
+ 17.5,
1952
+ 24,
1953
+ 36,
1954
+ 40.5,
1955
+ 52,
1956
+ 72.5,
1957
+ 100,
1958
+ 123,
1959
+ 145,
1960
+ 170,
1961
+ 245,
1962
+ 300,
1963
+ 362,
1964
+ 420,
1965
+ 550,
1966
+ 800
1967
+ ];
1968
+ var CATALOGUE_UM = [12, 17.5, 40.5, 72.5, 126, 145, 170, 252, 300, 363];
1969
+ function nominalSystemKv(ratedKv) {
1970
+ let best = ratedKv;
1971
+ for (const u of SNAP_UN) {
1972
+ if (u <= ratedKv && (ratedKv - u) / ratedKv <= 0.12) best = u;
1973
+ }
1974
+ return best;
1975
+ }
1976
+ function iecUmFromRatedKv(ratedKv) {
1977
+ if (!(ratedKv > 0)) return NaN;
1978
+ const un = nominalSystemKv(ratedKv);
1979
+ return IEC_UM.find((u) => u >= un * 1.04) ?? NaN;
1980
+ }
1981
+ function catalogueUmFromRatedKv(ratedKv) {
1982
+ const um = iecUmFromRatedKv(ratedKv);
1983
+ if (!Number.isFinite(um)) return NaN;
1984
+ return CATALOGUE_UM.find((c) => c >= um - 1e-9) ?? um;
1985
+ }
1986
+ function maxThroughCurrent(ratedA, minusSteps, stepPercent) {
1987
+ if (!(ratedA > 0)) return NaN;
1988
+ if (!(minusSteps > 0) || !(stepPercent > 0)) return ratedA;
1989
+ const drop = minusSteps * stepPercent;
1990
+ if (drop <= 0) return ratedA;
1991
+ const denom = 1 - Math.min(drop, 0.45);
1992
+ return ratedA / denom;
1993
+ }
1994
+
1995
+ // lib/transformer.ts
1996
+ var TAP_POINTS_FOR = {
1997
+ two_winding: ["neutral", "line_end"],
1998
+ auto: ["auto_junction", "auto_mv_line"]
1999
+ };
2000
+ var SQRT3 = Math.sqrt(3);
2001
+ var fail = (zh, en) => ({
2002
+ ok: false,
2003
+ errorZh: zh,
2004
+ errorEn: en,
2005
+ connection: "Y",
2006
+ umSystemKv: NaN,
2007
+ actualUmKv: NaN,
2008
+ umKv: NaN,
2009
+ umRule: "line",
2010
+ umAssumed: false,
2011
+ ratedA: NaN,
2012
+ maxA: NaN,
2013
+ dutyA: NaN,
2014
+ currentKv: NaN,
2015
+ currentDivisor: "sqrt3",
2016
+ stepV: null,
2017
+ combinedOnly: false,
2018
+ cautionsZh: [],
2019
+ cautionsEn: []
2020
+ });
2021
+ var NEUTRAL_DEFAULT_UM = 72.5;
2022
+ function deriveDuty(spec) {
2023
+ const cautionsZh = [];
2024
+ const cautionsEn = [];
2025
+ const auto = spec.kind === "auto";
2026
+ if (!TAP_POINTS_FOR[spec.kind].includes(spec.tapPoint)) {
2027
+ return fail(
2028
+ "\u5F00\u5173\u4F4D\u7F6E\u548C\u53D8\u538B\u5668\u79CD\u7C7B\u4E0D\u5339\u914D\u3002",
2029
+ "Tap position does not fit the transformer kind."
2030
+ );
2031
+ }
2032
+ if (auto) {
2033
+ if (!(spec.hvKv > 0) || !(spec.mvKv > 0)) {
2034
+ return fail("\u81EA\u8026\u53D8\u8981\u586B\u9AD8\u538B\u548C\u4E2D\u538B\u989D\u5B9A\u7535\u538B\u3002", "Enter the autotransformer's HV and MV rated voltage.");
2035
+ }
2036
+ if (!(spec.hvKv > spec.mvKv)) {
2037
+ return fail("\u81EA\u8026\u53D8\u9AD8\u538B\u8981\u9AD8\u4E8E\u4E2D\u538B\u3002", "Autotransformer HV must be above MV.");
2038
+ }
2039
+ } else {
2040
+ if (!(spec.tapKv > 0)) {
2041
+ return fail("\u8BF7\u586B\u5199\u8C03\u538B\u7ED5\u7EC4\u989D\u5B9A\u7535\u538B\u3002", "Enter the tapped winding's rated voltage.");
2042
+ }
2043
+ if (spec.tapPoint === "neutral" && spec.winding === "delta") {
2044
+ return fail(
2045
+ "\u89D2\u5F62\u7ED5\u7EC4\u6CA1\u6709\u4E2D\u6027\u70B9\uFF0C\u5F00\u5173\u53EA\u80FD\u5728\u7EBF\u7AEF\u3002",
2046
+ "A delta winding has no neutral; the tap changer sits at the line end."
2047
+ );
2048
+ }
2049
+ }
2050
+ let currentKv;
2051
+ let currentDivisor;
2052
+ let stepBaseV;
2053
+ if (auto) {
2054
+ currentKv = spec.tapPoint === "auto_junction" ? spec.hvKv : spec.mvKv;
2055
+ currentDivisor = "sqrt3";
2056
+ stepBaseV = currentKv * 1e3 / SQRT3;
2057
+ } else if (spec.winding === "delta") {
2058
+ currentKv = spec.tapKv;
2059
+ currentDivisor = "three";
2060
+ stepBaseV = spec.tapKv * 1e3;
2061
+ } else {
2062
+ currentKv = spec.tapKv;
2063
+ currentDivisor = "sqrt3";
2064
+ stepBaseV = spec.tapKv * 1e3 / SQRT3;
2065
+ }
2066
+ const ratedA = spec.mva > 0 ? spec.mva * 1e3 / ((currentDivisor === "three" ? 3 : SQRT3) * currentKv) : NaN;
2067
+ const maxA = spec.stepFraction != null && spec.stepFraction > 0 ? maxThroughCurrent(ratedA, spec.minusSteps, spec.stepFraction) : ratedA;
2068
+ const k = spec.safetyK > 0 ? spec.safetyK : 1;
2069
+ const stepV = spec.stepFraction != null && spec.stepFraction > 0 ? stepBaseV * spec.stepFraction : null;
2070
+ let umSystemKv;
2071
+ let umKv;
2072
+ let umRule;
2073
+ let umAssumed = false;
2074
+ if (auto) {
2075
+ umSystemKv = spec.hvKv;
2076
+ umKv = catalogueUmFromRatedKv(spec.hvKv);
2077
+ umRule = "auto_hv";
2078
+ } else if (spec.tapPoint === "neutral") {
2079
+ umSystemKv = spec.tapKv;
2080
+ const lineClass = catalogueUmFromRatedKv(spec.tapKv);
2081
+ if (lineClass <= NEUTRAL_DEFAULT_UM) {
2082
+ umKv = lineClass;
2083
+ umRule = "neutral_full";
2084
+ if (lineClass === 40.5) umAssumed = true;
2085
+ } else {
2086
+ umKv = NEUTRAL_DEFAULT_UM;
2087
+ umRule = "neutral_assumed";
2088
+ umAssumed = true;
2089
+ }
2090
+ } else {
2091
+ umSystemKv = spec.tapKv;
2092
+ umKv = catalogueUmFromRatedKv(spec.tapKv);
2093
+ umRule = "line";
2094
+ }
2095
+ if (spec.earthUmKv != null && spec.earthUmKv > 0) {
2096
+ umKv = spec.earthUmKv;
2097
+ umRule = "explicit";
2098
+ umAssumed = false;
2099
+ }
2100
+ if (!Number.isFinite(umKv) || umKv > 363) {
2101
+ return fail(
2102
+ "\u7535\u538B\u8D85\u51FA\u76EE\u5F55\uFF1A\u5F00\u5173\u6700\u9AD8 Um 363 kV\u3002",
2103
+ "Voltage above the catalogue: the highest switch class is Um 363 kV."
2104
+ );
2105
+ }
2106
+ if (umRule === "neutral_full" && umAssumed) {
2107
+ cautionsZh.push("35 kV \u7EA7\u4E2D\u6027\u70B9\u5148\u6309 Um 40.5 \u9009\uFF1B\u4E0D\u5C11\u8BA2\u5355\uFF08\u4FC4\u7F57\u65AF\u3001\u571F\u8033\u5176\uFF09\u6309 72.5 \u4E70\uFF0C\u4EE5 OS \u4E3A\u51C6\u3002");
2108
+ cautionsEn.push("35 kV-class neutral sized at Um 40.5; many orders (Russia, Turkey) bought 72.5. The OS decides.");
2109
+ }
2110
+ if (umRule === "neutral_assumed") {
2111
+ cautionsZh.push(`\u4E2D\u6027\u70B9\u7EDD\u7F18\u672A\u7ED9\uFF0C\u5148\u6309 Um ${NEUTRAL_DEFAULT_UM} \u9009\uFF0C\u4EE5 OS \u4E3A\u51C6\u3002`);
2112
+ cautionsEn.push(`Neutral insulation not given: sized at Um ${NEUTRAL_DEFAULT_UM}; the OS decides.`);
2113
+ }
2114
+ if (auto) {
2115
+ if (spec.tapPoint === "auto_mv_line" && umRule === "auto_hv") {
2116
+ cautionsZh.push("HMR 230/121 kV \u5148\u4F8B\u6309\u5382\u5BB6\u6570\u636E\u7528 Um 170\u3002");
2117
+ cautionsEn.push("HMR 230/121 kV orders used Um 170 on the maker's data.");
2118
+ } else if (spec.tapPoint === "auto_junction" && umKv === 252 && umRule === "auto_hv") {
2119
+ cautionsZh.push("\u5148\u4F8B\uFF1A125 MVA 225/115/35 kV \xB18\xD71.25% \u2192 3\xD7SHZVI-600/252D-10193W\uFF082026-10-27\uFF09\u3002");
2120
+ cautionsEn.push("Precedent: 125 MVA 225/115/35 kV \xB18\xD71.25% \u2192 3\xD7SHZVI-600/252D-10193W (27 Oct 2026).");
2121
+ }
2122
+ cautionsZh.push("\u672A\u6838\uFF1A\u8DE8\u8C03\u538B\u7ED5\u7EC4\u51B2\u51FB\uFF08a \u503C\uFF09\u3001\u675F\u7F1A\u7535\u963B\u3002");
2123
+ cautionsEn.push("Not checked: impulse across the tap winding (a), tie-in resistor.");
2124
+ }
2125
+ return {
2126
+ ok: true,
2127
+ connection: spec.tapPoint === "neutral" ? "Y" : "D",
2128
+ umSystemKv,
2129
+ actualUmKv: iecUmFromRatedKv(umSystemKv),
2130
+ umKv,
2131
+ umRule,
2132
+ umAssumed,
2133
+ ratedA,
2134
+ maxA,
2135
+ dutyA: maxA * k,
2136
+ currentKv,
2137
+ currentDivisor,
2138
+ stepV,
2139
+ combinedOnly: auto,
2140
+ cautionsZh,
2141
+ cautionsEn
2142
+ };
2143
+ }
2144
+
1979
2145
  // lib/cli.ts
1980
2146
  var CliError = class extends Error {
1981
2147
  constructor(message) {
@@ -1996,6 +2162,7 @@ function num(raw, flag) {
1996
2162
  function parseCliArgs(argv) {
1997
2163
  const out = {
1998
2164
  conn: "Y",
2165
+ kind: "two_winding",
1999
2166
  reg: "reversing",
2000
2167
  octc: false,
2001
2168
  structure: "auto",
@@ -2100,6 +2267,56 @@ function parseCliArgs(argv) {
2100
2267
  i = n;
2101
2268
  continue;
2102
2269
  }
2270
+ if (a === "--kind") {
2271
+ out.given.add("kind");
2272
+ const [v, n] = take(i, a);
2273
+ const k = v.toLowerCase();
2274
+ if (k === "auto" || k === "autotransformer" || k === "\u81EA\u8026") out.kind = "auto";
2275
+ else if (k === "two" || k === "two-winding" || k === "\u53CC\u7ED5\u7EC4") {
2276
+ out.kind = "two_winding";
2277
+ } else throw new CliError(`--kind must be two or auto`);
2278
+ i = n;
2279
+ continue;
2280
+ }
2281
+ if (a === "--auto") {
2282
+ out.given.add("kind");
2283
+ out.kind = "auto";
2284
+ continue;
2285
+ }
2286
+ if (a === "--tap") {
2287
+ out.given.add("tap");
2288
+ const [v, n] = take(i, a);
2289
+ const map = {
2290
+ neutral: "neutral",
2291
+ line: "line_end",
2292
+ "line-end": "line_end",
2293
+ junction: "auto_junction",
2294
+ "mv-line": "auto_mv_line"
2295
+ };
2296
+ const t = map[v.toLowerCase()];
2297
+ if (!t) throw new CliError(`--tap must be neutral|line|junction|mv-line`);
2298
+ out.tap = t;
2299
+ i = n;
2300
+ continue;
2301
+ }
2302
+ if (a === "--winding") {
2303
+ out.given.add("winding");
2304
+ const [v, n] = take(i, a);
2305
+ const w = v.toLowerCase();
2306
+ if (w === "star" || w === "y") out.winding = "star";
2307
+ else if (w === "delta" || w === "d") out.winding = "delta";
2308
+ else throw new CliError(`--winding must be star or delta`);
2309
+ i = n;
2310
+ continue;
2311
+ }
2312
+ if (a === "--hv" || a === "--mv" || a === "--earth-um") {
2313
+ const key = a === "--hv" ? "hv" : a === "--mv" ? "mv" : "earthUm";
2314
+ out.given.add(key);
2315
+ const [v, n] = take(i, a);
2316
+ out[key] = num(v, a);
2317
+ i = n;
2318
+ continue;
2319
+ }
2103
2320
  if (a === "--reg") {
2104
2321
  out.given.add("reg");
2105
2322
  const [v, n] = take(i, a);
@@ -2209,18 +2426,31 @@ var CLI_HELP = `oltc \u2014 OLTC/OCTC type selection (package: oltc-selector, no
2209
2426
 
2210
2427
  Usage:
2211
2428
  oltc --iu 400 --um 72.5 --conn Y --reg W --pm 8
2212
- oltc --mva 25 --kv 110 --conn Y --reg W --pm 8
2429
+ oltc --mva 25 --kv 110 --tap neutral --reg W --pm 8
2430
+ oltc --mva 16 --kv 22 --tap line --winding star
2431
+ oltc --mva 125 --kind auto --hv 225 --mv 115 --tap junction
2213
2432
  oltc --octc --iu 800 --um 72.5 --conn D --series II --contact 6x5
2214
2433
  oltc --iu 600 --um 72.5 --conn Y --reg W --pm 8 --structure combined
2215
2434
 
2216
2435
  Flags:
2217
2436
  --iu, --imax A Max through-current (Imax). No safety factor.
2218
2437
  --mva MVA --kv kV Capacity path: Imax from rated I, minus steps, --step-pct, --k
2438
+ --kind two|auto Transformer kind (--auto = --kind auto). Default two-winding.
2439
+ --tap P Where the OLTC sits: neutral|line (two-winding),
2440
+ junction|mv-line (autotransformer, series/common junction
2441
+ or MV line lead). Capacity path; replaces --conn there.
2442
+ --winding star|delta Tapped winding connection (two-winding). Sets the current
2443
+ formula: star I = S/(\u221A3U), delta I = S/(3U).
2444
+ --hv kV --mv kV Autotransformer HV / MV rated voltage (with --kind auto).
2445
+ --earth-um kV OLTC insulation to earth from the OS or maker (catalogue
2446
+ class). Overrides the rule: line end = winding system,
2447
+ neutral \u226472.5 full else 72.5 assumed, autotransformer = HV.
2219
2448
  --um kV Equipment Um (OLTC). With --mva/--kv, derived if omitted.
2220
2449
  --ust V Step voltage. With --mva/--kv/--step-pct, derived if omitted.
2221
2450
  --step-pct % Step as percent (1.25 means 1.25%). Capacity path only.
2222
2451
  --k n Safety factor on capacity path only (default 1.0, same as the web app).
2223
- --conn Y|D Switch connection (star / delta). Default Y.
2452
+ --conn Y|D Switch connection (star point / line end). Default Y.
2453
+ On the capacity path, legacy: Y = star neutral, D = delta line end.
2224
2454
  --reg W|G|0 Reversing / coarse-fine / linear. Default W.
2225
2455
  --pm N \xB1 steps. Default 8.
2226
2456
  --pos, --positions Linear / OCTC positions.
@@ -2237,6 +2467,75 @@ Flags:
2237
2467
  Defaults match the web first paint: on-load, in-tank vacuum, structure auto,
2238
2468
  \xB18 mid-3 reversing. Omitting --octc and --structure auto is minimum-adequate.
2239
2469
  `;
2470
+ function cliTapPoint(args) {
2471
+ if (args.tap) return args.tap;
2472
+ if (args.kind === "auto") return "auto_junction";
2473
+ return args.conn === "D" || args.winding === "delta" ? "line_end" : "neutral";
2474
+ }
2475
+ function tapSetsConnection(args) {
2476
+ return args.mva != null || args.tap != null || args.kind === "auto" || args.winding === "delta";
2477
+ }
2478
+ function cliConnection(args) {
2479
+ if (!tapSetsConnection(args)) return args.conn;
2480
+ return cliTapPoint(args) === "neutral" ? "Y" : "D";
2481
+ }
2482
+ var pmGiven = (args) => args.given.has("pm") && args.pm != null && args.pm > 0;
2483
+ function cliPlusMinus(args) {
2484
+ if (pmGiven(args)) return { n: args.pm, mid: 3 };
2485
+ if (args.positions != null) {
2486
+ const n = plusMinusFromPositions(args.positions, args.reg);
2487
+ if (n == null) return null;
2488
+ const mid = lookupByPositions(args.positions, 3, args.reg) ? 3 : 1;
2489
+ return { n, mid };
2490
+ }
2491
+ if (args.given.has("pm")) return null;
2492
+ return args.pm != null && args.pm > 0 ? { n: args.pm, mid: 3 } : null;
2493
+ }
2494
+ function cliMinusSteps(args) {
2495
+ const fromPositions = args.positions != null && args.positions > 1 ? Math.ceil((args.positions - 1) / 2) : null;
2496
+ if (args.octc || args.reg === "linear") {
2497
+ if (fromPositions != null) return fromPositions;
2498
+ if (pmGiven(args)) return args.pm;
2499
+ return 8;
2500
+ }
2501
+ const pm = cliPlusMinus(args);
2502
+ if (pm) return pm.n;
2503
+ return fromPositions ?? 8;
2504
+ }
2505
+ function cliLinearPositions(args) {
2506
+ if (args.positions != null) return args.positions;
2507
+ if (pmGiven(args)) return Math.round(2 * args.pm + 1);
2508
+ return void 0;
2509
+ }
2510
+ function cliDuty(args) {
2511
+ if (args.mva == null) return null;
2512
+ const auto = args.kind === "auto";
2513
+ if (auto) {
2514
+ if (!(args.hv != null && args.hv > 0 && args.mv != null && args.mv > 0)) {
2515
+ throw new CliError("--kind auto with --mva needs --hv and --mv");
2516
+ }
2517
+ } else if (!(args.kv != null && args.kv > 0)) {
2518
+ throw new CliError("--mva requires --kv (tap-side rated voltage)");
2519
+ }
2520
+ const tap = cliTapPoint(args);
2521
+ const winding = args.winding ?? (tap === "neutral" || args.conn === "Y" ? "star" : "delta");
2522
+ const pct = args.stepPct != null && args.stepPct > 0 ? args.stepPct / 100 : 0.0125;
2523
+ const earth = args.earthUm != null && args.earthUm > 0 ? args.earthUm : args.um != null && args.um > 0 ? args.um : void 0;
2524
+ return deriveDuty({
2525
+ kind: args.kind,
2526
+ tapPoint: tap,
2527
+ winding,
2528
+ mva: args.mva,
2529
+ tapKv: args.kv ?? 0,
2530
+ hvKv: args.hv ?? 0,
2531
+ mvKv: args.mv ?? 0,
2532
+ minusSteps: cliMinusSteps(args),
2533
+ stepFraction: pct,
2534
+ // 与网页版首屏一致:容量路径默认不额外加安全系数
2535
+ safetyK: args.k != null && args.k > 0 ? args.k : 1,
2536
+ ...earth != null ? { earthUmKv: earth } : {}
2537
+ });
2538
+ }
2240
2539
  function cliToSelectInput(args) {
2241
2540
  const dutyKind = args.octc ? "octc" : "oltc";
2242
2541
  const oil = args.octc || args.oil || !args.vacuum;
@@ -2256,26 +2555,16 @@ function cliToSelectInput(args) {
2256
2555
  if (args.stepPct != null && args.mva == null) {
2257
2556
  throw new CliError("--step-pct needs --mva/--kv; give --ust on the --iu path");
2258
2557
  }
2259
- if (args.mva != null) {
2260
- if (!(args.kv != null && args.kv > 0)) {
2261
- throw new CliError("--mva requires --kv (tap-side rated voltage)");
2262
- }
2263
- const rated = throughCurrentFromRated(args.mva, args.kv, args.conn);
2264
- if (!Number.isFinite(rated) || rated <= 0) {
2265
- throw new CliError("Could not compute rated current from --mva/--kv");
2266
- }
2267
- const pct = args.stepPct != null && args.stepPct > 0 ? args.stepPct / 100 : 0.0125;
2268
- const minus = args.pm != null && args.pm > 0 ? args.pm : 8;
2269
- const iMax = maxThroughCurrent(rated, minus, pct);
2270
- const k = args.k != null && args.k > 0 ? args.k : 1;
2271
- iu = iMax * k;
2272
- if (um == null || !(um > 0)) {
2273
- um = oltcUmFromRatedKv(args.kv, args.conn);
2274
- }
2275
- if (!(ust > 0)) {
2276
- const v = stepVoltageFromPercent(args.kv, pct, args.conn);
2277
- if (Number.isFinite(v) && v > 0) ust = v;
2278
- }
2558
+ const duty = cliDuty(args);
2559
+ let conn = args.conn;
2560
+ if (duty) {
2561
+ if (!duty.ok) throw new CliError(duty.errorZh ?? duty.errorEn ?? "Bad transformer data");
2562
+ iu = duty.dutyA;
2563
+ if (um == null || !(um > 0)) um = duty.umKv;
2564
+ if (!(ust > 0) && duty.stepV != null) ust = duty.stepV;
2565
+ conn = duty.connection;
2566
+ } else {
2567
+ conn = cliConnection(args);
2279
2568
  }
2280
2569
  if (iu == null || !(iu > 0)) {
2281
2570
  throw new CliError("Need --iu (Imax) or --mva plus --kv");
@@ -2289,7 +2578,8 @@ function cliToSelectInput(args) {
2289
2578
  preferVacuum: !oil && dutyKind === "oltc",
2290
2579
  dutyKind,
2291
2580
  phases: args.phases,
2292
- connection: args.conn,
2581
+ connection: conn,
2582
+ ...args.kind === "auto" ? { transformerKind: "auto" } : {},
2293
2583
  throughCurrentA: iu,
2294
2584
  umKv: um,
2295
2585
  stepVoltageV: ust,
@@ -2306,11 +2596,13 @@ function cliToSelectInput(args) {
2306
2596
  input.positions = Math.round(2 * args.pm + 1);
2307
2597
  }
2308
2598
  } else if (args.reg === "linear") {
2309
- if (args.positions != null) input.positions = args.positions;
2599
+ const pos = cliLinearPositions(args);
2600
+ if (pos != null) input.positions = pos;
2310
2601
  } else {
2311
- if (args.pm != null && args.pm > 0) {
2312
- input.plusMinusSteps = args.pm;
2313
- input.midPositions = 3;
2602
+ const pm = cliPlusMinus(args);
2603
+ if (pm) {
2604
+ input.plusMinusSteps = pm.n;
2605
+ input.midPositions = pm.mid;
2314
2606
  }
2315
2607
  if (args.positions != null) input.positions = args.positions;
2316
2608
  }
@@ -2326,9 +2618,37 @@ var MOUNT_ZH = {
2326
2618
  };
2327
2619
  function assumptionsFromArgs(args, family) {
2328
2620
  const mark = (key) => args.given.has(key) ? "" : "\uFF08\u9ED8\u8BA4\uFF09";
2329
- const items = [
2330
- `conn=${args.conn} ${args.conn === "Y" ? "\u661F\u70B9" : "\u7EBF\u7AEF"}${mark("conn")}`
2331
- ];
2621
+ const items = [];
2622
+ const tapZh = {
2623
+ neutral: "\u4E2D\u6027\u70B9",
2624
+ line_end: "\u7EBF\u7AEF",
2625
+ auto_junction: "\u4E32\u8054/\u516C\u5171\u7ED5\u7EC4\u8FDE\u63A5\u70B9",
2626
+ auto_mv_line: "\u4E2D\u538B\u51FA\u7EBF"
2627
+ };
2628
+ const tapGiven = args.given.has("tap") || args.given.has("conn") || args.winding === "delta";
2629
+ if (args.mva != null) {
2630
+ const duty = cliDuty(args);
2631
+ const tap = cliTapPoint(args);
2632
+ items.push(`${args.kind === "auto" ? "\u81EA\u8026\u53D8" : "\u53CC\u7ED5\u7EC4"}${mark("kind")}`);
2633
+ items.push(`\u5F00\u5173\u5728${tapZh[tap]}${tapGiven ? "" : "\uFF08\u9ED8\u8BA4\uFF09"}`);
2634
+ if (args.kind !== "auto") {
2635
+ const w = args.winding ?? (tap === "neutral" || args.conn === "Y" ? "star" : "delta");
2636
+ items.push(`${w === "star" ? "\u661F\u5F62" : "\u89D2\u5F62"}\u7ED5\u7EC4${args.given.has("winding") ? "" : "\uFF08\u9ED8\u8BA4\uFF09"}`);
2637
+ }
2638
+ if (duty?.umAssumed) items.push(`\u5BF9\u5730 Um ${duty.umKv}\uFF08\u672A\u6307\u5B9A\uFF09`);
2639
+ } else {
2640
+ const conn = cliConnection(args);
2641
+ const derived = tapSetsConnection(args);
2642
+ items.push(
2643
+ `conn=${conn} ${conn === "Y" ? "\u661F\u70B9" : "\u7EBF\u7AEF"}${derived ? "" : mark("conn")}`
2644
+ );
2645
+ if (args.kind === "auto") items.push("\u81EA\u8026\u53D8");
2646
+ if (derived) {
2647
+ items.push(
2648
+ `\u5F00\u5173\u5728${tapZh[cliTapPoint(args)]}${tapGiven ? "" : "\uFF08\u9ED8\u8BA4\uFF09"}`
2649
+ );
2650
+ }
2651
+ }
2332
2652
  if (args.mva != null) {
2333
2653
  items.push(args.given.has("k") ? `k=${args.k}` : "k=1.0\uFF08\u9ED8\u8BA4\uFF09");
2334
2654
  items.push(
@@ -2357,8 +2677,11 @@ function assumptionsFromArgs(args, family) {
2357
2677
  );
2358
2678
  if (args.reg === "linear") {
2359
2679
  items.push(
2360
- args.positions != null ? `${args.positions} \u6863${mark("positions")}` : "\u6863\u6570\u672A\u6307\u5B9A"
2680
+ args.positions != null ? `${args.positions} \u6863${mark("positions")}` : pmGiven(args) ? `${cliLinearPositions(args)} \u6863\uFF08\u7531 \xB1${args.pm} \u63A8\uFF09` : "\u6863\u6570\u672A\u6307\u5B9A"
2361
2681
  );
2682
+ } else if (args.positions != null && !args.given.has("pm")) {
2683
+ const pm = cliPlusMinus(args);
2684
+ items.push(pm ? `${args.positions} \u6863\uFF08\xB1${pm.n}\uFF09` : `${args.positions} \u6863`);
2362
2685
  } else {
2363
2686
  items.push(`\xB1${args.pm ?? 8} \u6863${mark("pm")}`);
2364
2687
  }
@@ -2377,6 +2700,13 @@ function assumptionsLine(args, family) {
2377
2700
  }
2378
2701
  return `\u5047\u5B9A\uFF1A${items.join(" \xB7 ")}`;
2379
2702
  }
2703
+ var round1 = (n) => Math.round(n * 10) / 10;
2704
+ function basisLineZh(d) {
2705
+ const div = d.currentDivisor === "three" ? "3" : "\u221A3";
2706
+ const um = d.umRule === "explicit" ? `\u5BF9\u5730 Um ${d.umKv}\uFF08\u6307\u5B9A\uFF09` : d.umRule === "neutral_assumed" || d.umRule === "neutral_full" ? `\u4E2D\u6027\u70B9 Um ${d.umKv}${d.umAssumed ? "\uFF08\u5F85 OS \u6838\u5BF9\uFF09" : ""}` : `${d.umSystemKv} kV \u7CFB\u7EDF Um ${d.actualUmKv} \u2192 ${d.umKv} \u7EA7`;
2707
+ const ust = d.stepV == null ? "" : ` \xB7 Ust ${round1(d.stepV)} V`;
2708
+ return `I = S/(${div}\xD7${d.currentKv} kV) = ${round1(d.ratedA)} A\uFF0C\u6700\u4F4E\u6863 ${round1(d.maxA)} A${ust} \xB7 ${um}`;
2709
+ }
2380
2710
  function formatCliText(input, args) {
2381
2711
  const out = selectOltc(input);
2382
2712
  if (!out.ok || !out.results.length) {
@@ -2401,7 +2731,10 @@ function formatCliText(input, args) {
2401
2731
  primary.model,
2402
2732
  primary.reasonsZh[0] || primary.reasonsEn[0] || "\u6700\u4F4E\u6EE1\u8DB3"
2403
2733
  ];
2734
+ const duty = args ? cliDuty(args) : null;
2735
+ if (duty?.ok) lines.push(`\u4F9D\u636E\uFF1A${basisLineZh(duty)}`);
2404
2736
  for (const c of primary.cautionsZh) lines.push(`\u6CE8\u610F\uFF1A${c}`);
2737
+ for (const c of duty?.cautionsZh ?? []) lines.push(`\u6CE8\u610F\uFF1A${c}`);
2405
2738
  if (alts.length) {
2406
2739
  lines.push("");
2407
2740
  lines.push("\u5176\u4ED6");
@@ -2437,7 +2770,24 @@ function formatCliJson(input, args) {
2437
2770
  model: primary?.model ?? null,
2438
2771
  why: primary?.reasonsZh[0] ?? primary?.reasonsEn[0] ?? null,
2439
2772
  alts,
2440
- cautions: primary?.cautionsZh ?? [],
2773
+ cautions: [
2774
+ ...primary?.cautionsZh ?? [],
2775
+ ...(args ? cliDuty(args) : null)?.cautionsZh ?? []
2776
+ ],
2777
+ basis: (() => {
2778
+ const d = args ? cliDuty(args) : null;
2779
+ return d?.ok ? {
2780
+ connection: d.connection,
2781
+ ratedA: round1(d.ratedA),
2782
+ maxA: round1(d.maxA),
2783
+ stepV: d.stepV == null ? null : round1(d.stepV),
2784
+ umSystemKv: d.umSystemKv,
2785
+ actualUmKv: d.actualUmKv,
2786
+ umKv: d.umKv,
2787
+ umRule: d.umRule,
2788
+ umAssumed: d.umAssumed
2789
+ } : null;
2790
+ })(),
2441
2791
  assumptions: args ? assumptionsFromArgs(args, primary?.seriesCode) : [],
2442
2792
  errors: out.errorsZh.length ? out.errorsZh : out.errorsEn
2443
2793
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oltc-selector",
3
- "version": "1.3.0",
3
+ "version": "2.1.0",
4
4
  "description": "Huaming OLTC/OCTC type selection CLI. No prices. Same engine as the web app.",
5
5
  "bin": {
6
6
  "oltc": "bin/oltc.js"