@tscircuit/ngspice-spice-engine 0.0.23 → 0.0.25
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/dist/index.js +39 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -87,6 +87,42 @@ var parseTranParams = (spiceString) => {
|
|
|
87
87
|
return params;
|
|
88
88
|
};
|
|
89
89
|
|
|
90
|
+
// lib/normalize-pspice-initial-condition-nodes.ts
|
|
91
|
+
import {
|
|
92
|
+
parseToSpiceTokens,
|
|
93
|
+
significantTokens,
|
|
94
|
+
tokensToLogicalCards
|
|
95
|
+
} from "spicets";
|
|
96
|
+
var normalizePspiceInitialConditionNodes = (spiceString) => {
|
|
97
|
+
const cards = tokensToLogicalCards(parseToSpiceTokens(spiceString).tokens);
|
|
98
|
+
let normalizedSpice = spiceString;
|
|
99
|
+
for (const card of cards.toReversed()) {
|
|
100
|
+
const tokens = significantTokens(card.tokens);
|
|
101
|
+
if (tokens[0]?.raw.toLowerCase() !== ".ic") continue;
|
|
102
|
+
for (let voltageTokenIndex = tokens.length - 4; voltageTokenIndex >= 1; voltageTokenIndex--) {
|
|
103
|
+
const voltageToken = tokens[voltageTokenIndex];
|
|
104
|
+
if (voltageToken.raw.toLowerCase() !== "v" || tokens[voltageTokenIndex + 1]?.raw !== "(") {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
const closingParenthesisTokenIndex = tokens.findIndex(
|
|
108
|
+
(token, tokenIndex) => tokenIndex > voltageTokenIndex + 1 && token.raw === ")"
|
|
109
|
+
);
|
|
110
|
+
if (closingParenthesisTokenIndex <= voltageTokenIndex + 2 || tokens[closingParenthesisTokenIndex + 1]?.raw !== "=") {
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
const firstNodeToken = tokens[voltageTokenIndex + 2];
|
|
114
|
+
const lastNodeToken = tokens[closingParenthesisTokenIndex - 1];
|
|
115
|
+
const closingParenthesisToken = tokens[closingParenthesisTokenIndex];
|
|
116
|
+
const nodeName = spiceString.slice(
|
|
117
|
+
firstNodeToken.range.start.offset,
|
|
118
|
+
lastNodeToken.range.end.offset
|
|
119
|
+
);
|
|
120
|
+
normalizedSpice = normalizedSpice.slice(0, voltageToken.range.start.offset) + `${voltageToken.raw}(${nodeName})` + normalizedSpice.slice(closingParenthesisToken.range.end.offset);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return normalizedSpice;
|
|
124
|
+
};
|
|
125
|
+
|
|
90
126
|
// lib/normalize-pspice-switch-models.ts
|
|
91
127
|
import {
|
|
92
128
|
Model,
|
|
@@ -218,7 +254,9 @@ var rewritePspiceValueBooleanCarets = (spiceString) => {
|
|
|
218
254
|
var rewritePspiceCompatibilitySyntax = (spiceString) => normalizePspiceSwitchModels(
|
|
219
255
|
rewritePspiceCurrentSourceUnits(
|
|
220
256
|
rewritePspiceValueBooleanCarets(
|
|
221
|
-
|
|
257
|
+
normalizePspiceInitialConditionNodes(
|
|
258
|
+
rewritePspiceResistorTcPairs(spiceString)
|
|
259
|
+
)
|
|
222
260
|
)
|
|
223
261
|
)
|
|
224
262
|
);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/ngspice-spice-engine",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.25",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/tscircuit/ngspice-spice-engine"
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"format-si-unit": "^0.0.7",
|
|
30
30
|
"@biomejs/biome": "^2.2.7",
|
|
31
31
|
"@types/bun": "latest",
|
|
32
|
-
"spicets": "^0.0.
|
|
32
|
+
"spicets": "^0.0.6",
|
|
33
33
|
"tscircuit": "^0.0.805",
|
|
34
34
|
"tsup": "^8.5.0"
|
|
35
35
|
},
|