Question: CSS - HW: Arrays You will write a program that calculates the velocity of a skydiver as a function of time. The main program will

CSS - HW: Arrays

You will write a program that calculates the velocity of a skydiver as a function of time. The main program will include a loop that allows you to enter in the specifications for more than one jump.

Work Items

  1. Write the program described below. Submit the single Java file (i.e., ".java" text file) that contains your program:
    1. Please submit only a single Java file via Canvas. Do not email your instructor your work.
    2. Name your Java file HW_Arrays.java. You must name your file this way.
    3. Note that by requiring you name your Java file HW_Arrays.java, it means that the public class that is in that file has to be named HW_Arrays.

Introduction to the Problem

If you had physics before, you will recognize the problem of finding the velocity of a skydiver as similar to that of the fall of an object under the influence of gravity. However, unlike the case studied in most introductory physics courses, where air resistance is neglected, in the case of a skydiver, you cannot neglect air resistance. Thus, Newton's Second Law has two forces you have to account for:

CSS - HW: Arrays You will write a program that calculates theFtot=ma=FgravityFdrag

where velocity of a skydiver as a function of time. The main programm is the mass (kg) and will include a loop that allows you to enter in the specificationsa is the acceleration for more than one jump. Work Items Write the program described below.(m/s2) of the skydiver. Note, in this and subsequent equations, we will assume that the positive Submit the single Java file (i.e., ".java" text file) that contains yourx-direction (and thus the positive velocity and acceleration) points down towards the ground.

(As an aside, in a vacuum where we can neglect air resistance and gravity is the only force acting on the skydiver, we can neglect program: Please submit only a single Java file via Canvas. Do notFdrag and the above simplifies:

email your instructor your work. Name your Java file HW_Arrays.java. You mustFtot=ma=Fgravity=mgma=mga=g

Meaning, the acceleration of the skydiver (name your file this way. Note that by requiring you name youra) equals the acceleration of gravity at the surface of the Earth Java file HW_Arrays.java, it means that the public class that is in(g=9.81 m/s2). Which makes sense :).)

In the case where we have air resistance, in general we cannot solve for acceleration (and thus velocity) by hand, using just algebra or calculus. The reason is because air resistance is generally a function of velocity:

that file has to be named HW_Arrays. Introduction to the Problem IfFdrag=12CAav2

where you had physics before, you will recognize the problem of finding theC is the drag coefficient (unitless), velocity of a skydiver as similar to that of the fall ofA is the cross-sectional area an object under the influence of gravity. However, unlike the case studied(m2), in most introductory physics courses, where air resistance is neglected, in thea is the air density case of a skydiver, you cannot neglect air resistance. Thus, Newton's Second(kg/m3), and Law has two forces you have to account for: Ftot=ma=FgravityFdrag where mv is the velocity is the mass (kg) and a is the acceleration (m/s2) of the(m/s). So, we have to solve this using a computer. How do we do this? Going back to Newton's Second Law, we can plug in for skydiver. Note, in this and subsequent equations, we will assume that theFdrag to find:

positive x-direction (and thus the positive velocity and acceleration) points down towardsFtot=ma=FgravityFdrag=mg12CAav2

the ground. (As an aside, in a vacuum where we can neglecta=gCaA2mv2

Note this means that the acceleration at any given moment in time is determined by the velocity at any given moment in time. That is:

air resistance and gravity is the only force acting on the skydiver,a(t)=gCaA2mv(t)2

(assuming we can neglect Fdrag and the above simplifies: Ftot=ma=Fgravity=mgma=mga=g Meaning, the accelerationg, of the skydiver (a) equals the acceleration of gravity at the surfaceC, of the Earth (g=9.81 m/s2). Which makes sense :).) In the casea, where we have air resistance, in general we cannot solve for accelerationA, and (and thus velocity) by hand, using just algebra or calculus. The reasonm are constant with time). But the velocity at any given moment in time depends on the acceleration a small bit of time before the current time. And that past acceleration depends on the past velocity, which in turn depends on the acceleration before that. And so on.

Here's another way to think of the problem. The velocity at time is because air resistance is generally a function of velocity: Fdrag=12CAav2 wheret, in general, can be given as:

C is the drag coefficient (unitless), A is the cross-sectional area (m2),v(t)=v(tt)+a(tt)t

where a is the air density (kg/m3), and v is the velocity (m/s).t is a small bit of time. Applying this to the specific case of the skydiver, we can substitute in for So, we have to solve this using a computer. How do wea(tt)using the do this? Going back to Newton's Second Law, we can plug ina(t) equation before it, namely:

for Fdrag to find: Ftot=ma=FgravityFdrag=mg12CAav2 a=gCaA2mv2 Note this means that the accelerationv(t)=v(tt)+(gCaA2mv(tt)2)t

But what this equation tells us is that the velocity at time at any given moment in time is determined by the velocity att depends on the velocity at time any given moment in time. That is: a(t)=gCaA2mv(t)2 (assuming g, C, a,tt. And the velocity at time A, and m are constant with time). But the velocity at anytt depends on the velocity at time given moment in time depends on the acceleration a small bit oft2t, and so on. This is why we need to use the computer, because in order to calculate the velocity at the current time time before the current time. And that past acceleration depends on thet you have to first calculate the velocities at all intermediate bits of time prior to past velocity, which in turn depends on the acceleration before that. Andt. Note that if you didn't follow this derivation, that's okay: to write the program, all you need to use is this last equation above.

(As an aside, remember that notation like so on. Here's another way to think of the problem. The velocityv(tt)2 does not mean "the velocity times the quantity at time t, in general, can be given as: v(t)=v(tt)+a(tt)t where tt minus is a small bit of time. Applying this to the specific caset, all squared" but rather "the square of the velocity evaluated at time of the skydiver, we can substitute in for a(tt)using the a(t) equationtt." That is to say, the notation before it, namely: v(t)=v(tt)+(gCaA2mv(tt)2)t But what this equation tells us is thatv(t) is not "the velocity at time t depends on the velocity at time tt.vtimes And the velocity at time tt depends on the velocity at timet" but "the function t2t, and so on. This is why we need to use thev evaluated at computer, because in order to calculate the velocity at the current timet.")

Program Description

Your program should ask you to enter in the mass, cross-sectional area, and drag coefficient of the skydiver. Your program should also ask how long do you want to calculate the dive out to and what your timestep t you have to first calculate the velocities at all intermediate bits(t) will be. You can assume the density of air is of time prior to t. Note that if you didn't follow this1.14 kg/m3 and gravitational acceleration is derivation, that's okay: to write the program, all you need to use9.81 m/s2. (Density of the atmosphere value from https://answers.yahoo.com/question/index?qid=20110201191027AADvsI0 (Links to an external site.)Links to an external site., accessed September 6, 2014.)

As your program does its calculations, it should save the time and velocities in an array (i.e., in two separate one-dimensional arrays, one for time and the other for velocities). One you have calculated all these values, write the output to a file. The file should have two columns, the first being the time is this last equation above. (As an aside, remember that notation like(t) and the second being the velocity v(tt)2 does not mean "the velocity times the quantity t minus t,(v(t))at that time. Please separate the values in each column (along a given row) by a comma (e.g., "0.200, 1.9616"). If you do so, you will create the comma-separated value (CSV) file I mentioned earlier that Excel can read in without difficulties: Importing a delimited text file into Excel usually means opening Excel and then choosing "Open" from the File menu. Excel should detect what kind of file it is and try to parse it into a spreadsheet grid format. Your program, then, should also prompt you for the output filename. (Note, you actually don't need arrays to solve this homework, but arrays are used in scientific computing all the time, and by asking you to write the code in this way, I'm hoping you'll get some practice manipulating arrays.)

While the full output will go to a file, you should write out a few values to screen, so you can see how you're doing. Make that diagnostic output match this example console output (when the parameter values are as shown):

Enter the mass of the skydiver (kg): 80 Enter the cross-sectional area of the skydiver (m^2): 1.035 Enter the drag coefficient of the skydiver: 0.581 Enter the ending time (sec): 16 Enter the time step (sec): 0.1 Enter the output filename: soln.csv Writing out file. Here are the first few lines: 0.100, 0.981 0.200, 1.9616 0.300, 2.9409 0.400, 3.9182 0.500, 4.8927 0.600, 5.8634 0.700, 6.8297 0.800, 7.7907 0.900, 8.7457 Enter another dive? (y/[n]): n 

For the case whose plot you turn in, you'll want to calculate a substantial number of timesteps, out at least to all squared" but rather "the square of the velocity evaluated at timet=16 sec. Use a tt." That is to say, the notation v(t) is not "vtimes t"t=0.1 sec, a mass of 80 kg, cross-sectional area of but "the function v evaluated at t.") Program Description Your program should1.035 m2, and a drag coefficient of 0.581 (drag coefficient is unitless). (Values for the skydiver from https://answers.yahoo.com/question/index?qid=20110201191027AADvsI0 (Links to an external site.)Links to an external site., accessed September 6, 2014.) Your initial velocity, i.e., ask you to enter in the mass, cross-sectional area, and drag coefficientv(t=0 sec), should be 0 m/s. By the way, when using these settings, your graph should show the skydiver achieves terminal velocity; at a certain time, the velocity shown on the graph should level off. If you aren't getting this behavior (or the sample output given above), something's wrong.

Finally, there should be at least one method that you write that can be used to provide output for tracing variables: The method should be called test-something, e.g., testVariableValues. Somewhere in your program, there should be a call to that method. In the code you submit, that call should be commented out, but I should be able to find it.

(If you're curious: This doesn't contribute to your grade, but try one case where of the skydiver. Your program should also ask how long do yout is quite a bit larger (and all the other parameters are the same), say want to calculate the dive out to and what your timestep (t)t=5 sec. What happens to your solution? Does this make physical sense? Any thoughts on why this occurs? We'll talk about this briefly in lecture. One hint: What you see is a classic example of what in scientific computing is called "numerical instability.")

Frot ma Fgravity Fdrag (m/s2) (g = 9.81 m/s *)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!