github.com/archlabjp/eeslism-go@v0.0.0-20231109122333-4bb7bfcdf292/eeslism/blrmschd.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  /*   rmschd.c      */
    17  
    18  package eeslism
    19  
    20  import (
    21  	"fmt"
    22  	"math"
    23  )
    24  
    25  /* --------------------------------------------- */
    26  
    27  /*  窓の熱抵抗の変更 */
    28  
    29  func Windowschdlr(isw []ControlSWType, windows []*WINDOW, ds []*RMSRF) {
    30  	for i := range ds {
    31  		sd := ds[i]
    32  		if sd.ble == BLE_Window {
    33  			nsw := sd.Nfn
    34  
    35  			// デフォルトの窓
    36  			j := 0
    37  
    38  			// 窓の選択は条件による切り替えが優先される
    39  			// スケジュールによる窓の変更
    40  			if nsw > 1 {
    41  				j = iswmode(rune(isw[sd.fnsw]), nsw, sd.fnmrk[:])
    42  			}
    43  
    44  			w := windows[sd.fnd[j]]
    45  
    46  			// 動的な窓の変更
    47  			if sd.ifwin != nil {
    48  				// 条件の確認
    49  				if contrlif(sd.Ctlif) != 0 {
    50  					w = sd.ifwin
    51  				}
    52  			}
    53  
    54  			sd.Eo = w.Eo
    55  			sd.Ei = w.Ei
    56  			sd.tgtn = w.tgtn
    57  			sd.Bn = w.Bn
    58  			sd.Rwall = w.Rwall
    59  			sd.CAPwall = 0.0
    60  
    61  			sd.fn = j
    62  		}
    63  	}
    64  }
    65  
    66  /* --------------------------------------------- */
    67  
    68  // 室内発熱の計算
    69  func (Room *ROOM) Qischdlr() {
    70  	Ht := [9]float64{92, 106, 119, 131, 145, 198, 226, 264, 383}
    71  	Hs24 := [9]float64{58, 62, 63, 64, 69, 76, 83, 99, 137}
    72  	d := [9]float64{3.5, 3.6, 4.0, 4.2, 4.4, 6.5, 7.0, 7.3, 6.3}
    73  
    74  	Room.Hc = 0.0
    75  	Room.Hr = 0.0
    76  	Room.HL = 0.0
    77  	Room.Lc = 0.0
    78  	Room.Lr = 0.0
    79  	Room.Ac = 0.0
    80  	Room.Ar = 0.0
    81  	Room.AL = 0.0
    82  
    83  	if DEBUG {
    84  		fmt.Printf("<Qischdlr> Name=%s\n", Room.Name)
    85  	}
    86  
    87  	if Room.Hmsch != nil && *Room.Hmsch > 0.0 {
    88  		N := Room.Nhm * *Room.Hmsch
    89  
    90  		if N > 0 && Room.Hmwksch != nil && *Room.Hmwksch > 0.0 {
    91  			wk := int(*Room.Hmwksch - 1)
    92  
    93  			if wk < 0 || wk > 8 {
    94  				s := fmt.Sprintf("Room=%s wk=%d", Room.Name, wk)
    95  				Eprint("<Qischdlr>", s)
    96  			}
    97  
    98  			if DEBUG {
    99  				fmt.Printf("wk=%d\n", wk)
   100  			}
   101  
   102  			Eo := Room.cmp.Elouts
   103  			Tr := Room.Tr // 自然室温計算時は前時刻の室温で顕熱・潜熱分離する
   104  			// 室温が高温となるときに、顕熱が負になるのを回避
   105  			if Eo[0].Control == LOAD_SW {
   106  				Tr = Room.rmld.Tset
   107  			}
   108  
   109  			Q := math.Max((Hs24[wk]-d[wk]*(Tr-24.0)), 0.) * N
   110  			Room.Hc = Q * 0.5
   111  			Room.Hr = Q * 0.5
   112  			Room.HL = Ht[wk]*N - Q
   113  
   114  			if DEBUG {
   115  				fmt.Printf("Hc=%f Hr=%f HL=%f\n", Room.Hc, Room.Hr, Room.HL)
   116  			}
   117  		}
   118  	}
   119  
   120  	if Room.Lightsch != nil && *Room.Lightsch > 0.0 {
   121  		Q := Room.Light * *Room.Lightsch
   122  		Room.Lc = Q * 0.5
   123  		Room.Lr = Q * 0.5
   124  	} else {
   125  		Room.Lc = 0.0
   126  		Room.Lr = 0.0
   127  	}
   128  
   129  	if Room.Assch != nil && *Room.Assch > 0.0 {
   130  		Room.Ac = Room.Apsc * *Room.Assch
   131  		Room.Ar = Room.Apsr * *Room.Assch
   132  	} else {
   133  		Room.Ac = 0.0
   134  		Room.Ar = 0.0
   135  	}
   136  
   137  	if Room.Alsch != nil && *Room.Alsch > 0.0 {
   138  		Room.AL = Room.Apl * *Room.Alsch
   139  	} else {
   140  		Room.AL = 0.0
   141  	}
   142  }
   143  
   144  /* -------------------------------------------------------- */
   145  
   146  /*  換気量の設定     */
   147  
   148  func Vtschdlr(rooms []*ROOM) {
   149  	for i := range rooms {
   150  		Gvi := 0.0
   151  		Gve := 0.0
   152  
   153  		if rooms[i].Visc != nil && *rooms[i].Visc > 0.0 {
   154  			Gvi = rooms[i].Gvi * *rooms[i].Visc
   155  		} else {
   156  			Gvi = 0.0
   157  		}
   158  
   159  		if rooms[i].Vesc != nil && *rooms[i].Vesc > 0.0 {
   160  			Gve = rooms[i].Gve * *rooms[i].Vesc
   161  		} else {
   162  			Gve = 0.0
   163  		}
   164  
   165  		rooms[i].Gvent = Gvi + Gve
   166  	}
   167  }