Simulink无法解决包含我自制的状态空间传播器的代数循环

时间:2015-01-27 12:20:40

标签: matlab simulink

由于我的状态空间模型的某些系数随时间而变化,因此我为状态空间矩阵创建了自己的传播器。在开环(所有输入不变)中,一切都很好。在闭环中虽然它只运行一段时间(取决于求解器),但由于它无法解决所谓的代数回路而失败。通过闭环,我的意思是2个输入是受噪声影响的常数(Tf和Ta),第3个是PID控制器的输出,用于监视该功能的输出。 Simulink所讨论的不连续性可能是P本身,因为它是脉冲宽度调制信号(0或3000)。

  

在代数循环中检测到的不连续性可能无法解决。

     

解决包含的代数循环时的收敛问题   ' PAC_control_sim / BB /状态空间模型'时间5069.4509867718116。   Simulink将尝试使用Simulink 3(R11)策略解决此循环。

     

Simulink无法解决包含的代数循环   ' PAC_control_sim / BB /状态空间模型'时间5069.4509867718116   由于以下原因之一,使用基于TrustRegion的算法   原因:模型定义不明确,即系统方程式没有   有一个解决方案;或者非线性方程求解器未能收敛   由于数字问题。

为什么呢?在下面的代码中,我甚至用常数替换了时变电阻(由温度梯度更新的辐射项)......

function [Tc, Ts] = stateSpaceModel(time, Tf, P, Ta)
coder.extrinsic('get_param')
coder.extrinsic('eval')

%States
persistent X_Tc; 
persistent X_Ts;

%Last call time
persistent lastTime;

%Physical values
%Radiative resistances in K^4/W (constant)
persistent Rsr;
persistent Rcr;
persistent Rar;
%Convective resistances in K/W (constant)
persistent Rsc;
persistent Rcc;
%Capacitances in J/K (constant)
persistent Cc;
persistent Cs;

%State space matrices (constant)
persistent C;
persistent D;

%Initial conditions
if isempty(X_Tc) 
    lastTime = double(0);

    %Retrieve the physical values
    Rsr = 0;
    Rsr = eval(get_param('PAC_control_sim/BB', 'Rshieldr'));
    Rcr = 0;
    Rcr = eval(get_param('PAC_control_sim/BB', 'Rcavityr'));
    Rar = 0;
    Rar = eval(get_param('PAC_control_sim/BB', 'Rambient'));
    Rcc = 0;
    Rcc = eval(get_param('PAC_control_sim/BB', 'Rcavity'));
    Rsc = 0;
    Rsc = eval(get_param('PAC_control_sim/BB', 'Rshield'));
    Cc = 0;
    Cc = eval(get_param('PAC_control_sim/BB', 'Ccavity'));
    Cs= 0;
    Cs = eval(get_param('PAC_control_sim/BB', 'Cshield'));

    %Initial state vector
    X_Tc = [0; 0;0; 0; 0; 0];
    X_Ts = X_Tc;

    %Build the constant matrices
    C = [1 0 1 0 1 0];
    D = [0 0 0];
end

%Build the input vector
U = [Tf;
     P;
     Ta];

%Calculate output & Ts (used for linearising thermal resistances)
Tc = C*X_Tc+D*U;
Ts = C*X_Ts+D*U;

%Update the thermal resistances (linearising radiative terms)
%Calculating parallel resistance with convective
%Rs = Rsc*Rsr/(Rsr+Rsc*abs(Tf-Ts)^3);
%Ditto for Rc
%Rc = Rcc*Rcr/(Rcr+Rcc*abs(Tc-Ts)^3);
%And Ra
%Ra = Rar/(abs(Ta-Tc)^3);
%Let's replace them instead by constants
Ra=Rar;
Rs=Rsc;
Rc=Rcc;

%Set the differential equations coeffs
alpha1=Rs*Cs*Rc*Cc;
alpha3s=Ra*Cc*Rc*Cs;
beta1=Rs*Cs*(Rc/Ra+1)+Cc*(Rs+Rc);
beta3s=Ra*Cc*(Rc/Rs+1)+Cs*(Ra+Rc);
gamma1=(Rs+Ra+Rc)/Ra;
gamma3s=(Ra+Rs+Rc)/Rs;
delta1=1;
delta3s=1;
alpha2=alpha1;
beta2=beta1;
gamma2=gamma1;
delta2=Rs;
alpha3=Ra*Cs*Cc*Rc;
alpha2s=Rs*Cc*Cs*Rc;
beta3=Ra*(Cc*(1+Rc/Rs)+Cs*(Rc/Ra+1));
beta2s=Rs*(Cs*(1+Rc/Ra)+Cc*(Rc/Rs+1));
gamma3=Ra/Rs*(Rc/Ra+1)+1;
gamma2s=Rs/Ra*(Rc/Rs+1)+1;
delta3=1+Rc/Rs;
delta2s=(1+Rc/Ra)*Rs;
alpha1s=alpha2s;
beta1s=beta2s;
gamma1s=gamma2s;
delta1s=delta2s/Rs;

%Build the time varying matrices
A_Tc=[0                  1                  0                  0                  0                  0;
     -gamma1/alpha1     -beta1/alpha1      0                  0                  0                  0;
     0                  0                  0                  1                  0                  0;
     0                  0                  -gamma2/alpha2     -beta2/alpha2      0                  0;
     0                  0                  0                  0                  0                  1;
     0                  0                  0                  0                  -gamma3/alpha3     -beta3/alpha3];

A_Ts=[0                  1                  0                  0                  0                  0;
     -gamma1s/alpha1s   -beta1s/alpha1s    0                  0                  0                  0;
     0                  0                  0                  1                  0                  0;
     0                  0                  -gamma2s/alpha2s   -beta2s/alpha2s    0                  0;
     0                  0                  0                  0                  0                  1;
     0                  0                  0                  0                  -gamma3s/alpha3s   -beta3s/alpha3s];

B_Tc=[0             0                   0;
     delta1/alpha1  0                   0;
     0              0                   0;
     0              delta2/alpha2       0;
     0              0                   0;
     0              0                   delta3/alpha3];

B_Ts=[0             0                   0;
     delta1s/alpha1s 0                  0;
     0              0                   0;
     0              delta2s/alpha2s     0;
     0              0                   0;
     0              0                   delta3s/alpha3s];

%If last time exists
if ~isnan(lastTime)
    %Calculate change of state
    X_Tcdot = A_Tc*X_Tc+B_Tc*U;
    X_Tsdot = A_Ts*X_Ts+B_Ts*U;
    %Update internal state
    X_Tc = X_Tc+X_Tcdot*double(time-lastTime);
    X_Ts = X_Ts+X_Tsdot*(time-lastTime);
end

%Update last time
lastTime = time;

0 个答案:

没有答案