如何访问 modelica 中的多相连接器? (FFT 模型)
How can I access multiphase connectors in modelica? (FFT model)
我设法制作了一个 FFT 模型来分析单相正弦波电压源的频率。
现在我正在尝试将我的 FFT 模型应用于三相域以分析三相电压源的频率。这看起来像下面这样:
within MasterarbeitPWM.FrequenzAnalysator;
model FFTmultiphaseTest
MasterarbeitPWM.FrequenzAnalysator.FFTmultiphase fFTmultiphase1 annotation(
Placement(visible = true, transformation(origin = {188, 110}, extent = {{-38, -38}, {38, 38}}, rotation = 0)));
Modelica.Electrical.MultiPhase.Sources.SineVoltage sineVoltage1(V = fill(5, 3), freqHz = fill(2, 3), m = 3) annotation(
Placement(visible = true, transformation(origin = {121, 22}, extent = {{-24, -27}, {24, 27}}, rotation = -90)));
Modelica.Electrical.Analog.Basic.Ground ground1 annotation(
Placement(visible = true, transformation(origin = {121, -71}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
Modelica.Electrical.MultiPhase.Basic.Star star1 annotation(
Placement(visible = true, transformation(origin = {120, -32}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
equation
connect(sineVoltage1.plug_p, fFTmultiphase1.positivePlug1) annotation(
Line(points = {{122, 46}, {120, 46}, {120, 110}, {146, 110}, {146, 110}}, color = {0, 0, 255}));
connect(star1.plug_p, sineVoltage1.plug_n) annotation(
Line(points = {{120, -22}, {123, -22}, {123, -18}, {120, -18}, {120, 2.98024e-07}, {122, 2.98024e-07}, {122, -4}, {124, -4}, {124, -2}, {122, -2}}, color = {0, 0, 255}));
connect(ground1.p, star1.pin_n) annotation(
Line(points = {{121, -52}, {119, -52}, {119, -42}, {119, -42}}, color = {0, 0, 255}));
annotation(
Diagram(coordinateSystem(extent = {{-300, -200}, {300, 200}})),
Icon(coordinateSystem(extent = {{-300, -200}, {300, 200}})),
__OpenModelica_commandLineOptions = "");end FFTmultiphaseTest;
当我点击 "check model" 时,我没有收到任何错误,但是当我尝试模拟时,它给了我错误
The initialization problem is inconsistent due to the following equation: 0 != 4.33013 = $START.fFTmultiphase1.y[2] - fFTmultiphase1.y[2]
Error in initialization. Storing results and exiting.<br>
Use -lv=LOG_INIT -w for more information.
Simulation process failed. Exited with code -1.
和类似警告:
[1] 13:55:08 Translation Warning
It was not possible to determine if the initialization problem is consistent, because of not evaluable parameters/start values during compile time: fFTmultiphase1.y[1] = $START.fFTmultiphase1.y[1] (sineVoltage1.sineVoltage[1].signalSource.offset + (if time < sineVoltage1.sineVoltage[1].signalSource.startTime then 0.0 else sineVoltage1.sineVoltage[1].signalSource.amplitude * sin(6.283185307179586 * sineVoltage1.sineVoltage[1].signalSource.freqHz * (time - sineVoltage1.sineVoltage[1].signalSource.startTime) + sineVoltage1.sineVoltage[1].signalSource.phase)) = $START.fFTmultiphase1.y[1])
这是我的 FFT 模型:
within MasterarbeitPWM.FrequenzAnalysator;
block FFTmultiphase
import Modelica.Constants.{pi};
import Modelica.Math.FastFourierTransform.*;
import Modelica.SIunits.*;
parameter Frequency f_max = 5 "Maximum frequency of interest";
parameter Frequency f_res = 1 "Frequency resolution";
final parameter Integer ns = realFFTsamplePoints(f_max, f_res, f_max_factor = 5) "Number of samples";
final parameter Integer nf = div(ns, 2) + 1 "Number of frequency points";
final parameter Integer nfi = max(1, min(integer(ceil(f_max / f_res)) + 1, nf));
final parameter Frequency f_i[nfi](each fixed = false) "FFT frequencies of interested frequency points";
parameter Time samplePeriod = 1 / (2 * f_res * div(ns, 2));
output Integer info(start = 0, fixed = true) "Information flag from FFT computation";
Integer iTick(start = 0, fixed = true);
discrete Real Buf[ns](start = zeros(ns), each fixed = true) "Input buffer";
Real A_i[nfi](start = zeros(nfi), each fixed = true) "FFT amplitudes";
Real Phi_i[nfi](start = zeros(nfi), each fixed = true) "FFT phases";
Real y[3](start = fill(0, 3), each fixed = true, each unit = "V");
// "Signal from which FFT is computed";
Modelica.Electrical.MultiPhase.Interfaces.PositivePlug positivePlug1 annotation(
Placement(visible = true, transformation(origin = {-114, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
initial equation
for i in 1:nfi loop
f_i[i] = (i - 1) * f_res;
end for;
equation
y = positivePlug1.pin.v;
positivePlug1.pin[1].i = 0.0;
positivePlug1.pin[2].i = 0.0;
positivePlug1.pin[3].i = 0.0;
algorithm
when sample(0, samplePeriod) then
iTick := iTick + 1;
if iTick <= ns then
Buf[iTick] := y[1];
end if;
if iTick == ns then
(info, A_i, Phi_i) := realFFT(Buf, nfi);
end if;
end when;
annotation(
Icon(graphics = {Text(origin = {-42, 62}, extent = {{110, -78}, {-30, 18}}, textString = "FFT"), Rectangle(origin = {0, -79}, fillPattern = FillPattern.Solid, extent = {{-80, -1}, {80, 1}}), Rectangle(origin = {-79, -49}, fillPattern = FillPattern.Solid, extent = {{-1, -29}, {1, 29}}), Polygon(origin = {-79, -15}, fillPattern = FillPattern.Solid, points = {{0, -5}, {-6, -5}, {0, 5}, {6, -5}, {6, -5}, {0, -5}}), Polygon(origin = {85, -79}, rotation = -90, fillPattern = FillPattern.Solid, points = {{0, -5}, {-6, -5}, {0, 5}, {6, -5}, {6, -5}, {0, -5}}), Rectangle(origin = {-59, -65}, fillPattern = FillPattern.Solid, extent = {{-1, 23}, {1, -15}}), Ellipse(origin = {-59, -39}, fillPattern = FillPattern.Solid, extent = {{-3, 3}, {3, -3}}, endAngle = 360), Ellipse(origin = {-49, -61}, fillPattern = FillPattern.Solid, extent = {{-3, 3}, {3, -3}}, endAngle = 360), Ellipse(origin = {-19, -53}, fillPattern = FillPattern.Solid, extent = {{-3, 3}, {3, -3}}, endAngle = 360), Ellipse(origin = {25, -67}, fillPattern = FillPattern.Solid, extent = {{-3, 3}, {3, -3}}, endAngle = 360), Ellipse(origin = {31, -49}, fillPattern = FillPattern.Solid, extent = {{-3, 3}, {3, -3}}, endAngle = 360), Rectangle(origin = {-49, -65}, fillPattern = FillPattern.Solid, extent = {{-1, 1}, {1, -15}}), Rectangle(origin = {31, -65}, fillPattern = FillPattern.Solid, extent = {{-1, 15}, {1, -15}}), Rectangle(origin = {-19, -63}, fillPattern = FillPattern.Solid, extent = {{-1, 7}, {1, -15}}), Rectangle(origin = {25, -63}, fillPattern = FillPattern.Solid, extent = {{-1, -5}, {1, -15}}), Ellipse(origin = {-67, -61}, fillPattern = FillPattern.Solid, extent = {{-3, 3}, {3, -3}}, endAngle = 360), Rectangle(origin = {-67, -63}, fillPattern = FillPattern.Solid, extent = {{-1, 1}, {1, -15}}), Rectangle(origin = {37, -63}, fillPattern = FillPattern.Solid, extent = {{-1, -5}, {1, -15}}), Ellipse(origin = {37, -67}, fillPattern = FillPattern.Solid, extent = {{-3, 3}, {3, -3}}, endAngle = 360), Line(points = {{-100, 100}, {100, 100}, {100, -100}, {-100, -100}, {-100, 100}, {-100, 100}}, thickness = 0.5)}),
Diagram,
__OpenModelica_commandLineOptions = "");
end FFTmultiphase;
令我遗憾的是我的单相示例有效(带有一些警告)。
我想我在电压源和我的 FFT 模型之间的连接上做错了什么,但我不知道它是什么。
有人可以向我解释我做错了什么以及如何解决吗?
我是 Modelica/OpenModelica 的新手,所以如果这是一个愚蠢的问题,请原谅。
非常感谢!
我观察到的一些事情(使用 Dymola)可能会引起一些麻烦:
block
FFTmultiphase
有一个Multiphase Interface,这在Modelica中通常是没有的。块只有因果 in-/outputs。我已将 class 从块更改为模型。您也可以使用传感器对模型使用 Real
输入来测量电压。
- 由于
Real y[3](start = fill(0, 3), each fixed = true, each unit = "V");
中的 fixed=true
,您的初始方程组似乎是 over-determined。我会尝试删除 each fixed = true
.
第二种似乎更有可能导致您描述的问题。
给出 A_i
= {0,0,4.87,0,0,0} 结果似乎是合理的(尽管我猜第三个条目应该是 5)。
我设法制作了一个 FFT 模型来分析单相正弦波电压源的频率。 现在我正在尝试将我的 FFT 模型应用于三相域以分析三相电压源的频率。这看起来像下面这样:
within MasterarbeitPWM.FrequenzAnalysator;
model FFTmultiphaseTest
MasterarbeitPWM.FrequenzAnalysator.FFTmultiphase fFTmultiphase1 annotation(
Placement(visible = true, transformation(origin = {188, 110}, extent = {{-38, -38}, {38, 38}}, rotation = 0)));
Modelica.Electrical.MultiPhase.Sources.SineVoltage sineVoltage1(V = fill(5, 3), freqHz = fill(2, 3), m = 3) annotation(
Placement(visible = true, transformation(origin = {121, 22}, extent = {{-24, -27}, {24, 27}}, rotation = -90)));
Modelica.Electrical.Analog.Basic.Ground ground1 annotation(
Placement(visible = true, transformation(origin = {121, -71}, extent = {{-19, -19}, {19, 19}}, rotation = 0)));
Modelica.Electrical.MultiPhase.Basic.Star star1 annotation(
Placement(visible = true, transformation(origin = {120, -32}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
equation
connect(sineVoltage1.plug_p, fFTmultiphase1.positivePlug1) annotation(
Line(points = {{122, 46}, {120, 46}, {120, 110}, {146, 110}, {146, 110}}, color = {0, 0, 255}));
connect(star1.plug_p, sineVoltage1.plug_n) annotation(
Line(points = {{120, -22}, {123, -22}, {123, -18}, {120, -18}, {120, 2.98024e-07}, {122, 2.98024e-07}, {122, -4}, {124, -4}, {124, -2}, {122, -2}}, color = {0, 0, 255}));
connect(ground1.p, star1.pin_n) annotation(
Line(points = {{121, -52}, {119, -52}, {119, -42}, {119, -42}}, color = {0, 0, 255}));
annotation(
Diagram(coordinateSystem(extent = {{-300, -200}, {300, 200}})),
Icon(coordinateSystem(extent = {{-300, -200}, {300, 200}})),
__OpenModelica_commandLineOptions = "");end FFTmultiphaseTest;
当我点击 "check model" 时,我没有收到任何错误,但是当我尝试模拟时,它给了我错误
The initialization problem is inconsistent due to the following equation: 0 != 4.33013 = $START.fFTmultiphase1.y[2] - fFTmultiphase1.y[2]
Error in initialization. Storing results and exiting.<br>
Use -lv=LOG_INIT -w for more information.
Simulation process failed. Exited with code -1.
和类似警告:
[1] 13:55:08 Translation Warning
It was not possible to determine if the initialization problem is consistent, because of not evaluable parameters/start values during compile time: fFTmultiphase1.y[1] = $START.fFTmultiphase1.y[1] (sineVoltage1.sineVoltage[1].signalSource.offset + (if time < sineVoltage1.sineVoltage[1].signalSource.startTime then 0.0 else sineVoltage1.sineVoltage[1].signalSource.amplitude * sin(6.283185307179586 * sineVoltage1.sineVoltage[1].signalSource.freqHz * (time - sineVoltage1.sineVoltage[1].signalSource.startTime) + sineVoltage1.sineVoltage[1].signalSource.phase)) = $START.fFTmultiphase1.y[1])
这是我的 FFT 模型:
within MasterarbeitPWM.FrequenzAnalysator;
block FFTmultiphase
import Modelica.Constants.{pi};
import Modelica.Math.FastFourierTransform.*;
import Modelica.SIunits.*;
parameter Frequency f_max = 5 "Maximum frequency of interest";
parameter Frequency f_res = 1 "Frequency resolution";
final parameter Integer ns = realFFTsamplePoints(f_max, f_res, f_max_factor = 5) "Number of samples";
final parameter Integer nf = div(ns, 2) + 1 "Number of frequency points";
final parameter Integer nfi = max(1, min(integer(ceil(f_max / f_res)) + 1, nf));
final parameter Frequency f_i[nfi](each fixed = false) "FFT frequencies of interested frequency points";
parameter Time samplePeriod = 1 / (2 * f_res * div(ns, 2));
output Integer info(start = 0, fixed = true) "Information flag from FFT computation";
Integer iTick(start = 0, fixed = true);
discrete Real Buf[ns](start = zeros(ns), each fixed = true) "Input buffer";
Real A_i[nfi](start = zeros(nfi), each fixed = true) "FFT amplitudes";
Real Phi_i[nfi](start = zeros(nfi), each fixed = true) "FFT phases";
Real y[3](start = fill(0, 3), each fixed = true, each unit = "V");
// "Signal from which FFT is computed";
Modelica.Electrical.MultiPhase.Interfaces.PositivePlug positivePlug1 annotation(
Placement(visible = true, transformation(origin = {-114, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
initial equation
for i in 1:nfi loop
f_i[i] = (i - 1) * f_res;
end for;
equation
y = positivePlug1.pin.v;
positivePlug1.pin[1].i = 0.0;
positivePlug1.pin[2].i = 0.0;
positivePlug1.pin[3].i = 0.0;
algorithm
when sample(0, samplePeriod) then
iTick := iTick + 1;
if iTick <= ns then
Buf[iTick] := y[1];
end if;
if iTick == ns then
(info, A_i, Phi_i) := realFFT(Buf, nfi);
end if;
end when;
annotation(
Icon(graphics = {Text(origin = {-42, 62}, extent = {{110, -78}, {-30, 18}}, textString = "FFT"), Rectangle(origin = {0, -79}, fillPattern = FillPattern.Solid, extent = {{-80, -1}, {80, 1}}), Rectangle(origin = {-79, -49}, fillPattern = FillPattern.Solid, extent = {{-1, -29}, {1, 29}}), Polygon(origin = {-79, -15}, fillPattern = FillPattern.Solid, points = {{0, -5}, {-6, -5}, {0, 5}, {6, -5}, {6, -5}, {0, -5}}), Polygon(origin = {85, -79}, rotation = -90, fillPattern = FillPattern.Solid, points = {{0, -5}, {-6, -5}, {0, 5}, {6, -5}, {6, -5}, {0, -5}}), Rectangle(origin = {-59, -65}, fillPattern = FillPattern.Solid, extent = {{-1, 23}, {1, -15}}), Ellipse(origin = {-59, -39}, fillPattern = FillPattern.Solid, extent = {{-3, 3}, {3, -3}}, endAngle = 360), Ellipse(origin = {-49, -61}, fillPattern = FillPattern.Solid, extent = {{-3, 3}, {3, -3}}, endAngle = 360), Ellipse(origin = {-19, -53}, fillPattern = FillPattern.Solid, extent = {{-3, 3}, {3, -3}}, endAngle = 360), Ellipse(origin = {25, -67}, fillPattern = FillPattern.Solid, extent = {{-3, 3}, {3, -3}}, endAngle = 360), Ellipse(origin = {31, -49}, fillPattern = FillPattern.Solid, extent = {{-3, 3}, {3, -3}}, endAngle = 360), Rectangle(origin = {-49, -65}, fillPattern = FillPattern.Solid, extent = {{-1, 1}, {1, -15}}), Rectangle(origin = {31, -65}, fillPattern = FillPattern.Solid, extent = {{-1, 15}, {1, -15}}), Rectangle(origin = {-19, -63}, fillPattern = FillPattern.Solid, extent = {{-1, 7}, {1, -15}}), Rectangle(origin = {25, -63}, fillPattern = FillPattern.Solid, extent = {{-1, -5}, {1, -15}}), Ellipse(origin = {-67, -61}, fillPattern = FillPattern.Solid, extent = {{-3, 3}, {3, -3}}, endAngle = 360), Rectangle(origin = {-67, -63}, fillPattern = FillPattern.Solid, extent = {{-1, 1}, {1, -15}}), Rectangle(origin = {37, -63}, fillPattern = FillPattern.Solid, extent = {{-1, -5}, {1, -15}}), Ellipse(origin = {37, -67}, fillPattern = FillPattern.Solid, extent = {{-3, 3}, {3, -3}}, endAngle = 360), Line(points = {{-100, 100}, {100, 100}, {100, -100}, {-100, -100}, {-100, 100}, {-100, 100}}, thickness = 0.5)}),
Diagram,
__OpenModelica_commandLineOptions = "");
end FFTmultiphase;
令我遗憾的是我的单相示例有效(带有一些警告)。 我想我在电压源和我的 FFT 模型之间的连接上做错了什么,但我不知道它是什么。 有人可以向我解释我做错了什么以及如何解决吗?
我是 Modelica/OpenModelica 的新手,所以如果这是一个愚蠢的问题,请原谅。
非常感谢!
我观察到的一些事情(使用 Dymola)可能会引起一些麻烦:
block
FFTmultiphase
有一个Multiphase Interface,这在Modelica中通常是没有的。块只有因果 in-/outputs。我已将 class 从块更改为模型。您也可以使用传感器对模型使用Real
输入来测量电压。- 由于
Real y[3](start = fill(0, 3), each fixed = true, each unit = "V");
中的fixed=true
,您的初始方程组似乎是 over-determined。我会尝试删除each fixed = true
.
第二种似乎更有可能导致您描述的问题。
给出 A_i
= {0,0,4.87,0,0,0} 结果似乎是合理的(尽管我猜第三个条目应该是 5)。