Compare commits

..

No commits in common. "main" and "convert2array" have entirely different histories.

18 changed files with 503 additions and 1020 deletions

1
.gitignore vendored
View file

@ -3,4 +3,3 @@ test*
__pycache__ __pycache__
*.db *.db
/docs/build/ /docs/build/
.vscode/

View file

@ -1,9 +0,0 @@
JEPL General Functions
================================
.. toctree::
:maxdepth: 2
:caption: Contents:
va

View file

@ -1,17 +0,0 @@
va - Volt-Amps
================
.. function:: va(voltage, current, phases=3)
:module: JEPL.general
:param voltage: The voltage of the circuit
:type voltage: float
:param current: The current of the circuit
:type current: float
:returns: volt-Amps in VA
:rtype: float
Describe the function

View file

@ -15,5 +15,3 @@ documentation for details.
:maxdepth: 2 :maxdepth: 2
:caption: Contents: :caption: Contents:
general/index

View file

@ -0,0 +1,28 @@
size,60,75,90
14,25,30,35
12,30,35,40
10,40,50,55
8,60,70,80
6,80,95,105
4,105,125,140
3,120,145,165
2,140,170,190
1,165,195,220
1/0,195,230,260
2/0,220,265,300
3/0,260,310,350
4/0,300,360,405
250,340,405,455
300,370,445,500
350,425,505,570
400,455,545,615
500,520,620,700
600,580,690,780
700,630,755,850
750,655,785,885
800,680,815,920
1000,785,870,980
1250,890,1065,1200
1500,985,1175,1325
1750,1070,1280,1445
2000,1160,1385,1560
1 size 60 75 90
2 14 25 30 35
3 12 30 35 40
4 10 40 50 55
5 8 60 70 80
6 6 80 95 105
7 4 105 125 140
8 3 120 145 165
9 2 140 170 190
10 1 165 195 220
11 1/0 195 230 260
12 2/0 220 265 300
13 3/0 260 310 350
14 4/0 300 360 405
15 250 340 405 455
16 300 370 445 500
17 350 425 505 570
18 400 455 545 615
19 500 520 620 700
20 600 580 690 780
21 700 630 755 850
22 750 655 785 885
23 800 680 815 920
24 1000 785 870 980
25 1250 890 1065 1200
26 1500 985 1175 1325
27 1750 1070 1280 1445
28 2000 1160 1385 1560

View file

@ -0,0 +1,20 @@
current,copper wire,copper bus,aluminum wire,aluminum bus
20,14,2,12,3.5
30,12,3.5,10,5.5
60,10,5.5,8,8.5
100,8,8.5,6,10.5
200,6,10.5,4,21
300,4,21,2,26.5
400,3,26.5,1,33.5
500,2,33.5,1/0,42.5
600,1,42.5,2/0,53.5
800,1/0,53.5,3/0,67.5
1000,2/0,67.5,4/0,84
1200,3/0,84,250,127
1600,4/0,107,350,177.5
2000,250,127.5,400,203
2500,350,177.5,500,253.5
3000,400,203,600,355
4000,500,253.5,800,405.5
5000,700,355,1000,507
6000,800,405.5,1250,633.5
1 current copper wire copper bus aluminum wire aluminum bus
2 20 14 2 12 3.5
3 30 12 3.5 10 5.5
4 60 10 5.5 8 8.5
5 100 8 8.5 6 10.5
6 200 6 10.5 4 21
7 300 4 21 2 26.5
8 400 3 26.5 1 33.5
9 500 2 33.5 1/0 42.5
10 600 1 42.5 2/0 53.5
11 800 1/0 53.5 3/0 67.5
12 1000 2/0 67.5 4/0 84
13 1200 3/0 84 250 127
14 1600 4/0 107 350 177.5
15 2000 250 127.5 400 203
16 2500 350 177.5 500 253.5
17 3000 400 203 600 355
18 4000 500 253.5 800 405.5
19 5000 700 355 1000 507
20 6000 800 405.5 1250 633.5

View file

@ -0,0 +1,29 @@
size,60,75,90
14,15,20,25
12,20,25,30
10,30,35,40
8,40,50,55
6,40,50,55
4,70,85,95
3,85,100,115
2,95,115,130
1,110,130,145
1/0,125,150,170
2/0,145,175,195
3/0,165,200,225
4/0,195,230,260
250,215,255,290
300,240,285,320
350,260,310,350
400,280,335,380
500,320,380,430
600,350,420,475
700,385,460,520
750,400,475,535
800,410,490,555
900,435,520,585
1000,455,545,615
1250,495,590,615
1500,525,625,705
1750,545,650,735
2000,555,665,750
1 size 60 75 90
2 14 15 20 25
3 12 20 25 30
4 10 30 35 40
5 8 40 50 55
6 6 40 50 55
7 4 70 85 95
8 3 85 100 115
9 2 95 115 130
10 1 110 130 145
11 1/0 125 150 170
12 2/0 145 175 195
13 3/0 165 200 225
14 4/0 195 230 260
15 250 215 255 290
16 300 240 285 320
17 350 260 310 350
18 400 280 335 380
19 500 320 380 430
20 600 350 420 475
21 700 385 460 520
22 750 400 475 535
23 800 410 490 555
24 900 435 520 585
25 1000 455 545 615
26 1250 495 590 615
27 1500 525 625 705
28 1750 545 650 735
29 2000 555 665 750

View file

@ -0,0 +1,27 @@
size,60,75,90
12,25,30,35
10,35,40,45
8,45,55,60
4,65,75,85
3,95,115,130
2,115,135,150
1,1340,155,175
1/0,150,180,205
2/0,175,210,235
3/0,200,240,270
4/0,235,280,315
250,265,315,355
300,295,350,395
350,330,395,445
400,355,425,480
500,405,485,545
600,455,545,615
700,500,595,670
750,520,620,700
800,540,645,725
900,585,700,790
1000,630,750,845
1250,715,855,965
1500,795,950,1070
1750,880,1050,1185
2000,965,1150,1295
1 size 60 75 90
2 12 25 30 35
3 10 35 40 45
4 8 45 55 60
5 4 65 75 85
6 3 95 115 130
7 2 115 135 150
8 1 1340 155 175
9 1/0 150 180 205
10 2/0 175 210 235
11 3/0 200 240 270
12 4/0 235 280 315
13 250 265 315 355
14 300 295 350 395
15 350 330 395 445
16 400 355 425 480
17 500 405 485 545
18 600 455 545 615
19 700 500 595 670
20 750 520 620 700
21 800 540 645 725
22 900 585 700 790
23 1000 630 750 845
24 1250 715 855 965
25 1500 795 950 1070
26 1750 880 1050 1185
27 2000 965 1150 1295

View file

@ -0,0 +1,28 @@
size,60,75,90
12,15,20,25
10,25,30,35
8,35,40,45
6,40,50,55
4,55,65,75
3,65,75,85
2,75,90,100
1,85,100,115
1/0,100,120,165
2/0,115,165,150
3/0,160,155,175
4/0,150,180,205
250,170,205,230
300,195,230,260
350,210,250,280
400,225,270,305
500,260,310,350
600,285,340,385
700,315,375,425
750,320,385,435
800,330,395,445
900,355,425,480
1000,375,445,500
1250,405,485,545
1500,435,520,585
1750,455,545,615
2000,470,560,630
1 size 60 75 90
2 12 15 20 25
3 10 25 30 35
4 8 35 40 45
5 6 40 50 55
6 4 55 65 75
7 3 65 75 85
8 2 75 90 100
9 1 85 100 115
10 1/0 100 120 165
11 2/0 115 165 150
12 3/0 160 155 175
13 4/0 150 180 205
14 250 170 205 230
15 300 195 230 260
16 350 210 250 280
17 400 225 270 305
18 500 260 310 350
19 600 285 340 385
20 700 315 375 425
21 750 320 385 435
22 800 330 395 445
23 900 355 425 480
24 1000 375 445 500
25 1250 405 485 545
26 1500 435 520 585
27 1750 455 545 615
28 2000 470 560 630

View file

@ -0,0 +1,15 @@
Trade Size,RMC,FMC,RPVC,EB1,DB2,LTMC,LTNMC,EMT,ENT,SCH40,SCH80
12,,71,,,,119,114,,,,
16,202,198,167,,,196,188,186,167,169,128
21,354,334,307,,,341,328,330,304,307,246
27,573,507,507,,,549,527,539,506,507,418
35,985,792,792,,,965,937,940,894,898,760
41,1336,1140,1140,,,1257,1257,1288,1230,1233,1054
53,2199,2027,2027,2027,2027,2068,2098,2132,2057,2057,1796
63,3139,3167,2951,,,3116,,3783,,2935,2549
78,4839,4560,4560,4560,4560,4776,,5701,,4553,4002
91,6458,6207,6138,6138,6138,6207,,7451,,,
103,8311,8107,7870,7870,7870,8107,,9503,,7895,7023
129,13039,,12439,12538,12538,,,,,12451,11169
155,18811,,17613,17613,17613,,,,,18027,16029
200,,,31225,,,,,,,31303,
1 Trade Size RMC FMC RPVC EB1 DB2 LTMC LTNMC EMT ENT SCH40 SCH80
2 12 71 119 114
3 16 202 198 167 196 188 186 167 169 128
4 21 354 334 307 341 328 330 304 307 246
5 27 573 507 507 549 527 539 506 507 418
6 35 985 792 792 965 937 940 894 898 760
7 41 1336 1140 1140 1257 1257 1288 1230 1233 1054
8 53 2199 2027 2027 2027 2027 2068 2098 2132 2057 2057 1796
9 63 3139 3167 2951 3116 3783 2935 2549
10 78 4839 4560 4560 4560 4560 4776 5701 4553 4002
11 91 6458 6207 6138 6138 6138 6207 7451
12 103 8311 8107 7870 7870 7870 8107 9503 7895 7023
13 129 13039 12439 12538 12538 12451 11169
14 155 18811 17613 17613 17613 18027 16029
15 200 31225 31303

View file

@ -1,7 +1,7 @@
# CEC 2021, Tables # CEC 2021, Table 1
cec21table1 = [ table1 = [
#['size', '60', '75', '90'], #['size', '60', '75', '90'],
['14', 25, 30, 35], ['14', 25, 30, 35],
['12', 30, 35, 40], ['12', 30, 35, 40],
@ -31,116 +31,3 @@ cec21table1 = [
['1750', 1070, 1280, 1445], ['1750', 1070, 1280, 1445],
['2000', 1160, 1385, 1560] ['2000', 1160, 1385, 1560]
] ]
cec21table2 = [
#['size', '60', '75', '90'],
['14', 15, 20, 25],
['12', 20, 25, 30],
['10', 30, 35, 40],
['8', 40, 50, 55],
['6', 40, 50, 55],
['4', 70, 85, 95],
['3', 85, 100, 115],
['2', 95, 115, 130],
['1', 110, 130, 145],
['1/0', 125, 150, 170],
['2/0', 145, 175, 195],
['3/0', 165, 200, 225],
['4/0', 195, 230, 260],
['250', 215, 255, 290],
['300', 240, 285, 320],
['350', 260, 310, 350],
['400', 280, 335, 380],
['500', 320, 380, 430],
['600', 350, 420, 475],
['700', 385, 460, 520],
['750', 400, 475, 535],
['800', 410, 490, 555],
['900', 435, 520, 585],
['1000', 455, 545, 615],
['1250', 495, 590, 615],
['1500', 525, 625, 705],
['1750', 545, 650, 735],
['2000', 555, 665, 750]
]
cec21table3 = [
#['size', '60', '75', '90'],
['12', 25, 30, 35],
['10', 35, 40, 45],
['8', 45, 55, 60],
['4', 65, 75, 85],
['3', 95, 115, 130],
['2', 115, 135, 150],
['1', 134, 155, 175],
['1/0', 150, 180, 205],
['2/0', 175, 210, 235],
['3/0', 200, 240, 270],
['4/0', 235, 280, 315],
['250', 265, 315, 355],
['300', 295, 350, 395],
['350', 330, 395, 445],
['400', 355, 425, 480],
['500', 405, 485, 545],
['600', 455, 545, 615],
['700', 500, 595, 670],
['750', 520, 620, 700],
['800', 540, 645, 725],
['900', 585, 700, 790],
['1000', 630, 750, 845],
['1250', 715, 855, 965],
['1500', 795, 950, 1070],
['1750', 880, 1050, 1185],
['2000', 965, 1150, 1295]
]
cec21table4 = [
#['size', '60', '75', '90'],
['12', 15, 20, 25],
['10', 25, 30, 35],
['8', 35, 40, 45],
['6', 40, 50, 55],
['4', 55, 65, 75],
['3', 65, 75, 85],
['2', 75, 90, 100],
['1', 85, 100, 115],
['1/0', 100, 120, 165],
['2/0', 115, 165, 150],
['3/0', 160, 155, 175],
['4/0', 150, 180, 205],
['250', 170, 205, 230],
['300', 195, 230, 260],
['350', 210, 250, 280],
['400', 225, 270, 305],
['500', 260, 310, 350],
['600', 285, 340, 385],
['700', 315, 375, 425],
['750', 320, 385, 435],
['800', 330, 395, 445],
['900', 355, 425, 480],
['1000', 375, 445, 500],
['1250', 405, 485, 545],
['1500', 435, 520, 585],
['1750', 455, 545, 615],
['2000', 470, 560, 630]
]
cec21table16 = [
['current','copper wire','copper bus','aluminum wire','aluminum bus'],
[20,'14',2,'12',3.5],
[30,'12',3.5,'10',5.5],
[60,'10',5.5,'8',8.5],
[100,'8',8.5,'6',10.5],
[200,'6',10.5,'4',21],
[300,'4',21,'2',26.5],
[400,'3',26.5,'1',33.5],
[500,'2',33.5,'1/0',42.5],
[600,'1',42.5,'2/0',53.5],
[800,'1/0',53.5,'3/0',67.5],
[1000,'2/0',67.5,'4/0',84],
[1200,'3/0',84,'250',127],
[1600,'4/0',107,'350',177.5],
[2000,'250',127.5,'400',203],
[2500,'350',177.5,'500',253.5],
[3000,'400',203,'600',355],
[4000,'500',253.5,'800',405.5],
[5000,'700',355,'1000',507],
[6000,'800',405.5,'1250',633.5],
]

View file

@ -1,321 +0,0 @@
# CEC 2024, Tables
cec24table1 = [
#['size', '60', '75', '90'],
['14', 25, 30, 35],
['12', 30, 35, 40],
['10', 40, 50, 55],
['8', 60, 70,80],
['6', 80, 95, 105],
['4', 105, 125, 140],
['3', 120, 145, 165],
['2', 140, 170, 190],
['1', 165, 195, 220],
['1/0', 195, 230, 260],
['2/0', 220, 265, 300],
['3/0', 260, 310, 350],
['4/0', 300, 360, 405],
['250', 340, 405, 455],
['300', 370, 445, 500],
['350', 425, 505, 570],
['400', 455, 545, 615],
['500', 520, 620, 700],
['600', 580, 690, 780],
['700', 630, 755, 850],
['750', 655, 785, 885],
['800', 680, 815, 920],
['1000', 785, 870, 980],
['1250', 890, 1065, 1200],
['1500', 985, 1175, 1325],
['1750', 1070, 1280, 1445],
['2000', 1160, 1385, 1560]
]
cec24table2 = [
#['size', '60', '75', '90'],
['14', 15, 20, 25],
['12', 20, 25, 30],
['10', 30, 35, 40],
['8', 40, 50, 55],
['6', 40, 50, 55],
['4', 70, 85, 95],
['3', 85, 100, 115],
['2', 95, 115, 130],
['1', 110, 130, 145],
['1/0', 125, 150, 170],
['2/0', 145, 175, 195],
['3/0', 165, 200, 225],
['4/0', 195, 230, 260],
['250', 215, 255, 290],
['300', 240, 285, 320],
['350', 260, 310, 350],
['400', 280, 335, 380],
['500', 320, 380, 430],
['600', 350, 420, 475],
['700', 385, 460, 520],
['750', 400, 475, 535],
['800', 410, 490, 555],
['900', 435, 520, 585],
['1000', 455, 545, 615],
['1250', 495, 590, 615],
['1500', 525, 625, 705],
['1750', 545, 650, 735],
['2000', 555, 665, 750]
]
cec24table3 = [
#['size', '60', '75', '90'],
['12', 25, 30, 35],
['10', 35, 40, 45],
['8', 45, 55, 60],
['4', 65, 75, 85],
['3', 95, 115, 130],
['2', 115, 135, 150],
['1', 134, 155, 175],
['1/0', 150, 180, 205],
['2/0', 175, 210, 235],
['3/0', 200, 240, 270],
['4/0', 235, 280, 315],
['250', 265, 315, 355],
['300', 295, 350, 395],
['350', 330, 395, 445],
['400', 355, 425, 480],
['500', 405, 485, 545],
['600', 455, 545, 615],
['700', 500, 595, 670],
['750', 520, 620, 700],
['800', 540, 645, 725],
['900', 585, 700, 790],
['1000', 630, 750, 845],
['1250', 715, 855, 965],
['1500', 795, 950, 1070],
['1750', 880, 1050, 1185],
['2000', 965, 1150, 1295]
]
cec24table4 = [
#['size', '60', '75', '90'],
['12', 15, 20, 25],
['10', 25, 30, 35],
['8', 35, 40, 45],
['6', 40, 50, 55],
['4', 55, 65, 75],
['3', 65, 75, 85],
['2', 75, 90, 100],
['1', 85, 100, 115],
['1/0', 100, 120, 165],
['2/0', 115, 165, 150],
['3/0', 160, 155, 175],
['4/0', 150, 180, 205],
['250', 170, 205, 230],
['300', 195, 230, 260],
['350', 210, 250, 280],
['400', 225, 270, 305],
['500', 260, 310, 350],
['600', 285, 340, 385],
['700', 315, 375, 425],
['750', 320, 385, 435],
['800', 330, 395, 445],
['900', 355, 425, 480],
['1000', 375, 445, 500],
['1250', 405, 485, 545],
['1500', 435, 520, 585],
['1750', 455, 545, 615],
['2000', 470, 560, 630]
]
# Table 6A Dimensions of single Class B R90XLPE, RW75XLPE, RW90XLPE and RPV90 unjacketed 600V insulated conductors for calculating conduit and tubing fill
# Only using the conductor characteristics columns, the area will be calculated in the functions. Only stranded.
cec24table6A = [
['size', 'diameter'],
['14', 3.36],
['12', 3.84],
['10', 4.47],
['8', 5.99],
['6', 6.95],
['4', 8.17],
['3', 8.88],
['2', 9.7],
['1', 11.23],
['1/0', 12.27],
['2/0', 13.44],
['3/0', 14.74],
['4/0', 16.21],
['250', 17.9],
['300', 19.3],
['350', 20.53],
['400', 21.79],
['450', 22.91],
['500', 23.95],
['600', 26.74],
['700', 28.55],
['750', 29.41],
['800', 30.25],
['900', 31.85],
['1000', 33.32],
['1250', 37.56],
['1500', 40.68],
['1750', 43.58],
['2000', 46.27]
]
# Table 6B Dimensions of single Class B R90XLPE, RW75XLPE, RW90XLPE and RPV90 unjacketed 1000V insulated conductors for calculating conduit and tubing fill
# Only using the conductor characteristics columns, the area will be calculated in the functions. Only stranded.
cec24table6B = [
['size', 'diameter'],
['14', 4.12],
['12', 4.6],
['10', 5.23],
['8', 5.99], # This is the same as the 600V in Table 6A
['6', 7.71],
['4', 8.93],
['3', 9.64],
['2', 10.46],
['1', 12.49],
['1/0', 13.53],
['2/0', 14.7],
['3/0', 16],
['4/0', 17.47],
['250', 19.17],
['300', 20.56],
['350', 21.79],
['400', 23.05],
['450', 24.17],
['500', 25.21],
['600', 27.24],
['700', 29.05],
['750', 29.91],
['800', 30.75],
['900', 32.35],
['1000', 33.82],
['1250', 38.32],
['1500', 41.44],
['1750', 44.34],
['2000', 47.03]
]
# Table 6C Dimensions of single Class B R90XLPE, RW75XLPE, R90EP, RW90XLPE, RW90EP, and RPV90 jacketed 600V insulated conductors for calculating conduit and tubing fill
# Only using the conductor characteristics columns, the area will be calculated in the functions. Only stranded.
cec24table6C = [
['size', 'diameter'],
['14', 4.12],
['12', 4.6],
['10', 5.23],
['8', 6.75],
['6', 8.47],
['4', 9.69],
['3', 10.4],
['2', 11.22],
['1', 13.51],
['1/0', 14.55],
['2/0', 15.72],
['3/0', 17.02],
['4/0', 18.49],
['250', 21.21],
['300', 22.6],
['350', 23.83],
['400', 25.09],
['450', 26.21],
['500', 27.25],
['600', 30.04],
['700', 31.85],
['750', 32.71],
['800', 33.55],
['900', 35.15],
['1000', 36.62],
['1250', 42.38],
['1500', 45.5],
['1750', 48.4],
['2000', 51.09]
]
# TODO - Add tables 6D thru 6K
# Table 9A/B Internal diameter and cross-sectional areas of various trade conduit and tubing
# Only using the internal diameter (ID) for each of these conduits, along with the trade size. This will be used to calculate the area and fill for the various limits per Table 8
'''
rmc = rigid metal conduit
fmc = flexible metal conduit
rpvc = rigid PVC
db2 = rigid Type EB1 PVC and rigid type DB2/ES2 PVC conduit
mlt = metallic liquid tight, flexible conduit
nmlt = non-metallic liquid tight conduit
emt = electrical metallic tubing
ent = electrical non-metallic tubing
rtrcips = rigid RTRC conduit marked IPS
rtrcid = rigid RTRC conduit marked ID
sch40 = HDPE conduit schedule 40
sch80 = HDPE conduit schedule 80
dr9 = HDPE DR9 conduit
dr11 = HDPE DR11 conduit
dr13 = HDPE DR13.5 conduit
dr15 = HDPE DR15.5 conduit
'''
cec24table9AB = [
['size','RMC', 'FMC', 'RPVC', 'DB2', 'LTMC', 'LTNMC','EMT', 'ENT', 'RTRCIPS', 'RTRCID', 'SCH40', 'SCH80', 'DR9','DR11', 'DR13', 'DR15'],
['16', 16.05, 15.88, 14.57, None, 15.8, 15.49, 15.4, 14.58, 17.27, 11.94, 14.67, 12.75, 15.47, 16.3, 17.02, 17.43],
['21', 21.23, 20.62, 19.77, None, 20.83, 20.45, 20.5, 19.66, 22.61, 18.29, 19.78, 17.7, 19.65, 20.73, 21.63, 22.14],
['27', 27.0, 25.4, 25.4, None, 26.44, 25.91, 26.2, 25.37, 29.34, 24.64, 25.4, 23.06, 24.86, 26.21, 27.33, 27.97],
['35', 35.41, 31.75, 31.75, None, 35.05, 34.54, 34.6, 33.73, 38.1, 30.99, 33.82, 31.1, 31.51, 33.31, 34.73, 35.54],
['41', 41.25, 38.1, 38.1, None, 40.01, 40.01, 40.5, 39.57, 44.2, 37.34, 39.63, 36.63, 36.1, 38.27, 39.93, 40.85],
['53', 52.91, 50.8, 50.8, 50.8, 51.31, 51.69, 52.1, 51.18, 56.26, 50.29, 51.18, 47.82, 45.19, 47.91, 50.18, 51.4],
['63', 63.22, 63.5, 61.3, None, 62.99, None, 69.4, None, 69.6, 63, 61.13, 56.97, 54.63, 57.92, 60.68, 62.24],
['78', 78.49, 76.2, 76.2, 76.2, 77.98, None, 85.2, None, 84.84, 75.69, 76.14, 71.38, 66.56, 70.6, 73.95, 75.85],
['91', 90.68, 88.9, 88.4, 88.4, 88.9, None, 97.4, None, None, 88.39, None, None, None, None, None, None],
['103', 102.87, 101.6, 100.1, 100.1, 101.6, None, 110, None, 109.72, 101.09, 100.26, 94.56, 85.36, 90.52, 94.83, 97.29],
['129', 128.85, None, 125.85, 126.35, None, None, 128.9, None, 136.14, 126.24, 125.91, 119.25, 105.54, 111.93, 117.25, 120.29],
['155', 154.76, None, 149.75, 149.75, None, None, 154.8, None, 162.05, None, 151.5, 142.86, 125.63, 133.22, 139.57, 143.19],
['200', None, None, 199.39, None, None, None, None, None, None, None, 199.64, None, 163.58, 173.49, 181.74, 186.43],
]
# Table 10D Dimensions of DLO cable for calculating conduit and tubing fill
cec24table10D = [
['size', 'diameter'],
['14', 5.59],
['12', 6.1],
['10', 6.86],
['8', 8.38],
['6', 10.41],
['4', 11.68],
['3', 12.45],
['2', 13.21],
['1', 16.51],
['1/0', 17.53],
['2/0', 18.29],
['3/0', 20.57],
['4/0', 22.10],
['262', 25.4],
['313', 26.92],
['373', 27.94],
['444', 31.24],
['535', 34.04],
['646', 36.83],
['777', 38.1],
['929', 40.89],
['1111', 44.45]
]
# Appendix Tables
cec24tableD3 = [
['size','cu_dc', 'cu_100pf', 'cu_cable_90pf', 'cu_cable_80pf', 'cu_raceway_90pf', 'cu_raceway_80pf', 'al_dc', 'al_100pf', 'al_cable_90pf', 'al_cable_80pf', 'al_raceway_90pf', 'al_raceway_80pf'],
['14', 10.2, 10.2, 9.92, 9.67, 10, 9.67, None, None, None, None, None, None],
['12', 6.38, 6.38, 6.25, 6.1, 6.26, 6.11, 10.5, 10.5, 10.3, 10, 10.3, 9.99],
['10', 4.03, 4.03, 3.96, 3.87, 3.96, 3.87, 6.58, 6.58, 6.44, 6.28, 6.45, 6.29],
['8', 2.54, 2.54, 2.5, 2.45, 2.51, 2.45, 4.14, 4.14, 4.07, 3.97, 4.07, 3.98],
['6', 1.59, 1.59, 1.58, 1.55, 1.58, 1.55, 2.62, 2.62, 2.58, 2.52, 2.58, 2.53],
['4', 1.01, 1.01, 1.01, 0.987, 1.01, 1, 1.65, 1.65, 1.63, 1.6, 1.64, 1.61],
['3', 0.792, 0.792, 0.797, 0.787, 0.801, 0.792, 1.3, 1.31, 1.3, 1.27, 1.3, 1.28],
['2', 0.626, 0.627, 0.636, 0.629, 0.639, 0.635, 1.04, 1.04, 1.04, 1.02, 1.04, 1.03],
['1', 0.5, 0.5, 0.512, 0.509, 0.516, 0.515, 0.82, 0.82, 0.823, 0.812, 0.827, 0.818],
['1/0', 0.395, 0.396, 0.41, 0.409, 0.414, 0.415, 0.651, 0.652, 0.659, 0.652, 0.663, 0.657],
['2/0', 0.314, 0.316, 0.331, 0.332, 0.335, 0.338, 0.516, 0.517, 0.526, 0.522, 0.53, 0.528],
['3/0', 0.249, 0.251, 0.267, 0.27, 0.271, 0.275, 0.408, 0.409, 0.42, 0.419, 0.424, 0.425],
['4/0', 0.197, 0.2, 0.217, 0.221, 0.221, 0.226, 0.326, 0.327, 0.341, 0.341, 0.345, 0.347],
['250', 0.167, 0.171, 0.188, 0.193, 0.192, 0.198, 0.275, 0.277, 0.291, 0.293, 0.295, 0.299],
['300', 0.14, 0.144, 0.162, 0.167, 0.166, 0.172, 0.229, 0.231, 0.247, 0.249, 0.25, 0.255],
['350', 0.12, 0.125, 0.143, 0.148, 0.147, 0.154, 0.196, 0.199, 0.215, 0.218, 0.219, 0.224],
['400', 0.105, 0.111, 0.129, 0.135, 0.133, 0.14, 0.172, 0.175, 0.191, 0.195, 0.195, 0.201],
['500', 0.0836, 0.0912, 0.11, 0.116, 0.114, 0.121, 0.138, 0.141, 0.158, 0.163, 0.162, 0.168],
['600', 0.0697, 0.0785, 0.0969, 0.104, 0.101, 0.109, 0.115, 0.119, 0.136, 0.142, 0.14, 0.147],
['750', 0.0558, 0.0668, 0.085, 0.0915, 0.0889, 0.097, 0.0916, 0.0968, 0.115, 0.121, 0.119, 0.126],
['1000', 0.0417, 0.0558, 0.0739, 0.0805, 0.0778, 0.086, 0.0686, 0.0758, 0.0933, 0.0994, 0.0973, 0.105]
]

View file

@ -8,10 +8,8 @@ import sys
from .jepl_general import * from .jepl_general import *
from .jeplpv import * from .jeplpv import *
from .jepl_circuits import * from .jepl_circuits import *
# safety still needs to be re-wrote, but I will do it later. from .jepl_templates import *
#from .jepl_safety import * from .jepl_safety import *
# Templates rely on safety so I will have to fix it too
#from .jepl_templates import *
def Test(): def Test():
print( "JMK Python Module works! !") print( "JMK Python Module works! !")

View file

@ -10,109 +10,171 @@ Circuit Design Functions
import pandas as pd import pandas as pd
import numpy as np import numpy as np
import math import math
import sqlite3
# Need to add the various table files here. import bisect
from .jepl_tables import *
def voltage_drop(voltage, current, conductor_size, length, num_phase = 3, material ='cu', num_runs = 1, code = 'CEC', power_factor = 'dc', raceway = True,insul_temp = 75): def vd(current,length,resistance,runs=1):
'''
Calculates the voltage drop across the conductor length.
If there are parallel runs we assume that they are approximately the same length.
Therefore from the general equation of:
1/Req = 1/R1 + 1/R2 ... and all R1-Rn are the same.
Req = R/n or in the equation below r = resistance / runs.
'''
r = (length*resistance/1000) / runs
vd=round(2*current*r,8)
return vd
def percentvd(vd,nominal):
percent = (vd/nominal)*100
return percent
def voltage_drop(nominal_voltage, current, conductor_size, length,material ='cu', num_runs = 1, code = 'CEC'):
''' '''
This function will return the drop in voltage and in percent of the supply. This function will return the drop in voltage and in percent of the supply.
For CEC this function uses Table D3 and the function VD = K * F * i * L / 1000 nominal_voltage = int
K -> is a table lookup based on the conductor material, size raceway and powerfactor current = float
F -> is the system factor, 2 for single phase and sqrt(3) for three phase conductor_size = string
Voltage drop equation is:
Vdrop = 2 * I * L * R/1000
I = load current
L = circuit length in meters
R = Resistance in ohms/km
''' '''
material = material.upper() # Check to see if the db we need exists
code = code.upper()
power_factor = power_factor.upper()
#conductor_size = str(conductor_size)
valid_insul_temp = [60,75,90]
valid_code = ['CEC',
]
valid_material = ['CU',
'AL',
]
valid_power_factor = ['DC',
'1',
'0.9',
'0.8'
]
if insul_temp not in valid_insul_temp: import os
return print(temp + " is not valid. The valid temps are "+ str(valid_insul_temp)) import sys
if code not in valid_code: if os.path.isfile('jepl-cable.db') == False:
return print(code + " is not a valid code. The valid codes are "+ str(valid_code)) return (print("Run init. \nCopy jeplinit.py to the same folder as this file and add \n%run jeplinit.py jepl/folder/location/\nto the notebook. Make sure there is a trailing slash."))
if material not in valid_material:
return print(material + " is not a valid material. I should be 'al' or 'cu'.")
if power_factor not in valid_power_factor:
return print(valid_power_factor + " is not a valid load_type.")
# if (material == 'al'):
# Find K
# try:
with sqlite3.connect("jepl-cable.db") as con:
cur = con.cursor()
cur.execute('SELECT "AC Resistance" FROM "SW-Spec 25051" WHERE "Conductor Number" = 3 AND "Conductor Size"=?', (conductor_size,))
resistance = cur.fetchone()[0]
#print(resistance)
except sqlite3.OperationalError as e:
print(e)
elif (material == 'cu'):
try:
with sqlite3.connect("jepl-cable.db") as con:
cur = con.cursor()
cur.execute('SELECT "AC Resistance" FROM "SW-Spec 25055" WHERE "Conductor Number" = 3 AND "Conductor Size"=?', (conductor_size,))
resistance = cur.fetchone()[0]
except sqlite3.OperationalError as e:
print(e)
# Select the correct table
if (code == 'CEC') :
D3headers = cectableD3[0]
D3rows = cectableD3[1:]
df = pd.DataFrame(D3rows, columns=D3headers)
else: else:
return ('The variables were\'t right, but I\'m a loss to why.') return (print("error, choose material as cu or al"))
# Select the correct column voltage = vd(current,length,resistance,num_runs)
percent = percentvd(voltage,nominal_voltage)
return [voltage, percent]
#
# voltage_drop_conductors is wrong
#
#
def voltage_drop_conductors(voltage,current,distance,v_drop_percent = 0.03,runs = 1,material='cu'):
'''
Calculates the minimum conductor size to accomodate for voltage drop based on:
voltage -> system nominal voltage
current -> the peak/design load for the circuit
distance -> meters
v_drop_percent -> The design voltage drop (default 0.03 or 3%)
runs -> number of parallel runs (default 1)
material -> the conductor material, either 'al' or 'cu'. (default 'cu')
First we calculate the necessary resistivity:
resistivity = ohms/km
but the distance is 2x (there and back)
resistivity = ohms/[(2 * distance)/1000] {ohms/km}
ohms = v/I or (v_drop/voltage)/current
v_drop = v_drop_percent * voltage
resistivity = (v_drop/current)/[(2 * distance)/1000]
This works for 1 run, but for parallel runs Rtot = R/n where n is the number of runs.
in this equation we are looking for R, not Rtot, so we multiply the top by the number of runs.
therefore:
resistivity = [(v_drop/current)*runs]/[(2 * distance)/1000]
'''
# Determine the resistivity needed in ohms/km
v_drop = v_drop_percent * voltage
resistivity = ((v_drop/current)*runs)/((2 * distance)/1000)
if resistivity < 0.1214:
print("add parallel runs")
import os
import sys
if os.path.isfile('jepl-cable.db') == False:
return (print("Run init. \nCopy jeplinit.py to the same folder as this file and add \n%run jeplinit.py jepl/folder/location/\nto the notebook. Make sure there is a trailing slash."))
# Lookup the conductor size that meets this resistivity.
if (material == 'al'):
try:
with sqlite3.connect("jepl-cable.db") as con:
cur = con.cursor()
cur.execute('SELECT "Conductor Size" FROM "SW-Spec 25055" WHERE "Conductor Number" = 3 AND "AC Resistance"<?', (resistivity,))
conductor = str(cur.fetchone()[0])
#print(conductor)
except sqlite3.OperationalError as e:
print(e)
elif (material == 'cu'):
try:
with sqlite3.connect("jepl-cable.db") as con:
cur = con.cursor()
cur.execute('SELECT "Conductor Size" FROM "SW-Spec 25051" WHERE "Conductor Number" = 3 AND "AC Resistance"<?', (resistivity,))
conductor = str(cur.fetchone()[0])
#print(conductor)
except sqlite3.OperationalError as e:
print(e)
if (material == 'CU') & (power_factor == 'DC'):
column = 'cu_dc'
elif material == 'CU' & power_factor == '1':
column = 'cu_100pf'
elif material == 'CU' & power_factor == '0.9' & raceway == False:
column = 'cu_cable_90pf'
elif material == 'CU' & power_factor == '0.8' & raceway == False:
column = 'cu_cable_80pf'
elif material == 'CU' & power_factor == '0.9' & raceway == True:
column = 'cu_raceway_90pf'
elif material == 'CU' & power_factor == '0.8' & raceway == True:
column = 'cu_raceway_80pf'
elif material == 'AL' & power_factor == 'DC':
column = 'al_dc'
elif material == 'AL' & power_factor == '1':
column = 'al_100pf'
elif material == 'AL' & power_factor == '0.9' & raceway == False:
column = 'al_cable_90pf'
elif material == 'AL' & power_factor == '0.8' & raceway == False:
column = 'al_cable_80pf'
elif material == 'AL' & power_factor == '0.9' & raceway == True:
column = 'al_raceway_90pf'
elif material == 'AL' & power_factor == '0.8' & raceway == True:
column = 'al_raceway_80pf'
else: else:
return ('Can\'t calculate K factor') return (print("error, choose material as cu or al"))
# Determine the ampacity of the max conductor size return (conductor)
K_loc = df.loc[df['size'] == conductor_size,column]
K = K_loc.item()
#print(K)
# # These functions need to be re-written with the databases.
# Find F
#
if num_phase == 3:
F = math.sqrt(3)
else:
F = 2
#print(F)
#print(current)
#print(length)
voltage_drop = K * F * current * length / 1000
percent_voltage_drop = (voltage_drop / voltage)
return [voltage_drop, percent_voltage_drop]
def current_for_lookup(current,max_current): def current_for_lookup(current,max_current):
@ -176,14 +238,15 @@ def conductor_size(current, temp = 75, material = 'cu', code = 'CEC', raceway =
# Seclect the proper table # Seclect the proper table
if (code == 'CEC') & (material == 'CU') & (raceway == False): if (code == 'CEC'):
df = pd.DataFrame(cectable1, columns=['size', '60C', '75C', '90C']) import Tables.CEC21Tables
elif (code == 'CEC') & (material == 'CU') & (raceway == True):
df = pd.DataFrame(cectable2, columns=['size', '60C', '75C', '90C']) if (material == 'CU') & (raceway == False):
elif (code == 'CEC') & (material == 'AL') & (raceway == False): df = pd.DataFrame(cec21tables.table1, columns=['size', '60C', '75C', '90C'])
df = pd.DataFrame(cectable3, columns=['size', '60C', '75C', '90C'])
elif (code == 'CEC') & (material == 'AL') & (raceway == True): elif (material == 'CU') & (raceway == True):
df = pd.DataFrame(cectable4, columns=['size', '60C', '75C', '90C']) df = pd.DataFrame(cec21tables.table3, columns=['size', '60C', '75C', '90C'])
elif (code =='NEC') & (material =='CU'): elif (code =='NEC') & (material =='CU'):
return (' I haven\'t created this table yet') return (' I haven\'t created this table yet')
elif (code =='NEC') & (material =='AL'): elif (code =='NEC') & (material =='AL'):
@ -197,7 +260,7 @@ def conductor_size(current, temp = 75, material = 'cu', code = 'CEC', raceway =
''' '''
# Determine the ampacity of the max conductor size # Determine the ampacity of the max conductor size
max_df = df.loc[df['size'] == max,column] max_df = df.loc[df['size'] == max_wire,column]
max_current = max_df.item() max_current = max_df.item()
#print(max_current) #print(max_current)
@ -241,14 +304,15 @@ def conductor_ampacity(conductor, temp = 75, material = 'cu', code = 'CEC', race
else: else:
column = '60C' column = '60C'
if (code == 'CEC') & (material == 'CU') & (raceway == False): if (code == 'CEC') & (material == 'CU') & (raceway == False): # CEC Table 1
df = pd.DataFrame(cectable1, columns=['size', '60C', '75C', '90C']) df = pd.DataFrame(cec21tables.table1, columns=['size', '60C', '75C', '90C'])
elif (code == 'CEC') & (material == 'CU') & (raceway == True):
df = pd.DataFrame(cectable2, columns=['size', '60C', '75C', '90C']) elif (code == 'CEC') & (material == 'CU') & (raceway == True): # CEC Table 2
elif (code == 'CEC') & (material == 'AL') & (raceway == False): df = pd.DataFrame(cec21tables.table2, columns=['size', '60C', '75C', '90C'])
df = pd.DataFrame(cectable3, columns=['size', '60C', '75C', '90C'])
elif (code == 'CEC') & (material == 'AL') & (raceway == True): elif (code =='CEC') & (material =='AL') & (raceway == False): # CEC Table 3
df = pd.DataFrame(cectable4, columns=['size', '60C', '75C', '90C']) df = pd.DataFrame(cec21tables.table3, columns=['size', '60C', '75C', '90C'])
elif (code =='NEC') & (material =='CU'): elif (code =='NEC') & (material =='CU'):
return (' I haven\'t created this table yet') return (' I haven\'t created this table yet')
elif (code =='NEC') & (material =='AL'): elif (code =='NEC') & (material =='AL'):
@ -263,9 +327,10 @@ def conductor_ampacity(conductor, temp = 75, material = 'cu', code = 'CEC', race
return conductor_ampacity return conductor_ampacity
def bonding_conductor(conductor_ampacity,bus=False,material='cu',code = 'CEC'):
''' '''
This function calculates the bonding wire or bus based on the circuit ampacity. This function
''' '''
@ -277,69 +342,43 @@ def conductor_ampacity(conductor, temp = 75, material = 'cu', code = 'CEC', race
'AL', 'AL',
] ]
# Select the correct table if (material == 'CU') & (bus == False):
if code == 'CEC': db_index = 1
table16headers = cectable16[0] elif (material == 'AL') & (bus == False):
table16rows = cectable16[1:] db_index = 3
df = pd.DataFrame(table16rows, columns=table16headers) elif (material == 'CU') & (bus == True):
db_index = 2
elif (material == 'AL') & (bus == True):
db_index = 4
else: else:
return ('The variables were\'t right, but I\'m a loss to why.') return ('The variables were\'t right, but I\'m a loss to why.')
# Select the correct column if (code == 'CEC'):
try:
with sqlite3.connect("jepl-cec21.db") as con:
cur = con.cursor()
cur.execute('SELECT * FROM "Table16" WHERE "current" >= ? ', (conductor_ampacity,))
bond_result = cur.fetchone()
bond_size = bond_result[db_index]
except sqlite3.OperationalError as e:
print(e)
if material == 'CU' and bus == False:
column = 'copper wire'
elif material == 'CU' and bus == True:
column = 'copper bus'
elif material == 'AL' and bus == False:
column = 'aluminum wire'
elif material == 'AL' and bus == True:
column = 'caluminum bus'
else: else:
return ('Can\'t calculate K factor') return ('The variables were\'t right, but I\'m a loss to why.')
# Calculate the absolute difference for all values and find the index of the minimum difference
sectioned_df = df.loc[df['current'] >= conductor_ampacity,'current']
closest_index = sectioned_df.idxmin()
# Retrieve the nearest value using the found index
bond_size = df[column].iloc[closest_index]
return bond_size return bond_size
## This doesn't work yet, but its getting ## This doesn't work yet, but its getting
def conduit_size(num_cc,cc_con,bond,insulation="RW90", voltage = 1000, jacketed = False,material='SCH80', code = 'CEC'): def conduit_size(num_cc,cc_con,bond,material='SCH80'):
'''
Calculated the necessary conduit size for the circuit using code tables.
num_cc = The number of current carrying conductors, including neutral.
cc_con = The current carrying conductor size
bond = The bond size
insulation = The insulation class of the conductors.
voltage = The voltage rating of the insulation, typically 600 or 1000 [V].
jacketed = Whether or not the conductor is jacketed, typically this is false.
material = The material of the conduit. The default is SCH80 as it is the "worse case" in most configurations as it has a high difference from trade size to inner diameter.
code = CEC or NEC, although NEC is lagging in the development front at the moment, so stick with CEC.
The calculation is completed in the following steps: # Calculate fill requirements based on Table 8
1. Check to make sure the variables are valid.
2. Determine the percent fill limitation based on the number of current carrying conductors.
3. Look up the outer diameter of the conductors and bond. Calculate the total area.
4. Look up the trade size conduit, of the correct material, that meets the requirements.
5. Return the trade size, inner diameter and "result name".
'''
valid_insulation = ['R90',
'RW90',
'RPV90',
'RW75'
]
valid_voltage = [600,1000]
valid_material = ['RMC', # Rigid Metal Conduit valid_material = ['RMC', # Rigid Metal Conduit
'FMC', # Flexible Metal Conduit 'FMC', # Flexible Metal Conduit
'RPVC', # Rigid PVC 'RPVC', # Rigid PVC
'EB1', # Type EB1
'DB2', # Type DB2 'DB2', # Type DB2
'LTMC', # Liquid Tight Metal Conduit 'LTMC', # Liquid Tight Metal Conduit
'LTNMC', # Liquid Tight non-metallic conduit 'LTNMC', # Liquid Tight non-metallic conduit
@ -347,34 +386,20 @@ def conduit_size(num_cc,cc_con,bond,insulation="RW90", voltage = 1000, jacketed
'ENT', # electrical non-metallic tubing 'ENT', # electrical non-metallic tubing
'SCH40', # HDPE Schedule 40 'SCH40', # HDPE Schedule 40
'SCH80', # HDPE Schedule 80 'SCH80', # HDPE Schedule 80
'DR9', # HDPE DR9 #'DR9', # HDPE DR9
'DR11', # HDPE DR11 #'DR11', # HDPE DR11
'DR13', # HDPE DR13.5 #'DR135', # HDPE DR13.5
'DR15' # HDPE DR15.5 #'DR155' # HDPE DR15.5
]
valid_code = ['CEC',
# 'NEC' - NEC isn't completed yet.
] ]
if insulation not in valid_insulation:
return print(insulation + " is not valid.")
if voltage not in valid_voltage:
return print(voltage + " is not valid.")
if material not in valid_material: if material not in valid_material:
return print(material + " is not a valid material. It should be in " + valid_material) return print(material + " is not a valid material. I should be 'al' or 'cu'.")
if code not in valid_code: import numpy as np
return print(code + " is not valid.") x = np.array(valid_material)
db_result_index = np.where(x == material)[0][0]
cc_con = str(cc_con)
bond = str(bond)
#
# Determine the maximum conduit fill
#
if num_cc == 1: if num_cc == 1:
percent_fill = 0.53 percent_fill = 0.53
@ -383,72 +408,82 @@ def conduit_size(num_cc,cc_con,bond,insulation="RW90", voltage = 1000, jacketed
else: else:
percent_fill = 0.4 percent_fill = 0.4
# # Wire Size and diameter
# Find the conductor area
#
# This will be modified/added to when all the Table 6's are added. Currently there are only A-C, wire_size = [
if jacketed == True: # ['tradesize',area mm^2]
table6 = cec24table6C ['14',2.08],
elif voltage == 600: ['12',3.31],
table6 = cec24table6A ['10',5.26],
elif voltage == 1000: ['8',8.37],
table6 = cec24table6B ['6',13.3],
else: ['4',21.2],
return print("error") ['3',26.7],
['2',33.6],
['1',42.4],
['1/0',53.5],
['2/0',67.4],
['3/0',85],
['4/0',107],
['250',127],
['300',152],
['350',177],
['400',203],
['500',253],
['600',304],
['700',355],
['800',405],
['900',456],
['1000',507],
['1250',633],
['1500',760],
['1750',887],
['2000',1010]
]
table6headers = table6[0] # Calculate the area of current carrying conductors
table6rows = table6[1:]
conductor_diameter = pd.DataFrame(table6rows,columns= table6headers)
#print(conductor_diameter)
cc_dia = conductor_diameter.loc[(conductor_diameter['size'] == cc_con) ]['diameter'].iloc[0] x = np.array(wire_size)
#print(cc_dia) row = np.where(x == cc_con)[0][0]
bond_dia = conductor_diameter.loc[(conductor_diameter['size'] == bond) ]['diameter'].iloc[0] current_carrying_conductor_area = wire_size[row][1]
cc_area = current_carrying_conductor_area * num_cc
#print(bond_dia) # Bond Area
cc_area = math.pi * (cc_dia/2) ** 2 row = np.where(x == bond)[0][0]
#print(cc_area) bond_area = wire_size[row][1]
bond_area = math.pi * (bond_dia/2) ** 2
#print(bond_area)
# Total conductor area # Total conductor area
area_conductors = num_cc * cc_area + bond_area area_conductors = cc_area + bond_area
#print(area_conductors) #print(area_conductors)
min_trade_area = area_conductors / percent_fill # The minimum area of the conduit min_trade_area = area_conductors / percent_fill # The minimum area of the conduit
#print(min_trade_area) #print(min_trade_area)
trade_inner_dia = math.sqrt(min_trade_area/math.pi) * 2
#print(trade_inner_dia) parameter = ' WHERE ' + material + ' > ' + str(min_trade_area)
try:
with sqlite3.connect("jepl-cec21.db") as con:
cur = con.cursor()
cur.execute('SELECT "Trade Size" from "Table9"'+ parameter )
table = cur.fetchone()
conduit = table
except sqlite3.OperationalError as e:
print(e)
# result_raw = conduit[0]
# Select the conduit trade size result_name = str(conduit[0]) + 'mm ' + material
#
conduit_table = pd.DataFrame(cec24table9AB[1:], columns=cec24table9AB[0]) return result_raw,result_name
#print(conduit_table)
# Calculate the absolute difference for all values and find the index of the minimum difference
sectioned_df = conduit_table.loc[conduit_table[material] >= trade_inner_dia,material]
closest_index = sectioned_df.idxmin()
# Retrieve the nearest value using the found index
result_raw = conduit_table['size'].iloc[closest_index]
result_name = result_raw + 'mm ' + material
# Get the new inner diameter
result_inner_dia = conduit_table[material].iloc[closest_index]
result_inner_area = math.pi * (result_inner_dia/2) ** 2
resulting_percent_fill = area_conductors / result_inner_area
return result_raw,result_name,result_inner_dia,resulting_percent_fill
def cable_schedule_naming(conductor_size,conductors,runs = 1,bond='BOND'): def cable_schedule_naming(conductor_size,conductors,runs = 1,bond='BOND'):

View file

@ -10,12 +10,11 @@ Some General Functions and things
import pandas as pd import pandas as pd
import numpy as np import numpy as np
import math import math
#import sqlite3 import sqlite3
def va(voltage, current,phases=3): def va(voltage, current,phases=3):
''' '''Calculate the Volt-Amp of a circuit
Calculate the Volt-Amp of a circuit
''' '''
if phases == 3: if phases == 3:
@ -28,22 +27,4 @@ def va(voltage, current,phases=3):
return va return va
def xfmr_sc(kva, voltage, impedance, phases = 3):
'''
Calculate the maximum let-through current of a transformer.
Isc = resulant short circuit
kva = kilo-voltamps
impednace in %Z
Assume 3 phase, but calculate single phase if its selected
'''
if phases == 1:
Isc = (kva * 1000) / (voltage * (impedance / 100))
else:
Isc = (kva * 1000) / (math.sqrt(3) * voltage * (impedance / 100))
return Isc

View file

@ -1,43 +0,0 @@
'''
JMK Engineering Inc. Python Library for design and such.
by: Jeff MacKinnon
email: jeff@jmkengineering.com
'''
#
# Import all the table files. This is for both NEC and CEC and all of the years that we may need.
#
from .Tables.CEC21Tables import *
from .Tables.CEC24Tables import *
#
# Set the default tables for CEC and NEC.
#
'''
This will also allow you to change the table on a case-by-case basis.
Ideally we will be able to select the code year as an option in the future.
'''
cectable1 = cec21table1
cectable2 = cec21table2
cectable3 = cec21table3
cectable4 = cec21table4
cectable16 = cec21table16
# Appendix Tables
cectableD3 = cec24tableD3
#print(cec21table1)
def Test():
print( "JMK Python Module works! !")

74
jepl/jeplinit.py Normal file
View file

@ -0,0 +1,74 @@
import pandas as pd
import sys
import sqlite3
'''
When this init file is used for projects, the location should be passed as an argument, similar to:
%run jeplinit.py resources/JEPL/jepl/
If there is no argument, we assume that it is part of development and we will use the root folder.
'''
location = ''
if sys.argv[1]:
location = sys.argv[1] # This needs to be passed if its not the same as the location of jepl.py
'''
The functions used in the initialization
'''
def insert(database,table,data):
'''
This function creates a database from the current
source data to be used in the modules.
Running this function will replace any data that is already in the database.
'''
conn = sqlite3.connect(database)
data.to_sql(table, conn, if_exists='replace', index=False)
conn.close()
def create_database(name,tables):
'''
This function loops over the source data lists to create tables in the database.
'''
for i in range(len(tables)):
db = tables[i][0]
table = tables[i][1]
source = tables[i][2]
data = pd.read_csv(source)
insert(db,table,data) # Call the database insert function to add the data
'''
This is all the tables and their sources that will be added to the databases.
'''
CEC21_database = [
['jepl-cec21.db','Table1',location+'Tables/CEC-Tables/CEC21-table1.csv'],
['jepl-cec21.db','Table2',location+'Tables/CEC-Tables/CEC21-table2.csv'],
['jepl-cec21.db','Table3',location+'Tables/CEC-Tables/CEC21-table3.csv'],
['jepl-cec21.db','Table4',location+'Tables/CEC-Tables/CEC21-table4.csv'],
['jepl-cec21.db','Table9',location+'Tables/CEC-Tables/CEC21-table9.csv'],
['jepl-cec21.db','Table16',location+'Tables/CEC-Tables/CEC21-table16.csv'],
]
create_database('jepl-cec21.db',CEC21_database)
Z46215_database = [
['jepl-z46215.db','Table1A',location+'Tables/Z462-Tables/Z46215-table1A.csv'],
['jepl-z46215.db','Table1B',location+'Tables/Z462-Tables/Z46215-table1B.csv'],
]
create_database('jepl-z46215.db',Z46215_database)
cable_database = [
['jepl-cable.db','SW-Spec 25055',location+'Tables/Manufacturer/SW-Spec-25055.csv'],
['jepl-cable.db','SW-Spec 25051',location+'Tables/Manufacturer/SW-Spec-25051.csv'],
]
create_database('jepl-cable.db',cable_database)

262
tools.py
View file

@ -30,187 +30,11 @@ def va(args):
else: else:
print(args.phases) print(args.phases)
def xfmr_sc(args):
if args.phases == None:
phases = 3
elif arg.phases == 1:
phases = 1
else:
phases = 3
#print(args.kva)
#print(args.voltage)
#print(args.impedance)
result = jmk.xfmr_sc(args.kva, args.voltage, args.impedance, phases = phases)
print(result)
# Circuits
def condsize(args):
if args.temp == None:
temp = 60
else:
temp = args.temp
if args.material == None:
material = 'cu'
else:
material = args.material
if args.code == None:
code = 'CEC'
else:
code = args.code
if args.raceway == None:
raceway = True
elif args.raceway == 'n':
raceway = False
else:
raceway = True
if args.ambient == None:
ambient = 30
else:
ambient = args.ambient
if args.maxsize == None:
maxsize = 500
else:
maxsize = 500
if args.type == None:
loadtype = None
else:
valid_load_type = ['normal','xfmr','xfmrp','xfmrs','motor',None]
if args.type not in valid_load_type:
print(args.type + " is not a valid load_type.")
else:
loadtype = args.type
result = jmk.conductor_size(args.current, temp = temp, material = material, code = code, raceway = raceway, max = maxsize, load_type = loadtype )
print(result)
def condamp(args):
if args.temp == None:
temp = 60
else:
temp = args.temp
if args.material == None:
material = 'cu'
else:
material = args.material
if args.code == None:
code = 'CEC'
else:
code = args.code
if args.raceway == None:
raceway = True
elif args.raceway == 'n':
raceway = False
else:
raceway = True
if args.ambient == None:
ambient = 30
else:
ambient = args.ambient
result = jmk.conductor_ampacity(args.conductor, temp = temp, material = material, code = code, raceway = raceway)
print(result)
def bonding(args):
if args.material == None:
material = 'cu'
else:
material = args.material
if args.code == None:
code = 'CEC'
else:
code = args.code
if args.bus == None:
bus = False
else:
bus = args.bus
result = jmk.bonding_conductor(args.circuit_ampacity, bus = bus, material = material, code = code)
print(result)
def voltagedrop(args):
voltage = args.voltage
current = args.current
size = args.conductor_size
length = args.length
if args.phases == None:
num_phase = 3
elif args.phases == '1':
num_phase = 1
elif args.phases == '3':
num_phase = 3
else:
print('--phase must be 1 or 2.')
if args.material == None:
material = 'cu'
else:
material = args.material
if args.runs == None:
num_runs = 1
else:
num_runs = args.runs
if args.runs == None:
num_runs = 1
else:
num_runs = args.runs
if args.code == None:
code = 'CEC'
else:
code = args.code
if args.powerfactor == None:
power_factor = 'dc'
else:
power_factor = args.powerfactor
if args.raceway == None:
raceway = True
elif args.raceway == 'n':
raceway = False
else:
raceway = True
if args.temp == None:
insul_temp = 75
else:
insul_temp = args.temp
result = jmk.voltage_drop(voltage, current, size, length, num_phase = num_phase, material = material, num_runs = num_runs, code = code, power_factor = power_factor, raceway = raceway, insul_temp = insul_temp)
print(result)
def conduit_size(args):
if args.insulation == None:
insulation = "RW90"
else:
insulation = args.insulation
if args.voltage == None:
voltage = 1000
else:
voltage = args.voltage
if args.jacketed == None:
jacketed = False
else:
jacketed = args.jacketed
if args.material == None:
material = 'SCH80'
else:
material = args.material
if args.code == None:
code = 'CEC'
else:
code = args.code
result = jmk.conduit_size(args.num_conductors,args.size,args.bond,insulation=insulation, voltage = voltage, jacketed = jacketed,material=material, code = code)
percent_fill = str(round(result[3],2) * 100) + "%" + " fill."
print(percent_fill,result[1])
# Solar # Solar
def temp_adj_Voc(args): def temp_adj_Voc(args):
if args.beta == None: if args.beta == None:
beta = -0.5 beta = -0.5
@ -231,8 +55,7 @@ def temp_adj_Voc(args):
try: try:
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers( subparsers = parser.add_subparsers(
title="tools", title="tools", help="Commandline Functions"
help="Commandline Functions"
) )
# #
@ -248,80 +71,6 @@ try:
va_parser.set_defaults(func=va) va_parser.set_defaults(func=va)
# Calcuating xfmr_sc
xfmrsc_parser = subparsers.add_parser("xfmr_sc", help="Calculates the secondary short circuit current of a transformer")
xfmrsc_parser.add_argument("voltage", type=float,help="Voltage of the circuit")
xfmrsc_parser.add_argument("kva", type=float,help="Transformer rating in kVA.")
xfmrsc_parser.add_argument("impedance", type=float,help="Transformer impedance in percent Z.")
xfmrsc_parser.add_argument("-p","--phases", type=int,help="Phases of the circuit. It should be either 1 or 3, and we will assume 3 if it is not used.")
xfmrsc_parser.set_defaults(func=xfmr_sc)
#
# Circuit Tools
#
condsize_parser = subparsers.add_parser("condsize", help="Determine the conductor size for a defined current and load type.")
condsize_parser.add_argument("current", type=float, help="The current of the circuit.")
condsize_parser.add_argument("-t", "--temp", type=int, help="The temperature rating for the insulation, if none included is 60C. default: 60" )
condsize_parser.add_argument("-m", "--material", type=str, help="This should be cu or al, for copper or aluminum. If none defined cu will be used.")
condsize_parser.add_argument("-c", "--code", type=str, help="Currently this will either be CEC or NEC. default CEC")
condsize_parser.add_argument("-r", "--raceway", type=str, help="If the conductors are in a raceway use y for yes and n for no.")
condsize_parser.add_argument("-a", "--ambient", type=float, help="Ambient temperature in celsious. default: 30")
condsize_parser.add_argument("-x", "--maxsize", type=str, help="Maximum conductor size in AWG/kcmil. default: 500")
condsize_parser.add_argument("--type",type=str, help="Load type {}'normal','xfmr','xfmrp','xfmrs','motor',None}, default: None")
condsize_parser.set_defaults(func=condsize)
condamp_parser = subparsers.add_parser("condamp", help="Determine the ampacity of a conductor.")
condamp_parser.add_argument("conductor", type=str, help="The conductor size in AWG/kcmil")
condamp_parser.add_argument("-t", "--temp", type=int, help="The temperature rating for the insulation, if none included is 60C. default: 60" )
condamp_parser.add_argument("-m", "--material", type=str, help="This should be cu or al, for copper or aluminum. If none defined cu will be used.")
condamp_parser.add_argument("-c", "--code", type=str, help="Currently this will either be CEC or NEC. default CEC")
condamp_parser.add_argument("-r", "--raceway", type=str, help="If the conductors are in a raceway use y for yes and n for no.")
condamp_parser.add_argument("-a", "--ambient", type=float, help="Ambient temperature in celsious. default: 30")
condamp_parser.set_defaults(func=condamp)
bonding_parser = subparsers.add_parser("bonding", help="Bonding conductor for the circuit, wire or bus.")
bonding_parser.add_argument("circuit_ampacity", type=float, help="Circuit ampacity.")
bonding_parser.add_argument("-m", "--material", type=str, help="This should be cu or al, for copper or aluminum. If none defined cu will be used.")
bonding_parser.add_argument("-c", "--code", type=str, help="Currently this will either be CEC or NEC. default CEC")
bonding_parser.add_argument("-b", "--bus", type=bool, help="Bus or wire bond, bus =True, wire = False.")
bonding_parser.set_defaults(func=bonding)
voltagedrop_parser = subparsers.add_parser("voltagedrop", help="Determine the voltage drop of a circuit.")
voltagedrop_parser.add_argument("voltage", type=float, help="The circuit voltage.")
voltagedrop_parser.add_argument("current", type=float, help="The circuit current")
voltagedrop_parser.add_argument("conductor_size", type=str, help="The conductor size.")
voltagedrop_parser.add_argument("length", type=float, help="The circuit length, in metres.")
voltagedrop_parser.add_argument("-t", "--temp", type=int, help="The temperature rating for the insulation, if none included is 60C. default: 75" )
voltagedrop_parser.add_argument("-m", "--material", type=str, help="This should be cu or al, for copper or aluminum. If none defined cu will be used.")
voltagedrop_parser.add_argument("-c", "--code", type=str, help="Currently this will either be CEC or NEC. default CEC")
voltagedrop_parser.add_argument("-r", "--raceway", type=str, help="If the conductors are in a raceway use y for yes and n for no.")
voltagedrop_parser.add_argument("-pf","--powerfactor", type=str, help="Power Factor. Valid options DC, 1, 0.9, 0.8. default dc")
voltagedrop_parser.add_argument("--phases", type=str, help="Number of phases, 1 or 3, default = 3.")
voltagedrop_parser.add_argument("--runs", type=int, help="Number of circuits in parallel, default 1.")
voltagedrop_parser.set_defaults(func=voltagedrop)
consize_parser = subparsers.add_parser("conduitsize", help="Calculate the proper conduit size.")
consize_parser.add_argument("num_conductors", type=int, help="Number of current carrying conductors, typically 1 to 4.")
consize_parser.add_argument("size", type=str, help="Size of the current carrying conductors in AWG or kcmil." )
consize_parser.add_argument("bond", type=str, help="Size of the bond conductor, or equipment grounding conductor in AWG or kcmil")
consize_parser.add_argument("-i", "--insulation", type=str, help="Insulation type. default RW90")
consize_parser.add_argument("-v", "--voltage", type=int, help="Voltage rating of the insulation, 600 or 1000")
consize_parser.add_argument("-j", "--jacketed", type=bool, help="Are the conductors jacketed? Default: False")
consize_parser.add_argument("-m", "--material", type=str, help="Material or conduit type, ie EMT, ENT, SCH40, etc. Default SCH80")
consize_parser.add_argument("-c", "--code", type=str, help="Currently this will either be CEC or NEC. default CEC")
consize_parser.set_defaults(func=conduit_size)
# #
# Solar Tools # Solar Tools
# #
@ -344,3 +93,8 @@ try:
except argparse.ArgumentError as e: except argparse.ArgumentError as e:
#log.error("Error parsing arguments") #log.error("Error parsing arguments")
raise e raise e
#else:
# print(f"Something clever")