This scenario was created to demonstrate the use of single segment mode in Astrogator. It uses a VBA script implemented in MS Excel to execute segments of an Astrogator MCS individually. In doing so, the script can then use logic to determine when specific segments can be run.
The logic and the script are used to propagate until a perigee occurs that lies within a specific Earth Geodetic longitude range. When this longitude is achieved, the script detects this and executes a Hohman transfer to a higher orbit, circularizes there, and propagates 2 revs.
The Astrogator MCS is as follows:
The beginning Stop is used to signify that this MCS will not run in the normal GUI.
After the stop there are 5 segments called by the script:
1.
2. Prop to Periapsis: This segment is run in a loop. Each time it is run, the script tests the Longitude at the end of the segment.
3. Raise Apogee: This targeter segment raises the orbital apogee and then propagates to that apogee.
4. Circularize: This targeter circularizes the orbit once at apogee.
5. Prop Twice Around: This segment propagates twice around the orbit (2 revs).
The MSC is run by a VBA script in an excel spreadsheet called “perigee_test.xls”. When you open the spreadsheet you see the following:
When you press the ‘Start Run’ button, the script will run
the first run the ‘
The main body of the script is as follows:
'Start creating the ephemeris.
This is the same as hitting the 'Go' button in the MCS GUI, except now
we will execute segments based on
'which ones we activate in the script.
Set tf =
gator.BeginRun()
'Run the initial state segment
Set state =
gator.RunSegment(InitialState)
'Set the initial longitude to something so that it never starts off
inside the range we give it.
longitude =
450
perigee_count
= 0
'Get the start epoch from the initial state so we can tell how long
we've been running later on.
start_epoch =
InitialState.GetResultValue("Epoch").Format("EpSec") / 3600
'The GetResultValue call can be used to extract any calc object on any
MCS segment. The result does not have
'to be declared as a result on that segment.
epoch = 0
'Set the upper and lower bounds for the Search from the spreadsheet
UpperBound =
Worksheets("Work").[C9].Value
LowerBound =
Worksheets("Work").[C10].Value
'
Do Until
longitude < UpperBound And longitude > LowerBound
perigee_count = perigee_count + 1
Set state = gator.RunSegment(Perigee)
epoch = Perigee.GetResultValue("Epoch").Format("EpSec")
/ 3600 - start_epoch
Worksheets("Work").[C6].Value =
epoch
longitude =
Perigee.GetResultValue("Longitude").GetIn("Deg")
Worksheets("Work").[C7].Value
= longitude
Worksheets("Work").[C5].Value
= perigee_count
'Once the perigee has fallen within the bounds, execute the other
segments, which raise the apogee, circularize the orbit, and propagate
'for 2 Revs.
Set state =
gator.RunSegment(Perigee)
Set state =
gator.RunSegment(RaiseApogee)
Set state =
gator.RunSegment(Circularize)
Set state =
gator.RunSegment(TwiceAround)
'End the ephemeris creation and stop
Set tf =
gator.EndRun()
Michel E. Loucks
President, Space Mission
Engineer
Space Exploration
Engineering Corp.
360.378.7168
360.317.5527 (cell)