Power Systems Electromagnetic Transients Simulation

Appendix F: MATLAB Code Examples

F.1 Voltage Step on RL Branch

In this example a voltage step (produced by a switch closed on to a d.c. voltage source) is applied to an RL load. The results are shown in section 4.4.2. The RL load is modelled by one difference equation rather than each component separately.

% EMT_StepRL.mclear all% Initialize VariablesR = 1.00000;L = 0.05E-3;Tau= L/R;       % load Time-constantDelt = 250.0E-6; % Time-stepFinish_Time = 4.0E-3;V_mag= 100.0;V_ang= 0.0;l=1;i(1)   = 0.0;time(1)= 0.0;V(1)   = 0.0;K_i = (1-Delt*R/(2.0*L))/(1+Delt*R/(2.0*L));K_v = (Delt/(2.0*L))/(1+Delt*R/(2.0*L));G_eff= K_v;% Main Time-step loopfor k=Delt:Delt:Finish_Timel=l+1;time(l) =k;if time(l)>=0.001v(l) = 100.0;<a name="1264"></a><a name="IDX-374"></a>elsev(l)=0.0;end;I_history = K_i*i(l-1) + K_v*v(l-1);I_inst = v(l)*G_eff;i(l) = I_inst+I_history;end;% Plot resultsfigure(1)plot(time,v,'-k',time,i,':k');legend('Voltage','Current');xlabel('Time (Seconds)');

F.2 Diode Fed RL Branch

This simple demonstration program is used to show the numerical oscillation that occurs at turn-off by modelling an RL load fed from an a.c. source through a diode. The results are shown in section 9.4. The RL load is modelled by one difference equation rather than each component separately.

% Diode fed RL load% A small demonstration program to demonstrate numerical noise%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%clear allf =50.0;               % Source FrequencyFinish_Time = 60.0E-3;R= 100.0;L= 500.0E-3;Tau= L/R;              % Load time-constantDelt = 50.0E-6;        % Time-stepV_mag= 230.0*sqrt(2.); % Peak source magnitudeV_ang= 0.0;R_ON = l.OE-10; % Diode ON ResistanceR_OFF= 1.0E10; ...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Frequency-to-Current Converters
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.