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

INTRODUCTION: Rocket motors are tested by restraining them on the ground, firing

ID: 3806567 • Letter: I

Question

INTRODUCTION:

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

********************************************

Explanation / Answer

this question is farely straight forward, if we can succesfully generate tthe time and thrust array from the input file. we are given this format -

10 (number of data entry)

time , thrust

therefore our c code to read the above data would be as follows -

#include <stdio.h>
#include <string.h>

void main()
{
    FILE *fp = fopen("testdata.txt", "r");
    const char s[2] = ", ";
    char *token;
    int i,j=0;
    if(fp != NULL)
    {
        char line[20];

         int size=fgets(line,sizeofline,fp);

           int time[size+1],thrust[size+1];

       while(fgets(line, sizeof line, fp) != NULL)
        {
            token = strtok(line, s);
          
               time[j++] = token[0];

               thrust[j++]=token[1];
          
        }
        fclose(fp);
    } else {
        perror("testdata.txt");
    }
}

now we have the time adn thrust array as required ! simply do the calculations needed as explained in the question.

F1 would be the value for time[0] and thrust[0]

.... and we will go ti;ll Fsize.

time increment would be time[i+1] - time[i] for successive quantitites!

therrefore total time increment, delta T in for the formula given in question wuld be time[size-1] - time [0], since array are 0 indexed therefore we go to till siize-1;

calculate other values as asked.

for output format-

for(i=0;i<100000;i++) printf("*");

printf(" ");

to print the line **********************

and other data could simply be printed usig basic printf.

now, to output it to a file we mist open it in write mode!

code -


FILE *f = fopen("output.txt", "w");
if (f == NULL)
{
    printf("Error opening file! ");
    exit(1);
}

/* print to file like this */

/* example code
int i = 1;
float py = 3.1415927;
fprintf(f, "Integer: %d, float: %f ", i, py);

*/

/* like above example write ur output format answer heere*/

fclose(f);

-----------------------------------------------------------------

thank you

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