-
Notifications
You must be signed in to change notification settings - Fork 22
/
energy.go
268 lines (222 loc) · 6.47 KB
/
energy.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
package unit
// Energy represents a SI unit of energy (in joules, J)
type Energy Unit
// ...
const (
// SI
Yoctojoule = Joule * 1e-24
Zeptojoule = Joule * 1e-21
Attojoule = Joule * 1e-18
Femtojoule = Joule * 1e-15
Picojoule = Joule * 1e-12
Nanojoule = Joule * 1e-9
Microjoule = Joule * 1e-6
Millijoule = Joule * 1e-3
Centijoule = Joule * 1e-2
Decijoule = Joule * 1e-1
Joule Energy = 1e0
Decajoule = Joule * 1e1
Hectojoule = Joule * 1e2
Kilojoule = Joule * 1e3
Megajoule = Joule * 1e6
Gigajoule = Joule * 1e9
Terajoule = Joule * 1e12
Petajoule = Joule * 1e15
Exajoule = Joule * 1e18
Zettajoule = Joule * 1e21
Yottajoule = Joule * 1e24
// SI-derived
YoctowattHour = WattHour * 1e-24
ZeptowattHour = WattHour * 1e-21
AttowattHour = WattHour * 1e-18
FemtowattHour = WattHour * 1e-15
PicowattHour = WattHour * 1e-12
NanowattHour = WattHour * 1e-9
MicrowattHour = WattHour * 1e-6
MilliwattHour = WattHour * 1e-3
CentiwattHour = WattHour * 1e-2
DeciwattHour = WattHour * 1e-1
WattHour = Joule * 3600
DecawattHour = WattHour * 1e1
HectowattHour = WattHour * 1e2
KilowattHour = WattHour * 1e3
MegawattHour = WattHour * 1e6
GigawattHour = WattHour * 1e9
TerawattHour = WattHour * 1e12
PetawattHour = WattHour * 1e15
ExawattHour = WattHour * 1e18
ZettawattHour = WattHour * 1e21
YottawattHour = WattHour * 1e24
// constant from https://en.wikipedia.org/wiki/Calorie#Definitions
Gramcalorie = Joule * 4.184
Kilocalorie = Gramcalorie * 1e3
Megacalorie = Gramcalorie * 1e6
)
// Yoctojoules returns the energy in yJ
func (e Energy) Yoctojoules() float64 {
return float64(e / Yoctojoule)
}
// Zeptojoules returns the energy in zJ
func (e Energy) Zeptojoules() float64 {
return float64(e / Zeptojoule)
}
// Attojoules returns the energy in aJ
func (e Energy) Attojoules() float64 {
return float64(e / Attojoule)
}
// Femtojoules returns the energy in fJ
func (e Energy) Femtojoules() float64 {
return float64(e / Femtojoule)
}
// Picojoules returns the energy in pJ
func (e Energy) Picojoules() float64 {
return float64(e / Picojoule)
}
// Nanojoules returns the energy in nJ
func (e Energy) Nanojoules() float64 {
return float64(e / Nanojoule)
}
// Microjoules returns the energy in µJ
func (e Energy) Microjoules() float64 {
return float64(e / Microjoule)
}
// Millijoules returns the energy in mJ
func (e Energy) Millijoules() float64 {
return float64(e / Millijoule)
}
// Centijoules returns the energy in cJ
func (e Energy) Centijoules() float64 {
return float64(e / Centijoule)
}
// Decijoules returns the energy in dJ
func (e Energy) Decijoules() float64 {
return float64(e / Decijoule)
}
// Joules returns the energy in J
func (e Energy) Joules() float64 {
return float64(e / Joule)
}
// Decajoules returns the energy in dJ
func (e Energy) Decajoules() float64 {
return float64(e / Decajoule)
}
// Hectojoules returns the energy in hJ
func (e Energy) Hectojoules() float64 {
return float64(e / Hectojoule)
}
// Kilojoules returns the energy in kJ
func (e Energy) Kilojoules() float64 {
return float64(e / Kilojoule)
}
// Megajoules returns the energy in MJ
func (e Energy) Megajoules() float64 {
return float64(e / Megajoule)
}
// Gigajoules returns the energy in GJ
func (e Energy) Gigajoules() float64 {
return float64(e / Gigajoule)
}
// Terajoules returns the energy in TJ
func (e Energy) Terajoules() float64 {
return float64(e / Terajoule)
}
// Petajoules returns the energy in PJ
func (e Energy) Petajoules() float64 {
return float64(e / Petajoule)
}
// Exajoules returns the energy in EJ
func (e Energy) Exajoules() float64 {
return float64(e / Exajoule)
}
// Zettajoules returns the energy in ZJ
func (e Energy) Zettajoules() float64 {
return float64(e / Zettajoule)
}
// Yottajoules returns the energy in YJ
func (e Energy) Yottajoules() float64 {
return float64(e / Yottajoule)
}
// AttowattHours returns the energy in aWh
func (e Energy) AttowattHours() float64 {
return float64(e / AttowattHour)
}
// YoctowattHours returns the energy in yWh
func (e Energy) YoctowattHours() float64 {
return float64(e / YoctowattHour)
}
// ZeptowattHours returns the energy in zWh
func (e Energy) ZeptowattHours() float64 {
return float64(e / ZeptowattHour)
}
// FemtowattHours returns the energy in fWh
func (e Energy) FemtowattHours() float64 {
return float64(e / FemtowattHour)
}
// PicowattHours returns the energy in pWh
func (e Energy) PicowattHours() float64 {
return float64(e / PicowattHour)
}
// NanowattHours returns the energy in nWh
func (e Energy) NanowattHours() float64 {
return float64(e / NanowattHour)
}
// MicrowattHours returns the energy in µWh
func (e Energy) MicrowattHours() float64 {
return float64(e / MicrowattHour)
}
// MilliwattHours returns the energy in mWh
func (e Energy) MilliwattHours() float64 {
return float64(e / MilliwattHour)
}
// CentiwattHours returns the energy in cWh
func (e Energy) CentiwattHours() float64 {
return float64(e / CentiwattHour)
}
// DeciwattHours returns the energy in dWh
func (e Energy) DeciwattHours() float64 {
return float64(e / DeciwattHour)
}
// WattHours returns the energy in Wh
func (e Energy) WattHours() float64 {
return float64(e / WattHour)
}
// DecawattHours returns the energy in daWh
func (e Energy) DecawattHours() float64 {
return float64(e / DecawattHour)
}
// HectowattHours returns the energy in hWh
func (e Energy) HectowattHours() float64 {
return float64(e / HectowattHour)
}
// KilowattHours returns the energy in kWh
func (e Energy) KilowattHours() float64 {
return float64(e / KilowattHour)
}
// MegawattHours returns the energy in MWh
func (e Energy) MegawattHours() float64 {
return float64(e / MegawattHour)
}
// GigawattHours returns the energy in GWh
func (e Energy) GigawattHours() float64 {
return float64(e / GigawattHour)
}
// TerawattHours returns the energy in TWh
func (e Energy) TerawattHours() float64 {
return float64(e / TerawattHour)
}
// PetawattHours returns the energy in PWh
func (e Energy) PetawattHours() float64 {
return float64(e / PetawattHour)
}
// ExawattHours returns the energy in EWh
func (e Energy) ExawattHours() float64 {
return float64(e / ExawattHour)
}
// ZettawattHours returns the energy in ZWh
func (e Energy) ZettawattHours() float64 {
return float64(e / ZettawattHour)
}
// YottawattHours returns the energy in YWh
func (e Energy) YottawattHours() float64 {
return float64(e / YottawattHour)
}