-
Notifications
You must be signed in to change notification settings - Fork 22
/
power.go
143 lines (118 loc) · 3.09 KB
/
power.go
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
package unit
// Power represents a SI unit of power (in watts, W)
type Power Unit
// ...
const (
// SI
Yoctowatt = Watt * 1e-24
Zeptowatt = Watt * 1e-21
Attowatt = Watt * 1e-18
Femtowatt = Watt * 1e-15
Picowatt = Watt * 1e-12
Nanowatt = Watt * 1e-9
Microwatt = Watt * 1e-6
Milliwatt = Watt * 1e-3
Centiwatt = Watt * 1e-2
Deciwatt = Watt * 1e-1
Watt Power = 1e0
Decawatt = Watt * 1e1
Hectowatt = Watt * 1e2
Kilowatt = Watt * 1e3
Megawatt = Watt * 1e6
Gigawatt = Watt * 1e9
Terawatt = Watt * 1e12
Petawatt = Watt * 1e15
Exawatt = Watt * 1e18
Zettawatt = Watt * 1e21
Yottawatt = Watt * 1e24
// non-SI
Pferdestarke = Watt * 735.49875
)
// Yoctowatts returns the power in yW
func (p Power) Yoctowatts() float64 {
return float64(p / Yoctowatt)
}
// Zeptowatts returns the power in zW
func (p Power) Zeptowatts() float64 {
return float64(p / Zeptowatt)
}
// Attowatts returns the power in aW
func (p Power) Attowatts() float64 {
return float64(p / Attowatt)
}
// Femtowatts returns the power in fW
func (p Power) Femtowatts() float64 {
return float64(p / Femtowatt)
}
// Picowatts returns the power in pW
func (p Power) Picowatts() float64 {
return float64(p / Picowatt)
}
// Nanowatts returns the power in nW
func (p Power) Nanowatts() float64 {
return float64(p / Nanowatt)
}
// Microwatts returns the power in µW
func (p Power) Microwatts() float64 {
return float64(p / Microwatt)
}
// Milliwatts returns the power in mW
func (p Power) Milliwatts() float64 {
return float64(p / Milliwatt)
}
// Centiwatts returns the power in cW
func (p Power) Centiwatts() float64 {
return float64(p / Centiwatt)
}
// Deciwatts returns the power in dW
func (p Power) Deciwatts() float64 {
return float64(p / Deciwatt)
}
// Watts returns the power in W
func (p Power) Watts() float64 {
return float64(p)
}
// Decawatts returns the power in daW
func (p Power) Decawatts() float64 {
return float64(p / Decawatt)
}
// Hectowatts returns the power in hW
func (p Power) Hectowatts() float64 {
return float64(p / Hectowatt)
}
// Kilowatts returns the power in kW
func (p Power) Kilowatts() float64 {
return float64(p / Kilowatt)
}
// Megawatts returns the power in MW
func (p Power) Megawatts() float64 {
return float64(p / Megawatt)
}
// Gigawatts returns the power in GW
func (p Power) Gigawatts() float64 {
return float64(p / Gigawatt)
}
// Petawatts returns the power in PW
func (p Power) Petawatts() float64 {
return float64(p / Petawatt)
}
// Exawatts returns the power in EW
func (p Power) Exawatts() float64 {
return float64(p / Exawatt)
}
// Zettawatts returns the power in ZW
func (p Power) Zettawatts() float64 {
return float64(p / Zettawatt)
}
// Yottawatts returns the power in YW
func (p Power) Yottawatts() float64 {
return float64(p / Yottawatt)
}
// Terawatts returns the power in tW
func (p Power) Terawatts() float64 {
return float64(p / Terawatt)
}
// Pferdestarke returns the power in PS
func (p Power) Pferdestarke() float64 {
return float64(p / Pferdestarke)
}