Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

can someone answer as soon This is the Assignment 11 Write (in C++) a program th

ID: 3696625 • Letter: C

Question

can someone answer as soon

This is the Assignment 11 Write (in C++) a program that uses Euler's method to solve the following problem: Assume the trajectory of a cannonball, including the effects of atmospheric drag, is given by the equations where , , and . Suppose we launch a cannonball at an angle of above the horizon with a speed of . How far does the cannonball travel horizontally and what timestep size ( ) did you have to use to find your answer? You should put your answers in comment statements in your header block along with the results of a convergence test. Hint: You will have to terminate your calculation when the cannonball comes back to approximately ground level. If your last timestep took the cannonball below ground level, the last timestep was too large and you should reduce the size of the last timestep and use the reduced timestep until you are approximately at ground level. You can use an if construct with a continue statement within a loop to adjust your timestep size as needed to accomplish this. Submit the source code file, i.e. the .cpp file containing the C++ code, by uploading it into blackboard using the “attachments” button under the assignment.

with given equations of Euler's method as follow.

dx/dt = vx ---------------eq(1)

dy/dt = vy---------------eq(2)

dvx/dt = -alphavvx----------------------eq(3)

dvy/dt = -alphavvy -g---------------------eq(4)

and another part of the problem as given the following values, such as

g=9.8m/s^2 , alpha = 4X 10^-5, V=SQRT(VX^2 + VY^2), V=700M/S^2

based on the above information in the problem i have to solve for this next Assignment 12 such as

Rewrite (in C++) a your Euler's method program to use the 4th order Runge-Kutta algorithm to do the integration for the cannonball problem specified in Assignment 11. The program should use C++ functions for the problem specific parts (initial conditions, number of equations, the right-hand-sides of the ODEs) and dynamic arrays so that the main driver program is generic (no problem specific information in the main program!). Put the function prototypes in a namespace declared within a header file. Package the problem specific function definitions into a separate file C++ code file. The main program should be in it's own file. What timestep were you able to use (compared to your Euler algorithm code) with the 4th order Runge-Kutta algorithm (note this information in the header of the file containing the function definitions)? Upload all three files (your main program, your header file, and your file containing the function definitions) into Blackboard one at a time.

The folumas taken from physics

Explanation / Answer

#include<stdio.h>
#include<math.h>


main()

{
/*Declare variables*/

double x; //Euler's ball position in x
double y; //Euler's ball position in y
double x_o; //Initial ball position in x
double y_o; //Initial ball position in y
double v; //Eulers ball speed
double v_x; //Eulers ball speed in x
double v_y; //Eulers ball speed in y
double v_x_o; //Initial ball speed in x
double v_y_o; //Initial ball speed in y
double p; //Air density
double p_o; //Initial air density
double m; //Ball mass
double g; //gravity constant
double theta; //Initial launch angle
double C; //Drag constant
double A; //Ball area
double dt,tmax,t; // Timestep, Maximum time,Current time


/* Set initial values for variables */


v = 700.0; //set initial speed
theta = M_PI/6.0; //set initial angle to 30 degrees
v_x = v_x_o; //set initial speed variable in x
v_x_o = v*cos(theta); //set initial speed constant in x
v_y = v_y_o; //set initial speed variable in y
v_y_o = v*sin(theta); //set initial speed constant in y
x = 0.0; //initial position
y = 0.0; //initial position
y_o = 10000.0; //initial sea height
m = 1.0; //set ball mass
p = 1.4; //density of air
g = 9.8; //gravity constant
C = 1.0; //set drag constant
A = 0.01; //set ball area
t = 0.0; //set initial time
dt = 0.5; //set time steps
tmax = 50.0; //maximum time

/* Now go through the steps until tmax is exceeded */

while (t < tmax )
{ //
no exact solution
printf("%lf %lf %lf ", t, x, y); //print statement
v = sqrt(v_x*v_x + v_y*v_y); //total speed
v_x = v_x - exp(-y/y_o)*(1.0/(2.0*m))*C*p*A*fabs(v_x)*v_x*dt; //Euler's solution in x
v_y = v_y - g*dt - exp(-y/y_o)*(1.0/(2.0*m))*C*p*A*fabs(v_y)*v_y*dt; //Euler's solution in y
x = x + v_x*dt; //Position in x as function of speed
y = y + v_y*dt; //Position in y as function of speed
t = t + dt; //time steps
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote