Skip to content

Commit 921e93f

Browse files
authored
Create resistance.py
Calculate the resistance of a circular conductor based on the geometry of the wire and the ambient temperature and return the value
1 parent 8cc8686 commit 921e93f

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

Electronics_Algorithms/resistance.py

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
def resistance_calculator(material:str, lenght:float, section:float, temperature:float):
2+
"""
3+
material is a string indicating the material of the wire
4+
5+
lenght is a floating value indicating the lenght of the wire in meters
6+
7+
diameter is a floating value indicating the diameter of the wire in millimeters
8+
9+
temperature is a floating value indicating the temperature at which the wire is operating in °C
10+
11+
Available materials:
12+
- silver
13+
- copper
14+
- aluminium
15+
- tungsten
16+
- iron
17+
- steel
18+
- zinc
19+
- solder"""
20+
21+
materials = {
22+
"silver": {
23+
"rho": 0.0163,
24+
"coefficient": 0.0038
25+
},
26+
27+
"copper": {
28+
"rho": 0.0178,
29+
"coefficient": 0.00381
30+
},
31+
32+
"aluminium": {
33+
"rho": 0.0284,
34+
"coefficient": 0.004
35+
},
36+
37+
"tungsten": {
38+
"rho": 0.055,
39+
"coefficient": 0.0045
40+
},
41+
42+
"iron": {
43+
"rho": 0.098,
44+
"coefficient": 0.006
45+
},
46+
47+
"steel": {
48+
"rho": 0.15,
49+
"coefficient": 0.0047
50+
},
51+
52+
"zinc": {
53+
"rho": 0.06,
54+
"coefficient": 0.0037
55+
},
56+
57+
"solder": {
58+
"rho": 0.12,
59+
"coefficient": 0.0043
60+
}
61+
}
62+
63+
rho_20deg = materials[material]["rho"]
64+
temp_coefficient = materials[material]["coefficient"]
65+
66+
rho = rho_20deg * (1 + temp_coefficient * (temperature - 20))
67+
resistance = rho * lenght / section
68+
69+
return f"{resistance}Ω"

0 commit comments

Comments
 (0)