-
Notifications
You must be signed in to change notification settings - Fork 0
/
mcpv.go
358 lines (308 loc) · 8.11 KB
/
mcpv.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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
//This file is part of EESLISM.
//
//Foobar is free software : you can redistribute itand /or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//Foobar is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with Foobar.If not, see < https://www.gnu.org/licenses/>.
/* solrcol.c */
package eeslism
/* 太陽光発電システム
機器仕様入力 */
import (
"fmt"
"io"
"math"
"strconv"
"strings"
)
func PVcadata(s string, PVca *PVCA) int {
dt := 0.0
id := 0
var st int
if st = strings.IndexRune(s, '='); st == -1 {
PVca.Name = s
PVca.PVcap = -999.0
PVca.Area = -999.0
PVca.KHD = 1.0
PVca.KPD = 0.95
PVca.KPM = 0.94
PVca.KPA = 0.97
PVca.effINO = 0.9
PVca.A = -999.0
PVca.B = -999.0
PVca.apmax = -0.41
} else {
s1 := s[:st]
s2 := s[st+1:]
var err error
dt, err = strconv.ParseFloat(s2, 64)
if err != nil {
panic(err)
}
switch {
case strings.HasPrefix(s1, "KHD"):
// 日射量年変動補正係数
PVca.KHD = dt
case strings.HasPrefix(s1, "KPD"):
// 経時変化補正係数
PVca.KPD = dt
case strings.HasPrefix(s1, "KPM"):
// アレイ負荷整合補正係数
PVca.KPM = dt
case strings.HasPrefix(s1, "KPA"):
// アレイ回路補正係数
PVca.KPA = dt
case strings.HasPrefix(s1, "EffInv"):
// インバータ実行効率
PVca.effINO = dt
case strings.HasPrefix(s1, "apmax"):
// 最大出力温度係数
PVca.apmax = dt
case s1 == "InstallType":
PVca.InstallType = rune(s2[0])
switch PVca.InstallType {
case 'A':
PVca.A = 46.0
PVca.B = 0.41
case 'B':
PVca.A = 50.0
PVca.B = 0.38
case 'C':
PVca.A = 57.0
PVca.B = 0.33
}
case strings.HasPrefix(s1, "PVcap"):
// 太陽電池容量
PVca.PVcap = dt
case strings.HasPrefix(s1, "Area"):
// 太陽電池容量
PVca.Area = dt
default:
id = 1
}
}
return id
}
/* ------------------------------------- */
/* 初期設定 */
func PVint(PV []*PV, Exs []*EXSF, Wd *WDAT) {
Err := ""
for i := range PV {
PV[i].Ta = &Wd.T
PV[i].V = &Wd.Wv
for _, exs := range Exs {
if PV[i].Cmp.Exsname == exs.Name {
PV[i].Sol = exs
PV[i].I = &PV[i].Sol.Iw
break
}
}
if PV[i].Sol == nil {
Eprint("PVint", PV[i].Cmp.Exsname)
}
if PV[i].Cat.KHD < 0.0 {
Err = fmt.Sprintf("Name=%s KHD=%.4g", PV[i].Cmp.Name, PV[i].Cat.KHD)
Eprint("PVint", Err)
}
if PV[i].Cat.KPD < 0.0 {
Err = fmt.Sprintf("Name=%s KHD=%.4g", PV[i].Cmp.Name, PV[i].Cat.KPD)
Eprint("PVint", Err)
}
if PV[i].Cat.KPM < 0.0 {
Err = fmt.Sprintf("Name=%s KPM=%.4g", PV[i].Cmp.Name, PV[i].Cat.KPM)
Eprint("PVint", Err)
}
if PV[i].Cat.KPA < 0.0 {
Err = fmt.Sprintf("Name=%s KPA=%.4g", PV[i].Cmp.Name, PV[i].Cat.KPA)
Eprint("PVint", Err)
}
if PV[i].Cat.effINO < 0.0 {
Err = fmt.Sprintf("Name=%s EffInv=%.4g", PV[i].Cmp.Name, PV[i].Cat.effINO)
Eprint("PVint", Err)
}
if PV[i].Cat.apmax > 0.0 {
Err = fmt.Sprintf("Name=%s apmax=%.4g", PV[i].Cmp.Name, PV[i].Cat.apmax)
Eprint("PVint", Err)
}
if PV[i].PVcap < 0.0 {
Err = fmt.Sprintf("Name=%s PVcap=%.4g", PV[i].Cmp.Name, PV[i].PVcap)
Eprint("PVint", Err)
}
if PV[i].Area < 0.0 {
Err = fmt.Sprintf("Name=%s Area=%.4g", PV[i].Cmp.Name, PV[i].Area)
Eprint("PVint", Err)
}
// 計算途中で変化しない各種補正係数の積
PV[i].KConst = PV[i].Cat.KHD * PV[i].Cat.KPD * PV[i].Cat.KPM * PV[i].Cat.KPA * PV[i].Cat.effINO
}
}
// 太陽光発電の発電量計算
/* ------------------------------------- */
/* 集熱量の計算 */
func PVene(PV []*PV) {
for i := range PV {
// 太陽電池アレイの計算(JIS C 8907:2005 P21による)
PV[i].TPV = *PV[i].Ta + (PV[i].Cat.A/(PV[i].Cat.B*math.Pow(*PV[i].V, 0.8)+1.0)+2.0)**PV[i].I/1000.0 - 2.0
PV[i].KPT = FNKPT(PV[i].TPV, PV[i].Cat.apmax)
PV[i].KTotal = PV[i].KConst * PV[i].KPT
// 太陽電池入社日射量の計算
PV[i].Iarea = *PV[i].I * PV[i].Area
// 発電量の計算
PV[i].Power = PV[i].KTotal * *PV[i].I / 1000.0 * PV[i].PVcap
// 発電効率の計算
PV[i].Eff = 0.0
if PV[i].Iarea > 0.0 {
PV[i].Eff = PV[i].Power / PV[i].Iarea
}
}
}
/* ------------------------------------------------------------- */
func PVprint(fo io.Writer, id int, PV []*PV) {
switch id {
case 0:
if len(PV) > 0 {
fmt.Fprintf(fo, "%s %d\n", PV_TYPE, len(PV))
}
for i := range PV {
fmt.Fprintf(fo, " %s 1 4\n", PV[i].Name)
}
break
case 1:
for i := range PV {
fmt.Fprintf(fo, " %s_TPV t f %s_I e f %s_P e f %s_Eff r f \n",
PV[i].Name, PV[i].Name, PV[i].Name, PV[i].Name)
}
break
default:
for i := range PV {
fmt.Fprintf(fo, " %4.1f %4.0f %3.0f %.3f\n",
PV[i].TPV, PV[i].Iarea, PV[i].Power, PV[i].Eff)
}
break
}
}
/* --------------------------- */
/* 日積算値に関する処理 */
func PVdyint(PV []*PV) {
for i := range PV {
qdyint(&PV[i].Edy)
edyint(&PV[i].Soldy)
}
}
func PVmonint(PV []*PV) {
for i := range PV {
qdyint(&PV[i].mEdy)
edyint(&PV[i].mSoldy)
}
}
func PVday(Mon int, Day int, ttmm int, PV []*PV, Nday int, SimDayend int) {
Mo := Mon - 1
tt := ConvertHour(ttmm)
for i := range PV {
var sw ControlSWType
if PV[i].Power > 0.0 {
sw = ON_SW
} else {
sw = OFF_SW
}
// 日間集計
qdaysum(int64(ttmm), sw, PV[i].Power, &PV[i].Edy)
if *PV[i].I > 0.0 {
sw = ON_SW
} else {
sw = OFF_SW
}
// 時間集計
edaysum(ttmm, sw, *PV[i].I, &PV[i].Soldy)
// 月間集計
sw = OFF_SW
if PV[i].Power > 0.0 {
sw = ON_SW
}
qmonsum(Mon, Day, ttmm, sw, PV[i].Power, &PV[i].mEdy, Nday, SimDayend)
if *PV[i].I > 0.0 {
sw = ON_SW
} else {
sw = OFF_SW
}
// 時間集計
emonsum(Mon, Day, ttmm, sw, *PV[i].I, &PV[i].mSoldy, Nday, SimDayend)
// 月・時刻のクロス集計
emtsum(Mon, Day, ttmm, sw, PV[i].Power, &PV[i].mtEdy[Mo][tt])
}
}
func PVdyprt(fo io.Writer, id int, PV []*PV) {
switch id {
case 0:
if len(PV) > 0 {
fmt.Fprintf(fo, "%s %d\n", PV_TYPE, len(PV))
}
for i := range PV {
fmt.Fprintf(fo, " %s 1 8\n", PV[i].Name)
}
case 1:
for i := range PV {
fmt.Fprintf(fo, "%s_Hh H d %s_E E f\n", PV[i].Name, PV[i].Name)
fmt.Fprintf(fo, "%s_th h d %s_Em e f\n", PV[i].Name, PV[i].Name)
fmt.Fprintf(fo, "%s_He H d %s_S E f %s_te h d %s_Sm e f\n\n", PV[i].Name, PV[i].Name, PV[i].Name, PV[i].Name)
}
default:
for i := range PV {
fmt.Fprintf(fo, "%1d %3.1f ", PV[i].Edy.Hhr, PV[i].Edy.H)
fmt.Fprintf(fo, "%1d %2.0f\n", PV[i].Edy.Hmxtime, PV[i].Edy.Hmx)
fmt.Fprintf(fo, "%1d %3.1f ", PV[i].Soldy.Hrs, PV[i].Soldy.D)
fmt.Fprintf(fo, "%1d %2.0f\n", PV[i].Soldy.Mxtime, PV[i].Soldy.Mx)
}
}
}
func PVmonprt(fo io.Writer, id int, PV []*PV) {
switch id {
case 0:
if len(PV) > 0 {
fmt.Fprintf(fo, "%s %d\n", PV_TYPE, len(PV))
}
for i := range PV {
fmt.Fprintf(fo, " %s 1 8\n", PV[i].Name)
}
case 1:
for i := range PV {
fmt.Fprintf(fo, "%s_Hh H d %s_E E f\n", PV[i].Name, PV[i].Name)
fmt.Fprintf(fo, "%s_th h d %s_Em e f\n", PV[i].Name, PV[i].Name)
fmt.Fprintf(fo, "%s_He H d %s_S E f %s_te h d %s_Sm e f\n\n", PV[i].Name, PV[i].Name, PV[i].Name, PV[i].Name)
}
default:
for i := range PV {
fmt.Fprintf(fo, "%1d %3.1f ", PV[i].mEdy.Hhr, PV[i].mEdy.H)
fmt.Fprintf(fo, "%1d %2.0f\n", PV[i].mEdy.Hmxtime, PV[i].mEdy.Hmx)
fmt.Fprintf(fo, "%1d %3.1f ", PV[i].mSoldy.Hrs, PV[i].mSoldy.D)
fmt.Fprintf(fo, "%1d %2.0f\n", PV[i].mSoldy.Mxtime, PV[i].mSoldy.Mx)
}
}
}
func PVmtprt(fo io.Writer, id int, PV []*PV, Mo int, tt int) {
switch id {
case 0:
if len(PV) > 0 {
fmt.Fprintf(fo, "%s %d\n", PV_TYPE, len(PV))
}
for i := range PV {
fmt.Fprintf(fo, " %s 1 1\n", PV[i].Name)
}
case 1:
for i := range PV {
fmt.Fprintf(fo, "%s_E E f\n", PV[i].Name)
}
default:
for i := range PV {
fmt.Fprintf(fo, " %.2f\n", PV[i].mtEdy[Mo-1][tt-1].D*Cff_kWh)
}
}
}