|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "id": "9fd37373-d1c6-4e27-aef0-a8f6fc5fc979", |
| 6 | + "metadata": {}, |
| 7 | + "source": [ |
| 8 | + "#### this script demostrates the use of single segment mode (or individual segment mode)\n", |
| 9 | + "##### it will create a new satellite and raise apogee to 10000 km using small maneuvers at perigee using single segment mode. This is similar to the auto-sequence tutorial. The script assumes a scenario is open and does not contain a satellite named SingleSegmentSat\n", |
| 10 | + "##### author: jens ramrath, agi\n", |
| 11 | + "##### date: 23 oct 2024" |
| 12 | + ] |
| 13 | + }, |
| 14 | + { |
| 15 | + "cell_type": "markdown", |
| 16 | + "id": "6e82508a-32be-479b-961f-427f006b95d3", |
| 17 | + "metadata": {}, |
| 18 | + "source": [ |
| 19 | + "### connect to running instance of STK" |
| 20 | + ] |
| 21 | + }, |
| 22 | + { |
| 23 | + "cell_type": "code", |
| 24 | + "execution_count": null, |
| 25 | + "id": "bed5a81c-df08-4274-8fed-b44de3a94c76", |
| 26 | + "metadata": {}, |
| 27 | + "outputs": [], |
| 28 | + "source": [ |
| 29 | + "from agi.stk12.stkdesktop import STKDesktop\n", |
| 30 | + "from agi.stk12.stkobjects import *\n", |
| 31 | + "from agi.stk12.stkobjects.astrogator import *\n", |
| 32 | + "\n", |
| 33 | + "stk = STKDesktop.AttachToApplication()\n", |
| 34 | + "root = stk.Root\n", |
| 35 | + "sc = root.CurrentScenario\n", |
| 36 | + "\n", |
| 37 | + "print('connected to ' + sc.InstanceName)" |
| 38 | + ] |
| 39 | + }, |
| 40 | + { |
| 41 | + "cell_type": "markdown", |
| 42 | + "id": "bb783e0a-c93e-4d41-a22b-6458dc8f7689", |
| 43 | + "metadata": {}, |
| 44 | + "source": [ |
| 45 | + "### create new satellite and set up MCS\n", |
| 46 | + "we'll have\n", |
| 47 | + "1. Initial State - keep the default\n", |
| 48 | + "2. Propagate - replace Duration stopping condition with Periapsis\n", |
| 49 | + "3. Maneuver - 20 m/sec intrack" |
| 50 | + ] |
| 51 | + }, |
| 52 | + { |
| 53 | + "cell_type": "code", |
| 54 | + "execution_count": null, |
| 55 | + "id": "6c8ed73e-e6d4-41d2-ab4e-dd08c97e631b", |
| 56 | + "metadata": {}, |
| 57 | + "outputs": [], |
| 58 | + "source": [ |
| 59 | + "# create new satellite\n", |
| 60 | + "sat = sc.Children.New(AgESTKObjectType.eSatellite, 'SingleSegmentSat')\n", |
| 61 | + "sat.SetPropagatorType(AgEVePropagatorType.ePropagatorAstrogator)\n", |
| 62 | + "prop = sat.Propagator\n", |
| 63 | + "\n", |
| 64 | + "# initial state\n", |
| 65 | + "# get handle to initial state\n", |
| 66 | + "iSegment = prop.MainSequence.Item(0)\n", |
| 67 | + "\n", |
| 68 | + "# propagate\n", |
| 69 | + "# get handle to propagate segment\n", |
| 70 | + "pSegment = prop.MainSequence.Item(1)\n", |
| 71 | + "# add periapsis stopping condition\n", |
| 72 | + "pSegment.StoppingConditions.Add('Periapsis')\n", |
| 73 | + "# remove default Duration stopping condition\n", |
| 74 | + "pSegment.StoppingConditions.Remove('Duration')\n", |
| 75 | + "# add apoapsis radius result so we can rasily query it\n", |
| 76 | + "pSegment.Results.Add('Radius of Apoapsis')\n", |
| 77 | + "\n", |
| 78 | + "# maneuver\n", |
| 79 | + "# add maneuver at end\n", |
| 80 | + "mSegment = prop.MainSequence.InsertByName('Maneuver', '-')\n", |
| 81 | + "# specify small thrust\n", |
| 82 | + "mSegment.Maneuver.AttitudeControl.DeltaVMagnitude = 0.02" |
| 83 | + ] |
| 84 | + }, |
| 85 | + { |
| 86 | + "cell_type": "markdown", |
| 87 | + "id": "f159b2b0-35fe-45ae-98ac-b2b596da7e7e", |
| 88 | + "metadata": {}, |
| 89 | + "source": [ |
| 90 | + "### RUN" |
| 91 | + ] |
| 92 | + }, |
| 93 | + { |
| 94 | + "cell_type": "code", |
| 95 | + "execution_count": null, |
| 96 | + "id": "d0c0598e-58a5-4d60-ada9-86af511cbdfc", |
| 97 | + "metadata": {}, |
| 98 | + "outputs": [], |
| 99 | + "source": [ |
| 100 | + "# start new run\n", |
| 101 | + "prop.BeginRun()\n", |
| 102 | + "\n", |
| 103 | + "# add initial state\n", |
| 104 | + "iSegment.Run()\n", |
| 105 | + "\n", |
| 106 | + "# add propagate segment\n", |
| 107 | + "pSegment.Run()\n", |
| 108 | + "\n", |
| 109 | + "# propagate\n", |
| 110 | + "prop.EndRun()\n", |
| 111 | + "\n", |
| 112 | + "# get final apo radius\n", |
| 113 | + "rop = pSegment.GetResultValue('Radius of Apoapsis')\n", |
| 114 | + "print('apogee radius: ' + str(rop))\n", |
| 115 | + "\n", |
| 116 | + "# add maneuver and propagate segments until perigee radius is above limit\n", |
| 117 | + "while rop < 10000:\n", |
| 118 | + " # last segment state\n", |
| 119 | + " rSegment = prop.MainSequence.GetItemByName('-')\n", |
| 120 | + " \n", |
| 121 | + " # append to last segment\n", |
| 122 | + " prop.AppendRun()\n", |
| 123 | + "\n", |
| 124 | + " # add maneuver and propagate\n", |
| 125 | + " mSegment.Run()\n", |
| 126 | + " pSegment.Run()\n", |
| 127 | + "\n", |
| 128 | + " # propagate\n", |
| 129 | + " prop.EndRun()\n", |
| 130 | + " \n", |
| 131 | + " # get apo radius\n", |
| 132 | + " rop = pSegment.GetResultValue('Radius of Apoapsis')\n", |
| 133 | + " print('apogee radius: ' + str(rop))" |
| 134 | + ] |
| 135 | + }, |
| 136 | + { |
| 137 | + "cell_type": "code", |
| 138 | + "execution_count": null, |
| 139 | + "id": "d293642a-19a1-4afe-87fb-d1f808ebb1f1", |
| 140 | + "metadata": {}, |
| 141 | + "outputs": [], |
| 142 | + "source": [] |
| 143 | + } |
| 144 | + ], |
| 145 | + "metadata": { |
| 146 | + "kernelspec": { |
| 147 | + "display_name": "Python 3 (ipykernel)", |
| 148 | + "language": "python", |
| 149 | + "name": "python3" |
| 150 | + }, |
| 151 | + "language_info": { |
| 152 | + "codemirror_mode": { |
| 153 | + "name": "ipython", |
| 154 | + "version": 3 |
| 155 | + }, |
| 156 | + "file_extension": ".py", |
| 157 | + "mimetype": "text/x-python", |
| 158 | + "name": "python", |
| 159 | + "nbconvert_exporter": "python", |
| 160 | + "pygments_lexer": "ipython3", |
| 161 | + "version": "3.10.9" |
| 162 | + } |
| 163 | + }, |
| 164 | + "nbformat": 4, |
| 165 | + "nbformat_minor": 5 |
| 166 | +} |
0 commit comments