# EG1007 Analyze various problems associated with an offshore wind turbine system as sketched:

You are asked to analyze various problems associated with an offshore wind turbine system as sketched in Figure. 1. This includes the statistics on the power production, analysis of the environmental conditions and environmental load on the wind turbine. You need to use NumPy and matplotlib to complete the tasks. Figure 1: sketch of wind turbine system.

1) Data analysis on power production (25 marks)
The file ‘windturbinepower.txt’ contains the time history of the power generated by the wind turbine. There are two columns of data in the file. The first column is the time t in seconds and the second is the power P in watts. Complete the following tasks
i) Use NumPy to read the data and analyse the maximum power, mean power and the standard deviation.
ii) Use matplotlib to plot a curve shows the variation in power with time.
iii) Estimate the rate of change of power with time (i.e. / ) at different time instants using appropriate finite difference schemes with a consistent order of O(dt2).

2) Interpolating lift coefficients (25 marks)
The file ‘liftcoeff.txt’ contains the lift coefficient Cl of the turbine blade subjected to different attack angles, , which are the angles between the wind velocity and the blade. The first column of the data in the file is the attack angles in degrees and the second column is the lift coefficient. For a specific lift coefficient, the corresponding force can be found by ! ” ” where  is the density of the fluid (i.e. air in this task), V is the relative velocity between the
wind and the rotating blade, A is the projection area of the blade perpendicular to the wind direction.

i) Using NumPy to load the data from the file, sort the data using the attack angle in ascending order (i.e. the first pair of data has the lowest attack angle)
ii) Using Newton’s Divided Difference Interpolation find the lift coefficient of the blade when the attack angle is 11 degrees using a linear polynomial. You need to select the two best data points and fit a linear polynomial using #() = \$ + !(− \$), where \$ and ! are the coefficients to be determined and \$ is the attack angle of one of the data points chosen.
iii) To improve the accuracy, a third order polynomial #() = \$ + ! + ”” + %% where \$, !, ” and % are the coefficients to be determined, will be used to find a second approximation of the lift coefficient at = 11 degrees. Select the 4 best sets  of data to determine the coefficients \$, !, ” and % and approximate the lift coefficient at = 11 degree.
iv) Use |’!(‘”| ‘” × 100% and the approximate lift coefficient obtained in iii) to evaluate the relative error of the prediction in ii) , where fn and fa are the estimated and reference values, respectively.

Note: when choosing the appropriate data sets for the interpolation, you need to write the Python code to automatically select the best data sets using the difference between the attack angle of interest and the attack angles for which you have data. You are also expected to produce a figure comparing the data in the file, the linear interpolation function in ii) and the third-order polynomial in iii).