github.com/archlabjp/eeslism-go@v0.0.0-20231109122333-4bb7bfcdf292/eeslism/blpvsystem.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  /*   bl_panel.c  */
    17  
    18  package eeslism
    19  
    20  import "math"
    21  
    22  // 太陽電池の温度補正係数計算式
    23  func FNKPT(TPV, apmax float64) float64 {
    24  	return 1.0 + apmax*(TPV-25.0)/100.0
    25  }
    26  
    27  // 太陽電池パラメータの初期化
    28  func PVwallcatinit(PVwallcat *PVWALLCAT) {
    29  	PVwallcat.Type = 'C'
    30  	PVwallcat.Apmax = -0.41
    31  	PVwallcat.KHD = 1.0
    32  	PVwallcat.KPD = 0.95
    33  	PVwallcat.KPM = 0.94
    34  	PVwallcat.KPA = 0.97
    35  	PVwallcat.EffINO = 0.9
    36  	PVwallcat.Ap = 10.0
    37  	PVwallcat.Rcoloff = -999.0
    38  	PVwallcat.Kcoloff = -999.0
    39  }
    40  
    41  // 温度補正係数以外は時々刻々変化しないので、最初に1度計算しておく
    42  func PVwallPreCalc(PVwallcat *PVWALLCAT) {
    43  	PVwallcat.KConst = PVwallcat.KHD * PVwallcat.KPD * PVwallcat.KPM * PVwallcat.KPA * PVwallcat.EffINO
    44  }
    45  
    46  // 太陽電池温度の計算
    47  func FNTPV(Sd *RMSRF, Wd *WDAT, Exsfs *EXSFS) float64 {
    48  	wall := Sd.mw.wall
    49  	Exs := Exsfs.Exs[Sd.exs]
    50  	Ipv := (wall.tra - Sd.PVwall.Eff) * Sd.Iwall
    51  
    52  	var TPV float64
    53  	if Sd.rpnl != nil && Sd.rpnl.cG > 0.0 {
    54  		TPV = (wall.PVwallcat.Ap*Sd.Tf + *Exs.Alo*Wd.T + Ipv) / (wall.PVwallcat.Ap + *Exs.Alo)
    55  	} else {
    56  		TPV = (wall.PVwallcat.Kcoloff*Sd.oldTx + *Exs.Alo*Wd.T + Ipv) / (wall.PVwallcat.Kcoloff + *Exs.Alo)
    57  	}
    58  
    59  	return TPV
    60  }
    61  
    62  func CalcPowerOutput(Sd []*RMSRF, Wd *WDAT, Exsfs *EXSFS) {
    63  	for i := range Sd {
    64  		if Sd[i].mw != nil {
    65  			wall := Sd[i].mw.wall
    66  
    67  			/// 太陽電池が設置されているときのみ
    68  			if Sd[i].PVwallFlg {
    69  				pvwall := &Sd[i].PVwall
    70  
    71  				pvwall.TPV = FNTPV(Sd[i], Wd, Exsfs)
    72  				pvwall.KPT = FNKPT(pvwall.TPV, wall.PVwallcat.Apmax)
    73  				pvwall.KTotal = wall.PVwallcat.KConst * pvwall.KPT
    74  
    75  				pvwall.Power = math.Max(Sd[i].PVwall.PVcap*pvwall.KTotal*Sd[i].Iwall/1000.0, 0.0)
    76  
    77  				// 発電効率の計算
    78  				if Sd[i].Iwall > 0.0 {
    79  					pvwall.Eff = pvwall.Power / (Sd[i].Iwall * Sd[i].A)
    80  				} else {
    81  					pvwall.Eff = 0.0
    82  				}
    83  			}
    84  		}
    85  	}
    86  }