Rocket motors are tested by restraining them on the ground, firing them with a k
ID: 3803042 • Letter: R
Question
Rocket motors are tested by restraining them on the ground, firing them with a known amount of propellant, and measuring the thrust over time. A typical curve is shown below.
The total impulse is the integral of the thrust over the operating duration of the motor. This can be approximated by
It = t(F1+F2+F3+…)
where: It = total impulse in lb-sec
t = time increment in seconds
F1, F2, F3, … = thrust at timesteps 1, 2, 3, … in lb
The specific impulse is the total impulse divided by the weight of the propellant burned in the test.
Isp = It/m
where: Isp = specific impulse in seconds
m = mass of propellant burned in pounds
The average thrust is found by dividing the total impulse by the thrust time.
Favg = It/t
where: Favg = average thrust in lb
t = total test time in seconds
An input data file called testdata contains time and thrust data for a rocket test where the mass of propellant burned was 1.74 lb. The first record line of the input file is the control number, which defines the number of data points to be read into the program. Each succeeding record line has two columns. The first column is the elapsed test time in seconds, and the second column is the thrust in pounds. The input file is comma delimited.
ASSIGNMENT:
Write a C program that will read the required values from the input file into two one-dimensional arrays. Using the thrust, time, and increment between timesteps (hint: you can get this from the time array – think about using one specific data value), compute the total thrust, total impulse, specific impulse, and average thrust. Print the total impulse, specific impulse, and average thrust to the computer screen and to an output file called results.
OUTPUT FORMAT:
********************************************
ROCKET MOTOR TEST RESULTS
Total Impulse: XXX.X lb-sec
Specific Impulse: XXX.X sec
Average Thrust: XXX.X lb
********************************************
FILE PATHS:
Before submitting your C source program, make sure that you set your input and output file paths to
U:ENGR 200.
the file :
Explanation / Answer
#include<stdio.h>
#include<stdlib.h>//Header file for dynamic memory allocation to allocate memory for array
#define PROP_MASS 1.74 //Mass of propellent burned
int main()
{
FILE *testdata = fopen("testdata","r");//opening testdata file in readonly mode
if(testdata==NULL)//Error checking, if error opening file, return from main function ie terminating the program
{
perror("testdata");
return 1;
}
int no_points,i;//no_points is to hold the no of data points to be read from file "testdata"
fscanf(testdata,"%d",&no_points);//Reading no_of points to be read from file
float *time_column,*thrust_column;//time_column and thrust column are pointers to hold the base addresses of arrays
float total_thrust,total_impulse,specific_impulse,avg_thrust,time_incr,total_test_time;
time_column = (float *)malloc(sizeof(float)*no_points);//Allocating array of size no_points to store time column
thrust_column = (float *)malloc(sizeof(float)*no_points);//Allocating array of size no_points to store thrust column
for(i=0;i<no_points;i++)
fscanf(testdata,"%f,%f",time_column+i,thrust_column+i);
time_incr = time_column[1]-time_column[0];//Calculating time increment
total_thrust = 0;
for(i=0;i<no_points;i++)//Sum of the elements of array thrust_column
total_thrust += thrust_column[i];//calculating total thrust
total_impulse = total_thrust * time_incr;//calculating total impulse
specific_impulse = total_impulse/PROP_MASS;//calculating specific impuluse
total_test_time = time_column[no_points-1]-time_column[0];//total test time calculation
avg_thrust = total_impulse/total_test_time;//calculating average thrust
printf(" ROCKET MOTOR TEST RESULTS ");
printf("Total Impulse: %f lb-sec ",total_impulse);
printf("Specific Impulse: %f sec ",specific_impulse);
printf("Average Thrust: %f lb ",avg_thrust);
FILE *output = fopen("output","w");
if(output==NULL)
{
perror("output");
return 1;
}
fprintf(output," ROCKET MOTOR TEST RESULTS ");
fprintf(output,"Total Impulse: %f lb-sec ",total_impulse);
fprintf(output,"Specific Impulse: %f sec ",specific_impulse);
fprintf("Average Thrust: %f lb ",avg_thrust);
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.