@@ -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
@@ -389,16 +389,14 @@ def build_fins(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
389389 pass
390390 # free form fins
391391 # checking if fins were added
392- try :
393- assert fin_counter > 0
392+ if fin_counter > 0 :
394393 logger .info (
395394 "[NOTEBOOK BUILDER] %s fins were added to the rocket." , fin_counter
396395 )
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 ."
399398 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" )
402400 return nb
403401
404402 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:
434432 return nb
435433
436434 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." )
438457 return nb
439458
440459 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:
535554 text += "error = abs((apogee_difference)/time_to_apogee_rpy)*100"
536555 text += "\n "
537556 text += r'print(f"Time to apogee difference: {error:.3f} %")'
557+ text += "\n print()"
538558 text += "\n \n "
539559
540560 # Flight time
@@ -550,10 +570,11 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
550570 "error_flight_time = abs((flight_time_difference)/flight_time_rpy)*100\n "
551571 )
552572 text += r'print(f"Flight time difference: {error_flight_time:.3f} %")'
573+ text += "\n print()"
553574 text += "\n \n "
554575
555576 # Ground hit velocity
556- ground_hit_velocity_ork = self .parameters ["stored_results" ][
577+ ground_hit_velocity_ork = - self .parameters ["stored_results" ][
557578 "ground_hit_velocity"
558579 ]
559580 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:
565586 text += "ground_hit_velocity_difference = ground_hit_velocity_rpy - ground_hit_velocity_ork\n "
566587 text += "error_ground_hit_velocity = abs((ground_hit_velocity_difference)/ground_hit_velocity_rpy)*100\n "
567588 text += r'print(f"Ground hit velocity difference: {error_ground_hit_velocity:.3f} %")'
589+ text += "\n print()"
568590 text += "\n \n "
569591
570592 # Launch rod velocity
@@ -580,6 +602,7 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
580602 text += "launch_rod_velocity_difference = launch_rod_velocity_rpy - launch_rod_velocity_ork\n "
581603 text += "error_launch_rod_velocity = abs((launch_rod_velocity_difference)/launch_rod_velocity_rpy)*100\n "
582604 text += r'print(f"Launch rod velocity difference: {error_launch_rod_velocity:.3f} %")'
605+ text += "\n print()"
583606 text += "\n \n "
584607
585608 # Max acceleration
@@ -599,6 +622,7 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
599622 text += (
600623 r'print(f"Max acceleration difference: {error_max_acceleration:.3f} %")'
601624 )
625+ text += "\n print()"
602626 text += "\n \n "
603627
604628 # Max altitude
@@ -614,6 +638,7 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
614638 "error_max_altitude = abs((max_altitude_difference)/max_altitude_rpy)*100\n "
615639 )
616640 text += r'print(f"Max altitude difference: {error_max_altitude:.3f} %")'
641+ text += "\n print()"
617642 text += "\n \n "
618643
619644 # Max Mach
@@ -627,6 +652,7 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
627652 text += "max_mach_difference = max_mach_rpy - max_mach_ork\n "
628653 text += "error_max_mach = abs((max_mach_difference)/max_mach_rpy)*100\n "
629654 text += r'print(f"Max Mach difference: {error_max_mach:.3f} %")'
655+ text += "\n print()"
630656 text += "\n \n "
631657
632658 # Max velocity
@@ -642,6 +668,7 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
642668 "error_max_velocity = abs((max_velocity_difference)/max_velocity_rpy)*100\n "
643669 )
644670 text += r'print(f"Max velocity difference: {error_max_velocity:.3f} %")'
671+ text += "\n print()"
645672 text += "\n \n "
646673
647674 # Max thrust
@@ -655,6 +682,7 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
655682 text += "max_thrust_difference = max_thrust_rpy - max_thrust_ork\n "
656683 text += "error_max_thrust = abs((max_thrust_difference)/max_thrust_rpy)*100\n "
657684 text += r'print(f"Max thrust difference: {error_max_thrust:.3f} %")'
685+ text += "\n print()"
658686 text += "\n \n "
659687
660688 # # Burnout stability margin
@@ -670,6 +698,7 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
670698 text += "burnout_stability_margin_difference = burnout_stability_margin_rpy - burnout_stability_margin_ork\n "
671699 text += "error_burnout_stability_margin = abs((burnout_stability_margin_difference)/burnout_stability_margin_rpy)*100\n "
672700 text += r'print(f"Burnout stability margin difference: {error_burnout_stability_margin:.3f} %")'
701+ text += "\n print()"
673702 text += "\n \n "
674703
675704 # # Max stability margin
@@ -685,6 +714,7 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
685714 text += "max_stability_margin_difference = max_stability_margin_rpy - max_stability_margin_ork\n "
686715 text += "error_max_stability_margin = abs((max_stability_margin_difference)/max_stability_margin_rpy)*100\n "
687716 text += r'print(f"Max stability margin difference: {error_max_stability_margin:.3f} %")'
717+ text += "\n print()"
688718 text += "\n \n "
689719
690720 # Min stability margin
@@ -700,6 +730,7 @@ def build_compare_results(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
700730 text += "min_stability_margin_difference = min_stability_margin_rpy - min_stability_margin_ork\n "
701731 text += "error_min_stability_margin = abs((min_stability_margin_difference)/min_stability_margin_rpy)*100\n "
702732 text += r'print(f"Min stability margin difference: {error_min_stability_margin:.3f} %")'
733+ text += "\n print()"
703734 text += "\n \n "
704735
705736 nb ["cells" ].append (nbf .v4 .new_code_cell (text ))
0 commit comments