Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Twinbuilder中OpenModelica模型的编译_Modelica_Openmodelica - Fatal编程技术网

Twinbuilder中OpenModelica模型的编译

Twinbuilder中OpenModelica模型的编译,modelica,openmodelica,Modelica,Openmodelica,我有一个用Openmodelica编写的模型。我想用Modelica在Twinbuilder中实现这个模型。模型的代码如下所示: model SelfActingValve extends Modelica.Fluid.Interfaces.PartialTwoPortTransport; // Import Elements import Modelica.Constants.pi; import Modelica.Constants.g_n; // Thermodynamic states

我有一个用Openmodelica编写的模型。我想用Modelica在Twinbuilder中实现这个模型。模型的代码如下所示:

model SelfActingValve 
extends Modelica.Fluid.Interfaces.PartialTwoPortTransport;
// Import Elements
import Modelica.Constants.pi;
import Modelica.Constants.g_n;
// Thermodynamic states
//Medium.ThermodynamicState port_a_state_inflow "State at port_a if inflowing";
//Medium.ThermodynamicState port_b_state_inflow "State at port_b if inflowing";

// Parameter
  parameter Modelica.SIunits.Length dGap=0.0062 "Mean value of outer diameter of the valve and the diameter of the pipe in front of the valve
";
  parameter Modelica.SIunits.Angle  alpha=pi/2"Angle between the vertical and the bevel edge of the cone valve";
  parameter Modelica.SIunits.Length dchamber=0.008"diameter before the valve";
  parameter Real gravityAccelerat = g_n;
  parameter Real cValve = 100 "spring constant/(N/m)";
  parameter Modelica.SIunits.Length spPre = 0.0029 "length of the spring preload";
  parameter Modelica.SIunits.Length scaleS = 0.0089 "maximum of possible movement of the sprin";
  parameter Modelica.SIunits.Mass mValve = 0.000486 "Mass of the valve body";
  parameter Modelica.SIunits.Area surfacePorta=1"Surface of the valve at port_a";
  parameter Modelica.SIunits.Area surfacePortb=1"Surface of the valve at port_b";
  parameter Modelica.SIunits.Volume volValve= 436e-9 "Volume of the valvebody";
  parameter Modelica.SIunits.Length dhydro=1.52e-3"hydraulic eyuivalent diameter of the gap ";
  parameter Boolean outletValve = false "= true --> outletValve, false-->inlet valve" annotation(
    Dialog(tab = "General"),
    Evaluate = true);
  parameter Real kgeo=10"geometric constant";
  parameter Real zetaOwn=0.7"loss coeffizient of the valve";
 // Variables in the equation
//protected
//  Real zetaOwn_dummy(start=0.7)"dummy for loss coefficient";
// Real zetaOwn(start=0.7) "loss coefficient";
//  Real P_lose(start=0);
  Real x(start = 0, min=0, max=scaleS) "Position of the valve";
  Real xdot(start = 0) "velocity of the valve";
  Real force0(start = 0) " preload of spring";
  Real forceSpr(start = 0) "spring force";
  Real dummydot(start = 0) "first derrivative dummy";
  Real forcePress(start=0);
  Real forceGrav(start = 0) "Gravity force of valve";
  Real forceDamp(start=0)"Damping force from friction";
  Real densiWat(start=998.2)"density of the medium";
  Real eta(start=1)"dynamic viscosity";
 Real thetaStar(start=0)"damping factor";
 Real volumstream(start=0);
//  Real reynold(start=10000)"Reynold number of the fluid before the gap";
//  Real psi(start=0.4)"coeffizeint to describe the not equal pressure distribution on the valve"; 
  Real reynoldGap(start=1)"Reynold number of the fluid in the gap";
  
equation
volumstream=m_flow*densiWat;

// outflow equation
m_flow=x*dGap*pi*densiWat*sin(alpha)*(abs((2*dp)/(zetaOwn*densiWat)))^(1/2);

//Ansatz für Lösen der Singularität, aber keine Ergebnisse.
// Isenthalpic state transformation (no storage and no loss of energy)
  port_a.h_outflow = inStream(port_b.h_outflow);
  port_b.h_outflow = inStream(port_a.h_outflow);

// Fence modelation
  if dummydot < 0 and x<0 then
    der(xdot) = 0;
    der(x) = 0;
  elseif dummydot > 0 and x>scaleS then
    der(xdot) = 0;
    der(x) = 0;
  else
    if outletValve == true then
      der(xdot) = 1 / mValve * ((-force0) - forceGrav - forceSpr +  forcePress-forceDamp*xdot);
//      der(xdot) = 1 / mValve * ((-force0) - forceGrav - forceSpr +  forcePress);
      xdot = der(x);
    else
      der(xdot) = 1 / mValve * ((-force0) + forceGrav - forceSpr+ forcePress-forceDamp*xdot);
//      der(xdot) = 1 / mValve * ((-force0) + forceGrav - forceSpr+ forcePress);
      xdot = der(x);
    end if;
// This If loop is for the direction of the Forces, e.g. Depending if we have a outlet or a inlet valve the pressure force appeals in different directions.
  end if;
// This If loop is for modelling of the fences of the valve
when dummydot < 0 and x<0 then
//    xdotnew=if edge(impact) then 0 else xdot;
    reinit(xdot, 0);
elsewhen dummydot > 0 and x> scaleS then
//    xdotnew=if edge(impact) then 0 else xdot;
    reinit(xdot, 0);
end when;
// This when loop reinitializes the speed and the accleration of the valve, when it hit the fences.
// equation of motion and force definition
if outletValve == true then
    dummydot = 1 / mValve * ((-force0) - forceGrav - forceSpr+ forcePress-forceDamp*xdot );
//    dummydot = 1 / mValve * ((-force0) - forceGrav - forceSpr+ forcePress );
else
    dummydot = 1 / mValve * ((-force0) + forceGrav - forceSpr + forcePress-forceDamp*xdot);
//    dummydot = 1 / mValve * ((-force0) + forceGrav - forceSpr + forcePress);
end if;
// This If loop is for the direction of the Forces, e.g. Depending if we have a outlet or a inlet valve the pressure force appeals in different directions. Dummydot is to calculate the actual acceleration to see, if we get away from the fences.

  force0 = spPre * cValve "preload of the spring";
  forcePress= port_a.p*surfacePorta-port_b.p*surfacePortb"Force of the pressures acting on the valve";
  forceSpr = cValve * x"force of the spring due to movements of the valve";
  forceGrav = gravityAccelerat*( mValve -densiWat*volValve) "Gravity of the valve";
  forceDamp=thetaStar*eta*dGap/kgeo"damping force";
  thetaStar=10*reynoldGap+505"help variable for caculation forceDamp";
  //  psi=0.82-1.6*x/dGap-0.075*log(abs(reynold));
//zetaOwn=280/reynoldGap+1;
eta = if m_flow > 0 then 
             Medium.dynamicViscosity(state_a) 
      else
              Medium.dynamicViscosity(state_b);
densiWat=if m_flow>0 then
               Medium.density(state_a)
         else
               Medium.density(state_b);

if x< scaleS/1000 then
  reynoldGap=0;
//  reynold=1;
else
 reynoldGap=4*m_flow/(pi*2*x*sin(alpha)*eta);
// reynold=4*m_flow/(pi*dchamber*eta);
end if;
 // if loop: First fix for to big Reynold number in case of nearly closed valve positions

  
annotation(Icon(coordinateSystem(
        preserveAspectRatio=true,
        extent={{-100,-100},{100,100}}), graphics={
        Line(points={{0,50},{0,0}}),
        Rectangle(
          extent={{-20,60},{20,50}},
          fillPattern=FillPattern.Solid),
        Polygon(
          points={{-100,50},{100,-50},{100,50},{0,0},{-100,-50},{-100,50}},
          fillColor={255,255,255},
          fillPattern=FillPattern.Solid),
        Polygon(
          points=DynamicSelect({{-100,0},{100,-0},{100,0},{0,0},{-100,-0},{-100,
              0}}, {{-100,50*opening},{-100,50*opening},{100,-50*opening},{
              100,50*opening},{0,0},{-100,-50*opening},{-100,50*opening}}),
          fillColor={0,255,0},
          lineColor={255,255,255},
          fillPattern=FillPattern.Solid),
        Polygon(points={{-100,50},{100,-50},{100,50},{0,0},{-100,-50},{-100,
              50}})}),Documentation(info="<html>
<p>
This model is build up witht the equations of the doctoral degree thesis ofErwin Thiel at the University Erlangen-Nürnberg with the title 'Kinematik und Druckverlust selbsttätiger Ventile oszillierender Verdrängerpumpen'.  GENAUERE BESCHREIBUNG FOLGT
<p>
</html>"),Icon(coordinateSystem(initialScale = 0.1), graphics = {Line(points = {{0, 50}, {0, 0}}), Rectangle(fillPattern = FillPattern.Solid, extent = {{-20, 60}, {20, 50}}), Polygon(fillColor = {255, 255, 255}, fillPattern = FillPattern.Solid, points = {{-100, 50}, {100, -50}, {100, 50}, {0, 0}, {-100, -50}, {-100, 50}}), Polygon(lineColor = {255, 255, 255}, fillColor = {0, 255, 0}, fillPattern = FillPattern.Solid, points = {{-100, 0}, {100, 0}, {100, 0}, {0, 0}, {-100, 0}, {-100, 0}}), Polygon(points = {{-100, 50}, {100, -50}, {100, 50}, {0, 0}, {-100, -50}, {-100, 50}})}),
    uses(Modelica(version = "3.2.3")));

end SelfActingValve;
你知道如何处理这个错误吗


非常感谢您的帮助和投入的时间提供建议。

您有两个图标批注,在模型末尾,删除其中一个


如果您只想测试它,您可以删除整个注释。

您有两个图标注释,在模型末尾,删除其中一个

如果只想测试注释,可以删除整个注释

Command GetStaticIconSVG failed with following error:
User error: 
ERROR: The annotation for the icon for SelfActingValve is malformed, cannot generate an icon
java exception in java.lang.NullPointerException