Skip to content

Commit c93e62c

Browse files
committed
ENH: Rail buttons added to nbbuilder. Other small changes made.
1 parent fca09d2 commit c93e62c

File tree

4 files changed

+1087
-161
lines changed

4 files changed

+1087
-161
lines changed

examples/ProjetoJupiter--Valetudo--2019/parameters.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"nozzle_radius": 0.01605,
4343
"position": 2.052896709219859,
4444
"throat_radius": 0.0107,
45-
"thrust_source": "examples\\ProjetoJupiter--Valetudo--2019\\thrust_source.csv"
45+
"thrust_source": "examples/ProjetoJupiter--Valetudo--2019/thrust_source.csv"
4646
},
4747
"nosecones": {
4848
"base_radius": 0.04045000000000001,
@@ -72,7 +72,7 @@
7272
"rocket": {
7373
"center_of_mass_without_propellant": 1.4023,
7474
"coordinate_system_orientation": "nose_to_tail",
75-
"drag_curve": "examples\\ProjetoJupiter--Valetudo--2019\\drag_curve.csv",
75+
"drag_curve": "examples/ProjetoJupiter--Valetudo--2019/drag_curve.csv",
7676
"inertia": [
7777
0.01467,
7878
0.01467,

examples/ProjetoJupiter--Valetudo--2019/simulation.ipynb

Lines changed: 1048 additions & 136 deletions
Large diffs are not rendered by default.

rocketserializer/nb_builder.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ def build_rocket(self, nb: nbf.v4.new_notebook):
227227
nb["cells"].append(nbf.v4.new_code_cell(text))
228228

229229
nb = self.add_parachutes_to_rocket(nb)
230+
nb = self.build_rail_buttons(nb)
230231

231232
text = "### Rocket Info\n"
232233
text += "rocket.all_info()\n"
@@ -243,7 +244,6 @@ def build_all_aerodynamic_surfaces(
243244
self.build_nosecones(nb)
244245
self.build_fins(nb)
245246
self.build_tails(nb)
246-
self.build_rail_buttons(nb)
247247
self.build_parachute(nb)
248248
logger.info("[NOTEBOOK BUILDER] All aerodynamic surfaces created.")
249249
return nb
@@ -434,7 +434,21 @@ def build_tails(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
434434
return nb
435435

436436
def build_rail_buttons(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
437-
logger.info("rail buttons not implemented yet")
437+
# add a markdown cell
438+
text = "### Rail Buttons\n"
439+
nb["cells"].append(nbf.v4.new_markdown_cell(text))
440+
rail_button_i = self.parameters["rail_buttons"]
441+
upper_position = rail_button_i["upper_position"]
442+
lower_position = rail_button_i["lower_position"]
443+
ang_position = rail_button_i["angular_position"]
444+
text = "rail_buttons = rocket.set_rail_buttons(\n"
445+
text += f" upper_button_position={upper_position:.3f},\n"
446+
text += f" lower_button_position={lower_position:.3f},\n"
447+
text += f" angular_position={ang_position:.3f},\n"
448+
text += ")\n"
449+
nb["cells"].append(nbf.v4.new_code_cell(text))
450+
451+
logger.info("[NOTEBOOK BUILDER] Rail Buttons created.")
438452
return nb
439453

440454
def build_parachute(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
@@ -535,6 +549,7 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
535549
text += "error = abs((apogee_difference)/time_to_apogee_rpy)*100"
536550
text += "\n"
537551
text += r'print(f"Time to apogee difference: {error:.3f} %")'
552+
text += "\nprint()"
538553
text += "\n\n"
539554

540555
# Flight time
@@ -550,10 +565,11 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
550565
"error_flight_time = abs((flight_time_difference)/flight_time_rpy)*100\n"
551566
)
552567
text += r'print(f"Flight time difference: {error_flight_time:.3f} %")'
568+
text += "\nprint()"
553569
text += "\n\n"
554570

555571
# Ground hit velocity
556-
ground_hit_velocity_ork = self.parameters["stored_results"][
572+
ground_hit_velocity_ork = -self.parameters["stored_results"][
557573
"ground_hit_velocity"
558574
]
559575
text += f"ground_hit_velocity_ork = {ground_hit_velocity_ork}\n"
@@ -565,6 +581,7 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
565581
text += "ground_hit_velocity_difference = ground_hit_velocity_rpy - ground_hit_velocity_ork\n"
566582
text += "error_ground_hit_velocity = abs((ground_hit_velocity_difference)/ground_hit_velocity_rpy)*100\n"
567583
text += r'print(f"Ground hit velocity difference: {error_ground_hit_velocity:.3f} %")'
584+
text += "\nprint()"
568585
text += "\n\n"
569586

570587
# Launch rod velocity
@@ -580,6 +597,7 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
580597
text += "launch_rod_velocity_difference = launch_rod_velocity_rpy - launch_rod_velocity_ork\n"
581598
text += "error_launch_rod_velocity = abs((launch_rod_velocity_difference)/launch_rod_velocity_rpy)*100\n"
582599
text += r'print(f"Launch rod velocity difference: {error_launch_rod_velocity:.3f} %")'
600+
text += "\nprint()"
583601
text += "\n\n"
584602

585603
# Max acceleration
@@ -599,6 +617,7 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
599617
text += (
600618
r'print(f"Max acceleration difference: {error_max_acceleration:.3f} %")'
601619
)
620+
text += "\nprint()"
602621
text += "\n\n"
603622

604623
# Max altitude
@@ -614,6 +633,7 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
614633
"error_max_altitude = abs((max_altitude_difference)/max_altitude_rpy)*100\n"
615634
)
616635
text += r'print(f"Max altitude difference: {error_max_altitude:.3f} %")'
636+
text += "\nprint()"
617637
text += "\n\n"
618638

619639
# Max Mach
@@ -627,6 +647,7 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
627647
text += "max_mach_difference = max_mach_rpy - max_mach_ork\n"
628648
text += "error_max_mach = abs((max_mach_difference)/max_mach_rpy)*100\n"
629649
text += r'print(f"Max Mach difference: {error_max_mach:.3f} %")'
650+
text += "\nprint()"
630651
text += "\n\n"
631652

632653
# Max velocity
@@ -642,6 +663,7 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
642663
"error_max_velocity = abs((max_velocity_difference)/max_velocity_rpy)*100\n"
643664
)
644665
text += r'print(f"Max velocity difference: {error_max_velocity:.3f} %")'
666+
text += "\nprint()"
645667
text += "\n\n"
646668

647669
# Max thrust
@@ -655,6 +677,7 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
655677
text += "max_thrust_difference = max_thrust_rpy - max_thrust_ork\n"
656678
text += "error_max_thrust = abs((max_thrust_difference)/max_thrust_rpy)*100\n"
657679
text += r'print(f"Max thrust difference: {error_max_thrust:.3f} %")'
680+
text += "\nprint()"
658681
text += "\n\n"
659682

660683
# # Burnout stability margin
@@ -670,6 +693,7 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
670693
text += "burnout_stability_margin_difference = burnout_stability_margin_rpy - burnout_stability_margin_ork\n"
671694
text += "error_burnout_stability_margin = abs((burnout_stability_margin_difference)/burnout_stability_margin_rpy)*100\n"
672695
text += r'print(f"Burnout stability margin difference: {error_burnout_stability_margin:.3f} %")'
696+
text += "\nprint()"
673697
text += "\n\n"
674698

675699
# # Max stability margin
@@ -685,6 +709,7 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
685709
text += "max_stability_margin_difference = max_stability_margin_rpy - max_stability_margin_ork\n"
686710
text += "error_max_stability_margin = abs((max_stability_margin_difference)/max_stability_margin_rpy)*100\n"
687711
text += r'print(f"Max stability margin difference: {error_max_stability_margin:.3f} %")'
712+
text += "\nprint()"
688713
text += "\n\n"
689714

690715
# Min stability margin
@@ -700,6 +725,7 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
700725
text += "min_stability_margin_difference = min_stability_margin_rpy - min_stability_margin_ork\n"
701726
text += "error_min_stability_margin = abs((min_stability_margin_difference)/min_stability_margin_rpy)*100\n"
702727
text += r'print(f"Min stability margin difference: {error_min_stability_margin:.3f} %")'
728+
text += "\nprint()"
703729
text += "\n\n"
704730

705731
nb["cells"].append(nbf.v4.new_code_cell(text))

testnbbuilder.ipynb

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 27,
5+
"execution_count": 7,
66
"metadata": {},
77
"outputs": [
88
{
@@ -21,21 +21,21 @@
2121
},
2222
{
2323
"cell_type": "code",
24-
"execution_count": 28,
24+
"execution_count": 8,
2525
"metadata": {},
2626
"outputs": [
2727
{
2828
"name": "stdout",
2929
"output_type": "stream",
3030
"text": [
31-
"Converted examples/EPFL--BellaLui--2020/rocket.ork to JSON successfully.\n"
31+
"Converted examples/ProjetoJupiter--Valetudo--2019/rocket.ork to JSON successfully.\n"
3232
]
3333
},
3434
{
3535
"name": "stderr",
3636
"output_type": "stream",
3737
"text": [
38-
"reformatted examples/EPFL--BellaLui--2020/simulation.ipynb\n",
38+
"reformatted examples/ProjetoJupiter--Valetudo--2019/simulation.ipynb\n",
3939
"\n",
4040
"All done! ✨ 🍰 ✨\n",
4141
"1 file reformatted.\n"
@@ -45,19 +45,7 @@
4545
"name": "stdout",
4646
"output_type": "stream",
4747
"text": [
48-
"Notebook for examples/EPFL--BellaLui--2020/rocket.ork built!\n",
49-
"Converted examples/rocket_with_elliptical_fins/rocket.ork to JSON successfully.\n",
50-
"Notebook for examples/rocket_with_elliptical_fins/rocket.ork built!\n"
51-
]
52-
},
53-
{
54-
"name": "stderr",
55-
"output_type": "stream",
56-
"text": [
57-
"reformatted examples/rocket_with_elliptical_fins/simulation.ipynb\n",
58-
"\n",
59-
"All done! ✨ 🍰 ✨\n",
60-
"1 file reformatted.\n"
48+
"Notebook for examples/ProjetoJupiter--Valetudo--2019/rocket.ork built!\n"
6149
]
6250
}
6351
],
@@ -68,10 +56,10 @@
6856
"from rocketserializer.nb_builder import NotebookBuilder\n",
6957
"\n",
7058
"files = [\n",
71-
" \"examples/EPFL--BellaLui--2020/rocket.ork\",\n",
59+
" # \"examples/EPFL--BellaLui--2020/rocket.ork\",\n",
7260
" # \"examples/NDRT--Rocket--2020/rocket.ork\",\n",
73-
" # \"examples/ProjetoJupiter--Valetudo--2019/rocket.ork\",\n",
74-
" \"examples/rocket_with_elliptical_fins/rocket.ork\",\n",
61+
" \"examples/ProjetoJupiter--Valetudo--2019/rocket.ork\",\n",
62+
" # \"examples/rocket_with_elliptical_fins/rocket.ork\",\n",
7563
" # \"examples/databank/Team01/rocket.ork\",\n",
7664
" # \"examples/databank/Team06/rocket.ork\",\n",
7765
" # \"examples/databank/Team07/rocket.ork\",\n",

0 commit comments

Comments
 (0)