OpenModelica не может запустить FMU? - PullRequest
2 голосов
/ 28 мая 2020

Я создал модель в OpenModelica, используя несколько простых блоков и уравнений:

block ZapuniInterpolation
// ----------------------------------------------------------------------------- //
  Modelica.Blocks.Interfaces.RealInput tableInput(start=190) annotation(
    Placement(visible = true, transformation(origin = {-68, 20}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-68, 20}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
  Modelica.Blocks.Interfaces.RealInput sineGainInput(start=1) annotation(
    Placement(visible = true, transformation(origin = {-68, -20}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-68, -20}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
  Modelica.Blocks.Interfaces.RealOutput output1 annotation(
    Placement(visible = true, transformation(origin = {22, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {22, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Blocks.Interfaces.RealOutput output2 annotation(
    Placement(visible = true, transformation(origin = {42, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {42, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Blocks.Interfaces.RealOutput output3 annotation(
    Placement(visible = true, transformation(origin = {62, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {62, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Blocks.Interfaces.RealInput alpha(start=0) annotation(
    Placement(visible = true, transformation(origin = {-8,-20}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-8,-20}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
  Modelica.Blocks.Interfaces.RealInput beta(start=0) annotation(
    Placement(visible = true, transformation(origin = {22, -20}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {22, -20}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
  Modelica.Blocks.Interfaces.RealInput gamma(start=0) annotation(
    Placement(visible = true, transformation(origin = {52, -20}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {52, -20}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
  Modelica.Blocks.Interfaces.RealInput sineFrequency(start = 1) annotation(
    Placement(visible = true, transformation(origin = {-38, -20}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-38, -20}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
// ----------------------------------------------------------------------------- //
protected
// ----------------------------------------------------------------------------- //
  import PI = Modelica.Constants.pi;
// -------------  
  Modelica.Blocks.Tables.CombiTable1Ds modelDef(table = [180.0, 0.0, 0.125639618, 0.122496368, 0.152595123, 1.30134654, 7.03518772, 10.1638193, 11.777113, 12.5243101, 21.683424, 27.5360508, 34.4655838, 34.1353836, -0.000156808334, 0.000567958435, -6.16513252e-06, 5.07716331e-05, 0.000295116516, -0.00226303029, 1.72715359e-05, -2.76345825e-05, -0.000384722595, -1.60172176e-05, 2.38217144e-05, 8.43528748e-06, 2.26263523e-05, -0.0392020416, -0.0412239838, 0.000444312775, -0.00735736036, 0.083243988, 0.00416324186, 0.00528137589, -0.012360487, 1.24845228e-05, -0.196934738, 6.53376694e-05, -7.1772345e-07, -0.047993618; 
  182.5, 0.0, 0.12338031, 0.121614441, 0.152516403, 1.28446889, 7.03372765, 10.160368, 11.7592869, 12.5243101, 24.4601326, 27.5334625, 34.4655838, 32.8034935, -0.000155028641, 0.000569061768, -1.06752777e-05, 4.43576736e-05, 0.000292540131, -0.00226327395, 1.87270737e-05, -2.94425335e-05, -0.000384721771, -1.95333481e-05, 2.38186722e-05, 8.43502998e-06, 2.18605156e-05, -0.038757122, -0.0399122047, 0.000745555359, -0.00661621618, 0.080380722, 0.00384176278, 0.00474613094, -0.010696907, 1.03946018e-05, -0.187355469, 0.000304825897, -3.04758026e-07, -0.0856405334; 
  185.0, 0.0, 0.121165268, 0.120708992, 0.152441833, 1.26705885, 7.03220701, 10.1565781, 11.7394562, 12.5243101, 26.2911625, 27.5308762, 34.4655838, 33.3992195, -0.000153284882, 0.000568685425, -4.0209774e-05, 3.89236832e-05, 0.000290123566, -0.00226349735, 2.0346014e-05, -3.14919395e-05, -0.000384720856, -2.75364189e-05, 2.39696522e-05, 8.43503952e-06, 1.46955872e-05, -0.0383211823, -0.0385091896, 0.00271969485, -0.00597921848, 0.0775424423, 0.00357709074, 0.00436138248, -0.00955755329, 8.97015572e-06, -0.137678406, 0.000970456665, -8.64766174e-07, -0.156308731; 
  187.5, 0.0, 0.118988342, 0.119786552, 0.152369507, 1.24918771, 7.0306282, 10.1524391, 11.7177658, 12.5243092, 26.049839, 27.5282478, 34.4655838, 37.3313332, -0.000151576111, 0.000570432922, 2.22414017e-05, 3.42602654e-05, 0.000287870667, -0.00226369929, 2.21327553e-05, -3.37703247e-05, -0.000384719849, -3.28333435e-05, 2.40614624e-05, 8.43494415e-06, 6.49287128e-06, -0.0378939934, -0.0372608452, -0.00145591199, -0.00542455482, 0.074719574, 0.00335672474, 0.00408232164, -0.00875357533, 7.95372009e-06, -0.080245285, 0.000683899231, 4.3715094e-07, -0.196699677; 
  190.0, 0.0, 0.116858894, 0.118837822, 0.152297958, 1.23091626, 7.02899122, 10.1479139, 11.6941319, 12.5243092, 24.9532948, 27.5255089, 34.4655838, 43.7087631, -0.000149901413, 0.000571410095, 8.67566872e-06, 3.02129364e-05, 0.000285783508, -0.00226387715, 2.41047344e-05, -3.62895241e-05, -0.000384718781, -3.62359619e-05, 2.40104408e-05, 8.43495083e-06, 3.14631987e-06, -0.0374753189, -0.0359707489, -0.000549157532, -0.0049361062, 0.0719031982, 0.00317143512, 0.00388165021, -0.00817939949, 7.20596743e-06, -0.0537428932, 0.000341564392, 1.62058945e-07, -0.2088992; 
  195.0, 0.0, 0.112727142, 0.116876053, 0.152152176, 1.19337523, 7.02551937, 10.1374197, 11.639926, 12.5243092, 22.4547005, 27.5198441, 34.4655838, 63.5006485, -0.000146650772, 0.000572308289, 3.85471559e-06, 2.35291004e-05, 0.000282106537, -0.00226414824, 2.87340622e-05, -4.21810608e-05, -0.00038471637, -4.2829483e-05, 2.39550076e-05, 8.43493652e-06, 1.15650666e-06, -0.0366626587, -0.0333576317, -0.00022747081, -0.0041120615, 0.0662582474, 0.0028797617, 0.00365292263, -0.00749141979, 6.22078133e-06, -0.0335395622, 0.00014459668, 7.19030685e-08, -0.2181745; 
  200.0, 0.0, 0.10876281, 0.114828865, 0.151995438, 1.15478432, 7.02172279, 10.1242056, 11.5731678, 12.5243082, 20.1688595, 27.5138836, 34.4655838, 97.7778931, -0.000143526184, 0.000572750549, 2.4388926e-06, 1.82274666e-05, 0.000279082581, -0.00226427436, 3.46423569e-05, -4.95841827e-05, -0.000384713623, -5.03695107e-05, 2.39311123e-05, 8.4349184e-06, 1.23468935e-06, -0.0358815079, -0.030764555, -0.000133495087, -0.00343931985, 0.0605537033, 0.00266271996, 0.00360132694, -0.00721686459, 5.66029549e-06, -0.0255758495, 8.98340149e-05, 4.8260746e-08, -0.220523834]) annotation(
    Placement(visible = true, transformation(origin = {-18, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
// ----------------------------------------------------------------------------- //
  Real[13] omega2 = {modelDef.y[1], modelDef.y[2], modelDef.y[3], modelDef.y[4], modelDef.y[5], modelDef.y[6], modelDef.y[7], modelDef.y[8], modelDef.y[9], modelDef.y[10], modelDef.y[11], modelDef.y[12], modelDef.y[13]};
  // -------------
  Real[13] Ba = {modelDef.y[14], modelDef.y[15], modelDef.y[16], modelDef.y[17], modelDef.y[18], modelDef.y[19], modelDef.y[20], modelDef.y[21], modelDef.y[22], modelDef.y[23], modelDef.y[24], modelDef.y[25], modelDef.y[26]};
  // -------------
  Real[13] Ca = {modelDef.y[27], modelDef.y[28], modelDef.y[29], modelDef.y[30], modelDef.y[31], modelDef.y[32], modelDef.y[33], modelDef.y[34], modelDef.y[35], modelDef.y[36], modelDef.y[37], modelDef.y[38], modelDef.y[39]};
  // -------------
  Real[13] damping = beta * omega2 + gamma * sqrt(omega2) .+ alpha;
// ----------------------------------------------------------------------------- //
  Real [1] ssu "input vector";
  Real [3] ssy = {output1, output2, output3}"output vector";
  Real [26] ssx "state vector";
// ----------------------------------------------------------------------------- //
  // -------------
  Real[26, 26] ssA = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0; 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0; 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0; 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0; 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0; 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0; 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0; 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0; 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0; 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0; 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0; 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0; 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1; 
-omega2[1], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -damping[1], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0; 
0, -omega2[2], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -damping[2], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0; 
0, 0, -omega2[3], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -damping[3], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0; 
0, 0, 0, -omega2[4], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -damping[4], 0, 0, 0, 0, 0, 0, 0, 0, 0; 
0, 0, 0, 0, -omega2[5], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -damping[5], 0, 0, 0, 0, 0, 0, 0, 0; 
0, 0, 0, 0, 0, -omega2[6], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -damping[6], 0, 0, 0, 0, 0, 0, 0; 
0, 0, 0, 0, 0, 0, -omega2[7], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -damping[7], 0, 0, 0, 0, 0, 0; 
0, 0, 0, 0, 0, 0, 0, -omega2[8], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -damping[8], 0, 0, 0, 0, 0; 
0, 0, 0, 0, 0, 0, 0, 0, -omega2[9], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -damping[9], 0, 0, 0, 0; 
0, 0, 0, 0, 0, 0, 0, 0, 0, -omega2[10], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -damping[10], 0, 0, 0; 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -omega2[11], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -damping[11], 0, 0; 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -omega2[12], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -damping[12], 0; 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -omega2[13], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -damping[13]];
  // ------------
  Real[26, 1] ssB = [0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; Ba[1]; Ba[2]; Ba[3]; Ba[4]; Ba[5]; Ba[6]; Ba[7]; Ba[8]; Ba[9]; Ba[10]; Ba[11]; Ba[12]; Ba[13]];
  // ------------
  Real[3, 26] ssC = [Ca[1], Ca[2], Ca[3], Ca[4], Ca[5], Ca[6], Ca[7], Ca[8], Ca[9], Ca[10], Ca[11], Ca[12], Ca[13], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0; 
  Ba[1], Ba[2], Ba[3], Ba[4], Ba[5], Ba[6], Ba[7], Ba[8], Ba[9], Ba[10], Ba[11], Ba[12], Ba[13], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0; 
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Ba[1], Ba[2], Ba[3], Ba[4], Ba[5], Ba[6], Ba[7], Ba[8], Ba[9], Ba[10], Ba[11], Ba[12], Ba[13]];
  // -----------
  Real[3, 1] ssD = [0; 0; 0];
// ----------------------------------------------------------------------------- //
initial equation
  ssx = fill(0, 26);
// ----------------------------------------------------------------------------- //
equation
// ----------------------------------------------------------------------------- //
  connect(modelDef.u, tableInput) annotation(
    Line(points = {{-30, 20}, {-68, 20}}, color = {0, 0, 127}));
  der(ssx) = ssA * ssx + ssB * ssu;
  ssy = ssC * ssx + ssD * ssu;
  ssu = {sineGainInput *sin(2*PI*sineFrequency*time)};
// ----------------------------------------------------------------------------- //
  annotation(
    uses(Modelica(version = "3.2.3")));
end ZapuniInterpolation;

Теперь я экспортировал модель в FMU с помощью OpenModelica, используя версию 2.0 и Model Exchange - Co Simulation. Когда я импортирую этот FMU в другую модель и присоединяю простые входы и выходы, например:

model importZapuniFMUtest
  Modelica.Blocks.Interfaces.RealInput alpha(start=0) annotation(
    Placement(visible = true, transformation(origin = {-80, 80}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-80, 80}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
  Modelica.Blocks.Interfaces.RealInput beta(start=0) annotation(
    Placement(visible = true, transformation(origin = {-80, 50}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-80, 50}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
  Modelica.Blocks.Interfaces.RealInput gamma(start=0) annotation(
    Placement(visible = true, transformation(origin = {-80, 20}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-80, 20}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
  Modelica.Blocks.Interfaces.RealInput Length(start=190) annotation(
    Placement(visible = true, transformation(origin = {-80, -80}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-80, -80}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
  Modelica.Blocks.Interfaces.RealInput Amplitude(start=1) annotation(
    Placement(visible = true, transformation(origin = {-80, -50}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-80, -50}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
  Modelica.Blocks.Interfaces.RealInput Frequency(start=1) annotation(
    Placement(visible = true, transformation(origin = {-80, -20}, extent = {{-20, -20}, {20, 20}}, rotation = 0), iconTransformation(origin = {-80, -20}, extent = {{-20, -20}, {20, 20}}, rotation = 0)));
  Modelica.Blocks.Interfaces.RealOutput Y1 annotation(
    Placement(visible = true, transformation(origin = {70, 50}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {70, 50}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Blocks.Interfaces.RealOutput Y2 annotation(
    Placement(visible = true, transformation(origin = {70, 30}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {70, 30}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Blocks.Interfaces.RealOutput Y3 annotation(
    Placement(visible = true, transformation(origin = {70, 10}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {70, 10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  ZapuniInterpolation_me_FMU zapuniInterpolation annotation(
    Placement(visible = true, transformation(origin = {10, 10}, extent = {{-30, -30}, {30, 30}}, rotation = 0)));
equation
  connect(zapuniInterpolation.alpha, alpha) annotation(
    Line(points = {{-24, 32}, {-30, 32}, {-30, 80}, {-80, 80}, {-80, 80}}, color = {0, 0, 127}));
  connect(zapuniInterpolation.beta, beta) annotation(
    Line(points = {{-24, 24}, {-40, 24}, {-40, 50}, {-80, 50}, {-80, 50}}, color = {0, 0, 127}));
  connect(zapuniInterpolation.gamma, gamma) annotation(
    Line(points = {{-24, 16}, {-50, 16}, {-50, 20}, {-80, 20}, {-80, 20}}, color = {0, 0, 127}));
  connect(zapuniInterpolation.sineFrequency, Frequency) annotation(
    Line(points = {{-24, 8}, {-50, 8}, {-50, -20}, {-80, -20}, {-80, -20}}, color = {0, 0, 127}));
  connect(zapuniInterpolation.sineGainInput, Amplitude) annotation(
    Line(points = {{-24, 0}, {-40, 0}, {-40, -50}, {-80, -50}, {-80, -50}}, color = {0, 0, 127}));
  connect(zapuniInterpolation.tableInput, Length) annotation(
    Line(points = {{-24, -6}, {-30, -6}, {-30, -80}, {-80, -80}, {-80, -80}}, color = {0, 0, 127}));
  connect(zapuniInterpolation.output1, Y1) annotation(
    Line(points = {{44, 32}, {50, 32}, {50, 50}, {70, 50}, {70, 50}}, color = {0, 0, 127}));
  connect(zapuniInterpolation.output2, Y2) annotation(
    Line(points = {{44, 24}, {52, 24}, {52, 30}, {70, 30}, {70, 30}}, color = {0, 0, 127}));
  connect(zapuniInterpolation.output3, Y3) annotation(
    Line(points = {{44, 16}, {50, 16}, {50, 10}, {70, 10}, {70, 10}}, color = {0, 0, 127}));

annotation(
    uses(Modelica(version = "3.2.3")));
end importZapuniFMUtest;

, я получаю следующую ошибку:

[1] 13:28:34 Перевод Ошибка [ZapuniInterpolation_me_FMU: 1360: 7-1360: 39]: Оператор reinit можно использовать только в теле уравнения when.

Я понятия не имею, что я сделал неправильно, так как исходная модель отлично работает в OpenModelica, я могу изменить все входные данные и т.д. c, но экспортированная модель не работает.

...