<jupyter_start><jupyter_text>Example Usage<jupyter_code>r = Rocket('Sample Rocket')
r
# create a nose cone
nc = NoseCone(mass=None, inertia=None, diameter=6*ureg.inch, length=18*ureg.inch, wall_thickness=6*ureg.mm, material=PLA())
# assign it to the rocket
r.set_nose_cone(nc)
nc
nc.mass.to(ureg.kg)
nc.I_zz.to_base_units()
nc.material
# plot the nose cone
fig = plt.figure()
ax = plt.gca()
#the pint functionality to apply a unit does not currently work
#ax.yaxis.set_units(ureg.meters)
#ax.xaxis.set_units(ureg.inches)
nc.plot(ax, unit=ureg.cm);
nc.plot(rotation=0*ureg.degree)
nc.plot(rotation=60*ureg.degree)

r.plot()
nc.x_ref
[comp.I_xx for comp in r.components]
# determine the normal force coefficient at some alpha
nc.CN(alpha=0.2*ureg.rad)
nc.xcp().to(ureg.m)
# create a body tube
bt = BodyTube(name = 'Body Tube', mass =None, inertia=None, diameter=6*ureg.inch, length=48*ureg.inch, wall_thickness=2*ureg.mm, material=Phenolic())

# define its location
bt.set_position(after=nc)

# assign to the rocket
r.set_body_tube(bt)
print(bt)
# plot the rocket so far
r.plot(plot_component_cg=True, unit=ureg.m)
r.CD()
r.describe()
PLA().density
r.xcp().to(ureg.inch)
# create a boat tail
boat_tail = Transition(name='Boat Tail',mass=None, inertia=None, fore_dia=6*ureg.inch, aft_dia=4*ureg.inch, length=4*ureg.inch, material=Phenolic())
boat_tail.set_position(after=bt)
r.set_boat_tail(boat_tail)
boat_tail
# get the normal force coefficient for the boat tail.
boat_tail.CNa()
r.xcp().to(ureg.inch)
# create the fins
fins = FinSet(name='Fins', mass=None, inertia=None, n=3, span=6*ureg.inch, root_chord=12*ureg.inch, tip_chord=6*ureg.inch, mid_sweep=10*ureg.degree, tube_dia=6*ureg.inch,  thickness=2*ureg.mm, material=Aluminium())

fins.set_position(end_of=bt, offset=-fins.root_chord)
# assign fins to the rocket
r.set_fins(fins)
fins
fins.leading_sweep().to(ureg.deg)
# plot the entire rocket
fig = plt.figure(figsize=(15,10))
ax = plt.gca()
r.plot(ax, rotation=5*ureg.degree, plot_component_cp=True,plot_component_cg=True, unit=ureg.inch)
# its also a good idea to do a check of the components list:
r.components
# and the total length of the rocket
print(r.length())
print(r.length().to_base_units())
# query some parameters of the rocket
r.xcp().to(ureg.inch)
r.xcg().to(ureg.inch)
r.CNa()
r.components
r.components[0].xcp()
r.describe()
2*(fins.A_ref/np.pi)**0.5
r.xcg().to(ureg.inch)
r.xcp().to(ureg.inch)
[i.to_base_units() for i in r.inertia()]
fins.describe()
for comp in r.components:
    comp.describe()
si(sum(comp.length for comp in r.components))
r.components
alphas = np.linspace(0, 20)*ureg.degree
CNs = np.array([bt.CN(alpha) for alpha in alphas])
plt.plot(alphas.to(ureg.degree), CNs)
plt.grid();
plt.xlabel('Alpha (deg)');
plt.ylabel('Normal Force Coefficient');
re_vals = np.logspace(4, 9)
plt.loglog(re_vals, [r.Cf(re) for re in re_vals])
plt.xlabel('Reynolds Number')
plt.ylabel('Viscous Friction Coefficient')
plt.grid()
# try to get the zero-angle of attack drag coefficient
r.CD0()
# plot this as a function of the drag coefficient
plt.semilogx(re_vals, [r.CD0(re) for re in re_vals])
plt.grid()
plt.xlabel("Re_{L}")
plt.ylabel("CD0 of Rocket")
plt.semilogx(re_vals, [r.CD(alpha=0*ureg.degree, Re=re, Mach=0.0) for re in re_vals], label='α = 0 degree')
plt.semilogx(re_vals, [r.CD(alpha=2*ureg.degree, Re=re, Mach=0.0) for re in re_vals], label='α = 2 degree')
plt.semilogx(re_vals, [r.CD(alpha=5*ureg.degree, Re=re, Mach=0.0) for re in re_vals], label='α = 5 degree')
plt.grid()
plt.xlabel("Re_{L}")
plt.ylabel("CD of Rocket")
plt.legend()
plt.semilogx(re_vals, [r.CD(alpha=0*ureg.degree, Re=re, Mach=0.3) for re in re_vals], label='α = 0 degree')
plt.semilogx(re_vals, [r.CD(alpha=2*ureg.degree, Re=re, Mach=0.3) for re in re_vals], label='α = 2 degree')
plt.semilogx(re_vals, [r.CD(alpha=5*ureg.degree, Re=re, Mach=0.3) for re in re_vals], label='α = 5 degree')
plt.grid()
plt.xlabel("Re_{L}")
plt.ylabel("CD of Rocket")
plt.legend()
np.log10((1.225*300*2)/1.8e-5)
alpha_vals = np.linspace(0,5)*ureg.degree
plt.plot(alpha_vals, [r.CD(alpha, Re=1e7) for alpha in alpha_vals],label='CD')
plt.plot(alpha_vals, [r.CA(alpha, Re=1e7) for alpha in alpha_vals],label='CD')
plt.plot(alpha_vals, [r.CN(alpha, Re=1e7) for alpha in alpha_vals],label='CN')
plt.xlabel('alpha (deg)')
plt.ylabel('CD or CA or CN')
plt.grid()


plt.legend()
r.CD(alpha=0*ureg.degree, Re=10e4, Mach=0.5)
Ma_vals = np.linspace(0, 2)
Re=1e8
plt.plot(Ma_vals, [r.CD(alpha=0*ureg.degree, Re=Re, Mach=Ma) for Ma in Ma_vals], label='α = 0 degree')
plt.plot(Ma_vals, [r.CD(alpha=2*ureg.degree, Re=Re, Mach=Ma) for Ma in Ma_vals], label='α = 2 degree')
plt.plot(Ma_vals, [r.CD(alpha=5*ureg.degree, Re=Re, Mach=Ma) for Ma in Ma_vals], label='α = 5 degree')
plt.grid()
plt.xlabel("Ma")
plt.ylabel("CD of Rocket")
plt.legend()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1746851125335536, 'fraction_numerical': 0.021267809209167873, 'mean_word_length': 6.01013024602026, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '329341', 'license': 'MIT', 'n_tokens_mistral': 2138, 'n_tokens_neox': 2045, 'n_words': 441, 'path': 'rocketPy/rocket_generate.ipynb', 'repo_name': 'dev10110/rocketPy_development', 'size': '4843'}