I have the following affine state space model
In[]:=
EqnsAffine={
′
vdc
[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],
′
ic
[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],
′
vcf
[t]444444.44444444444`ic[t]-444444.44444444444`is[t],
′
is
[t]-82.85714285714286`is[t]+2857.1428571428573`vcf[t]-2857.1428571428573`vs[t],
′
p
[t]100πq[t],
′
q
[t]-100πp[t]};
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[]=
vdc[t]
0.+ic[t](-1.13558p[t]+22.6926q[t])
ic[t](-907.539p[t]-45.4148q[t])
ic[t](22.7116p[t]-453.853q[t])
0
909.091
ic[t]
0.-32.6471ic[t]-294.118vcf[t]+0.367393p[t]vdc[t]-7.34174q[t]vdc[t]
293.615p[t]vdc[t]+14.693q[t]vdc[t]
-7.34786p[t]vdc[t]+146.835q[t]vdc[t]
0
0
vcf[t]
444444.ic[t]-444444.is[t]
0
0
0
0
is[t]
0.-82.8571is[t]+2857.14vcf[t]
0
0
-2857.14
0
p[t]
100πq[t]
0
0
0
0
q[t]
-100πp[t]
0
0
0
0
vdc[t]
0
0
0
0
ic[t]
0
0
0
0
vcf[t]
0
0
0
0
is[t]
0
0
0
0
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[]=
0.1
0.2
0.3
0.4
0.5
420
440
460
480
500
520
540
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
In[]:=
dt=1/50/1000;​​DTAffineSS=ToDiscreteTimeModel[AffineSS,dt]
Out[]=
vdck.
1
50000
0.+ick.-1.13558pk.+22.6926qk.+vdck.
1
50000
ick.-907.539pk.-45.4148qk.
1
50000
ick.22.7116pk.-453.853qk.
0
0.0181818
ick.
ick.+
1
50000
0.-32.6471ick.-294.118vcfk.+0.367393pk.vdck.-7.34174qk.vdck.
1
50000
293.615pk.vdck.+14.693qk.vdck.
1
50000
-7.34786pk.vdck.+146.835qk.vdck.
0
0
vcfk.
444444.ick.-444444.isk.
50000
+vcfk.
0
0
0
0
isk.
isk.+
1
50000
0.-82.8571isk.+2857.14vcfk.
0
0
-0.0571429
0
pk.
pk.+
1
500
πqk.
0
0
0
0
qk.
-
1
500
πpk.+qk.
0
0
0
0
vdck.
0
0
0
0
ick.
0
0
0
0
vcfk.
0
0
0
0
isk.
0
0
0
0
1
50000
Everything looking good!
Let us simulate
np=35;​​u1=Table0.5,k.,0,np;​​u2=Table0.5,k.,0,np;​​u3=Table230Sin2π50k.dt,k.,0,np;​​u4=Table1,k.,0,np;​​SimuDT=OutputResponse[{DTAffineSS,{400,0,0,0,0,1}},{u1,u2,u3,u4}];​​ListPlot[SimuDT[[1,All]]]
Out[]=
$Aborted
Out[]=
5
10
15
20
25
399.4
399.5
399.6
399.7
399.8
399.9
400.0
400.1
In[]:=
SimuDT//Dimensions
Out[]=
{4,21}
In[]:=
ListPlot[SimuDT[[2,All]]]
Out[]=
5
10
15
20
25
5
10
15
20