github.com/archlabjp/eeslism-go@v0.0.0-20231109122333-4bb7bfcdf292/eeslism/mchexchgr.go (about) 1 //This file is part of EESLISM. 2 // 3 //Foobar is free software : you can redistribute itand /or modify 4 //it under the terms of the GNU General Public License as published by 5 //the Free Software Foundation, either version 3 of the License, or 6 //(at your option) any later version. 7 // 8 //Foobar is distributed in the hope that it will be useful, 9 //but WITHOUT ANY WARRANTY; without even the implied warranty of 10 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 11 //GNU General Public License for more details. 12 // 13 //You should have received a copy of the GNU General Public License 14 //along with Foobar.If not, see < https://www.gnu.org/licenses/>. 15 16 /* hexchgr.c */ 17 18 package eeslism 19 20 // ------------------------------------------------------------- 21 // 熱交換器 22 // 23 // 冷風入力 [IN 1] ---> +-----+ <--- [IN 2] 温風入力 24 // | HEX | 25 // 冷風出力 [OUT 1] <--- +-----+ ---> [OUT 2] 温風出力 26 // 27 // ------------------------------------------------------------- 28 29 /* 仕様入力 */ 30 31 import ( 32 "fmt" 33 "io" 34 "math" 35 "strconv" 36 "strings" 37 ) 38 39 func Hexdata(s string, Hexca *HEXCA) int { 40 st := strings.IndexByte(s, '=') 41 if st == -1 { 42 Hexca.Name = s 43 Hexca.eff = -999.0 44 Hexca.KA = -999.0 45 } else { 46 s1 := s[:st] 47 s2 := s[st+1:] 48 if s1 == "eff" { 49 e, err := strconv.ParseFloat(s2, 64) 50 if err != nil { 51 return 1 52 } 53 Hexca.eff = e 54 } else if s1 == "KA" { 55 ka, err := strconv.ParseFloat(s2, 64) 56 if err != nil { 57 return 1 58 } 59 Hexca.KA = ka 60 } else { 61 return 1 62 } 63 } 64 return 0 65 } 66 67 /* --------------------------- */ 68 69 /* 特性式の係数 */ 70 71 func Hexcfv(Hex []*HEX) { 72 for _, hex := range Hex { 73 74 // 計算準備 75 if hex.Id == 0 { 76 /* 温度効率固定タイプと変動タイプの判定 */ 77 if hex.Cat.eff > 0.0 { 78 hex.Etype = 'e' 79 } else if hex.Cat.KA > 0.0 { 80 hex.Etype = 'k' 81 } else { 82 fmt.Printf("Hex %s Undefined Character eff or KA\n", hex.Name) 83 hex.Etype = '-' 84 } 85 86 hex.Id = 1 87 } 88 89 if hex.Cmp.Control != OFF_SW { 90 hex.Eff = hex.Cat.eff 91 92 if hex.Eff < 0.0 { 93 errMsg := fmt.Sprintf("Name=%s eff=%.4g", hex.Cmp.Name, hex.Eff) 94 Eprint("Hexcfv", errMsg) 95 } 96 97 eoh := hex.Cmp.Elouts[1] 98 eoc := hex.Cmp.Elouts[0] 99 hex.CGc = Spcheat(eoc.Fluid) * eoc.G 100 hex.CGh = Spcheat(eoh.Fluid) * eoh.G 101 102 if hex.Etype == 'k' { 103 hex.Eff = FNhccet(hex.CGc, hex.CGh, hex.Cat.KA) 104 } 105 106 eCGmin := hex.Eff * math.Min(hex.CGc, hex.CGh) 107 hex.ECGmin = eCGmin 108 eoc.Coeffin[0] = -hex.CGc + eCGmin 109 eoc.Coeffin[1] = -eCGmin 110 eoc.Coeffo = hex.CGc 111 eoc.Co = 0.0 112 113 eoh.Coeffin[0] = -eCGmin 114 eoh.Coeffin[1] = -hex.CGh + eCGmin 115 eoh.Coeffo = hex.CGh 116 eoh.Co = 0.0 117 } 118 } 119 } 120 121 /* --------------------------- */ 122 123 /* 交換熱量の計算 */ 124 125 func Hexene(Hex []*HEX) { 126 for _, hex := range Hex { 127 128 // 流入 129 hex.Tcin = hex.Cmp.Elins[0].Sysvin 130 hex.Thin = hex.Cmp.Elins[1].Sysvin 131 132 if hex.Cmp.Control != OFF_SW { 133 // 流出 134 hex.Qci = hex.CGc * (hex.Cmp.Elouts[0].Sysv - hex.Tcin) 135 hex.Qhi = hex.CGh * (hex.Cmp.Elouts[1].Sysv - hex.Thin) 136 } else { 137 hex.Qci = 0.0 138 hex.Qhi = 0.0 139 } 140 } 141 } 142 143 /* --------------------------- */ 144 145 func hexprint(fo io.Writer, id int, Hex []*HEX) { 146 switch id { 147 case 0: 148 if len(Hex) > 0 { 149 fmt.Fprintf(fo, "%s %d\n", HEXCHANGR_TYPE, len(Hex)) 150 } 151 for _, hex := range Hex { 152 fmt.Fprintf(fo, " %s 1 9\n", hex.Name) 153 } 154 case 1: 155 for _, hex := range Hex { 156 fmt.Fprintf(fo, "%s_c c c %s:c_G m f %s:c_Ti t f %s:c_To t f %s:c_Q q f\n", 157 hex.Name, hex.Name, hex.Name, hex.Name, hex.Name) 158 fmt.Fprintf(fo, "%s:h_G m f %s:h_Ti t f %s:h_To t f %s:h_Q q f\n", 159 hex.Name, hex.Name, hex.Name, hex.Name) 160 } 161 default: 162 for _, hex := range Hex { 163 eo_Tc := hex.Cmp.Elouts[0] 164 eo_Th := hex.Cmp.Elouts[1] 165 fmt.Fprintf(fo, "%c %6.4g %4.1f %4.1f %2.0f", hex.Cmp.Control, eo_Tc.G, hex.Tcin, eo_Tc.Sysv, hex.Qci) 166 fmt.Fprintf(fo, " %6.4g %4.1f %4.1f %2.0f\n", eo_Th.G, hex.Thin, eo_Th.Sysv, hex.Qhi) 167 } 168 } 169 } 170 171 /* 日積算値に関する処理 */ 172 173 func hexdyint(Hex []*HEX) { 174 for _, hex := range Hex { 175 svdyint(&hex.Tcidy) 176 svdyint(&hex.Thidy) 177 qdyint(&hex.Qcidy) 178 qdyint(&hex.Qhidy) 179 } 180 } 181 182 func hexmonint(Hex []*HEX) { 183 for _, hex := range Hex { 184 svdyint(&hex.MTcidy) 185 svdyint(&hex.MThidy) 186 qdyint(&hex.MQcidy) 187 qdyint(&hex.MQhidy) 188 } 189 } 190 191 func hexday(Mon, Day, ttmm int, Hex []*HEX, Nday, SimDayend int) { 192 for _, hex := range Hex { 193 // 日集計 194 svdaysum(int64(ttmm), hex.Cmp.Control, hex.Tcin, &hex.Tcidy) 195 svdaysum(int64(ttmm), hex.Cmp.Control, hex.Thin, &hex.Thidy) 196 qdaysum(int64(ttmm), hex.Cmp.Control, hex.Qci, &hex.Qcidy) 197 qdaysum(int64(ttmm), hex.Cmp.Control, hex.Qhi, &hex.Qhidy) 198 199 // 月集計 200 svmonsum(Mon, Day, ttmm, hex.Cmp.Control, hex.Tcin, &hex.MTcidy, Nday, SimDayend) 201 svmonsum(Mon, Day, ttmm, hex.Cmp.Control, hex.Thin, &hex.MThidy, Nday, SimDayend) 202 qmonsum(Mon, Day, ttmm, hex.Cmp.Control, hex.Qci, &hex.MQcidy, Nday, SimDayend) 203 qmonsum(Mon, Day, ttmm, hex.Cmp.Control, hex.Qhi, &hex.MQhidy, Nday, SimDayend) 204 } 205 } 206 207 func hexdyprt(fo io.Writer, id int, Hex []*HEX) { 208 var c byte 209 210 switch id { 211 case 0: 212 if len(Hex) > 0 { 213 fmt.Fprintf(fo, "%s %d\n", HEXCHANGR_TYPE, len(Hex)) 214 } 215 for _, hex := range Hex { 216 fmt.Fprintf(fo, " %s 1 28\n", hex.Name) 217 } 218 case 1: 219 for _, hex := range Hex { 220 for j := 0; j < 2; j++ { 221 if j == 0 { 222 c = 'c' 223 } else { 224 c = 'h' 225 } 226 fmt.Fprintf(fo, "%s:%c_Ht H d %s:%c_T T f ", hex.Name, c, hex.Name, c) 227 fmt.Fprintf(fo, "%s:%c_ttn h d %s:%c_Tn t f %s:%c_ttm h d %s:%c_Tm t f\n", 228 hex.Name, c, hex.Name, c, hex.Name, c, hex.Name, c) 229 fmt.Fprintf(fo, "%s:%c_Hh H d %s:%c_Qh Q f %s:%c_Hc H d %s:%c_Qc Q f\n", 230 hex.Name, c, hex.Name, c, hex.Name, c, hex.Name, c) 231 fmt.Fprintf(fo, "%s:%c_th h d %s:%c_qh q f %s:%c_tc h d %s:%c_qc q f\n", 232 hex.Name, c, hex.Name, c, hex.Name, c, hex.Name, c) 233 } 234 } 235 default: 236 for _, hex := range Hex { 237 fmt.Fprintf(fo, "%1d %3.1f %1d %3.1f %1d %3.1f ", 238 hex.Tcidy.Hrs, hex.Tcidy.M, 239 hex.Tcidy.Mntime, hex.Tcidy.Mn, 240 hex.Tcidy.Mxtime, hex.Tcidy.Mx) 241 fmt.Fprintf(fo, "%1d %3.1f ", hex.Qcidy.Hhr, hex.Qcidy.H) 242 fmt.Fprintf(fo, "%1d %3.1f ", hex.Qcidy.Chr, hex.Qcidy.C) 243 fmt.Fprintf(fo, "%1d %2.0f ", hex.Qcidy.Hmxtime, hex.Qcidy.Hmx) 244 fmt.Fprintf(fo, "%1d %2.0f ", hex.Qcidy.Cmxtime, hex.Qcidy.Cmx) 245 fmt.Fprintf(fo, "%1d %3.1f %1d %3.1f %1d %3.1f ", 246 hex.Thidy.Hrs, hex.Thidy.M, 247 hex.Thidy.Mntime, hex.Thidy.Mn, 248 hex.Thidy.Mxtime, hex.Thidy.Mx) 249 fmt.Fprintf(fo, "%1d %3.1f ", hex.Qhidy.Hhr, hex.Qhidy.H) 250 fmt.Fprintf(fo, "%1d %3.1f ", hex.Qhidy.Chr, hex.Qhidy.C) 251 fmt.Fprintf(fo, "%1d %2.0f ", hex.Qhidy.Hmxtime, hex.Qhidy.Hmx) 252 fmt.Fprintf(fo, "%1d %2.0f\n", hex.Qhidy.Cmxtime, hex.Qhidy.Cmx) 253 } 254 } 255 } 256 257 func hexmonprt(fo io.Writer, id int, Hex []*HEX) { 258 var c byte 259 260 switch id { 261 case 0: 262 if len(Hex) > 0 { 263 fmt.Fprintf(fo, "%s %d\n", HEXCHANGR_TYPE, len(Hex)) 264 } 265 for _, hex := range Hex { 266 fmt.Fprintf(fo, " %s 1 28\n", hex.Name) 267 } 268 case 1: 269 for _, hex := range Hex { 270 for j := 0; j < 2; j++ { 271 if j == 0 { 272 c = 'c' 273 } else { 274 c = 'h' 275 } 276 fmt.Fprintf(fo, "%s:%c_Ht H d %s:%c_T T f ", hex.Name, c, hex.Name, c) 277 fmt.Fprintf(fo, "%s:%c_ttn h d %s:%c_Tn t f %s:%c_ttm h d %s:%c_Tm t f\n", 278 hex.Name, c, hex.Name, c, hex.Name, c, hex.Name, c) 279 fmt.Fprintf(fo, "%s:%c_Hh H d %s:%c_Qh Q f %s:%c_Hc H d %s:%c_Qc Q f\n", 280 hex.Name, c, hex.Name, c, hex.Name, c, hex.Name, c) 281 fmt.Fprintf(fo, "%s:%c_th h d %s:%c_qh q f %s:%c_tc h d %s:%c_qc q f\n", 282 hex.Name, c, hex.Name, c, hex.Name, c, hex.Name, c) 283 } 284 } 285 default: 286 for _, hex := range Hex { 287 fmt.Fprintf(fo, "%1d %3.1f %1d %3.1f %1d %3.1f ", 288 hex.MTcidy.Hrs, hex.MTcidy.M, 289 hex.MTcidy.Mntime, hex.MTcidy.Mn, 290 hex.MTcidy.Mxtime, hex.MTcidy.Mx) 291 fmt.Fprintf(fo, "%1d %3.1f ", hex.MQcidy.Hhr, hex.MQcidy.H) 292 fmt.Fprintf(fo, "%1d %3.1f ", hex.MQcidy.Chr, hex.MQcidy.C) 293 fmt.Fprintf(fo, "%1d %2.0f ", hex.MQcidy.Hmxtime, hex.MQcidy.Hmx) 294 fmt.Fprintf(fo, "%1d %2.0f ", hex.MQcidy.Cmxtime, hex.MQcidy.Cmx) 295 fmt.Fprintf(fo, "%1d %3.1f %1d %3.1f %1d %3.1f ", 296 hex.MThidy.Hrs, hex.MThidy.M, 297 hex.MThidy.Mntime, hex.MThidy.Mn, 298 hex.MThidy.Mxtime, hex.MThidy.Mx) 299 fmt.Fprintf(fo, "%1d %3.1f ", hex.MQhidy.Hhr, hex.MQhidy.H) 300 fmt.Fprintf(fo, "%1d %3.1f ", hex.MQhidy.Chr, hex.MQhidy.C) 301 fmt.Fprintf(fo, "%1d %2.0f ", hex.MQhidy.Hmxtime, hex.MQhidy.Hmx) 302 fmt.Fprintf(fo, "%1d %2.0f\n", hex.MQhidy.Cmxtime, hex.MQhidy.Cmx) 303 } 304 } 305 }