I have the following affine state space model
In[]:=
EqnsAffine={[t]909.0909090909092`i0[t]-1.135578817864623`ic[t]p[t]+22.692646888513092`ic[t]q[t]-907.5386932783704`ic[t]p[t]S[t]-45.414786628553756`ic[t]q[t]S[t]+22.711576357285594`ic[t]p[t]ϕ[t]-453.8529377702641`ic[t]q[t]ϕ[t],[t]-32.64705882352941`ic[t]-294.11764705882354`vcf[t]+0.36739314695620146`p[t]vdc[t]-7.341738699224823`q[t]vdc[t]+293.61545959006094`p[t]S[t]vdc[t]+14.693019203355625`q[t]S[t]vdc[t]-7.347862939121809`p[t]vdc[t]ϕ[t]+146.8347739844972`q[t]vdc[t]ϕ[t],[t]444444.44444444444`ic[t]-444444.44444444444`is[t],[t]-82.85714285714286`is[t]+2857.1428571428573`vcf[t]-2857.1428571428573`vs[t],[t]100πq[t],[t]-100πp[t]};
′
vdc
′
ic
′
vcf
′
is
′
p
′
q
that I put into the AffineStateSpaceModel
In[]:=
AffineSS=AffineStateSpaceModel[EqnsAffine,{vdc[t],ic[t],vcf[t],is[t],p[t],q[t]},{S[t],ϕ[t],vs[t],i0[t]},{vdc[t],ic[t],vcf[t],is[t]},t]
Out[]=
|
a simulation with nonzero initial conditions and given inputs is
In[]:=
SimuAffine=OutputResponse[{AffineSS,{400,0,0,0,0,1}},{0.5,0,230Sin[2π50t],1},{t,0,0.5}];Plot[SimuAffine[[1]],{t,0,0.5}]
Out[]=
The response of the system is as expected.
To take advantage of the new predictive control functions of Mathematica I should discretize de system (right?), which I do
To take advantage of the new predictive control functions of Mathematica I should discretize de system (right?), which I do
In[]:=
dt=1/50/1000;DTAffineSS=ToDiscreteTimeModel[AffineSS,dt]
Out[]=
1 50000 |
Everything looking good!
Let us simulate
Let us simulate
np=35;u1=Table0.5,k.,0,np;u2=Table0.5,k.,0,np;u3=Table230Sin2π50k.dt,k.,0,np;u4=Table1,k.,0,np;SimuDT=OutputResponse[{DTAffineSS,{400,0,0,0,0,1}},{u1,u2,u3,u4}];ListPlot[SimuDT[[1,All]]]
Out[]=
$Aborted
Out[]=
In[]:=
SimuDT//Dimensions
Out[]=
{4,21}
In[]:=
ListPlot[SimuDT[[2,All]]]
Out[]=