Obtaining softening factors was added

This commit is contained in:
Evgeny Redikultsev
2023-07-22 19:03:18 +05:00
parent d7a4b1f0a7
commit 580087b2a6
26 changed files with 546 additions and 196 deletions

View File

@@ -41,6 +41,7 @@
<StackPanel Grid.Column="1">
<Button Margin="3" Content="Graphic" ToolTip="Show graphic results" Command="{Binding ShowIsoFieldCommand}"/>
<Button Margin="3" Content="Diagrams" ToolTip="Show diagrams" Command="{Binding ShowGraphsCommand}"/>
<Button Margin="3" Content="CrcDiagrams" ToolTip="Show diagrams for cracked section" Command="{Binding ShowCrackGraphsCommand}"/>
<Button Margin="3" Content="Interpolate" ToolTip="Create analysis by substep" Command="{Binding InterpolateCommand}"/>
<Button Margin="3" Content="Export" ToolTip="Export results to *.csv" Command="{Binding ExportToCSVCommand}"/>
<Button Margin="3" Content="Set Prestrain" ToolTip="Set strains as auto prestrain" Command="{Binding SetPrestrainCommand}"/>

View File

@@ -1,7 +1,9 @@
using StructureHelper.Windows.ViewModels.Graphs;
using StructureHelperCommon.Models.Parameters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
@@ -27,5 +29,8 @@ namespace StructureHelper.Windows.Graphs
InitializeComponent();
DataContext = vm;
}
public GraphView(ArrayParameter<double> arrayParameter) : this(new GraphViewModel(arrayParameter))
{
}
}
}

View File

@@ -0,0 +1,43 @@
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews;
using StructureHelper.Windows.Forces;
using StructureHelper.Windows.ViewModels.Forces;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.Services.NdmCalculations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
{
internal class InterpolateLogic
{
public void Show(IDesignForceTuple finishDesignTuple, IForceCalculator forceCalculator)
{
IDesignForceTuple startDesignTuple;
var viewModel = new InterpolateTuplesViewModel(finishDesignTuple, null, 100);
var wndTuples = new InterpolateTuplesView(viewModel);
wndTuples.ShowDialog();
if (wndTuples.DialogResult != true) return;
startDesignTuple = viewModel.StartDesignForce;
finishDesignTuple = viewModel.FinishDesignForce;
int stepCount = viewModel.StepCount;
var calculator = InterpolateService.InterpolateForceCalculator(forceCalculator, finishDesignTuple, startDesignTuple, stepCount);
calculator.Run();
var result = calculator.Result;
if (result is null || result.IsValid == false)
{
MessageBox.Show(result.Description, "Check data for analisys", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
var vm = new ForcesResultsViewModel(calculator);
var wnd = new ForceResultsView(vm);
wnd.ShowDialog();
}
}
}
}

View File

@@ -0,0 +1,66 @@
using StructureHelper.Windows.Errors;
using StructureHelper.Windows.ViewModels.Errors;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.NdmCalculations.Cracking;
using StructureHelperLogics.NdmCalculations.Primitives;
using StructureHelperLogics.Services.NdmPrimitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace StructureHelper.Windows.ViewModels.Calculations.Calculators.ForceResultLogic
{
internal class ShowCrackResultLogic
{
public static GeometryNames GeometryNames => ProgramSetting.GeometryNames;
public LimitStates LimitState { get; set; }
public CalcTerms CalcTerm { get; set; }
public ForceTuple ForceTuple { get; set; }
public IEnumerable<INdmPrimitive> ndmPrimitives { get; set; }
public void Show()
{
var calculator = new CrackForceCalculator();
calculator.EndTuple = ForceTuple;
calculator.NdmCollection = NdmPrimitivesService.GetNdms(ndmPrimitives, LimitState, CalcTerm);
calculator.Run();
var result = (CrackForceResult)calculator.Result;
if (result.IsValid)
{
//var softLogic = new ExponentialSofteningLogic() { ForceRatio = result.ActualFactor };
string message = string.Empty;
if (result.IsSectionCracked)
{
message += $"Actual crack factor {result.FactorOfCrackAppearance}\n";
message += $"Softening crack factor PsiS={result.PsiS}\n";
message += $"{GeometryNames.MomFstName}={result.TupleOfCrackAppearance.Mx},\n {GeometryNames.MomSndName}={result.TupleOfCrackAppearance.My},\n {GeometryNames.LongForceName}={result.TupleOfCrackAppearance.Nz}";
}
else
{
message += "Cracks are not apeared";
}
MessageBox.Show(
message,
"Crack results",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
else
{
var errorVM = new ErrorProcessor()
{
ShortText = "Error apeared while crack calculate",
DetailText = result.Description
};
var wnd = new ErrorMessage(errorVM);
wnd.ShowDialog();
}
}
}
}

View File

@@ -0,0 +1,164 @@
using LoaderCalculator;
using LoaderCalculator.Data.Materials.MaterialBuilders;
using LoaderCalculator.Data.Ndms;
using StructureHelper.Windows.Errors;
using StructureHelper.Windows.Graphs;
using StructureHelper.Windows.ViewModels.Errors;
using StructureHelper.Windows.ViewModels.Graphs;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Parameters;
using StructureHelperCommon.Services.Units;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Cracking;
using StructureHelperLogics.NdmCalculations.Primitives;
using StructureHelperLogics.Services.NdmPrimitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
{
internal class ShowDiagramLogic
{
static readonly CrackForceCalculator calculator = new();
ArrayParameter<double> arrayParameter;
private static GeometryNames GeometryNames => ProgramSetting.GeometryNames;
public void Show(List<IForcesTupleResult> results)
{
var resultList = results.Where(x => x.IsValid == true).ToList();
var unitForce = CommonOperation.GetUnit(UnitTypes.Force, "kN");
var unitMoment = CommonOperation.GetUnit(UnitTypes.Moment, "kNm");
var unitCurvature = CommonOperation.GetUnit(UnitTypes.Curvature, "1/m");
string[] labels = GetLabels(unitForce, unitMoment, unitCurvature);
arrayParameter = new ArrayParameter<double>(resultList.Count(), labels.Count(), labels);
CalculateWithoutCrack(resultList, unitForce, unitMoment, unitCurvature);
SafetyProcessor.RunSafeProcess(ShowWindow, "Errors apearred during showing graph, see detailed information");
}
public void ShowCracks(List<IForcesTupleResult> results, IEnumerable<INdmPrimitive> ndmPrimitives)
{
var resultList = results.Where(x => x.IsValid == true).ToList();
var unitForce = CommonOperation.GetUnit(UnitTypes.Force, "kN");
var unitMoment = CommonOperation.GetUnit(UnitTypes.Moment, "kNm");
var unitCurvature = CommonOperation.GetUnit(UnitTypes.Curvature, "1/m");
string[] labels = GetCrackLabels(unitForce, unitMoment, unitCurvature);
arrayParameter = new ArrayParameter<double>(resultList.Count(), labels.Count(), labels);
CalculateWithCrack(resultList, ndmPrimitives, unitForce, unitMoment, unitCurvature);
SafetyProcessor.RunSafeProcess(ShowWindow, "Errors apearred during showing graph, see detailed information");
}
private void CalculateWithCrack(List<IForcesTupleResult> resultList, IEnumerable<INdmPrimitive> ndmPrimitives, IUnit unitForce, IUnit unitMoment, IUnit unitCurvature)
{
var data = arrayParameter.Data;
for (int i = 0; i < resultList.Count(); i++)
{
var valueList = new List<double>
{
resultList[i].DesignForceTuple.ForceTuple.Mx * unitMoment.Multiplyer,
resultList[i].DesignForceTuple.ForceTuple.My * unitMoment.Multiplyer,
resultList[i].DesignForceTuple.ForceTuple.Nz * unitForce.Multiplyer
};
calculator.EndTuple = resultList[i].DesignForceTuple.ForceTuple;
var limitState = resultList[i].DesignForceTuple.LimitState;
var calcTerm = resultList[i].DesignForceTuple.CalcTerm;
var ndms = NdmPrimitivesService.GetNdms(ndmPrimitives, limitState, calcTerm);
calculator.NdmCollection = ndms;
calculator.Run();
var result = (CrackForceResult)calculator.Result;
if (result.IsValid == false)
{
MessageBox.Show(
"Result is not valid",
"Crack results",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
return;
}
valueList.Add(result.ReducedStrainTuple.Mx);
valueList.Add(result.ReducedStrainTuple.My);
valueList.Add(result.ReducedStrainTuple.Nz);
valueList.Add(result.SofteningFactors.Mx);
valueList.Add(result.SofteningFactors.My);
valueList.Add(result.SofteningFactors.Nz);
valueList.Add(result.PsiS);
for (int j = 0; j < valueList.Count; j++)
{
data[i, j] = valueList[j];
}
}
}
private void CalculateWithoutCrack(List<IForcesTupleResult> resultList, IUnit unitForce, IUnit unitMoment, IUnit unitCurvature)
{
var data = arrayParameter.Data;
for (int i = 0; i < resultList.Count(); i++)
{
var valueList = ProcessResultWithouCrack(resultList, unitForce, unitMoment, unitCurvature, i);
for (int j = 0; j < valueList.Count; j++)
{
data[i, j] = valueList[j];
}
}
}
private void ShowWindow()
{
var wnd = new GraphView(arrayParameter);
wnd.ShowDialog();
}
private static List<double> ProcessResultWithouCrack(List<IForcesTupleResult> resultList, IUnit unitForce, IUnit unitMoment, IUnit unitCurvature, int i)
{
return new List<double>
{
resultList[i].DesignForceTuple.ForceTuple.Mx * unitMoment.Multiplyer,
resultList[i].DesignForceTuple.ForceTuple.My * unitMoment.Multiplyer,
resultList[i].DesignForceTuple.ForceTuple.Nz * unitForce.Multiplyer,
resultList[i].LoaderResults.ForceStrainPair.StrainMatrix.Kx * unitCurvature.Multiplyer,
resultList[i].LoaderResults.ForceStrainPair.StrainMatrix.Ky * unitCurvature.Multiplyer,
resultList[i].LoaderResults.ForceStrainPair.StrainMatrix.EpsZ
};
}
private static string[] GetLabels(IUnit unitForce, IUnit unitMoment, IUnit unitCurvature)
{
return new string[]
{
$"{GeometryNames.MomFstName}, {unitMoment.Name}",
$"{GeometryNames.MomSndName}, {unitMoment.Name}",
$"{GeometryNames.LongForceName}, {unitForce.Name}",
$"{GeometryNames.CurvFstName}, {unitCurvature.Name}",
$"{GeometryNames.CurvSndName}, {unitCurvature.Name}",
$"{GeometryNames.StrainTrdName}"
};
}
private static string[] GetCrackLabels(IUnit unitForce, IUnit unitMoment, IUnit unitCurvature)
{
const string crc = "CrcSofteningFactor";
return new string[]
{
$"{GeometryNames.MomFstName}, {unitMoment.Name}",
$"{GeometryNames.MomSndName}, {unitMoment.Name}",
$"{GeometryNames.LongForceName}, {unitForce.Name}",
$"{GeometryNames.CurvFstName}, {unitCurvature.Name}",
$"{GeometryNames.CurvSndName}, {unitCurvature.Name}",
$"{GeometryNames.StrainTrdName}",
$"{crc}Ix",
$"{crc}Iy",
$"{crc}Az",
$"PsiFactor"
};
}
}
}

View File

@@ -12,6 +12,7 @@ using StructureHelper.Windows.Errors;
using StructureHelper.Windows.Forces;
using StructureHelper.Windows.Graphs;
using StructureHelper.Windows.PrimitivePropertiesWindow;
using StructureHelper.Windows.ViewModels.Calculations.Calculators.ForceResultLogic;
using StructureHelper.Windows.ViewModels.Errors;
using StructureHelper.Windows.ViewModels.Forces;
using StructureHelper.Windows.ViewModels.Graphs;
@@ -41,6 +42,9 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
{
public class ForcesResultsViewModel : ViewModelBase
{
private static readonly ShowDiagramLogic showDiagramLogic = new();
private static readonly InterpolateLogic interpolateLogic = new();
private static readonly ShowCrackResultLogic showCrackResultLogic = new();
private IForceCalculator forceCalculator;
private IForcesResults forcesResults;
private IEnumerable<INdmPrimitive> ndmPrimitives;
@@ -48,25 +52,24 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
private IEnumerable<INdm> ndms;
private IReport isoFieldReport;
static string firstAxisName => ProgramSetting.CrossSectionAxisNames.FirstAxis;
static string secondAxisName => ProgramSetting.CrossSectionAxisNames.SecondAxis;
static string thirdAxisName => ProgramSetting.CrossSectionAxisNames.ThirdAxis;
public static GeometryNames GeometryNames => ProgramSetting.GeometryNames;
public ForcesTupleResult SelectedResult { get; set; }
private RelayCommand showIsoFieldCommand;
private RelayCommand exportToCSVCommand;
private RelayCommand interpolateCommand;
private RelayCommand setPrestrainCommand;
private ICommand showIsoFieldCommand;
private ICommand exportToCSVCommand;
private ICommand interpolateCommand;
private ICommand setPrestrainCommand;
private ICommand showAnchorageCommand;
private ICommand showGeometryResultCommand;
private ICommand showGraphsCommand;
private ICommand showCrackResult;
private ICommand showCrackGraphsCommand;
public IForcesResults ForcesResults
{
get => forcesResults;
}
public RelayCommand ShowIsoFieldCommand
public ICommand ShowIsoFieldCommand
{
get
{
@@ -104,7 +107,19 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
}
public ICommand ShowGraphsCommand
{
get => showGraphsCommand ??= new RelayCommand(o => showGraphs());
get => showGraphsCommand ??= new RelayCommand(o =>
{
showDiagramLogic.Show(forcesResults.ForcesResultList);
}
);
}
public ICommand ShowCrackGraphsCommand
{
get => showCrackGraphsCommand ??= new RelayCommand(o =>
{
showDiagramLogic.ShowCracks(forcesResults.ForcesResultList, ndmPrimitives);
}
);
}
public ICommand ShowCrackResultCommand
{
@@ -113,138 +128,27 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
SafetyProcessor.RunSafeProcess(ShowCrackResult);
}, o => (SelectedResult != null) && SelectedResult.IsValid);
}
private void ShowCrackResult()
{
var limitState = SelectedResult.DesignForceTuple.LimitState;
var calcTerm = SelectedResult.DesignForceTuple.CalcTerm;
var calculator = new CrackForceCalculator();
calculator.EndTuple = SelectedResult.DesignForceTuple.ForceTuple;
calculator.NdmCollection = NdmPrimitivesService.GetNdms(ndmPrimitives, limitState, calcTerm);
//Act
calculator.Run();
var result = (CrackForceResult)calculator.Result;
if (result.IsValid)
{
var softLogic = new ExponentialSofteningLogic() { ForceRatio = result.ActualFactor };
string message = string.Empty;
if (result.IsSectionCracked)
{
message += $"Actual crack factor {result.ActualFactor}\n";
message += $"Softening crack factor PsiS={softLogic.SofteningFactor()}\n";
message += $"M{firstAxisName}={result.ActualTuple.Mx}, M{secondAxisName}={result.ActualTuple.My}, N{thirdAxisName}={result.ActualTuple.Nz}";
}
else
{
message += "Cracks are not apeared";
}
MessageBox.Show(
message,
"Crack results",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
else
{
var errorVM = new ErrorProcessor()
{
ShortText = "Error apeared while crack calculate",
DetailText = result.Description
};
var wnd = new ErrorMessage(errorVM);
wnd.ShowDialog();
}
showCrackResultLogic.LimitState = SelectedResult.DesignForceTuple.LimitState;
showCrackResultLogic.CalcTerm = CalcTerms.ShortTerm; //= SelectedResult.DesignForceTuple.CalcTerm;
showCrackResultLogic.ForceTuple = SelectedResult.DesignForceTuple.ForceTuple;
showCrackResultLogic.ndmPrimitives = ndmPrimitives;
showCrackResultLogic.Show();
}
private void showGraphs()
{
var unitForce = CommonOperation.GetUnit(UnitTypes.Force, "kN");
var unitMoment = CommonOperation.GetUnit(UnitTypes.Moment, "kNm");
var unitCurvature = CommonOperation.GetUnit(UnitTypes.Curvature, "1/m");
var labels = new string[]
{
$"M{firstAxisName}, {unitMoment.Name}",
$"M{secondAxisName}, {unitMoment.Name}",
$"N{thirdAxisName}, {unitForce.Name}",
$"K{firstAxisName}, {unitCurvature.Name}",
$"K{secondAxisName}, {unitCurvature.Name}",
$"Eps_{thirdAxisName}"
};
var resultList = forcesResults.ForcesResultList.Where(x => x.IsValid == true).ToList();
var array = new ArrayParameter<double>(resultList.Count(), labels.Count(), labels);
var data = array.Data;
for (int i = 0; i < resultList.Count(); i++)
{
var valueList = new List<double>
{
resultList[i].DesignForceTuple.ForceTuple.Mx * unitMoment.Multiplyer,
resultList[i].DesignForceTuple.ForceTuple.My * unitMoment.Multiplyer,
resultList[i].DesignForceTuple.ForceTuple.Nz * unitForce.Multiplyer,
resultList[i].LoaderResults.ForceStrainPair.StrainMatrix.Kx * unitCurvature.Multiplyer,
resultList[i].LoaderResults.ForceStrainPair.StrainMatrix.Ky * unitCurvature.Multiplyer,
resultList[i].LoaderResults.ForceStrainPair.StrainMatrix.EpsZ
};
for (int j = 0; j < valueList.Count(); j++)
{
data[i, j] = valueList[j];
}
}
var graphViewModel = new GraphViewModel(array);
var wnd = new GraphView(graphViewModel);
try
{
wnd.ShowDialog();
}
catch(Exception ex)
{
var vm = new ErrorProcessor()
{
ShortText = "Errors apearred during showing isofield, see detailed information",
DetailText = $"{ex}"
};
new ErrorMessage(vm).ShowDialog();
}
}
public RelayCommand InterpolateCommand
public ICommand InterpolateCommand
{
get
{
return interpolateCommand ??
(interpolateCommand = new RelayCommand(o =>
{
Interpolate();
IDesignForceTuple finishDesignTuple = SelectedResult.DesignForceTuple.Clone() as IDesignForceTuple;
interpolateLogic.Show(finishDesignTuple, forceCalculator);
}, o => SelectedResult != null));
}
}
private void Interpolate()
{
IDesignForceTuple startDesignTuple, finishDesignTuple;
finishDesignTuple = SelectedResult.DesignForceTuple.Clone() as IDesignForceTuple;
var viewModel = new InterpolateTuplesViewModel(finishDesignTuple, null, 100);
var wndTuples = new InterpolateTuplesView(viewModel);
wndTuples.ShowDialog();
if (wndTuples.DialogResult != true) return;
startDesignTuple = viewModel.StartDesignForce;
finishDesignTuple = viewModel.FinishDesignForce;
int stepCount = viewModel.StepCount;
var calculator = InterpolateService.InterpolateForceCalculator(forceCalculator, finishDesignTuple, startDesignTuple, stepCount);
calculator.Run();
var result = calculator.Result;
if (result is null || result.IsValid == false)
{
MessageBox.Show(result.Description, "Check data for analisys", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
var vm = new ForcesResultsViewModel(calculator);
var wnd = new ForceResultsView(vm);
wnd.ShowDialog();
}
}
public RelayCommand SetPrestrainCommand
public ICommand SetPrestrainCommand
{
get
{
@@ -256,7 +160,6 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
));
}
}
private void SetPrestrain()
{
var source = StrainTupleService.ConvertToStrainTuple(SelectedResult.LoaderResults.StrainMatrix);
@@ -271,7 +174,6 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
}
}
}
public ICommand ShowAnchorageCommand
{
get
@@ -304,7 +206,6 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
new ErrorMessage(vm).ShowDialog();
}
}
public ICommand ShowGeometryResultCommand =>
showGeometryResultCommand ??= new RelayCommand(o =>
showGeometryResult(), o => SelectedResult != null && SelectedResult.IsValid);
@@ -333,14 +234,12 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
}
}
}
public ForcesResultsViewModel(IForceCalculator forceCalculator)
{
this.forceCalculator = forceCalculator;
this.forcesResults = this.forceCalculator.Result as IForcesResults;
ndmPrimitives = this.forceCalculator.Primitives;
}
private void ShowIsoField()
{
try
@@ -384,7 +283,6 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
}
ndms = ndmRange;
}
private bool SelectPrimitives()
{
var vm = new SelectPrimitivesViewModel(ndmPrimitives);

View File

@@ -47,7 +47,7 @@ namespace StructureHelper.Windows.ViewModels.Forces
if (dialogResult == DialogResult.Yes)
{
if (DeleteAction() != true) return;
GlobalRepository.Materials.Delete(SelectedItem.Id);
GlobalRepository.Actions.Delete(SelectedItem.Id);
base.DeleteMethod(parameter);
}
}

View File

@@ -3,6 +3,7 @@ using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculato
using StructureHelper.Windows.ViewModels.Calculations.Calculators;
using StructureHelper.Windows.ViewModels.Errors;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.Models.CrossSections;
@@ -67,7 +68,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
(
runCommand = new RelayCommand(o =>
{
SafetyProcessor.RunSafeProcess(RunCalculator);
SafetyProcessor.RunSafeProcess(RunCalculator, ErrorStrings.ErrorOfExuting + $": {SelectedItem.Name}");
}, o => SelectedItem != null));
}
}