
# Thin Electric 9x4.5 at http://m-selig.ae.illinois.edu/props/volume-1/propDB-volume-1.html

Rhub = 1/100*6             # (m) Radius of hub
Rtip = 11.5/100*6          # (m) Radius of blade tip
B = 3                      # Number of blades

# r/R y/R (y-distance of LE from the middle point of hub)
sweepdist = [
  0.001480385	0.095446349;
  0.022205774	0.093053236;
  0.0407105850 .090656541;
  0.062176166	0.089073469;
  0.084381939	0.087491591;
  0.107327905	0.085910907;
  0.131014064	0.085140264;
  0.149518875	0.08517011;
  0.171724648	0.085205926;
  0.195410807	0.086052977;
  0.218356773	0.087707682;
  0.238341969	0.090166457;
  0.262028127	0.092631203;
  0.29015544	0.095103111;
  0.315321984	0.095143703;
  0.344929682	0.096000305;
  0.367875648	0.096037315;
  0.390821614	0.095265478;
  0.413027387	0.094492446;
  0.442635085	0.093731354;
  0.468541821	0.092155445;
  0.488527017	0.090569986;
  0.510732791	0.088988108;
  0.530717987	0.086593801;
  0.553663953	0.084204269;
  0.576609919	0.081005891;
  0.5980755	0.078613972;
  0.621021466	0.075415593;
  0.646928201	0.071413143;
  0.665433013	0.069016448;
  0.684678016	0.0658121;
  0.701702443	0.061795324;
  0.726128794	0.058599333;
  0.745373797	0.054586138;
  0.768319763	0.049770065;
  0.786824574	0.046564523;
  0.809030348	0.042556104;
  0.829755737	0.038545297;
  0.855662472	0.032925152;
  0.877868246	0.028916732;
  0.903034789	0.024104241;
  0.923760178	0.020093434;
  0.945965951	0.016085015;
  0.962990378	0.008832849;
  0.977054034	-0.003277174;
  0.986676536	-0.014585513;
  0.993338268	-0.02832517;
  0.99703923	-0.044496143;
  0.999259808	-0.062287198;
  1	-0.075227558;
	]

# r/R z/R  (height of leading edge from top face of hub)
heightdist = [
  0.100061686	0.063533274;
  0.115428599	0.068364815;
  0.132261738	0.073197533;
  0.150561105	0.078031427;
  0.168127358	0.082864732;
  0.185703101	0.08609164;
  0.203283589	0.088515349;
  0.22454388	0.088532401;
  0.244337944	0.088548276;
  0.266331348	0.088565916;
  0.295655887	0.088589436;
  0.344055612	0.086218647;
  0.36679162	0.084630476;
  0.393197941	0.082242047;
  0.41520558	0.07985009;
  0.443815986	0.076660226;
  0.475358846	0.073472714;
  # 0.320586491	0.087806229;
  0.498832713	0.071081933;
  0.524510665	0.067889717;
  0.553125816	0.063896654;
  0.620629196	0.054312361;
  # 0.586139647	0.059907118;
  0.649244347	0.050319298;
  0.678587867	0.047130022;
  0.707203018	0.043136959;
  0.731419488	0.039140368;
  0.756369072	0.035144365;
  0.783517996	0.031150126;
  0.804054663	0.029560192;
  0.830470474	0.025565365;
  0.85909037	0.020769102;
  0.882564236	0.018378321;
  0.913378728	0.014387022;
  0.93392014	0.011993889;
  0.956665639	0.008799321;
  0.975745569	0.005601813;
  1	-0.00482037;
]

# r/R t/R
thickdist = [
  0	.5;
  0.05790388	0.471107544;
  0.115807759	0.255744996;
  0.173711639	0.184816428;
  0.231615518	0.153640257;
  0.289519398	0.134343434;
  0.347423277	0.12172192;
  0.405327157	0.114454859;
  0.463231036	0.114329268;
  0.521134916	0.111640212;
  0.579038796	0.112186788;
  0.636942675	0.110633067;
  0.694846555	0.110354223;
  0.752750434	0.111281658;
  0.810654314	0.108251996;
  0.868558193	0.107515658;
  0.926462073	0.1075;
  1	0.1075;
]

# r/R c/R
chorddist = [
  0	.15;
  0.05790388	0.144296468;
  0.115807759	0.156224667;
  0.173711639	0.186103069;
  0.231615518	0.216328894;
  0.289519398	0.229299363;
  0.347423277	0.234047481;
  0.405327157	0.234742328;
  0.463231036	0.22790967;
  0.521134916	0.218876665;
  0.579038796	0.203358425;
  0.636942675	0.188419224;
  0.694846555	0.17000579;
  0.752750434	0.15089751;
  0.810654314	0.130515345;
  0.868558193	0.110943833;
  0.92	0.096204;
  0.93	0.093041;
  0.94	0.089878;
  0.95	0.086015;
  0.96	0.081552;
  0.97	0.074389;
  0.98	0.065226;
  0.99	0.051063;
  .9999	0.0209;
  1.01	0.0;
]

# r/R twist
pitchdist = [
  0.15	34.8;
  0.2	36.5;
  0.25	34.26;
  0.3	29.64;
  0.35	25.62;
  0.4	22.53;
  0.45	20.25;
  0.5	18.37;
  0.55	16.83;
  0.6	15.51;
  0.65	14.38;
  0.7	13.45;
  0.75	12.56;
  0.8	12.09;
  0.85	11.25;
  0.9	10.46;
  0.95	9.68;
  1	8.9
]


e216_file = "xf-e216-il-500000.csv"
x,y = vlm.ap.readcontour(data_path*"airfoils/e216.dat")
airfoilE216 = zeros(size(x)[1], 2)
airfoilE216[:,1] = x
airfoilE216[:,2] = y

e212_file = "xf-e212-il-500000.csv"
x,y = vlm.ap.readcontour(data_path*"airfoils/e212.dat")
airfoilE212 = zeros(size(x)[1], 2)
airfoilE212[:,1] = x
airfoilE212[:,2] = y

clarky_file = "xf-clarky-il-500000.csv"
clarkytop = [
  0.0000000 0.0000000;
  0.0005000 0.0023390;
  0.0010000 0.0037271;
  0.0020000 0.0058025;
  0.0040000 0.0089238;
  0.0080000 0.0137350;
  0.0120000 0.0178581;
  0.0200000 0.0253735;
  0.0300000 0.0330215;
  0.0400000 0.0391283;
  0.0500000 0.0442753;
  0.0600000 0.0487571;
  0.0800000 0.0564308;
  0.1000000 0.0629981;
  0.1200000 0.0686204;
  0.1400000 0.0734360;
  0.1600000 0.0775707;
  0.1800000 0.0810687;
  0.2000000 0.0839202;
  0.2200000 0.0861433;
  0.2400000 0.0878308;
  0.2600000 0.0890840;
  0.2800000 0.0900016;
  0.3000000 0.0906804;
  0.3200000 0.0911857;
  0.3400000 0.0915079;
  0.3600000 0.0916266;
  0.3800000 0.0915212;
  0.4000000 0.0911712;
  0.4200000 0.0905657;
  0.4400000 0.0897175;
  0.4600000 0.0886427;
  0.4800000 0.0873572;
  0.5000000 0.0858772;
  0.5200000 0.0842145;
  0.5400000 0.0823712;
  0.5600000 0.0803480;
  0.5800000 0.0781451;
  0.6000000 0.0757633;
  0.6200000 0.0732055;
  0.6400000 0.0704822;
  0.6600000 0.0676046;
  0.6800000 0.0645843;
  0.7000000 0.0614329;
  0.7200000 0.0581599;
  0.7400000 0.0547675;
  0.7600000 0.0512565;
  0.7800000 0.0476281;
  0.8000000 0.0438836;
  0.8200000 0.0400245;
  0.8400000 0.0360536;
  0.8600000 0.0319740;
  0.8800000 0.0277891;
  0.9000000 0.0235025;
  0.9200000 0.0191156;
  0.9400000 0.0146239;
  0.9600000 0.0100232;
  0.9700000 0.0076868;
  0.9800000 0.0053335;
  0.9900000 0.0029690;
  1.0000000 0.000
]

clarkybot = [
  0.0005000 -.0046700;
  0.0010000 -.0059418;
  0.0020000 -.0078113;
  0.0040000 -.0105126;
  0.0080000 -.0142862;
  0.0120000 -.0169733;
  0.0200000 -.0202723;
  0.0300000 -.0226056;
  0.0400000 -.0245211;
  0.0500000 -.0260452;
  0.0600000 -.0271277;
  0.0800000 -.0284595;
  0.1000000 -.0293786;
  0.1200000 -.0299633;
  0.1400000 -.0302404;
  0.1600000 -.0302546;
  0.1800000 -.0300490;
  0.2000000 -.0296656;
  0.2200000 -.0291445;
  0.2400000 -.0285181;
  0.2600000 -.0278164;
  0.2800000 -.0270696;
  0.3000000 -.0263079;
  0.3200000 -.0255565;
  0.3400000 -.0248176;
  0.3600000 -.0240870;
  0.3800000 -.0233606;
  0.4000000 -.0226341;
  0.4200000 -.0219042;
  0.4400000 -.0211708;
  0.4600000 -.0204353;
  0.4800000 -.0196986;
  0.5000000 -.0189619;
  0.5200000 -.0182262;
  0.5400000 -.0174914;
  0.5600000 -.0167572;
  0.5800000 -.0160232;
  0.6000000 -.0152893;
  0.6200000 -.0145551;
  0.6400000 -.0138207;
  0.6600000 -.0130862;
  0.6800000 -.0123515;
  0.7000000 -.0116169;
  0.7200000 -.0108823;
  0.7400000 -.0101478;
  0.7600000 -.0094133;
  0.7800000 -.0086788;
  0.8000000 -.0079443;
  0.8200000 -.0072098;
  0.8400000 -.0064753;
  0.8600000 -.0057408;
  0.8800000 -.0050063;
  0.9000000 -.0042718;
  0.9200000 -.0035373;
  0.9400000 -.0028028;
  0.9600000 -.0020683;
  0.9700000 -.0017011;
  0.9800000 -.0013339;
  0.9900000 -.0009666;
  1.0000000 0
]

rev_clarkytop = zeros(clarkytop)
for i in 1:size(clarkytop)[1]
  rev_clarkytop[i,:] = clarkytop[size(clarkytop)[1]-(i-1), :]
end
airfoilclarky = vcat(rev_clarkytop, clarkybot)


# Airfoils along the blade as
# airfoil_contours=[ (pos1, contour1), (pos2, contour2), ...] with contour=(x,y)
# and pos the position from root to tip between 0 and 1. pos1 must equal 0
# (root airfoil) and the last must be 1 (tip airfoil)
airfoil_contours = [ (0, airfoilclarky, clarky_file),
                      (0.25, airfoilE216, e216_file),
                      (1, airfoilE212, e212_file) ]
