我已经基于2个二通阀创建了一个三通阀模型,将其声明为可替换模型。这是它的开始...
within SHCLibrary;
model ThreeWayBallValveII
// Import section, AKA nicknames section. To (greately) improve readability.
import Modelica.Fluid.System;
import Modelica.Fluid.Interfaces.{FluidPort_a, FluidPort_b};
import Modelica.Blocks.Sources.Constant;
import Modelica.Blocks.Math.Add;
import Modelica.Blocks.Interfaces.RealInput;
// Definition of the fluid to be used in the component.
// replaceable package Medium = Modelica.Media.Interfaces.PartialMedium;
replaceable package Medium = Modelica.Media.Water.ConstantPropertyLiquidWater;
// Allows for optional redefinition of junciton and valves model.
// replaceable model TeeJunction = Modelica.Fluid.Fittings.BaseClasses.PartialTeeJunction;
replaceable model TeeJunction = Modelica.Fluid.Fittings.TeeJunctionIdeal;
// replaceable model Valve = Modelica.Fluid.Valves.BaseClasses.PartialValve;
replaceable model Valve = Modelica.Fluid.Valves.ValveLinear;
// replaceable model Valve = Modelica.Fluid.Valves.ValveIncompressible;
// import Valve = Modelica.Fluid.Valves.ValveIncompressible;
...
我正在其测试模型中使用此阀,修改了Valve
声明。关键是,如果我使用LinearValve
模型,一切都会顺利进行。
ThreeWayBallValveII V1(
redeclare package Medium = Medium,
redeclare model Valve = Modelica.Fluid.Valves.ValveLinear)
annotation(
Placement(visible = true, transformation(origin = {0, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
相反,如果我使用ValveIncompressible
模型
ThreeWayBallValveII V1(
redeclare package Medium = Medium,
// redeclare model Valve = Modelica.Fluid.Valves.ValveLinear)
redeclare model Valve = Modelica.Fluid.Valves.ValveIncompressible)
annotation(
Placement(visible = true, transformation(origin = {0, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
我收到此错误:
[1] 12:40:08 Translation Error
[Modelica.Fluid.Valves: 38:9-40:80]: Function Utilities.regRoot2 not found in scope Valve.
我认为可以通过添加这样的行来解决
import Modelica.Fluid.Utilities;
对于ValveIncompressible
程序包中的Valves
模型,但是对于我来说,以前这个问题尚未得到解决,这很奇怪,我想知道我做错了什么。您怎么看?
真诚地,
似乎文件import Modelica.Fluid.Utilities;
中需要Modelica 3.2.3/Fluid/Valves.mo
。在我的机器上,相关课程的开头现在显示为:
within Modelica.Fluid;
package Valves "Components for the regulation and control of fluid flow"
extends Modelica.Icons.VariantsPackage;
model ValveIncompressible "Valve for (almost) incompressible fluids"
extends BaseClasses.PartialValve;
import Modelica.Fluid.Types.CvTypes;
import Modelica.Constants.pi;
import Modelica.Fluid.Utilities;
constant SI.ReynoldsNumber Re_turbulent = 4000
"cf. straight pipe for fully open valve -- dp_turbulent increases for closing valve";
parameter Boolean use_Re = system.use_eps_Re
"= true, if turbulent region is defined by Re, otherwise by m_flow_small"
annotation(Dialog(tab="Advanced"), Evaluate=true);
...
通过此修改,我的模型起作用了。