summaryrefslogtreecommitdiff
path: root/Principles_of_Power_System/chapter5.ipynb
blob: 195b1538de95ebb62e9e2f4ef7bc66bee0fd088a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
{
 "metadata": {
  "name": "",
  "signature": "sha256:95fdfaa4e5e5dbdce2d60b65f4e1e462efff574f2746529cb62b6b5d733a0dc4"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 5: Tariff"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.1, Page Number: 91"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration:\n",
      "M = 200                          #max demand(kW)\n",
      "LF = 0.4                         #load factor\n",
      "c1 = 100                         #tarif(Rs/kW)\n",
      "c2 = 10                           #tariff(pais/kWh)\n",
      "\n",
      "#Calculation:\n",
      "E = M*LF*8760                    #units consumed/year\n",
      "T = c1*M+E*c2/100                #annual charges(Rs)\n",
      "OC = T/E                          #overall cost(Rs/kWh)\n",
      "\n",
      "#Results:\n",
      "print \"Overall cost per kWh is \",round(OC*100,2),\"paise\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Overall cost per kWh is  12.85 paise\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.2, Page Number: 91"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "\n",
      "#Variable declaration:\n",
      "V = 220                         #voltage(V)\n",
      "I = 20                          #current(A)\n",
      "E = 8760                        #kWh\n",
      "c1 = 20                         #tariff part1(paise/unit for 500hrs)\n",
      "c2 = 10                          #tariff part2 for additional unit(paise/unit)\n",
      "\n",
      "\n",
      "#Calculation:\n",
      "#assuming power factor to be unity.\n",
      "M = V*I/1000                       #max demand(kW)\n",
      "\n",
      "#part (i):\n",
      "E1 = M*500                       #kWh\n",
      "C1 = c1*E1/100                   #Rs\n",
      "E2 = E-E1                      #kWh\n",
      "C2 = 10*E2/100                 #kWh\n",
      "T = C1+C2                       #total annual bill(Rs)\n",
      "T2 = T/E                       #equivalent flat rate(Rs/kWh)\n",
      "\n",
      "#Results:\n",
      "print \"(i) Annual bill is Rs\",T\n",
      "print \"(ii)Eqv flat rate is \",round(T2*100,1),\"paise\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i) Annual bill is Rs 1096.0\n",
        "(ii)Eqv flat rate is  12.5 paise\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.3, Page Number: 92"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from sympy import *\n",
      "\n",
      "#Variable declaration:\n",
      "\n",
      "#for tariff (a):\n",
      "c1 = 100                   #tariff part1(Rs)\n",
      "c11 = 15                   #tariff part2(paise/kWh)\n",
      "\n",
      "#for tariff (b):\n",
      "c2 = 30                   #paise/kWh\n",
      "\n",
      "#Calculation:\n",
      "#Let x be the number of units at which charges \n",
      "#due to both tariffs become equal.\n",
      "\n",
      "x = symbols('x')\n",
      "x1 = solve(c1+c11*x/100 - c2*x/100 , x)[0]\n",
      "\n",
      "#Results:\n",
      "print \"Tariff(a) is economical if consumption is more than\",round(float(x1),2),\"units.\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Tariff(a) is economical if consumption is more than 666.67 units.\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.4, Page Number: 92"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "from sympy import *\n",
      "\n",
      "#Variable declaration:\n",
      "#for 1t tariff:\n",
      "c11 = 30                           #Rs/annum\n",
      "c12 = 3                            #paise/unit\n",
      "\n",
      "#for 2nd tariff:\n",
      "c21 = 6                            #paise/unit for 1st 400 units\n",
      "c22 = 5                            #paise/unit for extra units\n",
      "\n",
      "#Calculation:\n",
      "#Let x (> 400) be the number of units taken per annum \n",
      "#for which the annual charges due to both tariffs become equal.\n",
      "\n",
      "x=symbols('x')\n",
      "T1 = c11+c12*x/100                  #charges due to 1st tariff(Rs)\n",
      "T2 = c21*400/100+c22*(x-400)/100                  #charges due to 2nd tariff(Rs)\n",
      "x1 = solve(T1-T2,x)[0]\n",
      "\n",
      "#Results:\n",
      "print \"Required no. of units are \",round(x1),\"kWh\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Required no. of units are  1300.0 kWh\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.5, Page Number: 92"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration:\n",
      "M = 50                           #max load on the station(MW)\n",
      "AD = 75                          #aggregate demand by consumers(MW)\n",
      "E = 18*10**7                      #units/annum\n",
      "\n",
      "#for annual fixed charges:\n",
      "c11 = 28*10**5                    #for generation(Rs)\n",
      "c12 = 32*10**5                   #for transmission & distribution(Rs)\n",
      "c13 = 90*10**5                   #for fuel(Rs)\n",
      "\n",
      "#for running charges:\n",
      "c21 = 0.9*90*10**5               #fuel cost(Rs)\n",
      "r = 85                           #% of power transmitted\n",
      "\n",
      "\n",
      "#Calculation:\n",
      "T1 = c11+c12+c13*0.1            #10% of fuel used for fixed charges(Rs)\n",
      "C1 = T1/(AD*10**3)                       #Rs/kW\n",
      "\n",
      "\n",
      "E1 = r*E/100                        #units delivered to consumers\n",
      "C2 = c21/E1                     #cost per kWh\n",
      "\n",
      "#Results:\n",
      "print \"Tariff is\",C1 ,\"Rs/kW of maximum demand plus\",round(C2*100,1),\"paise per kWh.\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Tariff is 92.0 Rs/kW of maximum demand plus 5.3 paise per kWh.\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.6, Page Number: 93"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "\n",
      "#Variable declaration:\n",
      "M = 75*10**3                           #Max emand(kW)\n",
      "LF = 0.4                               #load factor\n",
      "\n",
      "c1 = 60                                #1st part of generating cost(Rs/kW)\n",
      "c2 = 4                                 #2nd part of generating cost(paise/kW)\n",
      "\n",
      "CT = 2000000                         #annual capital charges for transmission system(Rs)\n",
      "CD = 1500000                         #annual capital charges for distribution system(Rs)\n",
      "\n",
      "dt = 1.2                             #diversity factor of tr. system\n",
      "dd = 1.25                            #diversity factor of tr. system\n",
      "\n",
      "nt = 0.9                             #efficiency of tr system\n",
      "nd = 0.85                            ##efficiency of distribution system\n",
      "\n",
      "\n",
      "#Calculation:\n",
      "#(i) Cost at substation:\n",
      "#(a)Annual fixed charges:\n",
      "\n",
      "Tafc1 = c1*M+CT                      #total annual fixed cost(Rs)\n",
      "S1 = M*dt                            #sum of all the max demands(kW)\n",
      "AC1 = Tafc1/S1                        #Annual cost per kW of max. demand(Rs)\n",
      "\n",
      "#(b) Running Charges:\n",
      "Cs1 = c2/nt                        #Cost/kWh at substation(paise)\n",
      "\n",
      "#(ii) Cost at consumer\u2019s premises:\n",
      "Tafc2 = Tafc1+CD             #Total annual fixed charges at consumer\u2019s premises(Rs)\n",
      "S2 = S1*dd                   #sum of of maximum demands of all consumers(kW)\n",
      "AC2 = Tafc2/S2                      #Annual cost per kW of maximum demand(Rs)\n",
      "#As the distribution efficiency is 85%, therefore, for each kWh delivered from\n",
      "#substation, only 0\u00b785 kWh reaches the consumer\u2019s premises\n",
      "Cs2 = Cs1/nd                        #Cost/kWh at consumer premises(paise)\n",
      "\n",
      "#Result:\n",
      "print \"(i)At sub-station, the cost is Rs\",round(AC1,2),\"per annum per kW maximum demand \"\n",
      "print \"   plus\",round(Cs1,2),\"paise per kWh\"\n",
      "print \"\\n(ii)At consumer\u2019s premises, the cost is\",round(AC2,2),\"per annum per kW maximum demand\"\n",
      "print \"    plus\",round(Cs2,2),\"paise per kWh.\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i)At sub-station, the cost is Rs 72.22 per annum per kW maximum demand \n",
        "   plus 4.44 paise per kWh\n",
        "\n",
        "(ii)At consumer\u2019s premises, the cost is 71.11 per annum per kW maximum demand\n",
        "    plus 5.23 paise per kWh.\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.7, Page Number: 94"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "from sympy import *\n",
      "\n",
      "#Variable declaration:\n",
      "#     Fixed charges    Running charges       #Station \n",
      "#          (per kW)     (paise/kWh)\n",
      "Cf1 =  300;         Cr1 = 25                 #Diesel \n",
      "Cf2 =  1200;        Cr2 = 6.25               #Steam \n",
      "\n",
      "\n",
      "#Calculation:\n",
      "#Suppose energy supplied in one year is 100 units i.e., 100 kWh.\n",
      "\n",
      "#Diesel Station:\n",
      "L = symbols('L')                   #load factor\n",
      "E = 100                            #kWh(say)\n",
      "P = E/8760                         #avg power, kW\n",
      "M = P/L                             #max deamnd(kW)\n",
      "C1 = Cf1*M+E*Cr1/100             #Fixed and running charges for 100 kWh\n",
      "\n",
      "#Steam station\n",
      "C2 = Cf2*M+E*Cr2/100            #Fixed and running charges for 100 kWh\n",
      "\n",
      "L1 = solve(C1-C2,L)[0]\n",
      "\n",
      "#Result:\n",
      "print \"The load fctor is \",round(L1*100,2),\"%\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The load fctor is  54.79 %\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.8, Page Number: 95"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration:\n",
      "M = 100                           #max demand(kW)\n",
      "LF = 0.6                          #load factor\n",
      "pf = 0.8                          #power factor\n",
      "c1 = 75                           #1st part tariff(Rs/kVA)\n",
      "c2 = 15                           #2nd part tariff(paise/kWh)\n",
      "\n",
      "#Calculation:\n",
      "E = M*LF*8760                    #units consumed/year\n",
      "M1 = M/pf                        #max demand in kVA\n",
      "AB = M1*c1+E*c2/100              #annual bill(Rs)\n",
      "\n",
      "#Result:\n",
      "print \"Annual bill is Rs\",AB"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Annual bill is Rs 88215.0\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.9, Page Number: 95"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration:\n",
      "M = 240                             #max load(kW)\n",
      "pf = 0.8                             #power factor\n",
      "E = 50000                            #annual units consumption(kW)\n",
      "c1 = 50                              #1st part tariff(Rs/KVA)\n",
      "c2 = 10                              #2nd part tariff(paise/unit)\n",
      "\n",
      "#Calculation:\n",
      "M1 = M/pf                          #KVA\n",
      "AB = M1*c1+E*c2/100                 #annual bill(Rs)\n",
      "FR = AB/E                          #Rs\n",
      "\n",
      "#now\n",
      "pf1 = 1\n",
      "M2 = M\n",
      "AB1 = M2*c1+E*c2/100               #Rs\n",
      "S = AB-AB1                         #annual saving(Rs)\n",
      "\n",
      "#Result:\n",
      "print \"Flat rate of energy consumption is \",FR*100,\"paise\"\n",
      "print \"Annual saving is Rs\",S"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Flat rate of energy consumption is  40.0 paise\n",
        "Annual saving is Rs 3000.0\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.10, Page Number: 96"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "#Variable declaration:\n",
      "M = 50                            #max demand(kW)\n",
      "E = 36000                         #energy consume(kWh)\n",
      "R = 23400                         #reactive power(KVAR)\n",
      "c1 = 80                              #1st part tariff(Rs/kW)\n",
      "c2 = 8                              #2nd part tariff(paise/unit)\n",
      "c3 = 0.5               #3rd part tariff(p/kWh)for each 1% of pf below 86%\n",
      "\n",
      "#Calculation:\n",
      "L = E/(24*30)                   #avg load(kW)\n",
      "RP = R/(24*30)                  #avg reactive power(kVAR)\n",
      "\n",
      "theta = math.atan(RP/L)         #power factor angle\n",
      "pf = math.cos(theta)              \n",
      "PFS = E*c3*(0.86-pf)               #power factor surcharge(Rs)\n",
      "MB = c1*L+c2*E/100+PFS           #monthly bill(Rs)\n",
      "\n",
      "\n",
      "#Result:\n",
      "print \"The monthly bill is Rs\",round(MB,1)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The monthly bill is Rs 7268.0\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.11, Page Number: 96"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration:\n",
      "c1 = 150                              #1st part tariff(Rs/KVA)\n",
      "c2 = 8                              #2nd part tariff(paise/unit)\n",
      "LF = 0.3                            #load factor\n",
      "\n",
      "\n",
      "#Calculation:\n",
      "#suppose max demand is 1kVA\n",
      "\n",
      "#(i)When p.f. is unity:\n",
      "pf = 1\n",
      "OC1 = c1*100/(8760*LF)+c2              #operating cost(Rs)\n",
      "\n",
      "#(ii) When p.f. is 0\u00b77\n",
      "pf1 = 0.7\n",
      "OC2 = c1*100/(8760*LF*pf1)+c2         #operating cost(Rs)\n",
      "\n",
      "#Result:\n",
      "print \"At unity p. f., overall cost is Rs\",round(OC1,2)\n",
      "print \"At 0.7 p. f., overall cost is Rs\",round(OC2,2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "At unity p. f., overall cost is Rs 13.71\n",
        "At 0.7 p. f., overall cost is Rs 16.15\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.12, Page Number: 97"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "\n",
      "#variable declaration\n",
      "L = 200                        #avg load(kW)\n",
      "pf = 0.8                       #power factor\n",
      "M = 250                        #max demand(kW)\n",
      "l = 4                          #losses(%)\n",
      "r = 12                          #interest & depreciation(%)\n",
      "C = 50                         #high voltage equipment cost(Rs)\n",
      "t = 8                          #working hours\n",
      "n = 300                        #no. of working working\n",
      "\n",
      "#for system(i)high voltage supply:\n",
      "c11 = 5                        #1st part tariff(paise/unit)\n",
      "c12 = 4.50                    #2nd part tariff(per month per kVA)\n",
      "\n",
      "#for system(ii)low voltage supply:\n",
      "c21 = 5.5                      #1st part tariff(paise/unit)\n",
      "c22 = 5                        #2nd part tariff(Rs per month per kVA)\n",
      "\n",
      "\n",
      "#Calculation:\n",
      "#(i) High voltage supply:\n",
      "\n",
      "M1 = M/pf                      #Max. demand in kVA\n",
      "#As the losses in h.v. equipment are 4%, therefore, \n",
      "#capacity of h.v. equipment:\n",
      "Cap = round(M1/(1-l/100),1)            #capacity of h.v. equipment(kVA)\n",
      "C1 = C*Cap                     #Capital investment on h.v. equipment(Rs)\n",
      "E1 = L*t*n/(1-l/100)           #units consumed(kWh)\n",
      "T1 = C1*r/100+Cap*c12*12+c11*E1/100                #Total annual cost(Rs)\n",
      "\n",
      "#(i) low voltage supply:\n",
      "M2 = M/pf                      #Max. demand in kVA\n",
      "E2 = L*t*n                     #units consumed(kWh)\n",
      "T2 = M2*c22*12+E2*c21/100      #kWh\n",
      "\n",
      "T = T2 - T1\n",
      "\n",
      "#Results:\n",
      "print \"Difference in the annual costs of two systems is Rs\",T\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Difference in the annual costs of two systems is Rs 620.0\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.13, Page Number: 97"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "\n",
      "#Variable declaration:\n",
      "#(i) Purchasing diesel set:\n",
      "M1 = 1000                      #kW\n",
      "C1 = 400                       #Rs/kW\n",
      "r1 = 10                         #annual interest depreciation(%)\n",
      "c11 = 75                       #Rs/kW\n",
      "c12 = 5                         #paise/unit\n",
      "\n",
      "#(ii) Purchasing from grid supply:\n",
      "r1 = 10                         #annual interest depreciation(%)\n",
      "c21 =120                       #Rs/kW\n",
      "c22 = 3                         #paise/unit\n",
      "#after 2 years:\n",
      "M2 = 2500                        #kW\n",
      "E = 5.5*10**6                   #units reached\n",
      "\n",
      "#Calculation:\n",
      "#(i) Purchasing diesel set:\n",
      "CC = M1*C1                     #Rs\n",
      "#The present capacity of the station is 2000 kW and the expected\n",
      "#maximum demand after two years is 2500 kW.\n",
      "P = 2500-2000                   #extra power to be generated(kW)\n",
      "T1 = CC*r1/100+P*c11+E*c12/100       #total annual cost(Rs)\n",
      "\n",
      "#(ii) Purchasing from grid supply:\n",
      "T2 = P*c21+E*c22/100           #total annual cost(Rs)\n",
      "\n",
      "\n",
      "#Result:\n",
      "print \"Alternative (ii) is cheaper by Rs\",T1-T2,\"per annum\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Alternative (ii) is cheaper by Rs 127500.0 per annum\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.14, Page Number: 98"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "from pylab import *\n",
      "from sympy import *\n",
      "import math\n",
      "\n",
      "#Variable declaration:\n",
      "#H.V supply:\n",
      "c11 = 70                         #1st part tariff(Rs/kVA)\n",
      "c12 = 3                          #2nd part tariff(paise/kWh)\n",
      "\n",
      "#L.V supply:\n",
      "c21 = 65                         #1st part tariff(Rs/kVA)\n",
      "c22 = 4                          #2nd part tariff(paise/kWh)\n",
      "\n",
      "c = 50                           #cost of transformer & switchgear for HV side(Rs/kVA)\n",
      "r1= 2                            #transformer losses(%)\n",
      "r2 = 15                 #annual fixed charges(%) of transformer & switchgear\n",
      "n = 6                            #no of working hours\n",
      "\n",
      "#Calculation:\n",
      "(x,y) = symbols('x y')              #say x = Factory load in kW\n",
      "                                 #y = No. of working days above which H.V.\n",
      "                                    #supply is cheaper\n",
      "#for HV side:        \n",
      "r = x*round(1/(1-r1/100),4)                #rating of transformer & switchgear(kVA)\n",
      "E1 = x*y*round(n*1/(1-r1/100),2)                       #units consumed per annnum\n",
      "T11 = x*math.floor(1/(1-r1/100)*c11*100)/100+x*round(1/(1-r1/100)*r2*c/100,2)          #total fixed charges(Rs)\n",
      "T12 = E1*c12/100                 #total running charges(Rs)\n",
      "T1 = T11+T12                     #total annual charges(Rs)\n",
      "\n",
      "#for LV side:\n",
      "E2 = x*y*n                      #units consumed per annnum\n",
      "T21 = c21*x                     #total fixed charges(Rs)\n",
      "T22 = c22*E2/100                #total running charges(Rs)\n",
      "T2 = T21+T22                   #total annual charges(Rs)\n",
      "y11 = solve(T1-T2,y)[0]\n",
      "\n",
      "#Result:\n",
      "print \"If the factory is run for more than\",math.floor(y11),'days' #the ans. is different from that in book\n",
      "print \"then H. V. supply will be cheaper.\"                         #due to calculation using improper rounding."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "If the factory is run for more than 249.0 days\n",
        "then H. V. supply will be cheaper.\n"
       ]
      }
     ],
     "prompt_number": 2
    }
   ],
   "metadata": {}
  }
 ]
}