Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

projectile motion. Euler's method can be used to solve a basic problem of computing the trajectory of a projectile subject to aerodynamic drag force D

image text in transcribedimage text in transcribedimage text in transcribed

projectile motion. Euler's method can be used to solve a basic problem of computing the trajectory of a projectile subject to aerodynamic drag force D and gravitational force G, as shown below in the horizontal x and vertical y coordinate system. At any point in the motion of theprojectile the drag force D is directed opposite to the direction of the velocity and is proportional to the square of the projectile velocity v2 = y2 + v2. D = 0.5 p Ca A (v + v}) where p is the density of air (kg/m3), Ca is the drag coefficient, A is the cross-sectional area of the projectile. A = ttr2 where r (m) is the projectile radius. Using Newton's second law, a set of equations that describe the projectile motion is dx = VX dt dy = vy dt dvx m m = -Dcose dt dvy m = -Dsino - mg dt where g is the gravitational acceleration (9.81 m/s2), m is the projectile mass (kg), O is the angleof the projectile motion from x-axis (0 = arctan(vy/vx)). This set of the equations is difficult to solve by hand, but can be solved relatively easily numerically. Heighty V sin(O) D Vocos(O) G ymax yo Xrange Horizontal Distance Overall Tasks: Write a C++ program that computes, for a given initial projectile velocity vo and angle do and timestep size At the projectile trajectory from the initial location at a certain height yo until the projectile hits the ground after reaching its peak height ymax and traveling a certain horizontal distance Xrange over time travel. Note that x and y components of the initial projectile velocity vo can be expressed as Vx0 = Vocos(@) and Vyo = vosin(80) using the initial projectile velocity Vo and angle O.. Use the following projectile properties: mass m = 50.0 (kg) radius r = 0.25 (m) drag coefficient Cs = 0.5 air density rho = 1.275(kg/m3). Recall that A is the cross-sectional area of the projectile given as A = r? Euler's Method Algorithm: Euler's method numerically computes the trajectory of a projectile from the initial location (x(n = 0), y(n=0)) to (x(n = nstop), y(n = nstop)) by iteration Specifically, the projectile location change from (x(n), y(n)) to (x(n+1), y(n+1)) over a small time step At = t(n + 1) -t(n) is given as t(n + 1) x(n+1) y(n+1) Tasks: 1. Submit a C++ program source file named hw5.cpp to Gradescope. 2. Comment your code! 3. The hw5.cpp file should contain (i) a main() function, (ii) call-by-value functions named Fx and Fy that return values, and (iii) a call-by-reference function named euler that also returns a value. Details: 1. Declare the projectile property parameters cd, A, mass, radius, the gravitational acceleration g, and the air density rho as global variables so that they can be accessed by all functions. 2. Use the following prototypes to declare user-defined functions Fx and Fy: double Fx[double vx, double vy) double Fy(double vs, double vy) and implement Equations (6) and (7) as C++ functions that: a. takes vx(n) and vy(n) as input arguments b. computes the right-hand-side of Equations (6) and (7) c. returns its value. 3. Use the following prototype to declare a user-defined function euler: double euler(double &t, double &x, double y, double vx, double vy, double DT); and implement steps described by Equations (1)-(5) using a iterative method (eg, for- loop, while-loop, do while-loop), with initial values of t(0), x(),y(0),vx(0), vy(0) and a fixeed value of At given as input arguments. The euler function needs to call functions Fx and Fy to evaluate Equations (4)-(5). Note that the projectile peak height ymax value needs to be returned to the main function by return-by-value. The condition to stop the iteration is given by y(nstop) = 0, and x(nstop) and t(nstop) become the numerical estimates of Xrange and travel, which need tobe returned to the calling function by reference. 4. Write a main() function that sets the initial parameters: a. Projectile velocity Vo = 5.0(m/s) b. Angle 8. = 30 (degrees), c. Height yo = 10.0 (m) 5. Ask the user to provide a value for At a. Print "Enter the integration time step (sec);" 6. Using those values and calling the euler function compute: t(n) + At x(n) + vx(n)At y(n) + vy(n)At vx[n) + Fx(vx(n) vy(n) At vy(n) + Fy(vx(n)vy(n)) (2) (3) Van + 1) vy(n+1) where Fx and Fy are the rate of velocity changes due to acceleration by drag and gravitational forces. (These terms are functions of velocity itself, vx(n) and vy(n), because the drag force is proportional to the square of the projectile velocity as explained in the Problem Section.) Fx andFy are given as Fx(vx(n), vy(n)) = -0.5 rho Cd A (vx(n)2 + vy(n)) cos(arctan(vy(n)/vx(n))]/mass Fy(vx(n).vy(n)) = -0.5 rho Cd A (vx(n) + vy(n)) sin(arctan(vy(n)/vx(n))]/mass-8 (7) Euler's method can be implemented by evaluating Equations (1)-(7) from n=0 ton = 1, and then from n=1 to n = 2, etc, until (x(n), y(n)) reaches (x(n = Nistop), y(n = nstop)) for given initial values of t[0),x(0),y(0), vx(0), vy(0) and a fixed value of At Note that the projectile property parameters Cd, A, mass, radius, the gravitational acceleration g, and the air density rho do not change over the course of the iteration in this problem. the projectile peak height ymax, . range Xrange . travel time ttravel 7. Print the calculated values to the console: a. C. Print ymax with Peak height (m): b. Print Xrange with Range (m): Print ttravel with Travel time (sec): 8. Here are some details required for a successful Gradescope submission. a. Use atan2 so the arctangent of all four quadrants can be computed. b. Use double precision (double data type) to represent decimal numbers in the code. c. Use M_PI for 1. 9. Sample Console output ASENUser: /environment/Hw5 $ ./hw5 Enter the integration time step (sec): .1 Initial speed (m/s): 5 Initial angle (deg): 30 Initial height (m): 10 Peak height (m): 10.4553 Range (m): 7.74387 Travel time (sec): 1.8 ASENUser:~/environment/Hw5 $ I projectile motion. Euler's method can be used to solve a basic problem of computing the trajectory of a projectile subject to aerodynamic drag force D and gravitational force G, as shown below in the horizontal x and vertical y coordinate system. At any point in the motion of theprojectile the drag force D is directed opposite to the direction of the velocity and is proportional to the square of the projectile velocity v2 = y2 + v2. D = 0.5 p Ca A (v + v}) where p is the density of air (kg/m3), Ca is the drag coefficient, A is the cross-sectional area of the projectile. A = ttr2 where r (m) is the projectile radius. Using Newton's second law, a set of equations that describe the projectile motion is dx = VX dt dy = vy dt dvx m m = -Dcose dt dvy m = -Dsino - mg dt where g is the gravitational acceleration (9.81 m/s2), m is the projectile mass (kg), O is the angleof the projectile motion from x-axis (0 = arctan(vy/vx)). This set of the equations is difficult to solve by hand, but can be solved relatively easily numerically. Heighty V sin(O) D Vocos(O) G ymax yo Xrange Horizontal Distance Overall Tasks: Write a C++ program that computes, for a given initial projectile velocity vo and angle do and timestep size At the projectile trajectory from the initial location at a certain height yo until the projectile hits the ground after reaching its peak height ymax and traveling a certain horizontal distance Xrange over time travel. Note that x and y components of the initial projectile velocity vo can be expressed as Vx0 = Vocos(@) and Vyo = vosin(80) using the initial projectile velocity Vo and angle O.. Use the following projectile properties: mass m = 50.0 (kg) radius r = 0.25 (m) drag coefficient Cs = 0.5 air density rho = 1.275(kg/m3). Recall that A is the cross-sectional area of the projectile given as A = r? Euler's Method Algorithm: Euler's method numerically computes the trajectory of a projectile from the initial location (x(n = 0), y(n=0)) to (x(n = nstop), y(n = nstop)) by iteration Specifically, the projectile location change from (x(n), y(n)) to (x(n+1), y(n+1)) over a small time step At = t(n + 1) -t(n) is given as t(n + 1) x(n+1) y(n+1) Tasks: 1. Submit a C++ program source file named hw5.cpp to Gradescope. 2. Comment your code! 3. The hw5.cpp file should contain (i) a main() function, (ii) call-by-value functions named Fx and Fy that return values, and (iii) a call-by-reference function named euler that also returns a value. Details: 1. Declare the projectile property parameters cd, A, mass, radius, the gravitational acceleration g, and the air density rho as global variables so that they can be accessed by all functions. 2. Use the following prototypes to declare user-defined functions Fx and Fy: double Fx[double vx, double vy) double Fy(double vs, double vy) and implement Equations (6) and (7) as C++ functions that: a. takes vx(n) and vy(n) as input arguments b. computes the right-hand-side of Equations (6) and (7) c. returns its value. 3. Use the following prototype to declare a user-defined function euler: double euler(double &t, double &x, double y, double vx, double vy, double DT); and implement steps described by Equations (1)-(5) using a iterative method (eg, for- loop, while-loop, do while-loop), with initial values of t(0), x(),y(0),vx(0), vy(0) and a fixeed value of At given as input arguments. The euler function needs to call functions Fx and Fy to evaluate Equations (4)-(5). Note that the projectile peak height ymax value needs to be returned to the main function by return-by-value. The condition to stop the iteration is given by y(nstop) = 0, and x(nstop) and t(nstop) become the numerical estimates of Xrange and travel, which need tobe returned to the calling function by reference. 4. Write a main() function that sets the initial parameters: a. Projectile velocity Vo = 5.0(m/s) b. Angle 8. = 30 (degrees), c. Height yo = 10.0 (m) 5. Ask the user to provide a value for At a. Print "Enter the integration time step (sec);" 6. Using those values and calling the euler function compute: t(n) + At x(n) + vx(n)At y(n) + vy(n)At vx[n) + Fx(vx(n) vy(n) At vy(n) + Fy(vx(n)vy(n)) (2) (3) Van + 1) vy(n+1) where Fx and Fy are the rate of velocity changes due to acceleration by drag and gravitational forces. (These terms are functions of velocity itself, vx(n) and vy(n), because the drag force is proportional to the square of the projectile velocity as explained in the Problem Section.) Fx andFy are given as Fx(vx(n), vy(n)) = -0.5 rho Cd A (vx(n)2 + vy(n)) cos(arctan(vy(n)/vx(n))]/mass Fy(vx(n).vy(n)) = -0.5 rho Cd A (vx(n) + vy(n)) sin(arctan(vy(n)/vx(n))]/mass-8 (7) Euler's method can be implemented by evaluating Equations (1)-(7) from n=0 ton = 1, and then from n=1 to n = 2, etc, until (x(n), y(n)) reaches (x(n = Nistop), y(n = nstop)) for given initial values of t[0),x(0),y(0), vx(0), vy(0) and a fixed value of At Note that the projectile property parameters Cd, A, mass, radius, the gravitational acceleration g, and the air density rho do not change over the course of the iteration in this problem. the projectile peak height ymax, . range Xrange . travel time ttravel 7. Print the calculated values to the console: a. C. Print ymax with Peak height (m): b. Print Xrange with Range (m): Print ttravel with Travel time (sec): 8. Here are some details required for a successful Gradescope submission. a. Use atan2 so the arctangent of all four quadrants can be computed. b. Use double precision (double data type) to represent decimal numbers in the code. c. Use M_PI for 1. 9. Sample Console output ASENUser: /environment/Hw5 $ ./hw5 Enter the integration time step (sec): .1 Initial speed (m/s): 5 Initial angle (deg): 30 Initial height (m): 10 Peak height (m): 10.4553 Range (m): 7.74387 Travel time (sec): 1.8 ASENUser:~/environment/Hw5 $

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 2 Lncs 13427

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124251, 978-3031124259

More Books

Students also viewed these Databases questions

Question

7. Identify six intercultural communication dialectics.

Answered: 1 week ago