Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AE 370 Group Project 1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
adbeck2
AE 370 Group Project 1
Commits
18b6978d
Commit
18b6978d
authored
2 years ago
by
adbeck2
Browse files
Options
Downloads
Patches
Plain Diff
Earth Moon ISS System
parent
b0d74169
No related branches found
Branches containing commit
No related tags found
1 merge request
!4
Adbeck2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
RK8.txt
+110
-0
110 additions, 0 deletions
RK8.txt
Screenshot 2022-10-20 202317.png
+0
-0
0 additions, 0 deletions
Screenshot 2022-10-20 202317.png
test.py
+23
-10
23 additions, 10 deletions
test.py
with
133 additions
and
10 deletions
RK8.txt
0 → 100644
+
110
−
0
View file @
18b6978d
C_Coef = [0, .5, .5, .5 + np.sqrt(21)/ 14, .5 + np.sqrt(21)/ 14, .5, .5 - np.sqrt(21)/ 14, .5 - np.sqrt(21)/ 14, .5, .5 + np.sqrt(21)/ 14, 1]
B_Coef = [.05, 0, 0, 0, 0, 0, 0, 49/180, 16/45, 49/180, .05]
a = np.zeros((12,12))
a[2,1]=1/2
a[3,1]=1/4
a[3,2]=1/4
a[4,1]=1/7
a[4,2]=-1/14-3/98*21**(1/2)
a[4,3]=3/7+5/49*21**(1/2)
a[5,1]=11/84+1/84*21**(1/2)
a[5,2]=0
a[5,3]=2/7+4/63*21**(1/2)
a[5,4]=1/12-1/252*21**(1/2)
a[6,1]=5/48+1/48*21**(1/2)
a[6,2]=0
a[6,3]=1/4+1/36*21**(1/2)
a[6,4]=-77/120+7/180*21**(1/2)
a[6,5]=63/80-7/80*21**(1/2)
a[7,1]=5/21-1/42*21**(1/2)
a[7,2]=0
a[7,3]=-48/35+92/315*21**(1/2)
a[7,4]=211/30-29/18*21**(1/2)
a[7,5]=-36/5+23/14*21**(1/2)
a[7,6]=9/5-13/35*21**(1/2)
a[8,1]=1/14
a[8,2]=0
a[8,3]=0
a[8,4]=0
a[8,5]=1/9-1/42*21**(1/2)
a[8,6]=13/63-1/21*21**(1/2)
a[8,7]=1/9
a[9,1]=1/32
a[9,2]=0
a[9,3]=0
a[9,4]=0
a[9,5]=91/576-7/192*21**(1/2)
a[9,6]=11/72
a[9,7]=-385/1152-25/384*21**(1/2)
a[9,8]=63/128+13/128*21**(1/2)
a[10,1]=1/14
a[10,2]=0
a[10,3]=0
a[10,4]=0
a[10,5]=1/9
a[10,6]=-733/2205-1/15*21**(1/2)
a[10,7]=515/504+37/168*21**(1/2)
a[10,8]=-51/56-11/56*21**(1/2)
a[10,9]=132/245+4/35*21**(1/2)
a[11,1]=0
a[11,2]=0
a[11,3]=0
a[11,4]=0
a[11,5]=-7/3+7/18*21**(1/2)
a[11,6]=-2/5+28/45*21**(1/2)
a[11,7]=-91/24-53/72*21**(1/2)
a[11,8]=301/72+53/72*21**(1/2)
a[11,9]=28/45-28/45*21**(1/2)
a[11,10]=49/18-7/18*21**(1/2)
A_Coef = a[1:, 1:]
def k_func(k_step, func, t, state, delT, A_Coef, B_Coef, C_Coef, *args, **kwargs):
"""RK integration recursive function.
Args:
k_step: the current kfunction sub-step.
func: The ODE function to integrate.
t: The time of the initial condition state.
state: The value of the initial condition at t.
delT: The time step to integrate across.
A_Coef: The first set of Butcher Tableau Coefficients.
B_Coef: The second set of Butcher Tableau Coefficients.
C_Coef: The third set of Butcher Tableau Coefficients.
*args: Supplemental arguments for the ODE function func.
**kwargs: Supplemental argumentsfor ODE function func.
Returns:
The 'k_step'th k value for the integration step.
"""
if k_step == 1: #call the derivative function when necessary
return func(t, state, *args, **kwargs)
else:
carry = 0 #otherwise build the k value as a sum of the previous k values and thier coefficients recursively
for i in range(1, k_step):
carry += A_Coef[k_step - 1, i-1] * k_func(i-1, func, t, state, delT, A_Coef, B_Coef, C_Coef, *args, **kwargs)
return func(t + C_Coef[k_step - 1] * delT, state + delT*carry, *args, **kwargs)
def rk_step(func, t, state, delT, *args, **kwargs):
"""Generalized Runge-Kutta integrator
Args:
func: The ODE function to integrate.
t: The time of the initial condition state.
state: The value of the initial condition at t.
delT: The time step to integrate across.
A_Coef: The first set of Butcher Tableau Coefficients.
B_Coef: The second set of Butcher Tableau Coefficients.
C_Coef: The third set of Butcher Tableau Coefficients.
*args: Supplemental arguments for the ODE function func.
**kwargs: Supplemental argumentsfor ODE function func.
Returns:
Updated value of state at time t + delT.
"""
sum = 0 # sum of k functions and their coefficients.
for k_step in range(1, A_Coef.shape[1] + 1): #For each step according to the Butcher Tableau
sum += B_Coef[k_step - 1] * k_func(k_step, func, t, state, delT, A_Coef, B_Coef, C_Coef, *args, **kwargs) #Add contribution of each integration step
return state + delT * sum
This diff is collapsed.
Click to expand it.
Screenshot 2022-10-20 202317.png
0 → 100644
+
0
−
0
View file @
18b6978d
24.6 KiB
This diff is collapsed.
Click to expand it.
test.py
+
23
−
10
View file @
18b6978d
...
...
@@ -2,27 +2,40 @@ import numpy as np
from
core_functions
import
*
masses
=
[
5.972e24
,
419725
]
masses
=
[
5.972e24
,
419725
,
7.34767309e22
]
u_0
=
np
.
array
([[
0
,
0
,
0
,
0
,
0
,
0
],
[
400000
+
6378100
,
0
,
0
,
0
,
7823.6
,
0
]])
u_0
=
np
.
array
([[
0
,
0
,
0
,
0
,
0
,
0
],
[
414000
+
6378100
,
0
,
0
,
0
,
7662
,
0
],
[
363300e3
,
0
,
0
,
0
,
1081
,
0
]])
u_0
=
np
.
array
([[
0
,
0
,
0
,
0
,
0
,
0
],
[
4214929.7
,
0
,
5326067
,
0
,
7662
,
0
],
[
361836242.8
,
0
,
32579493.6
,
0
,
1081
,
0
]])
T
=
54
00
T
=
23606
00
delta_t
=
10
u
,
times
=
ivp_RK4
(
u_0
,
T
,
delta_t
,
masses
)
rx
=
[]
ry
=
[]
rz
=
[]
rx
sat
=
[]
ry
sat
=
[]
rz
sat
=
[]
for
i
in
range
(
len
(
times
)):
rx
.
append
(
u
[
i
][
1
][
0
])
ry
.
append
(
u
[
i
][
1
][
1
])
rz
.
append
(
u
[
i
][
1
][
2
])
rxsat
.
append
(
u
[
i
][
1
][
0
])
rysat
.
append
(
u
[
i
][
1
][
1
])
rzsat
.
append
(
u
[
i
][
1
][
2
])
rxmoon
=
[]
rymoon
=
[]
rzmoon
=
[]
for
i
in
range
(
len
(
times
)):
rxmoon
.
append
(
u
[
i
][
2
][
0
])
rymoon
.
append
(
u
[
i
][
2
][
1
])
rzmoon
.
append
(
u
[
i
][
2
][
2
])
import
matplotlib.pyplot
as
plt
plt
.
plot
(
rx
,
ry
)
plt
.
rcParams
[
'
figure.figsize
'
]
=
[
20
,
5
]
plt
.
plot
(
rxmoon
,
rymoon
,
label
=
'
Moon
'
)
plt
.
plot
(
rxsat
,
rysat
,
label
=
'
Satellite
'
)
plt
.
legend
()
plt
.
show
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment