From 9c8521763cbd41921c686cb04ceb1165d2a8e729 Mon Sep 17 00:00:00 2001 From: Jeff Date: Sun, 4 Jan 2026 23:24:38 -0400 Subject: [PATCH] Added transformer shortcircuit let-though calc. --- jepl/Tables/CEC-Tables/CEC21-table1.csv | 28 --------- jepl/Tables/CEC-Tables/CEC21-table16.csv | 20 ------- jepl/Tables/CEC-Tables/CEC21-table2.csv | 29 ---------- jepl/Tables/CEC-Tables/CEC21-table3.csv | 27 --------- jepl/Tables/CEC-Tables/CEC21-table4.csv | 28 --------- jepl/Tables/CEC-Tables/CEC21-table9.csv | 15 ----- jepl/jepl_general.py | 24 +++++++- jepl/jeplinit.py | 74 ------------------------ tools.py | 26 ++++++++- 9 files changed, 46 insertions(+), 225 deletions(-) delete mode 100644 jepl/Tables/CEC-Tables/CEC21-table1.csv delete mode 100644 jepl/Tables/CEC-Tables/CEC21-table16.csv delete mode 100644 jepl/Tables/CEC-Tables/CEC21-table2.csv delete mode 100644 jepl/Tables/CEC-Tables/CEC21-table3.csv delete mode 100644 jepl/Tables/CEC-Tables/CEC21-table4.csv delete mode 100644 jepl/Tables/CEC-Tables/CEC21-table9.csv delete mode 100644 jepl/jeplinit.py diff --git a/jepl/Tables/CEC-Tables/CEC21-table1.csv b/jepl/Tables/CEC-Tables/CEC21-table1.csv deleted file mode 100644 index 654c30d..0000000 --- a/jepl/Tables/CEC-Tables/CEC21-table1.csv +++ /dev/null @@ -1,28 +0,0 @@ -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 diff --git a/jepl/Tables/CEC-Tables/CEC21-table16.csv b/jepl/Tables/CEC-Tables/CEC21-table16.csv deleted file mode 100644 index 02d8a86..0000000 --- a/jepl/Tables/CEC-Tables/CEC21-table16.csv +++ /dev/null @@ -1,20 +0,0 @@ -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 diff --git a/jepl/Tables/CEC-Tables/CEC21-table2.csv b/jepl/Tables/CEC-Tables/CEC21-table2.csv deleted file mode 100644 index 6306941..0000000 --- a/jepl/Tables/CEC-Tables/CEC21-table2.csv +++ /dev/null @@ -1,29 +0,0 @@ -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 diff --git a/jepl/Tables/CEC-Tables/CEC21-table3.csv b/jepl/Tables/CEC-Tables/CEC21-table3.csv deleted file mode 100644 index f08fff0..0000000 --- a/jepl/Tables/CEC-Tables/CEC21-table3.csv +++ /dev/null @@ -1,27 +0,0 @@ -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 diff --git a/jepl/Tables/CEC-Tables/CEC21-table4.csv b/jepl/Tables/CEC-Tables/CEC21-table4.csv deleted file mode 100644 index 11c35f0..0000000 --- a/jepl/Tables/CEC-Tables/CEC21-table4.csv +++ /dev/null @@ -1,28 +0,0 @@ -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 diff --git a/jepl/Tables/CEC-Tables/CEC21-table9.csv b/jepl/Tables/CEC-Tables/CEC21-table9.csv deleted file mode 100644 index baeb9ef..0000000 --- a/jepl/Tables/CEC-Tables/CEC21-table9.csv +++ /dev/null @@ -1,15 +0,0 @@ -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, diff --git a/jepl/jepl_general.py b/jepl/jepl_general.py index 02092ba..baba347 100644 --- a/jepl/jepl_general.py +++ b/jepl/jepl_general.py @@ -10,11 +10,12 @@ Some General Functions and things import pandas as pd import numpy as np import math -import sqlite3 +#import sqlite3 def va(voltage, current,phases=3): - '''Calculate the Volt-Amp of a circuit + ''' + Calculate the Volt-Amp of a circuit ''' if phases == 3: @@ -27,4 +28,23 @@ def va(voltage, current,phases=3): return va +def xfmr_sc(kva, voltage, impedance, phases = 3): + '''i + 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 diff --git a/jepl/jeplinit.py b/jepl/jeplinit.py deleted file mode 100644 index c663892..0000000 --- a/jepl/jeplinit.py +++ /dev/null @@ -1,74 +0,0 @@ -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) - diff --git a/tools.py b/tools.py index b7c39e6..15d314c 100644 --- a/tools.py +++ b/tools.py @@ -30,6 +30,21 @@ def va(args): else: 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 @@ -157,8 +172,6 @@ def voltagedrop(args): raceway = False else: raceway = True - - if args.temp == None: insul_temp = 75 @@ -207,6 +220,15 @@ try: 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 #