Created
November 2, 2023 00:06
-
-
Save pukpr/3e1484dd8248623453ccf77723957b55 to your computer and use it in GitHub Desktop.
Analytic Tidal Forcing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Conventional tidal series summation or superposition of cycles | |
function Tide_Sum (Template : in Data_Pairs; | |
Constituents : in Long_Periods_Amp_Phase; | |
Periods : in Long_Periods; | |
Ref_Time : in Long_Float := 0.0; | |
Scaling : in Long_Float := 1.0; | |
Cos_Phase : in Boolean := True; | |
Year_Len : in Long_Float := Year_Length; | |
Integ: in Long_Float := 0.0 | |
) return Data_Pairs is | |
Pi : Long_Float := Ada.Numerics.Pi; | |
Time : Long_Float; | |
Res : Data_Pairs := Template; | |
Yr : Long_Float := Year_Len; | |
Drac : Long_Float := 2.0*pi*Yr/Draconic; | |
Trop : Long_Float := 2.0*pi*Yr/Tropical; | |
Anom : Long_Float := 2.0*pi*Yr/Anomalistic; | |
Nodal : Long_Float := Drac-Trop; | |
Peri : Long_Float := (Trop-Anom)/2.0; | |
K1 : Long_Float := Constituents(1).Value; -- -0.06 | |
K2 : Long_Float := Constituents(2).Value; -- -0.064 | |
TA : Long_Float := Constituents(3).Value; -- 0.144 | |
TP : Long_Float := Constituents(4).Value; -- 0.7 | |
AA : Long_Float := Constituents(5).Value; -- -0.718 | |
AP : Long_Float := Constituents(6).Value; -- -0.62 | |
T2A : Long_Float := Constituents(7).Value; -- 0.16 | |
T2P : Long_Float := Constituents(8).Value; -- 0.29 | |
DSA : Long_Float := Constituents(9).Value; -- 0.001 ---- | |
DSP : Long_Float := Constituents(10).Value; -- -0.0129 | |
A2A : Long_Float := Constituents(11).Value; -- -0.062 | |
SYA : Long_Float := Constituents(12).Value; -- 0.362 | |
SYP : Long_Float := Constituents(13).Value; -- 0.96 | |
EA : Long_Float := Constituents(14).Value; -- 0.284 | |
EP : Long_Float := Constituents(15).Value; -- 4.0 | |
E2A : Long_Float := Constituents(16).Value; -- -0.0227 | |
T2AYA : Long_Float := Constituents(17).Value; -- 0.04 --- | |
T2AYP : Long_Float := Constituents(18).Value; -- 0 | |
Q1 : Long_Float := Constituents(19).Value; -- -0.01 | |
Q2 : Long_Float := Constituents(20).Value; -- 9.47 | |
DA : Long_Float := Constituents(21).Value; -- -0.087 | |
DP : Long_Float := Constituents(22).Value; -- 0.17 | |
K3 : Long_Float := Constituents(23).Value; -- -0.088 | |
NA : Long_Float := Constituents(24).Value; -- 0.1 | |
NP : Long_Float := Constituents(25).Value; -- 9.6 | |
PA : Long_Float := Constituents(26).Value; -- 0.05 | |
PP : Long_Float := Constituents(27).Value; -- -6 | |
TN2A : Long_Float := Constituents(28).Value; -- 0 --- | |
TN2P : Long_Float := Constituents(29).Value; | |
function Ds is new rsin (DA, Drac, DP); -- = A*sin(2*Drac*(x+p)); | |
function Ts is new rsin (TA, Trop, TP); -- = A*sin(2*Trop*(x+p)) | |
function DsB is new gsin (DSA, 2.0*Drac, DSP); -- = A*sin(2*Drac*(x+p)); | |
function TsB is new gsin (TN2A, 2.0*Trop, TN2P); -- = A*sin(2*Trop*(x+p)) | |
function T2s is new gsin (T2AYA, Trop+Drac, T2AYP); -- = A*sin((Trop+Drac)*(x+p)) | |
function As is new gsin (AA, Anom, AP); -- = A*sin(Anom*(x+p)) | |
-- function Semi is new gsin(SA, 4.0*Pi, SP); -- = A*sin(4*pi*(x+p)) | |
function Evect is new gsin(EA, 2.0*Trop-Anom-4.0*Pi, EP); -- = A*sin((2*Trop-Anom-4*pi)*(x+p)) | |
function Syn is new gsin(SYA, 2.0*Trop-4.0*Pi, SYP); -- = A*sin((2*Trop-4*pi)*(x+p)) | |
--function Annual is new gsin(YA, 2.0*Pi, YP); -- = A*cos(2*pi*(x+p)) | |
function N is new gsin (NA, Nodal, NP); -- = A*sin(Nodal*(x+p)) | |
--function N2 is new gsin (N2A, Nodal/2.0, N2P); -- = A*sin(Nodal/2.0*(x+p)) | |
function P is new gsin (PA, Peri, PP); -- = A*sin(Peri*(x+p)) | |
-- # Define the model | |
function Model (Time : in Long_Float) return Long_Float is | |
MM : Long_Float := As(Time, 0.0); | |
Msm : Long_Float := Evect(Time, 0.0); | |
Mfp : Long_Float := T2s(Time, + A2A*Mm + E2A*Msm); | |
Mf : Long_Float := Ts(Time, + A2A*Mm + E2A*Msm, T2A) + TsB(Time, + A2A*Mm + E2A*Msm); | |
Mfd : Long_Float := Ds(Time, + A2A*Mm + E2A*Msm, T2P) + DsB(Time, + A2A*Mm + E2A*Msm); | |
Msf : Long_Float := Syn(Time, + Q1*(Mf+Mfd+Mfp+Q2*Mf*Mfd)); -- + Q2*Mfp | |
begin | |
return Mf + Mfd + Mfp + Q2*Mf*Mfd + Msm + Msf + N(Time, 0.0) + P(Time, 0.0) + -- + Semi(Time) + Annual(Time) + N2(Time) | |
As(Time, + K1*(Mf+Mfd+Mfp+Q2*Mf*Mfd) + K2*Mm + K3*Msf); | |
end Model; | |
begin | |
for I in Template'Range loop | |
Time := Template(I).Date - Ref_Time; | |
declare | |
TF : Long_Float := 0.0; | |
begin | |
Tf := Model (Time); | |
Res(I) := (Time, Scaling * TF); | |
end; | |
end loop; | |
return Res; | |
end Tide_Sum; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
AMO prediction