|
@@ -175,7 +175,7 @@ namespace ShakerApp.ViewModels
|
|
[PropertyAssociation(nameof(RandomConfigModel.SpectrumItemsCount))]
|
|
[PropertyAssociation(nameof(RandomConfigModel.SpectrumItemsCount))]
|
|
public uint SpectrumItemsCount => Model.SpectrumItemsCount;
|
|
public uint SpectrumItemsCount => Model.SpectrumItemsCount;
|
|
[PropertyAssociation(nameof(RandomConfigModel.HanningWindowCompensationCoefficient))]
|
|
[PropertyAssociation(nameof(RandomConfigModel.HanningWindowCompensationCoefficient))]
|
|
- public float HanningWindowCompensationCoefficient { get => Model.HanningWindowCompensationCoefficient; set => SetProperty(ref Model.HanningWindowCompensationCoefficient, value); }
|
|
|
|
|
|
+ public double HanningWindowCompensationCoefficient { get => Model.HanningWindowCompensationCoefficient; set => SetProperty(ref Model.HanningWindowCompensationCoefficient, value); }
|
|
[PropertyAssociation(nameof(RandomConfigModel.LinearAverage))]
|
|
[PropertyAssociation(nameof(RandomConfigModel.LinearAverage))]
|
|
public uint LinearAverage { get => Model.LinearAverage; set => SetProperty(ref Model.LinearAverage, value); }
|
|
public uint LinearAverage { get => Model.LinearAverage; set => SetProperty(ref Model.LinearAverage, value); }
|
|
[PropertyAssociation(nameof(RandomConfigModel.ExponentialAverage))]
|
|
[PropertyAssociation(nameof(RandomConfigModel.ExponentialAverage))]
|
|
@@ -183,7 +183,7 @@ namespace ShakerApp.ViewModels
|
|
[PropertyAssociation(nameof(RandomConfigModel.LinearAverage),nameof(RandomConfigModel.ExponentialAverage))]
|
|
[PropertyAssociation(nameof(RandomConfigModel.LinearAverage),nameof(RandomConfigModel.ExponentialAverage))]
|
|
public uint DOF => (LinearAverage << 1) * ((ExponentialAverage << 1) - 1);
|
|
public uint DOF => (LinearAverage << 1) * ((ExponentialAverage << 1) - 1);
|
|
[PropertyAssociation(nameof(RandomConfigModel.MaxFrequency),nameof(SpectrumLines))]
|
|
[PropertyAssociation(nameof(RandomConfigModel.MaxFrequency),nameof(SpectrumLines))]
|
|
- public float FrequencyResolution => (float)MaxFrequency / (float)SpectrumLines;
|
|
|
|
|
|
+ public double FrequencyResolution => (double)MaxFrequency / (double)SpectrumLines;
|
|
[PropertyAssociation(nameof(RandomConfigModel.RandomSampleRate))]
|
|
[PropertyAssociation(nameof(RandomConfigModel.RandomSampleRate))]
|
|
public uint RandomSampleRate => Model.RandomSampleRate;
|
|
public uint RandomSampleRate => Model.RandomSampleRate;
|
|
List<OxyPlot.Series.LineSeries> lineSeries = new List<OxyPlot.Series.LineSeries>();
|
|
List<OxyPlot.Series.LineSeries> lineSeries = new List<OxyPlot.Series.LineSeries>();
|
|
@@ -196,11 +196,11 @@ namespace ShakerApp.ViewModels
|
|
List<LineStyle> lineStyles = new List<LineStyle>() { LineStyle.Solid, LineStyle.Solid, LineStyle.Solid, LineStyle.LongDashDotDot, LineStyle.LongDashDotDot };
|
|
List<LineStyle> lineStyles = new List<LineStyle>() { LineStyle.Solid, LineStyle.Solid, LineStyle.Solid, LineStyle.LongDashDotDot, LineStyle.LongDashDotDot };
|
|
List<string> properties = new List<string>() { nameof(SweepData.TargetAcceleration), nameof(SweepData.UpStopAcceleration), nameof(SweepData.DownStopAcceleration), nameof(SweepData.UpWarnAcceleration), nameof(SweepData.DownWarnAcceleration) };
|
|
List<string> properties = new List<string>() { nameof(SweepData.TargetAcceleration), nameof(SweepData.UpStopAcceleration), nameof(SweepData.DownStopAcceleration), nameof(SweepData.UpWarnAcceleration), nameof(SweepData.DownWarnAcceleration) };
|
|
List<SweepData> datas = new List<SweepData>();
|
|
List<SweepData> datas = new List<SweepData>();
|
|
- private float rmsAcceleration = 0;
|
|
|
|
|
|
+ private double rmsAcceleration = 0;
|
|
private double maxDisplacement;
|
|
private double maxDisplacement;
|
|
private double maxVelocity;
|
|
private double maxVelocity;
|
|
private bool canResetRMS = false;
|
|
private bool canResetRMS = false;
|
|
- private float resetRMS;
|
|
|
|
|
|
+ private double resetRMS;
|
|
|
|
|
|
[PropertyAssociation(nameof(RandomConfigModel.MaxFrequency))]
|
|
[PropertyAssociation(nameof(RandomConfigModel.MaxFrequency))]
|
|
public RandomMaxFrequency MaxFrequency
|
|
public RandomMaxFrequency MaxFrequency
|
|
@@ -213,11 +213,11 @@ namespace ShakerApp.ViewModels
|
|
}
|
|
}
|
|
}
|
|
}
|
|
public bool CanResetRMS { get => canResetRMS; set =>SetProperty(ref canResetRMS, value); }
|
|
public bool CanResetRMS { get => canResetRMS; set =>SetProperty(ref canResetRMS, value); }
|
|
- public float ResetRMS { get => resetRMS; set =>SetProperty(ref resetRMS , value); }
|
|
|
|
|
|
+ public double ResetRMS { get => resetRMS; set =>SetProperty(ref resetRMS , value); }
|
|
[PropertyAssociation(nameof(RandomConfigModel.SynthesisType))]
|
|
[PropertyAssociation(nameof(RandomConfigModel.SynthesisType))]
|
|
public AccelerationSynthesisType SynthesisType { get => Model.SynthesisType; set => SetProperty(ref Model.SynthesisType, value); }
|
|
public AccelerationSynthesisType SynthesisType { get => Model.SynthesisType; set => SetProperty(ref Model.SynthesisType, value); }
|
|
[PropertyAssociation(nameof(RandomConfigModel.MinFrequency))]
|
|
[PropertyAssociation(nameof(RandomConfigModel.MinFrequency))]
|
|
- public float MinFrequency { get => Model.MinFrequency; set => SetProperty(ref Model.MinFrequency, value); }
|
|
|
|
|
|
+ public double MinFrequency { get => Model.MinFrequency; set => SetProperty(ref Model.MinFrequency, value); }
|
|
[PropertyAssociation(nameof(RandomConfigModel.SpectrumLines))]
|
|
[PropertyAssociation(nameof(RandomConfigModel.SpectrumLines))]
|
|
public SpectrumLines SpectrumLines
|
|
public SpectrumLines SpectrumLines
|
|
{
|
|
{
|
|
@@ -229,7 +229,7 @@ namespace ShakerApp.ViewModels
|
|
}
|
|
}
|
|
}
|
|
}
|
|
[PropertyAssociation(nameof(RandomConfigModel.Sigma))]
|
|
[PropertyAssociation(nameof(RandomConfigModel.Sigma))]
|
|
- public float Sigma { get => Model.Sigma; set => SetProperty(ref Model.Sigma, value); }
|
|
|
|
|
|
+ public double Sigma { get => Model.Sigma; set => SetProperty(ref Model.Sigma, value); }
|
|
|
|
|
|
[PropertyAssociation(nameof(RandomConfigModel.RandomSampleRate),nameof(RandomConfigModel.MaxFrequency),nameof(RandomConfigModel.SpectrumLines))]
|
|
[PropertyAssociation(nameof(RandomConfigModel.RandomSampleRate),nameof(RandomConfigModel.MaxFrequency),nameof(RandomConfigModel.SpectrumLines))]
|
|
public uint FFTLength => (uint)(Model.RandomSampleRate / (float)MaxFrequency * (uint)SpectrumLines);
|
|
public uint FFTLength => (uint)(Model.RandomSampleRate / (float)MaxFrequency * (uint)SpectrumLines);
|
|
@@ -243,25 +243,25 @@ namespace ShakerApp.ViewModels
|
|
[PropertyAssociation(nameof(RandomConfigModel.WarnLines))]
|
|
[PropertyAssociation(nameof(RandomConfigModel.WarnLines))]
|
|
public uint WarnLines { get => Model.WarnLines; set => SetProperty(ref Model.WarnLines, value); }
|
|
public uint WarnLines { get => Model.WarnLines; set => SetProperty(ref Model.WarnLines, value); }
|
|
[PropertyAssociation(nameof(RandomConfigModel.StopRMS))]
|
|
[PropertyAssociation(nameof(RandomConfigModel.StopRMS))]
|
|
- public float StopRMS { get => Model.StopRMS; set => SetProperty(ref Model.StopRMS, value); }
|
|
|
|
|
|
+ public double StopRMS { get => Model.StopRMS; set => SetProperty(ref Model.StopRMS, value); }
|
|
public OxyPlot.PlotModel AccelerationModel { get; } = new OxyPlot.PlotModel();
|
|
public OxyPlot.PlotModel AccelerationModel { get; } = new OxyPlot.PlotModel();
|
|
|
|
|
|
public PlotModel DisplacementModel { get; } = new PlotModel();
|
|
public PlotModel DisplacementModel { get; } = new PlotModel();
|
|
public PlotModel VelocityModel { get; } = new PlotModel();
|
|
public PlotModel VelocityModel { get; } = new PlotModel();
|
|
public static RandomConfigViewModel Instance { get; } = new RandomConfigViewModel();
|
|
public static RandomConfigViewModel Instance { get; } = new RandomConfigViewModel();
|
|
[PropertyAssociation(nameof(RandomConfigModel.Sigma))]
|
|
[PropertyAssociation(nameof(RandomConfigModel.Sigma))]
|
|
- public float MaxAcceleration => RMSAcceleration * Sigma;
|
|
|
|
|
|
+ public double MaxAcceleration => RMSAcceleration * Sigma;
|
|
public double MaxDisplacement { get => maxDisplacement; set =>SetProperty(ref maxDisplacement , value); }
|
|
public double MaxDisplacement { get => maxDisplacement; set =>SetProperty(ref maxDisplacement , value); }
|
|
public double MaxVelocity { get => maxVelocity; set =>SetProperty(ref maxVelocity , value); }
|
|
public double MaxVelocity { get => maxVelocity; set =>SetProperty(ref maxVelocity , value); }
|
|
public bool AccelerationOverLimit => MaxAcceleration >= ShakerConfigViewModel.Instance.MaxAcceleration;
|
|
public bool AccelerationOverLimit => MaxAcceleration >= ShakerConfigViewModel.Instance.MaxAcceleration;
|
|
public bool DisplacementOverLimit => MaxDisplacement > ShakerConfigViewModel.Instance.MaxDisplacement;
|
|
public bool DisplacementOverLimit => MaxDisplacement > ShakerConfigViewModel.Instance.MaxDisplacement;
|
|
public bool VelocityOverLimit => MaxVelocity > ShakerConfigViewModel.Instance.MaxVelocity;
|
|
public bool VelocityOverLimit => MaxVelocity > ShakerConfigViewModel.Instance.MaxVelocity;
|
|
- public float AccelerationLoad => MathF.Round(MaxAcceleration / ShakerConfigViewModel.Instance.MaxAcceleration * 100f, 2);
|
|
|
|
- public float DisplacementLoad => MathF.Round((float)MaxDisplacement / ShakerConfigViewModel.Instance.MaxDisplacement * 100f, 2);
|
|
|
|
- public float VelocityLoad => MathF.Round((float)MaxVelocity / ShakerConfigViewModel.Instance.MaxVelocity * 100f, 2);
|
|
|
|
|
|
+ public double AccelerationLoad => Math.Round(MaxAcceleration / ShakerConfigViewModel.Instance.MaxAcceleration * 100f, 2);
|
|
|
|
+ public double DisplacementLoad => Math.Round((double)MaxDisplacement / ShakerConfigViewModel.Instance.MaxDisplacement * 100f, 2);
|
|
|
|
+ public double VelocityLoad => Math.Round((double)MaxVelocity / ShakerConfigViewModel.Instance.MaxVelocity * 100f, 2);
|
|
|
|
|
|
|
|
|
|
- public float RMSAcceleration { get => rmsAcceleration; set =>SetProperty(ref rmsAcceleration , value); }
|
|
|
|
|
|
+ public double RMSAcceleration { get => rmsAcceleration; set =>SetProperty(ref rmsAcceleration , value); }
|
|
|
|
|
|
public ICommand AddCommand => new RelayCommand(Add);
|
|
public ICommand AddCommand => new RelayCommand(Add);
|
|
private void Add()
|
|
private void Add()
|
|
@@ -318,20 +318,20 @@ namespace ShakerApp.ViewModels
|
|
if (items.Count < 3) return;
|
|
if (items.Count < 3) return;
|
|
CalcRefSpectrum(items.Select(x => x.Frequency).ToArray(), items.Select(x => x.Value).ToArray(), items.Select(x => x.ValueType).ToArray(), FrequencyResolution,out var fy_array,out var f,out var turningfreq);
|
|
CalcRefSpectrum(items.Select(x => x.Frequency).ToArray(), items.Select(x => x.Value).ToArray(), items.Select(x => x.ValueType).ToArray(), FrequencyResolution,out var fy_array,out var f,out var turningfreq);
|
|
if (fy_array.Length == 0) return;
|
|
if (fy_array.Length == 0) return;
|
|
- RMSAcceleration = MathF.Sqrt(ViewModels.MainViewModel.Default.Calc.Sum.Sum(ref fy_array[0], (uint)fy_array.Length) * FrequencyResolution);
|
|
|
|
|
|
+ RMSAcceleration = Math.Sqrt(ViewModels.MainViewModel.Default.Calc.Sum.Sum(ref fy_array[0], (uint)fy_array.Length) * FrequencyResolution);
|
|
ResetRMS = RMSAcceleration;
|
|
ResetRMS = RMSAcceleration;
|
|
- float[] f2 = new float[f.Length];
|
|
|
|
- float[] fv = new float[f.Length];
|
|
|
|
|
|
+ double[] f2 = new double[f.Length];
|
|
|
|
+ double[] fv = new double[f.Length];
|
|
MainViewModel.Default.Calc.Multiply.Multiply(ref f[0], ref f[0], (uint)f.Length,ref f2[0]);
|
|
MainViewModel.Default.Calc.Multiply.Multiply(ref f[0], ref f[0], (uint)f.Length,ref f2[0]);
|
|
MainViewModel.Default.Calc.Division.Division(ref fy_array[0],ref f2[0], (uint)f.Length,ref fv[0]);
|
|
MainViewModel.Default.Calc.Division.Division(ref fy_array[0],ref f2[0], (uint)f.Length,ref fv[0]);
|
|
- float sum = MainViewModel.Default.Calc.Sum.Sum(ref fv[0], (uint)fv.Length);
|
|
|
|
- MaxVelocity = MathF.Sqrt((sum - (fv[0] + fv[^1] / 2) / 2) * FrequencyResolution) / (2 * MathF.PI) * Sigma * 9.8f;
|
|
|
|
|
|
+ double sum = MainViewModel.Default.Calc.Sum.Sum(ref fv[0], (uint)fv.Length);
|
|
|
|
+ MaxVelocity = Math.Sqrt((sum - (fv[0] + fv[^1] / 2) / 2) * FrequencyResolution) / (2 * Math.PI) * Sigma * 9.8f;
|
|
MainViewModel.Default.Calc.Division.Division(ref fv[0], ref f2[0], (uint)f.Length, ref fv[0]);
|
|
MainViewModel.Default.Calc.Division.Division(ref fv[0], ref f2[0], (uint)f.Length, ref fv[0]);
|
|
sum = MainViewModel.Default.Calc.Sum.Sum(ref fv[0], (uint)fv.Length);
|
|
sum = MainViewModel.Default.Calc.Sum.Sum(ref fv[0], (uint)fv.Length);
|
|
- MaxDisplacement = MathF.Sqrt((sum - (fv[0] + fv[^1] / 2) / 2) * FrequencyResolution) / (2 * MathF.PI*2*MathF.PI) * Sigma * 9800f;
|
|
|
|
|
|
+ MaxDisplacement = Math.Sqrt((sum - (fv[0] + fv[^1] / 2) / 2) * FrequencyResolution) / (2 * Math.PI*2*Math.PI) * Sigma * 9800f;
|
|
OnPropertyChanged(nameof(MaxAcceleration));
|
|
OnPropertyChanged(nameof(MaxAcceleration));
|
|
- float[,] spectrumdata = new float[5, f.Length];
|
|
|
|
- Unsafe.CopyBlock(ref Unsafe.As<float,byte>(ref spectrumdata[0, 0]), ref Unsafe.As<float,byte>(ref fy_array[0]), (uint)(Unsafe.SizeOf<float>() * fy_array.Length));
|
|
|
|
|
|
+ double[,] spectrumdata = new double[5, f.Length];
|
|
|
|
+ Unsafe.CopyBlock(ref Unsafe.As<double, byte>(ref spectrumdata[0, 0]), ref Unsafe.As<double, byte>(ref fy_array[0]), (uint)(Unsafe.SizeOf<double>() * fy_array.Length));
|
|
CalcSpectrum(items, f, fy_array, FrequencyResolution, turningfreq, ref spectrumdata);
|
|
CalcSpectrum(items, f, fy_array, FrequencyResolution, turningfreq, ref spectrumdata);
|
|
datas.Clear();
|
|
datas.Clear();
|
|
velocitydata.Clear();
|
|
velocitydata.Clear();
|
|
@@ -364,14 +364,14 @@ namespace ShakerApp.ViewModels
|
|
DisplacementModel.InvalidatePlot(true);
|
|
DisplacementModel.InvalidatePlot(true);
|
|
CanResetRMS = true;
|
|
CanResetRMS = true;
|
|
}
|
|
}
|
|
- private void CalcSpectrum(List<RandomSpectrumItemModel> models, [In] float[] f, [In] float[] fy_array, [In]float deltaf, [In] float[] turn_freq,ref float[,] spectrumdata)
|
|
|
|
|
|
+ private void CalcSpectrum(List<RandomSpectrumItemModel> models, [In] double[] f, [In] double[] fy_array, [In] double deltaf, [In] double[] turn_freq,ref double[,] spectrumdata)
|
|
{
|
|
{
|
|
CalcItemSpectrum(models.Select(x => x.UpStop).ToArray(), f, fy_array, deltaf, turn_freq, ref spectrumdata[1, 0]);
|
|
CalcItemSpectrum(models.Select(x => x.UpStop).ToArray(), f, fy_array, deltaf, turn_freq, ref spectrumdata[1, 0]);
|
|
CalcItemSpectrum(models.Select(x => x.UpWarn).ToArray(), f, fy_array, deltaf, turn_freq, ref spectrumdata[2, 0]);
|
|
CalcItemSpectrum(models.Select(x => x.UpWarn).ToArray(), f, fy_array, deltaf, turn_freq, ref spectrumdata[2, 0]);
|
|
CalcItemSpectrum(models.Select(x => x.DownStop).ToArray(), f, fy_array, deltaf, turn_freq, ref spectrumdata[3, 0]);
|
|
CalcItemSpectrum(models.Select(x => x.DownStop).ToArray(), f, fy_array, deltaf, turn_freq, ref spectrumdata[3, 0]);
|
|
CalcItemSpectrum(models.Select(x => x.DownWarn).ToArray(), f, fy_array, deltaf, turn_freq, ref spectrumdata[4, 0]);
|
|
CalcItemSpectrum(models.Select(x => x.DownWarn).ToArray(), f, fy_array, deltaf, turn_freq, ref spectrumdata[4, 0]);
|
|
}
|
|
}
|
|
- private void CalcItemSpectrum(float[] offset, [In] float[] f, [In] float[] fy_array, [In] float deltaf, [In] float[] turn_freq, ref float spectrumdata)
|
|
|
|
|
|
+ private void CalcItemSpectrum(double[] offset, [In] double[] f, [In] double[] fy_array, [In] double deltaf, [In] double[] turn_freq, ref double spectrumdata)
|
|
{
|
|
{
|
|
for (int i = 0; i < offset.Length - 1; i++)
|
|
for (int i = 0; i < offset.Length - 1; i++)
|
|
{
|
|
{
|
|
@@ -379,34 +379,34 @@ namespace ShakerApp.ViewModels
|
|
uint len = (uint)((turn_freq[i + 1] - turn_freq[i]) / deltaf);
|
|
uint len = (uint)((turn_freq[i + 1] - turn_freq[i]) / deltaf);
|
|
if (offset[i+1] == offset[i])
|
|
if (offset[i+1] == offset[i])
|
|
{
|
|
{
|
|
- var x = MathF.Pow(10, offset[i] / 10);
|
|
|
|
|
|
+ var x = Math.Pow(10, offset[i] / 10);
|
|
MainViewModel.Default.Calc.Multiply.Multiply(ref fy_array[index], x, len, ref Unsafe.Add(ref spectrumdata,index));
|
|
MainViewModel.Default.Calc.Multiply.Multiply(ref fy_array[index], x, len, ref Unsafe.Add(ref spectrumdata,index));
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- float db1_psd = MathF.Pow(10, offset[i] / 10) * fy_array[index];
|
|
|
|
- float db2_psd = MathF.Pow(10, offset[i + 1] / 10) * fy_array[index+len];
|
|
|
|
- var x= MathF.Log10(db2_psd / db1_psd) / (MathF.Log2(turn_freq[i + 1] / turn_freq[i])) * 10;
|
|
|
|
|
|
+ double db1_psd = Math.Pow(10, offset[i] / 10) * fy_array[index];
|
|
|
|
+ double db2_psd = Math.Pow(10, offset[i + 1] / 10) * fy_array[index+len];
|
|
|
|
+ var x= Math.Log10(db2_psd / db1_psd) / (Math.Log2(turn_freq[i + 1] / turn_freq[i])) * 10;
|
|
for(int j=0;j<len;j++)
|
|
for(int j=0;j<len;j++)
|
|
{
|
|
{
|
|
- ref float result = ref Unsafe.Add(ref spectrumdata, index + j);
|
|
|
|
- result = MathF.Pow(10, MathF.Log2(f[index + j] / turn_freq[i]) * x / 10) * db1_psd;
|
|
|
|
|
|
+ ref double result = ref Unsafe.Add(ref spectrumdata, index + j);
|
|
|
|
+ result = Math.Pow(10, Math.Log2(f[index + j] / turn_freq[i]) * x / 10) * db1_psd;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- ref float temp = ref Unsafe.Add(ref spectrumdata, fy_array.Length - 1);
|
|
|
|
- temp = MathF.Pow(10, offset[^1] / 10) * fy_array[^1];
|
|
|
|
|
|
+ ref double temp = ref Unsafe.Add(ref spectrumdata, fy_array.Length - 1);
|
|
|
|
+ temp = Math.Pow(10, offset[^1] / 10) * fy_array[^1];
|
|
}
|
|
}
|
|
- private void CalcRefSpectrum(float[] f_array, float[] y_array, RandomValueType[] k_array, float deltaf ,out float[] fy_array,out float[] f,out float[] turningfreq)
|
|
|
|
|
|
+ private void CalcRefSpectrum(double[] f_array, double[] y_array, RandomValueType[] k_array, double deltaf ,out double[] fy_array,out double[] f,out double[] turningfreq)
|
|
{
|
|
{
|
|
int n=f_array.Length;
|
|
int n=f_array.Length;
|
|
// 计算圆整频率值及其对应的谱值
|
|
// 计算圆整频率值及其对应的谱值
|
|
- float[] round_f = new float[n];
|
|
|
|
- float[] round_y = new float[n];
|
|
|
|
- turningfreq = new float[n];
|
|
|
|
|
|
+ double[] round_f = new double[n];
|
|
|
|
+ double[] round_y = new double[n];
|
|
|
|
+ turningfreq = new double[n];
|
|
for (int i = 0; i < n; i++)
|
|
for (int i = 0; i < n; i++)
|
|
{
|
|
{
|
|
- round_f[i] = MathF.Ceiling(f_array[i] / deltaf) * deltaf;
|
|
|
|
|
|
+ round_f[i] = Math.Ceiling(f_array[i] / deltaf) * deltaf;
|
|
turningfreq[i] = round_f[i];
|
|
turningfreq[i] = round_f[i];
|
|
}
|
|
}
|
|
|
|
|
|
@@ -424,8 +424,8 @@ namespace ShakerApp.ViewModels
|
|
|
|
|
|
if (k_array[0] == RandomValueType.Slope)
|
|
if (k_array[0] == RandomValueType.Slope)
|
|
{
|
|
{
|
|
- float kk = y_array[1];
|
|
|
|
- y_array[0] = y_array[2] / (MathF.Pow(10, kk / 10 * MathF.Log(f_array[1] / f_array[0], 2)));
|
|
|
|
|
|
+ double kk = y_array[1];
|
|
|
|
+ y_array[0] = y_array[2] / (Math.Pow(10, kk / 10 * Math.Log(f_array[1] / f_array[0], 2)));
|
|
y_array[1] = y_array[2];
|
|
y_array[1] = y_array[2];
|
|
k_array[0] = 0;
|
|
k_array[0] = 0;
|
|
k_array[1] = 0;
|
|
k_array[1] = 0;
|
|
@@ -436,27 +436,27 @@ namespace ShakerApp.ViewModels
|
|
{
|
|
{
|
|
if (f_array[i] == 0)
|
|
if (f_array[i] == 0)
|
|
{
|
|
{
|
|
- float kk = y_array[i];
|
|
|
|
|
|
+ double kk = y_array[i];
|
|
y_array[i] = y_array[i + 1];
|
|
y_array[i] = y_array[i + 1];
|
|
- f_array[i] = MathF.Pow(2, (10 * MathF.Log(y_array[i + 1] / y_array[i - 1], 10) / kk)) * f_array[i - 1];
|
|
|
|
|
|
+ f_array[i] = Math.Pow(2, (10 * Math.Log(y_array[i + 1] / y_array[i - 1], 10) / kk)) * f_array[i - 1];
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
if (k_array[i] == RandomValueType.Slope)
|
|
if (k_array[i] == RandomValueType.Slope)
|
|
{
|
|
{
|
|
- y_array[i] = MathF.Pow(10, y_array[i] / 10 * MathF.Log(f_array[i] / f_array[i - 1], 2)) * y_array[i - 1];
|
|
|
|
|
|
+ y_array[i] = Math.Pow(10, y_array[i] / 10 * Math.Log(f_array[i] / f_array[i - 1], 2)) * y_array[i - 1];
|
|
k_array[i] = 0;
|
|
k_array[i] = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// 验证结果值
|
|
// 验证结果值
|
|
- float[] k_exam = new float[n - 1];
|
|
|
|
|
|
+ double[] k_exam = new double[n - 1];
|
|
for (int i = 0; i < n; i++)
|
|
for (int i = 0; i < n; i++)
|
|
{
|
|
{
|
|
if (i < n - 1)
|
|
if (i < n - 1)
|
|
{
|
|
{
|
|
- k_exam[i] = 10 * MathF.Log(y_array[i + 1] / y_array[i], 10) / MathF.Log(f_array[i + 1] / f_array[i], 2);
|
|
|
|
|
|
+ k_exam[i] = 10 * Math.Log(y_array[i + 1] / y_array[i], 10) / Math.Log(f_array[i + 1] / f_array[i], 2);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -472,24 +472,24 @@ namespace ShakerApp.ViewModels
|
|
{
|
|
{
|
|
if (round_f[i] > f_array[i])
|
|
if (round_f[i] > f_array[i])
|
|
{
|
|
{
|
|
- round_y[i] = MathF.Pow(10, k_exam[i] / 10 * MathF.Log(round_f[i] / f_array[i], 2)) * y_array[i];
|
|
|
|
|
|
+ round_y[i] = Math.Pow(10, k_exam[i] / 10 * Math.Log(round_f[i] / f_array[i], 2)) * y_array[i];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (i == n - 1)
|
|
if (i == n - 1)
|
|
{
|
|
{
|
|
- round_y[i] = MathF.Pow(10, k_exam[i - 1] / 10 * MathF.Log(round_f[i] / f_array[i], 2)) * y_array[i];
|
|
|
|
|
|
+ round_y[i] = Math.Pow(10, k_exam[i - 1] / 10 * Math.Log(round_f[i] / f_array[i], 2)) * y_array[i];
|
|
}
|
|
}
|
|
|
|
|
|
if (round_f[i] < f_array[i])
|
|
if (round_f[i] < f_array[i])
|
|
{
|
|
{
|
|
- round_y[i] = MathF.Pow(10, k_exam[i - 1] / 10 * MathF.Log(f_array[i] / round_f[i], 2)) * y_array[i];
|
|
|
|
|
|
+ round_y[i] = Math.Pow(10, k_exam[i - 1] / 10 * Math.Log(f_array[i] / round_f[i], 2)) * y_array[i];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
int parts = k_exam.Length; // 将谱按斜率分成几段,parts为总的段数\
|
|
int parts = k_exam.Length; // 将谱按斜率分成几段,parts为总的段数\
|
|
f = Enumerable.Range(0, (int)((round_f[n - 1] - round_f[0]) / deltaf) + 1).Select(x => x * deltaf + round_f[0]).ToArray();
|
|
f = Enumerable.Range(0, (int)((round_f[n - 1] - round_f[0]) / deltaf) + 1).Select(x => x * deltaf + round_f[0]).ToArray();
|
|
- fy_array =new float[f.Length];
|
|
|
|
|
|
+ fy_array =new double[f.Length];
|
|
fy_array[0] = round_y[0];
|
|
fy_array[0] = round_y[0];
|
|
fy_array[^1] = round_y[^1];
|
|
fy_array[^1] = round_y[^1];
|
|
int part_begin = 0;
|
|
int part_begin = 0;
|
|
@@ -512,7 +512,7 @@ namespace ShakerApp.ViewModels
|
|
{
|
|
{
|
|
for (int k = part_begin + 1; k <= part_begin + n_part; k++)
|
|
for (int k = part_begin + 1; k <= part_begin + n_part; k++)
|
|
{
|
|
{
|
|
- fy_array[k] = MathF.Pow(10, k_exam[i] / 10 * MathF.Log(f[k] / f[k - 1], 2)) * fy_array[k - 1];
|
|
|
|
|
|
+ fy_array[k] = Math.Pow(10, k_exam[i] / 10 * Math.Log(f[k] / f[k - 1], 2)) * fy_array[k - 1];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|