-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwire_sizing.py
More file actions
111 lines (88 loc) · 5.16 KB
/
wire_sizing.py
File metadata and controls
111 lines (88 loc) · 5.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import matplotlib.pyplot as plt
from openpyxl import Workbook, load_workbook
####################################################################
# Wire Sizing Script
#
# Author: Jeremy Shinn
# Contact me on slack or via email Shinn3@purdue.edu
#
# Descritpion: This code sizes wires for given current requirements
# visit the wire sizing confluence page for more information
#
####################################################################
def CalcTemp(PreviousConTemp, PreviousInTemp, ConMass, ConSurfaceArea, InMass, InSurfaceArea):
Resistance = (Resistivity * WireLength) * (1 + ConTempResistCoeff * (PreviousConTemp - AirTemp))
# Calculates current thermal energy in the wire conductor
PreviousConEnergy = ConMass * ConHeatCapacity * (PreviousConTemp - AirTemp)
#Calculates the current thermal energy in the wire insulation
PreviousInEnergy = InMass * InHeatCapacity * (PreviousInTemp - AirTemp)
#Calculates the energy generated by resistance
ConEnergyIn = (Current ** 2) * Resistance * TimeStep
#Calculates the energy transfered from the conductor to the insulation
InEnergyIn = TimeStep * InConductiveCoefficient * ConSurfaceArea * (PreviousConTemp - PreviousInTemp) / InThickness
#Calculates the energy transfered from the insulation to the air
InEnergyOut = AirConvectiveCoefficient * InSurfaceArea * (PreviousInTemp - AirTemp) * TimeStep
InEnergyStored = InEnergyIn - InEnergyOut + PreviousInEnergy
ConEnergyStored = ConEnergyIn - InEnergyIn + PreviousConEnergy
ConTemp = (ConEnergyStored / (ConMass * ConHeatCapacity)) + AirTemp
InTemp = (InEnergyStored / (InMass * InHeatCapacity)) + AirTemp
return ConTemp, InTemp
###########################################################################
# Define parameters
# User input
WireLength = 3 # [M] Length of the wire
InitialTemp = 293.15 # [K] Initial temperature of the wire
#Spreadsheet values
wb = load_workbook('wire_sizing_parameters.xlsx')
ws = wb.active
Resistivity = ws['C10'].value # [ohm/Meter] Resistivity of the conductor
ConDensity = ws['C11'].value # [kg/m^3] Density of conductor
ConHeatCapacity = ws['C12'].value # [J/(kgK)] Specific heat capacity of conductor
ConTempResistCoeff = ws['C13'].value # [1/C] Temperature coefficient of resistance for conductor material
ConRadius = ws['C14'].value # [m] Radius of the wire conductor
InThickness = ws['C8'].value # [m] Outer radius minus inner radius
InConductiveCoefficient = ws['C6'].value # [W/mK] Thermal conductivity of the insulative material
InDensity = ws['C5'].value # [kg/m^3] Density of the insulative material
InHeatCapacity = ws['C7'].value # [J/kgK] Specific heat capacity of the insulative material
#Calculated
TimeStep = .1 # [Seconds]
AirTemp = 293 # [K] temperature of the air surrounding the wire
InitialConTemp = InitialTemp # [K] Initial temperature of the conductor
InitialInTemp = InitialTemp # [K] Initial temperature of the insulation
AirConvectiveCoefficient = 9 # [W/(m^2C)] Convective heat transfer coefficient
PreviousConTemp = 0
TimeEnd = -1
DiameterList = [cell.value for row in ws['F5:F8'] for cell in row]
GaugeList = [cell.value for row in ws['E5:E8'] for cell in row]
PriceList = [cell.value for row in ws['G5:G8'] for cell in row]
index = 0
GaugeFound = False
############################################################################
#################################################################
# Get inputs
Current = int(input("Please enter current requirements [Amps]: "))
####################################################################
for diameter in DiameterList:
ConRadius = diameter / 2 # [m] Radius of the wire conductor
ConductorCrossArea = 3.14 * ConRadius ** 2 # [m^2] Cross sectional area of the condcutor
ConductorSurfaceArea = 2 * 3.14 *ConRadius * WireLength # [m^2] Total surface area of the conductor
ConductorMass = ConductorCrossArea * WireLength * ConDensity # [kg] Mass of the conductor
InsulationCrossArea = 3.14 * (ConRadius + InThickness) ** 2 - ConductorCrossArea # [m^2] Cross-sectional area of the insulative material
InsulationMass = InDensity * InsulationCrossArea # [kg] Mass of the insulative material
InSurfaceArea = 2 * 3.14 * (ConRadius + InThickness) * WireLength # [m^2] Outer surface area of the insulator
PreviousTemps = CalcTemp(InitialConTemp, InitialInTemp, ConductorMass, ConductorSurfaceArea, InsulationMass, InSurfaceArea)
ConTempArray = []
for i in range(0,1000):
Temperatures = CalcTemp(PreviousTemps[0], PreviousTemps[1], ConductorMass, ConductorSurfaceArea, InsulationMass, InSurfaceArea)
PreviousTemps = Temperatures
if Temperatures[1] < 533.15:
print("Wire size: ", GaugeList[index], "awg")
print("Total wire mass: ", round(ConductorMass + InsulationMass,3), "kg")
print("Total wire cost: $", PriceList[index])
print("Wire temperature after 100 seconds of operation: ", round(Temperatures[0] - 273.15, 3), "C")
print("Insulation temperature after 100 seconds of operation: ", round(Temperatures[1] - 273.15, 3), "C")
GaugeFound = True
break
index += 1
if GaugeFound == False:
print("Current requirements too high")