Skip to content

Commit 32d5d24

Browse files
Merge pull request #9 from RocketPy-Team/bug/finding-fixing-errors
ENH/Updating Changes - NotebookBuilder Class
2 parents 8fccb68 + ff1450b commit 32d5d24

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

open_rocket_serializer/nb_builder.py

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def build_motor(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
116116
text += f" dry_mass={self.parameters['motors']['dry_mass']},\n"
117117
text += (
118118
" center_of_dry_mass_position="
119-
+ f"{self.parameters['motors']['center_of_dry_mass']},\n"
119+
+ f"{self.parameters['motors']['center_of_dry_mass_position']},\n"
120120
)
121121
text += (
122122
" dry_inertia="
@@ -138,7 +138,7 @@ def build_motor(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:
138138
f" grain_separation={self.parameters['motors']['grain_separation']},\n"
139139
)
140140
text += f" nozzle_radius={self.parameters['motors']['nozzle_radius']},\n"
141-
text += f" burn_time={self.parameters['motors']['burn_time']},\n"
141+
# text += f" burn_time={self.parameters['motors']['burn_time']},\n"
142142
text += f" nozzle_position={self.parameters['motors']['nozzle_position']},\n"
143143
text += f" throat_radius={self.parameters['motors']['throat_radius']},\n"
144144
text += (
@@ -192,10 +192,9 @@ def build_rocket(self, nb: nbf.v4.new_notebook):
192192
self.add_surfaces_to_rocket(nb)
193193

194194
# add the motor to the rocket
195-
# TODO: kinda needs to fix this
196195
text = (
197196
"rocket.add_motor(motor, position= "
198-
+ f"{self.parameters['rocket']['radius']})\n"
197+
+ f"{self.parameters['motors']['position']})\n"
199198
)
200199
nb["cells"].append(nbf.v4.new_code_cell(text))
201200

@@ -225,10 +224,32 @@ def add_surfaces_to_rocket(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook
225224
text = "### Adding surfaces to the rocket\n"
226225
text += "Now that we have all the surfaces, we can add them to the rocket\n"
227226
nb["cells"].append(nbf.v4.new_markdown_cell(text))
227+
text = "rocket.add_surfaces("
228+
229+
# building surfaces and positions text
230+
surface_text = "surfaces=["
231+
position_text = "positions=["
228232

229-
# add a code cell
230-
text = "rocket.add_surfaces"
233+
# adding nosecone
234+
surface_text += "nosecone, "
235+
position_text += f"{self.parameters['nosecones']['position']}, "
236+
237+
# adding trapezoidal
238+
for i in range(len(self.parameters["trapezoidal_fins"])):
239+
surface_text += f"trapezoidal_fins[{i}], "
240+
position_text += f"{self.parameters['trapezoidal_fins'][str(i)]['position']}, "
231241

242+
# adding tails
243+
for i in range(len(self.parameters["tails"])):
244+
surface_text += f"tails[{i}], "
245+
position_text += f"{self.parameters['tails'][str(i)]['position']}, "
246+
247+
# closing surfaces and positions text
248+
surface_text = surface_text[:-2] + "]"
249+
position_text = position_text[:-2] + "]"
250+
text += surface_text + ", " + position_text + ")"
251+
nb["cells"].append(nbf.v4.new_code_cell(text))
252+
# building trapezoidal fins text
232253
return nb
233254

234255
def build_nosecones(self, nb: nbf.v4.new_notebook) -> nbf.v4.new_notebook:

0 commit comments

Comments
 (0)