test_class_electrical_equipment.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 import unittest
5 import math
6 import rosunit
7 from phm_hazard_rate_calculation.class_electrical_equipment import ElectricalEquipment
8 
9 PKG = 'phm_hazard_rate_calculation'
10 NAME = 'test_class_electrical_equipment'
11 
12 
13 class TestElectricalEquipment(unittest.TestCase):
15 
16 # QUARTZ CRYSTALS FORMULAS - START-
17 
19  self.e_eq.qrtz_lambda_b_func(5)
20  result = self.e_eq.get_qrtz_lambda_b()
21  test_result = 0.018823763306560406
22  # result = float(0.013 * pow(5, 0.23))
23 
24  self.assertAlmostEqual(result, test_result, 5)
25 
26 # QUARTZ CRYSTALS FORMULAS - END-
27 
28 # CONNECTORS, SOCKETS FORMULAS - START -
29 
31  self.e_eq.con_sock_pi_p_func(5)
32  result = self.e_eq.get_con_sock_pi_p()
33  test_result = 2.012796909336014
34  # result = math.exp(pow(((5-1) / 10), 0.39))
35 
36  self.assertAlmostEqual(result, test_result, 5)
37 
38 # CONNECTORS, SOCKETS FORMULAS - END -
39 
40 # CONNECTORS, GENERAL FORMULAS - START -
41 
43  self.e_eq.con_gen_pi_t_func(35)
44  result = self.e_eq.get_con_gen_pi_t()
45  test_result = 1.1936465129494536
46  # result = float(math.exp((-0.14 / (8.617 * (pow(10, -5)))) * ((1 / (35 + 273)) - (1 / 298))))
47 
48  self.assertAlmostEqual(result, test_result, 5)
49 
50 # CONNECTORS, GENERAL FORMULAS - END -
51 
52 # RELAYS FORMULAS - START -
53 
55  self.e_eq.rel_lambda_b_func(35, 85)
56  result = self.e_eq.get_rel_lambda_b()
57  test_result = 0.007502108907236194
58  # result = float(0.0059 * float(math.exp((-0.19 / (8.617 * pow(10, -5))) * ((1 / (35 + 273)) - (1 / 298)))))
59 
60  self.assertAlmostEqual(result, test_result, 5)
61 
62 
64  self.e_eq.rel_lambda_b_func(35, 125)
65  result = self.e_eq.get_rel_lambda_b()
66  test_result = 0.007314777440225106
67  # result = float(0.0059 * float(math.exp((-0.17 / (8.617 * pow(10, -5))) * ((1 / (35 + 273)) - (1 / 298)))))
68 
69  self.assertAlmostEqual(result, test_result, 5)
70 
71 
73  self.e_eq.rel_pi_l_func(10, 1)
74  result = self.e_eq.get_rel_pi_l()
75  test_result = 157.25
76  # result = float(pow((10 / 0.8), 2) + 1)
77 
78  self.assertAlmostEqual(result, test_result, 2)
79 
80 
82  self.e_eq.rel_pi_l_func(10, 2)
83  result = self.e_eq.get_rel_pi_l()
84  test_result = 626.00
85  # result = float(pow((10 / 0.4), 2) + 1)
86 
87  self.assertAlmostEqual(result, test_result, 2)
88 
89 
91  self.e_eq.rel_pi_l_func(10, 3)
92  result = self.e_eq.get_rel_pi_l()
93  test_result = 2501.0
94  # result = float(pow((10 / 0.2), 2) + 1)
95 
96  self.assertAlmostEqual(result, test_result, 2)
97 
98 
100  self.e_eq.rel_pi_cyc_func(10, 0)
101  result = self.e_eq.get_rel_pi_cyc()
102  test_result = 1.0
103 
104  self.assertAlmostEqual(result, test_result, 2)
105 
106 
108  self.e_eq.rel_pi_cyc_func(0.1, 0)
109  result = self.e_eq.get_rel_pi_cyc()
110  test_result = 0.1
111 
112  self.assertAlmostEqual(result, test_result, 2)
113 
114 
116  self.e_eq.rel_pi_cyc_func(1500, 1)
117  result = self.e_eq.get_rel_pi_cyc()
118  test_result = 225.0
119  # result = float(pow(1500/100, 2))
120 
121  self.assertAlmostEqual(result, test_result, 2)
122 
123 
125  self.e_eq.rel_pi_cyc_func(150, 1)
126  result = self.e_eq.get_rel_pi_cyc()
127  test_result = 15.0
128  # result = float(150/10)
129 
130  self.assertAlmostEqual(result, test_result, 2)
131 
132 
134  self.e_eq.rel_pi_cyc_func(5, 1)
135  result = self.e_eq.get_rel_pi_cyc()
136  test_result = 1.0
137 
138  self.assertAlmostEqual(result, test_result, 2)
139 
140 # RELAYS FORMULAS - END -
141 
142 # ROTATING DEVICES, MOTORS FORMULAS - START -
143 
145  self.e_eq.rd_alpha_b_func(35)
146  result = self.e_eq.get_rd_alpha_b()
147  test_result = 85595.978589058
148  # result = float(pow(float(pow(10, float(2.534 - float(2357 / (35 + 273)))) + (1 / float(pow(10, float(20 - (4500 / float(35 + 273)))) + 300))), -1))
149 
150  self.assertAlmostEqual(result, test_result, 5)
151 
152 
154  self.e_eq.rd_alpha_w_func(35)
155  result = self.e_eq.get_rd_alpha_w()
156  test_result = 664656.7239197979
157  # result = float(pow(10, float(float(2357 / (35 + 273)) - 1.83)))
158 
159  self.assertAlmostEqual(result, test_result, 5)
160 
161 # ROTATING DEVICES, MOTORS FORMULAS - END -
162 
163 # RESISTOR FORMULAS - START -
164 
166  self.e_eq.res_pi_t_func(35, 1)
167  result = self.e_eq.get_res_pi_t()
168  test_result = 1.2877230710513001
169  # result = float(math.exp(((-1 * 0.2) / (8.617 * pow(10, -5))) * ((1 / (35 + 273)) - (1 / 298))))
170 
171  self.assertAlmostEqual(result, test_result, 5)
172 
173 
175  self.e_eq.res_pi_t_func(35, 2)
176  result = self.e_eq.get_res_pi_t()
177  test_result = 1.1064428601975629
178 
179  # result = float(math.exp(((-1 * 0.08) / (8.617 * pow(10, -5))) * ((1 / (35 + 273)) - (1 / 298))))
180 
181  self.assertAlmostEqual(result, test_result, 5)
182 
183 
185  self.e_eq.res_pi_t_func(35, 3)
186  result = self.e_eq.get_res_pi_t()
187  test_result = 1.0
188 
189  self.assertAlmostEqual(result, test_result, 5)
190 
191 
193  result = self.e_eq.calculate_res_pi_t_func(35, 1)
194  test_result = 3.5408895754801635
195 
196  # result = float(math.exp(((-1 * 1) / (8.617 * pow(10, -5))) * ((1 / (35 + 273)) - (1 / 298))))
197 
198  self.assertAlmostEqual(result, test_result, 5)
199 
200 
202  self.e_eq.res_pi_p_func(35)
203  result = self.e_eq.get_res_pi_p()
204  test_result = 4.001165701268361
205 
206  # result = float(pow(35, 0.39))
207 
208  self.assertAlmostEqual(result, test_result, 5)
209 
210 
212  self.e_eq.res_pi_s_func(0.35, 1)
213  result = self.e_eq.get_res_pi_s()
214  test_result = 1.0434261682232124
215 
216  # result = 0.71 * float(math.exp(1.1 * 0.35))
217 
218  self.assertAlmostEqual(result, test_result, 5)
219 
220 
222  self.e_eq.res_pi_s_func(0.35, 2)
223  result = self.e_eq.get_res_pi_s()
224  test_result = 1.1027574993576743
225 
226  # result = 0.54 * float(math.exp(2.04 * 0.35))
227 
228  self.assertAlmostEqual(result, test_result, 5)
229 
230 
232  self.e_eq.res_pi_s_func(0.35, 3)
233  result = self.e_eq.get_res_pi_s()
234  test_result = 1.0
235 
236  self.assertAlmostEqual(result, test_result, 5)
237 
238 
239 # RESISTOR FORMULAS - END -
240 
241 # CAPACITOR FORMULAS - START -
242 
244  self.e_eq.cc_pi_t_func(35, 0)
245  result = self.e_eq.get_cc_pi_t()
246  test_result = 35.0
247 
248  self.assertAlmostEqual(result, test_result, 5)
249 
250 
252  self.e_eq.cc_pi_t_func(35, 1)
253  result = self.e_eq.get_cc_pi_t()
254  test_result = 1.2088345313598179
255 
256  # result = float(math.exp(((-1 * 0.15) / (8.617 * pow(10, -5))) * ((1 / (35 + 273)) - (1 / 298))))
257 
258  self.assertAlmostEqual(result, test_result, 5)
259 
260 
262  self.e_eq.cc_pi_t_func(35, 2)
263  result = self.e_eq.get_cc_pi_t()
264  test_result = 1.5566441151155237
265 
266  # result = float(math.exp(((-1 * 0.35) / (8.617 * pow(10, -5))) * ((1 / (35 + 273)) - (1 / 298))))
267 
268  self.assertAlmostEqual(result, test_result, 5)
269 
270 
272  self.e_eq.cc_pi_t_func(35, 3)
273  result = self.e_eq.get_cc_pi_t()
274  test_result = 1.0
275 
276  self.assertAlmostEqual(result, test_result, 5)
277 
278 
280  result = self.e_eq.calculate_cc_pi_t_func(35, 1)
281  test_result = 3.5408895754801635
282 
283  # result = float(math.exp(((-1 * 1) / (8.617 * pow(10, -5))) * ((1 / (35 + 273)) - (1 / 298))))
284 
285  self.assertAlmostEqual(result, test_result, 5)
286 
287 
289  self.e_eq.cc_pi_c_func(35, 0)
290  result = self.e_eq.get_cc_pi_c()
291  test_result = 35.0
292 
293  self.assertAlmostEqual(result, test_result, 5)
294 
295 
297  self.e_eq.cc_pi_c_func(35, 1)
298  result = self.e_eq.get_cc_pi_c()
299  test_result = 1.3771020474505347
300 
301  # result = float(pow(35, 0.09))
302 
303  self.assertAlmostEqual(result, test_result, 5)
304 
305 
307  self.e_eq.cc_pi_c_func(35, 2)
308  result = self.e_eq.get_cc_pi_c()
309  test_result = 2.265351770958606
310 
311  # result = float(pow(35, 0.23))
312 
313  self.assertAlmostEqual(result, test_result, 5)
314 
315 
317  self.e_eq.cc_pi_c_func(35, 3)
318  result = self.e_eq.get_cc_pi_c()
319  test_result = 1.0
320 
321  self.assertAlmostEqual(result, test_result, 5)
322 
323 
325  self.e_eq.cc_pi_v_func(0.35, 0)
326  result = self.e_eq.get_cc_pi_v()
327  test_result = 0.35
328 
329  self.assertAlmostEqual(result, test_result, 5)
330 
331 
333  self.e_eq.cc_pi_v_func(0.35, 1)
334  result = self.e_eq.get_cc_pi_v()
335  test_result = 1.0675435635288066
336 
337  # result = float(pow((0.35 / 0.6), 5) + 1)
338 
339  self.assertAlmostEqual(result, test_result, 5)
340 
341 
343  self.e_eq.cc_pi_v_func(0.35, 2)
344  result = self.e_eq.get_cc_pi_v()
345  test_result = 1.0045621329741699
346 
347  # result = float(pow((0.35 / 0.6), 10) + 1)
348 
349  self.assertAlmostEqual(result, test_result, 5)
350 
351 
353  self.e_eq.cc_pi_v_func(0.35, 3)
354  result = self.e_eq.get_cc_pi_v()
355  test_result = 1.1984953703703705
356 
357  # result = float(pow((0.35 / 0.6), 3) + 1)
358 
359  self.assertAlmostEqual(result, test_result, 5)
360 
361 
363  self.e_eq.cc_pi_v_func(0.35, 4)
364  result = self.e_eq.get_cc_pi_v()
365  test_result = 1.0001048541194446
366 
367  # result = float(pow((0.35 / 0.6), 17) + 1)
368 
369  self.assertAlmostEqual(result, test_result, 5)
370 
371 
373  self.e_eq.cc_pi_v_func(0.35, 5)
374  result = self.e_eq.get_cc_pi_v()
375  test_result = 1.1984953703703705
376 
377  # result = float(pow((0.35 / 0.6), 3) + 1)
378 
379  self.assertAlmostEqual(result, test_result, 5)
380 
381 
383  self.e_eq.cc_pi_v_func(0.35, 6)
384  result = self.e_eq.get_cc_pi_v()
385  test_result = 1.0
386 
387  self.assertAlmostEqual(result, test_result, 5)
388 
389 
391  self.e_eq.cc_pi_sr_func("None")
392  result = self.e_eq.get_cc_pi_sr()
393  test_result = 1.0
394 
395  self.assertAlmostEqual(result, test_result, 2)
396 
397 
399  self.e_eq.cc_pi_sr_func("cr_g_0_8")
400  result = self.e_eq.get_cc_pi_sr()
401  test_result = 0.66
402 
403  self.assertAlmostEqual(result, test_result, 2)
404 
405 
407  self.e_eq.cc_pi_sr_func("cr_g_0_6_to_0_8")
408  result = self.e_eq.get_cc_pi_sr()
409  test_result = 1.0
410 
411  self.assertAlmostEqual(result, test_result, 2)
412 
413 
415  self.e_eq.cc_pi_sr_func("cr_g_0_4_to_0_6")
416  result = self.e_eq.get_cc_pi_sr()
417  test_result = 1.3
418 
419  self.assertAlmostEqual(result, test_result, 2)
420 
421 
423  self.e_eq.cc_pi_sr_func("cr_g_0_2_to_0_4")
424  result = self.e_eq.get_cc_pi_sr()
425  test_result = 2.0
426 
427  self.assertAlmostEqual(result, test_result, 2)
428 
429 
431  self.e_eq.cc_pi_sr_func("cr_g_0_1_to_0_2")
432  result = self.e_eq.get_cc_pi_sr()
433  test_result = 2.7
434 
435  self.assertAlmostEqual(result, test_result, 2)
436 
437 
439  self.e_eq.cc_pi_sr_func("cr_0_to_0_1")
440  result = self.e_eq.get_cc_pi_sr()
441  test_result = 3.3
442 
443  self.assertAlmostEqual(result, test_result, 2)
444 
445 
447  self.e_eq.cc_pi_sr_func(35)
448  result = self.e_eq.get_cc_pi_sr()
449  test_result = 35.0
450 
451  self.assertAlmostEqual(result, test_result, 2)
452 
453 
454 # CAPACITOR FORMULAS - END -
455 
456 # DIODE FORMULAS - START -
457 
459  self.e_eq.dd_pi_t_func(35, 0)
460  result = self.e_eq.get_dd_pi_t()
461  test_result = 35.0
462 
463  self.assertAlmostEqual(result, test_result, 2)
464 
465 
467  self.e_eq.dd_pi_t_func(35, 1)
468  result = self.e_eq.get_dd_pi_t()
469  test_result = 1.2333469156667014
470 
471  # result = float(math.exp((-1 * 1925) * ((1 / (35 + 273)) - (1 / 298))))
472 
473  self.assertAlmostEqual(result, test_result, 5)
474 
475 
477  self.e_eq.dd_pi_t_func(35, 2)
478  result = self.e_eq.get_dd_pi_t()
479  test_result = 1.4004154404247757
480 
481  # result = float(math.exp((-1 * 3091) * ((1 / (35 + 273)) - (1 / 298))))
482 
483  self.assertAlmostEqual(result, test_result, 5)
484 
485 
487  self.e_eq.dd_pi_t_func(35, 3)
488  result = self.e_eq.get_dd_pi_t()
489  test_result = 1.0
490 
491  self.assertAlmostEqual(result, test_result, 2)
492 
493 
495  result = self.e_eq.calculate_dd_pi_t_func(35, 1925)
496  test_result = 1.2333469156667014
497 
498  # result = float(math.exp((-1 * 1925) * ((1 / (35 + 273)) - (1 / 298))))
499 
500  self.assertAlmostEqual(result, test_result, 5)
501 
502 
504  self.e_eq.dd_pi_s_func(0.25, 1)
505  result = self.e_eq.get_dd_pi_s()
506  test_result = 0.054
507 
508  self.assertAlmostEqual(result, test_result, 3)
509 
510 
512  self.e_eq.dd_pi_s_func(0.35, 1)
513  result = self.e_eq.get_dd_pi_s()
514  test_result = 0.07799833781904994
515 
516  # result = float(pow(0.35, 2.43))
517 
518  self.assertAlmostEqual(result, test_result, 5)
519 
520 
522  self.e_eq.dd_pi_s_func(35, 2)
523  result = self.e_eq.get_dd_pi_s()
524  test_result = 35.0
525 
526  self.assertAlmostEqual(result, test_result, 2)
527 
528 
530  self.e_eq.dd_pi_s_func(35, 3)
531  result = self.e_eq.get_dd_pi_s()
532  test_result = 1.0
533 
534  self.assertAlmostEqual(result, test_result, 2)
535 
536 # DIODE FORMULAS - END -
537 
538 
539 # INDUCTOR FORMULAS - START -
540 
542  self.e_eq.id_pi_t_func(35, 0)
543  result = self.e_eq.get_id_pi_t()
544  test_result = 35.0
545 
546  self.assertAlmostEqual(result, test_result, 2)
547 
548 
550  self.e_eq.id_pi_t_func(35, 1)
551  result = self.e_eq.get_id_pi_t()
552  test_result = 1.1492178478655128
553 
554  # result = float(math.exp(((-1 * 0.11) / (8.617 * pow(10, -5))) * ((1 / (35 + 273)) - (1 / 298))))
555 
556 
557  self.assertAlmostEqual(result, test_result, 5)
558 
559 
561  self.e_eq.id_pi_t_func(35, 2)
562  result = self.e_eq.get_id_pi_t()
563  test_result = 1.0
564 
565  self.assertAlmostEqual(result, test_result, 2)
566 
567 # INDUCTOR FORMULAS - END -
568 
569 # TRANSISTOR FORMULAS - START -
570 
572  self.e_eq.ts_pi_t_func(35, 0)
573  result = self.e_eq.get_ts_pi_t()
574  test_result = 35.0
575 
576  self.assertAlmostEqual(result, test_result, 2)
577 
578 
580  self.e_eq.ts_pi_t_func(35, 1)
581  result = self.e_eq.get_ts_pi_t()
582  test_result = 1.2333469156667014
583 
584  # result = float(math.exp((-1 * 1925) * ((1 / (35 + 273)) - (1 / 298))))
585 
586  self.assertAlmostEqual(result, test_result, 5)
587 
588 
590  self.e_eq.ts_pi_t_func(35, 2)
591  result = self.e_eq.get_ts_pi_t()
592  test_result = 1.0
593 
594  self.assertAlmostEqual(result, test_result, 2)
595 
596 # TRANSISTOR FORMULAS - END -
597 
598 if __name__ == '__main__':
599  rosunit.unitrun(PKG, NAME, TestElectricalEquipment, sysargs = "--cov", coverage_packages=[str(PKG)])
600 


phm_hazard_rate_calculation
Author(s):
autogenerated on Thu Aug 13 2020 16:41:45