Added cable schedule naming and general tidying.

This commit is contained in:
Jeff MacKinnon 2024-12-19 10:09:04 -04:00
parent 97d1f4e58c
commit 0bfc55c880

View file

@ -35,7 +35,7 @@ def percentvd(vd,nominal):
return percent return percent
def voltage_drop(nominal_voltage, current, conductor_size, material ='cu', num_runs = 1, code = 'CEC'): 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.
@ -87,7 +87,7 @@ def voltage_drop(nominal_voltage, current, conductor_size, material ='cu', num_r
else: else:
return (print("error, choose material as cu or al")) return (print("error, choose material as cu or al"))
voltage = vd(nominal_voltage,current,resistance,num_runs) voltage = vd(current,length,resistance,num_runs)
percent = percentvd(voltage,nominal_voltage) percent = percentvd(voltage,nominal_voltage)
return [voltage, percent] return [voltage, percent]
@ -149,7 +149,7 @@ def voltage_drop_conductors(voltage,current,distance,v_drop_percent = 0.03,runs
with sqlite3.connect("jepl-cable.db") as con: with sqlite3.connect("jepl-cable.db") as con:
cur = con.cursor() cur = con.cursor()
cur.execute('SELECT "Conductor Size" FROM "SW-Spec 25055" WHERE "Conductor Number" = 3 AND "AC Resistance"<?', (resistivity,)) cur.execute('SELECT "Conductor Size" FROM "SW-Spec 25055" WHERE "Conductor Number" = 3 AND "AC Resistance"<?', (resistivity,))
conductor = cur.fetchone()[0] conductor = str(cur.fetchone()[0])
#print(conductor) #print(conductor)
@ -161,7 +161,7 @@ def voltage_drop_conductors(voltage,current,distance,v_drop_percent = 0.03,runs
with sqlite3.connect("jepl-cable.db") as con: with sqlite3.connect("jepl-cable.db") as con:
cur = con.cursor() cur = con.cursor()
cur.execute('SELECT "Conductor Size" FROM "SW-Spec 25051" WHERE "Conductor Number" = 3 AND "AC Resistance"<?', (resistivity,)) cur.execute('SELECT "Conductor Size" FROM "SW-Spec 25051" WHERE "Conductor Number" = 3 AND "AC Resistance"<?', (resistivity,))
conductor = cur.fetchone()[0] conductor = str(cur.fetchone()[0])
#print(conductor) #print(conductor)
@ -188,7 +188,7 @@ def current_for_lookup(current,max_current):
return (con_current,num_parallel) return (con_current,num_parallel)
def conductor_size(current, temp = 75, material = 'cu', code = 'CEC', raceway = True, ambient = 30, max = 500): def conductor_size(current, temp = 75, material = 'cu', code = 'CEC', raceway = True, ambient = 30, max = 500, load_type = None):
''' '''
The default temp column will be the 75C column as most terminals are rated for this. The default temp column will be the 75C column as most terminals are rated for this.
@ -197,7 +197,6 @@ def conductor_size(current, temp = 75, material = 'cu', code = 'CEC', raceway =
I still need to incorporate ambient temperature deratings, but that will be a future improvement I still need to incorporate ambient temperature deratings, but that will be a future improvement
''' '''
material = material.upper() material = material.upper()
code = code.upper() code = code.upper()
max = str(max) max = str(max)
@ -208,6 +207,8 @@ def conductor_size(current, temp = 75, material = 'cu', code = 'CEC', raceway =
valid_material = ['CU', valid_material = ['CU',
'AL', 'AL',
] ]
valid_load_type = ['normal','xfmr','xfmrp','xfmrs','motor',None]
#check to make sure that the values are valid #check to make sure that the values are valid
if temp not in valid_temp: if temp not in valid_temp:
@ -216,6 +217,8 @@ def conductor_size(current, temp = 75, material = 'cu', code = 'CEC', raceway =
return print(code + " is not a valid code. The valid codes are "+ str(valid_code)) return print(code + " is not a valid code. The valid codes are "+ str(valid_code))
if material not in valid_material: if material not in valid_material:
return print(material + " is not a valid material. I should be 'al' or 'cu'.") return print(material + " is not a valid material. I should be 'al' or 'cu'.")
if load_type not in valid_load_type:
return print(load_type + " is not a valid load_type.")
if temp == 90: if temp == 90:
conductor_current_index = 3 conductor_current_index = 3
@ -225,6 +228,13 @@ def conductor_size(current, temp = 75, material = 'cu', code = 'CEC', raceway =
conductor_current_index = 1 conductor_current_index = 1
'''
Per CEC rules 26-256 and 28-106 Transformer and Motor conductors should be sized 125% of the rated current.
'''
list_125 = ['xfmr','xfmrp','xfmrs', 'motor']
if load_type in list_125:
current = 1.25 * current
# select the correct code table # select the correct code table
if (code == 'CEC') & (material == 'CU') & (raceway == False): # CEC Table 1 if (code == 'CEC') & (material == 'CU') & (raceway == False): # CEC Table 1
try: try:
@ -351,7 +361,7 @@ def conductor_size(current, temp = 75, material = 'cu', code = 'CEC', raceway =
else: else:
cur.execute('SELECT size FROM "Table4" WHERE "60" > ? ', (current,)) cur.execute('SELECT size FROM "Table4" WHERE "60" > ? ', (current,))
conductor_size = cur.fetchone()[0] conductor_size = str(cur.fetchone()[0])
#print(conductor_size) #print(conductor_size)
@ -367,5 +377,29 @@ def conductor_size(current, temp = 75, material = 'cu', code = 'CEC', raceway =
return [conductor_size,num_parallel] return [conductor_size,num_parallel]
def cable_schedule_naming(conductor_size,conductors,runs = 1,bond='BOND'):
'''
Converts the conductor size from the above functions to something that can be added to a database/schedule.
'''
if conductor_size == '1/0' or conductor_size == '2/0' or conductor_size == '3/0' or conductor_size == '4/0':
unit = "AWG"
elif int(conductor_size) > 24:
unit = 'kcmil'
else:
unit = 'AWG'
if bond == 'BOND':
bondtext = bond
elif int(bond_size) > 24:
bondtext = '#' + str(bond) + 'kcmil'
else:
bondtext = '#' + str(bond) + 'AWG'
if runs > 1:
cable_text = str(runs) + "x " + str(conductors) + "C #" + str(conductor_size) + unit + " + " + bondtext
else:
cable_text = str(conductors) + "C #" + str(conductor_size) + unit + " + " + bondtext
return cable_text