This is a Python program that simulates the trajectory of a bullet fired from a gun at different angles. The simulation considers various physical factors including gravity, air resistance, wind speed and direction. The simulation also calculates the distance the bullet covered and the impact force when the bullet hits a stationary target.
g
: Acceleration due to gravity (9.81 m/s²)air_density
: Air density at sea level and 15 degrees Celsius (1.225 kg/m³)
gun_height
: Height of the gun (1 m)initial_bullet_velocity
: Initial speed of the bullet (350 m/s)bullet_mass
: Mass of the bullet (0.007 kg)bullet_diameter
: Diameter of the bullet (0.009 m)bullet_drag_coefficient
: Drag coefficient of the bullet (0.05, dimensionless)
target_distance
: Horizontal distance to the target (500 m)target_size
: Diameter of the target (1 m)
wind_speed
: Speed of the wind (10 m/s)wind_direction
: Direction of the wind (0 radians)
firing_angle
: Firing angle (45 degrees, converted to radians)x
: Initial horizontal position (0 m)y
: Initial vertical position (gun_height
m)v
: Initial velocity (initial_bullet_velocity
m/s)θ
: Initial angle (firing_angle
radians)
t
: Initial time (0 s)dt
: Time step (0.01 s)
The Runge-Kutta method is used to numerically solve the differential equations of motion.
The program outputs the trajectory of the bullet, the distance it covered, and if the bullet hit the target, the impact force. The impact force is calculated based on the bullet's momentum change during an assumed stopping time of 0.001 s.
To run the code, simply run the script in a Python environment with matplotlib
installed. You can adjust the variables and constants to see how they affect the bullet's trajectory and the resulting impact force. The plot will show the trajectory of the bullet.
The simulation is a simplification and does not account for certain real-world factors like bullet spin, temperature variations, humidity, altitude, or changes in wind speed and direction over distance. The calculation of the impact force is also an overestimate and the actual force could be much less. More accurate simulation would require complex modeling and simulation, taking into account factors like deformation, energy dissipation, material properties, etc.