openmodelica 中流体库的奇怪问题
Strange problem with the fluid library in openmodelica
我写了一个简单的代码来实验使用标准库的Fluid包中的PrescribedPump机器。我正在使用 OpenModelica 1.13.2。
我想通过使用以恒定值 10000 驱动的规定泵将一些水从一个水箱抽到另一个水箱。
这里是代码:
model PompaPilotata
package Medium = Modelica.Media.Water.ConstantPropertyLiquidWater;
inner Modelica.Fluid.System system ;
Modelica.Fluid.Vessels.OpenTank bacinella1(redeclare package Medium = Medium,
T_ambient = system.T_ambient, T_start = system.T_ambient, crossArea = 4, energyDynamics = Modelica.Fluid.Types.Dynamics.FixedInitial,
height = 10, level_start = 2, massDynamics = Modelica.Fluid.Types.Dynamics.FixedInitial, nPorts = 1, p_ambient = system.p_ambient,
use_HeatTransfer = false, use_T_start = true, use_portsData = false) ;
Modelica.Fluid.Vessels.OpenTank bacinella2(redeclare package Medium = Medium,
T_ambient = system.T_ambient, T_start = system.T_ambient, crossArea = 4, energyDynamics = Modelica.Fluid.Types.Dynamics.FixedInitial,
height = 10, level_start = 2, massDynamics = Modelica.Fluid.Types.Dynamics.FixedInitial, nPorts = 1, p_ambient = system.p_ambient,
use_HeatTransfer = false, use_T_start = true, use_portsData = false) ;
Modelica.Fluid.Machines.PrescribedPump Pompa(redeclare package Medium = Medium,
medium(h(stateSelect = StateSelect.default), p(stateSelect = StateSelect.default)),N_nominal = 100, V = 0.1, allowFlowReversal = false,
checkValve = true, energyDynamics = Modelica.Fluid.Types.Dynamics.DynamicFreeInitial, m_flow_start = 0.0000001,
massDynamics = Modelica.Fluid.Types.Dynamics.DynamicFreeInitial, nParallel = 1, use_HeatTransfer = false, use_N_in = true) ;
Modelica.Blocks.Sources.Constant Costante(k = 10000);
Modelica.Fluid.Pipes.StaticPipe tubo1(redeclare package Medium = Medium,allowFlowReversal = true,
diameter = 0.1, height_ab = 0, isCircular = true, length = 5, nParallel = 1) ;
Modelica.Fluid.Pipes.StaticPipe tubo2(redeclare package Medium = Medium,allowFlowReversal = true,
diameter = 0.1, height_ab = 0, isCircular = true, length = 5, nParallel = 1);
equation
connect(tubo2.port_b, bacinella2.ports[1]);
connect(Pompa.port_b, tubo2.port_a);
connect(tubo1.port_b, Pompa.port_a);
connect(bacinella1.ports[1], tubo1.port_a);
connect(Costante.y, Pompa.N_in);
end PompaPilotata;
我从编译器那里得到这个错误信息:
在 C:/OpenModelica1.13.264bit/include/omc/c/util/modelica_string.h:38:0 包含的文件中,
来自 C:/OpenModelica1.13.264bit/include/omc/c/openmodelica_func.h:52,
来自 PompaPilotata_model.h:6,
来自 PompaPilotata_06inz.c:2:
PompaPilotata_06inz.c:在函数中'PompaPilotata_eqFunction_237':
C:/OpenModelica1.13.264bit/include/omc/c/meta/meta_modelica_data.h:231:21: 错误:'omc_Modelica_Fluid_Machines_PrescribedPump$Pompa_flowCharacteristic' 的参数 2 的类型不兼容
#define mmc_mk_real mmc_mk_rcon
^
C:/OpenModelica1.13.264bit/include/omc/c/meta/meta_modelica_data.h:225:45: 注意:宏定义中 'mmc_unbox_real'
#define mmc_unbox_real(X) mmc_prim_get_real(X)
^
PompaPilotata_06inz.c:3005:139: 注意:在宏扩展中 'mmc_mk_real'
data->simulationInfo->realParameter[7] = mmc_unbox_real(omc_Modelica_Fluid_Machines_PrescribedPump$Pompa_flowCharacteristic(threadData, mmc_mk_real(data->simulationInfo->realParameter[5]))) ;
^
在 PompaPilotata_model.h:23:0 包含的文件中,
来自 PompaPilotata_06inz.c:2:
PompaPilotata_functions.h:223:15: 注意:预期 'modelica_real {aka double}' 但参数类型为 'void *'
modelica_real omc_Modelica_Fluid_Machines_PrescribedPump$Pompa_flowCharacteristic(threadData_t threadData, modelica_real _V_flow);
^
: 目标 'PompaPilotata_06inz.o' 的配方失败
\tools\msys\mingw64\bin\mingw32-make: [PompaPilotata_06inz.o] 错误 1
\tools\msys\mingw64\bin\mingw32-make: * 等待未完成的作业....
编译过程失败。已退出,代码为 2。
谁能解释一下这是什么意思以及如何解决?
谢谢
该模型在 Dymola eiter 中不起作用,但它给出了以下提示:
Function Pompa.flowCharacteristic_Unique7 is neither external nor has an algorithm. It should have been redeclared.
因此,重新声明 flowCharacteristic 函数应该会有所帮助。从 Modelica.Fluid.Examples.PumpingSystem
复制这部分并将 V_flow_nominal
的值减少 1000 倍(这是一个大胆的猜测)得到:
Modelica.Fluid.Machines.PrescribedPump Pompa(redeclare package Medium = Medium,
redeclare function flowCharacteristic = Modelica.Fluid.Machines.BaseClasses.PumpCharacteristics.quadraticFlow (V_flow_nominal={0.001,0.0025,0.005}, head_nominal={100,60,0}),
medium(h(stateSelect = StateSelect.default), p(stateSelect = StateSelect.default)),N_nominal = 100, V = 0.1, allowFlowReversal = false,
checkValve = true, energyDynamics = Modelica.Fluid.Types.Dynamics.DynamicFreeInitial, m_flow_start = 0.0000001,
massDynamics = Modelica.Fluid.Types.Dynamics.DynamicFreeInitial, nParallel = 1, use_HeatTransfer = false, use_N_in = true);
实际上添加了第二行。
我写了一个简单的代码来实验使用标准库的Fluid包中的PrescribedPump机器。我正在使用 OpenModelica 1.13.2。 我想通过使用以恒定值 10000 驱动的规定泵将一些水从一个水箱抽到另一个水箱。
这里是代码:
model PompaPilotata
package Medium = Modelica.Media.Water.ConstantPropertyLiquidWater;
inner Modelica.Fluid.System system ;
Modelica.Fluid.Vessels.OpenTank bacinella1(redeclare package Medium = Medium,
T_ambient = system.T_ambient, T_start = system.T_ambient, crossArea = 4, energyDynamics = Modelica.Fluid.Types.Dynamics.FixedInitial,
height = 10, level_start = 2, massDynamics = Modelica.Fluid.Types.Dynamics.FixedInitial, nPorts = 1, p_ambient = system.p_ambient,
use_HeatTransfer = false, use_T_start = true, use_portsData = false) ;
Modelica.Fluid.Vessels.OpenTank bacinella2(redeclare package Medium = Medium,
T_ambient = system.T_ambient, T_start = system.T_ambient, crossArea = 4, energyDynamics = Modelica.Fluid.Types.Dynamics.FixedInitial,
height = 10, level_start = 2, massDynamics = Modelica.Fluid.Types.Dynamics.FixedInitial, nPorts = 1, p_ambient = system.p_ambient,
use_HeatTransfer = false, use_T_start = true, use_portsData = false) ;
Modelica.Fluid.Machines.PrescribedPump Pompa(redeclare package Medium = Medium,
medium(h(stateSelect = StateSelect.default), p(stateSelect = StateSelect.default)),N_nominal = 100, V = 0.1, allowFlowReversal = false,
checkValve = true, energyDynamics = Modelica.Fluid.Types.Dynamics.DynamicFreeInitial, m_flow_start = 0.0000001,
massDynamics = Modelica.Fluid.Types.Dynamics.DynamicFreeInitial, nParallel = 1, use_HeatTransfer = false, use_N_in = true) ;
Modelica.Blocks.Sources.Constant Costante(k = 10000);
Modelica.Fluid.Pipes.StaticPipe tubo1(redeclare package Medium = Medium,allowFlowReversal = true,
diameter = 0.1, height_ab = 0, isCircular = true, length = 5, nParallel = 1) ;
Modelica.Fluid.Pipes.StaticPipe tubo2(redeclare package Medium = Medium,allowFlowReversal = true,
diameter = 0.1, height_ab = 0, isCircular = true, length = 5, nParallel = 1);
equation
connect(tubo2.port_b, bacinella2.ports[1]);
connect(Pompa.port_b, tubo2.port_a);
connect(tubo1.port_b, Pompa.port_a);
connect(bacinella1.ports[1], tubo1.port_a);
connect(Costante.y, Pompa.N_in);
end PompaPilotata;
我从编译器那里得到这个错误信息:
在 C:/OpenModelica1.13.264bit/include/omc/c/util/modelica_string.h:38:0 包含的文件中, 来自 C:/OpenModelica1.13.264bit/include/omc/c/openmodelica_func.h:52, 来自 PompaPilotata_model.h:6, 来自 PompaPilotata_06inz.c:2: PompaPilotata_06inz.c:在函数中'PompaPilotata_eqFunction_237': C:/OpenModelica1.13.264bit/include/omc/c/meta/meta_modelica_data.h:231:21: 错误:'omc_Modelica_Fluid_Machines_PrescribedPump$Pompa_flowCharacteristic' 的参数 2 的类型不兼容 #define mmc_mk_real mmc_mk_rcon ^ C:/OpenModelica1.13.264bit/include/omc/c/meta/meta_modelica_data.h:225:45: 注意:宏定义中 'mmc_unbox_real' #define mmc_unbox_real(X) mmc_prim_get_real(X) ^ PompaPilotata_06inz.c:3005:139: 注意:在宏扩展中 'mmc_mk_real' data->simulationInfo->realParameter[7] = mmc_unbox_real(omc_Modelica_Fluid_Machines_PrescribedPump$Pompa_flowCharacteristic(threadData, mmc_mk_real(data->simulationInfo->realParameter[5]))) ; ^ 在 PompaPilotata_model.h:23:0 包含的文件中, 来自 PompaPilotata_06inz.c:2: PompaPilotata_functions.h:223:15: 注意:预期 'modelica_real {aka double}' 但参数类型为 'void *' modelica_real omc_Modelica_Fluid_Machines_PrescribedPump$Pompa_flowCharacteristic(threadData_t threadData, modelica_real _V_flow); ^ : 目标 'PompaPilotata_06inz.o' 的配方失败 \tools\msys\mingw64\bin\mingw32-make: [PompaPilotata_06inz.o] 错误 1 \tools\msys\mingw64\bin\mingw32-make: * 等待未完成的作业.... 编译过程失败。已退出,代码为 2。
谁能解释一下这是什么意思以及如何解决? 谢谢
该模型在 Dymola eiter 中不起作用,但它给出了以下提示:
Function Pompa.flowCharacteristic_Unique7 is neither external nor has an algorithm. It should have been redeclared.
因此,重新声明 flowCharacteristic 函数应该会有所帮助。从 Modelica.Fluid.Examples.PumpingSystem
复制这部分并将 V_flow_nominal
的值减少 1000 倍(这是一个大胆的猜测)得到:
Modelica.Fluid.Machines.PrescribedPump Pompa(redeclare package Medium = Medium,
redeclare function flowCharacteristic = Modelica.Fluid.Machines.BaseClasses.PumpCharacteristics.quadraticFlow (V_flow_nominal={0.001,0.0025,0.005}, head_nominal={100,60,0}),
medium(h(stateSelect = StateSelect.default), p(stateSelect = StateSelect.default)),N_nominal = 100, V = 0.1, allowFlowReversal = false,
checkValve = true, energyDynamics = Modelica.Fluid.Types.Dynamics.DynamicFreeInitial, m_flow_start = 0.0000001,
massDynamics = Modelica.Fluid.Types.Dynamics.DynamicFreeInitial, nParallel = 1, use_HeatTransfer = false, use_N_in = true);
实际上添加了第二行。