github.com/archlabjp/eeslism-go@v0.0.0-20231109122333-4bb7bfcdf292/eeslism/blrzone.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  /* rzone.c */
    17  package eeslism
    18  
    19  import (
    20  	"bufio"
    21  	"io"
    22  	"strings"
    23  )
    24  
    25  /* ゾーン集計実施室の指定  */
    26  
    27  func Rzonedata(fi io.Reader, dsn string, Nroom int, Room []*ROOM, Nrzone *int, _Rzone []*RZONE) {
    28  	scanner := bufio.NewScanner(fi)
    29  
    30  	for scanner.Scan() {
    31  		line := scanner.Text()
    32  		if strings.HasPrefix(line, "*") {
    33  			break
    34  		}
    35  
    36  		fields := strings.Fields(line)
    37  
    38  		Rzone := _Rzone[*Nrzone]
    39  		Rzone.name = fields[0]
    40  		Rzone.Nroom = 0
    41  		Rzone.Afloor = 0.0
    42  
    43  		for _, s := range fields[1:] {
    44  			if i, err := idroom(s, Room, ""); err != nil {
    45  				Rm := Room[i]
    46  				Rzone.rm = append(Rzone.rm, Rm)
    47  				Rzone.Nroom++
    48  				Rzone.Afloor += Rm.FArea
    49  			} else {
    50  				Eprint(dsn, "<Rzinedata> room name")
    51  			}
    52  		}
    53  
    54  		(*Nrzone)++
    55  	}
    56  }
    57  
    58  /* -------------------------------------------------------- */
    59  
    60  /* 室内熱環境、室負荷のゾーン集計  */
    61  
    62  func Rzonetotal(Nrzone int, Rzone *RZONE) {
    63  	for i := 0; i < Nrzone; i++ {
    64  		Rzone.Tr = 0.0
    65  		Rzone.xr = 0.0
    66  		Rzone.RH = 0.0
    67  		Rzone.Tsav = 0.0
    68  		Rzone.Qhs = 0.0
    69  		Rzone.Qhl = 0.0
    70  		Rzone.Qht = 0.0
    71  		Rzone.Qcs = 0.0
    72  		Rzone.Qcl = 0.0
    73  		Rzone.Qct = 0.0
    74  
    75  		for j := 0; j < Rzone.Nroom; j++ {
    76  			R := Rzone.rm[j]
    77  
    78  			Rzone.Tr += R.Tr * R.FArea
    79  			Rzone.xr += R.xr * R.FArea
    80  			Rzone.RH += R.RH * R.FArea
    81  			Rzone.Tsav += R.Tsav * R.FArea
    82  			if R.rmld != nil {
    83  				if R.rmld.Qs > 0.0 {
    84  					Rzone.Qhs += R.rmld.Qs
    85  				} else {
    86  					Rzone.Qcs += R.rmld.Qs
    87  				}
    88  
    89  				if R.rmld.Ql > 0.0 {
    90  					Rzone.Qhl += R.rmld.Ql
    91  				} else {
    92  					Rzone.Qcl += R.rmld.Ql
    93  				}
    94  
    95  				if R.rmld.Qt > 0.0 {
    96  					Rzone.Qht += R.rmld.Qt
    97  				} else {
    98  					Rzone.Qct += R.rmld.Qt
    99  				}
   100  			}
   101  		}
   102  
   103  		Rzone.Tr /= Rzone.Afloor
   104  		Rzone.xr /= Rzone.Afloor
   105  		Rzone.RH /= Rzone.Afloor
   106  		Rzone.Tsav /= Rzone.Afloor
   107  	}
   108  }