Skip to content
LIBRARY
Analog.Semiconductors.Tests.DiodeTemperature.md

Analog.Semiconductors.Tests.DiodeTemperature ​

Temperature-law check for Diode, with use_temperature_dependency = true.

The diode hangs across an ideal source, so the junction sees exactly Vbias:

vt_t = k*T/q,   x_d = Vbias/(N*vt_t)
i = Ids*(exlin(x_d, Maxexp) - 1) * (T/TNOM)^(XTI/N)
    * exp((T/TNOM - 1)*EG/(N*vt_t)) + Vbias/R

At the default MSL card with T = 293.15, vt_t = 2.5261712e-2 and the Maxexp knee sits at 0.378926 V:

  • Vbias = 0.3 (case1): x_d = 11.876, exponential. i = 4.8056091e-2 A.

  • Vbias = 0.4 (case2): x_d = 15.834, linear continuation. i = 2.0048530 A.

Note that T defaults to 293.15 while TNOM is 300.15, so the law is not inert at the default card — the two temperature factors contribute 0.93124 and 0.35900.

DiodeForward covers the same two branches with the law off, so between them every path through the equation is pinned in closed form. That matters because Diode has no OpenModelica cross-validation; see test/msl_sources/README.md.

The dummy RC branch supplies the one differential state a transient test needs.

Usage ​

ElectricalComponents.Analog.Semiconductors.Tests.DiodeTemperature(Vbias=0.3)

Parameters: ​

NameDescriptionUnitsDefault value
VbiasBias voltage applied across the diodeV0.3

Behavior ​

Source ​

dyad
"""
Temperature-law check for Diode, with `use_temperature_dependency = true`.

The diode hangs across an ideal source, so the junction sees exactly `Vbias`:
```
vt_t = k*T/q,   x_d = Vbias/(N*vt_t)
i = Ids*(exlin(x_d, Maxexp) - 1) * (T/TNOM)^(XTI/N)
    * exp((T/TNOM - 1)*EG/(N*vt_t)) + Vbias/R
```
At the default MSL card with `T = 293.15`, `vt_t = 2.5261712e-2` and the `Maxexp` knee
sits at 0.378926 V:

  * `Vbias = 0.3` (case1): `x_d = 11.876`, **exponential**. `i = 4.8056091e-2` A.
  * `Vbias = 0.4` (case2): `x_d = 15.834`, **linear continuation**. `i = 2.0048530` A.

Note that `T` defaults to 293.15 while `TNOM` is 300.15, so the law is *not* inert at
the default card — the two temperature factors contribute 0.93124 and 0.35900.

`DiodeForward` covers the same two branches with the law off, so between them every path
through the equation is pinned in closed form. That matters because `Diode` has no
OpenModelica cross-validation; see `test/msl_sources/README.md`.

The dummy RC branch supplies the one differential state a transient test needs.
"""
test component DiodeTemperature
  "Bias level"
  sig = BlockComponents.Sources.Constant(k = Vbias) {
    "Dyad": {"placement": {"diagram": {"x1": 20, "y1": 120, "x2": 120, "y2": 220}}}
  }
  "Bias source"
  vs = ElectricalComponents.Analog.Sources.VoltageSource() {
    "Dyad": {"placement": {"diagram": {"x1": 155, "y1": 225, "x2": 255, "y2": 325}}}
  }
  "Diode under test, default card, temperature law on"
  d = ElectricalComponents.Analog.Semiconductors.Diode(use_temperature_dependency = true) {
    "Dyad": {"placement": {"diagram": {"x1": 160, "y1": 330, "x2": 260, "y2": 430}}}
  }
  "Dummy branch resistor; provides a differential state without loading the diode"
  r_dummy = ElectricalComponents.Analog.Basic.Resistor(R = 1000) {
    "Dyad": {"placement": {"diagram": {"x1": 150, "y1": 450, "x2": 250, "y2": 550}}}
  }
  "Dummy branch capacitor"
  c_dummy = ElectricalComponents.Analog.Basic.Capacitor(C = 1u) {
    "Dyad": {"placement": {"diagram": {"x1": 350, "y1": 450, "x2": 450, "y2": 550}}}
  }
  "Ground reference"
  ground = ElectricalComponents.Analog.Basic.Ground() {
    "Dyad": {"placement": {"diagram": {"x1": 580, "y1": 420, "x2": 680, "y2": 520}}}
  }
  "Bias voltage applied across the diode"
  parameter Vbias::Voltage = 0.3
relations
  initial c_dummy.v = 0
  connect(sig.y, vs.V) {"Dyad": {"edges": [{"S": 1, "M": [{"x": 205, "y": 170}], "E": 2}], "path": {}}}
  connect(vs.p, d.p, r_dummy.p) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [{"x": 0, "y": 275}, {"x": 0, "y": 380}], "E": 2},
        {"S": 1, "M": [{"x": 0, "y": 275}, {"x": 0, "y": 500}], "E": 3}
      ],
      "path": {}
    }
  }
  connect(r_dummy.n, c_dummy.p) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
  connect(d.n, c_dummy.n, vs.n, ground.g) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [{"x": 500, "y": 380}, {"x": 500, "y": 500}], "E": 2},
        {"S": 1, "M": [{"x": 500, "y": 380}, {"x": 500, "y": 275}], "E": 3},
        {"S": 1, "M": [{"x": 630, "y": 380}], "E": 4}
      ],
      "path": {}
    }
  }
metadata {
  "Dyad": {
    "tests": {
      "case1": {
        "stop": 0.01,
        "atol": {"d.i": 1e-9},
        "expect": {"final": {"d.i": 0.048056091402}}
      },
      "case2": {
        "stop": 0.01,
        "params": {"Vbias": 0.4},
        "atol": {"d.i": 1e-8},
        "expect": {"final": {"d.i": 2.0048529624}}
      }
    }
  }
}
end
Flattened Source
dyad
"""
Temperature-law check for Diode, with `use_temperature_dependency = true`.

The diode hangs across an ideal source, so the junction sees exactly `Vbias`:
```
vt_t = k*T/q,   x_d = Vbias/(N*vt_t)
i = Ids*(exlin(x_d, Maxexp) - 1) * (T/TNOM)^(XTI/N)
    * exp((T/TNOM - 1)*EG/(N*vt_t)) + Vbias/R
```
At the default MSL card with `T = 293.15`, `vt_t = 2.5261712e-2` and the `Maxexp` knee
sits at 0.378926 V:

  * `Vbias = 0.3` (case1): `x_d = 11.876`, **exponential**. `i = 4.8056091e-2` A.
  * `Vbias = 0.4` (case2): `x_d = 15.834`, **linear continuation**. `i = 2.0048530` A.

Note that `T` defaults to 293.15 while `TNOM` is 300.15, so the law is *not* inert at
the default card — the two temperature factors contribute 0.93124 and 0.35900.

`DiodeForward` covers the same two branches with the law off, so between them every path
through the equation is pinned in closed form. That matters because `Diode` has no
OpenModelica cross-validation; see `test/msl_sources/README.md`.

The dummy RC branch supplies the one differential state a transient test needs.
"""
test component DiodeTemperature
  "Bias level"
  sig = BlockComponents.Sources.Constant(k = Vbias) {
    "Dyad": {"placement": {"diagram": {"x1": 20, "y1": 120, "x2": 120, "y2": 220}}}
  }
  "Bias source"
  vs = ElectricalComponents.Analog.Sources.VoltageSource() {
    "Dyad": {"placement": {"diagram": {"x1": 155, "y1": 225, "x2": 255, "y2": 325}}}
  }
  "Diode under test, default card, temperature law on"
  d = ElectricalComponents.Analog.Semiconductors.Diode(use_temperature_dependency = true) {
    "Dyad": {"placement": {"diagram": {"x1": 160, "y1": 330, "x2": 260, "y2": 430}}}
  }
  "Dummy branch resistor; provides a differential state without loading the diode"
  r_dummy = ElectricalComponents.Analog.Basic.Resistor(R = 1000) {
    "Dyad": {"placement": {"diagram": {"x1": 150, "y1": 450, "x2": 250, "y2": 550}}}
  }
  "Dummy branch capacitor"
  c_dummy = ElectricalComponents.Analog.Basic.Capacitor(C = 1u) {
    "Dyad": {"placement": {"diagram": {"x1": 350, "y1": 450, "x2": 450, "y2": 550}}}
  }
  "Ground reference"
  ground = ElectricalComponents.Analog.Basic.Ground() {
    "Dyad": {"placement": {"diagram": {"x1": 580, "y1": 420, "x2": 680, "y2": 520}}}
  }
  "Bias voltage applied across the diode"
  parameter Vbias::Voltage = 0.3
relations
  initial c_dummy.v = 0
  connect(sig.y, vs.V) {"Dyad": {"edges": [{"S": 1, "M": [{"x": 205, "y": 170}], "E": 2}], "path": {}}}
  connect(vs.p, d.p, r_dummy.p) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [{"x": 0, "y": 275}, {"x": 0, "y": 380}], "E": 2},
        {"S": 1, "M": [{"x": 0, "y": 275}, {"x": 0, "y": 500}], "E": 3}
      ],
      "path": {}
    }
  }
  connect(r_dummy.n, c_dummy.p) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "path": {}}}
  connect(d.n, c_dummy.n, vs.n, ground.g) {
    "Dyad": {
      "edges": [
        {"S": 1, "M": [{"x": 500, "y": 380}, {"x": 500, "y": 500}], "E": 2},
        {"S": 1, "M": [{"x": 500, "y": 380}, {"x": 500, "y": 275}], "E": 3},
        {"S": 1, "M": [{"x": 630, "y": 380}], "E": 4}
      ],
      "path": {}
    }
  }
metadata {
  "Dyad": {
    "tests": {
      "case1": {
        "stop": 0.01,
        "atol": {"d.i": 1e-9},
        "expect": {"final": {"d.i": 0.048056091402}}
      },
      "case2": {
        "stop": 0.01,
        "params": {"Vbias": 0.4},
        "atol": {"d.i": 1e-8},
        "expect": {"final": {"d.i": 2.0048529624}}
      }
    }
  }
}
end


Test Cases ​

Test Case case1 ​

Test Case case2 ​