feat(core): extend AD, IA, and McCormick to support preserved array mode · modelscript/modelscript@7fb4ba4 · GitHub
Skip to content

Commit 7fb4ba4

Browse files
committed
feat(core): extend AD, IA, and McCormick to support preserved array mode
1 parent 980eabc commit 7fb4ba4

4 files changed

Lines changed: 6 additions & 4 deletions

File tree

‎packages/core/src/compiler/modelica/ad-codegen.ts‎

Lines changed: 2 additions & 2 deletions

‎packages/core/src/compiler/modelica/ad-jacobian.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ export function evaluateTapeReverse(ops: TapeOp[], t: Float64Array, outputIndex:
239239
export function buildAdJacobian(dae: ModelicaDAE): ((t: number, y: number[]) => number[][]) | null {
240240
// Gather derivative equations: der(x) = f(x, u)
241241
const derEqs: { state: string; rhs: ModelicaExpression }[] = [];
242-
for (const eq of dae.equations) {
242+
for (const eq of dae.sortedEquations.length > 0 ? dae.sortedEquations : dae.equations) {
243243
if (!("expression1" in eq && "expression2" in eq)) continue;
244244
const se = eq as { expression1: ModelicaExpression; expression2: ModelicaExpression };
245245
const ld = extractDer(se.expression1);

‎packages/core/src/compiler/modelica/dae.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export class ModelicaDAE {
1818
description: string | null;
1919
classKind = "class";
2020
equations: ModelicaEquation[] = [];
21+
/** Equations sorted by BLT transformation for simulation. */
22+
sortedEquations: ModelicaEquation[] = [];
2123
algorithms: ModelicaStatement[][] = [];
2224
/** Equations from `initial equation` sections. */
2325
initialEquations: ModelicaEquation[] = [];

‎packages/core/src/compiler/modelica/flattener.ts‎

Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)