Question: In C++ Create a derived class named turbine_dev based on the turbine class in the attached turbine.cpp code which is located below. The objective is

In C++

Create a derived class named turbine_dev based on the turbine class in the attached turbine.cpp code which is located below. The objective is for reading parameters from an input text file and writing the computed power to an output text file. To give you an idea, example text files are shown directly below.

param0.txt

rotor-radius(m) = 50 location(m) = 0 induction factor = 0.1

param1.txt

rotor-radius(m) = 50 location(m) = 800 induction factor = 0.2

param2.txt

rotor-radius(m) = 50 location(m) = 1800 induction factor = 0.3

power0.txt

turbine-location = 0 induction factor = 0.1 power (MW) = 1.55862

power1.txt

turbine-location = 800 induction factor = 0.2 power (MW) = 2.2508

power2.txt

turbine-location = 1800 induction factor = 0.3 power (MW) = 2.25534

Basically I need help editing the code below so that it takes in input text files such as the ones shown above (eg. param0.txt, param1.txt) and outputes the turbine power in an output text file (eg. power0.txt, power1.txt).

The specifications for the code are as follows:

In C++ Create a derived class named turbine_dev based on the turbine

The Turbine.cpp Code:

/* create a derived class turbine_dev adding capability for computing incoming turbulence intensity of each turbine */

#include

#include

using namespace std;

const double PI = acos(-1.0);

const double rho = 1.225;

double windspeed_freeincoming;

class turbine // define a turbine class

{

private:

double turbinecoor; // location of the turbine

double radius_rotor; // rotor radius

double inductionfactor_axis; // axial induction factor

double coeff_power; // power coefficient

double windspeed_incoming; // incoming wind speed for this turbine

double power; // produced power

double coeff_entrainment; // entrainment coefficient

public:

// ctor

turbine( ) : coeff_entrainment(0.1) { }

// ask user to enter turbine characteristics

void getturbine()

{

cout > turbinecoor;

cout > radius_rotor;

cout > inductionfactor_axis;

}

// compute wake radius at x downwind from this turbine

double radius_wake(double x) { return (radius_rotor + coeff_entrainment * x); }

// compute wake velocity at x downwind from this turbine

double velocity_wake(double x)

{

return (windspeed_incoming * (1.0 - 2*inductionfactor_axis*pow(radius_rotor/radius_wake(x),2)));

}

// compute the incoming wind speed if this turbine facing undisturbed wind

void comput_incomingwind( )

{

windspeed_incoming = windspeed_freeincoming;

}

// compute the incoming wind speed if this turbine in the downwind of Turbine_upwind

void comput_incomingwind(turbine Turbine_upwind)

{

double Sx = fabs(turbinecoor - Turbine_upwind.turbinecoor);

windspeed_incoming = Turbine_upwind.velocity_wake(Sx);

}

// compute power coefficient of this turbine

double CP() { return 4. * inductionfactor_axis * pow(1. - inductionfactor_axis, 2.); }

// compute power of this turbine

void comput_power()

{

coeff_power = CP();

power = 0.5 * coeff_power * rho * PI * pow(radius_rotor,2) * pow(windspeed_incoming,3);

}

// display the performance of this turbine

void dispturbine( ) const

{

cout

cout

}

};

// ask user to enter incoming wind info

void getwind()

{

cout > windspeed_freeincoming;

}

int main()

{

// create turbine object array;

turbine Turbine[3];

// get undisturbed wind speed

getwind();

int i = 0;

do {

cout

// get turbine parameters

Turbine[i].getturbine();

// compute incoming wind speed

if (i==0) Turbine[i].comput_incomingwind( );

else Turbine[i].comput_incomingwind(Turbine[i-1]);

// compute produced power

Turbine[i].comput_power();

// display turbine performance

Turbine[i].dispturbine();

i++;

} while (i

return 0;

}

1. (35 points) Properly define the derived class. 2. (20 points) Add member functions in the derived class for reading parameters and writing turbine power, respectively. 3. (20 points) Properly use the functions in the fstream) class or ifstream) and ofstream) classes for reading and writing files. 4. (10 points) Write lines in the main() functions for testing the new derived clas:s 5. (10 points) Correctly read and write the files. 6. (5 points) Necessary comments, indentation and others. 1. (35 points) Properly define the derived class. 2. (20 points) Add member functions in the derived class for reading parameters and writing turbine power, respectively. 3. (20 points) Properly use the functions in the fstream) class or ifstream) and ofstream) classes for reading and writing files. 4. (10 points) Write lines in the main() functions for testing the new derived clas:s 5. (10 points) Correctly read and write the files. 6. (5 points) Necessary comments, indentation and others

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!