Пример #1
0
            /// <summary>
            /// Most explicit constructor.
            /// </summary>
            /// <param name="power_In_db">Sound Power of the source</param>
            /// <param name="Source">Origin of the source</param>
            /// <param name="TotalRays_in">Number of rays </param>
            /// <param name="Broadband_Time"></param>
            /// <param name="ID">The identifier of the source</param>
            public Source(double[] power_In_db, Point Source, Phase_Regime p, int ID)
            {
                ph       = p;
                S_ID     = ID;
                H_Center = new Hare.Geometry.Point(Source.x, Source.y, Source.z);
                Center   = Source;

                SPL[0] = power_In_db[0];
                SPL[1] = power_In_db[1];
                SPL[2] = power_In_db[2];
                SPL[3] = power_In_db[3];
                SPL[4] = power_In_db[4];
                SPL[5] = power_In_db[5];
                SPL[6] = power_In_db[6];
                SPL[7] = power_In_db[7];

                phase = new double[8];

                SourcePower[0] = 1E-12 * Math.Pow(10, .1 * SPL[0]);
                SourcePower[1] = 1E-12 * Math.Pow(10, .1 * SPL[1]);
                SourcePower[2] = 1E-12 * Math.Pow(10, .1 * SPL[2]);
                SourcePower[3] = 1E-12 * Math.Pow(10, .1 * SPL[3]);
                SourcePower[4] = 1E-12 * Math.Pow(10, .1 * SPL[4]);
                SourcePower[5] = 1E-12 * Math.Pow(10, .1 * SPL[5]);
                SourcePower[6] = 1E-12 * Math.Pow(10, .1 * SPL[6]);
                SourcePower[7] = 1E-12 * Math.Pow(10, .1 * SPL[7]);
            }
            public LineSource(Curve SrcPath, String Code, int el_m, int SrcID, Phase_Regime ph)
                : base(new double[8] {
                60, 49, 41, 35, 31, 28, 26, 24
            }, new Point3d(0, 0, 0), ph, SrcID)
            {
                string type = SrcPath.GetUserString("SourceType");

                if (type == "Aircraft (ANCON derived)")
                {
                    double velocity = double.Parse(SrcPath.GetUserString("Velocity"));
                    double delta    = double.Parse(SrcPath.GetUserString("delta"));
                    D = new ANCON(delta, velocity);
                }
                else
                {
                    D = new Simple();
                }

                samplespermeter = el_m;
                Curve           = SrcPath;

                //Divide curve up in ~equal length segments.
                Samples = Curve.DivideEquidistant(1.0 / (double)samplespermeter);

                Level = Utilities.PachTools.DecodeSourcePower(Code);
                Power = new double[8];

                double PowerMod = Curve.GetLength() / (double)Samples.Length;

                for (int oct = 0; oct < 8; oct++)
                {
                    Power[oct] = 1E-12 * Math.Pow(10, .1 * Level[oct]) * PowerMod;
                }
            }
            /// <summary>
            /// Most explicit constructor.
            /// </summary>
            /// <param name="power_In_db">Sound Power of the source</param>
            /// <param name="Source">Origin of the source</param>
            /// <param name="TotalRays_in">Number of rays </param>
            /// <param name="Broadband_Time"></param>
            /// <param name="ID">The identifier of the source</param>
            public Source(double[] power_In_db, Point3d Source, Phase_Regime p, int ID)
            {
                ph = p;
                S_ID = ID;
                H_Center = new Hare.Geometry.Point(Source.X, Source.Y, Source.Z);
                Center = Source;                

                SPL[0] = power_In_db[0];
                SPL[1] = power_In_db[1];
                SPL[2] = power_In_db[2];
                SPL[3] = power_In_db[3];
                SPL[4] = power_In_db[4];
                SPL[5] = power_In_db[5];
                SPL[6] = power_In_db[6];
                SPL[7] = power_In_db[7];

                phase = new double[8];

                SourcePower[0] = 1E-12 * Math.Pow(10, .1 * SPL[0]);
                SourcePower[1] = 1E-12 * Math.Pow(10, .1 * SPL[1]);
                SourcePower[2] = 1E-12 * Math.Pow(10, .1 * SPL[2]);
                SourcePower[3] = 1E-12 * Math.Pow(10, .1 * SPL[3]);
                SourcePower[4] = 1E-12 * Math.Pow(10, .1 * SPL[4]);
                SourcePower[5] = 1E-12 * Math.Pow(10, .1 * SPL[5]);
                SourcePower[6] = 1E-12 * Math.Pow(10, .1 * SPL[6]);
                SourcePower[7] = 1E-12 * Math.Pow(10, .1 * SPL[7]);
            }
            public LineSource(Curve SrcPath, String Code, int el_m, int SrcID, Phase_Regime ph)
                :base(new double[8]{60, 49, 41, 35, 31, 28, 26, 24}, new Point3d(0,0,0), ph, SrcID)
            {
                string type = SrcPath.GetUserString("SourceType");
                
                if (type == "Aircraft (ANCON derived)")
                {
                    double velocity = double.Parse(SrcPath.GetUserString("Velocity"));
                    double delta = double.Parse(SrcPath.GetUserString("delta"));
                    D = new ANCON(delta, velocity);
                }
                else D = new Simple();

                samplespermeter = el_m;
                Curve = SrcPath;

                //Divide curve up in ~equal length segments.
                Samples = Curve.DivideEquidistant(1.0 / (double)samplespermeter);

                Level = Utilities.PachTools.DecodeSourcePower(Code);
                Power = new double[8];
            
                double PowerMod = Curve.GetLength() / (double)Samples.Length;
                for (int oct = 0; oct < 8; oct++) Power[oct] = 1E-12 * Math.Pow(10, .1 * Level[oct]) * PowerMod;
            }
Пример #5
0
            public GeodesicSource(double[] power_in_db, Point Source, Phase_Regime ph, int ID)
                : base(power_in_db, Source, ph, ID)
            {
                Random RAND = new Random();

                type = "Geodesic";
                GeoSphere(3);
            }
Пример #6
0
 public RandomSource(double[] power_in_db, Point Source, Phase_Regime ph, int ID)
     : base(power_in_db, Source, ph, ID)
 {
     type = "PseudoRandom";
 }
Пример #7
0
            public SurfaceSource(IEnumerable <Brep> Surfaces, List <String> CodeList, int el_m, int SrcID, Phase_Regime ph)
                : base(new double[8] {
                0, 0, 0, 0, 0, 0, 0, 0
            }, new Point3d(0, 0, 0), ph, SrcID)
            {
                samplespermeter = el_m;

                Srfs    = Surfaces.ToList <Brep>();
                Samples = new Point3d[Srfs.Count][];

                MeshingParameters mp = new MeshingParameters();

                mp.MaximumEdgeLength = 1.0 / (double)samplespermeter;
                mp.MinimumEdgeLength = 1.0 / (double)samplespermeter;

                Sub_A      = new double[Srfs.Count];
                SubDomains = new double[Srfs.Count][];
                T          = new Topology[Srfs.Count];

                //for(int i = 0; i < Curves.Count; i++)
                System.Threading.Tasks.Parallel.For(0, Srfs.Count, ips =>
                {
                    int i = (int)ips;


                    //Divide each curve up in ~equal length segments.
                    Mesh[] m        = Mesh.CreateFromBrep(Srfs[i], mp);
                    BoundingBox Box = m[0].GetBoundingBox(true);
                    for (int j = 1; j < m.Length; j++)
                    {
                        Box.Union(m[j].GetBoundingBox(true));
                    }
                    T[i] = new Topology(Utilities.PachTools.RPttoHPt(Box.Min), Utilities.PachTools.RPttoHPt(Box.Max));

                    List <Point3d> pts = new List <Point3d>();
                    SubDomains[i]      = new double[m[i].Faces.Count + 1];
                    for (int j = 0; j < m[i].Faces.Count; j++)
                    {
                        double u, v;
                        ComponentIndex ci;
                        Point3d no;
                        Vector3d V;
                        Point3d A = m[i].Vertices[m[i].Faces[j].A];
                        Srfs[i].ClosestPoint(A, out no, out ci, out u, out v, 1, out V);
                        A        += V;
                        Point3d B = m[i].Vertices[m[i].Faces[j].B];
                        Srfs[i].ClosestPoint(B, out no, out ci, out u, out v, 1, out V);
                        B        += V;
                        Point3d C = m[i].Vertices[m[i].Faces[j].C];
                        Srfs[i].ClosestPoint(C, out no, out ci, out u, out v, 1, out V);
                        C        += V;
                        Point3d D = m[i].Vertices[m[i].Faces[j].D];
                        Srfs[i].ClosestPoint(D, out no, out ci, out u, out v, 1, out V);
                        D += V;

                        if (m[i].Faces[j].IsQuad)
                        {
                            Hare.Geometry.Point[] poly = new Hare.Geometry.Point[4];
                            poly[0] = new Hare.Geometry.Point(A.X, A.Y, A.Z);
                            poly[1] = new Hare.Geometry.Point(B.X, B.Y, B.Z);
                            poly[2] = new Hare.Geometry.Point(C.X, C.Y, C.Z);
                            poly[3] = new Hare.Geometry.Point(D.X, D.Y, D.Z);
                            T[i].Add_Polygon(poly);
                        }
                        else
                        {
                            Hare.Geometry.Point[] poly = new Hare.Geometry.Point[3];
                            poly[0] = new Hare.Geometry.Point(A.X, A.Y, A.Z);
                            poly[1] = new Hare.Geometry.Point(B.X, B.Y, B.Z);
                            poly[2] = new Hare.Geometry.Point(C.X, C.Y, C.Z);
                            T[i].Add_Polygon(poly);
                        }

                        pts.Add(m[i].Faces[j].IsQuad ? new Point3d(A.X + B.X + C.X + D.X, A.Y + B.Y + C.Y + D.Y, A.Z + B.Z + C.Z + D.Z) / 4 : new Point3d(A.X + B.X + C.X, A.Y + B.Y + C.Y, A.Z + B.Z + C.Z) / 3);

                        SubDomains[i][j + 1] = Sub_A[i] += T[i].Polygon_Area(j);
                    }
                    Samples[i] = pts.ToArray();
                });

                Domains     = new double[Srfs.Count + 1];
                DomainLevel = new double[Srfs.Count][];
                DomainPower = new double[Srfs.Count][];
                Total_A     = 0;

                for (int i = 0; i < Srfs.Count; i++)
                {
                    for (int j = 0; j < SubDomains[i].Length; j++)
                    {
                        SubDomains[i][j] /= Sub_A[i];
                    }
                    double A = Srfs[i].GetArea();
                    Domains[i + 1] = Total_A += A;
                    DomainLevel[i] = Utilities.PachTools.DecodeSourcePower(CodeList[i]);
                    DomainPower[i] = new double[8];
                    double PowerMod = A;
                    for (int oct = 0; oct < 8; oct++)
                    {
                        DomainPower[i][oct] = 1E-12 * Math.Pow(10, .1 * DomainLevel[i][oct]) / PowerMod;
                    }
                }

                for (int i = 0; i < Domains.Length; i++)
                {
                    Domains[i] /= Total_A;
                }
            }
                public override BroadRay Directions(int index, int thread, ref Random random, ref Curve Curves, ref double[] DomainPower, ref double Delay, ref Phase_Regime ph, ref int S_ID)
                {
                    double pos = random.NextDouble();
                    //int i;

                    Interval t    = Curves.Domain;
                    double   x    = random.NextDouble() * (t[1] - t[0]) + t[0];
                    Point3d  P    = Curves.PointAt(x);
                    Vector3d f    = Curves.TangentAt(x);
                    Vector   fore = new Hare.Geometry.Vector(f.X, f.Y, f.Z);

                    double Theta     = random.NextDouble() * 2 * System.Math.PI;
                    double Phi       = random.NextDouble() * 2 * System.Math.PI;
                    Vector Direction = new Hare.Geometry.Vector(Math.Sin(Theta) * Math.Cos(Phi), Math.Sin(Theta) * Math.Sin(Phi), Math.Cos(Theta));

                    double cosphi = Hare.Geometry.Hare_math.Dot(Direction, fore);
                    double sinphi = Math.Sqrt(1 - cosphi * cosphi);
                    double tanphi = sinphi / cosphi;
                    double F_r    = sinphi * sinphi * Math.Pow((tanphi * tanphi + 1) / (tanphi * tanphi + (1 + tanphi * Math.Tan(delta))), 1.5);

                    double[] power = new double[8];
                    for (int oct = 0; oct < 8; oct++)
                    {
                        power[oct] = DomainPower[oct] * reciprocal_velocity * dLinf * F_r;
                    }
                    double[] phase = new double[8];
                    if (ph == Phase_Regime.Random)
                    {
                        for (int o = 0; o < 8; o++)
                        {
                            phase[o] = random.Next() * 2 * Math.PI;
                        }
                    }
                    else
                    {
                        for (int o = 0; o < 8; o++)
                        {
                            phase[o] = 0 - Delay * Utilities.Numerics.angularFrequency[o];
                        }
                    }

                    return(new BroadRay(Utilities.PachTools.RPttoHPt(P), Direction, random.Next(), thread, DomainPower, phase, Delay, S_ID));
                }
                public override BroadRay Directions(int index, int thread, ref Random random, ref Curve Curves, ref double[] DomainPower, ref double Delay, ref Phase_Regime ph, ref int S_ID)
                {
                    double pos = random.NextDouble();

                    Interval t = Curves.Domain;
                    double   x = random.NextDouble() * (t[1] - t[0]) + t[0];
                    Point3d  P = Curves.PointAt(x);

                    double Theta     = random.NextDouble() * 2 * System.Math.PI;
                    double Phi       = random.NextDouble() * 2 * System.Math.PI;
                    Vector Direction = new Hare.Geometry.Vector(Math.Sin(Theta) * Math.Cos(Phi), Math.Sin(Theta) * Math.Sin(Phi), Math.Cos(Theta));

                    double[] phase = new double[8];
                    if (ph == Phase_Regime.Random)
                    {
                        for (int o = 0; o < 8; o++)
                        {
                            phase[o] = random.Next() * 2 * Math.PI;
                        }
                    }
                    else
                    {
                        for (int o = 0; o < 8; o++)
                        {
                            phase[o] = 0 - Delay * Utilities.Numerics.angularFrequency[o];
                        }
                    }

                    return(new BroadRay(Utilities.PachTools.RPttoHPt(P), Direction, random.Next(), thread, DomainPower, phase, Delay, S_ID));
                }
 public abstract BroadRay Directions(int index, int thread, ref Random random, ref Curve Curves, ref double[] DomainPower, ref double delay, ref Phase_Regime ph, ref int S_ID);
            public SurfaceSource(IEnumerable<Brep> Surfaces, List<String> CodeList, int el_m, int SrcID, Phase_Regime ph)
                :base(new double[8]{0, 0, 0, 0, 0, 0, 0, 0}, new Point3d(0,0,0), ph, SrcID)
            {
                samplespermeter = el_m;
                
                Srfs = Surfaces.ToList<Brep>();
                Samples = new Point3d[Srfs.Count][];
                
                MeshingParameters mp = new MeshingParameters();
                mp.MaximumEdgeLength = 1.0 / (double)samplespermeter;
                mp.MinimumEdgeLength = 1.0 / (double)samplespermeter;

                Sub_A = new double[Srfs.Count];
                SubDomains = new double[Srfs.Count][];
                T = new Topology[Srfs.Count];

                //for(int i = 0; i < Curves.Count; i++)
                System.Threading.Tasks.Parallel.For(0, Srfs.Count, ips =>
                {
                    int i = (int)ips;
                    
                    
                    //Divide each curve up in ~equal length segments.
                    Mesh[] m = Mesh.CreateFromBrep(Srfs[i],mp);
                    BoundingBox Box = m[0].GetBoundingBox(true);
                    for (int j = 1; j < m.Length; j++) Box.Union(m[j].GetBoundingBox(true));
                    T[i] = new Topology(Utilities.PachTools.RPttoHPt(Box.Min), Utilities.PachTools.RPttoHPt(Box.Max));
                    
                    List<Point3d> pts = new List<Point3d>();
                    SubDomains[i] = new double[m[i].Faces.Count + 1];
                    for (int j = 0; j < m[i].Faces.Count; j++)
                    {
                        double u,v;
                        ComponentIndex ci;
                        Point3d no;
                        Vector3d V;
                        Point3d A = m[i].Vertices[m[i].Faces[j].A];
                        Srfs[i].ClosestPoint(A, out no, out ci, out u, out v, 1, out V);
                        A += V;
                        Point3d B = m[i].Vertices[m[i].Faces[j].B];
                        Srfs[i].ClosestPoint(B, out no, out ci, out u, out v, 1, out V);
                        B += V;
                        Point3d C = m[i].Vertices[m[i].Faces[j].C];
                        Srfs[i].ClosestPoint(C, out no, out ci, out u, out v, 1, out V);
                        C += V;
                        Point3d D = m[i].Vertices[m[i].Faces[j].D];
                        Srfs[i].ClosestPoint(D, out no, out ci, out u, out v, 1, out V);
                        D += V;
                        
                        if (m[i].Faces[j].IsQuad)
                        {
                            Hare.Geometry.Point[] poly = new Hare.Geometry.Point[4];
                            poly[0] = new Hare.Geometry.Point(A.X, A.Y, A.Z);
                            poly[1] = new Hare.Geometry.Point(B.X, B.Y, B.Z);
                            poly[2] = new Hare.Geometry.Point(C.X, C.Y, C.Z);
                            poly[3] = new Hare.Geometry.Point(D.X, D.Y, D.Z);
                            T[i].Add_Polygon(poly);
                        }
                        else
                        {
                            Hare.Geometry.Point[] poly = new Hare.Geometry.Point[3];
                            poly[0] = new Hare.Geometry.Point(A.X, A.Y, A.Z);
                            poly[1] = new Hare.Geometry.Point(B.X, B.Y, B.Z);
                            poly[2] = new Hare.Geometry.Point(C.X, C.Y, C.Z);
                            T[i].Add_Polygon(poly);
                        }

                        pts.Add(m[i].Faces[j].IsQuad ? new Point3d(A.X + B.X + C.X + D.X, A.Y + B.Y + C.Y + D.Y, A.Z + B.Z + C.Z + D.Z) / 4 : new Point3d(A.X + B.X + C.X, A.Y + B.Y + C.Y, A.Z + B.Z + C.Z) / 3);

                        SubDomains[i][j + 1] = Sub_A[i] += T[i].Polygon_Area(j);
                    }
                    Samples[i] = pts.ToArray();
                });

                Domains = new double[Srfs.Count+1];
                DomainLevel = new double[Srfs.Count][];
                DomainPower = new double[Srfs.Count][];
                Total_A = 0;
                
                for (int i = 0; i < Srfs.Count; i++)
                {
                    for (int j = 0; j < SubDomains[i].Length; j++) SubDomains[i][j] /= Sub_A[i];
                    double A = Srfs[i].GetArea();
                    Domains[i + 1] = Total_A += A;
                    DomainLevel[i] = Utilities.PachTools.DecodeSourcePower(CodeList[i]);
                    DomainPower[i] = new double[8];
                    double PowerMod = A;
                    for (int oct = 0; oct < 8; oct++) DomainPower[i][oct] = 1E-12 * Math.Pow(10, .1 * DomainLevel[i][oct]) / PowerMod;
                }

                for (int i = 0; i < Domains.Length; i++)
                {
                    Domains[i] /= Total_A;
                }
            }
                public override BroadRay Directions(int index, int thread, ref Random random, ref Curve Curves, ref double[] DomainPower, ref double Delay, ref Phase_Regime ph, ref int S_ID)
                {
                    double pos = random.NextDouble();
                    int i;

                    Interval t = Curves.Domain;
                    double x = random.NextDouble() * (t[1] - t[0]) + t[0];
                    Point3d P = Curves.PointAt(x);
                    Vector3d f = Curves.TangentAt(x);
                    Vector fore = new Hare.Geometry.Vector(f.X, f.Y, f.Z);

                    double Theta = random.NextDouble() * 2 * System.Math.PI;
                    double Phi = random.NextDouble() * 2 * System.Math.PI;
                    Vector Direction = new Hare.Geometry.Vector(Math.Sin(Theta) * Math.Cos(Phi), Math.Sin(Theta) * Math.Sin(Phi), Math.Cos(Theta));

                    double cosphi = Hare.Geometry.Hare_math.Dot(Direction, fore);
                    double sinphi = Math.Sqrt(1 - cosphi * cosphi);
                    double tanphi =  sinphi/cosphi;
                    double F_r = sinphi * sinphi * Math.Pow((tanphi * tanphi + 1) / (tanphi * tanphi + (1 + tanphi * Math.Tan(delta))), 1.5);

                    double[] power = new double[8];
                    for (int oct = 0; oct < 8; oct++) power[oct] = DomainPower[oct] * reciprocal_velocity * dLinf * F_r;
                    double[] phase = new double[8];
                    if (ph == Phase_Regime.Random) for (int o = 0; o < 8; o++) phase[o] = random.Next() * 2 * Math.PI;
                    else for (int o = 0; o < 8; o++) phase[o] = 0 - Delay * Utilities.Numerics.angularFrequency[o];

                    return new BroadRay(Utilities.PachTools.RPttoHPt(P), Direction, random.Next(), thread, DomainPower, phase, Delay, S_ID);
                }
                public override BroadRay Directions(int index, int thread, ref Random random, ref Curve Curves, ref double[] DomainPower, ref double Delay, ref Phase_Regime ph, ref int S_ID)
                {
                    double pos = random.NextDouble();
                    int i;

                    Interval t = Curves.Domain;
                    double x = random.NextDouble() * (t[1] - t[0]) + t[0];
                    Point3d P = Curves.PointAt(x);

                    double Theta = random.NextDouble() * 2 * System.Math.PI;
                    double Phi = random.NextDouble() * 2 * System.Math.PI;
                    Vector Direction = new Hare.Geometry.Vector(Math.Sin(Theta) * Math.Cos(Phi), Math.Sin(Theta) * Math.Sin(Phi), Math.Cos(Theta));
                    double[] phase = new double[8];
                    if (ph == Phase_Regime.Random) for (int o = 0; o < 8; o++) phase[o] = random.Next() * 2 * Math.PI;
                    else for (int o = 0; o < 8; o++) phase[o] = 0 - Delay * Utilities.Numerics.angularFrequency[o];

                    return new BroadRay(Utilities.PachTools.RPttoHPt(P), Direction, random.Next(), thread, DomainPower, phase, Delay, S_ID);
                }
 public abstract BroadRay Directions(int index, int thread, ref Random random, ref Curve Curves, ref double[] DomainPower, ref double delay, ref Phase_Regime ph, ref int S_ID);
 public GeodesicSource(double[] power_in_db, Point3d Source, Phase_Regime ph, int ID)
     : base(power_in_db, Source, ph, ID)
 {
     Random RAND = new Random();
     type = "Geodesic";
     GeoSphere(3);
 }
 public RandomSource(double[] power_in_db, Point3d Source, Phase_Regime ph, int ID)
     : base(power_in_db, Source, ph, ID)
 {
     type = "PseudoRandom";
 }