-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathmodels.jl
More file actions
123 lines (92 loc) · 2.52 KB
/
models.jl
File metadata and controls
123 lines (92 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#=
ODE models for orbital mechanics
=#
function NewtonianOrbitModel(u, model_params, t)
#=
Defines system of odes which describes motion of
point like particle with Newtonian physics, uses
u[1] = χ
u[2] = ϕ
where, p, M, and e are constants
=#
χ, ϕ = u
p, M, e = model_params
numer = (1+e*cos(χ))^2
denom = M*(p^(3/2))
χ̇ = numer / denom
ϕ̇ = numer / denom
return [χ̇, ϕ̇]
end
function RelativisticOrbitModel(u, model_params, t)
#=
Defines system of odes which describes motion of
point like particle in schwarzschild background, uses
u[1] = χ
u[2] = ϕ
where, p, M, and e are constants
=#
χ, ϕ = u
p, M, e = model_params
numer = (p-2-2*e*cos(χ)) * (1+e*cos(χ))^2
denom = sqrt( (p-2)^2-4*e^2 )
χ̇ = numer * sqrt( p-6-2*e*cos(χ) )/( M*(p^2)*denom )
ϕ̇ = numer / (M*(p^(3/2))*denom)
return [χ̇, ϕ̇]
end
function AbstractNNOrbitModel(u, model_params, t; NN=nothing, NN_params=nothing)
#=
Defines system of odes which describes motion of
point like particle with Newtonian physics, uses
u[1] = χ
u[2] = ϕ
where, p, M, and e are constants
=#
χ, ϕ = u
p, M, e = model_params
if isnothing(NN)
nn = [1,1]
else
nn = 1 .+ NN([u[1]], NN_params, st)[1]
end
numer = (1 + e*cos(χ))^2
denom = M*(p^(3/2))
χ̇ = (numer / denom) * nn[1]
ϕ̇ = (numer / denom) * nn[2]
return [χ̇, ϕ̇]
end
function AbstractNROrbitModel(u, model_params, t;
NN_chiphi=nothing, NN_chiphi_params=nothing,
NN_pe=nothing, NN_pe_params=nothing)
#=
Defines system of odes which describes motion of
point like particle with Newtonian physics, uses
u[1] = χ
u[2] = ϕ
u[3] = p
u[4] = e
q is the mass ratio
=#
χ, ϕ, p, e = u
q = model_params[1]
M=1.0
if p <= 0
println("p = ", p)
end
if isnothing(NN_chiphi)
nn_chiphi = [1,1]
else
nn_chiphi = 1 .+ NN_chiphi(u, NN_chiphi_params, st)
end
if isnothing(NN_pe)
nn_pe = [0,0]
else
nn_pe = NN_pe(u, NN_pe_params, st)
end
numer = (1+e*cos(χ))^2
denom = M*(abs(p)^(3/2))
χ̇ = (numer / denom) * nn_chiphi[1]
ϕ̇ = (numer / denom) * nn_chiphi[2]
ṗ = nn_pe[1]
ė = nn_pe[2]
return [χ̇, ϕ̇, ṗ, ė]
end