110 likes | 237 Views
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. partielle Funktionsevaluierung.
E N D
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-optimizationmodule partielle Funktionsevaluierung
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}) partielle Funktionsevaluierung
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]. EquationsystemJacobian 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}) partielle Funktionsevaluierung
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 functionentfernen, teil-evaluierte function umschreiben und outputs anpassen partielle Funktionsevaluierung
partielle Funktionsevaluierung b = func(a,10.0); functionfunc inputReal in1; inputReal in2; outputReal out; protected Realx; algorithm x := in1+in2; out := 8 – in2; endfunc; func.in1 variable func.in2 10.0 x variable out 8.0 -10.0 2 b 2 b = 2.0; partielle Funktionsevaluierung
partielle Funktionsevaluierung Modelica.Electrical.Spice3.Examples.Inverter functionmosCalcNoBypassCode … if (Spice3.Internal.SpiceRoot.useInitialConditions()) and (in_m.m_dICVBSIsGiven > 0.5) then int_c.m_vbs := in_m_type * in_m.m_dICVBS; elseif ( Spice3.Internal.SpiceRoot.initJunctionVoltages()) then int_c.m_vbs := if (in_m.m_off >0.5) then 0. elseint_c.m_VBScrit; endif; … functionuseInitialConditions"Initial conditionhandling" extendsModelica.Icons.Function; outputBooleanret; algorithm ret := false; enduseInitialConditions; functioninitJunctionVoltages "Choice ofjunctionvoltagehandling, obsolete, useinitJunctionVoltageRevised" extendsModelica.Icons.Function; extendsModelica.Icons.ObsoleteModel; outputBooleanret; algorithm ret := false; endinitJunctionVoltages; if-expression handling partielle Funktionsevaluierung
partielle Funktionsevaluierung Modelica.Electrical.Spice3.Internal.Mos.mosCalcDEVqmeyer functionmosCalcDEVqmeyer … if (vgst <= -in_c.m_tPhi) then out_qm.qm_capgb := in_c.m_capOx / 2.; out_qm.qm_capgs := 0.; out_qm.qm_capgd := 0.; elseif (vgst <= -in_c.m_tPhi / 2.) then out_qm.qm_capgb := -vgst * in_c.m_capOx / (2. * in_c.m_tPhi); out_qm.qm_capgs := 0.; out_qm.qm_capgd := 0.; elseif (vgst <= 0.) then out_qm.qm_capgb := -vgst * in_c.m_capOx / (2. * in_c.m_tPhi); out_qm.qm_capgs := vgst * in_c.m_capOx / (1.5 * in_c.m_tPhi) + in_c.m_capOx / 3.; 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.; out_qm.qm_capgd := 0.; out_qm.qm_capgb := 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.; out_qm.qm_capgs := in_c.m_capOx * (1. - vddif1 * vddif1 / vddif2) / 3.; out_qm.qm_capgb := 0.; end if; end if; … if-conditions NICHT evaluierbar, aber: 0.0 0.0 in_c.m_capOx 0.0 out_qm.qm_capgb := 0.0; out_qm.qm_capgs:= 0.0; out_qm.qm_capgd:= 0.0; 0.0 0.0 0.0 0.0 0.0 0.0 0.0 if-prediction 0.0 0.0 0.0 0.0 0.0 0.0 partielle Funktionsevaluierung
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, 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}) (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, 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.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 partielle Funktionsevaluierung
partielle Funktionsevaluierung Motivation? Parallelisierung von Modelica.Electrical.Spice3.Examples.Spice3BenchmarkFourBitBinaryAdder thread 2 thread 3 thread 1 thread 4 speedUp: 2.7 hohes paralleles Potenzial durch „schwach gekoppelte Subsysteme“ simulation time partielle Funktionsevaluierung