fork download
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3.  
  4. # 参数
  5. D1 = 5.0 # 入口直径 (cm)
  6. D_throat = 3.85 # 喉部直径 (cm)
  7. De = 5.0 # 出口直径 (cm)
  8. L_converge = 8.0 # 收敛段长度 (cm)
  9. L_diverge = 12.0 # 扩张段长度 (cm)
  10. L_total = 20.0 # 总长度 (cm)
  11.  
  12. # 生成轮廓曲线(简化直线锥形)
  13. x = np.array([0, L_converge, L_total]) # 轴向位置
  14. y = np.array([D1/2, D_throat/2, De/2]) # 半径
  15.  
  16. # 绘图
  17. plt.figure(figsize=(10, 4))
  18. plt.plot(x, y, 'b-', linewidth=2, label='喷管轮廓')
  19. plt.plot(x, -y, 'b-', linewidth=2) # 对称部分
  20. plt.fill_between(x, y, -y, color='lightblue', alpha=0.3)
  21.  
  22. # 标注尺寸
  23. plt.annotate(f'入口 D={D1}cm', xy=(0, D1/2), xytext=(2, D1/2 + 1), arrowprops=dict(arrowstyle="->"))
  24. plt.annotate(f'喉部 D*={D_throat}cm', xy=(L_converge, D_throat/2), xytext=(L_converge+1, D_throat/2 + 0.5), arrowprops=dict(arrowstyle="->"))
  25. plt.annotate(f'出口 D={De}cm', xy=(L_total, De/2), xytext=(L_total-5, De/2 + 1), arrowprops=dict(arrowstyle="->"))
  26.  
  27. plt.xlabel('轴向长度 (cm)')
  28. plt.ylabel('半径 (cm)')
  29. plt.title('拉瓦尔喷管设计(直径5cm,长20cm)')
  30. plt.grid(True)
  31. plt.axis('equal')
  32. plt.legend()
  33. plt.show()
Success #stdin #stdout 0.91s 54104KB
stdin
import numpy as np
import matplotlib.pyplot as plt

# 参数
D1 = 5.0    # 入口直径 (cm)
D_throat = 3.85  # 喉部直径 (cm)
De = 5.0    # 出口直径 (cm)
L_converge = 8.0  # 收敛段长度 (cm)
L_diverge = 12.0  # 扩张段长度 (cm)
L_total = 20.0    # 总长度 (cm)

# 生成轮廓曲线(简化直线锥形)
x = np.array([0, L_converge, L_total])  # 轴向位置
y = np.array([D1/2, D_throat/2, De/2])  # 半径

# 绘图
plt.figure(figsize=(10, 4))
plt.plot(x, y, 'b-', linewidth=2, label='喷管轮廓')
plt.plot(x, -y, 'b-', linewidth=2)  # 对称部分
plt.fill_between(x, y, -y, color='lightblue', alpha=0.3)

# 标注尺寸
plt.annotate(f'入口 D={D1}cm', xy=(0, D1/2), xytext=(2, D1/2 + 1), arrowprops=dict(arrowstyle="->"))
plt.annotate(f'喉部 D*={D_throat}cm', xy=(L_converge, D_throat/2), xytext=(L_converge+1, D_throat/2 + 0.5), arrowprops=dict(arrowstyle="->"))
plt.annotate(f'出口 D={De}cm', xy=(L_total, De/2), xytext=(L_total-5, De/2 + 1), arrowprops=dict(arrowstyle="->"))

plt.xlabel('轴向长度 (cm)')
plt.ylabel('半径 (cm)')
plt.title('拉瓦尔喷管设计(直径5cm,长20cm)')
plt.grid(True)
plt.axis('equal')
plt.legend()
plt.show()
stdout
Standard output is empty