|
30 | 30 | "outputs": [], |
31 | 31 | "source": [ |
32 | 32 | "import datetime as dt\n", |
| 33 | + "from pathlib import Path\n", |
33 | 34 | "\n", |
| 35 | + "import rocketpy as rp\n", |
34 | 36 | "from rocketpy import (\n", |
35 | 37 | " Attachment,\n", |
36 | 38 | " Deployable,\n", |
37 | 39 | " DeploymentEvent,\n", |
38 | 40 | " Environment,\n", |
| 41 | + " FlightBody,\n", |
39 | 42 | " IgnitionEvent,\n", |
40 | 43 | " Mission,\n", |
41 | 44 | " MissionExecutor,\n", |
| 45 | + " Parachute,\n", |
42 | 46 | " Rocket,\n", |
43 | 47 | " RocketAdapter,\n", |
44 | 48 | " SolidMotor,\n", |
45 | 49 | " Stage,\n", |
46 | 50 | " StageSeparationEvent,\n", |
47 | 51 | ")\n", |
48 | | - "from rocketpy.plots.compare import CompareFlights" |
| 52 | + "from rocketpy.plots.compare import CompareFlights\n" |
49 | 53 | ] |
50 | 54 | }, |
51 | 55 | { |
|
100 | 104 | "metadata": {}, |
101 | 105 | "outputs": [], |
102 | 106 | "source": [ |
103 | | - "def build_pro75_m1670():\n", |
104 | | - " return SolidMotor(\n", |
105 | | - " thrust_source=\"data/motors/cesaroni/Cesaroni_M1670.eng\",\n", |
106 | | - " burn_time=3.9,\n", |
107 | | - " dry_mass=1.815,\n", |
108 | | - " dry_inertia=(0.125, 0.125, 0.002),\n", |
109 | | - " center_of_dry_mass_position=0.317,\n", |
110 | | - " nozzle_position=0,\n", |
111 | | - " grain_number=5,\n", |
112 | | - " grain_density=1815,\n", |
113 | | - " nozzle_radius=33 / 1000,\n", |
114 | | - " throat_radius=11 / 1000,\n", |
115 | | - " grain_separation=5 / 1000,\n", |
116 | | - " grain_outer_radius=33 / 1000,\n", |
117 | | - " grain_initial_height=120 / 1000,\n", |
118 | | - " grains_center_of_mass_position=0.397,\n", |
119 | | - " grain_initial_inner_radius=15 / 1000,\n", |
120 | | - " interpolation_method=\"linear\",\n", |
121 | | - " coordinate_system_orientation=\"nozzle_to_combustion_chamber\",\n", |
122 | | - " )\n", |
| 107 | + "data_directory = Path(rp.__file__).resolve().parent.parent / \"data\"\n", |
| 108 | + "motor_file = data_directory / \"motors\" / \"cesaroni\" / \"Cesaroni_M1670.eng\"\n", |
| 109 | + "power_off_drag_file = (\n", |
| 110 | + " data_directory / \"rockets\" / \"calisto\" / \"powerOffDragCurve.csv\"\n", |
| 111 | + ")\n", |
| 112 | + "power_on_drag_file = data_directory / \"rockets\" / \"calisto\" / \"powerOnDragCurve.csv\"\n", |
123 | 113 | "\n", |
| 114 | + "first_stage_motor = SolidMotor(\n", |
| 115 | + " thrust_source=str(motor_file),\n", |
| 116 | + " burn_time=3.9,\n", |
| 117 | + " dry_mass=1.815,\n", |
| 118 | + " dry_inertia=(0.125, 0.125, 0.002),\n", |
| 119 | + " center_of_dry_mass_position=0.317,\n", |
| 120 | + " nozzle_position=0,\n", |
| 121 | + " grain_number=5,\n", |
| 122 | + " grain_density=1815,\n", |
| 123 | + " nozzle_radius=33 / 1000,\n", |
| 124 | + " throat_radius=11 / 1000,\n", |
| 125 | + " grain_separation=5 / 1000,\n", |
| 126 | + " grain_outer_radius=33 / 1000,\n", |
| 127 | + " grain_initial_height=120 / 1000,\n", |
| 128 | + " grains_center_of_mass_position=0.397,\n", |
| 129 | + " grain_initial_inner_radius=15 / 1000,\n", |
| 130 | + " interpolation_method=\"linear\",\n", |
| 131 | + " coordinate_system_orientation=\"nozzle_to_combustion_chamber\",\n", |
| 132 | + ")\n", |
124 | 133 | "\n", |
125 | | - "def build_stage_rocket(name, dry_mass, motor_position, fin_position, nose_position):\n", |
126 | | - " rocket = Rocket(\n", |
127 | | - " radius=0.0635,\n", |
128 | | - " mass=dry_mass,\n", |
129 | | - " inertia=(6.321, 6.321, 0.034),\n", |
130 | | - " power_off_drag=\"data/rockets/calisto/powerOffDragCurve.csv\",\n", |
131 | | - " power_on_drag=\"data/rockets/calisto/powerOnDragCurve.csv\",\n", |
132 | | - " center_of_mass_without_motor=0,\n", |
133 | | - " coordinate_system_orientation=\"tail_to_nose\",\n", |
134 | | - " )\n", |
135 | | - " rocket.name = name\n", |
136 | | - " rocket.add_motor(build_pro75_m1670(), position=motor_position)\n", |
137 | | - " rocket.set_rail_buttons(\n", |
138 | | - " upper_button_position=0.0818,\n", |
139 | | - " lower_button_position=-0.618,\n", |
140 | | - " angular_position=45,\n", |
141 | | - " )\n", |
142 | | - " rocket.add_nose(length=0.55829, kind=\"von karman\", position=nose_position)\n", |
143 | | - " rocket.add_trapezoidal_fins(\n", |
144 | | - " n=4,\n", |
145 | | - " root_chord=0.120,\n", |
146 | | - " tip_chord=0.060,\n", |
147 | | - " span=0.110,\n", |
148 | | - " position=fin_position,\n", |
149 | | - " cant_angle=0.5,\n", |
150 | | - " )\n", |
151 | | - " rocket.add_tail(\n", |
152 | | - " top_radius=0.0635,\n", |
153 | | - " bottom_radius=0.0435,\n", |
154 | | - " length=0.060,\n", |
155 | | - " position=-1.194656,\n", |
156 | | - " )\n", |
157 | | - " return rocket\n", |
| 134 | + "second_stage_motor = SolidMotor(\n", |
| 135 | + " thrust_source=str(motor_file),\n", |
| 136 | + " burn_time=3.9,\n", |
| 137 | + " dry_mass=1.815,\n", |
| 138 | + " dry_inertia=(0.125, 0.125, 0.002),\n", |
| 139 | + " center_of_dry_mass_position=0.317,\n", |
| 140 | + " nozzle_position=0,\n", |
| 141 | + " grain_number=5,\n", |
| 142 | + " grain_density=1815,\n", |
| 143 | + " nozzle_radius=33 / 1000,\n", |
| 144 | + " throat_radius=11 / 1000,\n", |
| 145 | + " grain_separation=5 / 1000,\n", |
| 146 | + " grain_outer_radius=33 / 1000,\n", |
| 147 | + " grain_initial_height=120 / 1000,\n", |
| 148 | + " grains_center_of_mass_position=0.397,\n", |
| 149 | + " grain_initial_inner_radius=15 / 1000,\n", |
| 150 | + " interpolation_method=\"linear\",\n", |
| 151 | + " coordinate_system_orientation=\"nozzle_to_combustion_chamber\",\n", |
| 152 | + ")\n", |
158 | 153 | "\n", |
| 154 | + "first_stage_rocket = Rocket(\n", |
| 155 | + " radius=0.0635,\n", |
| 156 | + " mass=14.426,\n", |
| 157 | + " inertia=(6.321, 6.321, 0.034),\n", |
| 158 | + " power_off_drag=str(power_off_drag_file),\n", |
| 159 | + " power_on_drag=str(power_on_drag_file),\n", |
| 160 | + " center_of_mass_without_motor=0,\n", |
| 161 | + " coordinate_system_orientation=\"tail_to_nose\",\n", |
| 162 | + ")\n", |
| 163 | + "first_stage_rocket.name = \"First Stage\"\n", |
| 164 | + "first_stage_rocket.add_motor(first_stage_motor, position=-1.255)\n", |
| 165 | + "first_stage_rocket.set_rail_buttons(\n", |
| 166 | + " upper_button_position=0.0818,\n", |
| 167 | + " lower_button_position=-0.618,\n", |
| 168 | + " angular_position=45,\n", |
| 169 | + ")\n", |
| 170 | + "first_stage_rocket.add_nose(length=0.55829, kind=\"von karman\", position=1.278)\n", |
| 171 | + "first_stage_rocket.add_trapezoidal_fins(\n", |
| 172 | + " n=4,\n", |
| 173 | + " root_chord=0.120,\n", |
| 174 | + " tip_chord=0.060,\n", |
| 175 | + " span=0.110,\n", |
| 176 | + " position=-1.04956,\n", |
| 177 | + " cant_angle=0.5,\n", |
| 178 | + ")\n", |
| 179 | + "first_stage_rocket.add_tail(\n", |
| 180 | + " top_radius=0.0635,\n", |
| 181 | + " bottom_radius=0.0435,\n", |
| 182 | + " length=0.060,\n", |
| 183 | + " position=-1.194656,\n", |
| 184 | + ")\n", |
159 | 185 | "\n", |
160 | | - "def build_payload_rocket(name):\n", |
161 | | - " payload = Rocket(\n", |
162 | | - " radius=0.055,\n", |
163 | | - " mass=4.5,\n", |
164 | | - " inertia=(0.25, 0.25, 0.03),\n", |
165 | | - " power_off_drag=0.55,\n", |
166 | | - " power_on_drag=0.55,\n", |
167 | | - " center_of_mass_without_motor=0,\n", |
168 | | - " coordinate_system_orientation=\"tail_to_nose\",\n", |
169 | | - " )\n", |
170 | | - " payload.name = name\n", |
171 | | - " payload.add_parachute(\n", |
172 | | - " \"Payload Drogue\",\n", |
173 | | - " cd_s=0.35,\n", |
174 | | - " trigger=\"apogee\",\n", |
175 | | - " sampling_rate=105,\n", |
176 | | - " lag=1.0,\n", |
177 | | - " noise=(0, 4.0, 0.2),\n", |
178 | | - " )\n", |
179 | | - " payload.add_parachute(\n", |
180 | | - " \"Payload Main\",\n", |
181 | | - " cd_s=3.5,\n", |
182 | | - " trigger=700,\n", |
183 | | - " sampling_rate=105,\n", |
184 | | - " lag=1.0,\n", |
185 | | - " noise=(0, 4.0, 0.2),\n", |
186 | | - " )\n", |
187 | | - " return payload" |
| 186 | + "second_stage_rocket = Rocket(\n", |
| 187 | + " radius=0.0635,\n", |
| 188 | + " mass=9.500,\n", |
| 189 | + " inertia=(6.321, 6.321, 0.034),\n", |
| 190 | + " power_off_drag=str(power_off_drag_file),\n", |
| 191 | + " power_on_drag=str(power_on_drag_file),\n", |
| 192 | + " center_of_mass_without_motor=0,\n", |
| 193 | + " coordinate_system_orientation=\"tail_to_nose\",\n", |
| 194 | + ")\n", |
| 195 | + "second_stage_rocket.name = \"Second Stage\"\n", |
| 196 | + "second_stage_rocket.add_motor(second_stage_motor, position=-1.000)\n", |
| 197 | + "second_stage_rocket.set_rail_buttons(\n", |
| 198 | + " upper_button_position=0.0818,\n", |
| 199 | + " lower_button_position=-0.618,\n", |
| 200 | + " angular_position=45,\n", |
| 201 | + ")\n", |
| 202 | + "second_stage_rocket.add_nose(length=0.55829, kind=\"von karman\", position=1.050)\n", |
| 203 | + "second_stage_rocket.add_trapezoidal_fins(\n", |
| 204 | + " n=4,\n", |
| 205 | + " root_chord=0.120,\n", |
| 206 | + " tip_chord=0.060,\n", |
| 207 | + " span=0.110,\n", |
| 208 | + " position=-0.920,\n", |
| 209 | + " cant_angle=0.5,\n", |
| 210 | + ")\n", |
| 211 | + "second_stage_rocket.add_tail(\n", |
| 212 | + " top_radius=0.0635,\n", |
| 213 | + " bottom_radius=0.0435,\n", |
| 214 | + " length=0.060,\n", |
| 215 | + " position=-1.194656,\n", |
| 216 | + ")\n", |
| 217 | + "\n", |
| 218 | + "payload_body = FlightBody(\n", |
| 219 | + " name=\"Payload\",\n", |
| 220 | + " geometry=0.055,\n", |
| 221 | + " mass_model=lambda t: 4.5,\n", |
| 222 | + " inertia_model=lambda t: (0.25, 0.25, 0.03, 0.0, 0.0, 0.0),\n", |
| 223 | + " center_of_mass_model=lambda t: 0.0,\n", |
| 224 | + " recovery_systems=[\n", |
| 225 | + " Parachute(\n", |
| 226 | + " name=\"Payload Drogue\",\n", |
| 227 | + " cd_s=0.35,\n", |
| 228 | + " trigger=\"apogee\",\n", |
| 229 | + " sampling_rate=105,\n", |
| 230 | + " lag=1.0,\n", |
| 231 | + " noise=(0, 4.0, 0.2),\n", |
| 232 | + " ),\n", |
| 233 | + " Parachute(\n", |
| 234 | + " name=\"Payload Main\",\n", |
| 235 | + " cd_s=3.5,\n", |
| 236 | + " trigger=700,\n", |
| 237 | + " sampling_rate=105,\n", |
| 238 | + " lag=1.0,\n", |
| 239 | + " noise=(0, 4.0, 0.2),\n", |
| 240 | + " ),\n", |
| 241 | + " ],\n", |
| 242 | + " coordinate_system_orientation=\"tail_to_nose\",\n", |
| 243 | + ")\n" |
188 | 244 | ] |
189 | 245 | }, |
190 | 246 | { |
|
202 | 258 | "metadata": {}, |
203 | 259 | "outputs": [], |
204 | 260 | "source": [ |
205 | | - "first_stage_rocket = build_stage_rocket(\n", |
206 | | - " name=\"First Stage\",\n", |
207 | | - " dry_mass=14.426,\n", |
208 | | - " motor_position=-1.255,\n", |
209 | | - " fin_position=-1.04956,\n", |
210 | | - " nose_position=1.278,\n", |
211 | | - ")\n", |
212 | | - "\n", |
213 | | - "second_stage_rocket = build_stage_rocket(\n", |
214 | | - " name=\"Second Stage\",\n", |
215 | | - " dry_mass=9.500,\n", |
216 | | - " motor_position=-1.000,\n", |
217 | | - " fin_position=-0.920,\n", |
218 | | - " nose_position=1.050,\n", |
219 | | - ")\n", |
220 | 261 | "second_stage_rocket.add_parachute(\n", |
221 | 262 | " \"Second Stage Main\",\n", |
222 | 263 | " cd_s=5.0,\n", |
|
226 | 267 | " noise=(0, 6.0, 0.25),\n", |
227 | 268 | ")\n", |
228 | 269 | "\n", |
229 | | - "payload_rocket = build_payload_rocket(name=\"Payload\")" |
| 270 | + "print(f\"Using motor file: {motor_file}\")\n", |
| 271 | + "print(f\"Using drag curve files: {power_off_drag_file.name}, {power_on_drag_file.name}\")\n", |
| 272 | + "print(f\"Payload body type: {type(payload_body).__name__}\")\n" |
230 | 273 | ] |
231 | 274 | }, |
232 | 275 | { |
|
296 | 339 | "\n", |
297 | 340 | "payload = Deployable(\n", |
298 | 341 | " name=\"payload\",\n", |
299 | | - " body=RocketAdapter(payload_rocket),\n", |
| 342 | + " body=payload_body,\n", |
300 | 343 | " attachment=payload_attachment,\n", |
301 | 344 | " deployment_event=payload_deploy_event,\n", |
302 | 345 | ")\n", |
303 | 346 | "\n", |
304 | 347 | "mission.add_stage(first_stage)\n", |
305 | 348 | "mission.add_stage(second_stage)\n", |
306 | | - "mission.add_deployable(payload)" |
| 349 | + "mission.add_deployable(payload)\n" |
307 | 350 | ] |
308 | 351 | }, |
309 | 352 | { |
|
0 commit comments