Skip to content

Assign all limited outputs of Spice3 diodeModelLineInitEquations - #4858

Open
hubertus65 wants to merge 1 commit into
modelica:masterfrom
hubertus65:fix-spice3-diode-model-line-limits
Open

hubertus65 wants to merge 1 commit into
modelica:masterfrom
hubertus65:fix-spice3-diode-model-line-limits

Conversation

@hubertus65

Copy link
Copy Markdown
Member

Modelica.Electrical.Spice3.Internal.Diode.diodeModelLineInitEquations limits three model line parameters, but it only assigns them when a limit applies:

if (in_p.m_gradingCoeff > 0.9) then
  out_v.m_gradingCoeff := 0.9;
end if;

For any input within the limits (including the defaults M=0.5, EG=1.11, FC=0.5), out_v.m_gradingCoeff, out_v.m_activationEnergy and out_v.m_depletionCapCoeff are never assigned, so their values are undefined. Different tools return different values: in a cross-tool run, Modelon Impact and the old OpenModelica frontend gave 0, while the new OpenModelica frontend gave 273.15 for m_depletionCapCoeff.

The fix assigns the input value when no limit applies. This matches SPICE3, where DIOsetup limits the model parameters in place, and it uses the same form as diodeRenameParameters, which already applies the same three limits:

out_v.m_gradingCoeff := if (in_p.m_gradingCoeff > 0.9) then 0.9 else in_p.m_gradingCoeff;

No Spice3 model calls this function, so no example results change. Checked with OpenModelica 1.27.1: with default model card values the function now returns 0.5 / 1.11 / 0.5, and with M=0.95, EG=0.05, FC=0.99 it returns 0.9 / 0.1 / 0.95.

🤖 Generated with Claude Code

hubertus65 added a commit to hubertus65/ModelicaStandardLibrary that referenced this pull request Nov 3, 2026
…e3 fix

With diodeModelLineInitEquations assigning all limited outputs
(modelica#4858), vDiode.m_gradingCoeff, m_activationEnergy and
m_depletionCapCoeff are 0.5, 1.11 and 0.5 instead of undefined (0 in
Impact). Completion check run: 87/87 checks pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AHaumer

AHaumer commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

@hubertus65 if Claude isn't capable of defining reviewers, labels and milestone, you have to take care of that.
Unfortunately, neither Christoph Clauss nor Kristin Majety are available, we have no Library Officers for Spice3.
And no, I'm not familiar with Spice3.

@beutlich beutlich added the L: Electrical.Spice3 Issue addresses Modelica.Electrical.Spice3 label Nov 4, 2026
The function set out_v.m_gradingCoeff, m_activationEnergy and
m_depletionCapCoeff only when the input exceeded its limit, so for
every input within the limits these outputs were never assigned and
their values were undefined (tools return 0 or arbitrary values).
Assign the input value when no limit applies, as SPICE3 does
(DIOsetup limits the model parameters in place) and as
diodeRenameParameters already does for the same three parameters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@beutlich
beutlich force-pushed the fix-spice3-diode-model-line-limits branch from a418252 to 3fe5b8a Compare November 11, 2026 12:31
@MSL-RegressionTesting-CI

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L: Electrical.Spice3 Issue addresses Modelica.Electrical.Spice3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants