170 thrust_design, force_coeffcient=force_coeffcient_default,
171 diameter_inner=chamber_diameter_default,
172 diameter_exit=diameter_exit_default,
173 l_star = l_star_default,
175 color_segments=False,
178 theta=theta_default):
180 Calculate the full chamber geometry including cylindrical section, contraction, and nozzle.
184 export_dxf : str or None
185 If provided, exports the contour to a DXF file at the specified path.
186 Example: 'chamber/chamber_contour.dxf'
191 Array of (x, y) points representing the full chamber contour
193 Table data with metric and imperial units. First row contains headers:
194 ['Parameter', 'Metric Value', 'Metric Units', 'Imperial Value', 'Imperial Units']
195 Subsequent rows contain parameter data.
202 nozzle_pts, nozzle_x_first, nozzle_y_first =
generate_nozzle(area_throat, area_exit, steps=steps, theta=theta)
203 cylindrical_length =
chamber_length_calc(volume_chamber, area_throat, contraction_ratio, theta)
208 total_chamber_length = cylindrical_length + contraction_length_horizontal
209 entrance_arc_length = 1.5 * np.sqrt(area_throat / np.pi) * np.sin(theta)
210 face_to_throat_length = total_chamber_length + entrance_arc_length
213 r_c = np.sqrt(area_chamber / np.pi)
222 _cot = np.tan(np.pi/2 - theta)
223 contraction_run = (r_c - nozzle_y_first) * _cot
224 x_cyl_start = nozzle_x_first - contraction_run
227 x_cyl_end = x_cyl_start - cylindrical_length
228 x_cyl = np.linspace(x_cyl_end, x_cyl_start, steps)
229 y_cyl = np.full_like(x_cyl, r_c)
232 x_contraction = np.linspace(x_cyl_start, nozzle_x_first, steps)
234 y_contraction = r_c - (x_contraction - x_cyl_start) * np.tan(theta)
238 chamber_pts = np.vstack([
239 np.column_stack((x_cyl, y_cyl)),
240 np.column_stack((x_contraction[1:-1], y_contraction[1:-1])),
246 diameter_throat = np.sqrt(4 * area_throat / np.pi)
247 diameter_exit_calc = np.sqrt(4 * area_exit / np.pi)
252 m2_to_in2 = 1550.0031
253 m3_to_in3 = 61023.7441
254 pa_to_psi = 0.000145038
258 volume_chamber_in3 = volume_chamber * m3_to_in3
259 area_chamber_in2 = area_chamber * m2_to_in2
260 diameter_chamber_in = diameter_chamber * m_to_in
261 area_throat_in2 = area_throat * m2_to_in2
262 diameter_throat_in = diameter_throat * m_to_in
263 area_exit_in2 = area_exit * m2_to_in2
264 diameter_exit_in = diameter_exit_calc * m_to_in
265 l_star_in = l_star * m_to_in
266 cylindrical_length_in = cylindrical_length * m_to_in
267 contraction_length_horizontal_in = contraction_length_horizontal * m_to_in
268 total_chamber_length_in = total_chamber_length * m_to_in
269 pc_design_psi = pc_design * pa_to_psi
270 thrust_design_lbf = thrust_design * n_to_lbf
274 [
'Parameter',
'Metric Value',
'Metric Units',
'Imperial Value',
'Imperial Units'],
275 [
'Design Pressure', f
'{pc_design:.2e}',
'Pa', f
'{pc_design_psi:.2f}',
'PSI'],
276 [
'Design Thrust', f
'{thrust_design:.2f}',
'N', f
'{thrust_design_lbf:.2f}',
'lbf'],
277 [
'Chamber Volume', f
'{volume_chamber:.6e}',
'm³', f
'{volume_chamber_in3:.4f}',
'in³'],
278 [
'Chamber Area', f
'{area_chamber:.6e}',
'm²', f
'{area_chamber_in2:.4f}',
'in²'],
279 [
'Chamber Diameter', f
'{diameter_chamber:.6e}',
'm', f
'{diameter_chamber_in:.4f}',
'in'],
280 [
'Throat Area', f
'{area_throat:.6e}',
'm²', f
'{area_throat_in2:.6f}',
'in²'],
281 [
'Throat Diameter', f
'{diameter_throat:.6e}',
'm', f
'{diameter_throat_in:.6f}',
'in'],
282 [
'Exit Area', f
'{area_exit:.6e}',
'm²', f
'{area_exit_in2:.4f}',
'in²'],
283 [
'Exit Diameter', f
'{diameter_exit_calc:.6e}',
'm', f
'{diameter_exit_in:.4f}',
'in'],
284 [
'Expansion Ratio', f
'{expansion_ratio:.4f}',
'', f
'{expansion_ratio:.4f}',
''],
285 [
'Contraction Ratio', f
'{contraction_ratio:.4f}',
'', f
'{contraction_ratio:.4f}',
''],
286 [
'L*', f
'{l_star:.4f}',
'm', f
'{l_star_in:.4f}',
'in'],
287 [
'Cylindrical Length', f
'{cylindrical_length:.6e}',
'm', f
'{cylindrical_length_in:.4f}',
'in'],
288 [
'Contraction Length', f
'{contraction_length_horizontal:.6e}',
'm', f
'{contraction_length_horizontal_in:.4f}',
'in'],
289 [
'Total Chamber Length', f
'{total_chamber_length:.6e}',
'm', f
'{total_chamber_length_in:.4f}',
'in'],
290 [
'Face to Throat', f
'{face_to_throat_length:.6e}',
'm', f
'{face_to_throat_length * m_to_in:.4f}',
'in'],
296 fig = plt.figure(figsize=(16, 14))
297 gs = fig.add_gridspec(2, 1, height_ratios=[2, 1], hspace=0.15)
300 ax = fig.add_subplot(gs[0])
303 ax.plot(x_cyl, y_cyl, label=
'Cylindrical section', color=
'blue', linewidth=2)
304 ax.plot(x_contraction, y_contraction, label=
'Contraction (45°)', color=
'green', linewidth=2)
305 ax.plot(nozzle_pts[:, 0], nozzle_pts[:, 1], label=
'Nozzle', color=
'red', linewidth=2)
308 ax.plot(chamber_pts[:, 0], chamber_pts[:, 1],
'k-', linewidth=2)
314 x_min, x_max = ax.get_xlim()
315 y_min, y_max = ax.get_ylim()
316 x_range = x_max - x_min
317 y_range = y_max - y_min
321 aspect_ratio = (x_range / y_range) * 0.2
322 ax.set_aspect(aspect_ratio,
'box')
325 ax.set_ylim(y_min - 0.05 * y_range, y_max + 0.05 * y_range)
327 ax.set_xlabel(
"Axial distance x (m)", fontsize=12)
328 ax.set_ylabel(
"Radius y (m)", fontsize=12)
329 ax.grid(
True, alpha=0.3)
330 ax.set_title(
"Full Chamber Contour", fontsize=14, fontweight=
'bold')
333 ax_table = fig.add_subplot(gs[1])
337 table = ax_table.table(cellText=table_data[1:], colLabels=table_data[0],
338 cellLoc=
'left', loc=
'center',
340 table.auto_set_font_size(
False)
341 table.set_fontsize(18)
342 table.scale(1.5, 4.5)
345 col_widths = [0.22, 0.22, 0.12, 0.22, 0.12]
347 for j
in range(len(table_data)):
348 table[(j, i)].set_width(col_widths[i])
352 table[(0, i)].set_facecolor(
'#40466e')
353 table[(0, i)].set_text_props(weight=
'bold', color=
'white', size=20)
354 table[(0, i)].set_height(0.35)
357 for i
in range(1, len(table_data)):
360 table[(i, j)].set_facecolor(
'#f1f1f2')
362 table[(i, j)].set_facecolor(
'white')
363 table[(i, j)].set_text_props(size=18)
364 table[(i, j)].set_height(0.30)
367 output_path = Path(
'chamber/chamber_full_contour.png')
368 output_path.parent.mkdir(parents=
True, exist_ok=
True)
369 plt.savefig(str(output_path), dpi=150, bbox_inches=
'tight')
373 if export_dxf
is not None:
375 export_chamber_dxf(chamber_pts, export_dxf)
379 'cylindrical': cylindrical_length,
380 'contraction': contraction_length_horizontal,
381 'total': total_chamber_length,
382 'entrance_arc': entrance_arc_length,
383 'face_to_throat': face_to_throat_length,
386 return chamber_pts, table_data, lengths