Skip to content

Add AD-safe overloads, Random.Utilities impure RNG, and scanInteger Ref overload#14

Merged
JKRT merged 2 commits into
OpenModelica:masterfrom
SVAGEN26:read-write-matrix-fix
Jun 11, 2026
Merged

Add AD-safe overloads, Random.Utilities impure RNG, and scanInteger Ref overload#14
JKRT merged 2 commits into
OpenModelica:masterfrom
SVAGEN26:read-write-matrix-fix

Conversation

@SVAGEN26

@SVAGEN26 SVAGEN26 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

This is SVAGEN26 (JKRT_CLAUDE), the Claude Code agent account acting on behalf of @JKRT.

Summary

  • AD-safe CombiTimeTable wrappers: adds _orcPrimal helper and ::Real overloads for ModelicaStandardTables_CombiTimeTable_getValue/getDerValue/getDer2Value so the DAE consistent-IC nonlinear solve can autodiff through table lookups without a ForwardDiff dependency (strips Dual to primal; table value is constant w.r.t. differentiated unknowns).
  • ModelicaStrings_scanInteger Ref overload: accepts Integer start/unsignedNumber and Ref{Cint} out-params, matching the calling convention used by codegen.
  • Modelica.Math.Random.Utilities impure RNG: Julia implementations of initializeImpureRandom, impureRandom, and impureRandomInteger backed by the existing ModelicaRandom_* C primitives; faithful to the MSL 3.2.3 algorithm.
  • Tests: new @testset blocks covering all new paths.

Test plan

  • Pkg.test("OMRuntimeExternalC") passes with no regressions
  • New ModelicaStrings_scanInteger Ref-overload testset passes
  • New Modelica.Math.Random.Utilities impure RNG testset passes (seeded determinism, range checks)
  • AD-safe CombiTimeTable overloads exercise correct _orcPrimal stripping

🤖 Generated with Claude Code

JKRT and others added 2 commits May 11, 2026 10:14
…ef overload

Adds ForwardDiff-transparent wrappers for CombiTimeTable getValue/getDerValue/getDer2Value
(strip Dual to primal so table lookups are constant w.r.t. differentiated unknowns), a
Ref-accepting overload for ModelicaStrings_scanInteger, and Julia implementations of
Modelica.Math.Random.Utilities initializeImpureRandom/impureRandom/impureRandomInteger
backed by the existing ModelicaRandom_* C primitives. Tests added for all new paths.

Co-Authored-By: JKRT <8775827+JKRT@users.noreply.github.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@JKRT JKRT self-requested a review June 11, 2026 10:26
@JKRT JKRT merged commit 7963225 into OpenModelica:master Jun 11, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants