import java.util.Arrays;
import java.lang.Math;
//功率曲线达标率计算-array1(拟合功率曲线),array2(保证功率无线),
//输入是风速和功率的二维数组,输出:功率曲线达标率
//判断标准: >150%或<80% 报警
class Main {
public static void main(String[] args) {
//拟合功率曲线
// double[][] array1 = new double[][]{{1.0,2.0,3.0,4.0},{1.0,2.0,3.0,4.0}};
double[][] array1 = new double[][]{{ 2.5 , 3. , 3.5 , 4. , 4.5 , 5. , 5.5 ,
6. , 6.5 , 7. , 7.5 , 8. , 8.5 , 9. ,
9.5 , 10. , 10.5 , 11. , 11.5 , 12. , 12.5 ,
13. , 13.5 , 14. , 14.5 , 15. },
{56.21, 64.69, 89.57, 122.61, 180.61, 259.54, 352.57,
484.87, 638.05, 784.88, 957.04, 1109.37, 1364.92, 1601.38,
1789.62, 1927.67, 1997.7 , 2054.98, 2054.98, 2054.98, 2054.98,
2054.98, 2054.98, 2054.98, 2054.98, 2054.98}};
//保证功率曲线
// double[][] array2 = new double[][]{{1.0,2.0,3.0,4.0},{1.0,2.0,3.0,4.0}};
double[][] array2 = new double[][]{{ 3.0 , 3.5 , 4.0 , 4.5 , 5.0 , 5.5 , 6.0 ,
6.5 , 7.0 , 7.5 , 8.0 , 8.5 , 9.0 , 9.5 ,
10.0 , 10.5 , 11.0 , 11.5 , 12.0 , 12.5 , 13.0 ,
13.5 , 14.0 , 14.5 , 15.0 , },
{ 38.73, 85.11, 132.25, 191.22, 264.44, 352.15, 456.46,
575.86, 711.8 , 864.69, 1036.81, 1217.69, 1411.01, 1617.85,
1808.56, 1931.75, 1981.81, 1995.29, 2000.0 , 2000.0 , 2000.0 ,
2000.0 , 2000.0 , 2000.0 , 2000.0 }};
double sum = fitrate(array1,array2);
System.out.println(sum); // 换行
}
public static double fitrate(double[][] x, double[][] y) {
double pi = Math.PI;
double[][] x_x = new double[2][50];
double[][] y_y = new double[2][50];
double[] xx=new double[50];
double[] yy=new double[50];
double sum_x = 0.0;
double sum_y = 0.0;
for (int i = 0; i < x[0].length; i++) {
x_x[0][i+1] = 1.0-Math.exp(-pi*Math.pow((x[0][i]/6.0),2)/4.0);
x_x[1][i+1] = x[1][i];
}
for (int i = 0; i < y[0].length; i++) {
y_y[0][i+1] = 1.0-Math.exp(-pi*Math.pow((y[0][i]/6.0),2)/4.0);
y_y[1][i+1] = y[1][i];
}
for (int i = 1; i < x[0].length+1; i++) {
xx[i-1] =(x_x[0][i]-x_x[0][i-1])*((x_x[1][i]+x_x[1][i-1])/2.0);
sum_x += xx[i-1];
}
for (int i = 1; i < y[0].length+1; i++) {
yy[i-1] =(y_y[0][i]-y_y[0][i-1])*((y_y[1][i]+y_y[1][i-1])/2.0);
sum_y += yy[i-1];
}
double sum = ((sum_x*8760.0)/(sum_y*8760.0))*100;
return sum;
}
}