我正在学习Modelica,一切正常。直到我想用一个电阻器向我的同事证明其原因。我们问自己一个问题:当电阻的热功率为1W时,1 Ohm电阻的压降和电流是多少(显然答案应该是1V,1A)。我没有得到0 V,0A以外的任何其他结果。从物理上讲,我对结果感到满意,因为我不希望一旦加热电阻器就可以将其转换为电源,但是我不理解这种因果关系会在电阻器模型中内置。 我通过电阻-ConditionalHeatPort-HeatPort_a-HeatPort追溯了Modelica库,但据我了解,Modelica仅存在非因果方程式。有人可以照亮它吗?
谢谢!
编辑:对Rene Just Nielsen的回答:
我正在使用下面的代码。想法是,考虑到电阻流出的热量固定为1W的事实,需要在电阻上建立电流和电压,以便求解所有方程式。如果我对此进行仿真,则组件fixedHeatFlow1上的热流= 0 W,电流和电压也均为0 V和0A。当然,这彼此一致,但与-1 W的固定边界条件不一致在fixedHeatFlow1。
model ElectricalPowerFromHeat
Modelica.Electrical.Analog.Basic.Resistor resistor1(R = 1, alpha = 0, useHeatPort = true) annotation(
Placement(visible = true, transformation(origin = {-28, -46}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Basic.Ground ground1 annotation(
Placement(visible = true, transformation(origin = {12, -80}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Thermal.HeatTransfer.Sources.FixedHeatFlow fixedHeatFlow1(Q_flow = -1, alpha = 1) annotation(
Placement(visible = true, transformation(origin = {-68, 14}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
connect(resistor1.n, ground1.p) annotation(
Line(points = {{-18, -46}, {12, -46}, {12, -70}, {12, -70}}, color = {0, 0, 255}));
connect(fixedHeatFlow1.port, resistor1.heatPort) annotation(
Line(points = {{-58, 14}, {-28, 14}, {-28, -56}, {-28, -56}}, color = {191, 0, 0}));
connect(resistor1.p, ground1.p) annotation(
Line(points = {{-38, -46}, {-38, -60}, {12, -60}, {12, -70}}, color = {0, 0, 255}));
annotation(
uses(Modelica(version = "3.2.2")),
experiment(StartTime = 0, StopTime = 1, Tolerance = 1e-06, Interval = 0.002));
end ElectricalPowerFromHeat;
根据电阻器内部的方程,我希望电阻器可以用作电源:
R_actual = R*(1 + alpha*(T_heatPort - T_ref));
v = R_actual*i;
LossPower = v*i;
答案 0 :(得分:5)
如果您想找到一个1欧姆电阻的压降,假设热流为1W,则可以按以下方式建模。首先,您使用一个模型来生成简单电路的热流(在VoltageToHeatFlow中),然后将信号求逆(在Test-model中):
package ShowInvertPower
model VoltageToHeatFlow
Modelica.Electrical.Analog.Basic.Ground ground
annotation (Placement(transformation(extent={{-22,-16},{-2,4}})));
Modelica.Electrical.Analog.Basic.HeatingResistor resistor(R_ref=1)
annotation (Placement(transformation(extent={{-8,48},{12,68}})));
Modelica.Electrical.Analog.Sources.SignalVoltage signalVoltage
annotation (Placement(transformation(extent={{-58,52},{-38,72}})));
Modelica.Thermal.HeatTransfer.Sensors.HeatFlowSensor heatFlowSensor
annotation (Placement(transformation(extent={{52,22},{72,42}})));
Modelica.Thermal.HeatTransfer.Components.HeatCapacitor heatCapacitor(C=1)
annotation (Placement(transformation(extent={{84,36},{104,56}})));
Modelica.Blocks.Interfaces.RealOutput Q_flow1
"Heat flow from port_a to port_b as output signal"
annotation (Placement(transformation(extent={{96,-18},{116,2}})));
Modelica.Blocks.Interfaces.RealInput v1
"Voltage between pin p and n (= p.v - n.v) as input signal"
annotation (Placement(transformation(extent={{-126,-32},{-86,8}})));
equation
connect(signalVoltage.n, resistor.p) annotation (Line(points={{-38,62},{-26,
62},{-26,58},{-8,58}}, color={0,0,255}));
connect(resistor.n, ground.p) annotation (Line(points={{12,58},{30,58},{30,4},
{-12,4}}, color={0,0,255}));
connect(signalVoltage.p, ground.p) annotation (Line(points={{-58,62},{-68,62},
{-68,4},{-12,4}}, color={0,0,255}));
connect(resistor.heatPort, heatFlowSensor.port_a) annotation (Line(points={{
2,48},{28,48},{28,32},{52,32}}, color={191,0,0}));
connect(heatFlowSensor.port_b, heatCapacitor.port) annotation (Line(points={
{72,32},{84,32},{84,36},{94,36}}, color={191,0,0}));
connect(heatFlowSensor.Q_flow, Q_flow1) annotation (Line(points={{62,22},{66,
22},{66,-8},{106,-8}}, color={0,0,127}));
connect(signalVoltage.v, v1) annotation (Line(points={{-48,74},{-106,74},{-106,
-12}}, color={0,0,127}));
end VoltageToHeatFlow;
model Test
ShowInvertPower.VoltageToHeatFlow voltageToHeatFlow annotation (Placement(
transformation(
extent={{-10,-10},{10,10}},
rotation=180,
origin={-2,58})));
Modelica.Blocks.Math.InverseBlockConstraints inverseBlockConstraints
annotation (Placement(transformation(extent={{-24,46},{16,70}})));
Modelica.Blocks.Sources.Constant const(k=2)
annotation (Placement(transformation(extent={{-86,46},{-66,66}})));
equation
connect(voltageToHeatFlow.v1, inverseBlockConstraints.y2) annotation (Line(
points={{8.6,59.2},{13.1,59.2},{13.1,58},{13,58}}, color={0,0,127}));
connect(inverseBlockConstraints.u2, voltageToHeatFlow.Q_flow1) annotation (
Line(points={{-20,58},{-12,58},{-12,58.8},{-12.6,58.8}}, color={0,0,127}));
connect(const.y, inverseBlockConstraints.u1) annotation (Line(points={{-65,56},
{-46,56},{-46,58},{-26,58}}, color={0,0,127}));
annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(
coordinateSystem(preserveAspectRatio=false)));
end Test;
annotation (uses(Modelica(version="3.2.3")));
end ShowInvertPower;
结果是需要1 V(和1 A)。显然,可以用更简单的方法对其进行建模,但是以这种方式使用逆模型是Modelica中的标准方法。