【发布时间】:2019-10-21 09:36:26
【问题描述】:
按照this question,我将代码修改为:
model test
// types
type Mass = Real(unit = "Kg", min = 0);
type Length = Real(unit = "m");
type Area = Real(unit = "m2", min = 0);
type Force = Real(unit = "Kg.m/s2");
type Pressure = Real(unit = "Kg/m/s2");
type Torque = Real(unit = "Kg.m2/s2");
type Velocity = Real(unit = "m/s");
type Time = Real(unit = "s");
// constants
constant Real pi = 2 * Modelica.Math.asin(1.0);
parameter Mass Mp = 0.01;
parameter Length r1 = 0.010;
parameter Length r3 = 0.004;
parameter Integer n = 3;
parameter Area A = 0.020 * 0.015;
parameter Time Stepping = 1.0;
parameter Real DutyCycle = 1.0;
parameter Pressure Pin = 500000;
parameter Real Js = 1;
//parameter Real Muk = 0.0;
parameter Real Muk = 0.158;
// variables
Length x[n];
Velocity vx[n];
Real theta;
Real vt;
Pressure P[n];
Force Fnsp[n];
Torque Tfsc;
initial equation
theta = 0;
vt = 0;
algorithm
for i in 1:n loop
if noEvent((i - 1) * Stepping < mod(time, n * Stepping)) and noEvent(mod(time, n * Stepping) < Stepping * ((i - 1) + DutyCycle)) then
P[i] := Pin;
else
P[i] := 0;
end if;
end for;
Tfsc := -r3 * Muk * sign(vt) * abs(sum(Fnsp));
equation
vx = der(x);
vt = der(theta);
x = r1 * {sin(theta + (i - 1) * 2 * pi / n) for i in 1:n};
Mp * der(vx) + P * A = Fnsp;
Js * der(theta) = Tfsc - r1 * Fnsp * {cos(theta + (i - 1) * 2 * pi / n) for i in 1:n};
// Js * der(theta) = - r1 * Fnsp * {cos(theta + (i - 1) * 2 * pi / n) for i in 1:n};
annotation(
experiment(StartTime = 0, StopTime = 30, Tolerance = 1e-06, Interval = 0.03),
__OpenModelica_simulationFlags(lv = "LOG_STATS", outputFormat = "mat", s = "dassl"));
end test;
但是,我收到了
的预处理警告[1] .... 翻译警告
撕裂非线性方程组中具有默认零起始属性的迭代变量:
Fnsp[3]:VARIABLE(unit = "Kg.m/s2" ) type: Real [3] Fnsp[2]:VARIABLE(unit = "Kg.m/s2" ) type: Real [3] Fnsp[1]:VARIABLE(unit = "Kg.m/s2" ) type: Real [3] $DER.vt:VARIABLE() type: Real
这没有意义,但我认为我可以放心地忽略,以及以下编译错误:
矩阵单数!
欠定线性系统不可解
之前也曾报告过here。如果我删除这些行
Torque Tfsc;
和
Tfsc := -r3 * Muk * sign(vt) * abs(sum(Fnsp));
变化
Js * der(theta) = - r1 * Fnsp * {cos(theta + (i - 1) * 2 * pi / n) for i in 1:n};
工作得很好。但是,将Muk 设置为零,理论上这会导致与上述相同的错误!如果您能帮助我了解问题所在以及如何解决,我将不胜感激。
P.S.1. 在 Dymola 的演示版上,模拟测试完成时没有错误,只有警告:
Some variables are iteration variables of the initialization problem:
but they are not given any explicit start values. Zero will be used.
Iteration variables:
der(theta, 2)
P[1]
P[2]
P[3]
P.S.2. 使用 JModelica,删除 noEvent 并使用 python 代码:
model_name = 'test'
mo_file = 'test.mo'
from pymodelica import compile_fmu
from pyfmi import load_fmu
my_fmu = compile_fmu(model_name, mo_file)
myModel = load_fmu('test.fmu')
res = myModel.simulate(final_time=30)
theta = res['theta']
t = res['time']
import matplotlib.pyplot as plt
plt.plot(t, theta)
plt.show()
对于Muk 的小值(例如0.1),它可以极快地求解模型。但它再次陷入更大的价值。唯一的警告是:
Warning at line 30, column 3, in file 'test.mo':
Iteration variable "Fnsp[2]" is missing start value!
Warning at line 30, column 3, in file 'test.mo':
Iteration variable "Fnsp[3]" is missing start value!
Warning in flattened model:
Iteration variable "der(_der_theta)" is missing start value!
【问题讨论】:
-
一些较小的cmets:它是“kg”而不是“Kg”,并且不允许多次划分,所以“Kg/m/s2”应该写成“kg/(m.s2)”。跨度>
-
@HansOlsson 非常感谢。很高兴您和其他 Modelica 人员加入 Modelica Discord group。
标签: modelica dymola openmodelica jmodelica