我目前正在尝试使用 OpenModelica 模拟声学谐振器,我想知道如何稳健/准确地计算它们的谐振频率。
作为一个简化的例子(没有媒体等),我实现了一个双亥姆霍兹谐振器,本质上是两个体积(顺从性)通过管道(惯性)连接。真实系统由更多连接在一起的组件组成。压力和体积流量(均为复数值)的振荡遵循正弦表达式,具有共振角频率w
。这为 4 个压力和 4 个体积流量(在端点和柔顺-惯性连接点)产生了 8 个方程。
这是我每晚在 OpenModelica 中解决的 Modelica 代码:
model Helmholtz_test "Simple test of double Helmholtz resonator"
constant Complex j = Modelica.ComplexMath.j;
ComplexU U_a, U_b, U_c, U_d "Oscillating volume flow rate";
ComplexPressure p_a, p_b, p_c, p_d "Oscillating pressure";
Modelica.SIunits.AngularFrequency w(start=2000, fixed=false);
Compliance C = 7.14e-9;
Inertance L = 80;
initial equation
p_a.re = 1e+2; //Simulation finishes, values reasonable, only during initialisation we get:
//Matrix singular!
//under-determined linear system not solvable!
//The initialization finished successfully without homotopy method.
equation
//BCs on ends
U_a = Complex(0);
U_d = Complex(0);
//Left compliance a-b;
p_a = p_b;
p_a = -1 / (j * w * C) * (U_b - U_a);
//Inertance b-c
U_b = U_c;
p_c - p_b = -j * w * L * U_b;
//Right compliance c-d
p_c = p_d;
p_c = -1 / (j * w * C) * (U_d - U_c);
//Additional condition for Eigenvalue
der(w) = 0;
//w^2 = 2/(L*C); //The "real" resonance frequency
annotation(
experiment(StartTime = 0, StopTime = 1, Tolerance = 1e-06, Interval = 0.002));
end Helmholtz_test;
附加定义
operator record ComplexPressure =
Complex(redeclare Modelica.SIunits.Pressure re,
redeclare Modelica.SIunits.Pressure im)
"Complex pressure";
operator record ComplexU =
Complex(redeclare Modelica.SIunits.VolumeFlowRate re,
redeclare Modelica.SIunits.VolumeFlowRate im)
"Complex volume flow rate";
type Compliance = Real(final quantity = "Compliance", final unit = "m3.Pa-1");
type Inertance = Real(final quantity="Inertance", final unit="kg.m-4");
在纸上计算,系统的共振角频率为w=\sqrt{\frac{2}{LC}}
(在这种情况下约为 1871 1/s),以获得非零解。
为了避免求解器得到零所有的无趣解,我必须在某一点添加一些刺激,因此初始方程p_a.re = 1e+2
。
现在,为了模拟这个,因为w
是一个附加变量,我需要引入一个附加方程,der(w) = 0;
在这种情况下选择谐振频率是恒定的。不幸的是,这使得无法进入更复杂/现实的情况,其中谐振频率随时间变化,例如随温度或其他变化值。
Q1:有没有更好的方法来提供共振频率的附加方程/计算系统的这个特征值?
此外,模拟的成功取决于初始刺激的值(在某些范围内,这会失败,或者我在每个时间步都得到奇异方程)。此外,实际上问题正在初始化阶段得到解决。在最好的情况下,我得到输出
Simulation finishes, values reasonable, only during initialisation we get:
Matrix singular!
under-determined linear system not solvable!
The initialization finished successfully without homotopy method.
Q2:有没有办法避免奇点和/或干净地处理这个初始化(例如homotopy
)?
虽然这在简化示例中可以充分发挥作用(并导致 的值正确w
),但我担心对于更复杂/现实的模型,我可能会遇到更多有问题的数值困难。我已经研究过了homotopy
,但我真的不知道如何在这里应用它。我想以w
某种方式应用它,但弗里茨森的书甚至似乎明确警告不要在导数表达式上使用它,除此之外,w.start
似乎只有值出现了。