我写了一个简单的代码来试验在标准库的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'的扩展中 数据-> 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。
有人可以向我解释这是什么意思,以及如何解决? 谢谢
答案 0 :(得分:2)
该模型不适用于Dymola高度,但它提供以下提示:
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);
第二行实际上已添加。