Ejemplo n.º 1
0
        public SAR GetFieldRange(double[][] ranges)
        {
            SAR dump = new SAR();

            dump.FileName = FileName;
            dump.Frequency = Frequency;

            // Generate indeces
            int[][] idxRanges = new int[3][];
            for (int n = 0; n < 3; n++)
            {
                if (ranges[n].Length == 0) // All
                {
                    idxRanges[n] = new int[Mesh[n].Length];
                    for (int i = 0; i < Mesh[n].Length; i++)
                    {
                        idxRanges[n][i] = i;
                    }
                }
                else if (ranges[n].Length == 1) // Single
                {
                    idxRanges[n] = new int[1];

                    if (ranges[n][0] <= Mesh[n].First())
                    {
                        idxRanges[n][0] = 0;
                    }
                    else if (ranges[n][0] >= Mesh[n].Last())
                    {
                        idxRanges[n][0] = Mesh[n].Length - 1;
                    }
                    else
                    {
                        int i = 0;
                        while (i < Mesh[n].Length && Mesh[n][i] < ranges[n][0])
                        {
                            i++;
                        }
                        idxRanges[n][0] = Math.Abs(Mesh[n][i] - ranges[n][0]) < Math.Abs(Mesh[n][i - 1] - ranges[n][0]) ? i : i - 1;
                    }
                }
                else // Some
                {
                    throw new NotImplementedException();
                }
            }

            dump.Mesh = new double[3][];
            for (int n = 0; n < 3; n++)
            {
                dump.Mesh[n] = new double[idxRanges[n].Length];
                for (int i = 0; i < idxRanges[n].Length; i++)
                {
                    dump.Mesh[n][i] = Mesh[n][idxRanges[n][i]];
                }
            }

            // Create field
            dump.Field = new double[idxRanges[0].Length, idxRanges[1].Length, idxRanges[2].Length];
            for (int i = 0; i < idxRanges[0].Length; i++)
            {
                for (int j = 0; j < idxRanges[1].Length; j++)
                {
                    for (int k = 0; k < idxRanges[2].Length; k++)
                    {
                        dump.Field[i, j, k] =
                            Field[idxRanges[0][0] + i, idxRanges[1][0] + j, idxRanges[2][0] + k];
                    }
                }
            }

            return dump;
        }
        public void DipoleSar_Sar_MatchesReference()
        {
            double f0 = 1e9;
            double r = 50;
            double refPin_f0 = 1.420492702441687e-027;
            double refMaxvalue = 3.336527874272695e-026;

            double[] freqs = Utility.LinearSpace(500e6, 1500e6, 501);
            var lumpedPort = new LumpedPort(0, 1, r, new Vector3D(-10, -1, -1), new Vector3D(10, 1, 1), ENormDir.X, true);
            lumpedPort.ReadResults(freqs);
            double dutPin_f0 = lumpedPort.GetPFdInAt(f0);

            string sarFileName = @"ref_dipole_sar_dump.h5";
            var sarDump = new SAR(sarFileName);

            Assert.Equal(String.Format("{0:e15}", refPin_f0), String.Format("{0:e15}", dutPin_f0));
            Assert.Equal(String.Format("{0:e15}", refMaxvalue), String.Format("{0:e15}", sarDump.MaxValue));
            Assert.Equal(String.Format("{0:e15}", refMaxvalue / refPin_f0), String.Format("{0:e15}", sarDump.MaxValue / dutPin_f0));
        }
Ejemplo n.º 3
0
        public SAR GetFieldRange(double[][] ranges)
        {
            SAR dump = new SAR();

            dump.FileName  = FileName;
            dump.Frequency = Frequency;

            // Generate indeces
            int[][] idxRanges = new int[3][];
            for (int n = 0; n < 3; n++)
            {
                if (ranges[n].Length == 0) // All
                {
                    idxRanges[n] = new int[Mesh[n].Length];
                    for (int i = 0; i < Mesh[n].Length; i++)
                    {
                        idxRanges[n][i] = i;
                    }
                }
                else if (ranges[n].Length == 1) // Single
                {
                    idxRanges[n] = new int[1];

                    if (ranges[n][0] <= Mesh[n].First())
                    {
                        idxRanges[n][0] = 0;
                    }
                    else if (ranges[n][0] >= Mesh[n].Last())
                    {
                        idxRanges[n][0] = Mesh[n].Length - 1;
                    }
                    else
                    {
                        int i = 0;
                        while (i < Mesh[n].Length && Mesh[n][i] < ranges[n][0])
                        {
                            i++;
                        }
                        idxRanges[n][0] = Math.Abs(Mesh[n][i] - ranges[n][0]) < Math.Abs(Mesh[n][i - 1] - ranges[n][0]) ? i : i - 1;
                    }
                }
                else // Some
                {
                    throw new NotImplementedException();
                }
            }

            dump.Mesh = new double[3][];
            for (int n = 0; n < 3; n++)
            {
                dump.Mesh[n] = new double[idxRanges[n].Length];
                for (int i = 0; i < idxRanges[n].Length; i++)
                {
                    dump.Mesh[n][i] = Mesh[n][idxRanges[n][i]];
                }
            }

            // Create field
            dump.Field = new double[idxRanges[0].Length, idxRanges[1].Length, idxRanges[2].Length];
            for (int i = 0; i < idxRanges[0].Length; i++)
            {
                for (int j = 0; j < idxRanges[1].Length; j++)
                {
                    for (int k = 0; k < idxRanges[2].Length; k++)
                    {
                        dump.Field[i, j, k] =
                            Field[idxRanges[0][0] + i, idxRanges[1][0] + j, idxRanges[2][0] + k];
                    }
                }
            }

            return(dump);
        }