Updated conductor_size and conductor_ampacity, ready for merge
This commit is contained in:
parent
eb05de266a
commit
211a11a2f9
1 changed files with 41 additions and 186 deletions
|
|
@ -222,12 +222,11 @@ def conductor_size(current, temp = 75, material = 'cu', code = 'CEC', raceway =
|
||||||
return print(load_type + " is not a valid load_type.")
|
return print(load_type + " is not a valid load_type.")
|
||||||
|
|
||||||
if temp == 90:
|
if temp == 90:
|
||||||
conductor_current_index = 3
|
column = '90C'
|
||||||
elif temp == 75:
|
elif temp == 75:
|
||||||
conductor_current_index = 2
|
column = '75C'
|
||||||
else:
|
else:
|
||||||
conductor_current_index = 1
|
column = '60C'
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Per CEC rules 26-256 and 28-106 Transformer and Motor conductors should be sized 125% of the rated current.
|
Per CEC rules 26-256 and 28-106 Transformer and Motor conductors should be sized 125% of the rated current.
|
||||||
|
|
@ -236,156 +235,18 @@ def conductor_size(current, temp = 75, material = 'cu', code = 'CEC', raceway =
|
||||||
if load_type in list_125:
|
if load_type in list_125:
|
||||||
current = 1.25 * current
|
current = 1.25 * current
|
||||||
|
|
||||||
|
|
||||||
# Seclect the proper table
|
# Seclect the proper table
|
||||||
|
|
||||||
if (code == 'CEC'):
|
if (code == 'CEC'):
|
||||||
import Tables.CEC21Tables
|
import Tables.CEC21Tables
|
||||||
|
|
||||||
if (material == 'CU') & (raceway == False):
|
if (material == 'CU') & (raceway == False):
|
||||||
table = table1
|
df = pd.DataFrame(cec21tables.table1, columns=['size', '60C', '75C', '90C'])
|
||||||
|
|
||||||
|
|
||||||
elif (material == 'CU') & (raceway == True):
|
elif (material == 'CU') & (raceway == True):
|
||||||
table = table3
|
df = pd.DataFrame(cec21tables.table3, columns=['size', '60C', '75C', '90C'])
|
||||||
|
|
||||||
# Determine the ampacity of the max conductor size
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# select the correct code table
|
|
||||||
if (code == 'CEC'): # CEC Table 1
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
|
||||||
with sqlite3.connect("jepl-cec21.db") as con:
|
|
||||||
cur = con.cursor()
|
|
||||||
cur.execute('SELECT * FROM "Table1" WHERE "size" = ? ', (max,))
|
|
||||||
max_conductor_current = cur.fetchone()
|
|
||||||
max_current = max_conductor_current[conductor_current_index]
|
|
||||||
|
|
||||||
except sqlite3.OperationalError as e:
|
|
||||||
print(e)
|
|
||||||
|
|
||||||
current_lookup = current_for_lookup(current,max_current)
|
|
||||||
current = current_lookup[0]
|
|
||||||
num_parallel = current_lookup[1]
|
|
||||||
|
|
||||||
try:
|
|
||||||
with sqlite3.connect("jepl-cec21.db") as con:
|
|
||||||
cur = con.cursor()
|
|
||||||
if temp == 90:
|
|
||||||
cur.execute('SELECT size FROM "Table1" WHERE "90" > ? ', (current,))
|
|
||||||
|
|
||||||
elif temp ==75:
|
|
||||||
cur.execute('SELECT size FROM "Table1" WHERE "75" > ? ', (current,))
|
|
||||||
|
|
||||||
else:
|
|
||||||
cur.execute('SELECT size FROM "Table1" WHERE "60" > ? ', (current,))
|
|
||||||
conductor_size = cur.fetchone()[0]
|
|
||||||
|
|
||||||
#print(conductor_size)
|
|
||||||
|
|
||||||
except sqlite3.OperationalError as e:
|
|
||||||
print(e)
|
|
||||||
|
|
||||||
elif (code == 'CEC') & (material == 'CU') & (raceway == True): # CEC Table 2
|
|
||||||
try:
|
|
||||||
with sqlite3.connect("jepl-cec21.db") as con:
|
|
||||||
cur = con.cursor()
|
|
||||||
cur.execute('SELECT * FROM "Table2" WHERE "size" = ? ', (max,))
|
|
||||||
max_conductor_current = cur.fetchone()
|
|
||||||
max_current = max_conductor_current[conductor_current_index]
|
|
||||||
|
|
||||||
except sqlite3.OperationalError as e:
|
|
||||||
print(e)
|
|
||||||
|
|
||||||
current_lookup = current_for_lookup(current,max_current)
|
|
||||||
current = current_lookup[0]
|
|
||||||
num_parallel = current_lookup[1]
|
|
||||||
|
|
||||||
try:
|
|
||||||
with sqlite3.connect("jepl-cec21.db") as con:
|
|
||||||
cur = con.cursor()
|
|
||||||
if temp == 90:
|
|
||||||
cur.execute('SELECT size FROM "Table2" WHERE "90" > ? ', (current,))
|
|
||||||
|
|
||||||
elif temp ==75:
|
|
||||||
cur.execute('SELECT size FROM "Table2" WHERE "75" > ? ', (current,))
|
|
||||||
|
|
||||||
else:
|
|
||||||
cur.execute('SELECT size FROM "Table2" WHERE "60" > ? ', (current,))
|
|
||||||
conductor_size = cur.fetchone()[0]
|
|
||||||
|
|
||||||
#print(conductor_size)
|
|
||||||
|
|
||||||
except sqlite3.OperationalError as e:
|
|
||||||
print(e)
|
|
||||||
elif (code =='CEC') & (material =='AL') & (raceway == False): # CEC Table 3
|
|
||||||
try:
|
|
||||||
with sqlite3.connect("jepl-cec21.db") as con:
|
|
||||||
cur = con.cursor()
|
|
||||||
cur.execute('SELECT * FROM "Table3" WHERE "size" = ? ', (max,))
|
|
||||||
max_conductor_current = cur.fetchone()
|
|
||||||
max_current = max_conductor_current[conductor_current_index]
|
|
||||||
|
|
||||||
except sqlite3.OperationalError as e:
|
|
||||||
print(e)
|
|
||||||
|
|
||||||
current_lookup = current_for_lookup(current,max_current)
|
|
||||||
current = current_lookup[0]
|
|
||||||
num_parallel = current_lookup[1]
|
|
||||||
|
|
||||||
try:
|
|
||||||
with sqlite3.connect("jepl-cec21.db") as con:
|
|
||||||
cur = con.cursor()
|
|
||||||
if temp == 90:
|
|
||||||
cur.execute('SELECT size FROM "Table3" WHERE "90" > ? ', (current,))
|
|
||||||
|
|
||||||
elif temp ==75:
|
|
||||||
cur.execute('SELECT size FROM "Table3" WHERE "75" > ? ', (current,))
|
|
||||||
|
|
||||||
else:
|
|
||||||
cur.execute('SELECT size FROM "Table3" WHERE "60" > ? ', (current,))
|
|
||||||
conductor_size = cur.fetchone()[0]
|
|
||||||
|
|
||||||
#print(conductor_size)
|
|
||||||
|
|
||||||
except sqlite3.OperationalError as e:
|
|
||||||
print(e)
|
|
||||||
|
|
||||||
|
|
||||||
elif (code =='CEC') & (material =='AL') & (raceway == True): # CEC Table 4
|
|
||||||
try:
|
|
||||||
with sqlite3.connect("jepl-cec21.db") as con:
|
|
||||||
cur = con.cursor()
|
|
||||||
cur.execute('SELECT * FROM "Table4" WHERE "size" = ? ', (max,))
|
|
||||||
max_conductor_current = cur.fetchone()
|
|
||||||
max_current = max_conductor_current[conductor_current_index]
|
|
||||||
|
|
||||||
except sqlite3.OperationalError as e:
|
|
||||||
print(e)
|
|
||||||
|
|
||||||
current_lookup = current_for_lookup(current,max_current)
|
|
||||||
current = current_lookup[0]
|
|
||||||
num_parallel = current_lookup[1]
|
|
||||||
|
|
||||||
try:
|
|
||||||
with sqlite3.connect("jepl-cec21.db") as con:
|
|
||||||
cur = con.cursor()
|
|
||||||
if temp == 90:
|
|
||||||
cur.execute('SELECT size FROM "Table4" WHERE "90" > ? ', (current,))
|
|
||||||
|
|
||||||
elif temp ==75:
|
|
||||||
cur.execute('SELECT size FROM "Table4" WHERE "75" > ? ', (current,))
|
|
||||||
|
|
||||||
else:
|
|
||||||
cur.execute('SELECT size FROM "Table4" WHERE "60" > ? ', (current,))
|
|
||||||
conductor_size = str(cur.fetchone()[0])
|
|
||||||
|
|
||||||
#print(conductor_size)
|
|
||||||
|
|
||||||
except sqlite3.OperationalError as e:
|
|
||||||
print(e)
|
|
||||||
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'):
|
||||||
|
|
@ -393,6 +254,30 @@ def conductor_size(current, temp = 75, material = 'cu', code = 'CEC', raceway =
|
||||||
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.')
|
||||||
|
|
||||||
|
'''
|
||||||
|
Using the correct table, calculate the number of parallel runs needed with the maximum conductor size,
|
||||||
|
and the resulting wire size.
|
||||||
|
'''
|
||||||
|
|
||||||
|
# Determine the ampacity of the max conductor size
|
||||||
|
max_df = df.loc[df['size'] == max_wire,column]
|
||||||
|
max_current = max_df.item()
|
||||||
|
#print(max_current)
|
||||||
|
|
||||||
|
# The current that we will need to
|
||||||
|
current_lookup = current_for_lookup(current,max_current)
|
||||||
|
current = current_lookup[0]
|
||||||
|
num_parallel = current_lookup[1]
|
||||||
|
|
||||||
|
|
||||||
|
# Calculate the absolute difference for all values and find the index of the minimum difference
|
||||||
|
sectioned_df = df.loc[df[column] >= current,column]
|
||||||
|
|
||||||
|
closest_index = sectioned_df.idxmin()
|
||||||
|
|
||||||
|
# Retrieve the nearest value using the found index
|
||||||
|
conductor_size = df['size'].iloc[closest_index]
|
||||||
|
|
||||||
return [conductor_size,num_parallel]
|
return [conductor_size,num_parallel]
|
||||||
|
|
||||||
def conductor_ampacity(conductor, temp = 75, material = 'cu', code = 'CEC', raceway = True, ambient = 30):
|
def conductor_ampacity(conductor, temp = 75, material = 'cu', code = 'CEC', raceway = True, ambient = 30):
|
||||||
|
|
@ -413,55 +298,20 @@ def conductor_ampacity(conductor, temp = 75, material = 'cu', code = 'CEC', race
|
||||||
]
|
]
|
||||||
|
|
||||||
if temp == 90:
|
if temp == 90:
|
||||||
conductor_current_index = 3
|
column = '90C'
|
||||||
elif temp == 75:
|
elif temp == 75:
|
||||||
conductor_current_index = 2
|
column = '75C'
|
||||||
else:
|
else:
|
||||||
conductor_current_index = 1
|
column = '60C'
|
||||||
|
|
||||||
if (code == 'CEC') & (material == 'CU') & (raceway == False): # CEC Table 1
|
if (code == 'CEC') & (material == 'CU') & (raceway == False): # CEC Table 1
|
||||||
try:
|
df = pd.DataFrame(cec21tables.table1, columns=['size', '60C', '75C', '90C'])
|
||||||
with sqlite3.connect("jepl-cec21.db") as con:
|
|
||||||
cur = con.cursor()
|
|
||||||
cur.execute('SELECT * FROM "Table1" WHERE "size" = ? ', (conductor,))
|
|
||||||
max_conductor_current = cur.fetchone()
|
|
||||||
conductor_ampacity = max_conductor_current[conductor_current_index]
|
|
||||||
|
|
||||||
except sqlite3.OperationalError as e:
|
|
||||||
print(e)
|
|
||||||
|
|
||||||
elif (code == 'CEC') & (material == 'CU') & (raceway == True): # CEC Table 2
|
elif (code == 'CEC') & (material == 'CU') & (raceway == True): # CEC Table 2
|
||||||
try:
|
df = pd.DataFrame(cec21tables.table2, columns=['size', '60C', '75C', '90C'])
|
||||||
with sqlite3.connect("jepl-cec21.db") as con:
|
|
||||||
cur = con.cursor()
|
|
||||||
cur.execute('SELECT * FROM "Table2" WHERE "size" = ? ', (conductor,))
|
|
||||||
max_conductor_current = cur.fetchone()
|
|
||||||
conductor_ampacity = max_conductor_current[conductor_current_index]
|
|
||||||
|
|
||||||
except sqlite3.OperationalError as e:
|
|
||||||
print(e)
|
|
||||||
|
|
||||||
elif (code =='CEC') & (material =='AL') & (raceway == False): # CEC Table 3
|
elif (code =='CEC') & (material =='AL') & (raceway == False): # CEC Table 3
|
||||||
try:
|
df = pd.DataFrame(cec21tables.table3, columns=['size', '60C', '75C', '90C'])
|
||||||
with sqlite3.connect("jepl-cec21.db") as con:
|
|
||||||
cur = con.cursor()
|
|
||||||
cur.execute('SELECT * FROM "Table3" WHERE "size" = ? ', (conductor,))
|
|
||||||
max_conductor_current = cur.fetchone()
|
|
||||||
conductor_ampacity = max_conductor_current[conductor_current_index]
|
|
||||||
|
|
||||||
except sqlite3.OperationalError as e:
|
|
||||||
print(e)
|
|
||||||
|
|
||||||
elif (code =='CEC') & (material =='AL') & (raceway == True): # CEC Table 4
|
|
||||||
try:
|
|
||||||
with sqlite3.connect("jepl-cec21.db") as con:
|
|
||||||
cur = con.cursor()
|
|
||||||
cur.execute('SELECT * FROM "Table4" WHERE "size" = ? ', (conductor,))
|
|
||||||
max_conductor_current = cur.fetchone()
|
|
||||||
conductor_ampacity = max_conductor_current[conductor_current_index]
|
|
||||||
|
|
||||||
except sqlite3.OperationalError as e:
|
|
||||||
print(e)
|
|
||||||
|
|
||||||
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')
|
||||||
|
|
@ -470,6 +320,11 @@ def conductor_ampacity(conductor, temp = 75, material = 'cu', code = 'CEC', race
|
||||||
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.')
|
||||||
|
|
||||||
|
# Determine the ampacity of the conductor size
|
||||||
|
result_df = df.loc[df['size'] == conductor,column]
|
||||||
|
conductor_ampacity = result_df.item()
|
||||||
|
#print(conductor_ampacity)
|
||||||
|
|
||||||
return conductor_ampacity
|
return conductor_ampacity
|
||||||
|
|
||||||
def bonding_conductor(conductor_ampacity,bus=False,material='cu',code = 'CEC'):
|
def bonding_conductor(conductor_ampacity,bus=False,material='cu',code = 'CEC'):
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue