Rowan-Classes/8th-Semester-Spring-2025/weapon-systems/homework/depth_of_fire.py
2025-02-24 22:16:41 -05:00

46 lines
1.2 KiB
Python

import numpy as np
import matplotlib.pyplot as plt
TARGET_RANGE = 20E3
MIN_RANGE = 2E3
MIN_DELAY = 5
T_HOMING = 8
V_MISSILE = 700
def depth_of_fire(target_range, min_range, t_homing, v_target, v_missile):
t_engagement = (target_range - min_range) / v_target
t_flight = target_range / (v_missile + v_target)
return (t_engagement + t_flight)/t_homing
def launch_delay(t_homing, v_missile, v_target):
return t_homing*(1 + v_target/v_missile)
def main():
# Range of target speeds from 0 to 1200 (inclusive)
v_target = np.arange(1200+1)
# Delta T_L for each target speed
t_L = launch_delay(T_HOMING, V_MISSILE, v_target)
plt.plot(v_target, t_L, label=r"$\Delta T_L$")
plt.hlines(0, v_target[-1], MIN_DELAY, label=r"$\Delta T_{L_\text{min}}$", color='r')
plt.legend()
plt.savefig("launch-delay.png")
plt.show()
dof = depth_of_fire(TARGET_RANGE, MIN_RANGE, T_HOMING, v_target, V_MISSILE)
print("DOF for V_T=200:", depth_of_fire(TARGET_RANGE, MIN_RANGE, T_HOMING, 200, V_MISSILE))
plt.plot(v_target, dof, label="Depth of Fire")
plt.savefig("depth-of-fire.png")
plt.show()
if __name__ == "__main__":
main()