-
Notifications
You must be signed in to change notification settings - Fork 0
/
eecmpdat_s.go
839 lines (770 loc) · 16.5 KB
/
eecmpdat_s.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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
package eeslism
import (
"fmt"
"os"
"strconv"
"strings"
)
// システム要素の入力
//
// - SYSCMPを`f`から読み込み、`Cmp`に使用機器情報を登録する.同時に、 `Eqsys`にメモリを確保する。
// - `Cmp`に使用機器情報を登録する際に `Eqcat`のカタログデータを参照する。
// - `Rmvls`に含まれる室および放射パネルは `Cmp`に使用機器として自動登録される。
//
// TODO:
// - この関数内で Eqsysにメモリを確保すると関数の責務を超えるので、分離独立させたほうが良い。
//
func Compodata(f *EeTokens, Rmvls *RMVLS, Eqcat *EQCAT, Cmp *[]*COMPNT, Eqsys *EQSYS) {
var (
Ni, No int
cio ELIOType
idi []ELIOType
ido []ELIOType
)
D := 0
errkey := "Compodata"
Room := Rmvls.Room
Rdpnl := Rmvls.Rdpnl
// Nairflow := Rmvls.Nairflow
// var AirFlow *AIRFLOW
// if Nairflow > 0 {
// AirFlow = Rmvls.airflow
// } else {
// AirFlow = nil
// }
//コンポーネント数
*Cmp = make([]*COMPNT, 0, 100)
// fmt.Printf("<Compodata> Compnt Alloc=%d\n", Ncmp)
//cmp = Cmp
// if fi, err := os.Open("bdata.ewk"); err != nil {
if f == nil {
Eprint("bdata.ewk", "<Compodata>")
os.Exit(EXIT_BDATA)
}
// ----------------------------------------------------------
// 組込みシステム要素
// 給水温度 _CW: -type FLI -V t=Twsup * ;
// 外気温度・絶対湿度 _OA: -type FLI -V t=_Ta x=_xa * ;
// 室 <室名>: ROOMデータセットの宣言に応じて自動で組み込まれる
// 放射パネル <パネル名>: 放射パネルの
// ----------------------------------------------------------
// 給水温度設定 `_CW`
Cmp1 := NewCOMPNT()
Cmp1.Name = CITYWATER_NAME
Cmp1.Eqptype = FLIN_TYPE
Cmp1.Tparm = CITYWATER_PARM
Cmp1.Nin = 1
Cmp1.Nout = 1
Eqsys.Flin = append(Eqsys.Flin, NewFLIN())
D++
// 取り入れ外気設定 `_OA`
Cmp2 := NewCOMPNT()
Cmp2.Name = OUTDRAIR_NAME
Cmp2.Eqptype = FLIN_TYPE
Cmp2.Tparm = OUTDRAIR_PARM
Cmp2.Nin = 2
Cmp2.Nout = 2
Eqsys.Flin = append(Eqsys.Flin, NewFLIN())
D++
*Cmp = append(*Cmp, Cmp1, Cmp2)
/* 室およびパネル用 */
var Ncrm int
if SIMUL_BUILDG {
// 室用 `<室名>`
for i := range Rmvls.Room {
c := NewCOMPNT()
c.Name = Room[i].Name
c.Eqptype = ROOM_TYPE
c.Neqp = i
c.Eqp = Room[i]
c.Nout = 2
c.Nin = 2*Room[i].Nachr + Room[i].Ntr + Room[i].Nrp
c.Nivar = 0
c.Ivparm = nil
c.Airpathcpy = true
*Cmp = append(*Cmp, c)
D++
}
Ncrm = 2 + len(Rmvls.Room) // 給水温度設定+取り入れ外気設定+室の数
// パネル用 `<パネル名>`
for i := range Rdpnl {
c := NewCOMPNT()
c.Name = Rdpnl[i].Name
c.Eqptype = RDPANEL_TYPE
c.Neqp = i
c.Eqp = Rdpnl[i]
c.Nout = 2
c.Nin = 3 + Rdpnl[i].Ntrm[0] + Rdpnl[i].Ntrm[1] + Rdpnl[i].Nrp[0] + Rdpnl[i].Nrp[1] + 1
c.Nivar = 0
c.Airpathcpy = true
*Cmp = append(*Cmp, c)
D++
}
// エアフローウィンドウの機器メモリ
// for i := 0; i < Nairflow; i++ {
// c := NewCOMPNT()
// c.name = AirFlow[i].name
// c.eqptype = AIRFLOW_TYPE
// c.neqp = i
// c.eqp = AirFlow[i]
// c.Nout = 2
// c.Nin = 3
// c.nivar = 0
// c.airpathcpy = true
// *Cmp = append(*Cmp, *c)
// }
}
//cp := (*COMPNT)(nil)
for f.IsEnd() == false {
s := f.GetToken()
if s == "*" {
break
}
if s == "\n" {
continue
}
cio = ELIO_SPACE
var comp *COMPNT = NewCOMPNT()
var Crm *COMPNT = comp
// 三方弁(二方弁で連動する弁)を指定するとき
// `(<elmname1> <elmname2>)` のように入力する
// elmname1とelmname2が三方弁のように、逆作動の連動弁として機能するときの記述方法。
// このように書くとelmname1とelmname2はともに2方弁であるが、elmname1が開くとelmname2は閉じる操作が行われる。
//
// [elm1] --> [elm2]
//
if strings.HasPrefix(s, "(") {
if len(s) == 1 {
s = f.GetToken()
} else {
fmt.Sscanf(s, "(%s", &s)
}
Crm = nil
// 1つ目の2方弁
vc1 := NewCOMPNT()
vc1.Name = s // <compname1>
s = f.GetToken()
if strings.IndexRune(s, ')') != -1 {
idx := strings.IndexRune(s, ')')
s = s[idx+1:]
}
// 2つ目の2方弁
vc2 := NewCOMPNT()
vc2.Name = s // <compname2>
// 1つ目の2方弁から2つ目の2方弁を参照させる
vc1.Valvcmp = vc2
*Cmp = append(*Cmp, vc1, vc2)
// 2つ目の要素に対して各種設定を反映させる
comp = vc2
// NOTE: ここでVALVを追加する理由が不明
Eqsys.Valv = append(Eqsys.Valv, NewVALV())
}
if Crm != nil {
// 組み込みの部屋要素を探す → 該当がなければ初期化 (必要性不明)
Crm = FindCOMPNTByName(s, (*Cmp)[:Ncrm])
if Crm == nil {
comp.Name = s
comp.Ivparm = nil
comp.Tparm = ""
comp.Envname = ""
comp.Roomname = ""
comp.Nivar = 0
}
}
for f.IsEnd() == false {
s = f.GetToken()
if s[0] == ';' {
break
}
if strings.HasPrefix(s, "-") {
/********************************/
if cio == 'i' {
comp.Nin = Ni
comp.Idi = make([]ELIOType, Ni)
} else if cio == 'o' {
comp.Nout = No
comp.Ido = make([]ELIOType, No)
if comp.Eqptype == DIVERG_TYPE {
comp.Nivar = No
//comp.Ivparm = new(float64)
}
}
/********************************/
// ハイフンの後ろに続く文字列を取得
ps := s[1:]
switch ps {
case "c":
// カタログ名
cio = 'c'
case "type":
// 要素の種類
cio = 't'
case "Nin":
// 合流数
cio = 'I'
case "Nout":
// 分岐数
cio = 'O'
case "in":
cio = 'i'
Ni = 0
idi = []ELIOType{}
case "out":
cio = 'o'
No = 0
ido = []ELIOType{}
case "L":
// 配管長 [m]
cio = 'L'
comp.Nivar = 1
case "env":
// 周囲温度
cio = 'e'
case "room":
// 機器設置空間の室名
cio = 'r'
case "roomheff":
cio = 'R'
case "exs":
// 太陽熱集熱器の方位・傾斜名(EXSRFデータで入力)
cio = 's'
case "S":
// ???
cio = 'S'
case "Tinit":
// 蓄熱槽の初期水温
cio = 'T'
case "V":
// ???
cio = 'V'
case "hcc":
// VWV制御するときの制御対象熱交換器名称
cio = 'h'
case "pfloor":
// VWV制御するときの制御対象床暖房
cio = 'f'
case "wet":
// 冷却コイルで出口相対湿度一定の仮定で除湿の計算を行う。
comp.Wetparm = ps
/*---- Roh Debug for a constant outlet humidity model of wet coil 2003/4/25 ----*/
cio = 'w'
comp.Ivparm = CreateConstantValuePointer(90.0)
case "control":
// 集熱器が直列接続の場合に流れ方向に記載する
cio = 'M'
case "monitor":
// Satoh Debug
cio = 'm'
case "PCMweight":
// 電気蓄熱暖房器の潜熱蓄熱材重量(kg)
cio = 'P'
default:
Eprint(errkey, s)
}
} else if cio != 'V' && cio != 'S' && strings.IndexRune(s, '-') != -1 {
idx := strings.IndexRune(s, '-')
st := s[idx+1:]
var err error
switch {
case strings.HasPrefix(s, "Ac"):
// 集熱器面積 [m2]
comp.Ac, err = readFloat(st)
if err != nil {
panic(err)
}
case strings.HasPrefix(s, "PVcap"):
// 設置容量 [W] (PV)
comp.PVcap, err = readFloat(st)
if err != nil {
panic(err)
}
case strings.HasPrefix(s, "Area"):
// アレイ面積 [m2](PV)
comp.Area, err = readFloat(st)
if err != nil {
panic(err)
}
}
} else {
switch cio {
case 'c':
// `-c <カタログ名>`
if eqpcat(s, comp, Eqcat, Eqsys) {
Eprint(errkey, s)
}
break
case 't':
// `-type <種類>`
comp.Eqptype = EqpType(s)
// 三方弁(二方弁で連動する弁)
if comp.Valvcmp != nil {
// 連動する対となる要素にも種類を指定
comp.Valvcmp.Eqptype = EqpType(s)
}
comp.Neqp = 0
comp.Ncat = 0
switch s {
case CONVRG_TYPE, CVRGAIR_TYPE:
// 合流要素
Eqsys.Cnvrg = append(Eqsys.Cnvrg, nil)
comp.Nout = 1
case DIVERG_TYPE, DIVGAIR_TYPE:
// 分岐要素
comp.Nin = 1
case FLIN_TYPE:
// 流入境界条件
Eqsys.Flin = append(Eqsys.Flin, NewFLIN())
case HCLOAD_TYPE, HCLOADW_TYPE, RMAC_TYPE, RMACD_TYPE:
// 空調負荷
Eqsys.Hcload = append(Eqsys.Hcload, NewHCLOAD())
case VALV_TYPE, TVALV_TYPE:
// 弁・ダンパー
Eqsys.Valv = append(Eqsys.Valv, NewVALV())
case QMEAS_TYPE:
// カロリーメータ
//Eqsys.Nqmeas++
default:
if s != DIVERG_TYPE && s != DIVGAIR_TYPE {
Eprint(errkey, s)
}
}
break
case 'i':
// `-in`
idi = append(idi, ELIO_None)
Ni++
break
case 'o':
// `-out`
ido = append(ido, ELIO_None)
No++
break
case 'I':
// `-Nin <合流数>`
// Satoh DEBUG 1998/5/15
var err error
if Crm != nil && SIMUL_BUILDG {
if Crm.Eqptype == ROOM_TYPE {
room := Crm.Eqp.(*ROOM)
room.Nasup, err = strconv.Atoi(s)
if err != nil {
panic(err)
}
N := room.Nasup
if N > 0 {
if room.Arsp == nil {
room.Arsp = make([]*AIRSUP, N)
for i := 0; i < N; i++ {
room.Arsp[i] = new(AIRSUP)
}
}
}
Crm.Nin += 2 * room.Nasup
}
} else {
comp.Nin, err = strconv.Atoi(s)
if err != nil {
panic(err)
}
}
comp.Idi = make([]ELIOType, comp.Nin)
for i := 0; i < comp.Nin; i++ {
comp.Idi[i] = ' '
}
break
case 'O':
// `-Nout <分岐数>`
var err error
comp.Nout, err = strconv.Atoi(s)
if err != nil {
panic(err)
}
ido = make([]ELIOType, comp.Nout)
for i := 0; i < comp.Nout; i++ {
ido[i] = ELIO_SPACE
}
comp.Ido = ido
break
case 'L':
// `-L <配管長>`
l, err := readFloat(s)
if err != nil {
panic(err)
}
comp.Ivparm = CreateConstantValuePointer(l)
break
case 'e':
// `-env <周囲温度>`
comp.Envname = s
break
case 'r':
// `-room <機器設置空間の室名>`
comp.Roomname = s
break
case 'h':
// `-hcc <VWV制御するときの制御対象熱交換器名称>`
comp.Hccname = s
break
case 'f':
// `-pfloor <VWV制御するときの制御対象床暖房>`
comp.Rdpnlname = s
break
case 'R':
// `-roomheff <ボイラ室内置き時の室内供給熱量率>`
var err error
comp.Roomname = s
s = f.GetToken()
comp.Eqpeff, err = readFloat(s)
if err != nil {
panic(err)
}
break
case 's':
// `-exs <太陽熱集熱器の方位・傾斜名>`
comp.Exsname = s
break
case 'M':
// `-control <集熱器が直列接続の場合に集熱器の要素名を流れ方向に記載する>`
comp.Omparm = s
break
case 'S', 'V':
// `-S <????>` or `-V <????>`
for {
_s := f.GetToken()
if _s == "*" {
break
}
s += " " + _s
}
s += " *"
comp.Tparm = s
break
case 'T':
// `-Tinit <蓄熱槽の初期水温>`
if strings.HasPrefix(s, "(") {
s += " "
s += strings.Repeat(" ", len(s))
_s := f.GetToken()
s += _s
comp.Tparm = s
} else {
comp.Tparm = s
}
break
case 'w':
// `-wet` 冷却コイルで出口相対湿度一定の仮定で除湿の計算を行う。
wet, err := readFloat(s)
if err != nil {
panic(err)
}
comp.Ivparm = CreateConstantValuePointer(wet)
break
case 'm':
// `-monitor` デバッグ用
comp.MonPlistName = s
comp.Valvcmp.MonPlistName = s
break
case 'P':
// `-PCMweight <電気蓄熱暖房器の潜熱蓄熱材重量(kg)>`
var err error
comp.MPCM, err = readFloat(s)
if err != nil {
panic(err)
}
break
}
}
}
if Crm == nil {
*Cmp = append(*Cmp, comp)
D++
}
}
// 空気の分岐要素・合流要素があった場合、内容をコピーして湿度用に分岐要素・合流要素を作成
n := len(*Cmp)
for i := 0; i < n; i++ {
cm := (*Cmp)[i]
if cm.Eqptype == DIVGAIR_TYPE {
c := NewCOMPNT()
c.Name = cm.Name + ".x"
c.Eqptype = cm.Eqptype
c.Nout = cm.Nout
c.Ido = cm.Ido
*Cmp = append(*Cmp, c)
} else if cm.Eqptype == CVRGAIR_TYPE {
c := NewCOMPNT()
c.Name = cm.Name + ".x"
c.Eqptype = cm.Eqptype
c.Nin = cm.Nin
c.Idi = cm.Idi
// ここで合流要素一覧に追加する理由が不明
Eqsys.Cnvrg = append(Eqsys.Cnvrg, nil)
*Cmp = append(*Cmp, c)
}
}
// for _, c := range *Cmp {
// if len(c.Idi) != c.Nin {
// panic(c.Name)
// }
// if len(c.Ido) != c.Nout {
// panic(c.Name)
// }
// }
//fmt.Printf("<<Compodata>> Ncompnt = %d\n", *Ncompnt)
//printf("<<Compodata>> end\n");
}
func FindCOMPNTByName(s string, Compnt []*COMPNT) *COMPNT {
cp := (*COMPNT)(nil)
for i := range Compnt {
if s == Compnt[i].Name {
cp = Compnt[i]
break
}
}
return cp
}
func NewVALV() *VALV {
return &VALV{
Name: "",
Cmp: nil,
Cmb: nil,
Org: 'n',
X: -999.0,
Xinit: nil,
Tin: nil,
Tset: nil,
Mon: nil,
Plist: nil,
MGo: nil,
Tout: nil,
MonPlist: nil,
//OMfan : nil,
//OMfanName : nil,
}
}
func NewHCC() *HCC {
return &HCC{
Name: "",
Cmp: nil,
Cat: nil,
Twin: 5.0,
Xain: FNXtr(25.0, 50.0),
}
}
func NewBOI() *BOI {
Boi := &BOI{
Name: "",
Cmp: nil,
Cat: nil,
Load: nil,
Mode: 'M',
}
MtEdayinit(&Boi.MtEdy)
MtEdayinit(&Boi.MtPhdy)
return Boi
}
func NewCOLL() *COLL {
return &COLL{
Name: "",
Cmp: nil,
Cat: nil,
sol: nil,
Te: 0.0,
Tcb: 0.0,
}
}
func NewPV() *PV {
PV := &PV{
PVcap: -999.,
Area: -999.,
Name: "",
Cmp: nil,
Cat: nil,
Sol: nil,
Ta: nil,
V: nil,
I: nil,
}
MtEdayinit(&PV.mtEdy)
return PV
}
func NewOMVAV() *OMVAV {
OMvav := &OMVAV{
Name: "",
Cmp: nil,
Cat: nil,
Omwall: nil,
Plist: nil,
Nrdpnl: 0,
}
for j := 0; j < 4; j++ {
OMvav.Rdpnl[j] = nil
}
return OMvav
}
func NewREFA() *REFA {
Rf := &REFA{
Name: "",
Cmp: nil,
Cat: nil,
Load: nil,
Room: nil,
Do: 0.0,
D1: 0.0,
Tin: 0.0,
Te: 0.0,
Tc: 0.0,
}
MtEdayinit(&Rf.mtEdy)
MtEdayinit(&Rf.mtPhdy)
return Rf
}
func NewPIPE() *PIPE {
return &PIPE{
Name: "",
Cmp: nil,
Cat: nil,
Loadt: nil,
Loadx: nil,
Room: nil,
}
}
func NewSTANK() *STANK {
return &STANK{
Name: "",
Cmp: nil,
Cat: nil,
Jin: nil,
Jout: nil,
Batchcon: nil,
Ihex: nil,
B: nil,
R: nil,
Fg: nil,
D: nil,
Tss: nil,
DtankF: nil,
Tssold: nil,
Dvol: nil,
Mdt: nil,
KS: nil,
Ihxeff: nil,
KA: nil,
KAinput: nil,
CGwin: nil,
EGwin: nil,
Twin: nil,
Q: nil,
Tenv: nil,
Stkdy: nil,
Mstkdy: nil,
MQlossdy: 0.0,
MQstody: 0.0,
Ncalcihex: 0,
}
}
func NewHEX() *HEX {
return &HEX{
Name: "",
Cmp: nil,
Cat: nil,
Id: 0,
}
}
func NewPUMP() *PUMP {
Pp := &PUMP{
Name: "",
Cmp: nil,
Cat: nil,
Sol: nil,
}
MtEdayinit(&Pp.MtEdy)
return Pp
}
func NewFLIN() *FLIN {
return &FLIN{
Name: "",
Namet: "",
Namex: "",
Vart: nil,
Varx: nil,
Cmp: nil,
}
}
func NewHCLOAD() *HCLOAD {
Hl := &HCLOAD{
Name: "",
Loadt: nil,
Loadx: nil,
Cmp: nil,
RMACFlg: 'N',
Ga: 0.0,
Gw: 0.0,
RHout: 50.0,
}
MtEdayinit(&Hl.mtEdy)
return Hl
}
func NewVAV() *VAV {
return &VAV{
Name: "",
Cat: nil,
Hcc: nil,
Hcld: nil,
Cmp: nil,
}
}
func NewSTHEAT() *STHEAT {
st := &STHEAT{
Name: "",
Cat: nil,
Cmp: nil,
Room: nil,
Pcm: nil,
}
MtEdayinit(&st.MtEdy)
return st
}
func NewDESI() *DESI {
return &DESI{
Name: "",
Cat: nil,
Cmp: nil,
Room: nil,
Tenv: nil,
}
}
func NewEVAC() *EVAC {
return &EVAC{
Name: "",
Cat: nil,
Cmp: nil,
M: nil,
Kx: nil,
Tdry: nil,
Twet: nil,
Xdry: nil,
Xwet: nil,
Ts: nil,
Xs: nil,
RHdry: nil,
RHwet: nil,
UXC: nil,
UX: nil,
//UXdry: nil,
//UXwet: nil,
}
}
func NewTHEX() *THEX {
return &THEX{
Name: "",
Cmp: nil,
Cat: nil,
Type: ' ',
CGe: 0.0,
Ge: 0.0,
Go: 0.0,
ET: -999.0,
EH: -999.0,
}
}