Exemple #1
0
        public void Calculate(
            double Thrust,
            FlowParameters FlowParameters,
            EngineSoundContourParameters ContourParameters,
            out EngineSoundContour EngineSoundContour) // см. метод с аналогичной сигнатурой в IModel
        {
            var FlowSoundParameters = GetFlowSoundParameters(Thrust, FlowParameters);
            var EngineSoundLevel = GetEngineSoundLevel(Thrust, FlowParameters);
            int Nx, Ny, W, H;

            if (ContourParameters.ContourAreaWidth >= ContourParameters.ContourAreaHeight)
            {
                Ny = 51;
                H  = 1000;
                Nx = (int)(Ny * ContourParameters.ContourAreaWidth / ContourParameters.ContourAreaHeight);
                W  = (int)(H * ContourParameters.ContourAreaWidth / ContourParameters.ContourAreaHeight);
            }
            else
            {
                Nx = 51;
                W  = 1000;
                Ny = (int)(Nx * ContourParameters.ContourAreaHeight / ContourParameters.ContourAreaWidth);
                H  = (int)(W * ContourParameters.ContourAreaHeight / ContourParameters.ContourAreaWidth);
            }
            var    X  = new double[Nx];
            var    Y  = new double[Ny];
            double dX = ContourParameters.ContourAreaWidth / (Nx - 1);
            double dY = ContourParameters.ContourAreaHeight / (Ny - 1);

            for (int i = 0; i < Nx; i++)
            {
                X[i] = i * dX;
            }
            for (int i = 0; i < Ny; i++)
            {
                Y[i] = i * dY;
            }
            var SoundLevels = new double[Nx, Ny];

            for (int i = 0; i < Nx; i++)
            {
                double x = X[i] - FlowSoundParameters.DistanceToPointOfMaximalSoundLevel - ContourParameters.NozzleCoordinate;
                x = Math.Abs(x) < 0.001 ? 0.001 : x;
                for (int j = 0; j < Ny; j++)
                {
                    double y = Math.Abs(Y[j] - ContourParameters.ContourAreaHeight / 2);
                    double Angle;
                    if (x == 0)
                    {
                        Angle = Math.Sign(y) * Math.PI / 2;
                    }
                    else
                    {
                        Angle = Math.Atan(y / Math.Abs(x));
                        if (x < 0)
                        {
                            Angle = Math.PI - Angle;
                        }
                    }
                    double Radius = Math.Sqrt(x * x + y * y);
                    SoundLevels[i, j] = EngineSoundLevel(Radius, Angle);
                }
            }
            var Contour = new Bitmap(W, H);

            EngineSoundContour = new EngineSoundContour(X, Y, SoundLevels, Contour);
            ModifyEngineSoundContour(ContourParameters.MinSoundLevel, ContourParameters.MaxSoundLevel, ref EngineSoundContour);
        }
Exemple #2
0
        public void ModifyEngineSoundContour(
            double MinSoundLevel,
            double MaxSoundLevel,
            ref EngineSoundContour EngineSoundContour) // см. метод с аналогичной сигнатурой в IModel
        {
            int ImageWidth  = EngineSoundContour.Contour.Width;
            int ImageHeight = EngineSoundContour.Contour.Height;

            double[] X = EngineSoundContour.X;
            double[] Y = EngineSoundContour.Y;
            double[,] SoundLevels = EngineSoundContour.SoundLevels;
            var Contour = new Bitmap(ImageWidth, ImageHeight);

            using (var g = Graphics.FromImage(Contour))
            {
                int    gNx = 300, gNy = 300;
                double mux          = X.Max() / ImageWidth;
                double muy          = Y.Max() / ImageHeight;
                int    dx           = ImageWidth / gNx;
                int    dy           = ImageHeight / gNy;
                double Max          = SoundLevels[0, 0];
                double Min          = Max;
                var    Interpolator = new DoubleInterpolation(X, Y, SoundLevels);
                for (int i = 0; i < SoundLevels.GetLength(0); i++)
                {
                    for (int j = 0; j < SoundLevels.GetLength(1); j++)
                    {
                        if (SoundLevels[i, j] > Max)
                        {
                            Max = SoundLevels[i, j];
                        }
                        else if (SoundLevels[i, j] < Min)
                        {
                            Min = SoundLevels[i, j];
                        }
                    }
                }
                var Intervals = new double[] { 0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0 };
                var R         = new Interpolation(Intervals, new double[] { 0, 0, 0, 0, 0, 0, 124, 203, 255, 255, 255, 255 });
                var G         = new Interpolation(Intervals, new double[] { 0, 124, 203, 255, 255, 255, 255, 255, 255, 203, 124, 0 });
                var B         = new Interpolation(Intervals, new double[] { 255, 255, 255, 255, 203, 124, 0, 0, 0, 0, 0, 0 });
                Func <double, Color> GetColor = x =>
                {
                    x = (x - MinSoundLevel) / (MaxSoundLevel - MinSoundLevel);
                    return(Color.FromArgb(
                               (int)R.Interpolate(x * 11),
                               (int)G.Interpolate(x * 11),
                               (int)B.Interpolate(x * 11)));
                };
                for (int i = 0; i < gNx; i++)
                {
                    ProgressChanged((int)(i * 100.0 / gNx));
                    int x = i * ImageWidth / gNx;
                    for (int j = 0; j < gNy; j++)
                    {
                        int y     = j * ImageHeight / gNy;
                        var color = GetColor(Interpolator.Interpolate(x * mux, y * muy));
                        using (var Brush = new SolidBrush(color))
                        {
                            g.FillRectangle(Brush, x, y, i * dx, i * dy);
                        }
                    }
                }
            }
            ProgressChanged(100);
            EngineSoundContour = new EngineSoundContour(X, Y, SoundLevels, Contour);
        }
Exemple #3
0
 public void ModifyEngineSoundContour(double MinSoundLevel, double MaxSoundLevel, ref EngineSoundContour EngineSoundContour)
 {
     engineNoiseModel.ModifyEngineSoundContour(MinSoundLevel, MaxSoundLevel, ref EngineSoundContour);
 }
Exemple #4
0
        void MainView_CalculateEngineNoise(CalculateEngineNoiseEventArgs e)
        {
            var summary = new EngineAcousticsLoadSummary(
                engineNoiseCalculation.FlowSoundParameters,
                engineNoiseCalculation.FrequencyCharacteristik,
                engineNoiseCalculation.RadiationPattern,
                engineNoiseCalculation.EngineAcousticsLoadAtFrequency,
                engineNoiseCalculation.EngineAcousticsLoadSummary);
            EngineSoundContour EngineSoundContour        = engineNoiseCalculation.EngineSoundContour;
            Func <bool>        ContourCoordinatesNotNull = () =>
                                                           engineNoiseCalculation.ContourAreaHeight *
                                                           engineNoiseCalculation.ContourAreaWidth *
                                                           engineNoiseCalculation.NozzleCoordinate *
                                                           engineNoiseCalculation.MinSoundLevel *
                                                           engineNoiseCalculation.MaxSoundLevel != 0;

            if (engineNoiseCalculation.InputDataChanged)
            {
                Model.CalculateEngineAcousticsLoadSummary(
                    engineNoiseCalculation.Thrust,
                    engineNoiseCalculation.FlowParameters,
                    out summary);
                if (ContourCoordinatesNotNull())
                {
                    Model.CalculateEngineSoundContour(
                        engineNoiseCalculation.Thrust,
                        engineNoiseCalculation.FlowParameters,
                        new EngineSoundContourParameters(
                            engineNoiseCalculation.ContourAreaWidth,
                            engineNoiseCalculation.ContourAreaHeight,
                            engineNoiseCalculation.NozzleCoordinate,
                            engineNoiseCalculation.MinSoundLevel,
                            engineNoiseCalculation.MaxSoundLevel),
                        out EngineSoundContour);
                }
            }
            else if (engineNoiseCalculation.ContourCoordinatesChanged)
            {
                if (ContourCoordinatesNotNull())
                {
                    Model.CalculateEngineSoundContour(
                        engineNoiseCalculation.Thrust,
                        engineNoiseCalculation.FlowParameters,
                        new EngineSoundContourParameters(
                            engineNoiseCalculation.ContourAreaWidth,
                            engineNoiseCalculation.ContourAreaHeight,
                            engineNoiseCalculation.NozzleCoordinate,
                            engineNoiseCalculation.MinSoundLevel,
                            engineNoiseCalculation.MaxSoundLevel),
                        out EngineSoundContour);
                }
            }
            else if (engineNoiseCalculation.ContourColorsChanged)
            {
                if (ContourCoordinatesNotNull())
                {
                    Model.ModifyEngineSoundContour(engineNoiseCalculation.MinSoundLevel, engineNoiseCalculation.MaxSoundLevel, ref EngineSoundContour);
                }
            }
            engineNoiseCalculation.FlowSoundParameters            = summary.FlowSoundParameters;
            engineNoiseCalculation.FrequencyCharacteristik        = summary.FrequencyCharacteristik;
            engineNoiseCalculation.RadiationPattern               = summary.RadiationPattern;
            engineNoiseCalculation.EngineAcousticsLoadAtFrequency = summary.EngineAcousticsLoadAtFrequency;
            engineNoiseCalculation.EngineAcousticsLoadSummary     = summary.SummaryLoad;
            engineNoiseCalculation.EngineSoundContour             = EngineSoundContour;
            e.FlowSoundParameters                            = summary.FlowSoundParameters;
            e.FrequencyCharacteristik                        = summary.FrequencyCharacteristik;
            e.RadiationPattern                               = summary.RadiationPattern;
            e.EngineAcousticsLoadAtFrequency                 = summary.EngineAcousticsLoadAtFrequency;
            e.EngineAcousticsLoadSummary                     = summary.SummaryLoad;
            e.EngineSoundContour                             = EngineSoundContour;
            engineNoiseCalculation.InputDataChanged          = false;
            engineNoiseCalculation.ContourCoordinatesChanged = false;
            engineNoiseCalculation.ContourColorsChanged      = false;
        }
Exemple #5
0
 public void CalculateEngineSoundContour(double Thrust, FlowParameters FlowParameters, EngineSoundContourParameters ContourParameters, out EngineSoundContour EngineSoundContour)
 {
     engineNoiseModel.Calculate(Thrust, FlowParameters, ContourParameters, out EngineSoundContour);
 }