forked from geekcomputers/Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresistance.py
More file actions
40 lines (32 loc) · 1.25 KB
/
Copy pathresistance.py
File metadata and controls
40 lines (32 loc) · 1.25 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
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}Ω"