gpt4 book ai didi

modelica - 在 modelica 中,Electrical.Analog.Basic.Resistor 的 Heatport 是否仅定义为输出?如果是,怎么办?

转载 作者:行者123 更新时间:2023-12-02 19:14:31 24 4
gpt4 key购买 nike

我正在学习 modelica,进展顺利。直到我想向我的同事证明与电阻器的因果关系。我们问自己的问题是:当电阻的热功率为 1W 时,1 欧姆电阻的压降和电流是多少(显然答案应该是 1V、1A)。除了 0 V、0A 之外,我没有得到任何其他结果。从物理上讲,我对结果感到满意,因为我不希望电阻器在加热后变成电源,但我不明白代码中的何处将这种因果关系内置到电阻器模型中。我通过Resistor - ConditionalHeatPort - HeatPort_a - HeatPort追溯到modelica库,但据我了解modelica只有非因果方程。有人能解释一下吗?

谢谢!

编辑:对雷内·贾斯特·尼尔森的回答:

我正在使用下面的代码。这个想法是,考虑到从电阻器流出的热流固定为 1W,需要在电阻器上建立电流和电压才能求解所有方程。如果我模拟一下,组件处的热流fixedHeatFlow1 = 0 W,电流和电压也都是0 V和0 A。当然这是一致的,但与-1 W的固定边界条件不一致在固定的 HeatFlow1 处。

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;

最佳答案

如果您想在热流为 1W 的情况下找到 1 欧姆电阻的压降,可以按如下方式建模。首先,您采用一个为简单电路生成热流的模型(在VoltageToHeatFlow中),然后反转信号(在测试模型中):

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 中的标准方式。

关于modelica - 在 modelica 中,Electrical.Analog.Basic.Resistor 的 Heatport 是否仅定义为输出?如果是,怎么办?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56008060/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com