From d5ebf99124c33a45389e587c6df8d9d6d3e819a9 Mon Sep 17 00:00:00 2001 From: Jeff Date: Mon, 5 Jan 2026 21:12:27 -0400 Subject: [PATCH] Adding conduit sizing to commandline tools. --- jepl/jepl_circuits.py | 19 ++++++++++-------- jepl/jepl_general.py | 3 +-- tools.py | 46 +++++++++++++++++++++++++++++++++++++------ 3 files changed, 52 insertions(+), 16 deletions(-) diff --git a/jepl/jepl_circuits.py b/jepl/jepl_circuits.py index 2f7ce4a..9d3f8d0 100644 --- a/jepl/jepl_circuits.py +++ b/jepl/jepl_circuits.py @@ -404,28 +404,28 @@ def conduit_size(num_cc,cc_con,bond,insulation="RW90", voltage = 1000, jacketed #print(conductor_diameter) cc_dia = conductor_diameter.loc[(conductor_diameter['size'] == cc_con) ]['diameter'].iloc[0] - print(cc_dia) + #print(cc_dia) bond_dia = conductor_diameter.loc[(conductor_diameter['size'] == bond) ]['diameter'].iloc[0] - print(bond_dia) + #print(bond_dia) cc_area = math.pi * (cc_dia/2) ** 2 - print(cc_area) + #print(cc_area) bond_area = math.pi * (bond_dia/2) ** 2 - print(bond_area) + #print(bond_area) # Total conductor area area_conductors = num_cc * cc_area + bond_area - print(area_conductors) + #print(area_conductors) 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) + #print(trade_inner_dia) @@ -443,10 +443,13 @@ def conduit_size(num_cc,cc_con,bond,insulation="RW90", voltage = 1000, jacketed # 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 + return result_raw,result_name,result_inner_dia,resulting_percent_fill diff --git a/jepl/jepl_general.py b/jepl/jepl_general.py index baba347..38fed7a 100644 --- a/jepl/jepl_general.py +++ b/jepl/jepl_general.py @@ -30,7 +30,7 @@ def va(voltage, current,phases=3): def xfmr_sc(kva, voltage, impedance, phases = 3): - '''i + ''' Calculate the maximum let-through current of a transformer. Isc = resulant short circuit @@ -46,5 +46,4 @@ def xfmr_sc(kva, voltage, impedance, phases = 3): else: Isc = (kva * 1000) / (math.sqrt(3) * voltage * (impedance / 100)) - return Isc diff --git a/tools.py b/tools.py index 15d314c..7356779 100644 --- a/tools.py +++ b/tools.py @@ -181,6 +181,34 @@ def voltagedrop(args): 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 def temp_adj_Voc(args): @@ -278,6 +306,17 @@ try: 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) + @@ -304,9 +343,4 @@ try: except argparse.ArgumentError as e: #log.error("Error parsing arguments") - raise e - - -#else: -# print(f"Something clever") - + raise e \ No newline at end of file