ダウンロード |
Option Explicit
Sub PosSol()
Dim M As Integer
Dim D As Integer
Dim J As Integer 'Julian Day
Dim Jang As Double
Dim Pi As Double
Dim Lat As Double 'Latitude
Dim Lon As Double 'Longitude
Dim Decl As Double 'Declination of the Sun
Dim GMT As Double 'Greenwich Meridian Time
Dim MST As Double 'Mean Solar Time (Local Time)
Dim TST As Double 'True Solar Time
Dim ET As Double 'Equation of Time
Dim ht As Double 'Hour Time
Dim SOLz As Double 'Solar Zenithal Angle
Dim cosSOLz As Double
Dim SOLa As Double 'Solar Azimuthal Angle
Dim sinSOLa As Double
Dim cosSOLa As Double
Dim a1 As Single
Dim a2 As Single
Dim a3 As Single
Dim a4 As Single
Dim a5 As Single
Dim b1 As Single
Dim b2 As Single
Dim b3 As Single
Dim b4 As Single
Dim b5 As Single
Dim b6 As Single
Dim b7 As Single
Dim WS1
Set WS1 = Worksheets("possol")
'----a & b----
a1 = 0.000075
a2 = 0.001868
a3 = 0.032077
a4 = 0.014615
a5 = 0.040849
b1 = 0.006918
b2 = 0.399912
b3 = 0.070257
b4 = 0.006758
b5 = 0.000907
b6 = 0.002697
b7 = 0.00148
'----Julian Day----
M = WS1.Cells(7, 3).Value
D = WS1.Cells(7, 4).Value
Select Case M
Case Is <= 2
J = 31 * (M - 1) + D
Case Is >= 9
J = 31 * (M - 1) - Int((M - 2) / 2) - 2 + D
Case Else
J = 31 * (M - 1) - Int((M - 1) / 2) - 2 + D
End Select
WS1.Cells(7, 7).Value = J
'----Lat, Lon & Jang----
Pi = Application.Pi()
Lat = WS1.Cells(13, 7).Value
Lon = WS1.Cells(14, 7).Value
J = WS1.Cells(7, 7).Value
Jang = 2 * Pi * J / 365 'Rad
'----Hour Angle----
MST = 0
TST = 0
ET = 0
ht = 0
GMT = WS1.Cells(10, 7).Value
MST = GMT + Lon / 15 'deg.
ET = (a1 + a2 * Cos(Jang) - a3 * Sin(Jang) - a4 * Cos(2 * Jang) - a5 * Sin(2 * Jang)) * 12 / Application.Pi()
TST = MST + ET
ht = 15 * (TST - 12) * Pi / 180 'Rad.
'----Declination of the Sun----
Decl = b1 - b2 * Cos(Jang) + b3 * Sin(Jang) - b4 * Cos(2 * Jang) + b5 * Sin(2 * Jang) - b6 * Cos(3 * Jang) + b7 * Sin(3 * Jang) 'Rad.
Lat = Application.Radians(Lat) 'Rad.
'----Solar Zenithal Angle----
cosSOLz = Sin(Decl) * Sin(Lat) + Cos(Decl) * Cos(Lat) * Cos(ht)
SOLz = Application.Degrees(Application.Acos(cosSOLz))
WS1.Cells(17, 3).Value = SOLz
'----Solar Azimathal Angle----
sinSOLa = Cos(Decl) * Sin(ht) / Sin(Application.Radians(SOLz))
If Abs(sinSOLa) > 1 Then
sinSOLa = Application.Sign(sinSOLa)
End If
SOLa = Application.Asin(sinSOLa)
cosSOLa = (-Cos(Lat) * Sin(Decl) + Sin(Lat) * Cos(Decl) * Cos(ht)) / Sin(Application.Radians(SOLz))
If cosSOLa < 0 Then
SOLa = Pi - SOLa
End If
If cosSOLa >= 0 And sinSOLa <= 0 Then
SOLa = 2 * Pi + SOLa
End If
SOLa = SOLa + Pi
If SOLa > Pi * 2 Then
SOLa = SOLa - Pi * 2
End If
SOLa = Application.Degrees(SOLa)
WS1.Cells(18, 3).Value = SOLa
End Sub