From 62f5f63989a5061e2cce2525746e312802f30fe3 Mon Sep 17 00:00:00 2001 From: aheldman Date: Tue, 7 Sep 2021 17:24:50 +0200 Subject: [PATCH] Largest Update of Code after 2 Years. Finished alpha Testing. --- CalScec/Analysis/Fitting/LMA.cs | 19 +- .../Analysis/Fitting/PeakFittingWindow.xaml | 2 +- .../Fitting/PeakFittingWindow.xaml.cs | 411 +- CalScec/Analysis/Peaks/Detection.cs | 10 +- .../Peaks/Functions/PeakRegionFunction.cs | 81 + CalScec/Analysis/Sample.cs | 3583 +++-- .../Stress/Macroskopic/TensileDataLoad.xaml | 101 + .../Macroskopic/TensileDataLoad.xaml.cs | 366 + .../Stress/Macroskopic/TensileTest.cs | 119 + .../ElasticityCalculationWindow.xaml | 153 +- .../ElasticityCalculationWindow.xaml.cs | 2130 ++- .../Stress/Microsopic/ElasticityTensors.cs | 215 +- .../REKAssociationCalculationWindow.xaml | 16 +- .../REKAssociationCalculationWindow.xaml.cs | 111 +- .../Analysis/Stress/Plasticity/EPModeling.cs | 4496 ++++++- .../Plasticity/ElastoPlasticExperiment.cs | 283 +- .../Stress/Plasticity/PlasticityTensor.cs | 944 +- .../Analysis/Stress/Plasticity/ReflexYield.cs | 196 +- .../Stress/Plasticity/YieldSurface.cs | 769 +- .../Stress/Plasticity/YieldSurfaceWindow.xaml | 854 +- .../Plasticity/YieldSurfaceWindow.xaml.cs | 10910 ++++++++++++---- .../OrientationDistributionFunction.cs | 1079 +- CalScec/App.config | 10 +- CalScec/CalScec.csproj | 42 + CalScec/DISEMM-Full-1.ico | Bin 0 -> 55921 bytes .../CrystalData/ReflexCondition.cs | 27 + CalScec/DataManagment/Files/SCEC/Header.cs | 73 +- .../Files/SCEC/PatternInformation.cs | 18 +- .../Files/SCEC/PlasticityTensorInformation.cs | 40 +- .../Files/SCEC/ReflexYieldInformation.cs | 12 + .../SCEC/SimulatedExperimentInformation.cs | 521 + .../Files/SCEC/YieldSurfaceInformation.cs | 5 +- .../DataManagment/Files/Simulation/SimBody.cs | 39 + .../Files/Simulation/SimHeader.cs | 465 + .../Files/Simulation/SimSystems.cs | 15 + CalScec/MainWindow.xaml | 343 +- CalScec/MainWindow.xaml.cs | 1121 +- CalScec/Pattern/DiffractionPattern.cs | 47 +- CalScec/Properties/Resources.Designer.cs | 56 +- CalScec/Properties/Settings.Designer.cs | 36 +- CalScec/Properties/Settings.settings | 10 +- CalScec/Res/Logo-Icon/DISEMM-Full-1.ico | Bin 0 -> 55921 bytes CalScec/Res/Logo-Icon/DISEMM-Icon-1.png | Bin 0 -> 6042 bytes CalScec/Res/Logo-Icon/Entwurf-1.png | Bin 0 -> 245489 bytes .../Res/ReflectionConditions/SlipSystems.xml | 1148 +- .../ReflectionConditions/SpaceGroupsHKL.xml | 18 + CalScec/Tools/AutoFillWindow.xaml | 98 + CalScec/Tools/AutoFillWindow.xaml.cs | 57 + CalScec/Tools/Calculation.cs | 160 + CalScec/Tools/FourthRankTensor.cs | 531 +- CalScec/Tools/PlottingWindow.xaml.cs | 14 + CalScec/Tools/YieldSurfacePlotSettings.xaml | 119 + .../Tools/YieldSurfacePlotSettings.xaml.cs | 41 + 53 files changed, 25502 insertions(+), 6412 deletions(-) create mode 100644 CalScec/Analysis/Stress/Macroskopic/TensileDataLoad.xaml create mode 100644 CalScec/Analysis/Stress/Macroskopic/TensileDataLoad.xaml.cs create mode 100644 CalScec/Analysis/Stress/Macroskopic/TensileTest.cs create mode 100644 CalScec/DISEMM-Full-1.ico create mode 100644 CalScec/DataManagment/Files/SCEC/SimulatedExperimentInformation.cs create mode 100644 CalScec/DataManagment/Files/Simulation/SimBody.cs create mode 100644 CalScec/DataManagment/Files/Simulation/SimHeader.cs create mode 100644 CalScec/DataManagment/Files/Simulation/SimSystems.cs create mode 100644 CalScec/Res/Logo-Icon/DISEMM-Full-1.ico create mode 100644 CalScec/Res/Logo-Icon/DISEMM-Icon-1.png create mode 100644 CalScec/Res/Logo-Icon/Entwurf-1.png create mode 100644 CalScec/Tools/AutoFillWindow.xaml create mode 100644 CalScec/Tools/AutoFillWindow.xaml.cs create mode 100644 CalScec/Tools/YieldSurfacePlotSettings.xaml create mode 100644 CalScec/Tools/YieldSurfacePlotSettings.xaml.cs diff --git a/CalScec/Analysis/Fitting/LMA.cs b/CalScec/Analysis/Fitting/LMA.cs index a7a44b7..68f9906 100644 --- a/CalScec/Analysis/Fitting/LMA.cs +++ b/CalScec/Analysis/Fitting/LMA.cs @@ -6817,14 +6817,29 @@ private static bool FitBackground(Analysis.Peaks.Functions.PeakFunction PF, doub #region Peak region routines + //private static void FitPeakRegionFunction(Analysis.Peaks.Functions.PeakRegionFunction PRF, double lambda) + //{ + // bool Converged = false; + // double Lambda = lambda; + + // Analysis.Peaks.Functions.PeakRegionFunction TrialPeakRegion = PRF.Clone() as Analysis.Peaks.Functions.PeakRegionFunction; + + // double FirstChi2 = TrialPeakRegion.Chi2Function; + // for (int TotalTrials = 0; TotalTrials < CalScec.Properties.Settings.Default.MaxFittingTrials; TotalTrials++) + // { + + // } + + //} + private static void CorrectFWHMLorentzRatioDown(Analysis.Peaks.Functions.PeakRegionFunction PRF) { for (int i = 0; i < 5; i++) { for (int n = 0; n < PRF.Count; n++) { - PRF[n].Sigma *= 0.9; - PRF[n].LorentzRatio *= 0.9; + PRF[n].Sigma *= 0.95; + //PRF[n].LorentzRatio *= 0.9; } FitAngleSigmaIntensityLorentzRatioBackground(PRF, LMA._lambda, true); diff --git a/CalScec/Analysis/Fitting/PeakFittingWindow.xaml b/CalScec/Analysis/Fitting/PeakFittingWindow.xaml index 8a7107d..a113166 100644 --- a/CalScec/Analysis/Fitting/PeakFittingWindow.xaml +++ b/CalScec/Analysis/Fitting/PeakFittingWindow.xaml @@ -68,7 +68,7 @@ - + diff --git a/CalScec/Analysis/Fitting/PeakFittingWindow.xaml.cs b/CalScec/Analysis/Fitting/PeakFittingWindow.xaml.cs index 7d872f8..22b9697 100644 --- a/CalScec/Analysis/Fitting/PeakFittingWindow.xaml.cs +++ b/CalScec/Analysis/Fitting/PeakFittingWindow.xaml.cs @@ -716,9 +716,9 @@ private void PeakView_SelectionChanged(object sender, SelectionChangedEventArgs this.FWHMTextBox.Text = PF.FWHM.ToString("F3"); this.LorentzRatioTextBox.Text = PF.LorentzRatio.ToString("F3"); this.IntensityTextBox.Text = PF.Intensity.ToString("F3"); - this.ConstantBackgroundTextBox.Text = PF.ConstantBackground.ToString("F3"); - this.CenterBackgroundTextBox.Text = PF.CenterBackground.ToString("F3"); - this.AclivityBackgroundTextBox.Text = PF.AclivityBackground.ToString("F3"); + //this.ConstantBackgroundTextBox.Text = PF.ConstantBackground.ToString("F3"); + //this.CenterBackgroundTextBox.Text = PF.CenterBackground.ToString("F3"); + //this.AclivityBackgroundTextBox.Text = PF.AclivityBackground.ToString("F3"); this.AngleConstraintTextBox.Text = PF.ParameterConstraints.AngleConstraint.ToString("F3"); this.FWHMConstraintTextBox.Text = PF.ParameterConstraints.SigmaConstraint.ToString("F3"); @@ -728,13 +728,13 @@ private void PeakView_SelectionChanged(object sender, SelectionChangedEventArgs this.FWHMConstraintActive.IsChecked = PF.ParameterConstraints.SigmaConstraintActiv; this.LorentzRatioConstraintActive.IsChecked = PF.ParameterConstraints.LorentzRatioConstraintActiv; - this.AngleFitActive.IsChecked = PF.FreeParameters[1]; - this.FWHMFitActive.IsChecked = PF.FreeParameters[0]; - this.LorentzRatioFitActive.IsChecked = PF.FreeParameters[2]; - this.IntensityFitActive.IsChecked = PF.FreeParameters[3]; - this.ConstantBackgroundFitActive.IsChecked = PF.FreeParameters[4]; - this.CenterBackgroundFitActive.IsChecked = PF.FreeParameters[5]; - this.AclivityBackgroundFitActive.IsChecked = PF.FreeParameters[6]; + //this.AngleFitActive.IsChecked = PF.FreeParameters[1]; + //this.FWHMFitActive.IsChecked = PF.FreeParameters[0]; + //this.LorentzRatioFitActive.IsChecked = PF.FreeParameters[2]; + //this.IntensityFitActive.IsChecked = PF.FreeParameters[3]; + //this.ConstantBackgroundFitActive.IsChecked = PF.FreeParameters[4]; + //this.CenterBackgroundFitActive.IsChecked = PF.FreeParameters[5]; + //this.AclivityBackgroundFitActive.IsChecked = PF.FreeParameters[6]; this.PeakFunctionBox.SelectedIndex = PF.functionType; @@ -1068,150 +1068,78 @@ private void LorentzRatioConstraintActive_Unchecked(object sender, RoutedEventAr private void AngleFitActive_Checked(object sender, RoutedEventArgs e) { - if (PeakView.SelectedIndex != -1) + if (RegionView.SelectedIndex != -1) { if (EditAktive) { - Analysis.Peaks.Functions.PeakFunction PF = (Analysis.Peaks.Functions.PeakFunction)PeakView.SelectedItem; - - PF.FreeParameters[1] = true; - } - } - else - { - if (RegionView.SelectedIndex != -1) - { - if (EditAktive) - { - Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; + Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; - PRF.FreeParameters[1] = true; - } + PRF.FreeParameters[1] = true; } } } private void AngleFitActive_Unchecked(object sender, RoutedEventArgs e) { - if (PeakView.SelectedIndex != -1) + if (RegionView.SelectedIndex != -1) { if (EditAktive) { - Analysis.Peaks.Functions.PeakFunction PF = (Analysis.Peaks.Functions.PeakFunction)PeakView.SelectedItem; - - PF.FreeParameters[1] = false; - } - } - else - { - if (RegionView.SelectedIndex != -1) - { - if (EditAktive) - { - Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; + Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; - PRF.FreeParameters[1] = false; - } + PRF.FreeParameters[1] = false; } } } private void FWHMFitActive_Checked(object sender, RoutedEventArgs e) { - if (PeakView.SelectedIndex != -1) + if (RegionView.SelectedIndex != -1) { if (EditAktive) { - Analysis.Peaks.Functions.PeakFunction PF = (Analysis.Peaks.Functions.PeakFunction)PeakView.SelectedItem; - - PF.FreeParameters[0] = true; - } - } - else - { - if (RegionView.SelectedIndex != -1) - { - if (EditAktive) - { - Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; + Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; - PRF.FreeParameters[0] = true; - } + PRF.FreeParameters[0] = true; } } } private void FWHMFitActive_Unchecked(object sender, RoutedEventArgs e) { - if (PeakView.SelectedIndex != -1) + if (RegionView.SelectedIndex != -1) { if (EditAktive) { - Analysis.Peaks.Functions.PeakFunction PF = (Analysis.Peaks.Functions.PeakFunction)PeakView.SelectedItem; - - PF.FreeParameters[0] = false; - } - } - else - { - if (RegionView.SelectedIndex != -1) - { - if (EditAktive) - { - Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; + Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; - PRF.FreeParameters[0] = false; - } + PRF.FreeParameters[0] = false; } } } private void LorentzRatioFitActive_Checked(object sender, RoutedEventArgs e) { - if (PeakView.SelectedIndex != -1) + if (RegionView.SelectedIndex != -1) { if (EditAktive) { - Analysis.Peaks.Functions.PeakFunction PF = (Analysis.Peaks.Functions.PeakFunction)PeakView.SelectedItem; - - PF.FreeParameters[2] = true; - } - } - else - { - if (RegionView.SelectedIndex != -1) - { - if (EditAktive) - { - Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; + Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; - PRF.FreeParameters[2] = true; - } + PRF.FreeParameters[2] = true; } } } private void LorentzRatioFitActive_Unchecked(object sender, RoutedEventArgs e) { - if (PeakView.SelectedIndex != -1) + if (RegionView.SelectedIndex != -1) { if (EditAktive) { - Analysis.Peaks.Functions.PeakFunction PF = (Analysis.Peaks.Functions.PeakFunction)PeakView.SelectedItem; - - PF.FreeParameters[2] = false; - } - } - else - { - if (RegionView.SelectedIndex != -1) - { - if (EditAktive) - { - Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; + Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; - PRF.FreeParameters[2] = false; - } + PRF.FreeParameters[2] = false; } } } @@ -1225,6 +1153,20 @@ private void PeakFunctionBox_SelectionChanged(object sender, SelectionChangedEve Analysis.Peaks.Functions.PeakFunction PF = (Analysis.Peaks.Functions.PeakFunction)PeakView.SelectedItem; PF.functionType = PeakFunctionBox.SelectedIndex; + + PeakView.Items.Refresh(); + + if (RegionView.SelectedIndex != -1) + { + Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; + + System.ComponentModel.BackgroundWorker worker = new System.ComponentModel.BackgroundWorker(); + + worker.DoWork += PlotFittingPatterns_Work; + worker.RunWorkerCompleted += PlotFittingPatterns_Completed; + + worker.RunWorkerAsync(PRF); + } } } } @@ -1267,50 +1209,26 @@ private void IntensityTextBox_TextChanged(object sender, TextChangedEventArgs e) private void IntensityFitActive_Checked(object sender, RoutedEventArgs e) { - if (PeakView.SelectedIndex != -1) + if (RegionView.SelectedIndex != -1) { if (EditAktive) { - Analysis.Peaks.Functions.PeakFunction PF = (Analysis.Peaks.Functions.PeakFunction)PeakView.SelectedItem; - - PF.FreeParameters[3] = true; - } - } - else - { - if (RegionView.SelectedIndex != -1) - { - if (EditAktive) - { - Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; + Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; - PRF.FreeParameters[3] = true; - } + PRF.FreeParameters[3] = true; } } } private void IntensityFitActive_Unchecked(object sender, RoutedEventArgs e) { - if (PeakView.SelectedIndex != -1) + if (RegionView.SelectedIndex != -1) { if (EditAktive) { - Analysis.Peaks.Functions.PeakFunction PF = (Analysis.Peaks.Functions.PeakFunction)PeakView.SelectedItem; - - PF.FreeParameters[3] = false; - } - } - else - { - if (RegionView.SelectedIndex != -1) - { - if (EditAktive) - { - Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; + Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; - PRF.FreeParameters[3] = false; - } + PRF.FreeParameters[3] = false; } } } @@ -1319,15 +1237,15 @@ private void ConstantBackgroundTextBox_TextChanged(object sender, TextChangedEve { if (EditAktive) { - if (PeakView.SelectedIndex != -1) + if (RegionView.SelectedIndex != -1) { try { double NewConstantBackground = Convert.ToDouble(ConstantBackgroundTextBox.Text); - Analysis.Peaks.Functions.PeakFunction PF = (Analysis.Peaks.Functions.PeakFunction)PeakView.SelectedItem; + Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; - PF.ConstantBackground = NewConstantBackground; + PRF.PolynomialBackgroundFunction.Constant = NewConstantBackground; PeakView.Items.Refresh(); } @@ -1335,27 +1253,6 @@ private void ConstantBackgroundTextBox_TextChanged(object sender, TextChangedEve { } - - } - else - { - if (RegionView.SelectedIndex != -1) - { - try - { - double NewConstantBackground = Convert.ToDouble(ConstantBackgroundTextBox.Text); - - Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; - - PRF.PolynomialBackgroundFunction.Constant = NewConstantBackground; - - PeakView.Items.Refresh(); - } - catch - { - - } - } } if (RegionView.SelectedIndex != -1) @@ -1376,17 +1273,15 @@ private void CenterBackgroundTextBox_TextChanged(object sender, TextChangedEvent { if (EditAktive) { - if (PeakView.SelectedIndex != -1) + if (RegionView.SelectedIndex != -1) { - - try { double NewCenterBackground = Convert.ToDouble(CenterBackgroundTextBox.Text); - Analysis.Peaks.Functions.PeakFunction PF = (Analysis.Peaks.Functions.PeakFunction)PeakView.SelectedItem; + Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; - PF.CenterBackground = NewCenterBackground; + PRF.PolynomialBackgroundFunction.Center = NewCenterBackground; PeakView.Items.Refresh(); } @@ -1394,27 +1289,6 @@ private void CenterBackgroundTextBox_TextChanged(object sender, TextChangedEvent { } - - } - else - { - if (RegionView.SelectedIndex != -1) - { - try - { - double NewCenterBackground = Convert.ToDouble(CenterBackgroundTextBox.Text); - - Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; - - PRF.PolynomialBackgroundFunction.Center = NewCenterBackground; - - PeakView.Items.Refresh(); - } - catch - { - - } - } } if (RegionView.SelectedIndex != -1) @@ -1435,17 +1309,15 @@ private void AclivityBackgroundTextBox_TextChanged(object sender, TextChangedEve { if (EditAktive) { - if (PeakView.SelectedIndex != -1) + if (RegionView.SelectedIndex != -1) { - - try { double NewAclivityBackground = Convert.ToDouble(AclivityBackgroundTextBox.Text); - Analysis.Peaks.Functions.PeakFunction PF = (Analysis.Peaks.Functions.PeakFunction)PeakView.SelectedItem; + Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; - PF.AclivityBackground = NewAclivityBackground; + PRF.PolynomialBackgroundFunction.Aclivity = NewAclivityBackground; PeakView.Items.Refresh(); } @@ -1453,27 +1325,6 @@ private void AclivityBackgroundTextBox_TextChanged(object sender, TextChangedEve { } - - } - else - { - if (RegionView.SelectedIndex != -1) - { - try - { - double NewAclivityBackground = Convert.ToDouble(AclivityBackgroundTextBox.Text); - - Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; - - PRF.PolynomialBackgroundFunction.Aclivity = NewAclivityBackground; - - PeakView.Items.Refresh(); - } - catch - { - - } - } } if (RegionView.SelectedIndex != -1) @@ -1492,61 +1343,31 @@ private void AclivityBackgroundTextBox_TextChanged(object sender, TextChangedEve private void ConstantBackgroundFitActive_Checked(object sender, RoutedEventArgs e) { - if (PeakView.SelectedIndex != -1) + if (RegionView.SelectedIndex != -1) { if (EditAktive) { - Analysis.Peaks.Functions.PeakFunction PF = (Analysis.Peaks.Functions.PeakFunction)PeakView.SelectedItem; - - PF.FreeParameters[4] = true; - PF.backgroundFit = true; - } - } - else - { - if (RegionView.SelectedIndex != -1) - { - if (EditAktive) - { - Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; + Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; - PRF.FreeParameters[4] = true; - PRF.backgroundFit = true; - } + PRF.FreeParameters[4] = true; + PRF.backgroundFit = true; } } } private void ConstantBackgroundFitActive_Unchecked(object sender, RoutedEventArgs e) { - if (PeakView.SelectedIndex != -1) + if (RegionView.SelectedIndex != -1) { if (EditAktive) { - Analysis.Peaks.Functions.PeakFunction PF = (Analysis.Peaks.Functions.PeakFunction)PeakView.SelectedItem; + Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; - PF.FreeParameters[4] = false; - if(!PF.FreeParameters[5] && !PF.FreeParameters[6]) + PRF.FreeParameters[4] = false; + if (!PRF.FreeParameters[5] && !PRF.FreeParameters[6]) { - PF.backgroundFit = false; - } - } - } - else - { - if (RegionView.SelectedIndex != -1) - { - if (EditAktive) - { - Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; - - PRF.FreeParameters[4] = false; - if (!PRF.FreeParameters[5] && !PRF.FreeParameters[6]) - { - - PRF.backgroundFit = false; - } + PRF.backgroundFit = false; } } } @@ -1554,61 +1375,31 @@ private void ConstantBackgroundFitActive_Unchecked(object sender, RoutedEventArg private void CenterBackgroundFitActive_Checked(object sender, RoutedEventArgs e) { - if (PeakView.SelectedIndex != -1) + if (RegionView.SelectedIndex != -1) { if (EditAktive) { - Analysis.Peaks.Functions.PeakFunction PF = (Analysis.Peaks.Functions.PeakFunction)PeakView.SelectedItem; - - PF.FreeParameters[5] = true; - PF.backgroundFit = true; - } - } - else - { - if (RegionView.SelectedIndex != -1) - { - if (EditAktive) - { - Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; + Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; - PRF.FreeParameters[5] = true; - PRF.backgroundFit = true; - } + PRF.FreeParameters[5] = true; + PRF.backgroundFit = true; } } } private void CenterBackgroundFitActive_Unchecked(object sender, RoutedEventArgs e) { - if (PeakView.SelectedIndex != -1) + if (RegionView.SelectedIndex != -1) { if (EditAktive) { - Analysis.Peaks.Functions.PeakFunction PF = (Analysis.Peaks.Functions.PeakFunction)PeakView.SelectedItem; - - PF.FreeParameters[5] = false; - if (!PF.FreeParameters[4] && !PF.FreeParameters[6]) - { + Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; - PF.backgroundFit = false; - } - } - } - else - { - if (RegionView.SelectedIndex != -1) - { - if (EditAktive) + PRF.FreeParameters[5] = false; + if (!PRF.FreeParameters[4] && !PRF.FreeParameters[6]) { - Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; - PRF.FreeParameters[5] = false; - if (!PRF.FreeParameters[4] && !PRF.FreeParameters[6]) - { - - PRF.backgroundFit = false; - } + PRF.backgroundFit = false; } } } @@ -1616,61 +1407,31 @@ private void CenterBackgroundFitActive_Unchecked(object sender, RoutedEventArgs private void AclivityBackgroundFitActive_Checked(object sender, RoutedEventArgs e) { - if (PeakView.SelectedIndex != -1) + if (RegionView.SelectedIndex != -1) { if (EditAktive) { - Analysis.Peaks.Functions.PeakFunction PF = (Analysis.Peaks.Functions.PeakFunction)PeakView.SelectedItem; - - PF.FreeParameters[6] = true; - PF.backgroundFit = true; - } - } - else - { - if (RegionView.SelectedIndex != -1) - { - if (EditAktive) - { - Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; + Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; - PRF.FreeParameters[6] = true; - PRF.backgroundFit = true; - } + PRF.FreeParameters[6] = true; + PRF.backgroundFit = true; } } } private void AclivityBackgroundFitActive_Unchecked(object sender, RoutedEventArgs e) { - if (PeakView.SelectedIndex != -1) + if (RegionView.SelectedIndex != -1) { if (EditAktive) { - Analysis.Peaks.Functions.PeakFunction PF = (Analysis.Peaks.Functions.PeakFunction)PeakView.SelectedItem; - - PF.FreeParameters[6] = false; - if (!PF.FreeParameters[4] && !PF.FreeParameters[5]) - { + Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; - PF.backgroundFit = false; - } - } - } - else - { - if (RegionView.SelectedIndex != -1) - { - if (EditAktive) + PRF.FreeParameters[6] = false; + if (!PRF.FreeParameters[4] && !PRF.FreeParameters[5]) { - Analysis.Peaks.Functions.PeakRegionFunction PRF = (Analysis.Peaks.Functions.PeakRegionFunction)RegionView.SelectedItem; - - PRF.FreeParameters[6] = false; - if (!PRF.FreeParameters[4] && !PRF.FreeParameters[5]) - { - PRF.backgroundFit = false; - } + PRF.backgroundFit = false; } } } @@ -2452,7 +2213,7 @@ public void AddRegion(Peaks.Functions.PeakRegionFunction PRF) PRF.backgroundFit = true; PRF.backgroundSwitch = true; - PRF.functionType = 2; + //PRF.functionType = 2; PRF.SetResetEvent(new System.Threading.ManualResetEvent(true)); PRF.startingLambda = -1; @@ -2462,7 +2223,7 @@ public void AddRegion(Peaks.Functions.PeakRegionFunction PRF) for(int n = 0; n < PRF.Count; n++) { - PRF[n].functionType = 2; + //PRF[n].functionType = 2; PRF[n].backgroundSwitch = true; PRF[n].backgroundFit = true; diff --git a/CalScec/Analysis/Peaks/Detection.cs b/CalScec/Analysis/Peaks/Detection.cs index b8fd7e7..8409e79 100644 --- a/CalScec/Analysis/Peaks/Detection.cs +++ b/CalScec/Analysis/Peaks/Detection.cs @@ -299,6 +299,8 @@ public static void CIFDetection(Pattern.DiffractionPattern DP, List CalScec.Properties.Settings.Default.PatternUpperLimit) { StopDegree = CalScec.Properties.Settings.Default.PatternUpperLimit; @@ -356,7 +358,9 @@ public static void PrevPatternDetection(Pattern.DiffractionPattern DP, Pattern.D double dBackground = FittingCounts[0][1]; DiffractionPeak DPeak = new DiffractionPeak(PrevDP.FoundPeaks[n].DetectedChannel, PrevDP.FoundPeaks[n].PFunction.Angle, PrevDP.FoundPeaks[n].PFunction.Intensity, dBackground, FittingCounts); - + DPeak.PFunction.functionType = PrevDP.FoundPeaks[n].PFunction.functionType; + DPeak.PFunction.FWHM = PrevDP.FoundPeaks[n].PFunction.FWHM; + DPeak.PFunction.LorentzRatio = PrevDP.FoundPeaks[n].PFunction.LorentzRatio; DPeak.AddHKLAssociation(PrevDP.FoundPeaks[n].AssociatedHKLReflex, PrevDP.FoundPeaks[n].AssociatedCrystalData); DPeakList.Add(DPeak); diff --git a/CalScec/Analysis/Peaks/Functions/PeakRegionFunction.cs b/CalScec/Analysis/Peaks/Functions/PeakRegionFunction.cs index 4474f9d..7f41c63 100644 --- a/CalScec/Analysis/Peaks/Functions/PeakRegionFunction.cs +++ b/CalScec/Analysis/Peaks/Functions/PeakRegionFunction.cs @@ -90,6 +90,7 @@ public double ReducedChi2Function } public System.Threading.ManualResetEvent _doneEvent; + /// /// If positive this lamdba is used in LMA as starting parameter /// @@ -229,6 +230,86 @@ public double Y(double theta) #region Reduced Hessian + //public MathNet.Numerics.LinearAlgebra.Vector ParameterDeltaVektor(double Lambda) + //{ + // int fitDimension = 0; + // for (int i = 0; i < this.Count; i++) + // { + // for(int j = 0; j < 4; j++) + // { + // if(this[i].FreeParameters[j]) + // { + // fitDimension++; + // } + // } + // } + + // if(this.FreeParameters[4]) + // { + // fitDimension++; + // } + // if (this.FreeParameters[5]) + // { + // fitDimension++; + // } + // if (this.FreeParameters[6]) + // { + // fitDimension++; + // } + + // //[0][0] Sigma + // //[1][1] Angle + // //[2][2] Intensity + // //[3][3] Lorentz Ratio + // // * + // // * + // // * + // //[4][4] Background Constant + // //[5][5] BackgroundCenter + // //[6][6] Background aclivity + // MathNet.Numerics.LinearAlgebra.Matrix HessianMatrix = MathNet.Numerics.LinearAlgebra.CreateMatrix.Dense(fitDimension, fitDimension, 0.0); + + // //[0] Sigma + // //[1] Angle + // //[2] Intensity + // //[3] Lorentz Ratio + // // * + // // * + // // * + // //[4] Background Constant + // //[5] BackgroundCenter + // //[6] Background aclivity + // MathNet.Numerics.LinearAlgebra.Vector SolutionVector = MathNet.Numerics.LinearAlgebra.CreateVector.Dense(fitDimension, 0.0); + + // for (int n = 0; n < this.FittingCounts.Count; n++) + // { + // int parameterIndex = 0; + // for (int i = 0; i < this.Count; i++) + // { + // for (int j = 0; j < 4; j++) + // { + // if (this[i].FreeParameters[j]) + // { + // switch(j) + // { + // case 0: + // HessianMatrix[parameterIndex, parameterIndex] += (this[i].FirstDerivativeSigma(this.FittingCounts[n][0]) * this[j].FirstDerivativeSigma(this.FittingCounts[n][0]) / Math.Pow(this.FittingCounts[n][2], 2)); + // break; + // case 1: + // break; + // case 2: + // break; + // case 3: + // break; + // default: + // break; + // } + // } + // } + // } + // } + //} + /// /// Calculates the Hessian matrix and the solution vecor /// diff --git a/CalScec/Analysis/Sample.cs b/CalScec/Analysis/Sample.cs index 1fcfbd6..ec2e6ca 100644 --- a/CalScec/Analysis/Sample.cs +++ b/CalScec/Analysis/Sample.cs @@ -50,6 +50,8 @@ public int ActualPatterId #region Macro elastic calculations + public List TensileTests = new List(); + public List MacroElasticData = new List(); public List AveragedEModulStandard() @@ -405,47 +407,47 @@ public MathNet.Numerics.LinearAlgebra.Matrix GetOverallCompliances() for (int n = 0; n < this.CrystalData.Count; n++) { - ret[0, 0] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[0, 0]; - ret[0, 1] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[0, 1]; - ret[0, 2] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[0, 2]; - ret[0, 3] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[0, 3]; - ret[0, 4] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[0, 4]; - ret[0, 5] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[0, 5]; - - ret[1, 0] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[1, 0]; - ret[1, 1] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[1, 1]; - ret[1, 2] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[1, 2]; - ret[1, 3] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[1, 3]; - ret[1, 4] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[1, 4]; - ret[1, 5] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[1, 5]; - - ret[2, 0] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[2, 0]; - ret[2, 1] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[2, 1]; - ret[2, 2] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[2, 2]; - ret[2, 3] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[2, 3]; - ret[2, 4] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[2, 4]; - ret[2, 5] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[2, 5]; - - ret[3, 0] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[3, 0]; - ret[3, 1] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[3, 1]; - ret[3, 2] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[3, 2]; - ret[3, 3] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[3, 3]; - ret[3, 4] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[3, 4]; - ret[3, 5] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[3, 5]; - - ret[4, 0] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[4, 0]; - ret[4, 1] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[4, 1]; - ret[4, 2] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[4, 2]; - ret[4, 3] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[4, 3]; - ret[4, 4] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[4, 4]; - ret[4, 5] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[4, 5]; - - ret[5, 0] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[5, 0]; - ret[5, 1] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[5, 1]; - ret[5, 2] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[5, 2]; - ret[5, 3] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[5, 3]; - ret[5, 4] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[5, 4]; - ret[5, 5] += this.CrystalData[n].PhaseFraction * this.HillTensorData[n]._complianceTensor[5, 5]; + ret[0, 0] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[0, 0]; + ret[0, 1] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[0, 1]; + ret[0, 2] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[0, 2]; + ret[0, 3] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[0, 3]; + ret[0, 4] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[0, 4]; + ret[0, 5] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[0, 5]; + + ret[1, 0] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[1, 0]; + ret[1, 1] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[1, 1]; + ret[1, 2] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[1, 2]; + ret[1, 3] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[1, 3]; + ret[1, 4] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[1, 4]; + ret[1, 5] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[1, 5]; + + ret[2, 0] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[2, 0]; + ret[2, 1] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[2, 1]; + ret[2, 2] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[2, 2]; + ret[2, 3] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[2, 3]; + ret[2, 4] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[2, 4]; + ret[2, 5] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[2, 5]; + + ret[3, 0] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[3, 0]; + ret[3, 1] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[3, 1]; + ret[3, 2] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[3, 2]; + ret[3, 3] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[3, 3]; + ret[3, 4] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[3, 4]; + ret[3, 5] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[3, 5]; + + ret[4, 0] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[4, 0]; + ret[4, 1] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[4, 1]; + ret[4, 2] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[4, 2]; + ret[4, 3] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[4, 3]; + ret[4, 4] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[4, 4]; + ret[4, 5] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[4, 5]; + + ret[5, 0] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[5, 0]; + ret[5, 1] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[5, 1]; + ret[5, 2] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[5, 2]; + ret[5, 3] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[5, 3]; + ret[5, 4] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[5, 4]; + ret[5, 5] += this.CrystalData[n].PhaseFraction * this.ReussTensorData[n]._complianceTensor[5, 5]; } @@ -505,6 +507,7 @@ public void SetStressTransitionFactors(int matrix, int inclusion, bool sphere) { eshelbyTensor = this.GetEshelbyTensorSpherical(matrix); } + MathNet.Numerics.LinearAlgebra.Matrix sampleCompliances = this.GetOverallCompliances(); MathNet.Numerics.LinearAlgebra.Matrix sampleStiffnesses = sampleCompliances.Inverse(); MathNet.Numerics.LinearAlgebra.Matrix unity = MathNet.Numerics.LinearAlgebra.CreateMatrix.Dense(6, 6, 0.0); @@ -514,15 +517,37 @@ public void SetStressTransitionFactors(int matrix, int inclusion, bool sphere) unity[3, 3] = 1.0; unity[4, 4] = 1.0; unity[5, 5] = 1.0; - + MathNet.Numerics.LinearAlgebra.Matrix first = -1 * sampleStiffnesses * (eshelbyTensor - unity); - MathNet.Numerics.LinearAlgebra.Matrix second = (this.HillTensorData[inclusion]._stiffnessTensor - sampleStiffnesses) * eshelbyTensor; + MathNet.Numerics.LinearAlgebra.Matrix second = (this.ReussTensorData[inclusion]._stiffnessTensor - sampleStiffnesses) * eshelbyTensor; second += sampleStiffnesses; - MathNet.Numerics.LinearAlgebra.Matrix third = (this.HillTensorData[inclusion]._stiffnessTensor - sampleStiffnesses) * sampleCompliances; + MathNet.Numerics.LinearAlgebra.Matrix third = (this.ReussTensorData[inclusion]._stiffnessTensor - sampleStiffnesses) * sampleCompliances; MathNet.Numerics.LinearAlgebra.Matrix ret1 = first * second.Inverse() * third; ret1 += unity; + Tools.FourthRankTensor eshelbyTensorFR = new Tools.FourthRankTensor(eshelbyTensor); + Tools.FourthRankTensor sampleCompliancesFR = new Tools.FourthRankTensor(sampleCompliances); + Tools.FourthRankTensor sampleStiffnessesFR = new Tools.FourthRankTensor(sampleStiffnesses); + Tools.FourthRankTensor unityFR = Tools.FourthRankTensor.GetUnityTensor(); + Tools.FourthRankTensor phaseStiffnessesFR = new Tools.FourthRankTensor(this.ReussTensorData[inclusion]._stiffnessTensor); + + Tools.FourthRankTensor firstFR = -1.0 * sampleStiffnessesFR * (eshelbyTensorFR - unityFR); + Tools.FourthRankTensor secondFR = (phaseStiffnessesFR - sampleStiffnessesFR) * eshelbyTensorFR; + secondFR += sampleStiffnessesFR; + Tools.FourthRankTensor thirdFR = (phaseStiffnessesFR - sampleStiffnessesFR) * sampleCompliancesFR; + + MathNet.Numerics.LinearAlgebra.Matrix firstComp = firstFR.GetVoigtTensor(); + MathNet.Numerics.LinearAlgebra.Matrix secondComp = secondFR.GetVoigtTensor(); + MathNet.Numerics.LinearAlgebra.Matrix thirdComp = thirdFR.GetVoigtTensor(); + + Tools.FourthRankTensor secondInverseFR = new Tools.FourthRankTensor(secondComp.Inverse()); + + Tools.FourthRankTensor ret1FR = firstFR * secondInverseFR * thirdFR; + ret1FR += unityFR; + + MathNet.Numerics.LinearAlgebra.Matrix ret1Comp = ret1FR.GetVoigtTensor(); + MathNet.Numerics.LinearAlgebra.Matrix ret2 = MathNet.Numerics.LinearAlgebra.CreateMatrix.Dense(6, 6, 0.0); ret2[0, 0] = 1 - (this.CrystalData[inclusion].PhaseFraction * ret1[0, 0]); @@ -588,14 +613,14 @@ public MathNet.Numerics.LinearAlgebra.Matrix GetEshelbyTensorSpherical(i { MathNet.Numerics.LinearAlgebra.Matrix ret = MathNet.Numerics.LinearAlgebra.CreateMatrix.Dense(6, 6, 0.0); - double e11 = 7 - (5 * this.ReussTensorData[matrix].AveragedNu); - e11 /= 15 * (1 - this.ReussTensorData[matrix].AveragedNu); + double e11 = 7 - (5 * this.HillTensorData[matrix].AveragedNu); + e11 /= 15 * (1 - this.HillTensorData[matrix].AveragedNu); - double e12 = -1 + (5 * this.ReussTensorData[matrix].AveragedNu); - e12 /= 15 * (1 - this.ReussTensorData[matrix].AveragedNu); + double e12 = -1 + (5 * this.HillTensorData[matrix].AveragedNu); + e12 /= 15 * (1 - this.HillTensorData[matrix].AveragedNu); - double e66 = 4 - (5 * this.ReussTensorData[matrix].AveragedNu); - e66 /= 15 * (1 - this.ReussTensorData[matrix].AveragedNu); + double e66 = 4 - (5 * this.HillTensorData[matrix].AveragedNu); + e66 /= 15 * (1 - this.HillTensorData[matrix].AveragedNu); ret[0, 0] = e11; ret[1, 1] = e11; @@ -1070,1385 +1095,2601 @@ public MathNet.Numerics.LinearAlgebra.Vector ParameterDeltaVektorReussFr #region Elasto plastic self consistent - #region Parameter + #region Simulation Multi threading - public List SimulationData = new List(); + #region Simulation using Multi Threading - public List> appliedSampleStressHistory = new List>(); + public System.Threading.ManualResetEvent _doneEvent; - public MathNet.Numerics.LinearAlgebra.Matrix StrainRate = MathNet.Numerics.LinearAlgebra.CreateMatrix.Dense(3, 3, 0.0); - - public List PlasticTensor = new List(); + public event System.ComponentModel.PropertyChangedEventHandler FitFinished; + public event System.ComponentModel.PropertyChangedEventHandler FitStarted; - public void SetYieldExperimentalData() + protected void OnElastoPlasticSimulationStarted() + { + System.ComponentModel.PropertyChangedEventHandler handler = FitStarted; + if (handler != null) + { + handler(this, new System.ComponentModel.PropertyChangedEventArgs("Simulation Started")); + } + } + + protected void OnElastoPlasticSimulationFinished() + { + this._doneEvent.Set(); + + System.ComponentModel.PropertyChangedEventHandler handler = FitFinished; + if (handler != null) + { + handler(this, new System.ComponentModel.PropertyChangedEventArgs("Simulation Finished")); + } + } + + // Wrapper method for use with thread pool. + public void FitRegionCallback(Object threadContext) + { + OnElastoPlasticSimulationStarted(); + + + + OnElastoPlasticSimulationFinished(); + } + + public void SetResetEvent(System.Threading.ManualResetEvent DoneEvent) + { + this._doneEvent = DoneEvent; + } + + + #endregion + + #endregion + + #region Parameter + + /// + /// Alle experimentellen Reflexe sortiert nach [Phase][Orientierung (z.B.100)][Psi Orientierung][gemessener Reflex] + /// + public List>>> SortedExperimentalPeakData = new List>>>(); + + public void SetExperimentalData() { + List> preDEC = new List>(); for (int n = 0; n < this.CrystalData.Count; n++) { - for (int i = 0; i < this.PlasticTensor[n].YieldSurfaceData.ReflexYieldData.Count; i++) + List phaseDEC = new List(); + + for (int i = 0; i < this.CrystalData[n].HKLList.Count; i++) { + Stress.Microsopic.REK ActualREK = new Stress.Microsopic.REK(this.CrystalData[n], this.CrystalData[n].HKLList[i]); + for (int j = 0; j < this.DiffractionPatterns.Count; j++) { for (int k = 0; k < this.DiffractionPatterns[j].FoundPeaks.Count; k++) { if (this.DiffractionPatterns[j].FoundPeaks[k].AssociatedCrystalData.SymmetryGroupID == this.CrystalData[n].SymmetryGroupID) { - if (this.DiffractionPatterns[j].FoundPeaks[k].AssociatedHKLReflex.HKLString == this.PlasticTensor[n].YieldSurfaceData.ReflexYieldData[i].HKLString) + if (this.DiffractionPatterns[j].FoundPeaks[k].AssociatedHKLReflex.HKLString == this.CrystalData[n].HKLList[i].HKLString) { Stress.Macroskopic.PeakStressAssociation NewAssociation = new Stress.Macroskopic.PeakStressAssociation(this.DiffractionPatterns[j].Stress, this.DiffractionPatterns[j].PsiAngle(this.DiffractionPatterns[j].FoundPeaks[k].Angle), this.DiffractionPatterns[j].FoundPeaks[k], this.DiffractionPatterns[j].PhiAngle(this.DiffractionPatterns[j].FoundPeaks[k].Angle)); NewAssociation._macroskopicStrain = this.DiffractionPatterns[j].MacroStrain; - this.PlasticTensor[n].YieldSurfaceData.ReflexYieldData[i].StressStrainData.Add(NewAssociation); + ActualREK.ElasticStressData.Add(NewAssociation); } } } } + if (ActualREK.ElasticStressData.Count != 0) + { + phaseDEC.Add(ActualREK); + } } - } - } - #endregion + preDEC.Add(phaseDEC); + } - #region Data display + SortedExperimentalPeakData.Clear(); - public Pattern.Counts SampleStrainOverSampleStrainData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment) - { - Pattern.Counts ret = new Pattern.Counts(); - - for (int n = 0; n < SimulationData[experiment].StrainSFHistory.Count; n++) + for (int phase = 0; phase < CrystalData.Count; phase++) { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainSFHistory[n] * direction1.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainSFHistory[n] * direction2.Direction; - - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); - } + List>> sortedData = new List>>(); - return ret; - } - public Pattern.Counts SampleStrainOverGrainStrainData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); + for (int n = 0; n < preDEC[phase].Count; n++) + { + List> orientationPre = new List>(); - for (int n = 0; n < SimulationData[experiment].StrainSFHistory.Count; n++) - { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainCFHistory[phase][n] * direction2.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainSFHistory[n] * direction1.Direction; + for (int i = 0; i < preDEC[phase][n].ElasticStressData.Count; i++) + { + bool newPsyAngle = true; + for (int j = 0; j < orientationPre.Count; j++) + { + if (Math.Abs(orientationPre[j][0].PsiAngle - preDEC[phase][n].ElasticStressData[i].PsiAngle) < CalScec.Properties.Settings.Default.PsyAcceptanceAngle) + { + orientationPre[j].Add(preDEC[phase][n].ElasticStressData[i]); + newPsyAngle = false; + break; + } + } - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); - } + if (newPsyAngle) + { + List tmp = new List(); + tmp.Add(preDEC[phase][n].ElasticStressData[i]); + orientationPre.Add(tmp); + } + } - return ret; - } - public Pattern.Counts SampleStrainOverSampleStressData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment) - { - Pattern.Counts ret = new Pattern.Counts(); + sortedData.Add(orientationPre); - for (int n = 0; n < SimulationData[experiment].StrainSFHistory.Count; n++) - { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StressSFHistory[n] * direction2.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainSFHistory[n] * direction1.Direction; + } - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); + SortedExperimentalPeakData.Add(sortedData); } - return ret; - } - public Pattern.Counts SampleStrainOverGrainStressData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); + #region OldStuff + //for (int phase = 0; phase < CrystalData.Count; phase++) + //{ + // List>> sortedData = new List>>(); - for (int n = 0; n < SimulationData[experiment].StrainSFHistory.Count; n++) - { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StressCFHistory[phase][n] * direction2.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainSFHistory[n] * direction1.Direction; + // for(int n = 0; n < this.DiffractionConstants[phase].Count; n++) + // { + // List> orientationPre = new List>(); - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); - } + // for(int i = 0; i < this.DiffractionConstants[phase][n].ElasticStressData.Count; i++) + // { + // bool newPsyAngle = true; + // for(int j = 0; j < orientationPre.Count; j++) + // { + // if(Math.Abs(orientationPre[j][0].PsiAngle - this.DiffractionConstants[phase][n].ElasticStressData[i].PsiAngle) < CalScec.Properties.Settings.Default.PsyAcceptanceAngle) + // { + // orientationPre[j].Add(this.DiffractionConstants[phase][n].ElasticStressData[i]); + // newPsyAngle = false; + // break; + // } + // } - return ret; - } - public Pattern.Counts SampleStrainOverGrainShearStressData(DataManagment.CrystalData.HKLReflex direction1, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); + // if(newPsyAngle) + // { + // List tmp = new List(); + // tmp.Add(this.DiffractionConstants[phase][n].ElasticStressData[i]); + // orientationPre.Add(tmp); + // } + // } - for (int n = 0; n < SimulationData[experiment].StrainSFHistory.Count; n++) - { - double directionValueX = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressCFHistory[phase][n]); - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainSFHistory[n] * direction1.Direction; + // sortedData.Add(orientationPre); - double[] tmp = { directionValueX, directionValueY.L2Norm() }; - ret.Add(tmp); - } + // } - return ret; + // SortedExperimentalPeakData.Add(sortedData); + //} + + #endregion } - public Pattern.Counts SampleStrainOverSampleShearStresData(DataManagment.CrystalData.HKLReflex direction1, int experiment) - { - Pattern.Counts ret = new Pattern.Counts(); - for (int n = 0; n < SimulationData[experiment].StrainSFHistory.Count; n++) + public void SetExperimentalStrainData() + { + for (int phase = 0; phase < CrystalData.Count; phase++) { - double directionValueX = this.PlasticTensor[0].YieldSurfaceData.Shearforce(SimulationData[experiment].StressSFHistory[n]); - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainSFHistory[n] * direction1.Direction; - - double[] tmp = { directionValueX, directionValueY.L2Norm() }; - ret.Add(tmp); + for(int n = 0; n < SortedExperimentalPeakData[phase].Count; n++) + { + for (int i = 0; i < SortedExperimentalPeakData[phase][n].Count; i++) + { + for (int j = 0; j < SortedExperimentalPeakData[phase][n][i].Count; j++) + { + SortedExperimentalPeakData[phase][n][i][j].Strain = (SortedExperimentalPeakData[phase][n][i][j].DifPeak.LatticeDistance - SortedExperimentalPeakData[phase][n][i][0].DifPeak.LatticeDistance) / SortedExperimentalPeakData[phase][n][i][0].DifPeak.LatticeDistance; + } + } + } } - - return ret; } - public Pattern.Counts SampleStrainOverSampleStrainRateData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment) - { - Pattern.Counts ret = new Pattern.Counts(); - for (int n = 0; n < SimulationData[experiment].StrainSFHistory.Count; n++) - { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainRateSFHistory[n] * direction1.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainSFHistory[n] * direction2.Direction; + public List SimulationData = new List(); - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); - } + //public List> appliedSampleStressHistory = new List>(); + //public MathNet.Numerics.LinearAlgebra.Matrix StrainRate = MathNet.Numerics.LinearAlgebra.CreateMatrix.Dense(3, 3, 0.0); + + public List PlasticTensor = new List(); - return ret; - } - public Pattern.Counts SampleStrainOverGrainStrainRateData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment, int phase) + public void SetYieldExperimentalData() { - Pattern.Counts ret = new Pattern.Counts(); - - for (int n = 0; n < SimulationData[experiment].StrainSFHistory.Count; n++) + for (int n = 0; n < this.CrystalData.Count; n++) { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainRateCFHistory[phase][n] * direction2.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainSFHistory[n] * direction1.Direction; - - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); + for (int i = 0; i < this.PlasticTensor[n].YieldSurfaceData.ReflexYieldData.Count; i++) + { + for (int j = 0; j < this.DiffractionPatterns.Count; j++) + { + for (int k = 0; k < this.DiffractionPatterns[j].FoundPeaks.Count; k++) + { + if (this.DiffractionPatterns[j].FoundPeaks[k].AssociatedCrystalData.SymmetryGroupID == this.CrystalData[n].SymmetryGroupID) + { + if (this.DiffractionPatterns[j].FoundPeaks[k].AssociatedHKLReflex.HKLString == this.PlasticTensor[n].YieldSurfaceData.ReflexYieldData[i].HKLString) + { + Stress.Macroskopic.PeakStressAssociation NewAssociation = new Stress.Macroskopic.PeakStressAssociation(this.DiffractionPatterns[j].Stress, this.DiffractionPatterns[j].PsiAngle(this.DiffractionPatterns[j].FoundPeaks[k].Angle), this.DiffractionPatterns[j].FoundPeaks[k], this.DiffractionPatterns[j].PhiAngle(this.DiffractionPatterns[j].FoundPeaks[k].Angle)); + NewAssociation._macroskopicStrain = this.DiffractionPatterns[j].MacroStrain; + this.PlasticTensor[n].YieldSurfaceData.ReflexYieldData[i].StressStrainData.Add(NewAssociation); + } + } + } + } + } } - - return ret; } - public Pattern.Counts GrainStrainOverSampleStrainData(DataManagment.CrystalData.HKLReflex macroDirection, DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) + public Tools.FourthRankTensor GetSampleCompliances(bool textureActive) { - Pattern.Counts ret = new Pattern.Counts(); + List phaseOCompliances = new List(); - for (int n = 0; n < SimulationData[experiment].StrainCFHistory[phase].Count; n++) + for(int n = 0; n < this.ODFList.Count; n++) { - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainCFHistory[phase][n] * microDirection.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainSFHistory[n] * macroDirection.Direction; - - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); + if (textureActive) + { + //this.ODFList[n].SetTextureTensor(); + } + else + { + phaseOCompliances.Add(this.SetTextureTensorIso(this.HillTensorData[n]).GetFourtRankStiffnesses()); + } } - return ret; - } - public Pattern.Counts GrainStrainOverGrainStrainData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); + Tools.FourthRankTensor ret = new Tools.FourthRankTensor(); - for (int n = 0; n < SimulationData[experiment].StrainCFHistory[phase].Count; n++) + for (int n = 0; n < this.CrystalData.Count; n++) { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainCFHistory[phase][n] * direction1.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainCFHistory[phase][n] * direction2.Direction; - - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); + ret += this.CrystalData[n].PhaseFraction * phaseOCompliances[n]; } + //ret /= phaseOCompliances.Count; + return ret; } - public Pattern.Counts GrainStrainOverSampleStressData(DataManagment.CrystalData.HKLReflex macroDirection, DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); - for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) + public Tools.FourthRankTensor GetSampleCompliances(int grainModel) + { + List phaseCompliances = new List(); + for (int n = 0; n < this.CrystalData.Count; n++) { - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainCFHistory[phase][n] * microDirection.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StressSFHistory[n] * macroDirection.Direction; - - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); + switch (grainModel) + { + case 0: + phaseCompliances.Add(this.SetTextureTensorIso(this.ReussTensorData[n]).GetFourtRankCompliances()); + break; + case 1: + phaseCompliances.Add(this.SetTextureTensorIso(this.HillTensorData[n]).GetFourtRankCompliances()); + break; + case 2: + phaseCompliances.Add(this.SetTextureTensorIso(this.KroenerTensorData[n]).GetFourtRankCompliances()); + break; + case 3: + phaseCompliances.Add(this.SetTextureTensorIso(this.DeWittTensorData[n]).GetFourtRankCompliances()); + break; + case 4: + phaseCompliances.Add(this.SetTextureTensorIso(this.GeometricHillTensorData[n]).GetFourtRankCompliances()); + break; + default: + phaseCompliances.Add(this.SetTextureTensorIso(this.HillTensorData[n]).GetFourtRankCompliances()); + break; + } } - - return ret; - } - public Pattern.Counts GrainStrainOverGrainStressData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); - - for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) + Tools.FourthRankTensor ret = new Tools.FourthRankTensor(); + for (int n = 0; n < this.CrystalData.Count; n++) { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StressCFHistory[phase][n] * direction2.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainCFHistory[phase][n] * direction1.Direction; - - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); + ret += this.CrystalData[n].PhaseFraction * phaseCompliances[n]; } return ret; } - public Pattern.Counts GrainStrainOverGrainShearStressData(DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); - for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) + public Tools.FourthRankTensor GetSampleStiffnesses(bool textureActive) + { + List phaseOStiffnesses = new List(); + + for (int n = 0; n < this.HillTensorData.Count; n++) { - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainCFHistory[phase][n] * microDirection.Direction; - double directionValueX = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressCFHistory[phase][n]); + if (textureActive) + { + //this.ODFList[n].SetTextureTensor(); + } + else + { + phaseOStiffnesses.Add(this.SetTextureTensorIso(this.HillTensorData[n]).GetFourtRankStiffnesses()); + } + } + + Tools.FourthRankTensor ret = new Tools.FourthRankTensor(); - double[] tmp = { directionValueX, directionValueY.L2Norm() }; - ret.Add(tmp); + for (int n = 0; n < phaseOStiffnesses.Count; n++) + { + ret += this.CrystalData[n].PhaseFraction * phaseOStiffnesses[n]; } + ret /= phaseOStiffnesses.Count; + return ret; } - public Pattern.Counts GrainStrainOverSampleShearStressData(DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) + public Tools.FourthRankTensor GetSampleStiffnesses(bool textureActive, List tensorData) { - Pattern.Counts ret = new Pattern.Counts(); + List phaseOStiffnesses = new List(); - for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) + for (int n = 0; n < tensorData.Count; n++) { - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainCFHistory[phase][n] * microDirection.Direction; - double directionValueX = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressSFHistory[n]); - - double[] tmp = { directionValueX, directionValueY.L2Norm() }; - ret.Add(tmp); + if (textureActive) + { + //this.ODFList[n].SetTextureTensor(); + } + else + { + phaseOStiffnesses.Add(this.SetTextureTensorIso(tensorData[n]).GetFourtRankStiffnesses()); + } } - return ret; - } - public Pattern.Counts GrainStrainOverSampleStrainRateData(DataManagment.CrystalData.HKLReflex macroDirection, DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); + Tools.FourthRankTensor ret = new Tools.FourthRankTensor(); - for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) + for (int n = 0; n < phaseOStiffnesses.Count; n++) { - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainCFHistory[phase][n] * microDirection.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainRateSFHistory[n] * macroDirection.Direction; - - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); + ret += phaseOStiffnesses[n]; } + ret /= phaseOStiffnesses.Count; + return ret; } - public Pattern.Counts GrainStrainOverGrainStrainRateData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment, int phase) + + #region Averaging + + public Stress.Microsopic.ElasticityTensors SetTextureTensorIso(Stress.Microsopic.ElasticityTensors averagingTensor) { - Pattern.Counts ret = new Pattern.Counts(); + Stress.Microsopic.ElasticityTensors ret = averagingTensor.Clone() as Stress.Microsopic.ElasticityTensors; - for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) + switch (averagingTensor.Symmetry) { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainCFHistory[phase][n] * direction1.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateCFHistory[phase][n] * direction2.Direction; + case "cubic": + ret = this.SetTextureTensorCubicIso(averagingTensor); + break; + case "hexagonal": + ret = this.SetTextureTensorHexagonalIso(averagingTensor); + break; + case "tetragonal type 1": + ret = this.SetTextureTensorTetragonalType1Iso(averagingTensor); + break; + case "tetragonal type 2": - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); - } + break; + case "trigonal type 1": - return ret; - } + break; + case "trigonal type 2": - public Pattern.Counts SampleStressOverSampleStrainData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment) - { - Pattern.Counts ret = new Pattern.Counts(); + break; + case "rhombic": + ret = this.SetTextureTensorRhombicIso(averagingTensor); + break; + case "monoclinic": - for (int n = 0; n < SimulationData[experiment].StressSFHistory.Count; n++) - { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainSFHistory[n] * direction2.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StressSFHistory[n] * direction1.Direction; + break; + case "triclinic": + + break; + default: - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); + break; } + ret.CalculateCompliances(); + return ret; } - public Pattern.Counts SampleStressOverGrainStrainData(DataManagment.CrystalData.HKLReflex macroDirection, DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) + + public Stress.Microsopic.ElasticityTensors SetTextureTensorCubicIso(Stress.Microsopic.ElasticityTensors averagingTensor) { - Pattern.Counts ret = new Pattern.Counts(); + double TC11 = 0; + double TC12 = 0; + double TC44 = 0; - for (int n = 0; n < SimulationData[experiment].StressSFHistory.Count; n++) + double normFactor = 0.0; + + for (double phi1 = 0.0; phi1 < 360.0; phi1 += 5.0) { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainCFHistory[phase][n] * microDirection.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StressSFHistory[n] * macroDirection.Direction; + for (double psi1 = 0.0; psi1 < 360.0; psi1 += 5.0) + { + for (double phi2 = 0.0; phi2 < 360.0; phi2 += 5.0) + { + normFactor++; + + TC11 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 4) * averagingTensor.C11; + TC11 += Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 4) * averagingTensor.C22; + TC11 += Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 4) * averagingTensor.C33; + + TC11 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * averagingTensor.C12; + TC11 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * averagingTensor.C13; + TC11 += Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * averagingTensor.C23; + + TC11 += Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * averagingTensor.C44; + TC11 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * averagingTensor.C55; + TC11 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * averagingTensor.C66; + //TC11 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * averagingTensor.C12; + //TC11 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * averagingTensor.C13; + //TC11 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * averagingTensor.C23; + + //TC11 += 4 * Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * averagingTensor.C44; + //TC11 += 4 * Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * averagingTensor.C55; + //TC11 += 4 * Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * averagingTensor.C66; + + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * averagingTensor.C11; + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * averagingTensor.C22; + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2), 2) * averagingTensor.C33; + + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * averagingTensor.C12; + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * averagingTensor.C12; + + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2), 2) * averagingTensor.C13; + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * averagingTensor.C13; + + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2), 2) * averagingTensor.C23; + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * averagingTensor.C23; + + TC12 += Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * averagingTensor.C44; + TC12 += Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * averagingTensor.C55; + TC12 += Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * averagingTensor.C66; + //TC12 += 4 * Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * averagingTensor.C44; + //TC12 += 4 * Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * averagingTensor.C55; + //TC12 += 4 * Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * averagingTensor.C66; + + TC44 += Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * averagingTensor.C11; + TC44 += Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * averagingTensor.C22; + TC44 += Math.Pow(Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C33; + + TC44 += Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * averagingTensor.C12; + TC44 += Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * averagingTensor.C13; + TC44 += Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * averagingTensor.C23; + //TC44 += 2 * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * averagingTensor.C12; + //TC44 += 2 * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * averagingTensor.C13; + //TC44 += 2 * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * averagingTensor.C23; + + TC44 += Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C44; + TC44 += Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * averagingTensor.C44; + //TC44 += 2 * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * averagingTensor.C44; + TC44 += Math.Pow(Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * averagingTensor.C44; + + TC44 += Math.Pow(Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * averagingTensor.C55; + TC44 += Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * averagingTensor.C55; + //TC44 += 2 * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * averagingTensor.C55; + TC44 += Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C55; + + TC44 += Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * averagingTensor.C66; + TC44 += Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * averagingTensor.C66; + //TC44 += 2 * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * averagingTensor.C66; + TC44 += Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * averagingTensor.C66; - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); + } + } } + + Stress.Microsopic.ElasticityTensors ret = averagingTensor.Clone() as Stress.Microsopic.ElasticityTensors; + + ret.C11 = (TC11 / normFactor); + ret.C12 = (TC12 / normFactor); + ret.C44 = (TC44 / normFactor); return ret; } - public Pattern.Counts SampleStressOverSampleStressData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment) + + private Stress.Microsopic.ElasticityTensors SetTextureTensorHexagonalIso(Stress.Microsopic.ElasticityTensors averagingTensor) { - Pattern.Counts ret = new Pattern.Counts(); + double TC11 = 0; + double TC33 = 0; + double TC12 = 0; + double TC13 = 0; + double TC44 = 0; - for (int n = 0; n < SimulationData[experiment].StressSFHistory.Count; n++) - { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StressSFHistory[n] * direction1.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StressSFHistory[n] * direction2.Direction; + double normFactor = 0.0; - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); + for (double phi1 = 0.0; phi1 < 360.0; phi1 += 5.0) + { + for (double psi1 = 0.0; psi1 < 360.0; psi1 += 5.0) + { + for (double phi2 = 0.0; phi2 < 360.0; phi2 += 5.0) + { + normFactor++; + + TC11 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 4) * averagingTensor.C11; + TC11 += Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 4) * averagingTensor.C22; + TC11 += Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 4) * averagingTensor.C33; + + TC11 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * averagingTensor.C12; + TC11 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * averagingTensor.C13; + TC11 += Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * averagingTensor.C23; + //TC11 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * averagingTensor.C12; + //TC11 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * averagingTensor.C13; + //TC11 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * averagingTensor.C23; + + TC11 += Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * averagingTensor.C44; + TC11 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * averagingTensor.C55; + TC11 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * averagingTensor.C66; + //TC11 += 4 * Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * averagingTensor.C44; + //TC11 += 4 * Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * averagingTensor.C55; + //TC11 += 4 * Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * averagingTensor.C66; + + TC33 += Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 4) * averagingTensor.C11; + TC33 += Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 4) * averagingTensor.C22; + TC33 += Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 4) * averagingTensor.C33; + + TC33 += Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * averagingTensor.C12; + TC33 += Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C13; + TC33 += Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C23; + //TC33 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * averagingTensor.C12; + //TC33 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C13; + //TC33 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C23; + + TC33 += Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C44; + TC33 += Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C55; + TC33 += Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * averagingTensor.C66; + //TC33 += 4 * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C44; + //TC33 += 4 * Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C55; + //TC33 += 4 * Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * averagingTensor.C66; + + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * averagingTensor.C11; + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * averagingTensor.C22; + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2), 2) * averagingTensor.C33; + + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * averagingTensor.C12; + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * averagingTensor.C12; + + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2), 2) * averagingTensor.C13; + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * averagingTensor.C13; + + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2), 2) * averagingTensor.C23; + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * averagingTensor.C23; + + TC12 += Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * averagingTensor.C44; + TC12 += Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * averagingTensor.C55; + TC12 += Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * averagingTensor.C66; + //TC12 += 4 * Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * averagingTensor.C44; + //TC12 += 4 * Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * averagingTensor.C55; + //TC12 += 4 * Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * averagingTensor.C66; + + TC13 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * averagingTensor.C11; + TC13 += Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * averagingTensor.C22; + TC13 += Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C33; + + TC13 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * averagingTensor.C12; + TC13 += Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * averagingTensor.C12; + + TC13 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C13; + TC13 += Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * averagingTensor.C13; + + TC13 += Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C23; + TC13 += Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * averagingTensor.C23; + + TC13 += Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * averagingTensor.C44; + TC13 += Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * averagingTensor.C55; + TC13 += Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * averagingTensor.C66; + //TC13 += 4 * Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * averagingTensor.C44; + //TC13 += 4 * Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * averagingTensor.C55; + //TC13 += 4 * Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * averagingTensor.C66; + + TC44 += Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * averagingTensor.C11; + TC44 += Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * averagingTensor.C22; + TC44 += Math.Pow(Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C22; + + TC44 += Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * averagingTensor.C12; + TC44 += Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * averagingTensor.C13; + TC44 += Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * averagingTensor.C23; + + TC44 += Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C44; + TC44 += Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * averagingTensor.C44; + + TC44 += Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C55; + TC44 += Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * averagingTensor.C55; + + TC44 += Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * averagingTensor.C66; + TC44 += Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * averagingTensor.C66; + //TC44 += 2 * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * averagingTensor.C12; + //TC44 += 2 * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * averagingTensor.C13; + //TC44 += 2 * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * averagingTensor.C23; + + //TC44 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C44; + //TC44 += 2 * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * averagingTensor.C44; + + //TC44 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C55; + //TC44 += 2 * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * averagingTensor.C55; + + //TC44 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * averagingTensor.C66; + //TC44 += 2 * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * averagingTensor.C66; + } + } } + Stress.Microsopic.ElasticityTensors ret = averagingTensor.Clone() as Stress.Microsopic.ElasticityTensors; + + ret.C11 = TC11 / normFactor; + ret.C33 = TC33 / normFactor; + ret.C12 = TC12 / normFactor; + ret.C13 = TC13 / normFactor; + ret.C44 = TC44 / normFactor; + return ret; } - public Pattern.Counts SampleStressOverGrainStressData(DataManagment.CrystalData.HKLReflex macroDirection, DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) + + private Stress.Microsopic.ElasticityTensors SetTextureTensorTetragonalType1Iso(Stress.Microsopic.ElasticityTensors averagingTensor) { - Pattern.Counts ret = new Pattern.Counts(); + double TC11 = 0; + double TC33 = 0; + double TC12 = 0; + double TC13 = 0; + double TC44 = 0; + double TC66 = 0; + + double normFactor = 0.0; - for (int n = 0; n < SimulationData[experiment].StressSFHistory.Count; n++) + for (double phi1 = 0.0; phi1 < 360.0; phi1 += 5.0) { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StressCFHistory[phase][n] * microDirection.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StressSFHistory[n] * macroDirection.Direction; + for (double psi1 = 0.0; psi1 < 360.0; psi1 += 5.0) + { + for (double phi2 = 0.0; phi2 < 360.0; phi2 += 5.0) + { + normFactor++; - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); - } + TC11 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 4) * averagingTensor.C11; + TC11 += Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 4) * averagingTensor.C22; + TC11 += Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 4) * averagingTensor.C33; - return ret; - } - public Pattern.Counts SampleStressOverGrainShearStressData(DataManagment.CrystalData.HKLReflex macroDirection, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); + TC11 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * averagingTensor.C12; + TC11 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * averagingTensor.C13; + TC11 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * averagingTensor.C23; - for (int n = 0; n < SimulationData[experiment].StressSFHistory.Count; n++) - { - double directionValueX = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressCFHistory[phase][n]); - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StressSFHistory[n] * macroDirection.Direction; + TC11 += 4 * Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * averagingTensor.C44; + TC11 += 4 * Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * averagingTensor.C55; + TC11 += 4 * Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * averagingTensor.C66; - double[] tmp = { directionValueX, directionValueY.L2Norm() }; - ret.Add(tmp); - } + TC33 += Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 4) * averagingTensor.C11; + TC33 += Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 4) * averagingTensor.C22; + TC33 += Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 4) * averagingTensor.C33; - return ret; - } - public Pattern.Counts SampleStressOverSampleShearStressData(DataManagment.CrystalData.HKLReflex macroDirection, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); + TC33 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * averagingTensor.C12; + TC33 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C13; + TC33 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C23; - for (int n = 0; n < SimulationData[experiment].StressSFHistory.Count; n++) - { - double directionValueX = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressSFHistory[n]); - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StressSFHistory[n] * macroDirection.Direction; + TC33 += 4 * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C44; + TC33 += 4 * Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C55; + TC33 += 4 * Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * averagingTensor.C66; - double[] tmp = { directionValueX, directionValueY.L2Norm() }; - ret.Add(tmp); - } + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * averagingTensor.C11; + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * averagingTensor.C22; + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2), 2) * averagingTensor.C33; - return ret; - } - public Pattern.Counts SampleStressOverSampleStrainRateData(DataManagment.CrystalData.HKLReflex direction, int experiment) - { - Pattern.Counts ret = new Pattern.Counts(); + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * averagingTensor.C12; + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * averagingTensor.C12; - for (int n = 0; n < SimulationData[experiment].StressSFHistory.Count; n++) - { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainRateSFHistory[n] * direction.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StressSFHistory[n] * direction.Direction; + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2), 2) * averagingTensor.C13; + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * averagingTensor.C13; - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); - } + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2), 2) * averagingTensor.C23; + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * averagingTensor.C23; - return ret; - } - public Pattern.Counts SampleStressOverGrainStrainRateData(DataManagment.CrystalData.HKLReflex macroDirection, DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); + TC12 += 4 * Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * averagingTensor.C44; + TC12 += 4 * Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * averagingTensor.C55; + TC12 += 4 * Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * averagingTensor.C66; - for (int n = 0; n < SimulationData[experiment].StressSFHistory.Count; n++) - { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainRateCFHistory[phase][n] * microDirection.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StressSFHistory[n] * macroDirection.Direction; + TC13 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * averagingTensor.C11; + TC13 += Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * averagingTensor.C22; + TC13 += Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C33; - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); - } + TC13 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * averagingTensor.C12; + TC13 += Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * averagingTensor.C12; - return ret; - } + TC13 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C13; + TC13 += Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * averagingTensor.C13; - public Pattern.Counts GrainStressOverSampleStrainData(DataManagment.CrystalData.HKLReflex macroDirection, DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); + TC13 += Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C23; + TC13 += Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * averagingTensor.C23; - for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) - { - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StressCFHistory[phase][n] * microDirection.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainSFHistory[n] * macroDirection.Direction; + TC13 += 4 * Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * averagingTensor.C44; + TC13 += 4 * Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * averagingTensor.C55; + TC13 += 4 * Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * averagingTensor.C66; - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); - } + TC44 += Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * averagingTensor.C11; + TC44 += Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * averagingTensor.C22; + TC44 += Math.Pow(Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C22; - return ret; - } - public Pattern.Counts GrainStressOverGrainStrainData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); + TC44 += 2 * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * averagingTensor.C12; + TC44 += 2 * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * averagingTensor.C13; + TC44 += 2 * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * averagingTensor.C23; - for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) - { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainCFHistory[phase][n] * direction2.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StressCFHistory[phase][n] * direction1.Direction; + TC44 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C44; + TC44 += 2 * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * averagingTensor.C44; - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); - } + TC44 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C55; + TC44 += 2 * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * averagingTensor.C55; - return ret; - } - public Pattern.Counts GrainStressOverSampleStressData(DataManagment.CrystalData.HKLReflex macroDirection, DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); + TC44 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * averagingTensor.C66; + TC44 += 2 * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * averagingTensor.C66; - for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) - { - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StressCFHistory[phase][n] * microDirection.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StressSFHistory[n] * macroDirection.Direction; + TC66 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * averagingTensor.C11; + TC66 += Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * averagingTensor.C22; + TC66 += Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2), 2) * averagingTensor.C22; - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); - } + TC66 += 2 * Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * averagingTensor.C12; + TC66 += 2 * Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * averagingTensor.C13; + TC66 += 2 * Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * averagingTensor.C23; - return ret; - } - public Pattern.Counts GrainStressOverGrainStressData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); + TC66 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2), 2) * averagingTensor.C44; + TC66 += 2 * Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * averagingTensor.C44; - for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) - { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StressCFHistory[phase][n] * direction1.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StressCFHistory[phase][n] * direction2.Direction; + TC66 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2), 2) * averagingTensor.C55; + TC66 += 2 * Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * averagingTensor.C55; - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); + TC66 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * averagingTensor.C66; + TC66 += 2 * Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * averagingTensor.C66; + } + } } - return ret; - } - public Pattern.Counts GrainStressOverGrainShearStressData(DataManagment.CrystalData.HKLReflex direction1, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); - - for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) - { - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StressCFHistory[phase][n] * direction1.Direction; - double directionValueX = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressCFHistory[phase][n]); + Stress.Microsopic.ElasticityTensors ret = averagingTensor.Clone() as Stress.Microsopic.ElasticityTensors; - double[] tmp = { directionValueX, directionValueY.L2Norm() }; - ret.Add(tmp); - } + ret.C11 = TC11 / normFactor; + ret.C33 = TC33 / normFactor; + ret.C12 = TC12 / normFactor; + ret.C13 = TC13 / normFactor; + ret.C44 = TC44 / normFactor; + ret.C66 = TC66 / normFactor; return ret; } - public Pattern.Counts GrainStressOverSampleShearStressData(DataManagment.CrystalData.HKLReflex direction1, int experiment, int phase) + + private Stress.Microsopic.ElasticityTensors SetTextureTensorRhombicIso(Stress.Microsopic.ElasticityTensors averagingTensor) { - Pattern.Counts ret = new Pattern.Counts(); + double TC11 = 0; + double TC22 = 0; + double TC33 = 0; + double TC12 = 0; + double TC13 = 0; + double TC23 = 0; + double TC44 = 0; + double TC55 = 0; + double TC66 = 0; + + double normFactor = 0.0; - for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) + for (double phi1 = 0.0; phi1 < 360.0; phi1 += 5.0) { - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StressCFHistory[phase][n] * direction1.Direction; - double directionValueX = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressSFHistory[n]); + for (double psi1 = 0.0; psi1 < 360.0; psi1 += 5.0) + { + for (double phi2 = 0.0; phi2 < 360.0; phi2 += 5.0) + { + normFactor++; - double[] tmp = { directionValueX, directionValueY.L2Norm() }; - ret.Add(tmp); - } + TC11 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 4) * averagingTensor.C11; + TC11 += Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 4) * averagingTensor.C22; + TC11 += Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 4) * averagingTensor.C33; - return ret; - } - public Pattern.Counts GrainStressOverSampleStrainRateData(DataManagment.CrystalData.HKLReflex macroDirection, DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); + TC11 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * averagingTensor.C12; + TC11 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * averagingTensor.C13; + TC11 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * averagingTensor.C23; - for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) - { - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StressCFHistory[phase][n] * microDirection.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainRateSFHistory[n] * macroDirection.Direction; + TC11 += 4 * Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * averagingTensor.C44; + TC11 += 4 * Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * averagingTensor.C55; + TC11 += 4 * Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * averagingTensor.C66; - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); - } + TC22 += Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 4) * averagingTensor.C11; + TC22 += Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 4) * averagingTensor.C22; + TC22 += Math.Pow(Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2), 4) * averagingTensor.C33; - return ret; - } - public Pattern.Counts GrainStressOverGrainStrainRateData(DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); + TC22 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * averagingTensor.C12; + TC22 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2), 2) * averagingTensor.C13; + TC22 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2), 2) * averagingTensor.C23; - for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) - { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainRateCFHistory[phase][n] * microDirection.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StressCFHistory[phase][n] * microDirection.Direction; + TC22 += 4 * Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2), 2) * averagingTensor.C44; + TC22 += 4 * Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2), 2) * averagingTensor.C55; + TC22 += 4 * Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * averagingTensor.C66; - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); - } + TC33 += Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 4) * averagingTensor.C11; + TC33 += Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 4) * averagingTensor.C22; + TC33 += Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 4) * averagingTensor.C33; - return ret; - } + TC33 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * averagingTensor.C12; + TC33 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C13; + TC33 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C23; - public Pattern.Counts GrainShearStressOverSampleStrainData(DataManagment.CrystalData.HKLReflex macroDirection, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); + TC33 += 4 * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C44; + TC33 += 4 * Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C55; + TC33 += 4 * Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * averagingTensor.C66; - for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) - { - double directionValueY = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressCFHistory[phase][n]); - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainSFHistory[n] * macroDirection.Direction; + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * averagingTensor.C11; + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * averagingTensor.C22; + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2), 2) * averagingTensor.C33; - double[] tmp = { directionValueX.L2Norm(), directionValueY }; - ret.Add(tmp); - } + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * averagingTensor.C12; + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * averagingTensor.C12; - return ret; - } - public Pattern.Counts GrainShearStressOverGrainStrainData(DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2), 2) * averagingTensor.C13; + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * averagingTensor.C13; - for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) - { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainCFHistory[phase][n] * microDirection.Direction; - double directionValueY = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressCFHistory[phase][n]); + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2), 2) * averagingTensor.C23; + TC12 += Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * averagingTensor.C23; - double[] tmp = { directionValueX.L2Norm(), directionValueY }; - ret.Add(tmp); - } + TC12 += 4 * Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * averagingTensor.C44; + TC12 += 4 * Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * averagingTensor.C55; + TC12 += 4 * Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * averagingTensor.C66; - return ret; - } - public Pattern.Counts GrainShearStressOverSampleStressData(DataManagment.CrystalData.HKLReflex macroDirection, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); + TC13 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * averagingTensor.C11; + TC13 += Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * averagingTensor.C22; + TC13 += Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C33; - for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) - { - double directionValueY = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressCFHistory[phase][n]); - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StressSFHistory[n] * macroDirection.Direction; + TC13 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * averagingTensor.C12; + TC13 += Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * averagingTensor.C12; - double[] tmp = { directionValueX.L2Norm(), directionValueY }; - ret.Add(tmp); - } + TC13 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C13; + TC13 += Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * averagingTensor.C13; - return ret; - } - public Pattern.Counts GrainShearStressOverGrainStressData(DataManagment.CrystalData.HKLReflex direction1, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); + TC13 += Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C23; + TC13 += Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * averagingTensor.C23; - for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) - { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StressCFHistory[phase][n] * direction1.Direction; - double directionValueY = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressCFHistory[phase][n]); + TC13 += 4 * Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * averagingTensor.C44; + TC13 += 4 * Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * averagingTensor.C55; + TC13 += 4 * Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * averagingTensor.C66; - double[] tmp = { directionValueX.L2Norm(), directionValueY }; - ret.Add(tmp); - } + TC23 += Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * averagingTensor.C11; + TC23 += Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * averagingTensor.C22; + TC23 += Math.Pow(Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C33; - return ret; - } - public Pattern.Counts GrainShearStressOverGrainShearStressData(int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); + TC23 += Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * averagingTensor.C12; + TC23 += Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * averagingTensor.C12; - for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) - { - double directionValue = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressCFHistory[phase][n]); + TC23 += Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C13; + TC23 += Math.Pow(Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * averagingTensor.C13; - double[] tmp = { directionValue, directionValue }; - ret.Add(tmp); - } + TC23 += Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C23; + TC23 += Math.Pow(Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * averagingTensor.C23; - return ret; - } - public Pattern.Counts GrainShearStressOverSampleShearStressData(int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); + TC23 += 4 * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * averagingTensor.C44; + TC23 += 4 * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * averagingTensor.C55; + TC23 += 4 * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * averagingTensor.C66; - for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) - { - double directionValueX = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressSFHistory[n]); - double directionValueY = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressCFHistory[phase][n]); + TC44 += Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * averagingTensor.C11; + TC44 += Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * averagingTensor.C22; + TC44 += Math.Pow(Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C22; - double[] tmp = { directionValueX, directionValueY }; - ret.Add(tmp); - } + TC44 += 2 * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * averagingTensor.C12; + TC44 += 2 * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * averagingTensor.C13; + TC44 += 2 * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * averagingTensor.C23; - return ret; - } - public Pattern.Counts GrainShearStressOverSampleStrainRateData(DataManagment.CrystalData.HKLReflex macroDirection, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); + TC44 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C44; + TC44 += 2 * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * averagingTensor.C44; - for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) - { - double directionValueY = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressCFHistory[phase][n]); - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainRateSFHistory[n] * macroDirection.Direction; + TC44 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C55; + TC44 += 2 * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * averagingTensor.C55; - double[] tmp = { directionValueX.L2Norm(), directionValueY }; - ret.Add(tmp); - } + TC44 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * averagingTensor.C66; + TC44 += 2 * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * averagingTensor.C66; - return ret; - } - public Pattern.Counts GrainShearStressOverGrainStrainRateData(DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); + TC55 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2), 2) * averagingTensor.C11; + TC55 += Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * averagingTensor.C22; + TC55 += Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C22; - for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) - { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainRateCFHistory[phase][n] * microDirection.Direction; - double directionValueY = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressCFHistory[phase][n]); + TC55 += 2 * Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * averagingTensor.C12; + TC55 += 2 * Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * averagingTensor.C13; + TC55 += 2 * Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * averagingTensor.C23; - double[] tmp = { directionValueX.L2Norm(), directionValueY }; - ret.Add(tmp); - } + TC55 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C44; + TC55 += 2 * Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * averagingTensor.C44; - return ret; - } + TC55 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2), 2) * averagingTensor.C55; + TC55 += 2 * Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM33(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * averagingTensor.C55; - public Pattern.Counts SampleShearStressOverSampleStrainData(DataManagment.CrystalData.HKLReflex macroDirection, int experiment) - { - Pattern.Counts ret = new Pattern.Counts(); + TC55 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2), 2) * averagingTensor.C66; + TC55 += 2 * Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM32(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM31(phi1, psi1, phi2) * averagingTensor.C66; - for (int n = 0; n < SimulationData[experiment].StressSFHistory.Count; n++) - { - double directionValueY = this.PlasticTensor[0].YieldSurfaceData.Shearforce(SimulationData[experiment].StressSFHistory[n]); - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainSFHistory[n] * macroDirection.Direction; + TC66 += Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2), 2) * averagingTensor.C11; + TC66 += Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * averagingTensor.C22; + TC66 += Math.Pow(Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2), 2) * averagingTensor.C22; - double[] tmp = { directionValueX.L2Norm(), directionValueY }; - ret.Add(tmp); - } + TC66 += 2 * Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * averagingTensor.C12; + TC66 += 2 * Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * averagingTensor.C13; + TC66 += 2 * Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * averagingTensor.C23; - return ret; - } - public Pattern.Counts SampleShearStressOverGrainStrainData(DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); + TC66 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2), 2) * averagingTensor.C44; + TC66 += 2 * Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * averagingTensor.C44; - for (int n = 0; n < SimulationData[experiment].StressSFHistory.Count; n++) - { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainCFHistory[phase][n] * microDirection.Direction; - double directionValueY = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressSFHistory[n]); + TC66 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2), 2) * averagingTensor.C55; + TC66 += 2 * Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM23(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM13(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * averagingTensor.C55; - double[] tmp = { directionValueX.L2Norm(), directionValueY }; - ret.Add(tmp); + TC66 += 2 * Math.Pow(Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2), 2) * Math.Pow(Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2), 2) * averagingTensor.C66; + TC66 += 2 * Texture.OrientationDistributionFunction.SCTM11(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM22(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM12(phi1, psi1, phi2) * Texture.OrientationDistributionFunction.SCTM21(phi1, psi1, phi2) * averagingTensor.C66; + } + } } - return ret; - } - public Pattern.Counts SampleShearStressOverSampleStressData(DataManagment.CrystalData.HKLReflex macroDirection, int experiment) - { - Pattern.Counts ret = new Pattern.Counts(); + Stress.Microsopic.ElasticityTensors ret = averagingTensor.Clone() as Stress.Microsopic.ElasticityTensors; - for (int n = 0; n < SimulationData[experiment].StressSFHistory.Count; n++) - { - double directionValueY = this.PlasticTensor[0].YieldSurfaceData.Shearforce(SimulationData[experiment].StressSFHistory[n]); - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StressSFHistory[n] * macroDirection.Direction; - - double[] tmp = { directionValueX.L2Norm(), directionValueY }; - ret.Add(tmp); - } + ret.C11 = TC11 / normFactor; + ret.C22 = TC22 / normFactor; + ret.C33 = TC33 / normFactor; + ret.C12 = TC12 / normFactor; + ret.C13 = TC13 / normFactor; + ret.C23 = TC23 / normFactor; + ret.C44 = TC44 / normFactor; + ret.C55 = TC55 / normFactor; + ret.C66 = TC66 / normFactor; return ret; } - public Pattern.Counts SampleShearStressOverGrainStressData(DataManagment.CrystalData.HKLReflex direction1, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); - for (int n = 0; n < SimulationData[experiment].StressSFHistory.Count; n++) - { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StressCFHistory[phase][n] * direction1.Direction; - double directionValueY = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressSFHistory[n]); + #endregion - double[] tmp = { directionValueX.L2Norm(), directionValueY }; - ret.Add(tmp); - } + #endregion - return ret; - } - public Pattern.Counts SampleShearStressOverGrainShearStressData(int experiment) + #region Data display + + public Pattern.Counts SimulationDataDisplay(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, List> xData, List> yData) { Pattern.Counts ret = new Pattern.Counts(); - for (int n = 0; n < SimulationData[experiment].StressSFHistory.Count; n++) + if(xData.Count == yData.Count) { - double directionValue = this.PlasticTensor[0].YieldSurfaceData.Shearforce(SimulationData[experiment].StressSFHistory[n]); + for (int n = 0; n < yData.Count; n++) + { + MathNet.Numerics.LinearAlgebra.Vector directionValueX = xData[n] * direction1.Direction; + MathNet.Numerics.LinearAlgebra.Vector directionValueY = yData[n] * direction2.Direction; - double[] tmp = { directionValue, directionValue }; - ret.Add(tmp); + double[] tmp = { direction1.Direction * directionValueX, direction2.Direction * directionValueY }; + ret.Add(tmp); + } } - - return ret; - } - public Pattern.Counts SampleShearStressOverSampleShearStressData(int experiment) - { - Pattern.Counts ret = new Pattern.Counts(); - - for (int n = 0; n < SimulationData[experiment].StressSFHistory.Count; n++) + else { - double directionValue = this.PlasticTensor[0].YieldSurfaceData.Shearforce(SimulationData[experiment].StressSFHistory[n]); + if (xData.Count > yData.Count) + { + for (int n = 0; n < yData.Count; n++) + { + MathNet.Numerics.LinearAlgebra.Vector directionValueX = xData[n] * direction1.Direction; + MathNet.Numerics.LinearAlgebra.Vector directionValueY = yData[n] * direction2.Direction; + + double[] tmp = { direction1.Direction * directionValueX, direction2.Direction * directionValueY }; + ret.Add(tmp); + } + } + else + { + for (int n = 0; n < xData.Count; n++) + { + MathNet.Numerics.LinearAlgebra.Vector directionValueX = xData[n] * direction1.Direction; + MathNet.Numerics.LinearAlgebra.Vector directionValueY = yData[n] * direction2.Direction; - double[] tmp = { directionValue, directionValue }; - ret.Add(tmp); + double[] tmp = { direction1.Direction * directionValueX, direction2.Direction * directionValueY }; + ret.Add(tmp); + } + } } return ret; } - public Pattern.Counts SampleShearStressOverSampleStrainRateData(DataManagment.CrystalData.HKLReflex macroDirection, int experiment) + + public Pattern.Counts SimulationDataDisplay(int[] xIndex, int[] yIndex, List> xData, List> yData) { Pattern.Counts ret = new Pattern.Counts(); - for (int n = 0; n < SimulationData[experiment].StressSFHistory.Count; n++) + if (xData.Count == yData.Count) { - double directionValueY = this.PlasticTensor[0].YieldSurfaceData.Shearforce(SimulationData[experiment].StressSFHistory[n]); - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainRateSFHistory[n] * macroDirection.Direction; - - double[] tmp = { directionValueX.L2Norm(), directionValueY }; - ret.Add(tmp); + for (int n = 0; n < yData.Count; n++) + { + double[] tmp = { xData[n][xIndex[0], xIndex[1]], yData[n][yIndex[0], yIndex[1]] }; + ret.Add(tmp); + } } - - return ret; - } - public Pattern.Counts SampleShearStressOverGrainStrainRateData(DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); - - for (int n = 0; n < SimulationData[experiment].StressSFHistory.Count; n++) + else { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainRateCFHistory[phase][n] * microDirection.Direction; - double directionValueY = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressSFHistory[n]); - - double[] tmp = { directionValueX.L2Norm(), directionValueY }; - ret.Add(tmp); + if(xData.Count > yData.Count) + { + for (int n = 0; n < yData.Count; n++) + { + double[] tmp = { xData[n][xIndex[0], xIndex[1]], yData[n][yIndex[0], yIndex[1]] }; + ret.Add(tmp); + } + } + else + { + for (int n = 0; n < xData.Count; n++) + { + double[] tmp = { xData[n][xIndex[0], xIndex[1]], yData[n][yIndex[0], yIndex[1]] }; + ret.Add(tmp); + } + } } return ret; } - public Pattern.Counts SampleStrainRateOverSampleStrainData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment) + public Pattern.Counts SimulationDataDisplay(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, List> xData, List> yData, bool xSum, bool ySum) { Pattern.Counts ret = new Pattern.Counts(); - for (int n = 0; n < SimulationData[experiment].StrainRateSFHistory.Count; n++) + if (xData.Count == yData.Count) { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainSFHistory[n] * direction1.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateSFHistory[n] * direction2.Direction; - - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); + double sumXValue = 0.0; + double sumYValue = 0.0; + for (int n = 0; n < yData.Count; n++) + { + MathNet.Numerics.LinearAlgebra.Vector directionValueX = xData[n] * direction1.DirectionNorm; + MathNet.Numerics.LinearAlgebra.Vector directionValueY = yData[n] * direction2.DirectionNorm; + if(xSum) + { + sumXValue += direction1.DirectionNorm * directionValueX; + if (ySum) + { + sumYValue += direction2.DirectionNorm * directionValueY; + double[] tmp = { sumXValue, sumYValue }; + ret.Add(tmp); + } + else + { + double[] tmp = { sumXValue, direction2.DirectionNorm * directionValueY }; + ret.Add(tmp); + } + } + else + { + if (ySum) + { + sumYValue += direction2.DirectionNorm * directionValueY; + double[] tmp = { direction1.DirectionNorm * directionValueX, sumYValue }; + ret.Add(tmp); + } + else + { + double[] tmp = { direction1.DirectionNorm * directionValueX, direction2.DirectionNorm * directionValueY }; + ret.Add(tmp); + } + } + } } - - return ret; - } - public Pattern.Counts SampleStrainRateOverGrainStrainData(DataManagment.CrystalData.HKLReflex macroDirection, DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); - - for (int n = 0; n < SimulationData[experiment].StrainRateSFHistory.Count; n++) + else { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainCFHistory[phase][n] * microDirection.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateSFHistory[n] * macroDirection.Direction; - - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); + if (xData.Count > yData.Count) + { + double sumXValue = 0.0; + double sumYValue = 0.0; + for (int n = 0; n < yData.Count; n++) + { + MathNet.Numerics.LinearAlgebra.Vector directionValueX = xData[n] * direction1.DirectionNorm; + MathNet.Numerics.LinearAlgebra.Vector directionValueY = yData[n] * direction2.DirectionNorm; + if (xSum) + { + sumXValue += direction1.DirectionNorm * directionValueX; + if (ySum) + { + sumYValue += direction2.DirectionNorm * directionValueY; + double[] tmp = { sumXValue, sumYValue }; + ret.Add(tmp); + } + else + { + double[] tmp = { sumXValue, direction2.DirectionNorm * directionValueY }; + ret.Add(tmp); + } + } + else + { + if (ySum) + { + sumYValue += direction2.DirectionNorm * directionValueY; + double[] tmp = { direction1.DirectionNorm * directionValueX, sumYValue }; + ret.Add(tmp); + } + else + { + double[] tmp = { direction1.DirectionNorm * directionValueX, direction2.DirectionNorm * directionValueY }; + ret.Add(tmp); + } + } + } + } + else + { + double sumXValue = 0.0; + double sumYValue = 0.0; + for (int n = 0; n < xData.Count; n++) + { + MathNet.Numerics.LinearAlgebra.Vector directionValueX = xData[n] * direction1.DirectionNorm; + MathNet.Numerics.LinearAlgebra.Vector directionValueY = yData[n] * direction2.DirectionNorm; + if (xSum) + { + sumXValue += direction1.DirectionNorm * directionValueX; + if (ySum) + { + sumYValue += direction2.DirectionNorm * directionValueY; + double[] tmp = { sumXValue, sumYValue }; + ret.Add(tmp); + } + else + { + double[] tmp = { sumXValue, direction2.DirectionNorm * directionValueY }; + ret.Add(tmp); + } + } + else + { + if (ySum) + { + sumYValue += direction2.DirectionNorm * directionValueY; + double[] tmp = { direction1.DirectionNorm * directionValueX, sumYValue }; + ret.Add(tmp); + } + else + { + double[] tmp = { direction1.DirectionNorm * directionValueX, direction2.DirectionNorm * directionValueY }; + ret.Add(tmp); + } + } + } + } } return ret; } - public Pattern.Counts SampleStrainRateOverSampleStressData(DataManagment.CrystalData.HKLReflex direction, int experiment) + + public Pattern.Counts SimulationDataDisplay(int[] xIndex, int[] yIndex, List> xData, List> yData, bool xSum, bool ySum) { Pattern.Counts ret = new Pattern.Counts(); - for (int n = 0; n < SimulationData[experiment].StrainRateSFHistory.Count; n++) + if (xData.Count == yData.Count) { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StressSFHistory[n] * direction.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateSFHistory[n] * direction.Direction; - - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); - } - - return ret; - } - public Pattern.Counts SampleStrainRateOverGrainStressData(DataManagment.CrystalData.HKLReflex macroDirection, DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); - - for (int n = 0; n < SimulationData[experiment].StrainRateSFHistory.Count; n++) - { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StressCFHistory[phase][n] * microDirection.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateSFHistory[n] * macroDirection.Direction; - - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); - } - - return ret; - } - public Pattern.Counts SampleStrainRateOverGrainShearStressData(DataManagment.CrystalData.HKLReflex macroDirection, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); - - for (int n = 0; n < SimulationData[experiment].StrainRateSFHistory.Count; n++) - { - double directionValueX = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressCFHistory[phase][n]); - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateSFHistory[n] * macroDirection.Direction; - - double[] tmp = { directionValueX, directionValueY.L2Norm() }; - ret.Add(tmp); - } - - return ret; - } - public Pattern.Counts SampleStrainRateOverSampleShearStressData(DataManagment.CrystalData.HKLReflex macroDirection, int experiment) - { - Pattern.Counts ret = new Pattern.Counts(); - - for (int n = 0; n < SimulationData[experiment].StrainRateSFHistory.Count; n++) - { - double directionValueX = this.PlasticTensor[0].YieldSurfaceData.Shearforce(SimulationData[experiment].StressSFHistory[n]); - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateSFHistory[n] * macroDirection.Direction; - - double[] tmp = { directionValueX, directionValueY.L2Norm() }; - ret.Add(tmp); - } - - return ret; - } - public Pattern.Counts SampleStrainRateOverSampleStrainRateData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment) - { - Pattern.Counts ret = new Pattern.Counts(); - - for (int n = 0; n < SimulationData[experiment].StrainRateSFHistory.Count; n++) - { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainRateSFHistory[n] * direction1.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateSFHistory[n] * direction2.Direction; - - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); - } - - return ret; - } - public Pattern.Counts SampleStrainRateOverGrainStrainRateData(DataManagment.CrystalData.HKLReflex macroDirection, DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); - - for (int n = 0; n < SimulationData[experiment].StrainRateSFHistory.Count; n++) - { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainRateCFHistory[phase][n] * microDirection.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateSFHistory[n] * macroDirection.Direction; - - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); - } - - return ret; - } - - public Pattern.Counts GrainStrainRateOverSampleStrainData(DataManagment.CrystalData.HKLReflex macroDirection, DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); - - for (int n = 0; n < SimulationData[experiment].StrainRateCFHistory[phase].Count; n++) - { - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateCFHistory[phase][n] * microDirection.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainSFHistory[n] * macroDirection.Direction; - - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); - } - - return ret; - } - public Pattern.Counts GrainStrainRateOverGrainStrainData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); - - for (int n = 0; n < SimulationData[experiment].StrainRateCFHistory[phase].Count; n++) - { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainCFHistory[phase][n] * direction1.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateCFHistory[phase][n] * direction2.Direction; - - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); - } - - return ret; - } - public Pattern.Counts GrainStrainRateOverSampleStressData(DataManagment.CrystalData.HKLReflex macroDirection, DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); - - for (int n = 0; n < SimulationData[experiment].StrainRateCFHistory[phase].Count; n++) - { - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateCFHistory[phase][n] * microDirection.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StressSFHistory[n] * macroDirection.Direction; - - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); - } - - return ret; - } - public Pattern.Counts GrainStrainRateOverGrainStressData(DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); - - for (int n = 0; n < SimulationData[experiment].StrainRateCFHistory[phase].Count; n++) - { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StressCFHistory[phase][n] * microDirection.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateCFHistory[phase][n] * microDirection.Direction; - - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); - } - - return ret; - } - public Pattern.Counts GrainStrainRateOverGrainShearStressData(DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); - - for (int n = 0; n < SimulationData[experiment].StrainRateCFHistory[phase].Count; n++) - { - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateCFHistory[phase][n] * microDirection.Direction; - double directionValueX = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressCFHistory[phase][n]); - - double[] tmp = { directionValueX, directionValueY.L2Norm() }; - ret.Add(tmp); - } - - return ret; - } - public Pattern.Counts GrainStrainRateOverSampleShearStressData(DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); - - for (int n = 0; n < SimulationData[experiment].StrainRateCFHistory[phase].Count; n++) - { - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateCFHistory[phase][n] * microDirection.Direction; - double directionValueX = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressSFHistory[n]); - - double[] tmp = { directionValueX, directionValueY.L2Norm() }; - ret.Add(tmp); - } - - return ret; - } - public Pattern.Counts GrainStrainRateOverSampleStrainRateData(DataManagment.CrystalData.HKLReflex macroDirection, DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); - - for (int n = 0; n < SimulationData[experiment].StrainRateCFHistory[phase].Count; n++) - { - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateCFHistory[phase][n] * microDirection.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainRateSFHistory[n] * macroDirection.Direction; - - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); - } - - return ret; - } - public Pattern.Counts GrainStrainRateOverGrainStrainRateData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment, int phase) - { - Pattern.Counts ret = new Pattern.Counts(); - - for (int n = 0; n < SimulationData[experiment].StrainRateCFHistory[phase].Count; n++) - { - MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainRateCFHistory[phase][n] * direction1.Direction; - MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateCFHistory[phase][n] * direction2.Direction; - - double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; - ret.Add(tmp); - } - - return ret; - } - - #region OldStuff - - public Pattern.Counts MacroStrainOverMacroStrainData(Stress.Microsopic.ElasticityTensors eT, Stress.Plasticity.PlasticityTensor pT) - { - Pattern.Counts ret = new Pattern.Counts(); - - List plottingData = Stress.Plasticity.EPModeling.GetPhaseStrainLD(eT, pT, this.appliedSampleStressHistory); - - for(int n = 0; n < plottingData.Count; n++) - { - double[] tmp = { plottingData[n][1], plottingData[n][1] }; - ret.Add(plottingData[n]); - } - - return ret; - } - public Pattern.Counts MacroStrainOverMicroStrainData(Stress.Microsopic.ElasticityTensors eT, Stress.Plasticity.PlasticityTensor pT, Stress.Plasticity.ReflexYield rY) - { - Pattern.Counts ret = new Pattern.Counts(); - - List plottingData1 = Stress.Plasticity.EPModeling.GetLatticeStrains(eT, pT, rY, this.appliedSampleStressHistory); - List plottingData2 = Stress.Plasticity.EPModeling.GetPhaseStrainLD(eT, pT, this.appliedSampleStressHistory); - - for (int n = 0; n < plottingData1.Count; n++) - { - double[] tmp = { plottingData1[n][1], plottingData2[n][1] }; - ret.Add(tmp); - } - - return ret; - } - public Pattern.Counts MacroStrainDataOverStressRD(Stress.Microsopic.ElasticityTensors eT, Stress.Plasticity.PlasticityTensor pT) - { - Pattern.Counts ret = new Pattern.Counts(); - - List plottingData = Stress.Plasticity.EPModeling.GetPhaseStrainLD(eT, pT, this.appliedSampleStressHistory); - - for (int n = 0; n < plottingData.Count; n++) - { - double[] tmp = { this.appliedSampleStressHistory[n][2, 2], plottingData[n][1] }; - ret.Add(tmp); - } - - return ret; - } - public Pattern.Counts MacroStrainDataOverPlainAdjustedStress(Stress.Microsopic.ElasticityTensors eT, Stress.Plasticity.PlasticityTensor pT, Stress.Plasticity.ReflexYield rY) - { - Pattern.Counts ret = new Pattern.Counts(); - - List plottingData = Stress.Plasticity.EPModeling.GetLatticeStrains(eT, pT, rY, this.appliedSampleStressHistory); - - for (int n = 0; n < plottingData.Count; n++) - { - ret.Add(plottingData[n]); - } - - return ret; - } - - public Pattern.Counts MicroStrainOverMacroStrainData(Stress.Microsopic.ElasticityTensors eT, Stress.Plasticity.PlasticityTensor pT, Stress.Plasticity.ReflexYield rY) - { - Pattern.Counts ret = new Pattern.Counts(); - - List plottingData1 = Stress.Plasticity.EPModeling.GetLatticeStrains(eT, pT, rY, this.appliedSampleStressHistory); - List plottingData2 = Stress.Plasticity.EPModeling.GetPhaseStrainLD(eT, pT, this.appliedSampleStressHistory); - - for (int n = 0; n < plottingData1.Count; n++) - { - double[] tmp = { plottingData2[n][1], plottingData1[n][1] }; - ret.Add(tmp); - } - - return ret; - } - public Pattern.Counts MicroStrainOverMicroStrainData(Stress.Microsopic.ElasticityTensors eT, Stress.Plasticity.PlasticityTensor pT, Stress.Plasticity.ReflexYield rY) - { - Pattern.Counts ret = new Pattern.Counts(); - - List plottingData1 = Stress.Plasticity.EPModeling.GetLatticeStrains(eT, pT, rY, this.appliedSampleStressHistory); - - for (int n = 0; n < plottingData1.Count; n++) - { - double[] tmp = { plottingData1[n][1], plottingData1[n][1] }; - ret.Add(tmp); - } - - return ret; - } - public Pattern.Counts MicroStrainDataOverStressRD(Stress.Microsopic.ElasticityTensors eT, Stress.Plasticity.PlasticityTensor pT, Stress.Plasticity.ReflexYield rY) - { - Pattern.Counts ret = new Pattern.Counts(); - - List plottingData1 = Stress.Plasticity.EPModeling.GetLatticeStrains(eT, pT, rY, this.appliedSampleStressHistory); - - for (int n = 0; n < plottingData1.Count; n++) - { - double[] tmp = { this.appliedSampleStressHistory[n][2, 2], plottingData1[n][1] }; - ret.Add(tmp); - } - - return ret; - } - public Pattern.Counts MicroStrainDataOverPlainAdjustedStress(Stress.Microsopic.ElasticityTensors eT, Stress.Plasticity.PlasticityTensor pT, Stress.Plasticity.ReflexYield rY) - { - Pattern.Counts ret = new Pattern.Counts(); - - List plottingData1 = Stress.Plasticity.EPModeling.GetLatticeStrains(eT, pT, rY, this.appliedSampleStressHistory); - - for (int n = 0; n < plottingData1.Count; n++) - { - double[] tmp = { plottingData1[n][0], plottingData1[n][1] }; - ret.Add(tmp); - } - - return ret; - } - - public Pattern.Counts StressRDOverMacroStrainData(Stress.Microsopic.ElasticityTensors eT, Stress.Plasticity.PlasticityTensor pT) - { - Pattern.Counts ret = new Pattern.Counts(); - - List plottingData2 = Stress.Plasticity.EPModeling.GetPhaseStrainLD(eT, pT, this.appliedSampleStressHistory); - - for (int n = 0; n < plottingData2.Count; n++) - { - double[] tmp = { plottingData2[n][1], this.appliedSampleStressHistory[n][2, 2] }; - ret.Add(tmp); - } - - return ret; - } - public Pattern.Counts StressRDOverMicroStrainData(Stress.Microsopic.ElasticityTensors eT, Stress.Plasticity.PlasticityTensor pT, Stress.Plasticity.ReflexYield rY) - { - Pattern.Counts ret = new Pattern.Counts(); - - List plottingData1 = Stress.Plasticity.EPModeling.GetLatticeStrains(eT, pT, rY, this.appliedSampleStressHistory); - - for (int n = 0; n < plottingData1.Count; n++) - { - double[] tmp = { plottingData1[n][1], this.appliedSampleStressHistory[n][2, 2] }; - ret.Add(tmp); - } - - return ret; - } - public Pattern.Counts StressRDOverStressData(Stress.Microsopic.ElasticityTensors eT, Stress.Plasticity.PlasticityTensor pT, Stress.Plasticity.ReflexYield rY) - { - Pattern.Counts ret = new Pattern.Counts(); - - List plottingData1 = Stress.Plasticity.EPModeling.GetLatticeStrains(eT, pT, rY, this.appliedSampleStressHistory); - - for (int n = 0; n < plottingData1.Count; n++) - { - double[] tmp = { this.appliedSampleStressHistory[n][2, 2], this.appliedSampleStressHistory[n][2, 2] }; - ret.Add(tmp); - } - - return ret; - } - public Pattern.Counts StressRDOverPlainAdjustedStressData(Stress.Microsopic.ElasticityTensors eT, Stress.Plasticity.PlasticityTensor pT, Stress.Plasticity.ReflexYield rY) - { - Pattern.Counts ret = new Pattern.Counts(); - - List plottingData1 = Stress.Plasticity.EPModeling.GetLatticeStrains(eT, pT, rY, this.appliedSampleStressHistory); - - for (int n = 0; n < plottingData1.Count; n++) - { - double[] tmp = { plottingData1[n][0], this.appliedSampleStressHistory[n][2, 2] }; - ret.Add(tmp); - } - - return ret; - } - - public Pattern.Counts PlainAdjustedStressOverMacroStrainData(Stress.Microsopic.ElasticityTensors eT, Stress.Plasticity.PlasticityTensor pT, Stress.Plasticity.ReflexYield rY) - { - Pattern.Counts ret = new Pattern.Counts(); - - List plottingData1 = Stress.Plasticity.EPModeling.GetLatticeStrains(eT, pT, rY, this.appliedSampleStressHistory); - List plottingData2 = Stress.Plasticity.EPModeling.GetPhaseStrainLD(eT, pT, this.appliedSampleStressHistory); - - for (int n = 0; n < plottingData2.Count; n++) - { - double[] tmp = { plottingData2[n][1], plottingData1[n][0] }; - ret.Add(tmp); - } - - return ret; - } - public Pattern.Counts PlainAdjustedStressOverMicroStrainData(Stress.Microsopic.ElasticityTensors eT, Stress.Plasticity.PlasticityTensor pT, Stress.Plasticity.ReflexYield rY) - { - Pattern.Counts ret = new Pattern.Counts(); - - List plottingData1 = Stress.Plasticity.EPModeling.GetLatticeStrains(eT, pT, rY, this.appliedSampleStressHistory); - - for (int n = 0; n < plottingData1.Count; n++) - { - double[] tmp = { plottingData1[n][1], plottingData1[n][0] }; - ret.Add(tmp); - } - - return ret; - } - public Pattern.Counts PlainAdjustedStressOverStressRDData(Stress.Microsopic.ElasticityTensors eT, Stress.Plasticity.PlasticityTensor pT, Stress.Plasticity.ReflexYield rY) - { - Pattern.Counts ret = new Pattern.Counts(); - - List plottingData1 = Stress.Plasticity.EPModeling.GetLatticeStrains(eT, pT, rY, this.appliedSampleStressHistory); - - for (int n = 0; n < plottingData1.Count; n++) - { - double[] tmp = { this.appliedSampleStressHistory[n][2, 2], plottingData1[n][0] }; - ret.Add(tmp); - } - - return ret; - } - public Pattern.Counts PlainAdjustedStressOverPlainAdjustedStressData(Stress.Microsopic.ElasticityTensors eT, Stress.Plasticity.PlasticityTensor pT, Stress.Plasticity.ReflexYield rY) - { - Pattern.Counts ret = new Pattern.Counts(); - - List plottingData1 = Stress.Plasticity.EPModeling.GetLatticeStrains(eT, pT, rY, this.appliedSampleStressHistory); - - for (int n = 0; n < plottingData1.Count; n++) - { - double[] tmp = { plottingData1[n][0], plottingData1[n][0] }; - ret.Add(tmp); - } - - return ret; - } - - #endregion - - #region To Experimet - - /// - /// return the macroscopic stress strain curve in LOAD DIRECTION - /// - /// - /// - /// - public Pattern.Counts GetMacroStressStrainCurveLD(int elasticModel, int phase, double totalYieldStrength, List stressStrainData) - { - Pattern.Counts ret = new Pattern.Counts(); - double eMod = 0.0; - stressStrainData.Sort((a, b) => a.MacroskopicStrain.CompareTo(b.MacroskopicStrain)); - - switch (elasticModel) - { - case 0: - eMod = this.VoigtTensorData[phase].AveragedEModul; - break; - case 1: - eMod = this.ReussTensorData[phase].AveragedEModul; - break; - case 2: - eMod = this.HillTensorData[phase].AveragedEModul; - break; - case 3: - eMod = this.KroenerTensorData[phase].AveragedEModul; - break; - case 4: - eMod = this.DeWittTensorData[phase].AveragedEModul; - break; - case 5: - eMod = this.GeometricHillTensorData[phase].AveragedEModul; - break; - default: - eMod = this.HillTensorData[phase].AveragedEModul; - break; - } - - double plasticStrainRate = 0.0; - int rateCounter = 0; - - for (int n = 0; n < stressStrainData.Count; n++) - { - if (stressStrainData[n].Stress > totalYieldStrength) + double sumXValue = 0.0; + double sumYValue = 0.0; + for (int n = 0; n < yData.Count; n++) { - plasticStrainRate += stressStrainData[n].MacroskopicStrain - stressStrainData[n - 1].MacroskopicStrain; - rateCounter++; + if (xSum) + { + sumXValue += xData[n][xIndex[0], xIndex[1]]; + if (ySum) + { + sumYValue += yData[n][yIndex[0], yIndex[1]]; + double[] tmp = { sumXValue, sumYValue }; + ret.Add(tmp); + } + else + { + double[] tmp = { sumXValue, yData[n][yIndex[0], yIndex[1]] }; + ret.Add(tmp); + } + } + else + { + if (ySum) + { + sumYValue += yData[n][yIndex[0], yIndex[1]]; + double[] tmp = { xData[n][xIndex[0], xIndex[1]], sumYValue }; + ret.Add(tmp); + } + else + { + double[] tmp = { xData[n][xIndex[0], xIndex[1]], yData[n][yIndex[0], yIndex[1]] }; + ret.Add(tmp); + } + } } } - - plasticStrainRate /= rateCounter; - - double plasticStrain = 0.0; - - for (int n = 0; n < stressStrainData.Count; n++) + else { - if (stressStrainData[n].Stress > totalYieldStrength) + if (xData.Count > yData.Count) { - plasticStrain += plasticStrainRate; + double sumXValue = 0.0; + double sumYValue = 0.0; + for (int n = 0; n < yData.Count; n++) + { + if (xSum) + { + sumXValue += xData[n][xIndex[0], xIndex[1]]; + if (ySum) + { + sumYValue += yData[n][yIndex[0], yIndex[1]]; + double[] tmp = { sumXValue, sumYValue }; + ret.Add(tmp); + } + else + { + double[] tmp = { sumXValue, yData[n][yIndex[0], yIndex[1]] }; + ret.Add(tmp); + } + } + else + { + if (ySum) + { + sumYValue += yData[n][yIndex[0], yIndex[1]]; + double[] tmp = { xData[n][xIndex[0], xIndex[1]], sumYValue }; + ret.Add(tmp); + } + else + { + double[] tmp = { xData[n][xIndex[0], xIndex[1]], yData[n][yIndex[0], yIndex[1]] }; + ret.Add(tmp); + } + } + } } - - double[] dataTmp = { stressStrainData[n].Stress, ((1 / eMod) * stressStrainData[n].Stress) + plasticStrain }; - - ret.Add(dataTmp); - } - - return ret; - } - /// - /// return the macroscopic stress strain curve in LOAD DIRECTION - /// - /// - /// - /// - public Pattern.Counts GetMacroStrainLatticeStrainCurveLD(int elasticModel, int phase, double totalYieldStrength, List stressStrainData) - { - Pattern.Counts ret = new Pattern.Counts(); - double eMod = 0.0; - stressStrainData.Sort((a, b) => a.MacroskopicStrain.CompareTo(b.MacroskopicStrain)); - - switch (elasticModel) - { - case 0: - eMod = this.VoigtTensorData[phase].AveragedEModul; - break; - case 1: - eMod = this.ReussTensorData[phase].AveragedEModul; - break; - case 2: - eMod = this.HillTensorData[phase].AveragedEModul; - break; - case 3: - eMod = this.KroenerTensorData[phase].AveragedEModul; - break; - case 4: - eMod = this.DeWittTensorData[phase].AveragedEModul; - break; - case 5: - eMod = this.GeometricHillTensorData[phase].AveragedEModul; - break; - default: - eMod = this.HillTensorData[phase].AveragedEModul; - break; - } - - double plasticStrainRate = 0.0; - int rateCounter = 0; - - for (int n = 0; n < stressStrainData.Count; n++) - { - if (stressStrainData[n].Stress > totalYieldStrength) + else { - plasticStrainRate += stressStrainData[n].MacroskopicStrain - stressStrainData[n - 1].MacroskopicStrain; - rateCounter++; + double sumXValue = 0.0; + double sumYValue = 0.0; + for (int n = 0; n < xData.Count; n++) + { + if (xSum) + { + sumXValue += xData[n][xIndex[0], xIndex[1]]; + if (ySum) + { + sumYValue += yData[n][yIndex[0], yIndex[1]]; + double[] tmp = { sumXValue, sumYValue }; + ret.Add(tmp); + } + else + { + double[] tmp = { sumXValue, yData[n][yIndex[0], yIndex[1]] }; + ret.Add(tmp); + } + } + else + { + if (ySum) + { + sumYValue += yData[n][yIndex[0], yIndex[1]]; + double[] tmp = { xData[n][xIndex[0], xIndex[1]], sumYValue }; + ret.Add(tmp); + } + else + { + double[] tmp = { xData[n][xIndex[0], xIndex[1]], yData[n][yIndex[0], yIndex[1]] }; + ret.Add(tmp); + } + } + } } } - plasticStrainRate /= rateCounter; - - double plasticStrain = 0.0; + return ret; + } - for (int n = 0; n < stressStrainData.Count; n++) - { - if (stressStrainData[n].Stress > totalYieldStrength) - { - plasticStrain += plasticStrainRate; - } + #region OldStuff - double[] dataTmp = { stressStrainData[n].Strain, ((1 / eMod) * stressStrainData[n].Stress) + plasticStrain }; + //public Pattern.Counts SampleStrainOverSampleStrainData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StrainSFHistory.Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainSFHistory[n] * direction1.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainSFHistory[n] * direction2.Direction; + + // double[] tmp = { direction1.Direction * directionValueX, direction2.Direction * directionValueY }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts SampleStrainOverGrainStrainData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StrainSFHistory.Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainCFHistory[phase][n] * direction1.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainSFHistory[n] * direction2.Direction; + + // double[] tmp = { direction1.Direction * directionValueX, direction2.Direction * directionValueY }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts SampleStrainOverSampleStressData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StrainSFHistory.Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StressSFHistory[n] * direction1.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainSFHistory[n] * direction2.Direction; + + // double[] tmp = { direction1.Direction * directionValueX, direction2.Direction * directionValueY }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts SampleStrainOverGrainStressData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StrainSFHistory.Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StressCFHistory[phase][n] * direction1.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainSFHistory[n] * direction2.Direction; + + // double[] tmp = { direction1.Direction * directionValueX, direction2.Direction * directionValueY }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts SampleStrainOverGrainShearStressData(DataManagment.CrystalData.HKLReflex direction1, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StrainSFHistory.Count; n++) + // { + // double directionValueX = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressCFHistory[phase][n]); + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainSFHistory[n] * direction1.Direction; + + // double[] tmp = { directionValueX, direction1.Direction * directionValueY }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts SampleStrainOverSampleShearStresData(DataManagment.CrystalData.HKLReflex direction1, int experiment) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StrainSFHistory.Count; n++) + // { + // double directionValueX = this.PlasticTensor[0].YieldSurfaceData.Shearforce(SimulationData[experiment].StressSFHistory[n]); + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainSFHistory[n] * direction1.Direction; + + // double[] tmp = { directionValueX, direction1.Direction * directionValueY }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts SampleStrainOverSampleStrainRateData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StrainSFHistory.Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainRateSFHistory[n] * direction1.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainSFHistory[n] * direction2.Direction; + + // double[] tmp = { direction1.Direction * directionValueX, direction2.Direction * directionValueY }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts SampleStrainOverGrainStrainRateData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StrainSFHistory.Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainRateCFHistory[phase][n] * direction1.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainSFHistory[n] * direction2.Direction; + + // double[] tmp = { direction1.Direction * directionValueX, direction2.Direction * directionValueY }; + // ret.Add(tmp); + // } + + // return ret; + //} + + //public Pattern.Counts GrainStrainOverSampleStrainData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StrainCFHistory[phase].Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainCFHistory[phase][n] * direction1.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainSFHistory[n] * direction2.Direction; + + // double[] tmp = { direction1.Direction * directionValueX, direction2.Direction * directionValueY }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts GrainStrainOverGrainStrainData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StrainCFHistory[phase].Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainCFHistory[phase][n] * direction1.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainCFHistory[phase][n] * direction2.Direction; + + // double[] tmp = { direction1.Direction * directionValueX, direction2.Direction * directionValueY }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts GrainStrainOverSampleStressData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainCFHistory[phase][n] * direction1.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StressSFHistory[n] * direction2.Direction; + + // double[] tmp = { direction1.Direction * directionValueX, direction2.Direction * directionValueY }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts GrainStrainOverGrainStressData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StressCFHistory[phase][n] * direction1.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainCFHistory[phase][n] * direction2.Direction; + + // double[] tmp = { direction1.Direction * directionValueX, direction2.Direction * directionValueY }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts GrainStrainOverGrainShearStressData(DataManagment.CrystalData.HKLReflex direction1, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainCFHistory[phase][n] * direction1.Direction; + // double directionValueX = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressCFHistory[phase][n]); + + // double[] tmp = { directionValueX, direction1.Direction * directionValueY }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts GrainStrainOverSampleShearStressData(DataManagment.CrystalData.HKLReflex direction1, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainCFHistory[phase][n] * direction1.Direction; + // double directionValueX = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressSFHistory[n]); + + // double[] tmp = { directionValueX, direction1.Direction * directionValueY }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts GrainStrainOverSampleStrainRateData(DataManagment.CrystalData.HKLReflex macroDirection, DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainCFHistory[phase][n] * microDirection.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainRateSFHistory[n] * macroDirection.Direction; + + // double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts GrainStrainOverGrainStrainRateData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainCFHistory[phase][n] * direction1.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateCFHistory[phase][n] * direction2.Direction; + + // double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + + //public Pattern.Counts SampleStressOverSampleStrainData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressSFHistory.Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainSFHistory[n] * direction2.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StressSFHistory[n] * direction1.Direction; + + // double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts SampleStressOverGrainStrainData(DataManagment.CrystalData.HKLReflex macroDirection, DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressSFHistory.Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainCFHistory[phase][n] * microDirection.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StressSFHistory[n] * macroDirection.Direction; + + // double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts SampleStressOverSampleStressData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressSFHistory.Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StressSFHistory[n] * direction1.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StressSFHistory[n] * direction2.Direction; + + // double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts SampleStressOverGrainStressData(DataManagment.CrystalData.HKLReflex macroDirection, DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressSFHistory.Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StressCFHistory[phase][n] * microDirection.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StressSFHistory[n] * macroDirection.Direction; + + // double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts SampleStressOverGrainShearStressData(DataManagment.CrystalData.HKLReflex macroDirection, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressSFHistory.Count; n++) + // { + // double directionValueX = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressCFHistory[phase][n]); + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StressSFHistory[n] * macroDirection.Direction; + + // double[] tmp = { directionValueX, directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts SampleStressOverSampleShearStressData(DataManagment.CrystalData.HKLReflex macroDirection, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressSFHistory.Count; n++) + // { + // double directionValueX = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressSFHistory[n]); + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StressSFHistory[n] * macroDirection.Direction; + + // double[] tmp = { directionValueX, directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts SampleStressOverSampleStrainRateData(DataManagment.CrystalData.HKLReflex direction, int experiment) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressSFHistory.Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainRateSFHistory[n] * direction.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StressSFHistory[n] * direction.Direction; + + // double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts SampleStressOverGrainStrainRateData(DataManagment.CrystalData.HKLReflex macroDirection, DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressSFHistory.Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainRateCFHistory[phase][n] * microDirection.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StressSFHistory[n] * macroDirection.Direction; + + // double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + + //public Pattern.Counts GrainStressOverSampleStrainData(DataManagment.CrystalData.HKLReflex macroDirection, DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StressCFHistory[phase][n] * microDirection.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainSFHistory[n] * macroDirection.Direction; + + // double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts GrainStressOverGrainStrainData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainCFHistory[phase][n] * direction2.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StressCFHistory[phase][n] * direction1.Direction; + + // double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts GrainStressOverSampleStressData(DataManagment.CrystalData.HKLReflex macroDirection, DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StressCFHistory[phase][n] * microDirection.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StressSFHistory[n] * macroDirection.Direction; + + // double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts GrainStressOverGrainStressData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StressCFHistory[phase][n] * direction1.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StressCFHistory[phase][n] * direction2.Direction; + + // double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts GrainStressOverGrainShearStressData(DataManagment.CrystalData.HKLReflex direction1, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StressCFHistory[phase][n] * direction1.Direction; + // double directionValueX = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressCFHistory[phase][n]); + + // double[] tmp = { directionValueX, directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts GrainStressOverSampleShearStressData(DataManagment.CrystalData.HKLReflex direction1, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StressCFHistory[phase][n] * direction1.Direction; + // double directionValueX = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressSFHistory[n]); + + // double[] tmp = { directionValueX, directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts GrainStressOverSampleStrainRateData(DataManagment.CrystalData.HKLReflex macroDirection, DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StressCFHistory[phase][n] * microDirection.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainRateSFHistory[n] * macroDirection.Direction; + + // double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts GrainStressOverGrainStrainRateData(DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainRateCFHistory[phase][n] * microDirection.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StressCFHistory[phase][n] * microDirection.Direction; + + // double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + + //public Pattern.Counts GrainShearStressOverSampleStrainData(DataManagment.CrystalData.HKLReflex macroDirection, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) + // { + // double directionValueY = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressCFHistory[phase][n]); + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainSFHistory[n] * macroDirection.Direction; + + // double[] tmp = { directionValueX.L2Norm(), directionValueY }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts GrainShearStressOverGrainStrainData(DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainCFHistory[phase][n] * microDirection.Direction; + // double directionValueY = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressCFHistory[phase][n]); + + // double[] tmp = { directionValueX.L2Norm(), directionValueY }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts GrainShearStressOverSampleStressData(DataManagment.CrystalData.HKLReflex macroDirection, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) + // { + // double directionValueY = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressCFHistory[phase][n]); + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StressSFHistory[n] * macroDirection.Direction; + + // double[] tmp = { directionValueX.L2Norm(), directionValueY }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts GrainShearStressOverGrainStressData(DataManagment.CrystalData.HKLReflex direction1, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StressCFHistory[phase][n] * direction1.Direction; + // double directionValueY = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressCFHistory[phase][n]); + + // double[] tmp = { directionValueX.L2Norm(), directionValueY }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts GrainShearStressOverGrainShearStressData(int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) + // { + // double directionValue = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressCFHistory[phase][n]); + + // double[] tmp = { directionValue, directionValue }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts GrainShearStressOverSampleShearStressData(int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) + // { + // double directionValueX = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressSFHistory[n]); + // double directionValueY = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressCFHistory[phase][n]); + + // double[] tmp = { directionValueX, directionValueY }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts GrainShearStressOverSampleStrainRateData(DataManagment.CrystalData.HKLReflex macroDirection, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) + // { + // double directionValueY = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressCFHistory[phase][n]); + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainRateSFHistory[n] * macroDirection.Direction; + + // double[] tmp = { directionValueX.L2Norm(), directionValueY }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts GrainShearStressOverGrainStrainRateData(DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressCFHistory[phase].Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainRateCFHistory[phase][n] * microDirection.Direction; + // double directionValueY = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressCFHistory[phase][n]); + + // double[] tmp = { directionValueX.L2Norm(), directionValueY }; + // ret.Add(tmp); + // } + + // return ret; + //} + + //public Pattern.Counts SampleShearStressOverSampleStrainData(DataManagment.CrystalData.HKLReflex macroDirection, int experiment) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressSFHistory.Count; n++) + // { + // double directionValueY = this.PlasticTensor[0].YieldSurfaceData.Shearforce(SimulationData[experiment].StressSFHistory[n]); + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainSFHistory[n] * macroDirection.Direction; + + // double[] tmp = { directionValueX.L2Norm(), directionValueY }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts SampleShearStressOverGrainStrainData(DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressSFHistory.Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainCFHistory[phase][n] * microDirection.Direction; + // double directionValueY = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressSFHistory[n]); + + // double[] tmp = { directionValueX.L2Norm(), directionValueY }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts SampleShearStressOverSampleStressData(DataManagment.CrystalData.HKLReflex macroDirection, int experiment) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressSFHistory.Count; n++) + // { + // double directionValueY = this.PlasticTensor[0].YieldSurfaceData.Shearforce(SimulationData[experiment].StressSFHistory[n]); + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StressSFHistory[n] * macroDirection.Direction; + + // double[] tmp = { directionValueX.L2Norm(), directionValueY }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts SampleShearStressOverGrainStressData(DataManagment.CrystalData.HKLReflex direction1, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressSFHistory.Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StressCFHistory[phase][n] * direction1.Direction; + // double directionValueY = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressSFHistory[n]); + + // double[] tmp = { directionValueX.L2Norm(), directionValueY }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts SampleShearStressOverGrainShearStressData(int experiment) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressSFHistory.Count; n++) + // { + // double directionValue = this.PlasticTensor[0].YieldSurfaceData.Shearforce(SimulationData[experiment].StressSFHistory[n]); + + // double[] tmp = { directionValue, directionValue }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts SampleShearStressOverSampleShearStressData(int experiment) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressSFHistory.Count; n++) + // { + // double directionValue = this.PlasticTensor[0].YieldSurfaceData.Shearforce(SimulationData[experiment].StressSFHistory[n]); + + // double[] tmp = { directionValue, directionValue }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts SampleShearStressOverSampleStrainRateData(DataManagment.CrystalData.HKLReflex macroDirection, int experiment) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressSFHistory.Count; n++) + // { + // double directionValueY = this.PlasticTensor[0].YieldSurfaceData.Shearforce(SimulationData[experiment].StressSFHistory[n]); + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainRateSFHistory[n] * macroDirection.Direction; + + // double[] tmp = { directionValueX.L2Norm(), directionValueY }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts SampleShearStressOverGrainStrainRateData(DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StressSFHistory.Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainRateCFHistory[phase][n] * microDirection.Direction; + // double directionValueY = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressSFHistory[n]); + + // double[] tmp = { directionValueX.L2Norm(), directionValueY }; + // ret.Add(tmp); + // } + + // return ret; + //} + + //public Pattern.Counts SampleStrainRateOverSampleStrainData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StrainRateSFHistory.Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainSFHistory[n] * direction1.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateSFHistory[n] * direction2.Direction; + + // double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts SampleStrainRateOverGrainStrainData(DataManagment.CrystalData.HKLReflex macroDirection, DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StrainRateSFHistory.Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainCFHistory[phase][n] * microDirection.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateSFHistory[n] * macroDirection.Direction; + + // double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts SampleStrainRateOverSampleStressData(DataManagment.CrystalData.HKLReflex direction, int experiment) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StrainRateSFHistory.Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StressSFHistory[n] * direction.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateSFHistory[n] * direction.Direction; + + // double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts SampleStrainRateOverGrainStressData(DataManagment.CrystalData.HKLReflex macroDirection, DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StrainRateSFHistory.Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StressCFHistory[phase][n] * microDirection.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateSFHistory[n] * macroDirection.Direction; + + // double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts SampleStrainRateOverGrainShearStressData(DataManagment.CrystalData.HKLReflex macroDirection, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StrainRateSFHistory.Count; n++) + // { + // double directionValueX = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressCFHistory[phase][n]); + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateSFHistory[n] * macroDirection.Direction; + + // double[] tmp = { directionValueX, directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts SampleStrainRateOverSampleShearStressData(DataManagment.CrystalData.HKLReflex macroDirection, int experiment) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StrainRateSFHistory.Count; n++) + // { + // double directionValueX = this.PlasticTensor[0].YieldSurfaceData.Shearforce(SimulationData[experiment].StressSFHistory[n]); + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateSFHistory[n] * macroDirection.Direction; + + // double[] tmp = { directionValueX, directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts SampleStrainRateOverSampleStrainRateData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StrainRateSFHistory.Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainRateSFHistory[n] * direction1.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateSFHistory[n] * direction2.Direction; + + // double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts SampleStrainRateOverGrainStrainRateData(DataManagment.CrystalData.HKLReflex macroDirection, DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StrainRateSFHistory.Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainRateCFHistory[phase][n] * microDirection.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateSFHistory[n] * macroDirection.Direction; + + // double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + + //public Pattern.Counts GrainStrainRateOverSampleStrainData(DataManagment.CrystalData.HKLReflex macroDirection, DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StrainRateCFHistory[phase].Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateCFHistory[phase][n] * microDirection.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainSFHistory[n] * macroDirection.Direction; + + // double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts GrainStrainRateOverGrainStrainData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StrainRateCFHistory[phase].Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainCFHistory[phase][n] * direction1.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateCFHistory[phase][n] * direction2.Direction; + + // double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts GrainStrainRateOverSampleStressData(DataManagment.CrystalData.HKLReflex macroDirection, DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StrainRateCFHistory[phase].Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateCFHistory[phase][n] * microDirection.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StressSFHistory[n] * macroDirection.Direction; + + // double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts GrainStrainRateOverGrainStressData(DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StrainRateCFHistory[phase].Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StressCFHistory[phase][n] * microDirection.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateCFHistory[phase][n] * microDirection.Direction; + + // double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts GrainStrainRateOverGrainShearStressData(DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StrainRateCFHistory[phase].Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateCFHistory[phase][n] * microDirection.Direction; + // double directionValueX = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressCFHistory[phase][n]); + + // double[] tmp = { directionValueX, directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts GrainStrainRateOverSampleShearStressData(DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StrainRateCFHistory[phase].Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateCFHistory[phase][n] * microDirection.Direction; + // double directionValueX = this.PlasticTensor[phase].YieldSurfaceData.Shearforce(SimulationData[experiment].StressSFHistory[n]); + + // double[] tmp = { directionValueX, directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts GrainStrainRateOverSampleStrainRateData(DataManagment.CrystalData.HKLReflex macroDirection, DataManagment.CrystalData.HKLReflex microDirection, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StrainRateCFHistory[phase].Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateCFHistory[phase][n] * microDirection.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainRateSFHistory[n] * macroDirection.Direction; + + // double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts GrainStrainRateOverGrainStrainRateData(DataManagment.CrystalData.HKLReflex direction1, DataManagment.CrystalData.HKLReflex direction2, int experiment, int phase) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // for (int n = 0; n < SimulationData[experiment].StrainRateCFHistory[phase].Count; n++) + // { + // MathNet.Numerics.LinearAlgebra.Vector directionValueX = SimulationData[experiment].StrainRateCFHistory[phase][n] * direction1.Direction; + // MathNet.Numerics.LinearAlgebra.Vector directionValueY = SimulationData[experiment].StrainRateCFHistory[phase][n] * direction2.Direction; + + // double[] tmp = { directionValueX.L2Norm(), directionValueY.L2Norm() }; + // ret.Add(tmp); + // } + + // return ret; + //} + + + + //public Pattern.Counts MacroStrainOverMacroStrainData(Stress.Microsopic.ElasticityTensors eT, Stress.Plasticity.PlasticityTensor pT) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // List plottingData = Stress.Plasticity.EPModeling.GetPhaseStrainLD(eT, pT, this.appliedSampleStressHistory); + + // for(int n = 0; n < plottingData.Count; n++) + // { + // double[] tmp = { plottingData[n][1], plottingData[n][1] }; + // ret.Add(plottingData[n]); + // } + + // return ret; + //} + //public Pattern.Counts MacroStrainOverMicroStrainData(Stress.Microsopic.ElasticityTensors eT, Stress.Plasticity.PlasticityTensor pT, Stress.Plasticity.ReflexYield rY) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // List plottingData1 = Stress.Plasticity.EPModeling.GetLatticeStrains(eT, pT, rY, this.appliedSampleStressHistory); + // List plottingData2 = Stress.Plasticity.EPModeling.GetPhaseStrainLD(eT, pT, this.appliedSampleStressHistory); + + // for (int n = 0; n < plottingData1.Count; n++) + // { + // double[] tmp = { plottingData1[n][1], plottingData2[n][1] }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts MacroStrainDataOverStressRD(Stress.Microsopic.ElasticityTensors eT, Stress.Plasticity.PlasticityTensor pT) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // List plottingData = Stress.Plasticity.EPModeling.GetPhaseStrainLD(eT, pT, this.appliedSampleStressHistory); + + // for (int n = 0; n < plottingData.Count; n++) + // { + // double[] tmp = { this.appliedSampleStressHistory[n][2, 2], plottingData[n][1] }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts MacroStrainDataOverPlainAdjustedStress(Stress.Microsopic.ElasticityTensors eT, Stress.Plasticity.PlasticityTensor pT, Stress.Plasticity.ReflexYield rY) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // List plottingData = Stress.Plasticity.EPModeling.GetLatticeStrains(eT, pT, rY, this.appliedSampleStressHistory); + + // for (int n = 0; n < plottingData.Count; n++) + // { + // ret.Add(plottingData[n]); + // } + + // return ret; + //} + + //public Pattern.Counts MicroStrainOverMacroStrainData(Stress.Microsopic.ElasticityTensors eT, Stress.Plasticity.PlasticityTensor pT, Stress.Plasticity.ReflexYield rY) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // List plottingData1 = Stress.Plasticity.EPModeling.GetLatticeStrains(eT, pT, rY, this.appliedSampleStressHistory); + // List plottingData2 = Stress.Plasticity.EPModeling.GetPhaseStrainLD(eT, pT, this.appliedSampleStressHistory); + + // for (int n = 0; n < plottingData1.Count; n++) + // { + // double[] tmp = { plottingData2[n][1], plottingData1[n][1] }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts MicroStrainOverMicroStrainData(Stress.Microsopic.ElasticityTensors eT, Stress.Plasticity.PlasticityTensor pT, Stress.Plasticity.ReflexYield rY) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // List plottingData1 = Stress.Plasticity.EPModeling.GetLatticeStrains(eT, pT, rY, this.appliedSampleStressHistory); + + // for (int n = 0; n < plottingData1.Count; n++) + // { + // double[] tmp = { plottingData1[n][1], plottingData1[n][1] }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts MicroStrainDataOverStressRD(Stress.Microsopic.ElasticityTensors eT, Stress.Plasticity.PlasticityTensor pT, Stress.Plasticity.ReflexYield rY) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // List plottingData1 = Stress.Plasticity.EPModeling.GetLatticeStrains(eT, pT, rY, this.appliedSampleStressHistory); + + // for (int n = 0; n < plottingData1.Count; n++) + // { + // double[] tmp = { this.appliedSampleStressHistory[n][2, 2], plottingData1[n][1] }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts MicroStrainDataOverPlainAdjustedStress(Stress.Microsopic.ElasticityTensors eT, Stress.Plasticity.PlasticityTensor pT, Stress.Plasticity.ReflexYield rY) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // List plottingData1 = Stress.Plasticity.EPModeling.GetLatticeStrains(eT, pT, rY, this.appliedSampleStressHistory); + + // for (int n = 0; n < plottingData1.Count; n++) + // { + // double[] tmp = { plottingData1[n][0], plottingData1[n][1] }; + // ret.Add(tmp); + // } + + // return ret; + //} + + //public Pattern.Counts StressRDOverMacroStrainData(Stress.Microsopic.ElasticityTensors eT, Stress.Plasticity.PlasticityTensor pT) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // List plottingData2 = Stress.Plasticity.EPModeling.GetPhaseStrainLD(eT, pT, this.appliedSampleStressHistory); + + // for (int n = 0; n < plottingData2.Count; n++) + // { + // double[] tmp = { plottingData2[n][1], this.appliedSampleStressHistory[n][2, 2] }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts StressRDOverMicroStrainData(Stress.Microsopic.ElasticityTensors eT, Stress.Plasticity.PlasticityTensor pT, Stress.Plasticity.ReflexYield rY) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // List plottingData1 = Stress.Plasticity.EPModeling.GetLatticeStrains(eT, pT, rY, this.appliedSampleStressHistory); + + // for (int n = 0; n < plottingData1.Count; n++) + // { + // double[] tmp = { plottingData1[n][1], this.appliedSampleStressHistory[n][2, 2] }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts StressRDOverStressData(Stress.Microsopic.ElasticityTensors eT, Stress.Plasticity.PlasticityTensor pT, Stress.Plasticity.ReflexYield rY) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // List plottingData1 = Stress.Plasticity.EPModeling.GetLatticeStrains(eT, pT, rY, this.appliedSampleStressHistory); + + // for (int n = 0; n < plottingData1.Count; n++) + // { + // double[] tmp = { this.appliedSampleStressHistory[n][2, 2], this.appliedSampleStressHistory[n][2, 2] }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts StressRDOverPlainAdjustedStressData(Stress.Microsopic.ElasticityTensors eT, Stress.Plasticity.PlasticityTensor pT, Stress.Plasticity.ReflexYield rY) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // List plottingData1 = Stress.Plasticity.EPModeling.GetLatticeStrains(eT, pT, rY, this.appliedSampleStressHistory); + + // for (int n = 0; n < plottingData1.Count; n++) + // { + // double[] tmp = { plottingData1[n][0], this.appliedSampleStressHistory[n][2, 2] }; + // ret.Add(tmp); + // } + + // return ret; + //} + + //public Pattern.Counts PlainAdjustedStressOverMacroStrainData(Stress.Microsopic.ElasticityTensors eT, Stress.Plasticity.PlasticityTensor pT, Stress.Plasticity.ReflexYield rY) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // List plottingData1 = Stress.Plasticity.EPModeling.GetLatticeStrains(eT, pT, rY, this.appliedSampleStressHistory); + // List plottingData2 = Stress.Plasticity.EPModeling.GetPhaseStrainLD(eT, pT, this.appliedSampleStressHistory); + + // for (int n = 0; n < plottingData2.Count; n++) + // { + // double[] tmp = { plottingData2[n][1], plottingData1[n][0] }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts PlainAdjustedStressOverMicroStrainData(Stress.Microsopic.ElasticityTensors eT, Stress.Plasticity.PlasticityTensor pT, Stress.Plasticity.ReflexYield rY) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // List plottingData1 = Stress.Plasticity.EPModeling.GetLatticeStrains(eT, pT, rY, this.appliedSampleStressHistory); + + // for (int n = 0; n < plottingData1.Count; n++) + // { + // double[] tmp = { plottingData1[n][1], plottingData1[n][0] }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts PlainAdjustedStressOverStressRDData(Stress.Microsopic.ElasticityTensors eT, Stress.Plasticity.PlasticityTensor pT, Stress.Plasticity.ReflexYield rY) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // List plottingData1 = Stress.Plasticity.EPModeling.GetLatticeStrains(eT, pT, rY, this.appliedSampleStressHistory); + + // for (int n = 0; n < plottingData1.Count; n++) + // { + // double[] tmp = { this.appliedSampleStressHistory[n][2, 2], plottingData1[n][0] }; + // ret.Add(tmp); + // } + + // return ret; + //} + //public Pattern.Counts PlainAdjustedStressOverPlainAdjustedStressData(Stress.Microsopic.ElasticityTensors eT, Stress.Plasticity.PlasticityTensor pT, Stress.Plasticity.ReflexYield rY) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + + // List plottingData1 = Stress.Plasticity.EPModeling.GetLatticeStrains(eT, pT, rY, this.appliedSampleStressHistory); + + // for (int n = 0; n < plottingData1.Count; n++) + // { + // double[] tmp = { plottingData1[n][0], plottingData1[n][0] }; + // ret.Add(tmp); + // } + + // return ret; + //} - ret.Add(dataTmp); - } + #endregion - return ret; - } + #region To Experiment + + ///// + ///// return the macroscopic stress strain curve in LOAD DIRECTION + ///// + ///// + ///// + ///// + //public Pattern.Counts GetMacroStressStrainCurveLD(int elasticModel, int phase, double totalYieldStrength, List stressStrainData) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + // double eMod = 0.0; + // stressStrainData.Sort((a, b) => a.MacroskopicStrain.CompareTo(b.MacroskopicStrain)); + + // switch (elasticModel) + // { + // case 0: + // eMod = this.VoigtTensorData[phase].AveragedEModul; + // break; + // case 1: + // eMod = this.ReussTensorData[phase].AveragedEModul; + // break; + // case 2: + // eMod = this.HillTensorData[phase].AveragedEModul; + // break; + // case 3: + // eMod = this.KroenerTensorData[phase].AveragedEModul; + // break; + // case 4: + // eMod = this.DeWittTensorData[phase].AveragedEModul; + // break; + // case 5: + // eMod = this.GeometricHillTensorData[phase].AveragedEModul; + // break; + // default: + // eMod = this.HillTensorData[phase].AveragedEModul; + // break; + // } + + // double plasticStrainRate = 0.0; + // int rateCounter = 0; + + // for (int n = 0; n < stressStrainData.Count; n++) + // { + // if (stressStrainData[n].Stress > totalYieldStrength) + // { + // plasticStrainRate += stressStrainData[n].MacroskopicStrain - stressStrainData[n - 1].MacroskopicStrain; + // rateCounter++; + // } + // } + + // plasticStrainRate /= rateCounter; + + // double plasticStrain = 0.0; + + // for (int n = 0; n < stressStrainData.Count; n++) + // { + // if (stressStrainData[n].Stress > totalYieldStrength) + // { + // plasticStrain += plasticStrainRate; + // } + + // double[] dataTmp = { stressStrainData[n].Stress, ((1 / eMod) * stressStrainData[n].Stress) + plasticStrain }; + + // ret.Add(dataTmp); + // } + + // return ret; + //} + + ///// + ///// return the macroscopic stress strain curve in LOAD DIRECTION + ///// + ///// + ///// + ///// + //public Pattern.Counts GetMacroStrainLatticeStrainCurveLD(int elasticModel, int phase, double totalYieldStrength, List stressStrainData) + //{ + // Pattern.Counts ret = new Pattern.Counts(); + // double eMod = 0.0; + // stressStrainData.Sort((a, b) => a.MacroskopicStrain.CompareTo(b.MacroskopicStrain)); + + // switch (elasticModel) + // { + // case 0: + // eMod = this.VoigtTensorData[phase].AveragedEModul; + // break; + // case 1: + // eMod = this.ReussTensorData[phase].AveragedEModul; + // break; + // case 2: + // eMod = this.HillTensorData[phase].AveragedEModul; + // break; + // case 3: + // eMod = this.KroenerTensorData[phase].AveragedEModul; + // break; + // case 4: + // eMod = this.DeWittTensorData[phase].AveragedEModul; + // break; + // case 5: + // eMod = this.GeometricHillTensorData[phase].AveragedEModul; + // break; + // default: + // eMod = this.HillTensorData[phase].AveragedEModul; + // break; + // } + + // double plasticStrainRate = 0.0; + // int rateCounter = 0; + + // for (int n = 0; n < stressStrainData.Count; n++) + // { + // if (stressStrainData[n].Stress > totalYieldStrength) + // { + // plasticStrainRate += stressStrainData[n].MacroskopicStrain - stressStrainData[n - 1].MacroskopicStrain; + // rateCounter++; + // } + // } + + // plasticStrainRate /= rateCounter; + + // double plasticStrain = 0.0; + + // for (int n = 0; n < stressStrainData.Count; n++) + // { + // if (stressStrainData[n].Stress > totalYieldStrength) + // { + // plasticStrain += plasticStrainRate; + // } + + // double[] dataTmp = { stressStrainData[n].Strain, ((1 / eMod) * stressStrainData[n].Stress) + plasticStrain }; + + // ret.Add(dataTmp); + // } + + // return ret; + //} #endregion #endregion - + #endregion #region Anisotropy diff --git a/CalScec/Analysis/Stress/Macroskopic/TensileDataLoad.xaml b/CalScec/Analysis/Stress/Macroskopic/TensileDataLoad.xaml new file mode 100644 index 0000000..90992f2 --- /dev/null +++ b/CalScec/Analysis/Stress/Macroskopic/TensileDataLoad.xaml @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -634,8 +725,8 @@ - + diff --git a/CalScec/Analysis/Stress/Microsopic/ElasticityCalculationWindow.xaml.cs b/CalScec/Analysis/Stress/Microsopic/ElasticityCalculationWindow.xaml.cs index 6897676..00972ae 100644 --- a/CalScec/Analysis/Stress/Microsopic/ElasticityCalculationWindow.xaml.cs +++ b/CalScec/Analysis/Stress/Microsopic/ElasticityCalculationWindow.xaml.cs @@ -35,6 +35,8 @@ public ElasticityCalculationWindow(Sample usedSample) this.PrepareREKS(); //PrepareStrainFit(); this.LoadData(); + + this.PrepareAnIsoPlot(); } private void PrepareREKS() @@ -128,7 +130,7 @@ private void LoadData() this.PhaseSwitchBox.SelectedIndex = 0; ComboBoxItem ModelItem1 = new ComboBoxItem(); - ModelItem1.Content = "Voigt"; + ModelItem1.Content = "Costom Data"; ComboBoxItem ModelItem2 = new ComboBoxItem(); ModelItem2.Content = "Reuss"; ComboBoxItem ModelItem3 = new ComboBoxItem(); @@ -177,106 +179,137 @@ private void LoadData() this.SetTensorData(); - this.TextureFittingPoolList.ItemsSource = this.TextureFitObjects; + //this.TextureFittingPoolList.ItemsSource = this.TextureFitObjects; TextEventsActive = true; } - private void SetTensorData() + private ElasticityTensors GetSelectedTensor() { - Stress.Microsopic.ElasticityTensors UsedTensor = null; + ElasticityTensors ret = null; - #region Tensor selection + #region Old Code - if (Convert.ToBoolean(this.ActivateTexture.IsChecked)) - { - if (Convert.ToBoolean(this.ActivateWeightedTensor.IsChecked)) - { - switch (this.ModelSwitchBox.SelectedIndex) - { - case 0: - UsedTensor = this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; - break; - case 1: - UsedTensor = this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; - break; - case 2: - UsedTensor = this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; - break; - case 3: - UsedTensor = this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; - break; - case 4: - UsedTensor = this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; - break; - case 5: - UsedTensor = this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; - break; - default: - UsedTensor = this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; - break; - } - } - else - { - switch (this.ModelSwitchBox.SelectedIndex) - { - case 0: - UsedTensor = this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; - break; - case 1: - UsedTensor = this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; - break; - case 2: - UsedTensor = this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; - break; - case 3: - UsedTensor = this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; - break; - case 4: - UsedTensor = this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; - break; - case 5: - UsedTensor = this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; - break; - default: - UsedTensor = this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; - break; - } - } - } - else + //if (Convert.ToBoolean(this.ActivateTexture.IsChecked)) + //{ + // if (Convert.ToBoolean(this.ActivateWeightedTensor.IsChecked)) + // { + // switch (this.ModelSwitchBox.SelectedIndex) + // { + // case 0: + // ret = this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; + // break; + // case 1: + // ret = this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; + // break; + // case 2: + // ret = this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; + // break; + // case 3: + // ret = this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; + // break; + // case 4: + // ret = this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; + // break; + // case 5: + // ret = this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; + // break; + // default: + // ret = this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; + // break; + // } + // } + // else + // { + // switch (this.ModelSwitchBox.SelectedIndex) + // { + // case 0: + // ret = this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; + // break; + // case 1: + // ret = this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; + // break; + // case 2: + // ret = this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; + // break; + // case 3: + // ret = this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; + // break; + // case 4: + // ret = this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; + // break; + // case 5: + // ret = this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; + // break; + // default: + // ret = this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; + // break; + // } + // } + //} + //else + //{ + // switch (this.ModelSwitchBox.SelectedIndex) + // { + // case 0: + // ret = this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex]; + // break; + // case 1: + // ret = this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex]; + // break; + // case 2: + // ret = this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex]; + // break; + // case 3: + // ret = this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex]; + // break; + // case 4: + // ret = this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex]; + // break; + // case 5: + // ret = this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex]; + // break; + // default: + // ret = this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex]; + // break; + // } + //} + + #endregion + + switch (this.ModelSwitchBox.SelectedIndex) { - switch (this.ModelSwitchBox.SelectedIndex) - { - case 0: - UsedTensor = this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex]; - break; - case 1: - UsedTensor = this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex]; - break; - case 2: - UsedTensor = this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex]; - break; - case 3: - UsedTensor = this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex]; - break; - case 4: - UsedTensor = this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex]; - break; - case 5: - UsedTensor = this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex]; - break; - default: - UsedTensor = this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex]; - break; - } + case 0: + ret = this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex]; + break; + case 1: + ret = this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex]; + break; + case 2: + ret = this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex]; + break; + case 3: + ret = this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex]; + break; + case 4: + ret = this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex]; + break; + case 5: + ret = this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex]; + break; + default: + ret = this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex]; + break; } + return ret; + } - #endregion - - if(Convert.ToBoolean(this.FixAnisotropyCheckBox.IsChecked)) + private void SetTensorData() + { + Stress.Microsopic.ElasticityTensors UsedTensor = this.GetSelectedTensor(); + + if (Convert.ToBoolean(this.FixAnisotropyCheckBox.IsChecked)) { UsedTensor.FixedAnIsotropy = true; } @@ -493,8 +526,9 @@ private void SetTensorData() this.AShearModulusFitLabel.Content = UsedTensor.AveragedSchearModulFit.ToString("F3"); this.ABulkModulusFitLabel.Content = UsedTensor.AveragedBulkModulFit.ToString("e3"); - this.UniversalAnisotropyLabel.Content = this.ActSample.GetUniversalAnisotropy(this.PhaseSwitchBox.SelectedIndex).ToString("F3"); - this.ChungBuessemAnistropyLabel.Content = this.ActSample.GetChungBuessemAnistropy(this.PhaseSwitchBox.SelectedIndex).ToString("F3"); + this.UniversalAnisotropyLabel.Content = UsedTensor.GetUniversalAnisotropy().ToString("F3"); + this.EquivalentAnistropyLabel.Content = UsedTensor.GetZenerEquivalentAnisotropy().ToString("F3"); + this.LogEukAnisitropyLabel.Content = this.ActSample.GetLogEukAnisitropyCubic(this.PhaseSwitchBox.SelectedIndex).ToString("F3"); this.FixedAnisotropy.Text = UsedTensor.AnIsotropy.ToString("F3"); this.ZehnderAnisitropyLabel.Content = UsedTensor.GetZehnderAnisotropy.ToString("F3"); @@ -557,285 +591,446 @@ private void RefitConstants_Click(object sender, RoutedEventArgs e) { this.TextEventsActive = false; - if (Convert.ToBoolean(this.ActivateTexture.IsChecked)) + #region Old Code + + //if (Convert.ToBoolean(this.ActivateTexture.IsChecked)) + //{ + // switch (this.ModelSwitchBox.SelectedIndex) + // { + // case 0: + // if (!this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.fitActive) + // { + // this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.FittingModel = 0; + // if (REKSwitchBox.SelectedIndex == 0) + // { + // this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.ClassicalCalculation = true; + // } + // else + // { + // this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.ClassicalCalculation = false; + // } + // System.Threading.ThreadPool.QueueUserWorkItem(this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.FitTensorCallback); + // } + // break; + // case 1: + // if (!this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.fitActive) + // { + // this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.FittingModel = 1; + // if (REKSwitchBox.SelectedIndex == 0) + // { + // this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.ClassicalCalculation = true; + // } + // else + // { + // this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.ClassicalCalculation = false; + // } + // System.Threading.ThreadPool.QueueUserWorkItem(this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.FitTensorCallback); + // } + // break; + // case 2: + // if (!this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.fitActive) + // { + // this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.FittingModel = 2; + // if (REKSwitchBox.SelectedIndex == 0) + // { + // this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.ClassicalCalculation = true; + // } + // else + // { + // this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.ClassicalCalculation = false; ; + // } + // System.Threading.ThreadPool.QueueUserWorkItem(this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.FitTensorCallback); + // } + // break; + // case 3: + // if (!this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.fitActive) + // { + // this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.UseStifnessCalculation = false; + // if (this.StiffnessComlplianceSwitchBox.SelectedIndex == 1) + // { + // this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.UseStifnessCalculation = true; + // } + // this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.FittingModel = 4; + // if (REKSwitchBox.SelectedIndex == 0) + // { + // this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.ClassicalCalculation = true; + // } + // else + // { + // this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.ClassicalCalculation = false; + // } + // System.Threading.ThreadPool.QueueUserWorkItem(this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.FitTensorCallback); + // } + // break; + // case 4: + // if (!this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.fitActive) + // { + // this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.UseStifnessCalculation = false; + // if (this.StiffnessComlplianceSwitchBox.SelectedIndex == 1) + // { + // this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.UseStifnessCalculation = true; + // } + // this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.FittingModel = 5; + // if (REKSwitchBox.SelectedIndex == 0) + // { + // this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.ClassicalCalculation = true; + // } + // else + // { + // this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.ClassicalCalculation = false; + // } + // System.Threading.ThreadPool.QueueUserWorkItem(this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.FitTensorCallback); + // } + // break; + // case 5: + // if (!this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.fitActive) + // { + // this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.FittingModel = 3; + // if (REKSwitchBox.SelectedIndex == 0) + // { + // this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.ClassicalCalculation = true; + // } + // else + // { + // this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.ClassicalCalculation = false; + // } + // System.Threading.ThreadPool.QueueUserWorkItem(this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.FitTensorCallback); + // } + // break; + // default: + // if (!this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.fitActive) + // { + // this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.FittingModel = 0; + // if (REKSwitchBox.SelectedIndex == 0) + // { + // this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.ClassicalCalculation = true; + // } + // else + // { + // this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.ClassicalCalculation = false; + // } + // System.Threading.ThreadPool.QueueUserWorkItem(this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.FitTensorCallback); + // } + // break; + // } + //} + //else + //{ + // switch (this.ModelSwitchBox.SelectedIndex) + // { + // case 0: + // if (REKSwitchBox.SelectedIndex == 0) + // { + // this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].FitVoigt(true); + // } + // else if(REKSwitchBox.SelectedIndex == 2) + // { + // this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].FitVoigtStrain(true); + // } + // else + // { + // this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].FitVoigt(false); + // } + // break; + // case 1: + // if (REKSwitchBox.SelectedIndex == 0) + // { + // this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].FitReuss(true); + // } + // else if (REKSwitchBox.SelectedIndex == 2) + // { + // this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].FitReussStrain(true); + // } + // else if (REKSwitchBox.SelectedIndex == 3) + // { + // if (CalScec.Properties.Settings.Default.ActivateDECTextureWeighting) + // { + // this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].ActivateDECMRDWeighting(); + // } + // else + // { + // this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].DeactivateDECMRDWeighting(); + // } + + // this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].FitReussTextured(true); + // } + // else + // { + // this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].FitReuss(false); + // } + // break; + // case 2: + // if (REKSwitchBox.SelectedIndex == 0) + // { + // this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].FitHill(true); + // } + // else if(REKSwitchBox.SelectedIndex == 3) + // { + // if (CalScec.Properties.Settings.Default.ActivateDECTextureWeighting) + // { + // this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].ActivateDECMRDWeighting(); + // } + // else + // { + // this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].DeactivateDECMRDWeighting(); + // } + + // this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].FitHillTextured(true); + // } + // else + // { + // this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].FitHill(false); + // } + // break; + // case 3: + // bool SC = false; + // if (this.StiffnessComlplianceSwitchBox.SelectedIndex == 1) + // { + // SC = true; + // } + // if (REKSwitchBox.SelectedIndex == 0) + // { + // this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].FitKroener(true, SC); + // } + // else if (REKSwitchBox.SelectedIndex == 3) + // { + // if (CalScec.Properties.Settings.Default.ActivateDECTextureWeighting) + // { + // this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].ActivateDECMRDWeighting(); + // } + // else + // { + // this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].DeactivateDECMRDWeighting(); + // } + + // this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].FitKroenerTextured(true, SC); + // } + // else + // { + // this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].FitKroener(false, SC); + // } + // break; + // case 4: + // bool SC1 = false; + // if (this.StiffnessComlplianceSwitchBox.SelectedIndex == 1) + // { + // SC1 = true; + // } + // if (REKSwitchBox.SelectedIndex == 0) + // { + // this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].FitDeWitt(true, SC1); + // } + // else if (REKSwitchBox.SelectedIndex == 3) + // { + // if (CalScec.Properties.Settings.Default.ActivateDECTextureWeighting) + // { + // this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].ActivateDECMRDWeighting(); + // } + // else + // { + // this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].DeactivateDECMRDWeighting(); + // } + + // this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].FitDeWittTextured(true, SC1); + // } + // else + // { + // this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].FitDeWitt(false, SC1); + // } + // break; + // case 5: + // if (REKSwitchBox.SelectedIndex == 0) + // { + // this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].FitGeometricHill(true); + // } + // else if(REKSwitchBox.SelectedIndex == 3) + // { + // if (CalScec.Properties.Settings.Default.ActivateDECTextureWeighting) + // { + // this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].ActivateDECMRDWeighting(); + // } + // else + // { + // this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].DeactivateDECMRDWeighting(); + // } + + // this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].FitGeometricHillTextured(true); + // } + // else + // { + // this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].FitGeometricHill(false); + // } + // break; + // default: + // if (REKSwitchBox.SelectedIndex == 0) + // { + // this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].FitVoigt(true); + // } + // else + // { + // this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].FitVoigt(false); + // } + // break; + // } + //} + + #endregion + + switch (this.ModelSwitchBox.SelectedIndex) { - switch (this.ModelSwitchBox.SelectedIndex) - { - case 0: - if (!this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.fitActive) - { - this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.FittingModel = 0; - if (REKSwitchBox.SelectedIndex == 0) - { - this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.ClassicalCalculation = true; - } - else - { - this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.ClassicalCalculation = false; - } - System.Threading.ThreadPool.QueueUserWorkItem(this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.FitTensorCallback); - } - break; - case 1: - if (!this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.fitActive) - { - this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.FittingModel = 1; - if (REKSwitchBox.SelectedIndex == 0) - { - this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.ClassicalCalculation = true; - } - else - { - this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.ClassicalCalculation = false; - } - System.Threading.ThreadPool.QueueUserWorkItem(this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.FitTensorCallback); - } - break; - case 2: - if (!this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.fitActive) - { - this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.FittingModel = 2; - if (REKSwitchBox.SelectedIndex == 0) - { - this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.ClassicalCalculation = true; - } - else - { - this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.ClassicalCalculation = false; ; - } - System.Threading.ThreadPool.QueueUserWorkItem(this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.FitTensorCallback); - } - break; - case 3: - if (!this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.fitActive) - { - this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.UseStifnessCalculation = false; - if (this.StiffnessComlplianceSwitchBox.SelectedIndex == 1) - { - this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.UseStifnessCalculation = true; - } - this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.FittingModel = 4; - if (REKSwitchBox.SelectedIndex == 0) - { - this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.ClassicalCalculation = true; - } - else - { - this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.ClassicalCalculation = false; - } - System.Threading.ThreadPool.QueueUserWorkItem(this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.FitTensorCallback); - } - break; - case 4: - if (!this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.fitActive) + case 0: + if (REKSwitchBox.SelectedIndex == 0) + { + this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].FitVoigt(true); + } + else if (REKSwitchBox.SelectedIndex == 2) + { + this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].FitVoigtStrain(true); + } + else + { + this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].FitVoigt(false); + } + break; + case 1: + if (REKSwitchBox.SelectedIndex == 0) + { + this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].FitReuss(true); + } + else if (REKSwitchBox.SelectedIndex == 2) + { + this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].FitReussStrain(true); + } + else if (REKSwitchBox.SelectedIndex == 3) + { + if (CalScec.Properties.Settings.Default.ActivateDECTextureWeighting) { - this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.UseStifnessCalculation = false; - if (this.StiffnessComlplianceSwitchBox.SelectedIndex == 1) - { - this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.UseStifnessCalculation = true; - } - this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.FittingModel = 5; - if (REKSwitchBox.SelectedIndex == 0) - { - this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.ClassicalCalculation = true; - } - else - { - this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.ClassicalCalculation = false; - } - System.Threading.ThreadPool.QueueUserWorkItem(this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.FitTensorCallback); + this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].ActivateDECMRDWeighting(); } - break; - case 5: - if (!this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.fitActive) + else { - this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.FittingModel = 3; - if (REKSwitchBox.SelectedIndex == 0) - { - this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.ClassicalCalculation = true; - } - else - { - this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.ClassicalCalculation = false; - } - System.Threading.ThreadPool.QueueUserWorkItem(this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.FitTensorCallback); + this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].DeactivateDECMRDWeighting(); } - break; - default: - if (!this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.fitActive) + + this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].FitReussTextured(true); + } + else + { + this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].FitReuss(false); + } + break; + case 2: + if (REKSwitchBox.SelectedIndex == 0) + { + this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].FitHill(true); + } + else if (REKSwitchBox.SelectedIndex == 3) + { + if (CalScec.Properties.Settings.Default.ActivateDECTextureWeighting) { - this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.FittingModel = 0; - if (REKSwitchBox.SelectedIndex == 0) - { - this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.ClassicalCalculation = true; - } - else - { - this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.ClassicalCalculation = false; - } - System.Threading.ThreadPool.QueueUserWorkItem(this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.FitTensorCallback); + this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].ActivateDECMRDWeighting(); } - break; - } - } - else - { - switch (this.ModelSwitchBox.SelectedIndex) - { - case 0: - if (REKSwitchBox.SelectedIndex == 0) + else { - this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].FitVoigt(true); + this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].DeactivateDECMRDWeighting(); } - else if(REKSwitchBox.SelectedIndex == 2) + + this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].FitHillTextured(true); + } + else + { + this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].FitHill(false); + } + break; + case 3: + bool SC = false; + if (this.StiffnessComlplianceSwitchBox.SelectedIndex == 1) + { + SC = true; + } + if (REKSwitchBox.SelectedIndex == 0) + { + this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].FitKroener(true, SC); + } + else if (REKSwitchBox.SelectedIndex == 3) + { + if (CalScec.Properties.Settings.Default.ActivateDECTextureWeighting) { - this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].FitVoigtStrain(true); + this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].ActivateDECMRDWeighting(); } else { - this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].FitVoigt(false); + this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].DeactivateDECMRDWeighting(); } - break; - case 1: - if (REKSwitchBox.SelectedIndex == 0) + + this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].FitKroenerTextured(true, SC); + } + else + { + this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].FitKroener(false, SC); + } + break; + case 4: + bool SC1 = false; + if (this.StiffnessComlplianceSwitchBox.SelectedIndex == 1) + { + SC1 = true; + } + if (REKSwitchBox.SelectedIndex == 0) + { + this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].FitDeWitt(true, SC1); + } + else if (REKSwitchBox.SelectedIndex == 3) + { + if (CalScec.Properties.Settings.Default.ActivateDECTextureWeighting) { - this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].FitReuss(true); + this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].ActivateDECMRDWeighting(); } - else if (REKSwitchBox.SelectedIndex == 2) + else { - this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].FitReussStrain(true); + this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].DeactivateDECMRDWeighting(); } - else if (REKSwitchBox.SelectedIndex == 3) - { - if (CalScec.Properties.Settings.Default.ActivateDECTextureWeighting) - { - this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].ActivateDECMRDWeighting(); - } - else - { - this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].DeactivateDECMRDWeighting(); - } - this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].FitReussTextured(true); + this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].FitDeWittTextured(true, SC1); + } + else + { + this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].FitDeWitt(false, SC1); + } + break; + case 5: + if (REKSwitchBox.SelectedIndex == 0) + { + this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].FitGeometricHill(true); + } + else if (REKSwitchBox.SelectedIndex == 3) + { + if (CalScec.Properties.Settings.Default.ActivateDECTextureWeighting) + { + this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].ActivateDECMRDWeighting(); } else { - this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].FitReuss(false); + this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].DeactivateDECMRDWeighting(); } - break; - case 2: - if (REKSwitchBox.SelectedIndex == 0) - { - this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].FitHill(true); - } - else if(REKSwitchBox.SelectedIndex == 3) - { - if (CalScec.Properties.Settings.Default.ActivateDECTextureWeighting) - { - this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].ActivateDECMRDWeighting(); - } - else - { - this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].DeactivateDECMRDWeighting(); - } - - this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].FitHillTextured(true); - } - else - { - this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].FitHill(false); - } - break; - case 3: - bool SC = false; - if (this.StiffnessComlplianceSwitchBox.SelectedIndex == 1) - { - SC = true; - } - if (REKSwitchBox.SelectedIndex == 0) - { - this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].FitKroener(true, SC); - } - else if (REKSwitchBox.SelectedIndex == 3) - { - if (CalScec.Properties.Settings.Default.ActivateDECTextureWeighting) - { - this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].ActivateDECMRDWeighting(); - } - else - { - this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].DeactivateDECMRDWeighting(); - } - - this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].FitKroenerTextured(true, SC); - } - else - { - this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].FitKroener(false, SC); - } - break; - case 4: - bool SC1 = false; - if (this.StiffnessComlplianceSwitchBox.SelectedIndex == 1) - { - SC1 = true; - } - if (REKSwitchBox.SelectedIndex == 0) - { - this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].FitDeWitt(true, SC1); - } - else if (REKSwitchBox.SelectedIndex == 3) - { - if (CalScec.Properties.Settings.Default.ActivateDECTextureWeighting) - { - this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].ActivateDECMRDWeighting(); - } - else - { - this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].DeactivateDECMRDWeighting(); - } - - this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].FitDeWittTextured(true, SC1); - } - else - { - this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].FitDeWitt(false, SC1); - } - break; - case 5: - if (REKSwitchBox.SelectedIndex == 0) - { - this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].FitGeometricHill(true); - } - else if(REKSwitchBox.SelectedIndex == 3) - { - if (CalScec.Properties.Settings.Default.ActivateDECTextureWeighting) - { - this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].ActivateDECMRDWeighting(); - } - else - { - this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].DeactivateDECMRDWeighting(); - } - this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].FitGeometricHillTextured(true); - } - else - { - this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].FitGeometricHill(false); - } - break; - default: - if (REKSwitchBox.SelectedIndex == 0) - { - this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].FitVoigt(true); - } - else - { - this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].FitVoigt(false); - } - break; - } + this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].FitGeometricHillTextured(true); + } + else + { + this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].FitGeometricHill(false); + } + break; + default: + if (REKSwitchBox.SelectedIndex == 0) + { + this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].FitReuss(true); + } + else + { + this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].FitReuss(false); + } + break; } this.SetTensorData(); @@ -847,97 +1042,7 @@ private void Tensor_TextChanged(object sender, TextChangedEventArgs e) { if(this.TextEventsActive) { - Stress.Microsopic.ElasticityTensors UsedTensor = null; - - #region Tensor selection - - if (Convert.ToBoolean(this.ActivateTexture.IsChecked)) - { - if (Convert.ToBoolean(this.ActivateWeightedTensor.IsChecked)) - { - switch (this.ModelSwitchBox.SelectedIndex) - { - case 0: - UsedTensor = this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; - break; - case 1: - UsedTensor = this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; - break; - case 2: - UsedTensor = this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; - break; - case 3: - UsedTensor = this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; - break; - case 4: - UsedTensor = this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; - break; - case 5: - UsedTensor = this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; - break; - default: - UsedTensor = this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; - break; - } - } - else - { - switch (this.ModelSwitchBox.SelectedIndex) - { - case 0: - UsedTensor = this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; - break; - case 1: - UsedTensor = this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; - break; - case 2: - UsedTensor = this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; - break; - case 3: - UsedTensor = this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; - break; - case 4: - UsedTensor = this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; - break; - case 5: - UsedTensor = this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; - break; - default: - UsedTensor = this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; - break; - } - } - } - else - { - switch (this.ModelSwitchBox.SelectedIndex) - { - case 0: - UsedTensor = this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex]; - break; - case 1: - UsedTensor = this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex]; - break; - case 2: - UsedTensor = this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex]; - break; - case 3: - UsedTensor = this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex]; - break; - case 4: - UsedTensor = this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex]; - break; - case 5: - UsedTensor = this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex]; - break; - default: - UsedTensor = this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex]; - break; - } - } - - - #endregion + Stress.Microsopic.ElasticityTensors UsedTensor = this.GetSelectedTensor(); TextBox UsedTextBox = sender as TextBox; @@ -1483,17 +1588,17 @@ private void TextureFitStartedHandler(Texture.OrientationDistributionFunction oD this.textureId++; TextureFitObjects.Add(oDF.FitDisplayInfo); - this.TextureFittingPoolList.Items.Refresh(); + //this.TextureFittingPoolList.Items.Refresh(); - if (this.TextureProgress.IsIndeterminate) - { - this.TextureProgress.ToolTip = "Fitting " + Convert.ToString(this.TextureFitObjects.Count) + " Tensors"; - } - else - { - this.TextureProgress.IsIndeterminate = true; - this.TextureProgress.ToolTip = "Fitting " + Convert.ToString(this.TextureFitObjects.Count) + " Tensors"; - } + //if (this.TextureProgress.IsIndeterminate) + //{ + // this.TextureProgress.ToolTip = "Fitting " + Convert.ToString(this.TextureFitObjects.Count) + " Tensors"; + //} + //else + //{ + // this.TextureProgress.IsIndeterminate = true; + // this.TextureProgress.ToolTip = "Fitting " + Convert.ToString(this.TextureFitObjects.Count) + " Tensors"; + //} } private void TextureFitUpdatedHandler(Texture.OrientationDistributionFunction oDF) @@ -1505,8 +1610,8 @@ private void TextureFitUpdatedHandler(Texture.OrientationDistributionFunction oD // TextureFitObjects[n].LMATrial++; // } //} - this.TextureFittingPoolList.Items.Refresh(); - this.SetTensorData(); + //this.TextureFittingPoolList.Items.Refresh(); + //this.SetTensorData(); } private void TextureFitFinishedHandler(Texture.OrientationDistributionFunction oDF) @@ -1520,273 +1625,737 @@ private void TextureFitFinishedHandler(Texture.OrientationDistributionFunction o } } - this.TextureFittingPoolList.Items.Refresh(); + //this.TextureFittingPoolList.Items.Refresh(); - this.TextureProgress.ToolTip = "Fitting " + Convert.ToString(this.TextureFitObjects.Count) + " Tensors"; + //this.TextureProgress.ToolTip = "Fitting " + Convert.ToString(this.TextureFitObjects.Count) + " Tensors"; - if (this.TextureFitObjects.Count == 0) - { - this.TextureProgress.IsIndeterminate = false; - } + //if (this.TextureFitObjects.Count == 0) + //{ + // this.TextureProgress.IsIndeterminate = false; + //} } #endregion #endregion - private void FixAnisotropyCheckBox_Checked(object sender, RoutedEventArgs e) - { - this.TextEventsActive = false; - this.SetTensorData(); - this.TextEventsActive = true; - } + #region Anisotropy - private void FixAnisotropyCheckBox_Unchecked(object sender, RoutedEventArgs e) + private Tools.PlottingWindow AniIsoPlotWindow = new Tools.PlottingWindow(); + public OxyPlot.PlotModel AnIsoPlotModel = new OxyPlot.PlotModel(); + OxyPlot.Axes.AngleAxis AnIsoAngleAxis = new OxyPlot.Axes.AngleAxis(); + OxyPlot.Axes.MagnitudeAxis AnIsoValueAxis = new OxyPlot.Axes.MagnitudeAxis(); + + private void PrepareAnIsoPlot() { - this.TextEventsActive = false; - this.SetTensorData(); - this.TextEventsActive = true; + AnIsoPlotModel.PlotType = OxyPlot.PlotType.Polar; + + AnIsoPlotModel.LegendBorder = OxyPlot.OxyColors.Black; + AnIsoPlotModel.LegendItemAlignment = OxyPlot.HorizontalAlignment.Left; + AnIsoPlotModel.LegendTitle = "Used modeling"; + AnIsoPlotModel.LegendFontSize = 28; + AnIsoPlotModel.LegendTitleFontSize = 30; + + AnIsoAngleAxis.MajorGridlineStyle = OxyPlot.LineStyle.Dash; + AnIsoAngleAxis.MinorGridlineStyle = OxyPlot.LineStyle.Dot; + AnIsoAngleAxis.FractionUnit = 2 * Math.PI; + AnIsoAngleAxis.FractionUnitSymbol = "π"; + AnIsoAngleAxis.FontSize = 28; + AnIsoAngleAxis.TitleFontSize = 30; + AnIsoAngleAxis.IsAxisVisible = false; + + AnIsoValueAxis.MajorGridlineStyle = OxyPlot.LineStyle.Dash; + AnIsoValueAxis.MinorGridlineStyle = OxyPlot.LineStyle.Dot; + //AnIsoValueAxis.FractionUnitSymbol = "GPa"; + //AnIsoAngleAxis.Minimum = 0.0; + AnIsoValueAxis.FractionUnit = 1000; + AnIsoValueAxis.FormatAsFractions = true; + AnIsoValueAxis.Title = "GPa"; + AnIsoValueAxis.FontSize = 28; + AnIsoValueAxis.TitleFontSize = 30; + AnIsoValueAxis.MinimumMajorStep = 5000; + + + AnIsoPlotModel.Axes.Add(AnIsoAngleAxis); + AnIsoPlotModel.Axes.Add(AnIsoValueAxis); + + AniIsoPlotWindow.MainPlot.Model = AnIsoPlotModel; } - private void ZehnderAnisotropy_TextChanged(object sender, TextChangedEventArgs e) + private void SetAnIsoData(ElasticityTensors usedTensor, int h, int k, int l, OxyPlot.Series.LineSeries parameterSeries, MathNet.Numerics.LinearAlgebra.Vector angleDirection, double angleCorrection) { - Stress.Microsopic.ElasticityTensors UsedTensor = null; + MathNet.Numerics.LinearAlgebra.Vector angleVector = MathNet.Numerics.LinearAlgebra.CreateVector.Dense(3, 0.0); + + angleVector[0] = h; + angleVector[1] = k; + angleVector[2] = l; + + - #region Tensor selection + double angle = Math.Acos((angleDirection * angleVector) / (angleDirection.L2Norm() * angleVector.L2Norm())); + angle += angleCorrection; - if (Convert.ToBoolean(this.ActivateTexture.IsChecked)) + double s1 = 0.0; + double s2 = 0.0; + + DataManagment.CrystalData.HKLReflex reflex = new DataManagment.CrystalData.HKLReflex(h, k, l, 1.0); + + if (usedTensor.Symmetry == "hexagonal") { - if (Convert.ToBoolean(this.ActivateWeightedTensor.IsChecked)) - { - switch (this.ModelSwitchBox.SelectedIndex) - { - case 0: - UsedTensor = this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; - break; - case 1: - UsedTensor = this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; - break; - case 2: - UsedTensor = this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; - break; - case 3: - UsedTensor = this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; - break; - case 4: - UsedTensor = this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; - break; - case 5: - UsedTensor = this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; - break; - default: - UsedTensor = this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; - break; - } - } - else + switch (AnIsoModelSelector.SelectedIndex) { - switch (this.ModelSwitchBox.SelectedIndex) - { - case 0: - UsedTensor = this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; - break; - case 1: - UsedTensor = this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; - break; - case 2: - UsedTensor = this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; - break; - case 3: - UsedTensor = this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; - break; - case 4: - UsedTensor = this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; - break; - case 5: - UsedTensor = this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; - break; - default: - UsedTensor = this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; - break; - } + case 0: + s1 = usedTensor.S1VoigtCubic(); + s2 = usedTensor.HS2VoigtCubic(); + break; + case 1: + s1 = usedTensor.S1ReussHexagonal(reflex); + s2 = usedTensor.HS2ReussHexagonal(reflex); + break; + case 2: + s1 = usedTensor.S1HillHexagonal(reflex); + s2 = usedTensor.HS2HillHexagonal(reflex); + break; + case 3: + s1 = usedTensor.S1ReussHexagonal(reflex); + s2 = usedTensor.HS2ReussHexagonal(reflex); + break; + case 5: + s1 = usedTensor.S1GeometricHillHexagonal(reflex); + s2 = usedTensor.HS2GeometricHillHexagonal(reflex); + break; + default: + s1 = usedTensor.S1ReussHexagonal(reflex); + s2 = usedTensor.HS2ReussHexagonal(reflex); + break; } + //double orientationParameter = usedTensor.OrientationParameterH(h, k, 0); + + //s1 = usedTensor.DirectionalS1ReussHexagonal(orientationParameter); + //s2 = usedTensor.DirectionalS2ReussHexagonal(orientationParameter); } else { - switch (this.ModelSwitchBox.SelectedIndex) + switch(AnIsoModelSelector.SelectedIndex) { case 0: - UsedTensor = this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex]; + s1 = usedTensor.S1VoigtCubic(); + s2 = usedTensor.HS2VoigtCubic(); break; case 1: - UsedTensor = this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex]; + s1 = usedTensor.S1ReussCubic(reflex); + s2 = usedTensor.HS2ReussCubic(reflex); break; case 2: - UsedTensor = this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex]; + s1 = usedTensor.S1HillCubic(reflex); + s2 = usedTensor.HS2HillCubic(reflex); break; case 3: - UsedTensor = this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex]; + s1 = usedTensor.S1KroenerCubicComplianceAnIso(); + s2 = usedTensor.HS2KroenerCubicComplianceAnIso(); break; case 4: - UsedTensor = this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex]; + s1 = usedTensor.S1DeWittCubicComplianceAnIso(reflex); + s2 = usedTensor.HS2DeWittCubicComplianceAnIso(reflex); break; case 5: - UsedTensor = this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex]; + s1 = usedTensor.S1GeometricHillCubic(reflex); + s2 = usedTensor.HS2GeometricHillCubic(reflex); break; default: - UsedTensor = this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex]; + s1 = usedTensor.S1ReussCubic(reflex); + s2 = usedTensor.HS2ReussCubic(reflex); break; } } + REK rekTmp = new REK(usedTensor.GetPhaseInformation, reflex); - #endregion - try + rekTmp.ClassicFittingFunction.Constant = s1; + rekTmp.ClassicFittingFunction.Aclivity = s2; + + OxyPlot.DataPoint plotPoint = new OxyPlot.DataPoint(0, 0); + + switch (this.AnIsoParamSelector.SelectedIndex) { - UsedTensor.AnIsotropy = Convert.ToDouble(this.FixedAnisotropy.Text); - this.TextEventsActive = false; - this.SetTensorData(); - this.TextEventsActive = true; + case 0: + plotPoint = new OxyPlot.DataPoint(rekTmp.ClassicEModulus, angle); + break; + case 1: + plotPoint = new OxyPlot.DataPoint(rekTmp.ClassicShearModulus, angle); + break; + case 2: + plotPoint = new OxyPlot.DataPoint(rekTmp.ClassicTransverseContraction, angle); + break; + case 3: + plotPoint = new OxyPlot.DataPoint(rekTmp.ClassicBulkModulus, angle); + break; + default: + plotPoint = new OxyPlot.DataPoint(rekTmp.ClassicEModulus, angle); + break; } - catch - { - } + parameterSeries.Points.Add(plotPoint); } - private void StartAnalysis_Click(object sender, RoutedEventArgs e) + private void SetAnIsoPlot() { - Tools.ValueSelection VWindow = new Tools.ValueSelection(); + MathNet.Numerics.LinearAlgebra.Vector angleDirection = MathNet.Numerics.LinearAlgebra.CreateVector.Dense(3, 0.0); + MathNet.Numerics.LinearAlgebra.Vector plainDirection = MathNet.Numerics.LinearAlgebra.CreateVector.Dense(3, 0.0); - VWindow.ShowDialog(); + ElasticityTensors usedTensor = this.GetSelectedTensor(); + + switch (AnIsoPlotDirectionSelection.SelectedIndex) + { + case 0: + angleDirection[0] = 1; + angleDirection[1] = 0; + angleDirection[2] = 0; - Microsoft.Win32.SaveFileDialog XlsxSaveFile = new Microsoft.Win32.SaveFileDialog(); - XlsxSaveFile.FileName = VWindow.fileName; - XlsxSaveFile.DefaultExt = ""; - XlsxSaveFile.Filter = "Excel data (.xlsx)|*.xlsx"; + plainDirection[0] = 0; + plainDirection[1] = 1; + plainDirection[2] = 0; + break; + case 1: + angleDirection[0] = 1; + angleDirection[1] = 0; + angleDirection[2] = 0; - Nullable Opened = XlsxSaveFile.ShowDialog(); + plainDirection[0] = 0; + plainDirection[1] = 0; + plainDirection[2] = 1; + break; + case 2: + angleDirection[0] = 0; + angleDirection[1] = 1; + angleDirection[2] = 0; - if (Opened == true) - { - string filename = XlsxSaveFile.FileName; - string PathName = filename.Replace(XlsxSaveFile.SafeFileName, ""); - System.IO.Directory.CreateDirectory(PathName); + plainDirection[0] = 0; + plainDirection[1] = 0; + plainDirection[2] = 1; + break; + case 4: + angleDirection[0] = 1; + angleDirection[1] = 0; + angleDirection[2] = 0; - Stress.Microsopic.ElasticityTensors UsedTensor = null; - int model = 0; + plainDirection[0] = 0; + plainDirection[1] = 1; + plainDirection[2] = 1; + break; + case 5: + angleDirection[0] = 0; + angleDirection[1] = 1; + angleDirection[2] = 0; - #region Tensor selection + plainDirection[0] = 1; + plainDirection[1] = 0; + plainDirection[2] = 1; + break; + case 6: + angleDirection[0] = 0; + angleDirection[1] = 0; + angleDirection[2] = 1; + + plainDirection[0] = 1; + plainDirection[1] = 1; + plainDirection[2] = 0; + break; + case 8: + angleDirection[0] = 1; + angleDirection[1] = 1; + angleDirection[2] = 0; + + plainDirection[0] = 1; + plainDirection[1] = -1; + plainDirection[2] = 0; + break; + case 9: + angleDirection[0] = 1; + angleDirection[1] = 0; + angleDirection[2] = 1; + + plainDirection[0] = 1; + plainDirection[1] = 0; + plainDirection[2] = -1; + break; + case 10: + angleDirection[0] = 0; + angleDirection[1] = 1; + angleDirection[2] = 1; + + plainDirection[0] = 0; + plainDirection[1] = 1; + plainDirection[2] = -1; + break; + case 12: + angleDirection[0] = 1; + angleDirection[1] = 1; + angleDirection[2] = 1; + + plainDirection[0] = 1; + plainDirection[1] = -1; + plainDirection[2] = 0; + break; + case 13: + angleDirection[0] = 1; + angleDirection[1] = 1; + angleDirection[2] = 1; + + plainDirection[0] = 1; + plainDirection[1] = 0; + plainDirection[2] = -1; + break; + case 14: + angleDirection[0] = 1; + angleDirection[1] = 1; + angleDirection[2] = 1; + + plainDirection[0] = 0; + plainDirection[1] = 1; + plainDirection[2] = -1; + break; + default: + angleDirection[0] = 1; + angleDirection[1] = 0; + angleDirection[2] = 0; - if (Convert.ToBoolean(this.ActivateTexture.IsChecked)) - { - if (Convert.ToBoolean(this.ActivateWeightedTensor.IsChecked)) + plainDirection[0] = 0; + plainDirection[1] = 1; + plainDirection[2] = 0; + break; + } + + MathNet.Numerics.LinearAlgebra.Vector normalDirection = MathNet.Numerics.LinearAlgebra.CreateVector.Dense(3, 0.0); + normalDirection[0] = angleDirection[1] * plainDirection[2] - angleDirection[2] * plainDirection[1]; + normalDirection[1] = -angleDirection[0] * plainDirection[2] + angleDirection[2] * plainDirection[0]; + normalDirection[2] = angleDirection[0] * plainDirection[1] - angleDirection[1] * plainDirection[0]; + + double viewCheck = angleDirection * plainDirection; + + if(usedTensor != null && viewCheck == 0) + { + OxyPlot.Series.LineSeries parameterSeries = new OxyPlot.Series.LineSeries(); + parameterSeries.LineStyle = OxyPlot.LineStyle.None; + parameterSeries.MarkerType = OxyPlot.MarkerType.Circle; + parameterSeries.MarkerSize = 2; + + #region Title + + parameterSeries.Title = "Constants: "; + switch (ModelSwitchBox.SelectedIndex) + { + case 0: + parameterSeries.Title += "Voigt"; + break; + case 1: + parameterSeries.Title += "Reuss"; + break; + case 2: + parameterSeries.Title += "Hill"; + break; + case 3: + parameterSeries.Title += "Kroener"; + break; + case 4: + parameterSeries.Title += "De Wit"; + break; + case 5: + parameterSeries.Title += "Matthies"; + break; + default: + parameterSeries.Title += "Reuss"; + break; + } + //switch (ModelSwitchBox.SelectedIndex) + //{ + // case 0: + // parameterSeries.Title += "Voigt; Modeling: "; + // break; + // case 1: + // parameterSeries.Title += "Reuss; Modeling: "; + // break; + // case 2: + // parameterSeries.Title += "Hill; Modeling: "; + // break; + // case 3: + // parameterSeries.Title += "Kroener; Modeling: "; + // break; + // case 4: + // parameterSeries.Title += "De Wit; Modeling: "; + // break; + // case 5: + // parameterSeries.Title += "Matthies; Modeling: "; + // break; + // default: + // parameterSeries.Title += "Reuss; Modeling: "; + // break; + //} + + //switch (AnIsoModelSelector.SelectedIndex) + //{ + // case 0: + // parameterSeries.Title += "Voigt"; + // break; + // case 1: + // parameterSeries.Title += "Reuss"; + // break; + // case 2: + // parameterSeries.Title += "Hill"; + // break; + // case 3: + // parameterSeries.Title += "Kroener"; + // break; + // case 4: + // parameterSeries.Title += "De Wit"; + // break; + // case 5: + // parameterSeries.Title += "Matthies"; + // break; + // default: + // parameterSeries.Title += "Reuss"; + // break; + //} + + #endregion + + //parameterSeries.Title = "Zener Anisotropy: " + usedTensor.GetZehnderAnisotropy.ToString("F3"); + + #region Color + + switch (AnIsoColorSelector.SelectedIndex) + { + case 0: + parameterSeries.Color = OxyPlot.OxyColors.Black; + parameterSeries.MarkerFill = OxyPlot.OxyColors.Black; + break; + case 1: + parameterSeries.Color = OxyPlot.OxyColors.DarkGray; + parameterSeries.MarkerFill = OxyPlot.OxyColors.DarkGray; + break; + case 2: + parameterSeries.Color = OxyPlot.OxyColors.DarkBlue; + parameterSeries.MarkerFill = OxyPlot.OxyColors.DarkBlue; + break; + case 3: + parameterSeries.Color = OxyPlot.OxyColors.Blue; + parameterSeries.MarkerFill = OxyPlot.OxyColors.Blue; + break; + case 4: + parameterSeries.Color = OxyPlot.OxyColors.DarkGreen; + parameterSeries.MarkerFill = OxyPlot.OxyColors.DarkGreen; + break; + case 5: + parameterSeries.Color = OxyPlot.OxyColors.Green; + parameterSeries.MarkerFill = OxyPlot.OxyColors.Green; + break; + case 6: + parameterSeries.Color = OxyPlot.OxyColors.DarkRed; + parameterSeries.MarkerFill = OxyPlot.OxyColors.DarkRed; + break; + case 7: + parameterSeries.Color = OxyPlot.OxyColors.Red; + parameterSeries.MarkerFill = OxyPlot.OxyColors.Red; + break; + case 8: + parameterSeries.Color = OxyPlot.OxyColors.Orange; + parameterSeries.MarkerFill = OxyPlot.OxyColors.Orange; + break; + case 9: + parameterSeries.Color = OxyPlot.OxyColors.Yellow; + parameterSeries.MarkerFill = OxyPlot.OxyColors.Yellow; + break; + default: + parameterSeries.Color = OxyPlot.OxyColors.Black; + parameterSeries.MarkerFill = OxyPlot.OxyColors.Black; + break; + } + + #endregion + + if (this.AnIsoPlotModel.Annotations.Count == 0) + { + OxyPlot.Annotations.LineAnnotation mainViewAxes = new OxyPlot.Annotations.LineAnnotation(); + mainViewAxes.LineStyle = OxyPlot.LineStyle.Solid; + mainViewAxes.Color = OxyPlot.OxyColors.Black; + mainViewAxes.MinimumX = 0.0; + mainViewAxes.MaximumX = 250000; + mainViewAxes.Type = OxyPlot.Annotations.LineAnnotationType.Horizontal; + mainViewAxes.Y = 0.0; + mainViewAxes.StrokeThickness = 2; + mainViewAxes.Text = "[" + angleDirection[0].ToString() + " " + angleDirection[1].ToString() + " " + angleDirection[2].ToString() + "]"; + mainViewAxes.FontSize = 25; + + OxyPlot.Annotations.LineAnnotation secondaryViewAxes = new OxyPlot.Annotations.LineAnnotation(); + secondaryViewAxes.LineStyle = OxyPlot.LineStyle.Solid; + secondaryViewAxes.Color = OxyPlot.OxyColors.Black; + secondaryViewAxes.MinimumX = 0.0; + secondaryViewAxes.MaximumX = 250000; + secondaryViewAxes.Type = OxyPlot.Annotations.LineAnnotationType.Horizontal; + secondaryViewAxes.Y = Math.PI / 2.0; + secondaryViewAxes.StrokeThickness = 2; + secondaryViewAxes.Text = "[" + plainDirection[0].ToString() + " " + plainDirection[1].ToString() + " " + plainDirection[2].ToString() + "]"; + secondaryViewAxes.FontSize = 25; + + AnIsoPlotModel.Annotations.Add(mainViewAxes); + AnIsoPlotModel.Annotations.Add(secondaryViewAxes); + } + + #region + + double param1Count = 0; + double param2Count = 0; + for(int n = 0; n < 3; n++) + { + if(angleDirection[n] != 0) { - switch (this.ModelSwitchBox.SelectedIndex) - { - case 0: - UsedTensor = this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; - model = 0; - break; - case 1: - UsedTensor = this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; - model = 1; - break; - case 2: - UsedTensor = this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; - model = 2; - break; - case 3: - UsedTensor = this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; - model = 3; - break; - case 4: - UsedTensor = this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; - model = 4; - break; - case 5: - UsedTensor = this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; - model = 5; - break; - default: - UsedTensor = this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.TextureTensor; - model = 0; - break; - } + param1Count++; } - else + if(plainDirection[n] != 0) { - switch (this.ModelSwitchBox.SelectedIndex) - { - case 0: - UsedTensor = this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; - model = 1; - break; - case 1: - UsedTensor = this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; - model = 2; - break; - case 2: - UsedTensor = this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; - model = 3; - break; - case 3: - UsedTensor = this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; - model = 4; - break; - case 4: - UsedTensor = this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; - model = 5; - break; - case 5: - UsedTensor = this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; - model = 6; - break; - default: - UsedTensor = this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].ODF.BaseTensor; - model = 0; - break; - } + param2Count++; } } - else + + for (int h = -50; h < 50; h++) { - switch (this.ModelSwitchBox.SelectedIndex) + for (int k = -50; k < 50; k++) { - case 0: - UsedTensor = this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex]; - model = 0; - break; - case 1: - UsedTensor = this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex]; - model = 1; - break; - case 2: - UsedTensor = this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex]; - model = 2; - break; - case 3: - UsedTensor = this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex]; - model = 3; - break; - case 4: - UsedTensor = this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex]; - model = 4; - break; - case 5: - UsedTensor = this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex]; - model = 5; - break; - default: - UsedTensor = this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex]; - model = 0; - break; + for (int l = -50; l < 50; l++) + { + MathNet.Numerics.LinearAlgebra.Vector calcDirection = MathNet.Numerics.LinearAlgebra.CreateVector.Dense(3, 0.0); + calcDirection[0] = h; + calcDirection[1] = k; + calcDirection[2] = l; + + double normalTest = normalDirection * calcDirection; + + if (Math.Abs(normalTest) < 0.001) + { + double angleCorrection = 0.0; + + switch (AnIsoPlotDirectionSelection.SelectedIndex) + { + case 0: + goto case 2; + case 1: + goto case 2; + case 2: + if (h < 0 && k < 0) + { + + } + else if (h < 0 && l < 0) + { + + } + else if (k < 0 && l < 0) + { + + } + else if (h < 0) + { + angleCorrection += Math.PI; + } + else if (k < 0) + { + angleCorrection += Math.PI; + } + else if (l < 0) + { + angleCorrection += Math.PI; + } + break; + case 4: + goto case 6; + case 5: + goto case 6; + case 6: + if (h < 0 && k < 0 && l < 0) + { + + } + else if (h < 0) + { + angleCorrection += Math.PI; + } + else if (k < 0) + { + angleCorrection += Math.PI; + } + else if (l < 0) + { + angleCorrection += Math.PI; + } + break; + case 8: + if ((h <= 0 && k > 0) && Math.Abs(h) < k) + { + angleCorrection -= (1.0 / 2.0) * Math.PI; + } + else if ((h > 0 && k > 0) && k > h) + { + angleCorrection -= (1.0 / 2.0) * Math.PI; + } + else if ((h < 0 && k < 0) && h < k) + { + angleCorrection += (1.0 / 2.0) * Math.PI; + } + else if ((k > 0 && h <= 0) && Math.Abs(h) > k) + { + angleCorrection += (1.0 / 2.0) * Math.PI; + } + break; + case 9: + if ((h <= 0 && l > 0) && Math.Abs(h) < l) + { + angleCorrection -= (1.0 / 2.0) * Math.PI; + } + else if ((h > 0 && l > 0) && l > h) + { + angleCorrection -= (1.0 / 2.0) * Math.PI; + } + else if ((h < 0 && l < 0) && h < l) + { + angleCorrection += (1.0 / 2.0) * Math.PI; + } + else if ((l > 0 && h <= 0) && Math.Abs(h) > l) + { + angleCorrection += (1.0 / 2.0) * Math.PI; + } + break; + case 10: + if ((k <= 0 && l > 0) && Math.Abs(k) < l) + { + angleCorrection -= (1.0 / 2.0) * Math.PI; + } + else if ((k > 0 && l > 0) && l > k) + { + angleCorrection -= (1.0 / 2.0) * Math.PI; + } + else if ((k < 0 && l < 0) && k < l) + { + angleCorrection += (1.0 / 2.0) * Math.PI; + } + else if ((l > 0 && k <= 0) && Math.Abs(k) > l) + { + angleCorrection += (1.0 / 2.0) * Math.PI; + } + break; + case 12: + + break; + case 13: + if ((k <= 0 && l > 0) && Math.Abs(k) < l) + { + angleCorrection += (1.0 / 1.0) * Math.PI; + } + else if ((k > 0 && l > 0) && l > k) + { + angleCorrection += (1.0 / 1.0) * Math.PI; + } + //else if ((k < 0 && l < 0) && k < l) + //{ + // angleCorrection += (1.0 / 2.0) * Math.PI; + //} + //else if ((l > 0 && k <= 0) && Math.Abs(k) > l) + //{ + // angleCorrection += (1.0 / 2.0) * Math.PI; + //} + break; + case 14: + + break; + default: + goto case 2; + } + + SetAnIsoData(usedTensor, h, k, l, parameterSeries, angleDirection, angleCorrection); + } + } } } - #endregion + + //AnIsoValueAxis.Minimum = double.MaxValue; + //AnIsoValueAxis.Maximum = 0; + + //for (int n = 0; n < parameterSeries.Points.Count; n++) + //{ + // if(parameterSeries.Points[n].X < AnIsoValueAxis.Minimum) + // { + // AnIsoValueAxis.Minimum = parameterSeries.Points[n].X; + // } + // if (parameterSeries.Points[n].X > AnIsoValueAxis.Minimum) + // { + // AnIsoValueAxis.Maximum = parameterSeries.Points[n].X; + // } + //} + + AnIsoAngleAxis.Minimum = 0.0; + AnIsoAngleAxis.Maximum = 2 * Math.PI; + //AnIsoValueAxis.Maximum = 250000; + + AnIsoPlotModel.ResetAllAxes(); + AnIsoPlotModel.Series.Add(parameterSeries); + AnIsoPlotModel.InvalidatePlot(true); + } + } + private void FixAnisotropyCheckBox_Checked(object sender, RoutedEventArgs e) + { + this.TextEventsActive = false; + this.SetTensorData(); + this.TextEventsActive = true; + } + + private void FixAnisotropyCheckBox_Unchecked(object sender, RoutedEventArgs e) + { + this.TextEventsActive = false; + this.SetTensorData(); + this.TextEventsActive = true; + } + + private void ZehnderAnisotropy_TextChanged(object sender, TextChangedEventArgs e) + { + Stress.Microsopic.ElasticityTensors UsedTensor = this.GetSelectedTensor(); + + try + { + UsedTensor.AnIsotropy = Convert.ToDouble(this.FixedAnisotropy.Text); + this.TextEventsActive = false; + this.SetTensorData(); + this.TextEventsActive = true; + } + catch + { + + } + } + + private void StartAnalysis_Click(object sender, RoutedEventArgs e) + { + Tools.ValueSelection VWindow = new Tools.ValueSelection(); + + VWindow.ShowDialog(); + + Microsoft.Win32.SaveFileDialog XlsxSaveFile = new Microsoft.Win32.SaveFileDialog(); + XlsxSaveFile.FileName = VWindow.fileName; + XlsxSaveFile.DefaultExt = ""; + XlsxSaveFile.Filter = "Excel data (.xlsx)|*.xlsx"; + + Nullable Opened = XlsxSaveFile.ShowDialog(); + + if (Opened == true) + { + string filename = XlsxSaveFile.FileName; + string PathName = filename.Replace(XlsxSaveFile.SafeFileName, ""); + System.IO.Directory.CreateDirectory(PathName); + + Stress.Microsopic.ElasticityTensors UsedTensor = this.GetSelectedTensor(); + int model = 0; + if (this.REKSwitchBox.SelectedIndex != 3) { UsedTensor.AutoAnisotropyFit(VWindow.lborder, VWindow.uborder, VWindow.step, VWindow.SC, XlsxSaveFile.FileName, model, true); @@ -1844,6 +2413,11 @@ private void SetTransitionFactors_Click(object sender, RoutedEventArgs e) this.ActSample.SetStressTransitionFactors(matrixPhase, inclusionPhase, incType); SetTransitionView(); + MessageBox.Show("Calculation finished.", "Stresses factors ready!", MessageBoxButton.OK, MessageBoxImage.Information); + } + else + { + MessageBox.Show("Only one phase found in the crystallographic data! \n at least two destinct phases are requried.", "Only one phase detected", MessageBoxButton.OK, MessageBoxImage.Error); } } @@ -1851,16 +2425,266 @@ private void ResetPhaseStresses_Click(object sender, RoutedEventArgs e) { if (this.ActSample.CrystalData.Count > 1) { - this.ActSample.SetPhaseStresses(); + if (this.ActSample.StressTransitionFactors[0][2, 2] != 0) + { + this.ActSample.SetPhaseStresses(); + MessageBox.Show("Reset finished.", "Stresses ready!", MessageBoxButton.OK, MessageBoxImage.Information); + } + else + { + MessageBox.Show("Please set the transition factors first.", "Transition factors not set!", MessageBoxButton.OK, MessageBoxImage.Error); + } + } + else + { + MessageBox.Show("Only one phase found in the crystallographic data! \n at least two destinct phases are requried.", "Only one phase detected", MessageBoxButton.OK, MessageBoxImage.Error); } } + private void RefitAllDEC_Click(object sender, RoutedEventArgs e) { if (this.ActSample.CrystalData.Count > 1) { this.ActSample.RefitAllDECStressCorrected(); + MessageBox.Show("Refit finished.", "DEC are ready!", MessageBoxButton.OK, MessageBoxImage.Information); + } + else + { + MessageBox.Show("Only one phase found in the crystallographic data! \n at least two destinct phases are requried.", "Only one phase detected", MessageBoxButton.OK, MessageBoxImage.Error); } } + + private void FitConstantsSelfConsistent_Click(object sender, RoutedEventArgs e) + { + + this.TextEventsActive = false; + + if (this.ActSample.CrystalData.Count > 1) + { + for (int n = 0; n < 10; n++) + { + #region Setting of transition Factors + + int matrixPhase = 0; + int inclusionPhase = 1; + + if (this.ActSample.CrystalData[1].Matrix) + { + matrixPhase = 1; + inclusionPhase = 0; + } + + bool incType = false; + if (this.ActSample.CrystalData[inclusionPhase].InclusionType == 0) + { + incType = true; + } + + this.ActSample.SetStressTransitionFactors(matrixPhase, inclusionPhase, incType); + + #endregion + + this.ActSample.SetPhaseStresses(); + this.ActSample.RefitAllDECStressCorrected(); + + #region Constant Fit + + switch (this.ModelSwitchBox.SelectedIndex) + { + case 0: + if (REKSwitchBox.SelectedIndex == 0) + { + this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].FitVoigt(true); + } + else if (REKSwitchBox.SelectedIndex == 2) + { + this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].FitVoigtStrain(true); + } + else + { + this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].FitVoigt(false); + } + break; + case 1: + if (REKSwitchBox.SelectedIndex == 0) + { + this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].FitReuss(true); + } + else if (REKSwitchBox.SelectedIndex == 2) + { + this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].FitReussStrain(true); + } + else if (REKSwitchBox.SelectedIndex == 3) + { + if (CalScec.Properties.Settings.Default.ActivateDECTextureWeighting) + { + this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].ActivateDECMRDWeighting(); + } + else + { + this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].DeactivateDECMRDWeighting(); + } + + this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].FitReussTextured(true); + } + else + { + this.ActSample.ReussTensorData[this.PhaseSwitchBox.SelectedIndex].FitReuss(false); + } + break; + case 2: + if (REKSwitchBox.SelectedIndex == 0) + { + this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].FitHill(true); + } + else if (REKSwitchBox.SelectedIndex == 3) + { + if (CalScec.Properties.Settings.Default.ActivateDECTextureWeighting) + { + this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].ActivateDECMRDWeighting(); + } + else + { + this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].DeactivateDECMRDWeighting(); + } + + this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].FitHillTextured(true); + } + else + { + this.ActSample.HillTensorData[this.PhaseSwitchBox.SelectedIndex].FitHill(false); + } + break; + case 3: + bool SC = false; + if (this.StiffnessComlplianceSwitchBox.SelectedIndex == 1) + { + SC = true; + } + if (REKSwitchBox.SelectedIndex == 0) + { + this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].FitKroener(true, SC); + } + else if (REKSwitchBox.SelectedIndex == 3) + { + if (CalScec.Properties.Settings.Default.ActivateDECTextureWeighting) + { + this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].ActivateDECMRDWeighting(); + } + else + { + this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].DeactivateDECMRDWeighting(); + } + + this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].FitKroenerTextured(true, SC); + } + else + { + this.ActSample.KroenerTensorData[this.PhaseSwitchBox.SelectedIndex].FitKroener(false, SC); + } + break; + case 4: + bool SC1 = false; + if (this.StiffnessComlplianceSwitchBox.SelectedIndex == 1) + { + SC1 = true; + } + if (REKSwitchBox.SelectedIndex == 0) + { + this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].FitDeWitt(true, SC1); + } + else if (REKSwitchBox.SelectedIndex == 3) + { + if (CalScec.Properties.Settings.Default.ActivateDECTextureWeighting) + { + this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].ActivateDECMRDWeighting(); + } + else + { + this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].DeactivateDECMRDWeighting(); + } + + this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].FitDeWittTextured(true, SC1); + } + else + { + this.ActSample.DeWittTensorData[this.PhaseSwitchBox.SelectedIndex].FitDeWitt(false, SC1); + } + break; + case 5: + if (REKSwitchBox.SelectedIndex == 0) + { + this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].FitGeometricHill(true); + } + else if (REKSwitchBox.SelectedIndex == 3) + { + if (CalScec.Properties.Settings.Default.ActivateDECTextureWeighting) + { + this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].ActivateDECMRDWeighting(); + } + else + { + this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].DeactivateDECMRDWeighting(); + } + + this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].FitGeometricHillTextured(true); + } + else + { + this.ActSample.GeometricHillTensorData[this.PhaseSwitchBox.SelectedIndex].FitGeometricHill(false); + } + break; + default: + if (REKSwitchBox.SelectedIndex == 0) + { + this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].FitReuss(true); + } + else + { + this.ActSample.VoigtTensorData[this.PhaseSwitchBox.SelectedIndex].FitReuss(false); + } + break; + } + + #endregion + } + + SetTransitionView(); + this.SetTensorData(); + this.TextEventsActive = true; + MessageBox.Show("Calculation finished.", "Constants ready!", MessageBoxButton.OK, MessageBoxImage.Information); + } + else + { + MessageBox.Show("Only one phase found in the crystallographic data! \n at least two destinct phases are requried.", "Only one phase detected", MessageBoxButton.OK, MessageBoxImage.Error); + } + } + + private void ShowAnIsoPlot_Click(object sender, RoutedEventArgs e) + { + this.AniIsoPlotWindow.Show(); + } + + private void SetAnIsoPlot_Click(object sender, RoutedEventArgs e) + { + this.SetAnIsoPlot(); + } + private void SaveAnIsoPlotClipboard_Click(object sender, RoutedEventArgs e) + { + OxyPlot.Wpf.PngExporter pngExporter = new OxyPlot.Wpf.PngExporter{ Width = 1200, Height = 1200, Background = OxyPlot.OxyColors.White }; + var bitmap = pngExporter.ExportToBitmap(this.AnIsoPlotModel); + Clipboard.SetImage(bitmap); + } + private void ReSetAnIsoPlot_Click(object sender, RoutedEventArgs e) + { + this.AnIsoPlotModel.Annotations.Clear(); + this.AnIsoPlotModel.Series.Clear(); + + AnIsoPlotModel.ResetAllAxes(); + AnIsoPlotModel.InvalidatePlot(true); + } + + #endregion } public struct StressFactorView diff --git a/CalScec/Analysis/Stress/Microsopic/ElasticityTensors.cs b/CalScec/Analysis/Stress/Microsopic/ElasticityTensors.cs index ee41ccb..248f2ad 100644 --- a/CalScec/Analysis/Stress/Microsopic/ElasticityTensors.cs +++ b/CalScec/Analysis/Stress/Microsopic/ElasticityTensors.cs @@ -700,7 +700,8 @@ public double GetZehnderAnisotropy { get { - return this.S44 / (2 * (this.S11 - this.S12)); + double ret = this.S44 / (2 * (this.S11 - this.S12)); + return 1.0 / ret; } } @@ -728,6 +729,141 @@ public void DeactivateDECMRDWeighting() } } + #region Anisotropy + + public double OrientationParameterH(int h, int k, int l) + { + double ret = l; + + double nenner = 4.0 / 3.0; + + nenner *= Math.Pow(this.GetPhaseInformation.A / this.GetPhaseInformation.C, 2); + nenner *= Math.Pow(h, 2) + Math.Pow(k, 2) + (h * k); + nenner += Math.Pow(l, 2); + + return ret / Math.Sqrt(nenner); + } + + private double OrientationParameterGamma(int h, int k, int l) + { + DataManagment.CrystalData.HKLReflex tmp = new DataManagment.CrystalData.HKLReflex(h, k, l, 1); + + return this.CubicGamma(tmp); + } + + public double KVoigt() + { + double ret = 2 * this.C11; + ret += this.C33; + ret += 4 * this.C13; + ret += 2 * this.C12; + + return ret / 9.0; + } + + public double GVoigt() + { + double ret = 3.5 * this.C11; + ret += this.C33; + ret += -2 * this.C13; + ret += -2.5 * this.C12; + ret += 6 * this.C44; + + return ret / 15.0; + } + + public double EVoigt() + { + double ret = KVoigt() * GVoigt(); + + double n = 4.5 * this.C11; + n += 2.0 * this.C23; + n += 6.0 * this.C13; + n += 2.5 * this.C12; + n += 2.0 * this.C44; + n *= 3.0; + + return ret / n; + } + + public double KReuss() + { + double alpha = this.S11 + this.S22 + this.S33; + double beta = this.S23 + this.S13 + this.S12; + + double ret = alpha + (2.0 * beta); + + return 1 / ret; + } + + public double GReuss() + { + double alpha = this.S11 + this.S22 + this.S33; + double beta = this.S23 + this.S13 + this.S12; + double lambda = this.S44 + this.S55 + this.S66; + + double ret = (4.0 / 3.0) * alpha; + ret += -1 * (4.0 / 3.0) * beta; + ret += lambda; + + return 5.0 / ret; + } + + public double EReuss() + { + double k = this.KReuss(); + double g = this.GReuss(); + + double ret = 9.0 * k * g; + ret /= (3.0 * k) + g; + + return ret; + } + + public double GetUniversalAnisotropy() + { + double ret = 5.0 * (GVoigt() / GReuss()); + ret += KVoigt() / KReuss(); + + ret -= 6.0; + + return ret; + } + + public double GetZenerEquivalentAnisotropy() + { + double aU = this.GetUniversalAnisotropy(); + + double co = (5.0 / 12.0) * aU; + co += 1; + + double ret = co + Math.Sqrt(Math.Pow(co, 2) - 1); + + return ret; + } + + public double DirectionalS1ReussHexagonal(double h) + { + double ret = this.S12 * (1 - Math.Pow(h, 2)); + ret += this.S13 * Math.Pow(h, 2); + ret += (this.S11 + this.S33 - (2 * this.S13) - this.S44) * (1 - Math.Pow(h, 2)) * Math.Pow(h, 2); + + return 0.5 * ret; + } + + public double DirectionalS2ReussHexagonal(double h) + { + double ret = this.S11 * (1 - Math.Pow(h, 2)) * (2 - (3 * Math.Pow(h, 2))); + ret -= this.S12 * (1 - Math.Pow(h, 2)); + ret += this.S13 * ((Math.Pow(h, 2) * (5 - (6 * Math.Pow(h, 2)))) - 1); + ret += this.S33 * (3 * Math.Pow(h, 2) - 1) * Math.Pow(h, 2); + ret += this.S44 * (1 - Math.Pow(h, 2)) * Math.Pow(h, 2); + + return 0.5 * ret; + } + + #endregion + #region averaged parameters private double _averagedEModul; @@ -7914,11 +8050,14 @@ private void SetErrorHillCubic() this.S12Error = Math.Sqrt(CoVMatrixCompliance[1, 1]); this.S44Error = Math.Sqrt(CoVMatrixCompliance[2, 2]); - MathNet.Numerics.LinearAlgebra.Matrix ErrorMatrixStiffness =this._complianceTensorError.Inverse(); + //MathNet.Numerics.LinearAlgebra.Matrix ErrorMatrixStiffness =this._complianceTensorError.Inverse(); - this.C11Error = ErrorMatrixStiffness[0, 0]; - this.C12Error = ErrorMatrixStiffness[1, 1]; - this.C44Error = ErrorMatrixStiffness[2, 2]; + //this.C11Error = ErrorMatrixStiffness[0, 0]; + //this.C12Error = ErrorMatrixStiffness[1, 1]; + //this.C44Error = ErrorMatrixStiffness[2, 2]; + this.C11Error = Math.Abs(this.C11 * this.S11Error / this.S11); + this.C12Error = Math.Abs(this.C12 * this.S12Error / this.S12); + this.C44Error = Math.Abs(this.C44 * this.S44Error / this.S44); } @@ -7997,14 +8136,19 @@ private void SetErrorHillHexagonal() this.S13Error = Math.Sqrt(CoVMatrixCompliance[3, 3]); this.S44Error = Math.Sqrt(CoVMatrixCompliance[4, 4]); - MathNet.Numerics.LinearAlgebra.Matrix ErrorMatrixStiffness = this._complianceTensorError.Inverse(); + //MathNet.Numerics.LinearAlgebra.Matrix ErrorMatrixStiffness = this._complianceTensorError.Inverse(); - this.C11Error = ErrorMatrixStiffness[0, 0]; - this.C33Error = ErrorMatrixStiffness[1, 1]; - this.C12Error = ErrorMatrixStiffness[2, 2]; - this.C13Error = ErrorMatrixStiffness[3, 3]; - this.C44Error = ErrorMatrixStiffness[4, 4]; + //this.C11Error = ErrorMatrixStiffness[0, 0]; + //this.C33Error = ErrorMatrixStiffness[1, 1]; + //this.C12Error = ErrorMatrixStiffness[2, 2]; + //this.C13Error = ErrorMatrixStiffness[3, 3]; + //this.C44Error = ErrorMatrixStiffness[4, 4]; + this.C11Error = Math.Abs(this.C11 * this.S11Error / this.S11); + this.C33Error = Math.Abs(this.C33 * this.S33Error / this.S33); + this.C12Error = Math.Abs(this.C12 * this.S12Error / this.S12); + this.C13Error = Math.Abs(this.C13 * this.S13Error / this.S13); + this.C44Error = Math.Abs(this.C44 * this.S44Error / this.S44); } private void SetErrorReussCubic() @@ -8046,11 +8190,14 @@ private void SetErrorReussCubic() this.S12Error = Math.Sqrt(CoVMatrixCompliance[1, 1]); this.S44Error = Math.Sqrt(CoVMatrixCompliance[2, 2]); - MathNet.Numerics.LinearAlgebra.Matrix ErrorMatrixStiffness = this._complianceTensorError.Inverse(); + //MathNet.Numerics.LinearAlgebra.Matrix ErrorMatrixStiffness = this._complianceTensorError.Inverse(); - this.C11Error = ErrorMatrixStiffness[0, 0]; - this.C12Error = ErrorMatrixStiffness[1, 1]; - this.C44Error = ErrorMatrixStiffness[2, 2]; + //this.C11Error = ErrorMatrixStiffness[0, 0]; + //this.C12Error = ErrorMatrixStiffness[1, 1]; + //this.C44Error = ErrorMatrixStiffness[2, 2]; + this.C11Error = Math.Abs(this.C11 * this.S11Error / this.S11); + this.C12Error = Math.Abs(this.C12 * this.S12Error / this.S12); + this.C44Error = Math.Abs(this.C44 * this.S44Error / this.S44); } @@ -8129,14 +8276,19 @@ private void SetErrorReussHexagonal() this.S13Error = Math.Sqrt(CoVMatrixCompliance[3, 3]); this.S44Error = Math.Sqrt(CoVMatrixCompliance[4, 4]); - MathNet.Numerics.LinearAlgebra.Matrix ErrorMatrixStiffness = this._complianceTensorError.Inverse(); + //MathNet.Numerics.LinearAlgebra.Matrix ErrorMatrixStiffness = this._complianceTensorError.Inverse(); - this.C11Error = ErrorMatrixStiffness[0, 0]; - this.C33Error = ErrorMatrixStiffness[1, 1]; - this.C12Error = ErrorMatrixStiffness[2, 2]; - this.C13Error = ErrorMatrixStiffness[3, 3]; - this.C44Error = ErrorMatrixStiffness[4, 4]; + //this.C11Error = ErrorMatrixStiffness[0, 0]; + //this.C33Error = ErrorMatrixStiffness[1, 1]; + //this.C12Error = ErrorMatrixStiffness[2, 2]; + //this.C13Error = ErrorMatrixStiffness[3, 3]; + //this.C44Error = ErrorMatrixStiffness[4, 4]; + this.C11Error = Math.Abs(this.C11 * this.S11Error / this.S11); + this.C33Error = Math.Abs(this.C33 * this.S33Error / this.S33); + this.C12Error = Math.Abs(this.C12 * this.S12Error / this.S12); + this.C13Error = Math.Abs(this.C13 * this.S13Error / this.S13); + this.C44Error = Math.Abs(this.C44 * this.S44Error / this.S44); } #endregion @@ -18817,20 +18969,23 @@ public double FirstDerivativeS44HS2GeometricHillHexagonal(DataManagment.CrystalD public void SetPeakStressAssociation(Sample actSample) { - this.UsedPSA.Clear(); - for (int i = 0; i < this.GetPhaseInformation.HKLList.Count; i++) + if (this.GetPhaseInformation.A != 0 && this.GetPhaseInformation.B != 0 && this.GetPhaseInformation.B != 0) { - for (int j = 0; j < actSample.DiffractionPatterns.Count; j++) + this.UsedPSA.Clear(); + for (int i = 0; i < this.GetPhaseInformation.HKLList.Count; i++) { - for (int k = 0; k < actSample.DiffractionPatterns[j].FoundPeaks.Count; k++) + for (int j = 0; j < actSample.DiffractionPatterns.Count; j++) { - if (actSample.DiffractionPatterns[j].FoundPeaks[k].AssociatedCrystalData.SymmetryGroupID == this.GetPhaseInformation.SymmetryGroupID) + for (int k = 0; k < actSample.DiffractionPatterns[j].FoundPeaks.Count; k++) { - if (actSample.DiffractionPatterns[j].FoundPeaks[k].AssociatedHKLReflex.HKLString == this.GetPhaseInformation.HKLList[i].HKLString) + if (actSample.DiffractionPatterns[j].FoundPeaks[k].AssociatedCrystalData.SymmetryGroupID == this.GetPhaseInformation.SymmetryGroupID) { - Stress.Macroskopic.PeakStressAssociation NewAssociation = new Stress.Macroskopic.PeakStressAssociation(actSample.DiffractionPatterns[j].Stress, actSample.DiffractionPatterns[j].PsiAngle(actSample.DiffractionPatterns[j].FoundPeaks[k].Angle), actSample.DiffractionPatterns[j].FoundPeaks[k], actSample.DiffractionPatterns[j].PhiAngle(actSample.DiffractionPatterns[j].FoundPeaks[k].Angle)); - NewAssociation._macroskopicStrain = actSample.DiffractionPatterns[j].MacroStrain; - this.UsedPSA.Add(NewAssociation); + if (actSample.DiffractionPatterns[j].FoundPeaks[k].AssociatedHKLReflex.HKLString == this.GetPhaseInformation.HKLList[i].HKLString) + { + Stress.Macroskopic.PeakStressAssociation NewAssociation = new Stress.Macroskopic.PeakStressAssociation(actSample.DiffractionPatterns[j].Stress, actSample.DiffractionPatterns[j].PsiAngle(actSample.DiffractionPatterns[j].FoundPeaks[k].Angle), actSample.DiffractionPatterns[j].FoundPeaks[k], actSample.DiffractionPatterns[j].PhiAngle(actSample.DiffractionPatterns[j].FoundPeaks[k].Angle)); + NewAssociation._macroskopicStrain = actSample.DiffractionPatterns[j].MacroStrain; + this.UsedPSA.Add(NewAssociation); + } } } } diff --git a/CalScec/Analysis/Stress/Microsopic/REKAssociationCalculationWindow.xaml b/CalScec/Analysis/Stress/Microsopic/REKAssociationCalculationWindow.xaml index 2290515..ac0557a 100644 --- a/CalScec/Analysis/Stress/Microsopic/REKAssociationCalculationWindow.xaml +++ b/CalScec/Analysis/Stress/Microsopic/REKAssociationCalculationWindow.xaml @@ -7,7 +7,7 @@ xmlns:oxycore="clr-namespace:OxyPlot;assembly=OxyPlot" xmlns:oxy="clr-namespace:OxyPlot.Wpf;assembly=OxyPlot.Wpf" mc:Ignorable="d" - Title="REKAssociationCalculationWindow" Height="700" Width="1600"> + Title="Diffraction Elastic Constants" Height="700" Width="1600"> @@ -45,7 +45,7 @@ + + + + + @@ -200,13 +207,13 @@ - -