Esempio n. 1
0
        /// <summary>
        /// 粗く定義されるOldのListとPropと同じ間隔のNewのListを引数にしてPropを出力
        /// </summary>
        /// <param name="Old">粗く定義されている断面</param>
        /// <param name="New">n個で定義されている断面Propに代入</param>
        /// <returns>Propのコンストラクタをreturn</returns>
        public void Transration(ref Prop prop, List <WingSection> Old)
        {
            //中間出力用のList<WingSection>,Propの分割数だけ配列作成
            List <WingSection> New = new List <WingSection>();

            for (int i = 0; i < Prop.n; i++)
            {
                New.Add(new WingSection());
            }

            var ZeroLiftAlpha_deg_known = new Dictionary <double, double>();  //ゼロ揚力角[deg]
            var DCl_dAlpha_known        = new Dictionary <double, double>();  //揚力傾斜
            var MaxCl_known             = new Dictionary <double, double>();  //最大Cl
            var MinCl_known             = new Dictionary <double, double>();  //最小Cl
            var MinCd_known             = new Dictionary <double, double>();  //最小Cd
            var ClatMinCd_known         = new Dictionary <double, double>();  //最小Cd時のCl
            var DCd_dCl2_known          = new Dictionary <double, double>();  //二階微分
            var Reref_known             = new Dictionary <double, double>();  //Reの参照部
            var Reexp_known             = new Dictionary <double, double>();  //Reの指数部
            var Cm_known    = new Dictionary <double, double>();              //翼型Cm
            var Mcrit_known = new Dictionary <double, double>();

            var CL_known        = new Dictionary <double, double>();          //CLこれを補間したい。後はオマケ
            var Thickness_known = new Dictionary <double, double>();

            for (int i = 0; i < Old.Count; i++)
            {
                ZeroLiftAlpha_deg_known.Add(Old[i].Position, Old[i].ZeroLiftAlpha_deg);
                DCl_dAlpha_known.Add(Old[i].Position, Old[i].DCl_dAlpha);
                MaxCl_known.Add(Old[i].Position, Old[i].MaxCl);
                MinCl_known.Add(Old[i].Position, Old[i].MinCl);
                MinCd_known.Add(Old[i].Position, Old[i].MinCd);
                ClatMinCd_known.Add(Old[i].Position, Old[i].ClatMinCd);
                DCd_dCl2_known.Add(Old[i].Position, Old[i].DCd_dCl2);
                Reref_known.Add(Old[i].Position, Old[i].Reref);
                Reexp_known.Add(Old[i].Position, Old[i].Reexp);
                Mcrit_known.Add(Old[i].Position, Old[i].Mcrit);

                CL_known.Add(Old[i].Position, Old[i].Cl);
                Thickness_known.Add(Old[i].Position, Old[i].Thickness);
            }
            var ZeroLiftAlpha_deg_scaler = new SplineInterpolator(ZeroLiftAlpha_deg_known);
            var DCl_dAlpha_scaler        = new SplineInterpolator(DCl_dAlpha_known);
            var MaxCl_scaler             = new SplineInterpolator(MaxCl_known);
            var MinCl_scaler             = new SplineInterpolator(MinCl_known);
            var MinCd_scaler             = new SplineInterpolator(MinCd_known);
            var ClatMinCd_scaler         = new SplineInterpolator(ClatMinCd_known);
            var DCd_dCl2_scaler          = new SplineInterpolator(DCd_dCl2_known);
            var Reref_scaler             = new SplineInterpolator(Reref_known);
            var Reexp_scaler             = new SplineInterpolator(Reexp_known);
            var Mcrit_scaler             = new SplineInterpolator(Mcrit_known);

            var CL_scaler        = new SplineInterpolator(CL_known);
            var Thickness_scaler = new SplineInterpolator(Thickness_known);

            double start = MaxCl_known.First().Key;
            double end   = MaxCl_known.Last().Key;
            double step  = (end - start) / prop.n_number;
            int    iter  = 0;

            for (double x = start + 0.00000000001, i = 0; x <= end; x += step, i++)
            {
                iter = (int)i;
                New[iter].Position = (double)iter / (double)(prop.n_number - 1)
                                     * (prop.Radius - prop.Radius_in) + prop.Radius_in;

                //New[iter].ZeroLiftAlpha_deg = ZeroLiftAlpha_deg_scaler.GetValue(x);
                //New[iter].DCl_dAlpha = DCl_dAlpha_scaler.GetValue(x);
                //New[iter].MaxCl = MaxCl_scaler.GetValue(x);
                //New[iter].MinCl = MinCl_scaler.GetValue(x);
                //New[iter].MinCd = MinCd_scaler.GetValue(x);
                //New[iter].ClatMinCd = ClatMinCd_scaler.GetValue(x);
                //New[iter].DCd_dCl2 = DCd_dCl2_scaler.GetValue(x);
                //New[iter].Reref = Reref_scaler.GetValue(x);
                //New[iter].Reexp = Reexp_scaler.GetValue(x);
                //New[iter].Mcrit = Mcrit_scaler.GetValue(x);

                New[iter].ZeroLiftAlpha_deg = ZeroLiftAlpha_deg_scaler.GetLinearValue(x);
                New[iter].DCl_dAlpha        = DCl_dAlpha_scaler.GetLinearValue(x);
                New[iter].MaxCl             = MaxCl_scaler.GetLinearValue(x);
                New[iter].MinCl             = MinCl_scaler.GetLinearValue(x);
                New[iter].MinCd             = MinCd_scaler.GetLinearValue(x);
                New[iter].ClatMinCd         = ClatMinCd_scaler.GetLinearValue(x);
                New[iter].DCd_dCl2          = DCd_dCl2_scaler.GetLinearValue(x);
                New[iter].Reref             = Reref_scaler.GetLinearValue(x);
                New[iter].Reexp             = Reexp_scaler.GetLinearValue(x);
                New[iter].Mcrit             = Mcrit_scaler.GetLinearValue(x);

                New[iter].Cl        = CL_scaler.GetLinearValue(x);
                New[iter].Thickness = Thickness_scaler.GetLinearValue(x);

                prop.CLs[iter]  = New[iter].Cl;
                prop.CDs[iter]  = New[iter].Get_Cd();
                prop.AOAs[iter] = New[iter].Get_Alpha(); //順番が大事。CLの後にAlpha
                //レイノルズ数は未考慮
                prop.thickness[iter] = New[iter].Thickness;
            }
            //return prop;
        }
Esempio n. 2
0
        /// <summary>
        /// PropのCSV出力
        /// # header
        /// Inaprop version
        /// 各種パラメータ
        /// # recorder
        /// 分布にそった値
        /// </summary>
        /// <param name="prop"></param>
        private void exportCSVprop(Prop prop, int partition, double start = 0)
        {
            if (partition < 2 || start < 0 || start > prop.Radius)
            {
                MessageBox.Show("Invalid value", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            // File Open
            string stCurrentDir = System.IO.Directory.GetCurrentDirectory();
            string exportPath   = "/";
            string exportName   = prop.Name;

            System.Text.Encoding enc = System.Text.Encoding.GetEncoding("Shift_JIS");

            // 開く2つ目の引数は上書きか追加か
            System.IO.StreamWriter sr = new System.IO.StreamWriter(stCurrentDir + exportPath + exportName + ".csv", true, enc);

            // Header
            //sr.WriteLine("Inaprop ver." + this.ProductVersion);
            //sr.WriteLine("----");

            sr.WriteLine("Number of blades" + "," + prop.Blade);
            sr.WriteLine("radius(m)" + "," + prop.Radius);
            sr.WriteLine("thrust(N)" + "," + prop.Thrust);
            sr.WriteLine("Power(W)" + "," + prop.Power);
            sr.WriteLine("Efficiency(%)" + "," + prop.Efficiency);
            sr.WriteLine("speed(m/s)" + "," + prop.Uinf);
            sr.WriteLine("rpm" + "," + prop.Rpm);
            sr.WriteLine("hub rad.(m)" + "," + prop.Radius_in);
            sr.WriteLine("air density(kg/m3)" + "," + prop.Rho);
            sr.WriteLine("kinematic viscosity coeff.(kg/m-s)" + "," + prop.Nu);
            sr.WriteLine("design METHOD" + "," + prop.Method);

            sr.WriteLine("====");

            // 出力用変数定義
            double[] radius    = new double[partition];
            double[] chord     = new double[partition];
            double[] phi_deg   = new double[partition];
            double[] gamma     = new double[partition];
            double[] reinolds  = new double[partition];
            double[] Cl        = new double[partition];
            double[] Cd        = new double[partition];
            double[] thickness = new double[partition];

            //partitionが分割数、divisionが何個の分割の山があるか
            int division = partition - 1;


            //prop.Rがn+1の配列を持っているので他のと合わせる必要がある
            double[] radius_prop = new double[Prop.n];
            for (int i = 0; i < Prop.n; i++)
            {
                radius_prop[i] = prop.R[i];
            }
            //補間
            if (partition == Prop.n)
            {
                radius    = radius_prop; //参照コピー、値をコピーならprop.R.CopyTo(radius);
                chord     = prop.ci;
                phi_deg   = prop.phi;
                gamma     = prop.gamma;
                reinolds  = prop.Re;
                Cl        = prop.CLs;
                Cd        = prop.CDs;
                thickness = prop.thickness;
            }
            else
            {
                radius = Spline_Interpolate(radius_prop, radius_prop, partition, start);
                //radius = Spline_Interpolate(prop.R, prop.R, partition, start);
                chord     = Spline_Interpolate(radius_prop, prop.ci, partition, start);
                phi_deg   = Spline_Interpolate(radius_prop, prop.phi, partition, start);
                gamma     = Spline_Interpolate(radius_prop, prop.gamma, partition, start);
                reinolds  = Spline_Interpolate(radius_prop, prop.Re, partition, start);
                Cl        = Spline_Interpolate(radius_prop, prop.CLs, partition, start);
                Cd        = Spline_Interpolate(radius_prop, prop.CDs, partition, start);
                thickness = Spline_Interpolate(radius_prop, prop.thickness, partition, start);
            }

            // レコード
            string[] parameterName = { "Position(m)", "chord(m)", "phi(deg)", "gamma", "Re", "CL", "CD", "Thickness" };
            string   s             = string.Join(",", parameterName);

            sr.WriteLine(s);

            for (int i = 0; i < partition; i++)
            {
                string[] s1 = { radius[i].ToString("F3"), chord[i].ToString("F3"),    phi_deg[i].ToString("F2"),
                                gamma[i].ToString("F3"),  reinolds[i].ToString("F1"),
                                Cl[i].ToString("F2"),     Cd[i].ToString("F2"),
                                (thickness[i] * chord[i]).ToString("F3") };
                string   s2 = string.Join(",", s1);
                sr.WriteLine(s2);
            }


            //フィイルクローズ
            sr.Close();
        }