确定线性系统下的矩阵奇异不可解 [英] matrix singular under determined linear system not solvable

查看:63
本文介绍了确定线性系统下的矩阵奇异不可解的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据这个问题,我将代码修改为:

Following this question, I modified my code to:

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] .... 翻译警告

[1] .... Translation Warning

撕裂非线性方程组中具有默认零起始属性的迭代变量:

Iteration variables with default zero start attribute in torn nonlinear equation system:

     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

这没有意义,但我认为我可以放心地忽略以下编译错误:

which doesn't make sense but I assume I can safely ignore, and the compiling error of:

矩阵单数!

欠定线性系统不可解

之前也曾报道过此处.如果我删除线条

which had also been previously reported here. if I remove the lines

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 设置为零,理论上相同的事情会导致与上述相同的错误!如果您能帮助我了解问题所在以及如何解决,我将不胜感激.

works perfectly fine. However, setting Muk to zero, which theoretically the same thing leads to the same error as above! I would appreciate if you could help me know what is the problem and how I can resolve it.

P.S.1. 在 Dymola 的演示版上,模拟测试完成时没有错误,只有警告:

P.S.1. On the demo version of Dymola the simulation test finishes with no errors, only the warning:

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 代码:

P.S.2. Using JModelica, removing the noEvent and using the python code:

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)求解模型.但它再次陷入更大的价值.唯一的警告是:

it solves the model blazingly fast for small values (e.g. 0.1) of Muk. But again it gets stuck for bigger values. The only warnings are:

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!

推荐答案

此外,由 if 方程触发的事件似乎可以完全替换为 Sample 运算符.你可能想看看那个.

Also it seems like your event triggered by your if-equation could be cleanly replaced by a Sample operator. You might want to have a look at that.

这篇关于确定线性系统下的矩阵奇异不可解的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆