-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresistor.py
More file actions
56 lines (37 loc) · 1.7 KB
/
resistor.py
File metadata and controls
56 lines (37 loc) · 1.7 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
import constants
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class Resistor:
def __init__(self, r, temp):
#nominal resistance in Ohms (protected)
self._r = r
"""Getter for the standard temperature that the resistance was
meansured"""
def getStdTemp (self):
return self._std_temp
def getRr(self):
return self._r
"""Getter for the resistance (meansured at _std_temp temperature)"""
def getR(self, temperature):
return self._r*math.exp(self._thermal_const*(temperature - std_temp))
def getR(self, r_std, temperature):
return r_std*math.exp(self._thermal_const*(temperature - std_temp))
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class WireResistor(Resistor):
def __init__ (self, r, Temp, conductor):
#calls the constructor of the superclass (Resistor)
super().__init__(r, Temp)
#define the resistor conductor
if isinstance(conductor, constants.Conductor):
self._conductor = conductor
else:
raise ValueError ("Parameter conductor is not of Conductor type")
""" Returns the lenght of wire (in m) for the specified area (in m^2) """
def getLenght(self, Area):
return self._r*Area/(self._resistivity)
"""Returns the sectional are of the wire (m^2) given the lenght (m)"""
def getArea(self, lenght):
return (lenght*self._resistivity)/self._r
""" Get the resistance"""
def getR (self,lenght, area, temperature):
return self.getR((self._resistivity*lenght/area), temperature)
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++