This example script shows how you can linearize a Simscape™ Electrical™ model to support control system stability analysis and design. It uses example model ee_sm_governor_control_design.
The Synchronous Machine in this example operates as a generator. The machine is initialized to start in periodic steady state to supply a load of 250 MW/15 Mvar.
An alternative and recommended way to linearize Simulink® and Simscape models is to use Simulink Control Design™. Simulink Control Design linearizes your model at operating points you specify. It also returns a state-space model object with state names. If you have Simulink Control Design, open the model ee_sm_governor_control_design. On the Apps tab, under Control Systems, click Model Linearizer. In the Linear Analysis Tool, on the Linear Analysis tab, in the Setup section, select Operating Point > Linearize At. Set the simulation snapshot time to 4 seconds, then click OK. In the Linearize section, click Bode.
Open the model.
open_system('ee_sm_governor_control_design') set_param(find_system('ee_sm_governor_control_design','FindAll', 'on','type','annotation','Tag','ModelFeatures'),'Interpreter','off')
Trim the model by running closed-loop and selecting the state at 4 seconds when generator is in steady-state.
assignin('base','ClosedLoop',1); % Close the speed-control feedback loop [t,x,y] = sim('ee_sm_governor_control_design'); idx = find(t>4,1); X = x(idx,:); U = y(idx);
Open the speed-control feedback loop, linearize the model, and close the speed-control feedback loop.
assignin('base','ClosedLoop',0); % Open the speed-control feedback loop [a,b,c,d]=linmod('ee_sm_governor_control_design',X,U); assignin('base','ClosedLoop',1); % Close the speed-control feedback loop
Plot the Bode diagram.
c = -c; d = -d; % Negative feedback convention npts = 100; w = logspace(-3,5,npts); G = zeros(1,npts); for i=1:npts G(i) = c*(1i*w(i)*eye(size(a))-a)^-1*b +d; end figure ax1 = subplot(2,1,1); semilogx(w,20*log10(abs(G))) grid on ylabel('Magnitude (dB)') title('Bode diagram: speed-control feedback loop') ax2 = subplot(2,1,2); semilogx(w,180/pi*unwrap(angle(G))) ylabel('Phase (degrees)') xlabel('Frequency (rad/s)') linkaxes([ax1,ax2],'x') xlim(w([1 end])) grid on