forked from geekcomputers/Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Calculate the resistance of a circular conductor based on the geometry of the wire and the ambient temperature and return the value
- Loading branch information
1 parent
8cc8686
commit 921e93f
Showing
1 changed file
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
def resistance_calculator(material:str, lenght:float, section:float, temperature:float): | ||
""" | ||
material is a string indicating the material of the wire | ||
lenght is a floating value indicating the lenght of the wire in meters | ||
diameter is a floating value indicating the diameter of the wire in millimeters | ||
temperature is a floating value indicating the temperature at which the wire is operating in °C | ||
Available materials: | ||
- silver | ||
- copper | ||
- aluminium | ||
- tungsten | ||
- iron | ||
- steel | ||
- zinc | ||
- solder""" | ||
|
||
materials = { | ||
"silver": { | ||
"rho": 0.0163, | ||
"coefficient": 0.0038 | ||
}, | ||
|
||
"copper": { | ||
"rho": 0.0178, | ||
"coefficient": 0.00381 | ||
}, | ||
|
||
"aluminium": { | ||
"rho": 0.0284, | ||
"coefficient": 0.004 | ||
}, | ||
|
||
"tungsten": { | ||
"rho": 0.055, | ||
"coefficient": 0.0045 | ||
}, | ||
|
||
"iron": { | ||
"rho": 0.098, | ||
"coefficient": 0.006 | ||
}, | ||
|
||
"steel": { | ||
"rho": 0.15, | ||
"coefficient": 0.0047 | ||
}, | ||
|
||
"zinc": { | ||
"rho": 0.06, | ||
"coefficient": 0.0037 | ||
}, | ||
|
||
"solder": { | ||
"rho": 0.12, | ||
"coefficient": 0.0043 | ||
} | ||
} | ||
|
||
rho_20deg = materials[material]["rho"] | ||
temp_coefficient = materials[material]["coefficient"] | ||
|
||
rho = rho_20deg * (1 + temp_coefficient * (temperature - 20)) | ||
resistance = rho * lenght / section | ||
|
||
return f"{resistance}Ω" |