[关闭]
@yukangnineteen 2016-10-16T13:11:37.000000Z 字数 4665 阅读 566

Computational Physics Homework 5

computational_physics homework


Aurther: Kang Yu

Student Number: 2014301020117


1.Abstract

抱歉作业更新晚了!2.2章作业任选一题。

Exercises

2.8. In our model of the cannon shell trajectory we have assumed that the acceleration due to gravity, , is a constant. It will, of course, depend on altitude. Add this to the model and calculate how much it affects the range.

2.9. Calculate the trajectory of of our cannon shell including both air drag and the reduced air density at high altitudes so that you can reproduce the results in Figure 2.5. Perform your calculation for different firing angles and determine the value of the angle that gives the maximum range.

All in all, what I would like to do is to explore the effects of 's independence on altitude, air drag and the reduced air density on the cannon shell trajectory.


2.Background

On this topic, we have learned too much about it from our junior high schools to senior high schools, so I have nothing special to say.

In our problems, we will need to use the relation between and altitude:

where is the mass of the Earth, is the average radius of the Earth, and is the distance between the cannon shell and the surface of the Earth.

According to our textbook, it is not difficult to find by energy relation that:

where is known as the drag coefficient, and can be simply assumed to be . To be more simplified, we have:

What really matters is that is proportional to . So:

1.Isothermal model

From our Thermaldynamics and Statistical Physics course, we have a conclusion :

where , and is density at sea level ().

From this and what I have emphasized before, we have:

2.Adiabatic model

In the same way, we have a conclusion:

where , is the sea level temperature (in K), and the exponent for air.

From this and what I have emphasized before, we have:


3.Main

I still choose to use the dirty and quick method - The Euler Mehtod (So no more illumination is to be made)

Design of Program and Result (Declaration: The unit of distance is , and other units are in SI)

Firstly, I take air drag as a commom premise. This is the trojectory of cannon shell only affected by air drag

Codes:

  1. import pylab as pl
  2. import math
  3. class cannon_shell:
  4. def __init__(self, B_2_over_mass = 4 * 10 ** (- 2), time_step = 0.1, initial_velocity = 0.7, gravitational_acceleration = 9.8 * 10 ** (-3), firing_angle = float(input("Please input the launch angle:")) * math.pi / 180):
  5. self.x = [0]
  6. self.y = [0]
  7. self.theta = firing_angle
  8. self.v = [initial_velocity]
  9. self.v_x = [self.v[0] * math.cos(self.theta)]
  10. self.v_y = [self.v[0] * math.sin(self.theta)]
  11. self.t = [0]
  12. self.c = B_2_over_mass
  13. self.g = gravitational_acceleration
  14. self.dt = time_step
  15. def run(self):
  16. while(self.y[-1] >= 0):
  17. self.x.append(self.x[-1] + self.v_x[-1] * self.dt)
  18. self.y.append(self.y[-1] + self.v_y[-1] * self.dt)
  19. self.v_x.append(self.v_x[-1] - self.c * self.v[-1] * self.v_x[-1] * self.dt)
  20. self.v_y.append(self.v_y[-1] - self.g * self.dt - self.c * self.v[-1] * self.v_y[-1] * self.dt)
  21. self.v.append(math.sqrt(self.v_x[-1] ** 2 + self.v_y[-1] ** 2))
  22. else:
  23. r = - self.y[-1] / self.y[-2]
  24. x_l = (self.x[-2] + r * self.x[-1]) / (r + 1)
  25. y_l = 0
  26. self.x[-1] = x_l
  27. self.y[-1] = y_l
  28. print("The fall point of the cannon shell is: x =",x_l)
  29. def show_results(self):
  30. font = {'family': 'serif',
  31. 'color': 'k',
  32. 'weight': 'normal',
  33. 'size': 14,
  34. }
  35. pl.plot(self.x, self.y, 'c', label='firing angle = 45°')
  36. pl.title('The Trajectory of a Cannon Shell', fontdict = font)
  37. pl.xlabel('x (k$m$)')
  38. pl.ylabel('y ($km$)')
  39. pl.xlim(0, 60)
  40. pl.ylim(0, 20)
  41. pl.grid(True)
  42. pl.legend(loc='upper right', shadow=True, fontsize='large')
  43. pl.text(41, 16, 'Only with air drag', fontdict = font)
  44. pl.show()
  45. a = cannon_shell()
  46. a.run()
  47. a.show_results()

Figure:

Figure1

Secondly, (only) add the reduced air density - isothermal

Codes: (I will only show the parts that I have made some sigificant changes)

  1. python
  2. self.v_x.append(self.v_x[-1] - math.exp(- self.y[-1] / self.y_0) * self.c * self.v[-1] * self.v_x[-1] * self.dt)
  3. self.v_y.append(self.v_y[-1] - self.g * self.dt - self.c * self.v[-1] * math.exp(- self.y[-1] / self.y_0) * self.v_y[-1] * self.dt)

Figure:

Figure2

Thirdly, (only) add the reduced air density - adiabatic

Codes:

  1. python
  2. self.v_x.append(self.v_x[-1] - (1 - self.a * self.y[-1] / self.T_0) ** self.alpha * self.c * self.v[-1] * self.v_x[-1] * self.dt)
  3. self.v_y.append(self.v_y[-1] - self.g * self.dt - (1 - self.a * self.y[-1] / self.T_0) ** self.alpha * self.c * self.v[-1] * self.v_y[-1] * self.dt)

Figure:

Figure3

Fourthly, (only) add the 's independence on altitude

Codes:

  1. python
  2. self.v_y.append(self.v_y[-1] - self.G * self.ME * (self.RE + self.y[-1]) ** (- 2) * self.dt - self.c * self.v[-1] * self.v_y[-1] * self.dt)

Figure:

Figure4


4.Conclusion


5.Acknowlegement

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注