• No se han encontrado resultados

3.3 Evaluación del desempeño profesional de los docentes 1 Desempeño

3.3.6 Modelos de evaluación del desempeño docente

148

149

References

Anshika R., (2019). ‘’ Components of Power Systemectrical Engineering (withDiagrams) Slip Ring Manufactures.

Abdelsalem, Elhaffar A. M., (2008), ‘Power Transmission Line Fault Location Based on Current Traveling Waves’, Espoo 2008, Helsinki University of Technology, Faculty of Electronics, Communications and Automation, ISBN 978-951-22-924-5

Abdelsalem M. A., 2008. Multi – End Travelling Wave Fault Location Based on Current Traveling Wave’. 16 PSCC, Glasgow, Scotland, July 14 – 18, 2008.

Ashrafian A., Rostani M., Gharehpetian G. B., Gholamphasemi M., 2012. ‘Application of Discrete S – Transform for Differential Protection of Power Transformer’.

International Journal of Computer and Electrical Engineering, Vol. 4, No 2, April 2012.

Bashier E. and Tayeb M., (2016), ‘Faults Detection in Power Systems Using Artificial Neural.

Bowan Y., Fangyu L., Jin Y., and Wenzhan S., ‘Conditions Monitoring and Fault Diagnosis of Generators in Power Networks’, University of Georgia Atlanta, Georgia USA. 2019. NSF – 1725636, NSF – CNS – 1066391.

Capolino G. A., Henao H. Assaf T. ‘Discrete Fourier Transform for Computation of Symmetrical Components Harmonics’. 2003 IEEE Bologna, Italy.

Chengzong P., Mladenk, Zhang N., 2010. ‘Wavelet Based Method for Transmission Line Fault Detection and Classification During Power Swing’, Texas A & M University College Station, TX77843, USA, WERC 323, MS 3128.

150

Faruqul A. M. D., Salman S., Hamid A., 2014. ‘Short Circuit Current Calculation and Prevention in High Voltage Power Networks’. Blekinge TekniskaHogskola 371799, Karlskrona Sweden.

Francisco M. G. L., ‘Power System Protection’. DOI:10,13140/RG.2.2.31364.27523.

https://www.researchgate.net/publication/339460150.

Francisco M. G. L., ‘Introduction to Power Systems’, University of South – Eastern Norway. DOI:10.13140/RG:2.25941.99043

Gupta J. B., (2004), ‘A course in Electrical Power System Engineering’, S. K. Kataria&

Sons New Delhi, India.

Henao H., Assaf T. and Capolino G. A., 2003. ‘The discrete Fourier transform for computation of symmetrical components harmonics’, Fellow, IEEE.

Jensen C. F., 2014, ‘Faults on Transmission line Cables and Current Fault Location Methods’, 001: 10, 1007/978 – 3 - 319 – 05398 – 1_2, SpringerInternational Publishing Switzerland, 2014. – Hill Publishing Company Limited New Delhi, India, ISBN 0-07-462299-4.

Klingerman N., Energy D., Finney D., Samineni S., Fischer N., and Haas D., (2011),

‘Understanding Generator Stator Ground, Faults and Their Protection Schemes’, Schweitzer Engineering Laboratories, Inc.

Karl Z., David C., ‘Impedance Based Fault Location experience’. Journal of Reliable Power.Vol. 1.Number 1. July, 2010.

Kumararaja A., Nazeer S., Srinivas V. and Bhanu C. Y., ‘Fault Detection, Classification and Location on Transmission Lines Using Fundamental Phasor Base Approach’.

151

International Journal of Recent Technology and Engineering (IJRTE). ISSN:2277 – 3878. Vol.8, Issue 3, June 2019.

Maher R. C., (2003), ‘Introduction to Fast Fourier Transform (FFT) Algorithms’. DSP Laboratory Spring, 2003.

Mamis M. S., Arkan M., (2011), ‘FFT Based Fault Location Algorithm for Transmission Lines’

Mohammad A. B., 2013. ‘Travelling Waves for Finding the Fault Location on Transmission Line’. Journal of Electrical and Electronics Engineering, 2013, (1): 1 – 19.

Müslüm A. 2010. ‘FFT Based Fault Location Algorithm for Transmission Lines’Inonu University, Engineering Faculty, Electrical & Electronics Eng. Dept., Malatya, Turkey, [email protected], [email protected]

Murthy P. S. R., ‘Power System Analysis’, B. S. Publication, 4 – 4 – 309, Giriraj Lane, Sultan Bazar, Hyderabad – 500095AP. www.bspublication.net.

Personal E., García A., Parejo A., Larios D. F., Biscarri F. and León C., (2015), ‘A Comparison of Impedance-Based Fault Location Methods for Power Underground Distribution Systems’, Department of Electronic Technology, University of Seville, 41011 Seville, Spain. International Journal of Advanced Research in Electrical, Electronics and Instrumentation Engineering, (An ISO 3297: 2007 Certified Organization), Vol. 2, Issue 12, December 2013.

Prasad C. D. and Paresh K. N., ‘A DFT – ED Based Approach for Detection and Classification of Faults in Electric Power Transmission Network’. Ain Shams Engineering Journal. Vol 10, Issue 1, March 2019, pp. 171 – 178.

152

Rao M. and Hasabe R. P. (2013), ‘Detection and classification of faults on transmission line using wavelet transform and neural network’, Walchand College of Engineering, Sangi. ISSN: 2278 – 8948, Volume – 2, Issue – 5, 2013.

Reddy B. R., 2009, ‘Detection and Location of Faults on Transmission Line Using Coiflet Mother Wavelet Transform’, Journal of Theoretical and Applied Information Technology. 2005 – 2009. www.jatit.org .

Robi P., 2013. ‘Tutorial on Signal Analysis Method of Fault Study’

Roshni U. &Niranjan V., Prakash C. &Rao R. S., (2012), ‘Location of Faults In Transmission Line Using Fast Fourier Transform and Discrete Wavelet Transform In Power Systems’, Undergraduate Academic Research Journal (UARJ), ISSN:

2278 – 1129, Volume-1, Issue-1, 2012.

Sai R., Marutheswar G.V., ‘Classification of Power Quality Disturbance Using Wavelet Transform and S – Transform Based Artificial Neural Network.’ International Journal of Advanced Research in Electrical Electronics and Instrumentation Engineering ISO 3297: 2007 Certified Organization. Vol. 2, Issue 12, December, 2013.

Saadat H., (2006), ‘Power System Analysis’, Tata McGraw – Hill PublishingCompany Limited New Delhi, India.

Sadiku M. N. O., Alexander C. K., ‘Fundamentals of Electric Circuits’, McGraw – Hill Company. Inc., New York City, NY, 10020.

153

Saurabh J. and Abdul G. S., ‘Transmission Line Fault Detection and Classification using Alienation Coefficient Technique for Current Signal’. DOI:

10.1109/12CT.2018.8529447.

Shih M. H., ‘Power System Basic Concepts and Application’, PDH Centre 5272 Meadow Estates Drive, Fairfax, VA22030 – 6658. www.PDHCentres.com.

Tharaja B. L. and Tharaja A. K., 2001, Electrical Technology’, Tata McGraw – HillPublishing Company Limited New Delhi, India.

Turan G.’ Modern Power System Analysis’.John Wiley and Sons Inc. publishing. TK 1001. G66. 1987. ISBN 0 - 471 – 85903 – www.dieselserviceandsupply.com

Wadhwa C. L., (2010). ‘’Electical Power Systems’’ Tata McGraw – Hill Publishing Company Limited New Delhi, India.

Williams P. D., 2012.‘Analysis of Faults in Overhead Transmission Lines’. Department of Electrical and Electronics Engineering, California State University, Sacramento, 2012.

Zimmerman K. and Costello D., (2010), ‘Impedance-Based Fault Location Experience’,Schweitzer Engineering Laboratories, Inc. SEL Journal of Reliable Power, Volume 1, Number 1, July 2010.

154

Matlab/Simulink R2017a Codes for DFT and FFT fault detection on the 330kV 96Km Onitsha - Enugu transmission line

Appendix I

% MATLAB CODES FOR FAULT DETECTION ON A 33OKV POWER SYSTEM TRANSMISSION LINE

% USING DISCRETE FOURIER TRANSFORM (DFT) AND FAST FOURIER TRANSFORM (FFT)

% Parameters for the fault detection are the three phase voltage and

% current (Va, Vb, Vc, and Ia, Ib, Ic)respectively.

% Vp is called the discrete three phase voltage while Ip is called the

% discrete three phase current.

f = 50; % Line frequency t = 1;

theta = [45 50 55 60]; % Phase difference N = [0 1 2 3];

wt = 2*pi*f*t;

Va = 0.4; % Normal Steady State Vb = 0.45; % Normal Steady State Vc = 0.49; % Normal Steady State Ia = 0.22; % Normal Steady State Ib = 0.14; % Normal Steady State Ic = 0.149; % Normal Steady State Ns = 4; % Number of points V_average = (Va+Vb+Vc)/3;

I_average = (Ia+Ib+Ic)/3;

Zrs = V_average/I_average;

% To discretize three phase parameters;

Vp = ((2/3)*(Va+(Vb*(exp((1j)*2*pi/Ns)))+(Vc*(exp((-1j)*2*pi/Ns)))));

Ip = ((2/3)*(Ia+(Ib*(exp((1j)*2*pi/Ns)))+(Ic*(exp((-1j)*2*pi/Ns)))));

n = Ns - 1;

vt = ((Vp)*(sin(wt)+theta));

it = ((Ip)*(sin(wt)+theta));

% To compute the DFT of Pre-fault vt and it;

% Vn is the DFT of vt;

% In is the DFT of it;

% Vn is given as sum of the product of vt and (exp((-j)*2*pi)/N);

% In is given as sum of the product of it and (exp((-j)*2*pi)/N);

155

% Computation of DFT of vt at No fault and on load conditions;

Vn = vt.*exp(-1j*2*pi*n/Ns);

In = it.*exp(-1j*2*pi*n/Ns);

Vn_mag = abs(Vn);

In_mag = abs(In);

Zn = Vn./In;

Zn_mag = abs(Zn);

fault_result = Zn_mag < Zrs;

figure(1);

bar(Zn_mag);

title('DFT Three Phase Prefault Impedance') figure(2);

bar(Vn_mag);

title('DFT Three Phase Prefault voltage') figure(3)

bar(In_mag);

title('DFT Three Phase Prefault current')

Wk = [1 -1j -1 1j];

Vk = [0 0 0 0];

Vk(1) = (vt(1) + vt(3)*Wk(1)) + Wk(1)*(vt(2) + vt(4)*Wk(1));

Vk(2) = (vt(1) + vt(3)*Wk(3)) + Wk(2)*(vt(2) + vt(4)*Wk(3));

Vk(3) = (vt(1) + vt(3)*Wk(1)) + Wk(3)*(vt(2) + vt(4)*Wk(1));

Vk(4) = (vt(1) + vt(3)*Wk(3)) + Wk(4)*(vt(2) + vt(4)*Wk(3));

Ik = [0 0 0 0];

Ik(1) = (it(1) + it(3)*Wk(1)) + Wk(1)*(it(2) + it(4)*Wk(1));

Ik(2) = (it(1) + it(3)*Wk(3)) + Wk(2)*(it(2) + it(4)*Wk(3));

Ik(3) = (it(1) + it(3)*Wk(1)) + Wk(3)*(it(2) + it(4)*Wk(1));

Ik(4) = (it(1) + it(3)*Wk(3)) + Wk(4)*(it(2) + it(4)*Wk(3));

Zk = Vk./Ik;

Zk_mag = abs(Zk);

Vk_mag = abs(Vk);

156

Ik_mag = abs(Ik);

fault_result_fft = Zk_mag < Zrs;

figure(4);

bar(Zk_mag);

title('FFT Three Phase Prefault Impedance') figure(5);

bar(Vk_mag);

title('FFT Three Phase Prefault voltage') figure(6)

bar(Ik_mag);

title('FFT Three Phase Prefault current')

MATLAB CODES BARCHART RESULT FOR THREE PHASE PRE -FAULT COMPUTATION USING DFT

157

Figure 1: DFT three pre-fault current is 8.9pu maximum at N = 4 or 3 for (N = 0 1 2 3).

Figure 2: DFT three pre-fault voltage is 16pu maximum at N = 4 or 3 for (N = 0 1 2 3).

158

Figure 3: DFT three pre – fault impedance is equal at all points of N = 1.8pu, (N = 0 1 2 3).

159

Matlab Codes Barchart Result for Three Phase Pre-Fault Computation Using DFT

Figure 6: FFT three pre-fault current is 32pu maximum at N = 1 or 0 for (N = 0 1 2 3).

160

Figure 4: FFT three pre-fault Voltage is 57pu maximum at N = 1 or 0 for (N = 0 1 2 3).

161

Figure 5: FFT three pre – fault impedance is equal at all points of N, (N = 0 1 2 3).

162

MATLAB CODES BARCHART RESULT FOR THREE PHASE FAULT COMPUTATION USING DFT

Figure 6: DFT three phase fault current is 76pu maximum at N = 4 or 3 for (N = 0 1 2 3).

163

Figure 7: DFT three phase fault voltage is 6pu maximum at N = 4 or 3 for (N = 0 1 2 3).

Figure 8: DFT three phase fault impedance is equal at all points of N = 0.08pu, (N = 0 1 2 3).

164

MATLAB CODES BARCHART RESULT FOR THREE PHASE FAULT COMPUTATION USING FFT

Figure 9: FFT three pre-fault Voltage is 270pu maximum at N = 1 or 0 for (N = 0 1 2 3).

165

Figure 10: FFT three phase fault Voltage is 23pu maximum at N = 1 or 0 for (N = 0 1 2 3).

166

Figure 11: FFT three phase fault impedance is equal at all points of N = 0.08pu, (N = 0 1 2 3).

167

Appendix II

Matlab/Simulink Codes for the Developed DFT and FFT Model for Fault Detection on the Power System Transmission Line

File:

ert_main.c 3 *

4 * Code generated for Simulink model

'NEWPDFDEVELOPMENTDESERTATIONamusingnow'.

5 *

6 * Model version : 1.21

7 * Simulink Coder version : 8.12 (R2017a) 15-Nov-2019 8 * C/C++ source code generated on : Fri 15 03:12:04 2019 9 *

10 * Target selection: ert.tlc

11 * Embedded hardware selection: Intel->x86-64 (Windows64) 12 * Code generation objectives:

13 * 1. Execution efficiency 14 * 2. RAM efficiency

15 * Validation result: Not run 16 */

17

18 #include <stddef.h>

19 #include <stdio.h>/* This ert_main.c example uses printf/fflush */

20 #include "NEWPDFDEVELOPMENTDESERTATIONamusingnow.h"/*

Model's header file */

21 #include "rtwtypes.h"

22 23 /*

24 * Associating rt_OneStep with a real-time clock or interrupt service routine 25 * is what makes the generated code "real-time". The function rt_OneStep is 26 * always associated with the base rate of the model. Subrates are managed 27 * by the base rate from inside the generated code. Enabling/disabling 28 * interrupts and floating point context switches are target specific. This 29 * example code indicates where these should take place relative to executing 30 * the generated code step function. Overrun behavior should be tailored to 31 * your application needs. This example simply sets an error status in the 32 * real-time model and returns from rt_OneStep.

168 33 */

34 void rt_OneStep(void);

35 void rt_OneStep(void) 36 {

37 static boolean_T OverrunFlag = false;

38

39 /* Disable interrupts here */

40

41 /* Check for overrun */

42 if (OverrunFlag) {

43 rtmSetErrorStatus(rtM, "Overrun");

44 return;

45 } 46

47 OverrunFlag = true;

48

49 /* Save FPU context here (if necessary) */

50 /* Re-enable timer or interrupt here */

51 /* Set model inputs here */

52

53 /* Step the model for base rate */

54 NEWPDFDEVELOPMENTDESERTATIONamusingnow_step();

55

56 /* Get model outputs here */

57

58 /* Indicate task complete */

59 OverrunFlag = false;

60

61 /* Disable interrupts here */

62 /* Restore FPU context here (if necessary) */

63 /* Enable interrupts here */

64 } 65 66 /*

67 * The example "main" function illustrates what is required by your

68 * application code to initialize, execute, and terminate the generated code.

69 * Attaching rt_OneStep to a real-time clock is target specific. This example 70 * illustrates how you do this relative to initializing the model.

169 71 */

72 int_T main(int_T argc, constchar *argv[]) 73 {

74 /* Unused arguments */

75 (void)(argc);

76 (void)(argv);

77

78 /* Initialize model */

79 NEWPDFDEVELOPMENTDESERTATIONamusingnow_initialize();

80

81 /* Attach rt_OneStep to a timer or interrupt service routine with 82 * period 5.0E-5 seconds (the model's base sample time) here. The 83 * call syntax for rt_OneStep is

84 *

85 * rt_OneStep();

86 */

87 printf("Warning: The simulation will run forever. "

88 "Generated ERT main won't simulate model step behavior. "

89 "To change this behavior select the 'MAT-file logging' option.\n");

90 fflush((NULL));

91 while (rtmGetErrorStatus(rtM) == (NULL)) { 92 /* Perform other application tasks here */

93 } 94

95 /* Disable rt_OneStep() here */

96 return 0;

97 } 98 99 /*

100 * File trailer for generated code.

101 *

102 * [EOF]

103 */

104

WORKING MATLAB CODES

File: NEWPDFDEVELOPMENTDESERTATIONamusingnow.c

170 1 /*

2 * File: NEWPDFDEVELOPMENTDESERTATIONamusingnow.c 3 *

4 * Code generated for Simulink model

'NEWPDFDEVELOPMENTDESERTATIONamusingnow'.

5 *

6 * Model version : 1.21

7 * Simulink Coder version : 8.12 (R2017a) 16-Feb-2017

8 * C/C++ source code generated on : Sat Nov 16 03:12:04 2019 9 *

10 * Target selection: ert.tlc

11 * Embedded hardware selection: Intel->x86-64 (Windows64) 12 * Code generation objectives:

13 * 1. Execution efficiency 14 * 2. RAM efficiency

15 * Validation result: Not run 16 */

17

18 #include "NEWPDFDEVELOPMENTDESERTATIONamusingnow.h"

19 #include <math.h>

20 #include <stdlib.h>

21 #define NumBitsPerChar 8U 22

23 /* Private macros used by the generated code to access rtModel */

24 #ifndef rtmIsMajorTimeStep

25 # define rtmIsMajorTimeStep(rtm) (((rtm)->Timing.simTimeStep) ==

MAJOR_TIME_STEP) 26 #endif

27

28 #ifndef rtmIsMinorTimeStep

29 # define rtmIsMinorTimeStep(rtm) (((rtm)->Timing.simTimeStep) ==

MINOR_TIME_STEP) 30 #endif

31

32 #ifndef rtmGetTPtr

33 # define rtmGetTPtr(rtm) ((rtm)->Timing.t) 34 #endif

35

36 #ifndef rtmSetTPtr

171

37 # define rtmSetTPtr(rtm, val) ((rtm)->Timing.t = (val)) 38 #endif

39

40 #ifndef CodeFormat

41 #define CodeFormat S-Function 42 #else

43 #undef CodeFormat

44 #define CodeFormat S-Function 45 #endif

46

47 #ifndef S_FUNCTION_NAME

48 #define S_FUNCTION_NAME simulink_only_sfcn 49 #else

50 #undef S_FUNCTION_NAME

51 #define S_FUNCTION_NAME simulink_only_sfcn 52 #endif

53

54 #ifndef S_FUNCTION_LEVEL 55 #define S_FUNCTION_LEVEL 2 56 #else

57 #undef S_FUNCTION_LEVEL 58 #define S_FUNCTION_LEVEL 2 59 #endif

60

61 #ifndef RTW_GENERATED_S_FUNCTION 62 #define RTW_GENERATED_S_FUNCTION 63 #endif

64

65 #ifndef rtmGetDataMapInfo

66 # define rtmGetDataMapInfo(rtm) NULL 67 #endif

68

69 #ifndef rtmSetDataMapInfo

70 # define rtmSetDataMapInfo(rtm, val) 71 #endif

72

73 #if !defined(RTW_SFUNCTION_DEFINES) 74 #define RTW_SFUNCTION_DEFINES

172 75 #ifndef _RTW_COMMON_DEFINES_

76 #define _RTW_COMMON_DEFINES_

77 #endif 78 #endif 79

80 /* Block signals and states (auto storage) */

81 DW rtDW;

82

83 /* External outputs (root outports fed by signals with auto storage) */

84 ExtY rtY;

85

86 /* Real-time model */

87 RT_MODEL rtM_;

88 RT_MODEL *const rtM = &rtM_;

89 extern real_T rt_hypotd_snf(real_T u0, real_T u1);

90 extern real_T rtGetInf(void);

91 extern real32_T rtGetInfF(void);

92 extern real_T rtGetMinusInf(void);

93 extern real32_T rtGetMinusInfF(void);

94

95 /*===========*

96 * Constants *

97 *===========*/

98 #define RT_PI 3.14159265358979323846 99 #define RT_PIF 3.1415927F

100 #define RT_LN_10 2.30258509299404568402 101 #define RT_LN_10F 2.3025851F

102 #define RT_LOG10E 0.43429448190325182765 103 #define RT_LOG10EF 0.43429449F

104 #define RT_E 2.7182818284590452354 105 #define RT_EF 2.7182817F

106 107 /*

108 * UNUSED_PARAMETER(x)

109 * Used to specify that a function parameter (argument) is required but not 110 * accessed by the function body.

111 */

112 #ifndef UNUSED_PARAMETER

173 113 # if defined(__LCC__)

114 # define UNUSED_PARAMETER(x) /* do nothing */

115 # else 116

117 /*

118 * This is the semi-ANSI standard way of indicating that an 119 * unused function parameter is required.

120 */

121 # define UNUSED_PARAMETER(x) (void) (x) 122 # endif

123 #endif 124

125 #ifndef INTERP

126 # define INTERP(x,x1,x2,y1,y2) ( (y1)+(((y2) - (y1))/((x2) - (x1)))*((x)-(x1)) ) 127 #endif

128

129 #ifndef ZEROTECHNIQUE 130 #define ZEROTECHNIQUE 131

132 typedefenum{

133 NORMAL_INTERP, 134 AVERAGE_VALUE, 135 MIDDLE_VALUE 136 } ZeroTechnique;

137

138 #endif 139

140 extern int_T rt_GetLookupIndex(const real_T *x, int_T xlen, real_T u) ;

141 extern real_T rt_Lookup(const real_T *x, int_T xlen, real_T u, const real_T *y);

142 extern real_T rtInf;

143 extern real_T rtMinusInf;

144 extern real_T rtNaN;

145 extern real32_T rtInfF;

146 extern real32_T rtMinusInfF;

147 extern real32_T rtNaNF;

148 externvoid rt_InitInfAndNaN(size_t realSize);

149 extern boolean_T rtIsInf(real_T value);

150 extern boolean_T rtIsInfF(real32_T value);

174 151 extern boolean_T rtIsNaN(real_T value);

152 extern boolean_T rtIsNaNF(real32_T value);

153 typedefstruct{

154 struct{

155 uint32_T wordH;

156 uint32_T wordL;

157 } words;

158 } BigEndianIEEEDouble;

159

160 typedefstruct{

161 struct{

162 uint32_T wordL;

163 uint32_T wordH;

164 } words;

165 } LittleEndianIEEEDouble;

166

167 typedefstruct{

168 union{

169 real32_T wordLreal;

170 uint32_T wordLuint;

171 } wordL;

172 } IEEESingle;

173

174 real_T rtInf;

175 real_T rtMinusInf;

176 real_T rtNaN;

177 real32_T rtInfF;

178 real32_T rtMinusInfF;

179 real32_T rtNaNF;

180 extern real_T rtGetNaN(void);

181 extern real32_T rtGetNaNF(void);

182 183 /*

184 * Initialize rtInf needed by the generated code.

185 * Inf is initialized as non-signaling. Assumes IEEE.

186 */

187 real_T rtGetInf(void) 188 {

175

189 size_t bitsPerReal = sizeof(real_T) * (NumBitsPerChar);

190 real_T inf = 0.0;

191 if (bitsPerReal == 32U) { 192 inf = rtGetInfF();

193 }else{

194 union{

195 LittleEndianIEEEDouble bitVal;

196 real_T fltVal;

197 } tmpVal;

198

199 tmpVal.bitVal.words.wordH = 0x7FF00000U;

200 tmpVal.bitVal.words.wordL = 0x00000000U;

201 inf = tmpVal.fltVal;

202 } 203

204 return inf;

205 } 206 207 /*

208 * Initialize rtInfF needed by the generated code.

209 * Inf is initialized as non-signaling. Assumes IEEE.

210 */

211 real32_T rtGetInfF(void) 212 {

213 IEEESingle infF;

214 infF.wordL.wordLuint = 0x7F800000U;

215 return infF.wordL.wordLreal;

216 } 217 218 /*

219 * Initialize rtMinusInf needed by the generated code.

220 * Inf is initialized as non-signaling. Assumes IEEE.

221 */

222 real_T rtGetMinusInf(void) 223 {

224 size_t bitsPerReal = sizeof(real_T) * (NumBitsPerChar);

225 real_T minf = 0.0;

226 if (bitsPerReal == 32U) {

176 227 minf = rtGetMinusInfF();

228 }else{

229 union{

230 LittleEndianIEEEDouble bitVal;

231 real_T fltVal;

232 } tmpVal;

233

234 tmpVal.bitVal.words.wordH = 0xFFF00000U;

235 tmpVal.bitVal.words.wordL = 0x00000000U;

236 minf = tmpVal.fltVal;

237 } 238

239 return minf;

240 } 241 242 /*

243 * Initialize rtMinusInfF needed by the generated code.

244 * Inf is initialized as non-signaling. Assumes IEEE.

245 */

246 real32_T rtGetMinusInfF(void) 247 {

248 IEEESingle minfF;

249 minfF.wordL.wordLuint = 0xFF800000U;

250 return minfF.wordL.wordLreal;

251 } 252 253 /*

254 * Routine to get the index of the input from a table using binary or 255 * interpolation search.

256 *

257 * Inputs:

258 * *x : Pointer to table, x[0] ....x[xlen-1]

259 * xlen : Number of values in xtable 260 * u : input value to look up

261 *

262 * Output:

263 * idx : the index into the table such that:

264 * if u is negative

177 265 * x[idx] <= u < x[idx+1]

266 * else

267 * x[idx] < u <= x[idx+1]

268 *

269 * Interpolation Search: If the table contains a large number of nearly 270 * uniformly spaced entries, i.e., x[n] vs n is linear then the index 271 * corresponding to the input can be found in one shot using the linear 272 * interpolation formula. Therefore if you have a look-up table block with 273 * many data points, using interpolation search might speed up the code.

274 * Compile the generated code with the following flag:

275 *

276 * make_rtw OPTS=-DDOINTERPSEARCH 277 *

278 * to enable interpolation search.

279 */

280 int_T rt_GetLookupIndex(const real_T *x, int_T xlen, real_T u) 281 {

282 int_T idx = 0;

283 int_T bottom = 0;

284 int_T top = xlen-1;

285 int_T retValue = 0;

286 boolean_T returnStatus = 0U;

287

288 #ifdef DOINTERPSEARCH 289

290 real_T offset = 0;

291

292 #endif 293

294 /*

295 * Deal with the extreme cases first:

296 * if u <= x[bottom] then return idx = bottom 297 * if u >= x[top] then return idx = top-1 298 */

299 if (u <= x[bottom]) { 300 retValue = bottom;

301 returnStatus = 1U;

302 }elseif (u >= x[top]) {

178 303 retValue = top-1;

304 returnStatus = 1U;

305 }else{

306 /* else required to ensure safe programming, even * 307 * if it's expected that it will never be reached */

308 } 309

310 if (returnStatus == 0U) { 311 if (u < 0) {

312 /* For negative input find index such that: x[idx] <= u < x[idx+1] */

313 for (;;) { 314

315 #ifdef DOINTERPSEARCH 316

317 offset = (u-x[bottom])/(x[top]-x[bottom]);

318 idx = bottom + (int_T)((top-bottom)*(offset-DBL_EPSILON));

319 320 #else 321

322 idx = (bottom + top)/2;

323

324 #endif 325

326 if (u < x[idx]) { 327 top = idx - 1;

328 }elseif (u >= x[idx+1]) { 329 bottom = idx + 1;

330 }else{

331 /* we have x[idx] <= u < x[idx+1], return idx */

332 retValue = idx;

333 break;

334 } 335 } 336 }else{

337 /* For non-negative input find index such that: x[idx] < u <= x[idx+1] */

338 for (;;) { 339

340 #ifdef DOINTERPSEARCH

179 341

342 offset = (u-x[bottom])/(x[top]-x[bottom]);

343 idx = bottom + (int_T)((top-bottom)*(offset-DBL_EPSILON));

344 345 #else 346

347 idx = (bottom + top)/2;

348

349 #endif 350

351 if (u <= x[idx]) { 352 top = idx - 1;

353 }elseif (u > x[idx+1]) { 354 bottom = idx + 1;

355 }else{

356 /* we have x[idx] < u <= x[idx+1], return idx */

357 retValue = idx;

358 break;

359 } 360 } 361 } 362 } 363

364 return retValue;

365 } 366

367 /* 1D lookup routine for data type of real_T. */

368 real_T rt_Lookup(const real_T *x, int_T xlen, real_T u, const real_T *y) 369 {

370 int_T idx = rt_GetLookupIndex(x, xlen, u);

371 real_T num = y[idx+1] - y[idx];

372 real_T den = x[idx+1] - x[idx];

373

374 /* Due to the way the binary search is implemented 375 in rt_look.c (rt_GetLookupIndex), den cannot be 376 0. Equivalently, m cannot be inf or nan. */

377 real_T m = num/den;

378 return (y[idx] + (m * (u - x[idx])));

180 379 }

380 381 /*

382 * Initialize the rtInf, rtMinusInf, and rtNaN needed by the

383 * generated code. NaN is initialized as non-signaling. Assumes IEEE.

384 */

385 void rt_InitInfAndNaN(size_t realSize) 386 {

387 (void) (realSize);

388 rtNaN = rtGetNaN();

389 rtNaNF = rtGetNaNF();

390 rtInf = rtGetInf();

391 rtInfF = rtGetInfF();

392 rtMinusInf = rtGetMinusInf();

393 rtMinusInfF = rtGetMinusInfF();

394 } 395

396 /* Test if value is infinite */

397 boolean_T rtIsInf(real_T value) 398 {

399 return (boolean_T)((value==rtInf || value==rtMinusInf) ? 1U : 0U);

400 } 401

402 /* Test if single-precision value is infinite */

403 boolean_T rtIsInfF(real32_T value) 404 {

405 return (boolean_T)(((value)==rtInfF || (value)==rtMinusInfF) ? 1U : 0U);

406 } 407

408 /* Test if value is not a number */

409 boolean_T rtIsNaN(real_T value) 410 {

411 return (boolean_T)((value!=value) ? 1U : 0U);

412 } 413

414 /* Test if single-precision value is not a number */

415 boolean_T rtIsNaNF(real32_T value) 416 {

181 417 return (boolean_T)(((value!=value) ? 1U : 0U));

418 } 419 420 /*

421 * Initialize rtNaN needed by the generated code.

422 * NaN is initialized as non-signaling. Assumes IEEE.

423 */

424 real_T rtGetNaN(void) 425 {

426 size_t bitsPerReal = sizeof(real_T) * (NumBitsPerChar);

427 real_T nan = 0.0;

428 if (bitsPerReal == 32U) { 429 nan = rtGetNaNF();

430 }else{

431 union{

432 LittleEndianIEEEDouble bitVal;

433 real_T fltVal;

434 } tmpVal;

435

436 tmpVal.bitVal.words.wordH = 0xFFF80000U;

437 tmpVal.bitVal.words.wordL = 0x00000000U;

438 nan = tmpVal.fltVal;

439 } 440

441 return nan;

442 } 443 444 /*

445 * Initialize rtNaNF needed by the generated code.

446 * NaN is initialized as non-signaling. Assumes IEEE.

447 */

448 real32_T rtGetNaNF(void) 449 {

450 IEEESingle nanF = {{ 0 }};

451

452 nanF.wordL.wordLuint = 0xFFC00000U;

453 return nanF.wordL.wordLreal;

454 }

182 455

456 real_T rt_hypotd_snf(real_T u0, real_T u1) 457 {

458 real_T y;

459 real_T a;

460 a = fabs(u0);

461 y = fabs(u1);

462 if (a < y) { 463 a /= y;

464 y *= sqrt(a * a + 1.0);

465 }elseif (a > y) { 466 y /= a;

467 y = sqrt(y * y + 1.0) * a;

468 }else{

469 if (!rtIsNaN(y)) {

470 y = a * 1.4142135623730951;

471 } 472 } 473

474 return y;

475 } 476

477 /* Model step function */

478 void NEWPDFDEVELOPMENTDESERTATIONamusingnow_step(void) 479 {

480 {

481 real_T rtb_Gain23;

482 real_T rtb_Gain26_g;

483 real_T rtb_Product5;

484 real_T rtb_Gain25;

485 real_T rtb_Product6;

486 real_T rtb_Product4_a;

487 real_T rtb_Product;

488 real_T rtb_LookUpTable;

489 real_T rtb_Kv1_idx_0;

490 real_T rtb_Kv1_idx_1;

491 real_T rtb_Kv1_idx_2;

492 real_T rtb_Kv_idx_0;

183 493 real_T rtb_Kv_idx_1;

494 real_T rtb_Kv_idx_2;

495 real_T rtb_Sum5_re;

496 real_T rtb_Sum5_im;

497 real_T rtb_Sum11_re;

498 real_T rtb_Sum11_im;

499 real_T rtb_Sum19_re;

500 real_T rtb_Sum19_im;

501

502 /* Sin: '<S75>/Sine Wave A' */

503 if (rtDW.systemEnable != 0) {

504 rtDW.lastSin = sin(314.15926535897933 * ((rtM->Timing.clockTick1) * 5.0E-5));

505 rtDW.lastCos = cos(314.15926535897933 * ((rtM->Timing.clockTick1) * 5.0E-5));

506 rtDW.systemEnable = 0;

507 } 508

509 rtDW.SineWaveA = ((rtDW.lastSin * 0.71812629776318893 + rtDW.lastCos * 510 0.69591279659231431) * 0.99987663248166059 +

511 (rtDW.lastCos * 0.71812629776318893 - rtDW.lastSin * 512 0.69591279659231431) * 0.015707317311820675) * 513 393388.05269097845;

514

515 /* End of Sin: '<S75>/Sine Wave A' */

516

517 /* Sin: '<S75>/Sine Wave B' */

518 if (rtDW.systemEnable_p != 0) {

519 rtDW.lastSin_b = sin(314.15926535897933 * ((rtM->Timing.clockTick1) * 520 5.0E-5));

521 rtDW.lastCos_h = cos(314.15926535897933 * ((rtM->Timing.clockTick1) * 522 5.0E-5));

523 rtDW.systemEnable_p = 0;

524 } 525

526 rtDW.SineWaveB = ((rtDW.lastSin_b * 0.24361501178602257 + rtDW.lastCos_h * 527 -0.96987201528474676) * 0.99987663248166059 +

528 (rtDW.lastCos_h * 0.24361501178602257 - rtDW.lastSin_b * 529 -0.96987201528474676) * 0.015707317311820675) *

530 393388.05269097845;

184 531

532 /* End of Sin: '<S75>/Sine Wave B' */

533

534 /* Sin: '<S75>/Sine Wave C' */

535 if (rtDW.systemEnable_b != 0) {

536 rtDW.lastSin_e = sin(314.15926535897933 * ((rtM->Timing.clockTick1) * 537 5.0E-5));

538 rtDW.lastCos_p = cos(314.15926535897933 * ((rtM->Timing.clockTick1) * 539 5.0E-5));

540 rtDW.systemEnable_b = 0;

541 } 542

543 rtDW.SineWaveC = ((rtDW.lastSin_e * -0.96174130954921133 + rtDW.lastCos_p * 544 0.27395921869243262) * 0.99987663248166059 +

545 (rtDW.lastCos_p * -0.96174130954921133 - rtDW.lastSin_e * 546 0.27395921869243262) * 0.015707317311820675) *

547 393388.05269097845;

548

549 /* End of Sin: '<S75>/Sine Wave C' */

550

551 /* S-Function (sfun_spssw_discc): '<S76>/State-Space' incorporates:

552 * Constant: '<S78>/SwitchCurrents' 553 */

554

555 /* S-Function block: <S76>/State-Space */

556 {

557 real_T accum;

558

559 /* Circuit has switches */

560 int_T *switch_status = (int_T*) rtDW.StateSpace_PWORK.SWITCH_STATUS;

561 int_T *switch_status_init = (int_T*)

562 rtDW.StateSpace_PWORK.SWITCH_STATUS_INIT;

563 int_T *SwitchChange = (int_T*) rtDW.StateSpace_PWORK.SW_CHG;

564 int_T *gState = (int_T*) rtDW.StateSpace_PWORK.G_STATE;

565 real_T *yswitch = (real_T*)rtDW.StateSpace_PWORK.Y_SWITCH;

566 int_T *switchTypes = (int_T*) rtDW.StateSpace_PWORK.SWITCH_TYPES;

567 int_T *idxOutSw = (int_T*) rtDW.StateSpace_PWORK.IDX_OUT_SW;

568 real_T *DxCol = (real_T*)rtDW.StateSpace_PWORK.DX_COL;

185

569 real_T *tmp2 = (real_T*)rtDW.StateSpace_PWORK.TMP2;

570 real_T *BDcol = (real_T*)rtDW.StateSpace_PWORK.BD_COL;

571 real_T *tmp1 = (real_T*)rtDW.StateSpace_PWORK.TMP1;

572 real_T *uswlast = (real_T*)rtDW.StateSpace_PWORK.USWLAST;

573 int_T newState;

574 int_T swChanged = 0;

575 int loopsToDo = 20;

576 real_T temp;

577

578 /* keep an initial copy of switch_status*/

579 memcpy(switch_status_init, switch_status, 9 * sizeof(int_T));

580 memcpy(uswlast, &rtDW.StateSpace_o1[0], 9*sizeof(real_T));

581 do{

582 if (loopsToDo == 1) {/* Need to reset some variables: */

583 swChanged = 0;

584

585 /* return to the original switch status*/

586 {

587 int_T i1;

588 for (i1=0; i1 < 9; i1++) {

589 swChanged = ((SwitchChange[i1] = switch_status_init[i1] - 590 switch_status[i1]) != 0) ? 1 : swChanged;

591 switch_status[i1] = switch_status_init[i1];

592 } 593 } 594 }else{

595 /*

596 * Compute outputs:

597 * --- 598 */

599 real_T *Cs = (real_T*)rtDW.StateSpace_PWORK.CS;

600 real_T *Ds = (real_T*)rtDW.StateSpace_PWORK.DS;

601 602 {

603 int_T i1;

604 real_T *y0 = &rtDW.StateSpace_o1[0];

605 for (i1=0; i1 < 21; i1++) { 606 accum = 0.0;

186 607

608 {

609 int_T i2;

610 real_T *xd = &rtDW.StateSpace_DSTATE[0];

611 for (i2=0; i2 < 20; i2++) { 612 accum += *(Cs++) * xd[i2];

613 } 614 } 615 616 {

617 int_T i2;

618 const real_T *u0 = rtConstP.SwitchCurrents_Value;

619 for (i2=0; i2 < 9; i2++) { 620 accum += *(Ds++) * u0[i2];

621 } 622

623 accum += *(Ds++) * rtDW.SineWaveA;

624 accum += *(Ds++) * rtDW.SineWaveB;

625 accum += *(Ds++) * rtDW.SineWaveC;

626 } 627

628 y0[i1] = accum;

629 } 630 } 631

632 swChanged = 0;

633 634 {

635 int_T i1;

636 real_T *y0 = &rtDW.StateSpace_o1[0];

637 for (i1=0; i1 < 9; i1++) {

638 newState = (gState[i1] > 0) ? 1 : ((y0[i1]*uswlast[i1] < 0.0) ? 0 : 639 switch_status[i1]);

640 swChanged = ((SwitchChange[i1] = newState - switch_status[i1]) !=

641 0) ? 1 : swChanged;

642 switch_status[i1] = newState;/* Keep new state */

643 } 644 }

187 645 }

646 647 /*

648 * Compute new As, Bs, Cs and Ds matrixes:

649 * --- 650 */

651 if (swChanged) {

652 real_T *As = (real_T*)rtDW.StateSpace_PWORK.AS;

653 real_T *Cs = (real_T*)rtDW.StateSpace_PWORK.CS;

654 real_T *Bs = (real_T*)rtDW.StateSpace_PWORK.BS;

655 real_T *Ds = (real_T*)rtDW.StateSpace_PWORK.DS;

656 real_T a1;

657 658 {

659 int_T i1;

660 for (i1=0; i1 < 9; i1++) { 661 if (SwitchChange[i1] != 0) { 662 a1 = 1000.0*SwitchChange[i1];

663 temp = 1/(1-Ds[i1*13]*a1);

664 665 {

666 int_T i2;

667 for (i2=0; i2 < 21; i2++) {

668 DxCol[i2]= Ds[i2 * 12 + i1]*temp*a1;

669 } 670 } 671

672 DxCol[i1] = temp;

673 674 {

675 int_T i2;

676 for (i2=0; i2 < 20; i2++) { 677 BDcol[i2]= Bs[i2 * 12 + i1]*a1;

678 } 679 } 680

681 /* Copy row nSw of Cs into tmp1 and zero it out in Cs */

682 memcpy(tmp1, &Cs[i1 * 20], 20 * sizeof(real_T));

188 683 memset(&Cs[i1 * 20], '\0', 20 * sizeof(real_T));

684

685 /* Copy row nSw of Ds into tmp2 and zero it out in Ds */

686 memcpy(tmp2, &Ds[i1 * 12], 12 * sizeof(real_T));

687 memset(&Ds[i1 * 12], '\0', 12 * sizeof(real_T));

688

689 /* Cs = Cs + DxCol * tmp1, Ds = Ds + DxCol * tmp2 *******************/

690 {

691 int_T i2;

692 for (i2=0; i2 < 21; i2++) { 693 a1 = DxCol[i2];

694 695 {

696 int_T i3;

697 for (i3=0; i3 < 20; i3++) {

698 Cs[i2 * 20 + i3] += a1 * tmp1[i3];

699 } 700 } 701 702 {

703 int_T i3;

704 for (i3=0; i3 < 12; i3++) {

705 Ds[i2 * 12 + i3] += a1 * tmp2[i3];

706 } 707 } 708 } 709 } 710

711 /* As = As + BdCol*Cs(nSw,:), Bs = Bs + BdCol*Ds(nSw,:) *************/

712 {

713 int_T i2;

714 for (i2=0; i2 < 20; i2++) { 715 a1 = BDcol[i2];

716 717 {

718 int_T i3;

719 for (i3=0; i3 < 20; i3++) {

720 As[i2 * 20 + i3] += a1 * Cs[i1 * 20 + i3];

189 721 }

722 } 723 724 {

725 int_T i3;

726 for (i3=0; i3 < 12; i3++) {

727 Bs[i2 * 12 + i3] += a1 * Ds[i1 * 12 + i3];

728 } 729 } 730 } 731 } 732 } 733 } 734 }

735 }/* if (swChanged) */

736 }while (swChanged > 0 && --loopsToDo > 0);

737

738 if (loopsToDo == 0) {

739 real_T *Cs = (real_T*)rtDW.StateSpace_PWORK.CS;

740 real_T *Ds = (real_T*)rtDW.StateSpace_PWORK.DS;

741 742 {

743 int_T i1;

744 real_T *y0 = &rtDW.StateSpace_o1[0];

745 for (i1=0; i1 < 21; i1++) { 746 accum = 0.0;

747 748 {

749 int_T i2;

750 real_T *xd = &rtDW.StateSpace_DSTATE[0];

751 for (i2=0; i2 < 20; i2++) { 752 accum += *(Cs++) * xd[i2];

753 } 754 } 755 756 {

757 int_T i2;

758 const real_T *u0 = rtConstP.SwitchCurrents_Value;

190 759 for (i2=0; i2 < 9; i2++) {

760 accum += *(Ds++) * u0[i2];

761 } 762

763 accum += *(Ds++) * rtDW.SineWaveA;

764 accum += *(Ds++) * rtDW.SineWaveB;

765 accum += *(Ds++) * rtDW.SineWaveC;

766 } 767

768 y0[i1] = accum;

769 } 770 } 771 } 772

773 /* Output new switches states */

774 {

775 int_T i1;

776 real_T *y1 = &rtDW.StateSpace_o2[0];

777 for (i1=0; i1 < 9; i1++) {

778 y1[i1] = (real_T)switch_status[i1];

779 } 780 } 781 } 782

783 /* Gain: '<S3>/Kv1' */

784 rtb_Kv1_idx_0 = 3.7113480951260267E-6 * rtDW.StateSpace_o1[9];

785

786 /* Gain: '<S3>/Kv' */

787 rtb_Kv_idx_0 = 0.00447729929721086 * rtDW.StateSpace_o1[15];

788

789 /* Gain: '<S3>/Kv1' */

790 rtb_Kv1_idx_1 = 3.7113480951260267E-6 * rtDW.StateSpace_o1[10];

791

792 /* Gain: '<S3>/Kv' */

793 rtb_Kv_idx_1 = 0.00447729929721086 * rtDW.StateSpace_o1[16];

794

795 /* Gain: '<S3>/Kv1' */

796 rtb_Kv1_idx_2 = 3.7113480951260267E-6 * rtDW.StateSpace_o1[11];

191 797

798 /* Gain: '<S3>/Kv' */

799 rtb_Kv_idx_2 = 0.00447729929721086 * rtDW.StateSpace_o1[17];

800

801 /* Gain: '<S1>/Gain53' incorporates:

802 * Gain: '<S1>/Gain4' 803 * Product: '<S1>/Product1' 804 * Product: '<S1>/Product4' 805 * Sum: '<S1>/Add2'

806 */

807 rtb_Gain23 = ((rtb_Kv1_idx_0 + rtb_Kv1_idx_1) + rtb_Kv1_idx_2) * 0.667 * 808 1.0E+15;

809

810 /* Product: '<S1>/Product14' */

811 rtb_Gain26_g = rtb_Gain23 * 0.85090352453411844;

812

813 /* Product: '<S1>/Product15' */

814 rtb_Product5 = rtb_Gain23 * -0.22286052796839617;

815

816 /* Product: '<S1>/Product16' */

817 rtb_Gain25 = rtb_Gain23 * -0.43451132285096439;

818

819 /* Product: '<S1>/Product17' */

820 rtb_Gain23 *= -0.62430649351725087;

821

822 /* Sum: '<S1>/Sum2' incorporates:

823 * Sum: '<S1>/Sum' 824 * Sum: '<S1>/Sum1' 825 */

826 rtb_Product6 = (rtb_Gain26_g + rtb_Product5) + (rtb_Gain25 + rtb_Gain23);

827

828 /* Outport: '<Root>/Out19' */

829 rtY.Out19 = rtb_Product6;

830

831 /* Sum: '<S1>/Sum5' incorporates:

832 * Gain: '<S1>/Gain18' 833 * Gain: '<S1>/Gain19' 834 * Gain: '<S1>/Gain20'

Documento similar