Example #1
0
        static Plural Atheta(string uan, double power, Point originPoint, Point targetPoint)
        {
            //List<string> thetaGain = new List<string>();  //这四个数组的值以后从uan格式的天线文件中获取
            //List<string> phiGain = new List<string>();
            //List<string> thetaPhase = new List<string>();
            //List<string> phiPhase = new List<string>();
            //          ReadUan.GetGainPara(uan);
            Plural Atheta = new Plural();

            if (ReadUan.thetaGain.Count < 10)
            {
                return(Atheta);

                throw new Exception("Could not get the value of Antenna thetaGain!");
            }
            else
            {
                try
                {
                    int    row   = (ReadUan.GetPhiAngle(originPoint, targetPoint)) * 181 + ReadUan.GetThetaAngle(originPoint, targetPoint);
                    double A     = Math.Sqrt(60 * power * Math.Abs(Math.Pow(10, Convert.ToDouble(ReadUan.thetaGain[row]) / 10)));
                    Plural theta = new Plural(Math.Cos(Math.PI / 180 * Convert.ToDouble(ReadUan.thetaPhase[row])),
                                              Math.Sin(Math.PI / 180 * Convert.ToDouble(ReadUan.thetaPhase[row])));
                    Atheta = Plural.PluralMultiplyDouble(theta, A);
                    //Console.WriteLine("theta="+ReadUan .GetThetaAngle (originPoint ,targetPoint )+" phi="+ReadUan .GetPhiAngle (originPoint ,targetPoint ));
                }
                catch (Exception e)
                {
                    throw new Exception(e.Message);
                }
                return(Atheta);
            }
        }
Example #2
0
        //求得电场的xyz方向的量
        public static EField EfieldCal(string uan, double power1, double frequency, Point originPoint, Point targetPoint, Point rotateAngle = null)
        {
            double power = power1;     //传入的power1单位是dBm,转换为单位为瓦的power
            //      ReadUan.GetGainPara(uan);
            Plural Etheta = DirectEThetaCal(uan, power, frequency, originPoint, targetPoint, rotateAngle);
            Plural Ephi   = DirectEPhiCal(uan, power, frequency, originPoint, targetPoint, rotateAngle);
            //        double The = ReadUan.GetThetaAngle(originPoint, targetPoint) * Math.PI / 180.0;
            //        double Ph = ReadUan.GetPhiAngle(originPoint, targetPoint) * Math.PI / 180.0;
            EField e          = new EField();
            double thetaAngle = Convert.ToInt32(ReadUan.GetThetaAngle(originPoint, targetPoint));
            double phiAngle   = Convert.ToInt32(ReadUan.GetPhiAngle(originPoint, targetPoint));
            double Xtheta     = Math.Cos(thetaAngle * Math.PI / 180.0) * Math.Cos(phiAngle / 180 * Math.PI);
            double Xphi       = Math.Sin(ReadUan.GetPhiAngle(originPoint, targetPoint) * Math.PI / 180.0);
            double Ytheta     = Math.Cos(thetaAngle * Math.PI / 180.0) * Math.Sin(phiAngle / 180 * Math.PI);
            double Yphi       = Math.Cos(phiAngle * Math.PI / 180.0);
            double Ztheta     = Math.Sin(thetaAngle * Math.PI / 180.0);
            double Zphi       = 0;

            e.X = Plural.PluralMultiplyDouble(Etheta, Xtheta) - Plural.PluralMultiplyDouble(Ephi, Xphi);
            e.Y = Plural.PluralMultiplyDouble(Etheta, Ytheta) + Plural.PluralMultiplyDouble(Ephi, Yphi);
            e.Z = Plural.PluralMultiplyDouble(Ephi, Zphi) - Plural.PluralMultiplyDouble(Etheta, Ztheta);
            //string pathtest = "D:\\renwu\\"+DateTime.Today.ToString("yy/MM/dd")+".txt";
            //File.WriteAllText(pathtest, e.X.Re + "  " + e.X.Im + "|  " + e.Y.Re + "  " + e.Y.Im + "|  " + e.Z.Re + "  " + e.Z.Im);
            //需添加计算方法
            return(e);
        }
Example #3
0
 /// <summary>
 /// 计算路径的损耗,延时,相位
 /// </summary>
 private void GetLossAndComponentOFPath(Path midpath)
 {
     midpath.pathloss = 10 * Math.Log10(midpath.node[0].Power / midpath.node[midpath.node.Count - 1].Power);
     midpath.Delay    = midpath.GetPathLength() / 300000000;
     midpath.thetaa   = ReadUan.GetThetaAngle(midpath.node[0].Position, midpath.node[1].Position);
     midpath.thetab   = ReadUan.GetThetaAngle(midpath.node[midpath.node.Count - 2].Position, midpath.node[midpath.node.Count - 1].Position);
     midpath.phia     = ReadUan.GetPhiAngle(midpath.node[0].Position, midpath.node[1].Position);
     midpath.phib     = ReadUan.GetPhiAngle(midpath.node[midpath.node.Count - 2].Position, midpath.node[midpath.node.Count - 1].Position);
 }
Example #4
0
        public static EField EfieldCalSingle(string uan, double power1, double frequency, Point originPoint, Point targetPoint, Point rotateAngle = null)
        {
            double power = Math.Pow(10, (power1 - 30) / 10);     //传入的power1单位是dBm,转换为单位为瓦的power
//            ReadUan.GetGainPara(uan);

            Plural Etheta = DirectEThetaCal(uan, power, frequency, originPoint, targetPoint, rotateAngle);
            Plural Ephi   = DirectEPhiCal(uan, power, frequency, originPoint, targetPoint, rotateAngle);
            //double The = ReadUan.GetThetaAngle(originPoint, targetPoint) * Math.PI / 180.0;
            // double Ph = ReadUan.GetPhiAngle(originPoint, targetPoint) * Math.PI / 180.0;
            EField e      = new EField();
            int    Xtheta = Convert.ToInt32(Math.Cos(ReadUan.GetThetaAngle(originPoint, targetPoint) * Math.PI / 180.0) * Math.Cos(ReadUan.GetPhiAngle(originPoint, targetPoint) / 180 * Math.PI));
            double Xphi   = Convert.ToInt32(Math.Sin(ReadUan.GetPhiAngle(originPoint, targetPoint) * Math.PI / 180.0));
            double Ytheta = Convert.ToInt32(Math.Cos(ReadUan.GetThetaAngle(originPoint, targetPoint) * Math.PI / 180.0) * Math.Sin(ReadUan.GetPhiAngle(originPoint, targetPoint) / 180 * Math.PI));
            double Yphi   = Convert.ToInt32(Math.Cos(ReadUan.GetPhiAngle(originPoint, targetPoint) * Math.PI / 180.0));
            double Ztheta = Convert.ToInt32(Math.Sin(ReadUan.GetThetaAngle(originPoint, targetPoint) * Math.PI / 180.0));
            double Zphi   = 0;

            e.X = Plural.PluralMultiplyDouble(Etheta, Xtheta) - Plural.PluralMultiplyDouble(Ephi, Xphi);
            e.Y = Plural.PluralMultiplyDouble(Etheta, Ytheta) + Plural.PluralMultiplyDouble(Ephi, Yphi);
            e.Z = Plural.PluralMultiplyDouble(Ephi, Zphi) - Plural.PluralMultiplyDouble(Etheta, Ztheta);
            //需添加计算方法
            return(e);
        }
Example #5
0
        /// <summary>
        /// 计算每条路径的功率(王楠)
        /// </summary>
        /// <param name="Rx_uan">接收机UAN文件</param>
        /// <param name="finalNode">最后一个节点</param>
        /// <param name="parentNode">倒数第二个节点</param>
        /// <returns></returns>
        static public double[] GetPower(Node finalNode, Node parentNode)
        {
            //先计算前面的系数temp1
            double lamada = 300 / finalNode.Frequence;
            double temp1  = (Math.Pow(lamada, 2) * GetBeta(finalNode, parentNode)) / (8 * Math.PI * 377); //377是真空中的本征阻抗
            //在计算后面的模的平方
            EField totalE         = finalNode.TotalE;                                                     //获得接收点场强
            Point  finalPosition  = finalNode.Position;                                                   //获得接收点的位置
            Point  parentPosition = parentNode.Position;                                                  //上一节点的位置
            //用两点的位置信息确定天线的theta和phi方向的增益和相位。
            double ThetaAngle  = ReadUan.GetThetaAngle(parentPosition, finalPosition);                    //获得射线的theta角thetaAngle
            double phiAngle    = ReadUan.GetPhiAngle(parentPosition, finalPosition);                      //获得射线的phi角phiAngle
            int    index       = Convert.ToInt32(Math.Floor(phiAngle * 181 + ThetaAngle));                //将相应的index对应到读取UAN所形成的数组中
            double thetagain1  = Convert.ToDouble(ReadUan.thetaGain[index]);                              //天线theta方向上的增益
            double phigain1    = Convert.ToDouble(ReadUan.phiGain[index]);                                //天线phi方向上的增益
            double thetaPhase1 = Convert.ToDouble(ReadUan.thetaPhase[index]);                             //天线theta方向上的相位
            double phiPhase1   = Convert.ToDouble(ReadUan.phiPhase[index]);                               //天线phi方向上的相位
                                                                                                          //求theta方向的场强
            Plural Etheta = new Plural(totalE.X.Re * Math.Cos(ThetaAngle) * Math.Cos(phiAngle) + totalE.Y.Re * Math.Cos(ThetaAngle) * Math.Sin(phiAngle) - totalE.Z.Re * Math.Sin(ThetaAngle), totalE.X.Im * Math.Cos(ThetaAngle) * Math.Cos(phiAngle) + totalE.Y.Im * Math.Cos(ThetaAngle) * Math.Sin(phiAngle) - totalE.Z.Im * Math.Sin(ThetaAngle));
            //求phi方向的场强
            Plural Ephi = new Plural(totalE.X.Re * Math.Sin(phiAngle) * (-1) + totalE.Y.Re * Math.Cos(phiAngle), totalE.X.Im * Math.Sin(phiAngle) * (-1) + totalE.Y.Im * Math.Cos(phiAngle));

            //求g在theta和phi方向的向量
            Plural thetaGainPlural = new Plural(Math.Sqrt(Math.Pow(10, thetagain1 / 10.0)) * Math.Cos(thetaPhase1), Math.Sqrt(Math.Pow(10, thetagain1 / 10.0)) * Math.Sin(thetaPhase1));
            Plural phiGainPlural   = new Plural(Math.Sqrt(Math.Pow(10, phigain1 / 10.0)) * Math.Cos(phiPhase1), Math.Sqrt(Math.Pow(10, phigain1 / 10.0)) * Math.Sin(phiPhase1));
            //求得模的平方temp2
            Plural temp2 = (Etheta * thetaGainPlural + Ephi * phiGainPlural);
            double temp3 = Math.Pow((temp2.GetMag()), 2);
            double phase = 0;

            if (temp2.Re == 0)
            {
                if (temp2.Im >= 0)
                {
                    phase = 90;
                }
                else
                {
                    phase = -90;
                }
            }
            if (temp2.Im >= 0 && temp2.Re > 0)
            {
                phase = Math.Atan(temp2.Im / temp2.Re) * 180.0 / Math.PI;
            }
            if (temp2.Im <= 0 && temp2.Re > 0)
            {
                phase = Math.Atan(temp2.Im / temp2.Re) * 180.0 / Math.PI;
            }
            if (temp2.Im >= 0 && temp2.Re < 0)
            {
                phase = Math.Atan(temp2.Im / temp2.Re) * 180.0 / Math.PI + 180;
            }
            if (temp2.Im <= 0 && temp2.Re < 0)
            {
                phase = Math.Atan(temp2.Im / temp2.Re) * 180.0 / Math.PI - 180;
            }

            double[] powerAndPhase = new double[2];
            powerAndPhase[0] = temp1 * temp3;
            powerAndPhase[1] = phase;
            return(powerAndPhase);
        }
Example #6
0
        static public double[] GetTotalPowerInDifferentPhase(List <Path> areaPaths)
        {
            //在计算后面的模的平方
            Plural temp2 = new Plural(0, 0);

            double[] frequence = new double[areaPaths.Count];
            int      i         = 0;

            foreach (Path item in areaPaths)
            {
                frequence[i] = item.node[item.node.Count - 1].Frequence;
                i++;

                EField totalE         = item.node[item.node.Count - 1].TotalE;//获得最后一个节点rx的场强
                Point  finalPosition  = item.node[item.node.Count - 1].Position;
                Point  parentPosition = item.node[item.node.Count - 2].Position;
                double ThetaAngle     = ReadUan.GetThetaAngle(parentPosition, finalPosition);     //获得射线的theta角thetaAngle
                double phiAngle       = ReadUan.GetPhiAngle(parentPosition, finalPosition);       //获得射线的phi角phiAngle
                int    index          = Convert.ToInt32(Math.Floor(phiAngle * 181 + ThetaAngle)); //将相应的index对应到读取UAN所形成的数组中
                double thetagain1     = Convert.ToDouble(ReadUan.thetaGain[index]);               //天线theta方向上的增益
                double phigain1       = Convert.ToDouble(ReadUan.phiGain[index]);                 //天线phi方向上的增益
                double thetaPhase1    = Convert.ToDouble(ReadUan.thetaPhase[index]);              //天线theta方向上的相位
                double phiPhase1      = Convert.ToDouble(ReadUan.phiPhase[index]);                //天线phi方向上的相位
                //求theta方向的场强
                Plural Etheta = new Plural(totalE.X.Re * Math.Cos(Math.PI * ThetaAngle / 180.0) * Math.Cos(Math.PI * phiAngle / 180.0) + totalE.Y.Re * Math.Cos(Math.PI * ThetaAngle / 180.0) * Math.Sin(Math.PI * phiAngle / 180.0) - totalE.Z.Re * Math.Sin(Math.PI * ThetaAngle / 180.0), totalE.X.Im * Math.Cos(Math.PI * ThetaAngle / 180.0) * Math.Cos(Math.PI * phiAngle / 180.0) + totalE.Y.Im * Math.Cos(Math.PI * ThetaAngle / 180.0) * Math.Sin(Math.PI * phiAngle / 180.0) - totalE.Z.Im * Math.Sin(Math.PI * ThetaAngle / 180.0));
                //求phi方向的场强
                Plural Ephi = new Plural(totalE.X.Re * Math.Sin(phiAngle * Math.PI / 180.0) * (-1) + totalE.Y.Re * Math.Cos(phiAngle * Math.PI / 180.0), totalE.X.Im * Math.Sin(phiAngle * Math.PI / 180.0) * (-1) + totalE.Y.Im * Math.Cos(Math.PI * phiAngle / 180.0));

                //求g在theta和phi方向的向量
                Plural thetaGainPlural = new Plural((Math.Pow(10, thetagain1 / 20.0)) * Math.Cos(thetaPhase1 * Math.PI / 180.0), (Math.Pow(10, thetagain1 / 20.0)) * Math.Sin(thetaPhase1 * Math.PI / 180.0));
                Plural phiGainPlural   = new Plural((Math.Pow(10, phigain1 / 20.0)) * Math.Cos(phiPhase1 * Math.PI / 180.0), (Math.Pow(10, phigain1 / 20.0)) * Math.Sin(phiPhase1 * Math.PI / 180.0));
                //求得模的平方temp2
                //Plural mul1 = Etheta * thetaGainPlural;
                //Plural mul2 = Ephi * phiGainPlural;
                temp2 += (Etheta * thetaGainPlural + Ephi * phiGainPlural);
            }
            Array.Sort(frequence);

            //先计算前面的系数temp1
            double lamada = 300 / frequence[(int)(frequence.Length / 2)];
            double temp1  = (Math.Pow(lamada, 2)) / (8 * Math.PI * 377);//377是真空中的本征阻抗
            double temp3  = Math.Pow((temp2.GetMag()), 2);
            double phase  = 0;

            if (temp2.Re == 0)
            {
                if (temp2.Im >= 0)
                {
                    phase = 90;
                }
                else
                {
                    phase = -90;
                }
            }
            if (temp2.Im >= 0 && temp2.Re > 0)
            {
                phase = Math.Atan(temp2.Im / temp2.Re) * 180.0 / Math.PI;
            }
            if (temp2.Im <= 0 && temp2.Re > 0)
            {
                phase = Math.Atan(temp2.Im / temp2.Re) * 180.0 / Math.PI;
            }
            if (temp2.Im >= 0 && temp2.Re < 0)
            {
                phase = Math.Atan(temp2.Im / temp2.Re) * 180.0 / Math.PI + 180;
            }
            if (temp2.Im <= 0 && temp2.Re < 0)
            {
                phase = Math.Atan(temp2.Im / temp2.Re) * 180.0 / Math.PI - 180;
            }

            double[] powerAndPhase = new double[2];
            powerAndPhase[0] = temp1 * temp3;
            powerAndPhase[1] = phase;
            return(powerAndPhase);
        }
Example #7
0
        private static void OutEveryRxPath(List <CalculateModelClasses.Path> paths, string Rxname, int Rxnum)//接收机的名字,加到path里面,Rxnum接收机的个数
        {
            int           N           = paths.Count;
            int           index       = 0;
            List <string> strListTemp = new List <string>();

            //StringBuilder sbtemp = new StringBuilder();
            sb.AppendLine("# Receiver Set:" + Rxname);
            sb.AppendLine("     " + Rxnum);//Rxnum是这一组有多少个接收机
            for (int i = 1; i <= Rxnum; i++)
            {
                sb.AppendLine("     " + i + "     " + "N");
                sb.Replace("N", N.ToString());
                if (paths.Count != 0)
                {
                    //string powertemp = ((10 * Math.Log10(Math.Sqrt(Math.Pow(P2mFileOutput.GetTolPower(paths), 2) ))) + 30).ToString("f2");
                    string powertemp = ((10 * Math.Log10(Math.Sqrt(Math.Pow(Power.GetTotalPowerInDifferentPhase(paths)[0], 2)))) + 30).ToString("f2");
                    //string powertemp = (10*Math.Log10(Math.Sqrt(Math.Pow(P2mFileOutput.GetTolPower(paths).Re, 2) + Math.Pow(P2mFileOutput.GetTolPower(paths).Im, 2)))).ToString("f2");
                    sb.AppendLine(powertemp + "   " + P2mFileOutput.GetTolTime(paths).ToString("0.#####E+00") + "  " + P2mFileOutput.GetTolDelay(paths).ToString("0.#####E+00"));
                    for (int j = 0; j < paths.Count; j++)
                    {
                        double distance = 0;
                        string theta_a  = ReadUan.GetThetaAngle(paths[j].node[0].Position, paths[j].node[1].Position).ToString("f4");
                        string phi_a    = ReadUan.GetPhiAngle(paths[j].node[0].Position, paths[j].node[1].Position).ToString("f4");
                        string theta_d  = ReadUan.GetThetaAngle(paths[j].node[paths[j].node.Count - 2].Position, paths[j].node[paths[j].node.Count - 1].Position).ToString("f4");
                        string phi_d    = ReadUan.GetPhiAngle(paths[j].node[paths[j].node.Count - 2].Position, paths[j].node[paths[j].node.Count - 1].Position).ToString("f4");

                        for (int k = 0; k < paths[j].node.Count - 1; k++)
                        {
                            distance += paths[j].node[k].Position.GetDistance(paths[j].node[k + 1].Position);
                        }

                        //string temp2 = Math.Sqrt(Math.Pow(paths[j].node[paths[j].node.Count - 1].power.Re, 2) + Math.Pow(paths[j].node[paths[j].node.Count - 1].power.Im, 2)).ToString("f4");
                        string temp2    = ((10 * Math.Log10(Math.Sqrt(Math.Pow(paths[j].node[paths[j].node.Count - 1].Power, 2)))) + 30).ToString("f4");
                        string weishuju = Math.Sqrt(Math.Pow(paths[j].node[paths[j].node.Count - 1].TotalE.Z.Re, 2) + Math.Pow(paths[j].node[paths[j].node.Count - 1].TotalE.Z.Im, 2)).ToString("f4");
                        sbtemp.AppendLine("    " + ("M") + "   " + (paths[j].node.Count - 2).ToString() + "     " + temp2 + "   " + (30 / distance).ToString("0.#####E+00") + "    " + theta_a + "   " + phi_a + "   " + theta_d + "   " + phi_d + "   " + weishuju);//达到时间需要计算,另外四个角度需要计算"(theta,phia,thetd,phid")
                        if (paths[j].node.Count == 2)
                        {
                            //if (paths[j].node[1].PointStyle.Equals("FinalPoint"))
                            //{
                            //    continue;
                            //}
                            //else
                            //{
                            //    Direct(paths[j]);
                            //    string[] temp = sbtemp.ToString().Split('|');
                            //    //检验是否重复
                            //    check(temp, strListTemp);
                            //    //清空临时字符串
                            //    sbtemp.Clear();
                            //}
                            Direct(paths[j]);
                            index++;
                            sb.Append(sbtemp.ToString().Replace("M", index.ToString()));
                            sbtemp.Clear();
                        }
                        else
                        {
                            NotDirect(paths[j]);
                            index++;
                            //string[] temp = sbtemp.ToString().Split('|');
                            //check(temp, strListTemp);
                            ////清空临时字符串
                            sb.Append(sbtemp.ToString().Replace("M", index.ToString()));
                            sbtemp.Clear();
                        }
                    }
                }
            }
        }