LoginSignup
0
0

Julia/ControlSystemsによるグラフ作成

Last updated at Posted at 2023-10-14

環境

Julia 1.8.5
VScode 1.83.0
 Jupyter Notebook Renderers 1.0.17

初期設定

パッケージ読込み
using Plots
using ControlSystems
初回読込み時
using Pkg
Pkg.add("Plots")
Pkg.add("ControlSystems")
伝達関数
G = tf([1,0.1], [1, 0,0])
JupyterNotebook出力
TransferFunction{Continuous, ControlSystemsBase.SisoRational{Float64}}
1.0s + 0.1
----------
  1.0s^2
Continuous-time transfer function model

周波数応答

ボード線図

ノーマルのボード線図は以下。

ボード線図
setPlotScale("dB") # log10とするとY軸が10^aの形で表される
ws = exp10.(range(-3,stop=3,length=200)) # X軸を10^(-3)~10^3の範囲で200点分計算する
bodeplot(G,ws,legend=false,linecolor = [:red :blue],title=["Bode plot" ""])
plot!(xticks=10.0.^(-3:3), xlims=(10^(-3), 10^3))
plot!(yticks=-100:20:100, ylims=(-100,100), subplot=1)
plot!(yticks=-195:15:75, ylims=(-210,-75), subplot=2)

Bodeplot1.png

安定余有を追記してくれているのが、以下。

ボード線図 安定余有の記載あり
setPlotScale("dB")
marginplot(G)

Marginplot1.png

需要があるのか分からないが、ゲイン線図のみを図示する関数。これをここでは、Sigma Plotと言っているらしい。

ボード線図 ゲイン線図のみ
setPlotScale("dB")
sigmaplot(G,legend=false)

Sigmaplot1.png

ナイキスト線図

ナイキスト線図
nyquistplot(G,legend=false,unit_circle=true,Ms_circles=1.2, Mt_circles=1.2) # Msは感度関数に対応するレベル、Mtは相補関数に関するレベルらしい
plot!(xticks=-4:0.5:4, xlims=(-4,0))
plot!(yticks=-4:0.5:4, ylims=(-2,2))

Nyquistplot1.png

ニコルス線図

以下がよく分かっていない。
・閉ループ伝達関数にゲインや位相の情報をテキストで追加しようとすると、図が正しく表示されない。
・閉ループ伝達関数の線の消し方が分からない。

ニコルス線図
setPlotScale("dB")
ws = exp10.(range(-3,stop=3,length=200))
nicholsplot(G,ws, Gains=[40,20,0,-20,-40,-60],pInc = 45)
plot!(xticks=-195:15:75, xlims=(-210,-75))
plot!(yticks=-100:20:100, ylims=(-100,40))

Nicholsplot1.png

Gang-of-Four Plot

Gang-of-Fourは四人組という意味らしい。Gang-of-Four Plotという名称は一般的ではないはず。

Gang-of-Four Plot
setPlotScale("log10")
P = tf([1],[200,0,0])
C = tf([200, 20],[1])
gangoffourplot(P, C) # プラント、コントローラの順番
plot!(legend=false, subplot=1)
plot!(legend=false, subplot=2)
plot!(legend=false, subplot=3)
plot!(legend=false, subplot=4)

・左上:感度関数S
・左下:相補感度関数の一部 C/(1+PC)
・右上:相補感度関数の一部 P/(1+PC)
・右下:相補感度関数T=閉ループ伝達関数
Gangoffourplot1.png

時間応答

インパルス応答

インパルス応答
Gc = feedback(G)
y, t, x = impulse(Gc)
plot(t, x', xlabel="Time [s]", legend=true) # 位置と速度

Impulse1.png

ステップ応答

ステップ応答
res = step(Gc) # Simulate 20 seconds step response
plot(res)

Step1.png

ステップ応答の評価指標出力
si = stepinfo(res)
JupyterNotebook出力
StepInfo:
Initial value:     0.000
Final value:       1.017
Step size:         1.017
Peak:              1.070
Peak time:         5.358 s
Overshoot:          5.13 %
Undershoot:         0.00 %
Settling time:    12.032 s
Rise time:         1.786 s
ステップ応答 評価指標あり
plot(si)

Stepinfo1.png

任意入力に対する応答

LSIM関数は、LTIシステムのSimulationの意図かと思われる。

任意入力に対する応答
t=range(0,10,length=100); # 時間(横)軸
u=zeros(1,100);	# 入力信号生成
u[50:100].=1.0;	# 5秒後に0から1へ
y,T,x=lsim(Gc,u,t);	# step応答

size(y)
plot(T,y',legend = true)
plot!(T,u')

lsim.png

その他

根軌跡

極零プロット
pzmap(G,legend=true)

PoleZero1.png

根軌跡
using ControlSystemsBase
rlocusplot(Gc)

rlocusplot.png

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0