Skip to content

Commit dedde59

Browse files
committed
set default guess for missing start values
1 parent 3df43d5 commit dedde59

File tree

4 files changed

+402
-5
lines changed

4 files changed

+402
-5
lines changed

src/evaluator.jl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -575,22 +575,26 @@ function eval_AST(model::BaseModelicaModel)
575575
start_value = get_class_modification_value(declaration.modification, "start")
576576
fixed_value = get_class_modification_value(declaration.modification, "fixed")
577577

578+
var = variable_map[name]
578579
if !isnothing(start_value)
579-
var = variable_map[name]
580580
# If fixed=true, use setdefault for initial condition
581581
# Otherwise use setguess for guess value
582582
is_fixed = !isnothing(fixed_value) &&
583583
(fixed_value === true || fixed_value == true)
584584
if is_fixed
585585
variable_map[name] = ModelingToolkit.setdefault(var, start_value)
586-
idx = findfirst(v -> ModelingToolkit.getname(v) == name, vars)
587-
vars[idx] = variable_map[name]
588586
else
589587
variable_map[name] = ModelingToolkit.setguess(var, start_value)
590-
idx = findfirst(v -> ModelingToolkit.getname(v) == name, vars)
591-
vars[idx] = variable_map[name]
592588
end
589+
else
590+
# No explicit start: set a default guess of 0.0 so that all variables
591+
# have numeric guesses. Without this, MTK's initialization problem can
592+
# end up with symbolic (cyclic) guesses when missing_guess_value is not
593+
# forwarded through SCCNonlinearProblem → NonlinearProblem.
594+
variable_map[name] = ModelingToolkit.setguess(var, 0.0)
593595
end
596+
idx = findfirst(v -> ModelingToolkit.getname(v) == name, vars)
597+
!isnothing(idx) && (vars[idx] = variable_map[name])
594598

595599
# stateSelect attribute: StateSelect.never/avoid/default/prefer/always → Int 1–5
596600
ss_value = get_class_modification_value(declaration.modification, "stateSelect")

test/test_antlr_parser.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,4 +433,15 @@ BM = BaseModelica
433433
@test parse_basemodelica(broken_when_path, parser = :antlr) isa System
434434
end
435435

436+
@testset "OpAmp Adder" begin
437+
adder_path = joinpath(
438+
dirname(dirname(pathof(BM))), "test", "testfiles", "OpAmpAdder.bmo"
439+
)
440+
adder_package = BM.parse_file_antlr(adder_path)
441+
@test adder_package isa BM.BaseModelicaPackage
442+
adder_system = BM.baseModelica_to_ModelingToolkit(adder_package)
443+
@test adder_system isa System
444+
@test parse_basemodelica(adder_path, parser = :antlr) isa System
445+
end
446+
436447
end

test/testfiles/OpAmpAdder.bmo

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
//! base 0.1.0
2+
package 'Adder'
3+
type 'Modelica.Blocks.Types.LimiterHomotopy' = enumeration('NoHomotopy', 'Linear', 'UpperLimit', 'LowerLimit');
4+
5+
model 'Adder' "Inverting adder"
6+
parameter Real 'Vin'(unit = "V", quantity = "ElectricPotential") = 5.0 "Amplitude of input voltage";
7+
parameter Real 'f'(unit = "Hz", quantity = "Frequency") = 10.0 "Frequency of input voltage";
8+
Real 'ground.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin";
9+
Real 'ground.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin";
10+
parameter Real 'vIn1.V'(start = 1.0, unit = "V", quantity = "ElectricPotential") = 5.0 "Amplitude of sine wave";
11+
parameter Real 'vIn1.phase'(displayUnit = "deg", unit = "rad", quantity = "Angle") = 0.0 "Phase of sine wave";
12+
parameter Real 'vIn1.f'(start = 1.0, unit = "Hz", quantity = "Frequency") = 10.0 "Frequency of sine wave";
13+
Real 'vIn1.v'(unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)";
14+
Real 'vIn1.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin";
15+
Real 'vIn1.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin";
16+
Real 'vIn1.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin";
17+
Real 'vIn1.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin";
18+
Real 'vIn1.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n";
19+
parameter Real 'vIn1.signalSource.amplitude' = 5.0 "Amplitude of sine wave";
20+
parameter Real 'vIn1.signalSource.f'(start = 1.0, unit = "Hz", quantity = "Frequency") = 10.0 "Frequency of sine wave";
21+
parameter Real 'vIn1.signalSource.phase'(displayUnit = "deg", unit = "rad", quantity = "Angle") = 0.0 "Phase of sine wave";
22+
parameter Boolean 'vIn1.signalSource.continuous' = false "Make output continuous by starting at offset + amplitude*sin(phase)" annotation(Evaluate = true);
23+
Real 'vIn1.signalSource.y' "Connector of Real output signal";
24+
parameter Real 'vIn1.signalSource.offset' = 0.0 "Offset of output signal y";
25+
parameter Real 'vIn1.signalSource.startTime'(unit = "s", quantity = "Time") = 0.0 "Output y = offset for time < startTime";
26+
parameter Real 'vIn1.offset'(unit = "V", quantity = "ElectricPotential") = 0.0 "Voltage offset";
27+
parameter Real 'vIn1.startTime'(unit = "s", quantity = "Time") = 0.0 "Time offset";
28+
parameter Real 'vIn2.V'(start = 1.0, unit = "V", quantity = "ElectricPotential") = 5.0 "Value of constant voltage";
29+
Real 'vIn2.v'(unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)";
30+
Real 'vIn2.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin";
31+
Real 'vIn2.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin";
32+
Real 'vIn2.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin";
33+
Real 'vIn2.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin";
34+
Real 'vIn2.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n";
35+
Real 'vOut.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin";
36+
Real 'vOut.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin";
37+
Real 'vOut.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin";
38+
Real 'vOut.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin";
39+
Real 'vOut.v'(unit = "V") "Voltage between pin p and n (= p.v - n.v) as output signal";
40+
Real 'add.v1'(unit = "V", quantity = "ElectricPotential") "Voltage drop of port 1 (= p1.v - n1.v)";
41+
Real 'add.v2'(unit = "V", quantity = "ElectricPotential") "Voltage drop of port 2 (= p2.v - n2.v)";
42+
Real 'add.i1'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pos. to neg. pin of port 1";
43+
Real 'add.i2'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pos. to neg. pin of port 2";
44+
Real 'add.p1.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin";
45+
Real 'add.p1.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin";
46+
Real 'add.n1.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin";
47+
Real 'add.n1.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin";
48+
Real 'add.p2.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin";
49+
Real 'add.p2.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin";
50+
Real 'add.n2.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin";
51+
Real 'add.n2.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin";
52+
parameter Real 'add.Vps'(unit = "V", quantity = "ElectricPotential") = 15.0 "Positive supply";
53+
parameter Real 'add.Vns'(unit = "V", quantity = "ElectricPotential") = -15.0 "Negative supply";
54+
parameter Real 'add.V0' = 15000.0 "No-load amplification";
55+
parameter Real 'add.opAmp.V0' = 15000.0 "No-load amplification";
56+
parameter Boolean 'add.opAmp.useSupply' = false "Use supply pins (otherwise constant supply)" annotation(Evaluate = true);
57+
parameter Real 'add.opAmp.Vps'(unit = "V", quantity = "ElectricPotential") = 15.0 "Positive supply voltage";
58+
parameter Real 'add.opAmp.Vns'(unit = "V", quantity = "ElectricPotential") = -15.0 "Negative supply voltage";
59+
parameter Boolean 'add.opAmp.strict' = true "= true, if strict limits with noEvent(..)" annotation(Evaluate = true);
60+
parameter 'Modelica.Blocks.Types.LimiterHomotopy' 'add.opAmp.homotopyType' = 'Modelica.Blocks.Types.LimiterHomotopy'.'NoHomotopy' "Simplified model for homotopy-based initialization" annotation(Evaluate = true);
61+
Real 'add.opAmp.vps'(unit = "V", quantity = "ElectricPotential") "Positive supply voltage";
62+
Real 'add.opAmp.vns'(unit = "V", quantity = "ElectricPotential") "Negative supply voltage";
63+
Real 'add.opAmp.v_in'(unit = "V", quantity = "ElectricPotential") "Input voltage difference";
64+
Real 'add.opAmp.v_out'(unit = "V", quantity = "ElectricPotential") "Output voltage to ground";
65+
Real 'add.opAmp.p_in'(unit = "W", quantity = "Power") "Input power";
66+
Real 'add.opAmp.p_out'(unit = "W", quantity = "Power") "Output power";
67+
Real 'add.opAmp.p_s'(unit = "W", quantity = "Power") "Supply power";
68+
Real 'add.opAmp.i_s'(unit = "A", quantity = "ElectricCurrent") "Supply current";
69+
Real 'add.opAmp.in_p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin";
70+
Real 'add.opAmp.in_p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin";
71+
Real 'add.opAmp.in_n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin";
72+
Real 'add.opAmp.in_n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin";
73+
Real 'add.opAmp.out.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin";
74+
Real 'add.opAmp.out.i'(fixed = false, start = 0.0, unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin";
75+
Real 'add.opAmp.simplifiedExpr'(unit = "V", quantity = "ElectricPotential") "Simplified expression for homotopy-based initialization";
76+
Real 'add.v1_2'(unit = "V", quantity = "ElectricPotential") "Voltage drop of port 1_2 (= p1_2.v - n1.v)";
77+
Real 'add.i1_2'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pos. to neg. pin of port 1_2";
78+
parameter Real 'add.k1'(min = 0.0) = 1.0 "Weight of input 1";
79+
parameter Real 'add.k2'(min = 0.0) = 1.0 "Weight of input 2";
80+
parameter Real 'add.R'(unit = "Ohm", quantity = "Resistance") = 1000.0 "Resistance at output of OpAmp";
81+
parameter Real 'add.R1'(unit = "Ohm", quantity = "Resistance") = 1000.0 "Calculated resistance to reach desired weight 1";
82+
parameter Real 'add.R2'(unit = "Ohm", quantity = "Resistance") = 1000.0 "Calculated resistance to reach desired weight 2";
83+
parameter Real 'add.r1.R'(start = 1.0, unit = "Ohm", quantity = "Resistance") = 1000.0 "Resistance at temperature T_ref";
84+
parameter Real 'add.r1.T_ref'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") = 300.15 "Reference temperature";
85+
parameter Real 'add.r1.alpha'(unit = "1/K", quantity = "LinearTemperatureCoefficient") = 0.0 "Temperature coefficient of resistance (R_actual = R*(1 + alpha*(T_heatPort - T_ref))";
86+
Real 'add.r1.v'(unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)";
87+
Real 'add.r1.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin";
88+
Real 'add.r1.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin";
89+
Real 'add.r1.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin";
90+
Real 'add.r1.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin";
91+
Real 'add.r1.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n";
92+
parameter Boolean 'add.r1.useHeatPort' = false "= true, if heatPort is enabled" annotation(Evaluate = true);
93+
parameter Real 'add.r1.T'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") = 300.15 "Fixed device temperature if useHeatPort = false";
94+
Real 'add.r1.LossPower'(unit = "W", quantity = "Power") "Loss power leaving component via heatPort";
95+
Real 'add.r1.T_heatPort'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") "Temperature of heatPort";
96+
Real 'add.r1.R_actual'(unit = "Ohm", quantity = "Resistance") "Actual resistance = R*(1 + alpha*(T_heatPort - T_ref))";
97+
parameter Real 'add.r2.R'(start = 1.0, unit = "Ohm", quantity = "Resistance") = 1000.0 "Resistance at temperature T_ref";
98+
parameter Real 'add.r2.T_ref'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") = 300.15 "Reference temperature";
99+
parameter Real 'add.r2.alpha'(unit = "1/K", quantity = "LinearTemperatureCoefficient") = 0.0 "Temperature coefficient of resistance (R_actual = R*(1 + alpha*(T_heatPort - T_ref)))";
100+
Real 'add.r2.v'(unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)";
101+
Real 'add.r2.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin";
102+
Real 'add.r2.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin";
103+
Real 'add.r2.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin";
104+
Real 'add.r2.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin";
105+
Real 'add.r2.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n";
106+
parameter Boolean 'add.r2.useHeatPort' = false "= true, if heatPort is enabled" annotation(Evaluate = true);
107+
parameter Real 'add.r2.T'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") = 300.15 "Fixed device temperature if useHeatPort = false";
108+
Real 'add.r2.LossPower'(unit = "W", quantity = "Power") "Loss power leaving component via heatPort";
109+
Real 'add.r2.T_heatPort'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") "Temperature of heatPort";
110+
Real 'add.r2.R_actual'(unit = "Ohm", quantity = "Resistance") "Actual resistance = R*(1 + alpha*(T_heatPort - T_ref))";
111+
Real 'add.p1_2.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin";
112+
Real 'add.p1_2.i'(start = 0.0, unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin";
113+
parameter Real 'add.r.R'(start = 1.0, unit = "Ohm", quantity = "Resistance") = 1000.0 "Resistance at temperature T_ref";
114+
parameter Real 'add.r.T_ref'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") = 300.15 "Reference temperature";
115+
parameter Real 'add.r.alpha'(unit = "1/K", quantity = "LinearTemperatureCoefficient") = 0.0 "Temperature coefficient of resistance (R_actual = R*(1 + alpha*(T_heatPort - T_ref))";
116+
Real 'add.r.v'(unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)";
117+
Real 'add.r.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin";
118+
Real 'add.r.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin";
119+
Real 'add.r.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin";
120+
Real 'add.r.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin";
121+
Real 'add.r.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n";
122+
parameter Boolean 'add.r.useHeatPort' = false "= true, if heatPort is enabled" annotation(Evaluate = true);
123+
parameter Real 'add.r.T'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") = 300.15 "Fixed device temperature if useHeatPort = false";
124+
Real 'add.r.LossPower'(unit = "W", quantity = "Power") "Loss power leaving component via heatPort";
125+
Real 'add.r.T_heatPort'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") "Temperature of heatPort";
126+
Real 'add.r.R_actual'(unit = "Ohm", quantity = "Resistance") "Actual resistance = R*(1 + alpha*(T_heatPort - T_ref))";
127+
equation
128+
'add.opAmp.v_in' = 'add.opAmp.in_p.v' - 'add.opAmp.in_n.v';
129+
'add.opAmp.v_out' = 'add.opAmp.out.v';
130+
'add.opAmp.p_in' = 'add.opAmp.in_p.v' * 'add.opAmp.in_p.i' + 'add.opAmp.in_n.v' * 'add.opAmp.in_n.i';
131+
'add.opAmp.p_out' = 'add.opAmp.out.v' * 'add.opAmp.out.i';
132+
'add.opAmp.p_s' = -('add.opAmp.p_in' + 'add.opAmp.p_out');
133+
'add.opAmp.i_s' = 'add.opAmp.p_s' / ('add.opAmp.vps' - 'add.opAmp.vns');
134+
'add.v1_2' = 'add.p1_2.v' - 'add.n1.v';
135+
'add.i1_2' = 'add.p1_2.i';
136+
'add.n1.v' = 'add.opAmp.in_p.v';
137+
'add.n1.v' = 'add.n2.v';
138+
'add.opAmp.in_p.i' - 'add.n1.i' - 'add.n2.i' = 0.0;
139+
'add.p1.v' = 'add.r1.p.v';
140+
'add.r1.p.i' - 'add.p1.i' = 0.0;
141+
'add.p1_2.v' = 'add.r2.p.v';
142+
'add.r2.p.i' - 'add.p1_2.i' = 0.0;
143+
'add.opAmp.in_n.v' = 'add.r.n.v';
144+
'add.opAmp.in_n.v' = 'add.r1.n.v';
145+
'add.opAmp.in_n.v' = 'add.r2.n.v';
146+
'add.opAmp.out.v' = 'add.p2.v';
147+
'add.opAmp.out.v' = 'add.r.p.v';
148+
'ground.p.v' = 'vIn1.n.v';
149+
'ground.p.v' = 'vIn2.n.v';
150+
'ground.p.v' = 'add.n1.v';
151+
'vIn1.p.v' = 'add.p1.v';
152+
'vIn2.p.v' = 'add.p1_2.v';
153+
'add.p2.v' = 'vOut.n.v';
154+
'add.n2.v' = 'vOut.p.v';
155+
'add.p1.i' + 'vIn1.p.i' = 0.0;
156+
'add.p1_2.i' + 'vIn2.p.i' = 0.0;
157+
'add.n1.i' + 'vIn2.n.i' + 'vIn1.n.i' + 'ground.p.i' = 0.0;
158+
'add.p2.i' + 'vOut.n.i' = 0.0;
159+
'add.n2.i' + 'vOut.p.i' = 0.0;
160+
'add.r.n.i' + 'add.r2.n.i' + 'add.r1.n.i' + 'add.opAmp.in_n.i' = 0.0;
161+
'add.r.p.i' + 'add.opAmp.out.i' - 'add.p2.i' = 0.0;
162+
'ground.p.v' = 0.0;
163+
'vIn1.signalSource.y' = if time < 0.0 then 0.0 else 5.0 * sin(62.83185307179586 * time);
164+
'vIn1.v' = 'vIn1.signalSource.y';
165+
0.0 = 'vIn1.p.i' + 'vIn1.n.i';
166+
'vIn1.i' = 'vIn1.p.i';
167+
'vIn1.v' = 'vIn1.p.v' - 'vIn1.n.v';
168+
'vIn2.v' = 5.0;
169+
0.0 = 'vIn2.p.i' + 'vIn2.n.i';
170+
'vIn2.i' = 'vIn2.p.i';
171+
'vIn2.v' = 'vIn2.p.v' - 'vIn2.n.v';
172+
'vOut.p.i' = 0.0;
173+
'vOut.n.i' = 0.0;
174+
'vOut.v' = 'vOut.p.v' - 'vOut.n.v';
175+
'add.opAmp.vps' = 15.0;
176+
'add.opAmp.vns' = -15.0;
177+
'add.opAmp.in_p.i' = 0.0;
178+
'add.opAmp.in_n.i' = 0.0;
179+
'add.opAmp.simplifiedExpr' = 0.0;
180+
'add.opAmp.v_out' = smooth(0, noEvent(if 15000.0 * 'add.opAmp.v_in' > 'add.opAmp.vps' then 'add.opAmp.vps' else if 15000.0 * 'add.opAmp.v_in' < 'add.opAmp.vns' then 'add.opAmp.vns' else 15000.0 * 'add.opAmp.v_in'));
181+
'add.r1.R_actual' = 1000.0;
182+
'add.r1.v' = 'add.r1.R_actual' * 'add.r1.i';
183+
'add.r1.LossPower' = 'add.r1.v' * 'add.r1.i';
184+
'add.r1.T_heatPort' = 300.15;
185+
0.0 = 'add.r1.p.i' + 'add.r1.n.i';
186+
'add.r1.i' = 'add.r1.p.i';
187+
'add.r1.v' = 'add.r1.p.v' - 'add.r1.n.v';
188+
'add.r2.R_actual' = 1000.0;
189+
'add.r2.v' = 'add.r2.R_actual' * 'add.r2.i';
190+
'add.r2.LossPower' = 'add.r2.v' * 'add.r2.i';
191+
'add.r2.T_heatPort' = 300.15;
192+
0.0 = 'add.r2.p.i' + 'add.r2.n.i';
193+
'add.r2.i' = 'add.r2.p.i';
194+
'add.r2.v' = 'add.r2.p.v' - 'add.r2.n.v';
195+
'add.r.R_actual' = 1000.0;
196+
'add.r.v' = 'add.r.R_actual' * 'add.r.i';
197+
'add.r.LossPower' = 'add.r.v' * 'add.r.i';
198+
'add.r.T_heatPort' = 300.15;
199+
0.0 = 'add.r.p.i' + 'add.r.n.i';
200+
'add.r.i' = 'add.r.p.i';
201+
'add.r.v' = 'add.r.p.v' - 'add.r.n.v';
202+
'add.v1' = 'add.p1.v' - 'add.n1.v';
203+
'add.v2' = 'add.p2.v' - 'add.n2.v';
204+
'add.i1' = 'add.p1.i';
205+
'add.i2' = 'add.p2.i';
206+
annotation(experiment(StartTime = 0, StopTime = 1, Tolerance = 1e-006, Interval = 0.001));
207+
end 'Adder';
208+
end 'Adder';

0 commit comments

Comments
 (0)