### Vortrag von Volker Waurich „Partielle

```Professur für Baumaschinen- und Fördertechnik
Partielle Funktionsevaluierung
- der Schlüssel zu den Spice3 Modellen -
Leipzig, 02.07.2014
partielle Funktionsevaluierung
- OpenModelica-Compiler pre-optimization module
HTWK Leipzig, 02.07.2014
partielle Funktionsevaluierung
Folie 2 von 11
partielle Funktionsevaluierung
Modelica.Electrical.Spice3.Examples.CascodeCircuit
assert
| debug | division by zero at time 0, (a=-0.0388) / (b=0), where divisor b expression is: J1.cc.cGD
SingleEquation:
der(J1.vGD) = J1.icGD /J1.cc.cGD
ComplexEquation:
(5): J1.cc = Modelica.Electrical.Spice3.Internal.Jfet.jfetNoBypassCode(
(300.15, 1.0, false, 0.0, 0.0, 0.0, 0.0, false, 1e-014, 1.0, 0.0, 0.0, 0.5,
0.7302833841653967, 0.5857864376269049, 0.3535533905932738, 0.25, 0.02586470905512062, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
(-2.0, 0.0001, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1e-014, 0.5, 1.0, 0.0, 1.0, 0.0, 0.0, 300.15, 0.0),
1,
false,
{U0.V, J1.Dinternal, J1.Sinternal})
HTWK Leipzig, 02.07.2014
partielle Funktionsevaluierung
Folie 3 von 11
partielle Funktionsevaluierung
Modelica.Electrical.Spice3.Examples.Inverter
warning | Failed to solve linear system of equations (no. 32) at time 0.000000, system is singular for U[7, 7].
warning | Failed to solve linear system of equations (no. 68) at time 0.000000, system is singular for U[6, 6].
Equationsystem Jacobian Time varying:
1/1 (1): 0.0 = (-mp.irs) - mp.icBS - mp.ibsgmin - mp.cc.iBS - mp.icGS - mp.cc.idrain
2/2 (1): mp.icGS = mp.cc.cGS * (\$DER.mn.G.v - der(mn.Dinternal))
3/3 (1): mn.icGD = mn.cc.cGD * (\$DER.mn.G.v - der(mn.Dinternal))
4/4 (1): 0.0 = mn.cc.idrain + mp.irs + (-mn.ibdgmin) - mn.icGD - mn.icBD - mn.cc.iBD
5/5 (1): mn.icBD = (-mn.cc.cBD) * der(mn.Dinternal) [dynamic]
6/6 (1): mp.icBS = mp.cc.cBS * (\$DER.mp.B.v - der(mn.Dinternal))
1/1 (9): mn.cc = Modelica.Electrical.Spice3.Internal.Mos.mosCalcNoBypassCode(
(300.15, 0.0001, 0.0001, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, 0, 1, 0.0, 0.0, false),
1,
(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2e-005, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 1, 0.0001, 0.0, 0.0, 2e-005, 600.0, 0.6, 0.0, 0.0, 1e-014, 1e-014, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.8, 0.4, 0.0, .7302833841653967, 0.7302833841653967, 0.4686291501015239, 0.3535533905932738,
0.25, 0.0, 0.0, 0.0, 0.02586470905512062, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), (0.0, 0.0, 0.8, 0.5, 0.5, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.5, 0.6, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 600.0, 0.0, 1e-014, 0.0, 1.0, 0.0, 1.0, 2e-005, 0.0, 300.15),
(1.035943139907e-010, 3.453133e-011, 1.6021918e-019, 273.15, 1.3806226e-023, 300.15,
1.414213562373095, 2.718281828459045, 1e-012, 300.15, 300.15, 0.0, 0.0, 0.0001, 0.0001, 1e-010,
1e-015, 1e-010, 0.001, 0.02586470905512062, 8.61726105451295e-005),
(0.0, 0.0, 0.6, 0.0, 2e-005),
false,
{mn.G.v, 0.0, mn.Dinternal, 0.0})
HTWK Leipzig, 02.07.2014
partielle Funktionsevaluierung
Folie 4 von 11
partielle Funktionsevaluierung
TODO:
- konstante function-inputs inklusive teil-konstanter record-Ausdrücke einsetzen
- Funktionsvariablen und outputs evaluieren
- konstante function-outputs inklusive teil-konstanter record-Ausdrücke als neue
Zuweisungen zum DAE-System hinzufügen
- vollständig evaluierte function entfernen, teil-evaluierte function umschreiben
und outputs anpassen
HTWK Leipzig, 02.07.2014
partielle Funktionsevaluierung
Folie 5 von 11
partielle Funktionsevaluierung
function func
input Real in1;
input Real in2;
output Real out;
protected
Real x;
algorithm
x := in1+in2;
out := 8 – in2;
end func;
HTWK Leipzig, 02.07.2014
b = func(a,10.0);
func.in1  variable
func.in2  10.0
x  variable
out  8.0 -10.0 2
b = 2.0;
partielle Funktionsevaluierung
b 2
Folie 6 von 11
partielle Funktionsevaluierung
Modelica.Electrical.Spice3.Examples.Inverter
function mosCalcNoBypassCode
…
if (Spice3.Internal.SpiceRoot.useInitialConditions()) and (in_m.m_dICVBSIsGiven
> 0.5)
then
function
useInitialConditions
"Initial condition handling"
int_c.m_vbs
:= in_m_type * in_m.m_dICVBS;
extends
Modelica.Icons.Function;
elseif
( Boolean ret;
output
Spice3.Internal.SpiceRoot.initJunctionVoltages()) then
algorithm
int_c.m_vbs
:= if (in_m.m_off >0.5) then 0. else int_c.m_VBScrit;
function
initJunctionVoltages
ret
:= false;
end
if;
"Choice
of junction voltage handling, obsolete, use initJunctionVoltageRe
end
useInitialConditions;
…
vised"
extends Modelica.Icons.Function;
extends Modelica.Icons.ObsoleteModel;
output Boolean ret;
algorithm
ret := false;

if-expression handling
end initJunctionVoltages;
HTWK Leipzig, 02.07.2014
partielle Funktionsevaluierung
Folie 7 von 11
partielle Funktionsevaluierung
Modelica.Electrical.Spice3.Internal.Mos.mosCalcDEVqmeyer
function mosCalcDEVqmeyer
…
if (vgst <= -in_c.m_tPhi) then
out_qm.qm_capgb := in_c.m_capOx / 2.;
 0.0
out_qm.qm_capgs := 0.;
 0.0
out_qm.qm_capgd := 0.;
 0.0
elseif (vgst <= -in_c.m_tPhi / 2.) then
out_qm.qm_capgb := -vgst * in_c.m_capOx / (2. * in_c.m_tPhi);  0.0
out_qm.qm_capgs := 0.;
 0.0
out_qm.qm_capgd := 0.;
 0.0
elseif (vgst <= 0.) then
out_qm.qm_capgb := -vgst * in_c.m_capOx / (2. * in_c.m_tPhi);  0.0
out_qm.qm_capgs := vgst * in_c.m_capOx / (1.5 * in_c.m_tPhi) + in_c.m_capOx / 3.;  0.0
 0.0
out_qm.qm_capgd := 0.;
else
vds := vgs - vgd;
if (in_c.m_vdsat <= vds) then
out_qm.qm_capgs := in_c.m_capOx / 3.;  0.0
out_qm.qm_capgd := 0.;  0.0
out_qm.qm_capgb := 0.;  0.0
else
vddif := 2.0 * in_c.m_vdsat - vds;
vddif1 := in_c.m_vdsat - vds;
vddif2 := vddif * vddif;
out_qm.qm_capgd := in_c.m_capOx * (1. - in_c.m_vdsat * in_c.m_vdsat / vddif2) / 3.;  0.0
 0.0
out_qm.qm_capgs := in_c.m_capOx * (1. - vddif1 * vddif1 / vddif2) / 3.;

0.0
out_qm.qm_capgb := 0.;
end if;
end if;
…
if-conditions NICHT evaluierbar,
aber:
in_c.m_capOx  0.0
out_qm.qm_capgb := 0.0;
out_qm.qm_capgs := 0.0;
out_qm.qm_capgd := 0.0;
 if-prediction
HTWK Leipzig, 02.07.2014
partielle Funktionsevaluierung
Folie 8 von 11
partielle Funktionsevaluierung
Modelica.Electrical.Spice3.Examples.Inverter
mn.cc = Modelica.Electrical.Spice3.Internal.Mos.mosCalcNoBypassCode( (300.15, 0.0001, 0.0001, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0, 0, 1, 0.0, 0.0, false), 1, (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2e -005, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1,
0.0001, 0.0, 0.0, 2e-005, 600.0, 0.6, 0.0, 0.0, 1e-014, 1e-014, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.8, 0.4, 0.0, 0.7302833841653967, 0.7302833841653967,
0.4686291501015239, 0.3535533905932738, 0.25, 0.0, 0.0, 0.0, 0.02586470905512062, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), (0.0, 0.0, 0.8, 0.5, 0.5, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.5, 0.6, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 600.0, 0.0, 1e014, 0.0, 1.0, 0.0, 1.0, 2e-005, 0.0, 300.15), (1.035943139907e-010, 3.453133e-011, 1.6021918e-019, 273.15, 1.3806226e-023, 300.15,
1.414213562373095, 2.718281828459045, 1e-012, 300.15, 300.15, 0.0, 0.0, 0.0001, 0.0001, 1e-010, 1e-015, 1e-010, 0.001, 0.02586470905512062,
8.61726105451295e-005), (0.0, 0.0, 0.6, 0.0, 2e-005), false, {mn.G.v, 0.0, mn.Dinternal, 0.0})
(mn.cc.idrain, mn.cc.iBD, mn.cc.iBS) = Modelica.Electrical.Spice3.Internal.Mos.mosCalcNoBypassCode_eval15( (300.15, 0.0001, 0.0001, 0.0, 0.0,
1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, 0, 1, 0.0, 0.0, false), 1, (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 2e-005, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, 0.0001, 0.0, 0.0, 2e-005, 600.0, 0.6, 0.0, 0.0, 1e-014, 1e-014, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.8, 0.4, 0.0,
0.7302833841653967, 0.7302833841653967, 0.4686291501015239, 0.3535533905932738, 0.25, 0.0, 0.0, 0.0, 0.02586470905512062, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0), (0.0, 0.0, 0.8, 0.5, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.5, 0.6, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 600.0, 0.0, 1e-014, 0.0, 1.0, 0.0, 1.0, 2e-005, 0.0, 300.15), 1.035943139907e-010, 3.453133e-011, 1.6021918e-019,
273.15, 1.3806226e-023, 300.15, 1.414213562373095, 2.718281828459045, 1e-012, 300.15, 300.15, 0.0, 0.0, 0.0001, 0.0001, 1e-010, 1e-015, 1e010, 0.001, 0.02586470905512062, 8.61726105451295e-005), (0.0, 0.0, 0.6, 0.0, 2e-005), false, {mn.G.v, 0.0, mn.Dinternal, 0.0})
mn.cc.cGS = 0.0
mn.cc.cGD = 0.0
mn.cc.cGB = 0.0
mn.cc.cBD = 0.0
mn.cc.cBS = 0.0
mn.cc.m_capgd = 0.0
HTWK Leipzig, 02.07.2014
partielle Funktionsevaluierung
Folie 9 von 11
partielle Funktionsevaluierung
Motivation?
Parallelisierung
von
simulation time
speedUp:
2.7
HTWK Leipzig, 02.07.2014