2025-06-01 10:36:07 -04:00

44 lines
1.0 KiB
Python

from orbiter.orbits.body import Body
from orbiter.orbits.simulator import Simulator
from orbiter.units import *
from pathlib import Path
from decimal import Decimal, getcontext
getcontext().prec = 50
#set up the earth
earth = Body(
Position([0,0,0]),
Velocity([0,0,0]),
Mass(norm_mass(EARTH_MASS)),
"Earth"
)
r = EARTH_RADIUS+100_000
#Lets try a body just outside earth accelerating in. Should be 9.8m/s2
person = Body(
Position([norm_pos(r),0,0]), #10_000m in the sky, airliner height!
Velocity([0,(Decimal(0.5)/norm_pos(r)).sqrt(),0]), #orbital velocity
Mass(norm_mass(80)), #avg person
"Person"
)
T = 2*pi_approx*norm_pos(r)/person.V[1]
time_to_run = T*3 #norm_time(2000)
STEP_SIZE = Decimal(6e-4)
n_steps = int(time_to_run/STEP_SIZE)
def main():
print("Before: ")
print(str(person))
print(str(earth))
import cProfile
s = Simulator([earth,person], STEP_SIZE, 100, Path("hello_world"))
cProfile.run(s.run(n_steps))
print("\nAfter:")
print(str(person))
print(str(earth))
main()