[关闭]
@feipai11 2016-03-30T15:50:24.000000Z 字数 1891 阅读 1010

My first progrem: the parachute model

S.F.Guo


first step: the algorithm

This is the most important part of all this progrem ,which likes the decay-progrem ,is a ODE problem. First we must know the recurrence relation :


This is the most important relation in this progrem. Certainly ,we should initialize all the variables ,including the velocity and time List. And we should store the data so that we can use and analyse it.Last but not least, we should plot the data, so that we can easily find the relation between the velocity and the time, this step consumed most of my time.

Second step:the code

With all the ideas above, I still can't write good codes.Actually I must know all the related Computer syntax,such as 'how to input some value that the progrem can use ','how to plot beaitiful and clear figures', 'how to read a txt file and return it's content as a List' and so on. Finally, Through the codes of teacher Cai and chenfeng, I know how to achieve these functions in python. view the main code ,and the read_file code.through this two code I first gained the two data and corresponding figures, they are all in the directory chapter.

third step: the analysis

  1. This is a physicial problem with two parameters 'a'and 'b'. At the begining, I just change the parameters arbitrarily, and find there are two different contitions :
    • This is the first figure, with it's parameter a = 10 and b = 2. figure1
    • this is the second figure, with it's parameters a = 5 and b = 10.
      figure2
      The above two condition means that the parameter a and b determine the final equilibrium velocity.If the friction is too large, then the object will slow down and gain its equilirium, on the contrary, if the friction is too small, then the object will speed up and gain its equilirium.
  2. To compare the difference of this two conditions, I want to put the two datas together. But I found it not that easy, because a founction can return only one List. And if I RUN the main function twice the first data would be coverd. Then I remenber that I have stored the two datas in txt files. So the problem I should solve is to read a fille and return a list. Thank ChenFeng, I changed his code for my own use. And finaly I solved the legend problem, gained a better figure! The feeling is perfect! This IS the final figure:
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注