Jump to content
Science Forums

GRAVSIM2 - an orbital mechanics simulator


CraigD

Recommended Posts

Inspired by the orbital mechanical adventures of The Prophesy, I’ve cleaned up the user interface to my gravity & acceleration simulator, and played around with it for several hours. I’d like to share the code and sample output.

 

Here’s the M[uMPS] code:

f  r R q:'$l(R)  s I=$p($p(R,";",$l(R,";")),":") i $l(I) s @I=R ;XRX: read xecute code
N (XGRAVSIM1) S G=6.6742e-11,TI=1,T=0,I9=0 F  R "XGRAVSIM1> ",R,! Q:R="."  X XGRAVSIM1("I",$S(R="R":1,R="W":2,R="":3,R?1.N:4,1:0)) ;XGRAVSIM1: interactive gravity simulator
F I2=1:1:I1-1,I1+1:1:I9 S DY=B(I2,1)-Y,DX=B(I2,2)-X,D2=DY*DY+(DX*DX),D=D2**.5,A=G*B(I2,0)/D2*TI,VY=DY/D*A+VY,VX=DX/D*A+VX ;XGRAVSIM1(1): change body I1 velocity
N (XGRAVSIM1,B,B1,I9,TI,G) F I1=1:1:I9 S VY=B(I1,11),VX=B(I1,12),Y=VY*TI/2+B(I1,1),X=VX*TI/2+B(I1,2),V="" X XGRAVSIM1(1),XGRAVSIM1(4):$D(B(I1,20)),XGRAVSIM1(5):$D(B(I1,21)) S B1(I1,11)=VY,B1(I1,12)=VX ;XGRAVSIM1(2): change all velocities
N (B,B1,I9,TI) F I=1:1:I9 S B(I,1)=B(I,11)+B1(I,11)/2*TI+B(I,1),B(I,2)=B(I,12)+B1(I,12)/2*TI+B(I,2) ;XGRAVSIM1(3): change all positions
S V=VY*VY+(VX*VX)**.5,A=B(I1,20),B(I1,21)=A*VY/V,B(I1,22)=A*VX/V ;XGRAVSIM1(4): calculate acceleration
S VY=B(I1,21)*TI+VY,VX=B(I1,22)*TI+VX ;XGRAVSIM1(5): change body I1 velocity due to defined acceleration
W "Enter: . to exit; R to enter/edit objects; W to display objects;",!," a number of iterations; Return for 1 iteration and a display",! ;XGRAVSIM1("I",0)
N (B,I9) F I=1:1 W I,". M Y,X VY,VX A: " R R,! Q:R=""  S I9=I,B(I,0)=$P(R," "),B(I,1)=$P($P(R," ",2),","),B(I,2)=$P($P(R," ",2),",",2),B(I,11)=$P($P(R," ",3),","),B(I,12)=$P($P(R," ",3),",",2) S:$P(R," ",4) B(I,20)=$P(R," ",4) ;XGRAVSIM1("I",1)
W "T=",T,! X XGRAVSIM1("W") ;XGRAVSIM1("I",2): display
X XGRAVSIM1(2),XGRAVSIM1(3) M B=B1 s T=T+TI X XGRAVSIM1("I",2) ;XGRAVSIM1("I",3): 1 itteration, display
F I=1:1:R X XGRAVSIM1(2),XGRAVSIM1(3) M B=B1 s T=T+TI ;XGRAVSIM1("I",4): R itterations
N (B,I9) F I=1:1:I9 W I,". M Y,X VY,VX: ",B(I,0),!," ",B(I,1),",",B(I,2)," (",B(I,1)**2+(B(I,2)**2)**.5,")",!," ",B(I,11),",",B(I,12)," (",B(I,11)**2+(B(I,12)**2)**.5,")",! ;XGRAVSIM1("W"): display all
n (XGRAVSIM1,XGRAVSIM2) x XGRAVSIM2(3,1) s QF=0 f  q:QF  x XGRAVSIM2(0,0) f  s I=$o(XGRAVSIM2(I)) q:'I  x XGRAVSIM2(I) ;XGRAVSIM2: gravity/thrust simulator w/ cleaned-up interface
w:$x ! r "XGRAVSIM2>",R,! s R=$p($p($p(R,">",$l(R,">")),";"),"'"),CC=$tr(R,"quithelpklmyxvarwnf","QUITHELPKLMYXVARWNF"),(R,CP,CK)="" x XGRAVSIM2(0,1) ;XGRAVSIM2(0,0)
s C=$p(CC,","),$p(CC,",")="",$e(CC)="",CK=$s(CK]"":CK_",",1:"")_C,I=$s(C="":99,1:0) ;XGRAVSIM2(0,1): next input item
w:$x ! w:$l(R) R,! s I=99 ;XGRAVSIM2(0,2): error stop
i C="QUIT" s (I,QF)=99 ;XGRAVSIM2(1)
i C?1(1"?",1"H",1"HELP") x XGRAVSIM2(2,1) s I=99 ;XGRAVSIM2(2)
n (XGRAVSIM2) s N="" f  s N=$o(XGRAVSIM2(2,1,N)) q:'N  w $p(XGRAVSIM2(2,1,N),";"),! ;XGRAVSIM2(2,1)
Enter - K or KILL to clear all objects from the simulation ;XGRAVSIM2(2,1,1)
     - an object number, property, =, and a value to set its value (eg: ;XGRAVSIM2(2,1,2)
      1M=5.9736e24) ;XGRAVSIM2(2,1,3)
     - G or GO, a space, and a number of itterations to run the simulation ;XGRAVSIM2(2,1,4)
     - W or WRITE, alone, followed by an object number, or an object number ;XGRAVSIM2(2,1,5)
      and a property to to display all properties, all properties for an ;XGRAVSIM2(2,1,6)
      object, or a single property (eg: W or W 1 or W1M) ;XGRAVSIM2(2,1,7)
     - W or WRITE, 2 object numbers separated by a dash, and a property to ;XGRAVSIM2(2,1,7.1)
      display the difference in properties or a property of 2 objects (eg: ;XGRAVSIM2(2,1,7.2)
      W 1-2D) ;XGRAVSIM2(2,1,7.3)
     - One or more of the above, separated by commas. Repeated object numbers ;XGRAVSIM2(2,1,8)
      or Ws may be skipped (eg: 3A=0.1,G 60,W 3X,Y) ;XGRAVSIM2(2,1,9)
     - QUIT to exit the simulation ;XGRAVSIM2(2,1,10)
     - R or REPEAT and a number (n) to repeat the preceeding commands n times ;XGRAVSIM2(2,1,10.1)
      (eg: G 60,W 1-2D,1-2V,/LF,R 10) ;XGRAVSIM2(2,1,10.2)
Note - Object have the following required properties: M=mass, Y,X=position, ;XGRAVSIM2(2,1,11)
     VY,VX=velocity, and the following optional properties: A=acceleration (in ;XGRAVSIM2(2,1,11.1)
     direction of travel), AY,AX=acceleration ;XGRAVSIM2(2,1,11.2)
    - Pairs of objects have the following properties: D=distance, V=relative ;XGRAVSIM2(2,1,11.3)
     velocity. These cannot be set, only displayed ;XGRAVSIM2(2,1,11.4)
    - the T property is number of seconds into the simulation ;XGRAVSIM2(2,1,11.5)
    - /LF may be used as display property (eg: W /LF) to insert a newline ;XGRAVSIM2(2,1,11.6)
     into display output ;XGRAVSIM2(2,1,11.7)
i C="KILL" x XGRAVSIM2(3,1),XGRAVSIM2(0,1) ;XGRAVSIM2(3)
k B S G=6.6742e-11,TI=1,T=0,I9=0 ;XGRAVSIM2(3,1)
n (XGRAVSIM2,B,I9,CP,C,CC,CK,I)  x XGRAVSIM2(4,1) i  x XGRAVSIM2(4,2) e  x XGRAVSIM2(4,3) e  x XGRAVSIM2(4,4) e  x XGRAVSIM2(4,5) ;XGRAVSIM2(4): 9AA=999
s:CP_C?1.n1.a1"=".e&(C?1.a1"=".e) C=CP_C i C?1(1.n,1"N")1.2a1"=".e ;XGRAVSIM2(4,1)
s I1=$s(C?1"N":I9+1,1:+C),L1=$s(C?1"N".e:1,1:$l(I1)+1),CP=I1 i I9+1'=I1&'$d(B(I1))!($e(C,L1)'?1a) s R="invalid object "_$p(C,"=") x XGRAVSIM2(0,2) ;XGRAVSIM2(4,2)
s V=$p(C,"=",2) s:V?.n.1".".n1"E".1"-"1.3n&($p(V,"E",2)>-129)&($p(V,"E",2)<145) V=+V i $S(+V?1".".E:0,1:"")_+V'=V s R="invalid value "_$p(C,"=",2) x XGRAVSIM2(0,2) ;XGRAVSIM2(4,3)
s J=" M:0 Y:1 X:2 VY:11 VX:12 A:20 AY:21 AX:22",$e(J,1,$f(J," "_$p($e(C,L1,$l(C)),"=")_":")-1)="",J=$P(J," ") i J="" s R="invalid property "_$p(C,"=") x XGRAVSIM2(0,2) ;XGRAVSIM2(4,4)
s:I1>I9 I9=I1 s B(I1,J)=V x XGRAVSIM2(4,6),XGRAVSIM2(0,1) ;XGRAVSIM2(4,5)
n J k:'$g(B(I1,20)) B(I1,20),B(I1,21),B(I1,22) f J=0,1,2,11,12 s B(I1,J)=$g(B(I1,J),0) ;XGRAVSIM2(4,6): assure required fields set
n (XGRAVSIM1,XGRAVSIM2,B,I9,C,CC,CK,I,T,TI,G) i C?1(1"G",1"GO").1(1" "1.n) x XGRAVSIM2(5,1),XGRAVSIM2(0,1) ;XGRAVSIM2(5): run n times
s K=$p(C," ",2) f C=1:1:$s(K:K,1:1) X XGRAVSIM1(2),XGRAVSIM1(3) M B=B1 s T=T+TI ;XGRAVSIM2(5,1)
n (XGRAVSIM2,B,I9,CP,C,CC,CK,I,T,TI) x XGRAVSIM2(5.9,1) i  x XGRAVSIM2(5.9,2) e  s CP="W ",V=@K,R=$s($x:",",1:"") x XGRAVSIM2(6,2),XGRAVSIM2(0,1) ;XGRAVSIM2(5.9): write global property
s:CP?1"W ".E&(C?1a.an) C="W "_C i C?1(1"W",1"WRITE")1" "1a.an ;XGRAVSIM2(5.9,1)
s (K,KJ)=$p(C," ",2) i K'?1(1"I9",1"T",1"TI",1"G") s R="invalid property "_K x XGRAVSIM2(0,2) ;XGRAVSIM2(5.9,2)
n (XGRAVSIM2,B,I9,CP,C,CC,CK,I,T,TI,G) i C?1(1"W",1"WRITE") x XGRAVSIM2(6,0),XGRAVSIM2(6,3) W ! X XGRAVSIM2(0,1) ;XGRAVSIM2(6): write (output) all
f I1=1:1:I9 x XGRAVSIM2(6,1) w ! ;XGRAVSIM2(6,0)
s R=I1 f KJ="M:0","Y:1","X:2","VY:11","VX:12","A:20:1","AY:21:1:20","AX:22:1:20" s J=$p(KJ,":",2),V=+$g(B(I1,J)),J2=$p(KJ,":",4) i V!'$p(KJ,":",3),$s(J2:'$g(B(I1,J2)),1:1) x XGRAVSIM2(6,2) s R="," ;XGRAVSIM2(6,1): write all for 1 object
n (R,KJ,V) s W=$p(KJ,":")_"="_V,R=$g(R) W:$l(W)+$l(R)+$x>79&$x ! s:R=","&'$x R="" s:$x&R R=","_R w R,W ;XGRAVSIM2(6,2): write 1 property
s R="" f KJ="G","I9","T","TI" s V=@KJ x XGRAVSIM2(6,2) s R="," ;XGRAVSIM2(6,3): global properties
n (XGRAVSIM2,B,I9,CP,C,CC,CK,I) x XGRAVSIM2(6.1,1) i  x XGRAVSIM2(6.1,2) e  s CP="W " x XGRAVSIM2(6,1),XGRAVSIM2(0,1) ;XGRAVSIM2(6.1): write (output) 1 object
s:CP_C?1(1"W",1"WRITE")1" "1.n C=CP_C i C?1(1"W",1"WRITE")1." "1.n ;XGRAVSIM2(6.1,1)
s I1=+$p(C," ",2) i '$d(B(I1)) s R="invalid object "_$p(C," ",2) x XGRAVSIM2(0,2) ;XGRAVSIM2(6.1,2)
n (XGRAVSIM2,B,I9,CP,C,CC,CK,I) x XGRAVSIM2(6.2,1) i  x XGRAVSIM2(6.2,2) e  x XGRAVSIM2(6.2,3) e  s R=I1,V=$g(B(I1,$p(KJ,":",2))),CP="W "_I1 x XGRAVSIM2(6,2),XGRAVSIM2(0,1) ;XGRAVSIM2(6.2): write 1 property
s:CP_C?1(1"W",1"WRITE")1" "1.n1.2a C=$S('C:CP,1:"W ")_C i C?1(1"W",1"WRITE")1." "1.n1.2a ;XGRAVSIM2(6.2,1)
s I1=+$p(C," ",2),L1=$l($p(C," "))+$l(I1)+2 i '$d(B(I1)) s R="invalid object "_$p(C," ",2) x XGRAVSIM2(0,2) ;XGRAVSIM2(6.2,2)
s J=" M:0 Y:1 X:2 VY:11 VX:12 A:20 AY:21 AX:22",$e(J,1,$f(J," "_$e(C,L1,$l(C))_":")-3-$l(C)+L1)="",KJ=$P(J," ") i KJ="" s R="invalid property "_$e(C,L1,$l(C)) x XGRAVSIM2(0,2) ;XGRAVSIM2(6.2,3)
n (XGRAVSIM2,B,I9,CP,C,CC,CK,I) x XGRAVSIM2(7,1) i  x XGRAVSIM2(7,2) e  x XGRAVSIM2(7,3) i  s CP="W ",R=$s($x:",",1:"")_I1_"-"_I2 x XGRAVSIM2(6,2),XGRAVSIM2(0,1) ;XGRAVSIM2(7): W 9-9A
s:CP?1"W ".E&("W "_C?1(1"W",1"WRITE")1" "1.n1"-"1.n1.a) C="W "_C i C?1(1"W",1"WRITE")1." "1.n1"-"1.n1.a ;XGRAVSIM2(7,1)
s J=$p(C," ",2),I1=$p(J,"-"),I2=+$p(J,"-",2),L1=$l(I1)+$l(I2)+2,K=$e($P(C," ",2),L1,$l(C)) i '$d(B(I1))!'$d(B(I2)) s R="invalid object(s) "_J x XGRAVSIM2(0,2) ;XGRAVSIM2(7,2)
x XGRAVSIM2(7,3,1),XGRAVSIM2(7,3,2) e  s R="invalid property "_K x XGRAVSIM2(0,2) ;XGRAVSIM2(7,3)
s J=" M:0 Y:1 X:2 VY:11 VX:12 A:20 AY:21 AX:22",$e(J,1,$f(J," "_K_":")-$L(K)-2)="",KJ=$P(J," "),J=$p(KJ,":",2) i KJ]"" s V=$g(B(I1,J))-$g(B(I2,J)) ;XGRAVSIM2(7,3,1)
i KJ="" s J=" D:1,2 V:11,12",$e(J,1,$f(J," "_K_":")-$L(K)-2)="",KJ=$P(J," "),JJ=$p(KJ,":",2) i KJ]"" x XGRAVSIM2(7,3,2,1) s V=V**.5 ;XGRAVSIM2(7,3,2): derived property
s V=0 f N=1:1:$l(JJ,",") s J=$p(JJ,",",N),V=$g(B(I1,J))-$g(B(I2,J))**2+V ;XGRAVSIM2(7,3,2,1)
n (XGRAVSIM2,C,CC,CK,I) i C?1(1"R",1"REPEAT").1" "1.n s N=$p(C," ",2) s:N>0&(CK[",") CC=$P(CK,",",1,$L(CK,",")-1)_",R "_(N-1)_$s(CC="":"",1:","_CC),CK="" x XGRAVSIM2(0,1) ;XGRAVSIM2(8): repeatpreceeding commands
n (XGRAVSIM2,CP,C,CC,CK,I) x XGRAVSIM2(9,1) i  x XGRAVSIM2(9,2) ;XGRAVSIM2(9): display control
s:CP?1"W ".E&(C?1"/"1a.an) C="W "_C i C?1(1"W",1"WRITE")1" /"1a.an ;XGRAVSIM2(9,1)
s K=$p(C," ",2),N=0 f  s N=$o(XGRAVSIM2(9,2,N)) q:'N  x XGRAVSIM2(9,2,N) ;XGRAVSIM2(9,2)
i K="/LF" w ! x XGRAVSIM2(0,1) s N=99,CP="W " ;XGRAVSIM2(9,2,1)
s R="syntax error "_K x XGRAVSIM2(0,2) ;XGRAVSIM2(9,2,99)
n (XGRAVSIM2,T,TI,G,C,CC,CK,I) i C?1.a1"=".e x XGRAVSIM2(10,1) e  x XGRAVSIM2(4,3) e  s @K=V x XGRAVSIM2(0,1) ;XGRAVSIM2(10):
s K=$p(C,"=") i K'?1(1"T",1"TI",1"G") s R="invalid property "_K x XGRAVSIM2(0,2) ;XGRAVSIM2(10,1)
s R="syntax error "_C S:CK'["," R=R_"- enter ? for information" x XGRAVSIM2(0,2) ;XGRAVSIM2(99)

x XGRAVSIM2

Folk who know M may be wondering “where’s the routine?” I don’t use one – everything is xecute code in a couple of local symbols XGRAVSIM1 and XGRAVSIM2. I use a nifty code management system for this sort of stuff, but the above can be set up and run just by pasting it into a M direct mode terminal session. (Everything you need to get a free copy of M is described in this post)

 

Here’s a sample of my attempt at a low earth to geosynchronous transfer maneuver, using a rocket with a 1 g (10 m/s^2) “kick motor”:

USER>x XGRAVSIM2
XGRAVSIM2>?
Enter - K or KILL to clear all objects from the simulation
     - an object number, property, =, and a value to set its value (eg:
      1M=5.9736e24)
     - G or GO, a space, and a number of itterations to run the simulation
     - W or WRITE, alone, followed by an object number, or an object number
      and a property to to display all properties, all properties for an
      object, or a single property (eg: W or W 1 or W1M)
     - W or WRITE, 2 object numbers separated by a dash, and a property to
      display the difference in properties or a property of 2 objects (eg:
      W 1-2D)
     - One or more of the above, separated by commas. Repeated object numbers
      or Ws may be skipped (eg: 3A=0.1,G 60,W 3X,Y)
     - QUIT to exit the simulation
     - R or REPEAT and a number (n) to repeat the preceeding commands n times
      (eg: G 60,W 1-2D,1-2V,/LF,R 10)
Note - Object have the following required properties: M=mass, Y,X=position,
     VY,VX=velocity, and the following optional properties: A=acceleration (in
     direction of travel), AY,AX=acceleration
    - Pairs of objects have the following properties: D=distance, V=relative
     velocity. These cannot be set, only displayed
    - the T property is number of seconds into the simulation
    - /LF may be used as display property (eg: W /LF) to insert a newline
     into display output
XGRAVSIM2>KILL
XGRAVSIM2>1M=5973600000000000000000000,Y=0,X=0,VY=0,VX=0;earth
XGRAVSIM2>2M=1000,Y=6772797,X=0,VY=0,VX=7690;ship in LEO
XGRAVSIM2>2A=10,G 239,2A=0,T,1-2D,1-2V;239 sec 10 m/s^2 burn
T=239,1-2D=6832861.525479620895,1-2V=10025.18527780891226
XGRAVSIM2>G 3600,W T,1-2D,1-2V,/LF,R 3;coasting up to GEO
T=3839,1-2D=19995597.72527654048,1-2V=4866.65218568410039
T=7439,1-2D=30149829.25506655552,1-2V=3202.151350430838447
T=11039,1-2D=36733860.72120118874,1-2V=2348.07866533316713
T=14639,1-2D=40669625.9661864065,1-2V=1847.377509990263565
XGRAVSIM2>G 60,W T,1-2D,1-2V,/LF,R 49
T=14699,1-2D=40715515.88516291639,1-2V=1841.386892333956825
T=14759,1-2D=40760788.77419431781,1-2V=1835.470946367032488
T=14819,1-2D=40805445.72749779146,1-2V=1829.629668947971579
T=14879,1-2D=40849487.8217351429,1-2V=1823.863062383314888
T=14939,1-2D=40892916.11615586356,1-2V=1818.171134269825648
T=14999,1-2D=40935731.65273737193,1-2V=1812.553897336676547
T=15059,1-2D=40977935.45632247904,1-2V=1807.011369287635779
T=15119,1-2D=41019528.53475411918,1-2V=1801.543572643231207
T=15179,1-2D=41060511.87900738715,1-2V=1796.150534582875732
T=15239,1-2D=41100886.46331892316,1-2V=1790.832286786941184
T=15299,1-2D=41140653.24531368248,1-2V=1785.588865278772305
T=15359,1-2D=41179813.16612912994,1-2V=1780.420310266636586
T=15419,1-2D=41218367.15053689565,1-2V=1775.326665985609996
T=15479,1-2D=41256316.10706192855,1-2V=1770.30798053940292
T=15539,1-2D=41293660.92809918311,1-2V=1765.364305742134863
T=15599,1-2D=41330402.49002787445,1-2V=1760.495696960070832
T=15659,1-2D=41366541.65332333512,1-2V=1755.702212953336542
T=15719,1-2D=41402079.2626665067,1-2V=1750.983915717633928
T=15779,1-2D=41437016.14705109875,1-2V=1746.340870325982664
T=15839,1-2D=41471353.11988844632,1-2V=1741.773144770517748
T=15899,1-2D=41505090.97911009676,1-2V=1737.28080980437739
T=15959,1-2D=41538230.50726815562,1-2V=1732.863938783719703
T=16019,1-2D=41570772.47163342069,1-2V=1728.522607509910851
T=16079,1-2D=41602717.62429133312,1-2V=1724.256894071931528
T=16139,1-2D=41634066.70223577299,1-2V=1720.066878689052681
T=16199,1-2D=41664820.42746072595,1-2V=1715.952643553835473
T=16259,1-2D=41694979.5070498482,1-2V=1711.914272675514455
T=16319,1-2D=41724544.63326395455,1-2V=1707.951851723826899
T=16379,1-2D=41753516.48362645495,1-2V=1704.065467873354927
T=16439,1-2D=41781895.72100676376,1-2V=1700.255209648451062
T=16499,1-2D=41809682.99370170555,1-2V=1696.521166768821211
T=16559,1-2D=41836878.93551494004,1-2V=1692.863429995842865
T=16619,1-2D=41863484.16583442929,1-2V=1689.282090979699596
T=16679,1-2D=41889499.28970796811,1-2V=1685.777242107416285
T=16739,1-2D=41914924.89791679966,1-2V=1682.348976351882727
T=16799,1-2D=41939761.5670473365,1-2V=1678.997387121956231
T=16859,1-2D=41964009.85956100707,1-2V=1675.722568113736742
T=16919,1-2D=41987670.32386224725,1-2V=1672.524613163110738
T=16979,1-2D=42010743.49436465571,1-2V=1669.403616099662721
T=17039,1-2D=42033229.89155533153,1-2V=1666.359670602055456
T=17099,1-2D=42055130.02205741195,1-2V=1663.392870054982336
T=17159,1-2D=42076444.37869082738,1-2V=1660.503307407797227
T=17219,1-2D=42097173.44053129035,1-2V=1657.691075034928932
T=17279,1-2D=42117317.67296753478,1-2V=1654.95626459818901
T=17339,1-2D=42136877.52775682128,1-2V=1652.298966911083002
T=17399,1-2D=42155853.44307872329,1-2V=1649.719271805236337
T=17459,1-2D=42174245.84358720946,1-2V=1647.217267999046971
T=17519,1-2D=42192055.14046103579,1-2V=1644.793042968677595
T=17579,1-2D=42209281.73145246132,1-2V=1642.446682821500596
T=17639,1-2D=42225926.00093430141,1-2V=1640.178272172109151
XGRAVSIM2>G 600,W T,1-2D,1-2V,/LF,R 1
T=18239,1-2D=42360416.094458723,1-2V=1621.798701836470701
T=18839,1-2D=42436999.04580155004,1-2V=1611.291799271928731
XGRAVSIM2>G 60,W T,1-2D,1-2V,/LF,R 7
T=18899,1-2D=42441480.07296954139,1-2V=1610.676074629445822
T=18959,1-2D=42445383.92476241984,1-2V=1610.139572046677634
T=19019,1-2D=42448710.68714835247,1-2V=1609.682315097898868
T=19079,1-2D=42451460.43337288621,1-2V=1609.30432393138402
T=19139,1-2D=42453633.22396741969,1-2V=1609.005615241716215
T=19199,1-2D=42455229.1067562032,1-2V=1608.786202246850011
T=19259,1-2D=42456248.11686186768,1-2V=1608.646094669955492
T=19319,1-2D=42456690.27670948483,1-2V=1608.585298726065283
XGRAVSIM2>2A=10,G 140,W T,1-2D,1-2V,/LF;145 S 10 m/s^2 burn
T=19464,1-2D=42455664.35223149843,1-2V=3058.67243656596648
XGRAVSIM2>2A=5,G 1,2A=0,W T,1-2D,1-2V,/LF;motor shutdown
T=19465,1-2D=42455650.01723357535,1-2V=3063.673472361365328
XGRAVSIM2>G 1,W T,1-2D,1-2V,/LF,R 3
T=19466,1-2D=42455635.67023374623,1-2V=3063.674508178416615
T=19467,1-2D=42455621.32311971638,1-2V=3063.675544004062768
T=19468,1-2D=42455606.97589156047,1-2V=3063.676579838298407
XGRAVSIM2>G 3600,W T,1-2D,1-2V,/LF,R 48;coasting in GEO
T=23068,1-2D=42403801.2946082409,1-2V=3067.419105619079941
T=26668,1-2D=42354013.502191021,1-2V=3071.020170076249249
T=30268,1-2D=42309617.04453727134,1-2V=3074.234867434226101
T=33868,1-2D=42273639.70638882778,1-2V=3076.842428320038246
T=37468,1-2D=42248548.75718741211,1-2V=3078.662285624526562
T=41068,1-2D=42236072.16649186909,1-2V=3079.567622189195996
T=44668,1-2D=42237071.40682698154,1-2V=3079.495104599903054
T=48268,1-2D=42251477.42884209427,1-2V=3078.449811876693419
T=51868,1-2D=42278295.80807463389,1-2V=3076.504838558604078
T=55468,1-2D=42315680.57693370025,1-2V=3073.795614555966867
T=59068,1-2D=42361069.84388958761,1-2V=3070.509539395104848
T=62668,1-2D=42411370.91990547672,1-2V=3066.871978488929495
T=66268,1-2D=42463179.02330725857,1-2V=3063.129945449111296
T=69868,1-2D=42513012.02254083012,1-2V=3059.534874121450354
T=73468,1-2D=42557543.98701361643,1-2V=3056.325789350131468
T=77068,1-2D=42593822.11462934855,1-2V=3053.713970760362597
T=80668,1-2D=42619454.30106051182,1-2V=3051.86993515598649
T=84268,1-2D=42632757.63599604055,1-2V=3050.913299373780079
T=87868,1-2D=42632861.02356079427,1-2V=3050.905865992325141
T=91468,1-2D=42619757.70026436111,1-2V=3051.848114567344366
T=95068,1-2D=42594305.64116917879,1-2V=3053.679174575139722
T=98668,1-2D=42558175.83914910448,1-2V=3056.28028060731105
T=102268,1-2D=42513750.43446145229,1-2V=3059.481634969348297
T=105868,1-2D=42463974.88437269641,1-2V=3063.072497025489898
T=109468,1-2D=42412170.93286952944,1-2V=3066.814159830336762
T=113068,1-2D=42361820.04842326761,1-2V=3070.455256013275422
T=116668,1-2D=42316330.01910317939,1-2V=3073.74857157319492
T=120268,1-2D=42278800.0999276043,1-2V=3076.468277214060402
T=123868,1-2D=42251801.92432563343,1-2V=3078.426270792576788
T=127468,1-2D=42237193.7293180368,1-2V=3079.486227442391411
T=131068,1-2D=42235983.86393523522,1-2V=3079.574030628823414
T=134668,1-2D=42248255.93191089722,1-2V=3078.683530773752148
T=138268,1-2D=42273162.5601254726,1-2V=3076.877025826816939
T=141868,1-2D=42308988.38168594017,1-2V=3074.280412481359657
T=145468,1-2D=42353276.33028775217,1-2V=3071.073520282791499
T=149068,1-2D=42403005.73640268771,1-2V=3067.476613675675566
T=152668,1-2D=42454806.75333386817,1-2V=3063.734354473257802
T=156268,1-2D=42505193.69596553963,1-2V=3060.098628423184861
T=159868,1-2D=42550799.89644704675,1-2V=3056.811570104001718
T=163468,1-2D=42588598.27602293106,1-2V=3054.089920733007876
T=167068,1-2D=42616094.42410258951,1-2V=3052.111589152826657
T=170668,1-2D=42631481.97750977578,1-2V=3051.005018419559786
T=174268,1-2D=42633753.04355561534,1-2V=3050.841732091316523
T=177868,1-2D=42622759.04788108256,1-2V=3051.632264812043766
T=181468,1-2D=42599219.65780283773,1-2V=3053.325567839749958
T=185068,1-2D=42564679.44852898297,1-2V=3055.811901481426949
T=188668,1-2D=42521413.95612032917,1-2V=3058.929153150103067
T=192268,1-2D=42472288.9252596383,1-2V=3062.472420736837578
T=195868,1-2D=42420579.06853179217,1-2V=3066.206551760004811
XGRAVSIM2>;not a very good GEO, but OK for a beginner?!
XGRAVSIM2>QUIT

USER>

That didn’t go very well, but it was better than my first 2 attempts!

 

This version of the code runs pretty fast, but does a lot of needless calculations of the gravitational effect of small bodies – Not a problem for a simple Earth-satellite sim like the above, but trouble for something more interesting, like roaming the Jovian moons. My next version will enhance this issue away, and likely add the 3rd spatial dimension (it’s currently only 2-D).

 

It’s fun playing space pilot with this thing, and more than a little challenging if you “play by the rules” and only use reasonable accelerations. It’s got no built-in orbital mechanics calculator, so you must either do them yourself on the side, or just try flying by the seat of your pants. Even Gemini-era rendezvous maneuvers are a lot harder to actually perform than you might think.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...