@@ -227,6 +227,7 @@ def build_rocket(self, nb: nbf.v4.new_notebook):
227
227
nb ["cells" ].append (nbf .v4 .new_code_cell (text ))
228
228
229
229
nb = self .add_parachutes_to_rocket (nb )
230
+ nb = self .build_rail_buttons (nb )
230
231
231
232
text = "### Rocket Info\n "
232
233
text += "rocket.all_info()\n "
@@ -243,7 +244,6 @@ def build_all_aerodynamic_surfaces(
243
244
self .build_nosecones (nb )
244
245
self .build_fins (nb )
245
246
self .build_tails (nb )
246
- self .build_rail_buttons (nb )
247
247
self .build_parachute (nb )
248
248
logger .info ("[NOTEBOOK BUILDER] All aerodynamic surfaces created." )
249
249
return nb
@@ -389,16 +389,14 @@ def build_fins(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
389
389
pass
390
390
# free form fins
391
391
# checking if fins were added
392
- try :
393
- assert fin_counter > 0
392
+ if fin_counter > 0 :
394
393
logger .info (
395
394
"[NOTEBOOK BUILDER] %s fins were added to the rocket." , fin_counter
396
395
)
397
- except AssertionError :
398
- text = "No fins were added to the rocket. Please add at least one ."
396
+ else :
397
+ text = "# No fins were added to the rocket. Check parameters.json ."
399
398
nb ["cells" ].append (nbf .v4 .new_code_cell (text ))
400
- logger .warning ("No fins were added to the rocket. Please add at least one." )
401
- raise Warning ("No fins were added to the rocket. Please add at least one." )
399
+ logger .warning ("No fins were added to the rocket. Check parameters.json" )
402
400
return nb
403
401
404
402
def build_tails (self , nb : nbf .v4 .new_notebook ) -> nbf .v4 .new_notebook :
@@ -434,7 +432,28 @@ def build_tails(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
434
432
return nb
435
433
436
434
def build_rail_buttons (self , nb : nbf .v4 .new_notebook ) -> nbf .v4 .new_notebook :
437
- logger .info ("rail buttons not implemented yet" )
435
+ # add a markdown cell
436
+ text = "### Rail Buttons\n "
437
+ nb ["cells" ].append (nbf .v4 .new_markdown_cell (text ))
438
+
439
+ if not self .parameters ["rail_buttons" ]:
440
+ text = "# No rail buttons were added to the rocket."
441
+ nb ["cells" ].append (nbf .v4 .new_code_cell (text ))
442
+ logger .warning ("No rail buttons were added to the rocket." )
443
+ return nb
444
+
445
+ rail_button_i = self .parameters ["rail_buttons" ]
446
+ upper_position = rail_button_i ["upper_position" ]
447
+ lower_position = rail_button_i ["lower_position" ]
448
+ ang_position = rail_button_i ["angular_position" ]
449
+ text = "rail_buttons = rocket.set_rail_buttons(\n "
450
+ text += f" upper_button_position={ upper_position :.3f} ,\n "
451
+ text += f" lower_button_position={ lower_position :.3f} ,\n "
452
+ text += f" angular_position={ ang_position :.3f} ,\n "
453
+ text += ")\n "
454
+ nb ["cells" ].append (nbf .v4 .new_code_cell (text ))
455
+
456
+ logger .info ("[NOTEBOOK BUILDER] Rail Buttons created." )
438
457
return nb
439
458
440
459
def build_parachute (self , nb : nbf .v4 .new_notebook ) -> nbf .v4 .new_notebook :
@@ -535,6 +554,7 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
535
554
text += "error = abs((apogee_difference)/time_to_apogee_rpy)*100"
536
555
text += "\n "
537
556
text += r'print(f"Time to apogee difference: {error:.3f} %")'
557
+ text += "\n print()"
538
558
text += "\n \n "
539
559
540
560
# Flight time
@@ -550,10 +570,11 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
550
570
"error_flight_time = abs((flight_time_difference)/flight_time_rpy)*100\n "
551
571
)
552
572
text += r'print(f"Flight time difference: {error_flight_time:.3f} %")'
573
+ text += "\n print()"
553
574
text += "\n \n "
554
575
555
576
# Ground hit velocity
556
- ground_hit_velocity_ork = self .parameters ["stored_results" ][
577
+ ground_hit_velocity_ork = - self .parameters ["stored_results" ][
557
578
"ground_hit_velocity"
558
579
]
559
580
text += f"ground_hit_velocity_ork = { ground_hit_velocity_ork } \n "
@@ -565,6 +586,7 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
565
586
text += "ground_hit_velocity_difference = ground_hit_velocity_rpy - ground_hit_velocity_ork\n "
566
587
text += "error_ground_hit_velocity = abs((ground_hit_velocity_difference)/ground_hit_velocity_rpy)*100\n "
567
588
text += r'print(f"Ground hit velocity difference: {error_ground_hit_velocity:.3f} %")'
589
+ text += "\n print()"
568
590
text += "\n \n "
569
591
570
592
# Launch rod velocity
@@ -580,6 +602,7 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
580
602
text += "launch_rod_velocity_difference = launch_rod_velocity_rpy - launch_rod_velocity_ork\n "
581
603
text += "error_launch_rod_velocity = abs((launch_rod_velocity_difference)/launch_rod_velocity_rpy)*100\n "
582
604
text += r'print(f"Launch rod velocity difference: {error_launch_rod_velocity:.3f} %")'
605
+ text += "\n print()"
583
606
text += "\n \n "
584
607
585
608
# Max acceleration
@@ -599,6 +622,7 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
599
622
text += (
600
623
r'print(f"Max acceleration difference: {error_max_acceleration:.3f} %")'
601
624
)
625
+ text += "\n print()"
602
626
text += "\n \n "
603
627
604
628
# Max altitude
@@ -614,6 +638,7 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
614
638
"error_max_altitude = abs((max_altitude_difference)/max_altitude_rpy)*100\n "
615
639
)
616
640
text += r'print(f"Max altitude difference: {error_max_altitude:.3f} %")'
641
+ text += "\n print()"
617
642
text += "\n \n "
618
643
619
644
# Max Mach
@@ -627,6 +652,7 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
627
652
text += "max_mach_difference = max_mach_rpy - max_mach_ork\n "
628
653
text += "error_max_mach = abs((max_mach_difference)/max_mach_rpy)*100\n "
629
654
text += r'print(f"Max Mach difference: {error_max_mach:.3f} %")'
655
+ text += "\n print()"
630
656
text += "\n \n "
631
657
632
658
# Max velocity
@@ -642,6 +668,7 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
642
668
"error_max_velocity = abs((max_velocity_difference)/max_velocity_rpy)*100\n "
643
669
)
644
670
text += r'print(f"Max velocity difference: {error_max_velocity:.3f} %")'
671
+ text += "\n print()"
645
672
text += "\n \n "
646
673
647
674
# Max thrust
@@ -655,6 +682,7 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
655
682
text += "max_thrust_difference = max_thrust_rpy - max_thrust_ork\n "
656
683
text += "error_max_thrust = abs((max_thrust_difference)/max_thrust_rpy)*100\n "
657
684
text += r'print(f"Max thrust difference: {error_max_thrust:.3f} %")'
685
+ text += "\n print()"
658
686
text += "\n \n "
659
687
660
688
# # Burnout stability margin
@@ -670,6 +698,7 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
670
698
text += "burnout_stability_margin_difference = burnout_stability_margin_rpy - burnout_stability_margin_ork\n "
671
699
text += "error_burnout_stability_margin = abs((burnout_stability_margin_difference)/burnout_stability_margin_rpy)*100\n "
672
700
text += r'print(f"Burnout stability margin difference: {error_burnout_stability_margin:.3f} %")'
701
+ text += "\n print()"
673
702
text += "\n \n "
674
703
675
704
# # Max stability margin
@@ -685,6 +714,7 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
685
714
text += "max_stability_margin_difference = max_stability_margin_rpy - max_stability_margin_ork\n "
686
715
text += "error_max_stability_margin = abs((max_stability_margin_difference)/max_stability_margin_rpy)*100\n "
687
716
text += r'print(f"Max stability margin difference: {error_max_stability_margin:.3f} %")'
717
+ text += "\n print()"
688
718
text += "\n \n "
689
719
690
720
# Min stability margin
@@ -700,6 +730,7 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
700
730
text += "min_stability_margin_difference = min_stability_margin_rpy - min_stability_margin_ork\n "
701
731
text += "error_min_stability_margin = abs((min_stability_margin_difference)/min_stability_margin_rpy)*100\n "
702
732
text += r'print(f"Min stability margin difference: {error_min_stability_margin:.3f} %")'
733
+ text += "\n print()"
703
734
text += "\n \n "
704
735
705
736
nb ["cells" ].append (nbf .v4 .new_code_cell (text ))
0 commit comments