github.com/archlabjp/eeslism-go@v0.0.0-20231109122333-4bb7bfcdf292/eeslism/blrmvent.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  /* rmvent.c  */
    17  package eeslism
    18  
    19  import (
    20  	"fmt"
    21  	"regexp"
    22  	"strings"
    23  )
    24  
    25  /* ------------------------------------------------------------------ */
    26  
    27  /*  外気導入量および室間相互換気量の設定スケジュ-ル入力   */
    28  
    29  // VENTデータセット
    30  func Ventdata(fi *EeTokens, Schdl *SCHDL, Room []*ROOM, Simc *SIMCONTL) {
    31  	var Rm *ROOM
    32  	var name1, ss, E string
    33  	var k int
    34  
    35  	E = fmt.Sprintf(ERRFMT, "RAICH or VENT")
    36  	for fi.IsEnd() == false {
    37  		line := fi.GetLogicalLine()
    38  		if line[0] == "*" {
    39  			break
    40  		}
    41  
    42  		// 室名
    43  		name1 = line[0]
    44  
    45  		// 室検索
    46  		i, err := idroom(name1, Room, E+name1)
    47  		if err != nil {
    48  			panic(err)
    49  		}
    50  		Rm = Room[i] //室の参照
    51  
    52  		for _, s := range line[1:] {
    53  			_ss := strings.SplitN(s, "=", 2)
    54  			key := _ss[0]
    55  			valstr := _ss[1]
    56  
    57  			switch key {
    58  			case "Vent":
    59  				// 換気量
    60  				// Vent=(基準値[kg/s],換気量設定値名)
    61  				regex := regexp.MustCompile(`\(([^,]+),([^,]+)\)`)
    62  				match := regex.FindStringSubmatch(valstr)
    63  				if len(match) == 3 {
    64  					// 基準値[kg/s]
    65  					Rm.Gve, err = readFloat(match[1])
    66  					if err != nil {
    67  						panic(err)
    68  					}
    69  
    70  					// 換気量設定値名
    71  					ss = match[2]
    72  					if k, err := idsch(ss, Schdl.Sch, ""); err == nil {
    73  						Rm.Vesc = &Schdl.Val[k]
    74  					} else {
    75  						Rm.Vesc = envptr(ss, Simc, nil, nil, nil)
    76  					}
    77  				} else {
    78  					fmt.Println("No match found.")
    79  				}
    80  
    81  			case "Inf":
    82  				// すきま風
    83  				// Inf=(基準値[kg/s],隙間風量設定値名)
    84  				regex := regexp.MustCompile(`\(([^,]+),([^,]+)\)`)
    85  				match := regex.FindStringSubmatch(valstr)
    86  				if len(match) == 3 {
    87  					// 基準値[kg/s]
    88  					Rm.Gvi, err = readFloat(match[1])
    89  					if err != nil {
    90  						panic(err)
    91  					}
    92  
    93  					// 隙間風量設定値名
    94  					ss = match[2]
    95  					if k, err = idsch(ss, Schdl.Sch, ""); err == nil {
    96  						Rm.Visc = &Schdl.Val[k]
    97  					} else {
    98  						Rm.Visc = envptr(ss, Simc, nil, nil, nil)
    99  					}
   100  				} else {
   101  					fmt.Println("No match found.")
   102  				}
   103  
   104  			default:
   105  				err := fmt.Sprintf("Room=%s  %s", Rm.Name, key)
   106  				Eprint("<Ventedata>", err)
   107  			}
   108  		}
   109  	}
   110  }
   111  
   112  /* ------------------------------------------------------------------ */
   113  
   114  /*  室間相互換気量の設定   */
   115  
   116  func Aichschdlr(val []float64, rooms []*ROOM) {
   117  	for i := range rooms {
   118  		room := rooms[i]
   119  
   120  		for j := 0; j < room.Nachr; j++ {
   121  			achr := room.achr[j]
   122  			v := val[achr.sch]
   123  			if v > 0.0 {
   124  				achr.Gvr = v
   125  			} else {
   126  				achr.Gvr = 0.0
   127  			}
   128  		}
   129  	}
   130  }