Advertisement
Sateviss

Turbine Calculator

Nov 16th, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.37 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4.  
  5. using namespace std;
  6.  
  7. double UsableSteamEnergy (int BladeSurfaceArea, double SteamIn)
  8. {
  9.     if (1.5*25*BladeSurfaceArea > SteamIn)
  10.         return 10*SteamIn;
  11.     else
  12.         return 10*floor(1.5*25.0*BladeSurfaceArea);
  13. }
  14.  
  15. double LiftTorque (int BladeSurfaceArea, double SteamIn)
  16. {
  17.     double USE = UsableSteamEnergy(BladeSurfaceArea, SteamIn);
  18.     return ((BladeSurfaceArea*(10*SteamIn-USE))/floor(SteamIn/25)+USE);
  19. }
  20.  
  21. double InductionTorque (int CoilSize, double InductorDrag, int BladeSurfaceArea, int RotorMass)
  22. {
  23.     return ((1.5*CoilSize*InductorDrag)/(BladeSurfaceArea*RotorMass));
  24. }
  25.  
  26. double RotorEnergy (int CoilSize, double InductorDrag, int BladeSurfaceArea, int RotorMass, double SteamIn)
  27. {
  28.     double LT = LiftTorque(BladeSurfaceArea, SteamIn);
  29.     double IT = InductionTorque(CoilSize, InductorDrag, BladeSurfaceArea, RotorMass);
  30.     return ((LT-RotorMass/10.0)/(IT+1/(4000.0*RotorMass)));
  31. }
  32.  
  33. double RotorSpeed(int CoilSize, double InductorDrag, int BladeSurfaceArea, int RotorMass, double SteamIn)
  34. {
  35.     double Energy = RotorEnergy(CoilSize, InductorDrag, BladeSurfaceArea, RotorMass, SteamIn);
  36.     return Energy/(BladeSurfaceArea*RotorMass);
  37. }
  38.  
  39. double TurbineEfficiency (double RotorSpeed)
  40. {
  41.     if (RotorSpeed < 500)
  42.         return 0.5;
  43.     else
  44.         return 0.25*(cos(RotorSpeed/(45.5*M_PI))+3);
  45. }
  46.  
  47. double GeneratedEnergy(double InductorEfficiency, int CoilSize, double InductorDrag, int BladeSurfaceArea, int RotorMass, double SteamIn, double InductorBonus)
  48. {
  49.     double RotorSpd = RotorSpeed(CoilSize, InductorDrag, BladeSurfaceArea, RotorMass, SteamIn);
  50.     double TE = TurbineEfficiency(RotorSpd);
  51.     double GeneratedEnergy = InductorEfficiency*TE*powf(1.5*CoilSize*InductorDrag*RotorSpd, InductorBonus);
  52.     return GeneratedEnergy;
  53. }
  54.  
  55. int binMax(double* arr, int start, int end)
  56. {
  57.     if (start == end)
  58.         return start;
  59.     else
  60.     {
  61.         int a = binMax(arr, start, (end+start)/2);
  62.         int b = binMax(arr, (end+start)/2+1, end);
  63.         if (arr[a] > arr[b])
  64.             return a;
  65.         else
  66.             return b;
  67.     }
  68. }
  69.  
  70. int main()
  71.  
  72. {
  73.    
  74.     double InductorEfficiency;
  75.     double InductorDrag;
  76.     double InductorBonus;
  77.     double SteamIn;
  78.     int BladesPerLevel;
  79.    
  80.     cout<<"Inductor efficiency: ";
  81.     cin>>InductorEfficiency;
  82.     cout<<"\nInductor drag: ";
  83.     cin>>InductorDrag;
  84.     cout<<"\nInductor bonus: ";
  85.     cin>>InductorBonus;
  86.     cout<<"\nSteam in: ";
  87.     cin>>SteamIn;
  88.     cout<<"\nBlades per level: ";
  89.     cin>>BladesPerLevel;
  90.  
  91.    
  92.     double output[1000][1000];
  93.     for (int i = 0; i < 1000; i++)
  94.         for (int j = 0; j<1000; j++)
  95.             output[i][j] = 0;
  96.     int height = 2;
  97.     int MaxCoilSize = 0;
  98.     for (int CoilSize = 1; height <= 14; CoilSize++)
  99.     {
  100.         for (int BladeCount = 1; height <=14; BladeCount++)
  101.         {
  102.             height = (CoilSize+7)/8 + (BladeCount+BladesPerLevel-1)/BladesPerLevel;
  103.             double out = GeneratedEnergy(InductorEfficiency, CoilSize, InductorDrag, BladeCount, 10*(height+BladeCount), SteamIn, InductorBonus);
  104.             output[CoilSize][BladeCount] = out;
  105.         }
  106.         height = (CoilSize+7)/8 + 1;
  107.         MaxCoilSize = CoilSize;
  108.     }
  109.    
  110.     MaxCoilSize++;
  111.    
  112.     for (int CoilSize = 1; CoilSize < MaxCoilSize ; CoilSize++)
  113.     {
  114.         int BladeCount = binMax(output[CoilSize], 0, 999);
  115.         cout<<"\n\n\nCoils:\t"<<CoilSize<<"\nBlades:\t"<<BladeCount<<"\nRF/t:\t"<<output[CoilSize][BladeCount]<<"\nRPM:\t"<<RotorSpeed(CoilSize, InductorDrag, BladeCount, 10*(((CoilSize+7)/8 + (BladeCount+BladesPerLevel-1)/BladesPerLevel)+BladeCount) , SteamIn);
  116.     }
  117.     return 0;
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement