diff --git a/StructureHelper/Services/ResultViewers/ShowAnchorageResult.cs b/StructureHelper/Services/ResultViewers/ShowAnchorageResult.cs index f461a5c..ced8330 100644 --- a/StructureHelper/Services/ResultViewers/ShowAnchorageResult.cs +++ b/StructureHelper/Services/ResultViewers/ShowAnchorageResult.cs @@ -1,10 +1,14 @@ -using LoaderCalculator.Data.Materials; +using FieldVisualizer.Entities.Values.Primitives; +using LoaderCalculator.Data.Materials; using LoaderCalculator.Data.Matrix; +using LoaderCalculator.Data.Ndms; using LoaderCalculator.Logics; +using StructureHelper.Infrastructure.UI.Converters.Units; using StructureHelper.Infrastructure.UI.DataContexts; using StructureHelperCommon.Infrastructures.Enums; using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Infrastructures.Strings; +using StructureHelperCommon.Services.Units; using StructureHelperLogics.Models.Materials; using StructureHelperLogics.Models.Primitives; using StructureHelperLogics.NdmCalculations.Analyses.RC; @@ -12,6 +16,7 @@ using StructureHelperLogics.NdmCalculations.Primitives; using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Intrinsics.Arm; using System.Text; using System.Threading.Tasks; @@ -19,53 +24,139 @@ namespace StructureHelper.Services.ResultViewers { public static class ShowAnchorageResult { - private static IStressLogic stressLogic => new StressLogic(); - public static void ShowAnchorageField (IStrainMatrix strainMatrix, LimitStates limitState, CalcTerms calcTerm, IEnumerable primitives) + internal static List GetPrimitiveSets(IStrainMatrix strainMatrix, LimitStates limitState, CalcTerms calcTerm, IEnumerable ndmPrimitives) { - foreach (var item in primitives) - { - if (item is ReinforcementViewPrimitive) - { - var primitive = item as ReinforcementViewPrimitive; - var ndmPrimitive = primitive.GetNdmPrimitive() as ReinforcementPrimitive; - var inputData = new AnchorageInputData(); - inputData.ConcreteStrength = GetConcreteStrength(limitState, calcTerm, ndmPrimitive); - inputData.ReinforcementStrength = GetReinforcementStrength(limitState, calcTerm, ndmPrimitive); - inputData.CrossSectionArea = ndmPrimitive.Area; - var diameter = Math.Sqrt(ndmPrimitive.Area / Math.PI) * 2d; - inputData.CrossSectionPerimeter = Math.PI * diameter; - var material = ndmPrimitive.HeadMaterial.GetLoaderMaterial(limitState, calcTerm); - var ndm = ndmPrimitive.GetNdms(material).Single(); - inputData.ReinforcementStress = stressLogic.GetStress(strainMatrix, ndm); - inputData.LappedCountRate = 0.5d; - } - } - } - private static double GetConcreteStrength(LimitStates limitState, CalcTerms calcTerm, ReinforcementPrimitive primitive) - { - if (primitive.HostPrimitive is not null) - { - var host = primitive.HostPrimitive; - var hostMaterial = host.HeadMaterial.HelperMaterial; - if (hostMaterial is IConcreteLibMaterial) - { - var concreteMaterial = hostMaterial as IConcreteLibMaterial; - var concreteStrength = concreteMaterial.GetStrength(limitState, calcTerm).Tensile; - return concreteStrength; - } - } - throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ": host's material is incorrect or null"); + var primitiveSets = new List(); + PrimitiveSet primitiveSet; + primitiveSet = GetBaseDevelopmentLength(strainMatrix, limitState, calcTerm, ndmPrimitives); + primitiveSets.Add(primitiveSet); + primitiveSet = GetDevelopmentLength(strainMatrix, limitState, calcTerm, ndmPrimitives, true); + primitiveSet.Name = "Development length full strength"; + primitiveSets.Add(primitiveSet); + primitiveSet = GetDevelopmentLength(strainMatrix, limitState, calcTerm, ndmPrimitives,false); + primitiveSet.Name = "Development length actual stress"; + primitiveSets.Add(primitiveSet); + primitiveSet = GetFullStrengthLapLength(strainMatrix, limitState, calcTerm, ndmPrimitives, 0.5d, true); + primitiveSet.Name = "Lapping length full strength, r=50%"; + primitiveSets.Add(primitiveSet); + primitiveSet = GetFullStrengthLapLength(strainMatrix, limitState, calcTerm, ndmPrimitives, 1d, true); + primitiveSet.Name = "Lapping length full strength, r=100%"; + primitiveSets.Add(primitiveSet); + primitiveSet = GetFullStrengthLapLength(strainMatrix, limitState, calcTerm, ndmPrimitives, 0.5d, false); + primitiveSet.Name = "Lapping length actual stress, r=50%"; + primitiveSets.Add(primitiveSet); + primitiveSet = GetFullStrengthLapLength(strainMatrix, limitState, calcTerm, ndmPrimitives, 1d, false); + primitiveSet.Name = "Lapping length actual stress, r=100%"; + primitiveSets.Add(primitiveSet); + primitiveSet = GetStrength(strainMatrix, limitState, calcTerm, ndmPrimitives, true); + primitiveSet.Name = "Full strength"; + primitiveSets.Add(primitiveSet); + primitiveSet = GetStrength(strainMatrix, limitState, calcTerm, ndmPrimitives, false); + primitiveSet.Name = "Actual stress"; + primitiveSets.Add(primitiveSet); + return primitiveSets; } - private static double GetReinforcementStrength(LimitStates limitState, CalcTerms calcTerm, ReinforcementPrimitive primitive) + private static PrimitiveSet GetStrength(IStrainMatrix strainMatrix, LimitStates limitState, CalcTerms calcTerm, IEnumerable ndmPrimitives, bool fullStrength) { - if (primitive.HeadMaterial.HelperMaterial is IReinforcementLibMaterial) + PrimitiveSet primitiveSet = new PrimitiveSet(); + List primitives = new List(); + foreach (var item in ndmPrimitives) { - var material = primitive.HeadMaterial.HelperMaterial as IReinforcementLibMaterial; - var strength = material.GetStrength(limitState, calcTerm).Tensile; - return strength; + if (item is ReinforcementPrimitive) + { + var primitive = item as ReinforcementPrimitive; + var inputData = InputDataFactory.GetInputData(primitive, strainMatrix, limitState, calcTerm, 1d); + if (fullStrength == true) + { + inputData.ReinforcementStress = inputData.ReinforcementStrength * Math.Sign(inputData.ReinforcementStress); + } + var val = inputData.ReinforcementStress * UnitConstatnts.Stress; + var valuePrimitive = GetValuePrimitive(primitive, val); + primitives.Add(valuePrimitive); + } } - throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ": host's material is incorrect or null"); + primitiveSet.ValuePrimitives = primitives; + return primitiveSet; + } + + private static PrimitiveSet GetBaseDevelopmentLength(IStrainMatrix strainMatrix, LimitStates limitState, CalcTerms calcTerm, IEnumerable ndmPrimitives) + { + PrimitiveSet primitiveSet = new PrimitiveSet() { Name = "Base Development Length"}; + List primitives = new List(); + foreach (var item in ndmPrimitives) + { + if (item is ReinforcementPrimitive) + { + var primitive = item as ReinforcementPrimitive; + var inputData = InputDataFactory.GetInputData(primitive, strainMatrix, limitState, calcTerm, 1d); + var calculator = new AnchorageCalculator(inputData); + var val = calculator.GetBaseDevLength() * UnitConstatnts.Length; + var valuePrimitive = GetValuePrimitive(primitive, val); + primitives.Add(valuePrimitive); + } + } + primitiveSet.ValuePrimitives = primitives; + return primitiveSet; + } + private static PrimitiveSet GetDevelopmentLength(IStrainMatrix strainMatrix, LimitStates limitState, CalcTerms calcTerm, IEnumerable ndmPrimitives, bool fullStrength) + { + PrimitiveSet primitiveSet = new PrimitiveSet(); + List primitives = new List(); + foreach (var item in ndmPrimitives) + { + if (item is ReinforcementPrimitive) + { + var primitive = item as ReinforcementPrimitive; + var inputData = InputDataFactory.GetInputData(primitive, strainMatrix, limitState, calcTerm, 1d); + if (fullStrength == true) + { + inputData.ReinforcementStress = inputData.ReinforcementStrength * Math.Sign(inputData.ReinforcementStress); + } + var calculator = new AnchorageCalculator(inputData); + var val = calculator.GetDevLength() * UnitConstatnts.Length; + var valuePrimitive = GetValuePrimitive(primitive, val); + primitives.Add(valuePrimitive); + } + } + primitiveSet.ValuePrimitives = primitives; + return primitiveSet; + } + + private static PrimitiveSet GetFullStrengthLapLength(IStrainMatrix strainMatrix, LimitStates limitState, CalcTerms calcTerm, IEnumerable ndmPrimitives, double lapperdCountRate, bool fullStrength) + { + PrimitiveSet primitiveSet = new PrimitiveSet(); + List primitives = new List(); + foreach (var item in ndmPrimitives) + { + if (item is ReinforcementPrimitive) + { + var primitive = item as ReinforcementPrimitive; + var inputData = InputDataFactory.GetInputData(primitive, strainMatrix, limitState, calcTerm, lapperdCountRate); + if (fullStrength == true) + { + inputData.ReinforcementStress = inputData.ReinforcementStrength * Math.Sign(inputData.ReinforcementStress); + } + var calculator = new AnchorageCalculator(inputData); + var val = calculator.GetLapLength() * UnitConstatnts.Length; + var valuePrimitive = GetValuePrimitive(primitive, val); + primitives.Add(valuePrimitive); + } + } + primitiveSet.ValuePrimitives = primitives; + return primitiveSet; + } + + private static FieldVisualizer.Entities.Values.Primitives.CirclePrimitive GetValuePrimitive(IPointPrimitive primitive, double val) + { + var valuePrimitive = new FieldVisualizer.Entities.Values.Primitives.CirclePrimitive() + { + CenterX = primitive.CenterX, + CenterY = primitive.CenterY, + Diameter = Math.Sqrt(primitive.Area / Math.PI) * 2, + Value = val + }; + return valuePrimitive; } } } diff --git a/StructureHelper/StructureHelper.csproj.user b/StructureHelper/StructureHelper.csproj.user index 3098e55..7a16b50 100644 --- a/StructureHelper/StructureHelper.csproj.user +++ b/StructureHelper/StructureHelper.csproj.user @@ -9,6 +9,9 @@ + + Code + Code @@ -23,6 +26,9 @@ Designer + + Designer + Designer diff --git a/StructureHelper/Windows/Errors/ErrorMessage.xaml b/StructureHelper/Windows/Errors/ErrorMessage.xaml new file mode 100644 index 0000000..31887ec --- /dev/null +++ b/StructureHelper/Windows/Errors/ErrorMessage.xaml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/StructureHelper/Windows/Errors/ErrorMessage.xaml.cs b/StructureHelper/Windows/Errors/ErrorMessage.xaml.cs new file mode 100644 index 0000000..03fcdac --- /dev/null +++ b/StructureHelper/Windows/Errors/ErrorMessage.xaml.cs @@ -0,0 +1,31 @@ +using StructureHelper.Windows.ViewModels.Errors; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; + +namespace StructureHelper.Windows.Errors +{ + /// + /// Логика взаимодействия для ErrorMessage.xaml + /// + public partial class ErrorMessage : Window + { + ErrorProcessor vm; + public ErrorMessage(ErrorProcessor errorProcessor) + { + vm = errorProcessor; + this.DataContext = vm; + InitializeComponent(); + } + } +} diff --git a/StructureHelper/Windows/ViewModels/CRUDViewModelBase.cs b/StructureHelper/Windows/ViewModels/CRUDViewModelBase.cs index aea589b..da745d7 100644 --- a/StructureHelper/Windows/ViewModels/CRUDViewModelBase.cs +++ b/StructureHelper/Windows/ViewModels/CRUDViewModelBase.cs @@ -7,16 +7,17 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Documents; +using System.Windows.Input; namespace StructureHelper.Windows.ViewModels { public abstract class CRUDViewModelBase : ViewModelBase, ICRUDViewModel where TItem : class { - private RelayCommand addCommand; - private RelayCommand deleteCommand; - private RelayCommand copyCommand; - private RelayCommand editCommand; + private ICommand addCommand; + private ICommand deleteCommand; + private ICommand copyCommand; + private ICommand editCommand; public List Collection { get; set; } @@ -25,7 +26,7 @@ namespace StructureHelper.Windows.ViewModels public ObservableCollection Items { get; private set; } - public RelayCommand Add + public ICommand Add { get { @@ -43,7 +44,7 @@ namespace StructureHelper.Windows.ViewModels Collection.Add(NewItem); Items.Add(NewItem); } - public RelayCommand Delete + public ICommand Delete { get { @@ -61,7 +62,7 @@ namespace StructureHelper.Windows.ViewModels Collection.Remove(SelectedItem); Items.Remove(SelectedItem); } - public RelayCommand Edit + public ICommand Edit { get { @@ -84,7 +85,7 @@ namespace StructureHelper.Windows.ViewModels OnPropertyChanged(nameof(Items)); } - public RelayCommand Copy + public ICommand Copy { get { diff --git a/StructureHelper/Windows/ViewModels/Calculations/Calculators/ForcesResultsViewModel.cs b/StructureHelper/Windows/ViewModels/Calculations/Calculators/ForcesResultsViewModel.cs index 9f1cffa..c26772e 100644 --- a/StructureHelper/Windows/ViewModels/Calculations/Calculators/ForcesResultsViewModel.cs +++ b/StructureHelper/Windows/ViewModels/Calculations/Calculators/ForcesResultsViewModel.cs @@ -7,8 +7,10 @@ using StructureHelper.Services.Reports.CalculationReports; using StructureHelper.Services.ResultViewers; using StructureHelper.Windows.CalculationWindows.CalculatorsViews; using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews; +using StructureHelper.Windows.Errors; using StructureHelper.Windows.Forces; using StructureHelper.Windows.PrimitivePropertiesWindow; +using StructureHelper.Windows.ViewModels.Errors; using StructureHelper.Windows.ViewModels.Forces; using StructureHelper.Windows.ViewModels.PrimitiveProperties; using StructureHelperCommon.Infrastructures.Exceptions; @@ -74,7 +76,7 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators } } - public RelayCommand ExportToCSVCommand + public ICommand ExportToCSVCommand { get { @@ -105,7 +107,12 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators } catch (Exception ex) { - throw new StructureHelperException(ErrorStrings.FileCantBeDeleted + ex + filename); + var vm = new ErrorProcessor() + { + ShortText = ErrorStrings.FileCantBeDeleted + ex + filename, + DetailText = $"{ex}" + }; + new ErrorMessage(vm).ShowDialog(); } } @@ -115,15 +122,21 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators logic.Export(forcesResults); try { - Process filopener = new Process(); - filopener.StartInfo.FileName = saveFileDialog.FileName; + var filopener = new Process(); + var startInfo = new ProcessStartInfo(saveFileDialog.FileName) { UseShellExecute = true}; + filopener.StartInfo = startInfo; filopener.Start(); } catch (Exception) { } } catch (Exception ex) { - throw new StructureHelperException(ErrorStrings.FileCantBeSaved + ex + filename); + var vm = new ErrorProcessor() + { + ShortText = ErrorStrings.FileCantBeSaved + ex + filename, + DetailText = $"{ex}" + }; + new ErrorMessage(vm).ShowDialog(); } } } @@ -209,7 +222,24 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators private void showAnchorage() { - throw new NotImplementedException(); + try + { + var strainMatrix = SelectedResult.LoaderResults.ForceStrainPair.StrainMatrix; + var limitState = SelectedResult.DesignForceTuple.LimitState; + var calcTerm = SelectedResult.DesignForceTuple.CalcTerm; + + var primitiveSets = ShowAnchorageResult.GetPrimitiveSets(strainMatrix, limitState, calcTerm, ndmPrimitives); + isoFieldReport = new IsoFieldReport(primitiveSets); + isoFieldReport.Show(); + } + catch(Exception ex) + { + var vm = new ErrorProcessor() + { ShortText = "Errors apearred during showing isofield, see detailed information", + DetailText = $"{ex}"}; + new ErrorMessage(vm).ShowDialog(); + } + } public ForcesResultsViewModel(IForceCalculator forceCalculator) @@ -221,10 +251,23 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators private void ShowIsoField() { - IStrainMatrix strainMatrix = SelectedResult.LoaderResults.ForceStrainPair.StrainMatrix; - var primitiveSets = ShowIsoFieldResult.GetPrimitiveSets(strainMatrix, ndms, ResultFuncFactory.GetResultFuncs()); - isoFieldReport = new IsoFieldReport(primitiveSets); - isoFieldReport.Show(); + try + { + IStrainMatrix strainMatrix = SelectedResult.LoaderResults.ForceStrainPair.StrainMatrix; + var primitiveSets = ShowIsoFieldResult.GetPrimitiveSets(strainMatrix, ndms, ResultFuncFactory.GetResultFuncs()); + isoFieldReport = new IsoFieldReport(primitiveSets); + isoFieldReport.Show(); + } + catch (Exception ex) + { + var vm = new ErrorProcessor() + { + ShortText = "Errors apearred during showing isofield, see detailed information", + DetailText = $"{ex}" + }; + new ErrorMessage(vm).ShowDialog(); + } + } private void GetNdms() diff --git a/StructureHelper/Windows/ViewModels/Calculations/Calculators/SetPrestrainViewModel.cs b/StructureHelper/Windows/ViewModels/Calculations/Calculators/SetPrestrainViewModel.cs index 8797839..f2c2fac 100644 --- a/StructureHelper/Windows/ViewModels/Calculations/Calculators/SetPrestrainViewModel.cs +++ b/StructureHelper/Windows/ViewModels/Calculations/Calculators/SetPrestrainViewModel.cs @@ -12,30 +12,30 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators public class SetPrestrainViewModel : ViewModelBase { IStrainTuple SourceTuple; - private double coeffcient; + private double coefficient; public double Coefficient { get { - return coeffcient; + return coefficient; } set { - SetProperty(ref coeffcient, value); + SetProperty(ref coefficient, value); } } public SetPrestrainViewModel(IStrainTuple sourceTuple) { SourceTuple = sourceTuple; - coeffcient = 1d; + coefficient = 1d; } public IStrainTuple GetStrainTuple() { var result = new StrainTuple(); - StrainTupleService.CopyProperties(SourceTuple, result, coeffcient); + StrainTupleService.CopyProperties(SourceTuple, result, coefficient); return result; } } diff --git a/StructureHelper/Windows/ViewModels/Errors/ErrorProcessor.cs b/StructureHelper/Windows/ViewModels/Errors/ErrorProcessor.cs new file mode 100644 index 0000000..4c5f890 --- /dev/null +++ b/StructureHelper/Windows/ViewModels/Errors/ErrorProcessor.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelper.Windows.ViewModels.Errors +{ + public class ErrorProcessor + { + public string? ShortText { get; set; } + public string? DetailText { get; set; } + } +} diff --git a/StructureHelper/Windows/ViewModels/ICRUDViewModel.cs b/StructureHelper/Windows/ViewModels/ICRUDViewModel.cs index 16fb247..3bf1c5e 100644 --- a/StructureHelper/Windows/ViewModels/ICRUDViewModel.cs +++ b/StructureHelper/Windows/ViewModels/ICRUDViewModel.cs @@ -6,6 +6,7 @@ using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Input; namespace StructureHelper.Windows.ViewModels { @@ -13,10 +14,10 @@ namespace StructureHelper.Windows.ViewModels { TItem SelectedItem { get; set; } ObservableCollection Items { get; } - RelayCommand Add { get; } - RelayCommand Delete { get; } - RelayCommand Edit { get; } - RelayCommand Copy { get; } + ICommand Add { get; } + ICommand Delete { get; } + ICommand Edit { get; } + ICommand Copy { get; } void AddItems(IEnumerable items); } } diff --git a/StructureHelper/Windows/ViewModels/NdmCrossSections/ForceCombinationViewModelLogic.cs b/StructureHelper/Windows/ViewModels/NdmCrossSections/ForceCombinationViewModelLogic.cs index d360122..2bd529d 100644 --- a/StructureHelper/Windows/ViewModels/NdmCrossSections/ForceCombinationViewModelLogic.cs +++ b/StructureHelper/Windows/ViewModels/NdmCrossSections/ForceCombinationViewModelLogic.cs @@ -23,8 +23,8 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections public ObservableCollection Items { get; private set; } - private RelayCommand addForceCombinationCommand; - public RelayCommand Add + private ICommand addForceCombinationCommand; + public ICommand Add { get { @@ -43,8 +43,8 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections Items.Add(item); repository.ForceActions.Add(item); } - private RelayCommand deleteForceCombinationCommand; - public RelayCommand Delete + private ICommand deleteForceCombinationCommand; + public ICommand Delete { get { @@ -65,10 +65,10 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections repository.ForceActions.Remove(SelectedItem); } } - private RelayCommand editForceCombinationCommand; - private RelayCommand copyCommand; + private ICommand editForceCombinationCommand; + private ICommand copyCommand; - public RelayCommand Edit + public ICommand Edit { get { @@ -84,7 +84,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections } } - public RelayCommand Copy + public ICommand Copy { get { diff --git a/StructureHelper/Windows/ViewModels/NdmCrossSections/PrimitiveViewModelLogic.cs b/StructureHelper/Windows/ViewModels/NdmCrossSections/PrimitiveViewModelLogic.cs index 14950ce..62bed2b 100644 --- a/StructureHelper/Windows/ViewModels/NdmCrossSections/PrimitiveViewModelLogic.cs +++ b/StructureHelper/Windows/ViewModels/NdmCrossSections/PrimitiveViewModelLogic.cs @@ -19,6 +19,7 @@ using System.Windows.Forms; using System.Windows.Documents; using StructureHelper.Windows.PrimitiveProperiesWindow; using StructureHelperLogics.NdmCalculations.Analyses.ByForces; +using System.Windows.Input; namespace StructureHelper.Windows.ViewModels.NdmCrossSections { @@ -26,12 +27,12 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections { private ICrossSection section; private ICrossSectionRepository repository => section.SectionRepository; - private RelayCommand addCommand; - private RelayCommand deleteCommand; - private RelayCommand editCommand; - private RelayCommand copyCommand; - private RelayCommand setToFront; - private RelayCommand setToBack; + private ICommand addCommand; + private ICommand deleteCommand; + private ICommand editCommand; + private ICommand copyCommand; + private ICommand setToFront; + private ICommand setToBack; public double CanvasWidth { get; set; } public double CanvasHeight { get; set; } @@ -40,7 +41,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections public ObservableCollection Items { get; private set; } - public RelayCommand Add + public ICommand Add { get { @@ -106,7 +107,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections OnPropertyChanged(nameof(PrimitivesCount)); } - public RelayCommand Delete + public ICommand Delete { get { @@ -148,7 +149,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections OnPropertyChanged(nameof(PrimitivesCount)); } - public RelayCommand Edit + public ICommand Edit { get { @@ -166,7 +167,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections wnd.ShowDialog(); } - public RelayCommand Copy + public ICommand Copy { get { @@ -197,7 +198,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections public int PrimitivesCount => repository.Primitives.Count(); - public RelayCommand SetToFront + public ICommand SetToFront { get { @@ -226,7 +227,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections else return false; } - public RelayCommand SetToBack + public ICommand SetToBack { get { diff --git a/StructureHelper/Windows/ViewModels/PrimitiveProperties/PrimitivePropertiesViewModel.cs b/StructureHelper/Windows/ViewModels/PrimitiveProperties/PrimitivePropertiesViewModel.cs index 60cc925..a959b2e 100644 --- a/StructureHelper/Windows/ViewModels/PrimitiveProperties/PrimitivePropertiesViewModel.cs +++ b/StructureHelper/Windows/ViewModels/PrimitiveProperties/PrimitivePropertiesViewModel.cs @@ -10,6 +10,7 @@ using StructureHelperCommon.Models.Shapes; using StructureHelperCommon.Services.ColorServices; using StructureHelperLogics.Models.CrossSections; using StructureHelperLogics.Models.Materials; +using StructureHelperLogics.NdmCalculations.Analyses.ByForces; using StructureHelperLogics.NdmCalculations.Primitives; using System; using System.Collections.Generic; @@ -19,6 +20,7 @@ using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; +using System.Windows.Forms; using System.Windows.Input; using System.Windows.Media; using System.Xml.Linq; @@ -314,7 +316,33 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties foreach (var item in sectionRepository.Primitives) { if (item is RectanglePrimitive || item is CirclePrimitive) - {HostPrimitives.Add(PrimitiveOperations.ConvertNdmPrimitiveToPrimitiveBase(item));} + { + CheckHost(primitive, item); + HostPrimitives.Add(PrimitiveOperations.ConvertNdmPrimitiveToPrimitiveBase(item)); + } + } + } + + private void CheckHost(PrimitiveBase primitive, INdmPrimitive item) + { + var ndm = primitive.GetNdmPrimitive(); + if (ndm is ReinforcementPrimitive) + { + var host = item as IHasDivisionSize; + var reinforcement = ndm as ReinforcementPrimitive; + if (host.IsPointInside(new Point2D() { X = reinforcement.CenterX, Y = reinforcement.CenterY }) + && reinforcement.HostPrimitive is null) + { + var dialogResult = MessageBox.Show($"Primitive {reinforcement.Name} is inside primitive {item.Name}", + "Assign new host?", + MessageBoxButtons.YesNo, + MessageBoxIcon.Warning); + if (dialogResult == DialogResult.Yes) + { + reinforcement.HostPrimitive = item; + } + } + } } diff --git a/StructureHelperLogics/Models/Materials/ConcreteLibMaterial.cs b/StructureHelperLogics/Models/Materials/ConcreteLibMaterial.cs index 0172bcb..c4b465b 100644 --- a/StructureHelperLogics/Models/Materials/ConcreteLibMaterial.cs +++ b/StructureHelperLogics/Models/Materials/ConcreteLibMaterial.cs @@ -2,15 +2,15 @@ using StructureHelperCommon.Infrastructures.Exceptions; using StructureHelperCommon.Infrastructures.Strings; using StructureHelperCommon.Models.Materials.Libraries; -using LCM = LoaderCalculator.Data.Materials; -using LCMB = LoaderCalculator.Data.Materials.MaterialBuilders; +using LoaderMaterials = LoaderCalculator.Data.Materials; +using LoaderMaterialBuilders = LoaderCalculator.Data.Materials.MaterialBuilders; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using StructureHelperCommon.Infrastructures.Settings; -using LCMBML = LoaderCalculator.Data.Materials.MaterialBuilders.MaterialLogics; +using LoaderMaterialLogic = LoaderCalculator.Data.Materials.MaterialBuilders.MaterialLogics; namespace StructureHelperLogics.Models.Materials { @@ -22,13 +22,13 @@ namespace StructureHelperLogics.Models.Materials public bool TensionForSLS { get; set; } private IMaterialOptionLogic optionLogic; - private LCMBML.ITrueStrengthLogic strengthLogic; + private LoaderMaterialLogic.ITrueStrengthLogic strengthLogic; public ConcreteLibMaterial() { SafetyFactors = new List(); SafetyFactors.AddRange(PartialCoefficientFactory.GetDefaultConcreteSafetyFactors(ProgramSetting.CodeType)); - optionLogic = new MaterialOptionLogic(new LCMB.ConcreteOptions()); + optionLogic = new MaterialOptionLogic(new LoaderMaterialBuilders.ConcreteOptions()); TensionForULS = false; TensionForSLS = true; } @@ -38,9 +38,9 @@ namespace StructureHelperLogics.Models.Materials return new ConcreteLibMaterial() { MaterialEntity = MaterialEntity, TensionForULS = TensionForULS, TensionForSLS = TensionForSLS }; } - public LCM.IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm) + public LoaderMaterials.IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm) { - var materialOptions = optionLogic.SetMaterialOptions(MaterialEntity, limitState, calcTerm) as LCMB.ConcreteOptions; + var materialOptions = optionLogic.SetMaterialOptions(MaterialEntity, limitState, calcTerm) as LoaderMaterialBuilders.ConcreteOptions; materialOptions.WorkInTension = false; if (limitState == LimitStates.ULS & TensionForULS == true) { @@ -53,8 +53,8 @@ namespace StructureHelperLogics.Models.Materials var strength = GetStrengthFactors(limitState, calcTerm); materialOptions.ExternalFactor.Compressive = strength.Compressive; materialOptions.ExternalFactor.Tensile = strength.Tensile; - LCMB.IMaterialBuilder builder = new LCMB.ConcreteBuilder(materialOptions); - LCMB.IBuilderDirector director = new LCMB.BuilderDirector(builder); + LoaderMaterialBuilders.IMaterialBuilder builder = new LoaderMaterialBuilders.ConcreteBuilder(materialOptions); + LoaderMaterialBuilders.IBuilderDirector director = new LoaderMaterialBuilders.BuilderDirector(builder); return director.BuildMaterial(); } @@ -72,9 +72,19 @@ namespace StructureHelperLogics.Models.Materials public (double Compressive, double Tensile) GetStrength(LimitStates limitState, CalcTerms calcTerm) { - strengthLogic = new LCMBML.TrueStrengthConcreteLogicSP63_2018(MaterialEntity.MainStrength); + strengthLogic = new LoaderMaterialLogic.TrueStrengthConcreteLogicSP63_2018(MaterialEntity.MainStrength); var strength = strengthLogic.GetTrueStrength(); - return (strength.Comressive, strength.Tensile); + double compressionFactor = 1d; + double tensionFactor = 1d; + if (limitState == LimitStates.ULS) + { + compressionFactor /= 1.3d; + tensionFactor /= 1.5d; + var factors = GetStrengthFactors(limitState, calcTerm); + compressionFactor *= factors.Compressive; + tensionFactor *= factors.Tensile; + } + return (strength.Comressive * compressionFactor, strength.Tensile * tensionFactor); } } } diff --git a/StructureHelperLogics/Models/Materials/Factories/HeadMaterialFactory.cs b/StructureHelperLogics/Models/Materials/Factories/HeadMaterialFactory.cs index 82ef0a7..ab67211 100644 --- a/StructureHelperLogics/Models/Materials/Factories/HeadMaterialFactory.cs +++ b/StructureHelperLogics/Models/Materials/Factories/HeadMaterialFactory.cs @@ -16,6 +16,7 @@ namespace StructureHelperLogics.Models.Materials { Concrete40, Reinforecement400, + Reinforecement500, Elastic200 } @@ -30,10 +31,21 @@ namespace StructureHelperLogics.Models.Materials codeType = code; if (type == HeadmaterialType.Concrete40) { return GetConcrete40(); } if (type == HeadmaterialType.Reinforecement400) { return GetReinforcement400(); } + if (type == HeadmaterialType.Reinforecement500) { return GetReinforcement500(); } if (type == HeadmaterialType.Elastic200) { return GetElastic200(); } else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + nameof(type)); } + private static IHeadMaterial GetReinforcement500() + { + var material = new HeadMaterial() { Name = "New reinforcement" }; + var libMaterial = LibReinforcementMaterials.Where(x => x.Name.Contains("500")).First(); + var libMat = new ReinforcementLibMaterial(); + libMat.MaterialEntity = libMaterial; + material.HelperMaterial = libMat; + return material; + } + private static IHeadMaterial GetElastic200() { var material = new HeadMaterial(); diff --git a/StructureHelperLogics/Models/Materials/ReinforcementLibMaterial.cs b/StructureHelperLogics/Models/Materials/ReinforcementLibMaterial.cs index dacbde4..105911a 100644 --- a/StructureHelperLogics/Models/Materials/ReinforcementLibMaterial.cs +++ b/StructureHelperLogics/Models/Materials/ReinforcementLibMaterial.cs @@ -5,9 +5,9 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using LCM = LoaderCalculator.Data.Materials; -using LCMB = LoaderCalculator.Data.Materials.MaterialBuilders; -using LCMBML = LoaderCalculator.Data.Materials.MaterialBuilders.MaterialLogics; +using Loadermaterials = LoaderCalculator.Data.Materials; +using LoaderMaterialBuilders = LoaderCalculator.Data.Materials.MaterialBuilders; +using LoaderMaterialLogics = LoaderCalculator.Data.Materials.MaterialBuilders.MaterialLogics; namespace StructureHelperLogics.Models.Materials { @@ -17,12 +17,12 @@ namespace StructureHelperLogics.Models.Materials public List SafetyFactors { get; } private IMaterialOptionLogic optionLogic; - private LCMBML.ITrueStrengthLogic strengthLogic; + private LoaderMaterialLogics.ITrueStrengthLogic strengthLogic; public ReinforcementLibMaterial() { SafetyFactors = new List(); - optionLogic = new MaterialOptionLogic(new LCMB.ReinforcementOptions()); + optionLogic = new MaterialOptionLogic(new LoaderMaterialBuilders.ReinforcementOptions()); } public object Clone() @@ -30,14 +30,14 @@ namespace StructureHelperLogics.Models.Materials return new ReinforcementLibMaterial() { MaterialEntity = MaterialEntity}; } - public LCM.IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm) + public Loadermaterials.IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm) { var materialOptions = optionLogic.SetMaterialOptions(MaterialEntity, limitState, calcTerm); var strength = GetStrengthFactors(limitState, calcTerm); materialOptions.ExternalFactor.Compressive = strength.Compressive; materialOptions.ExternalFactor.Tensile = strength.Tensile; - LCMB.IMaterialBuilder builder = new LCMB.ReinforcementBuilder(materialOptions); - LCMB.IBuilderDirector director = new LCMB.BuilderDirector(builder); + LoaderMaterialBuilders.IMaterialBuilder builder = new LoaderMaterialBuilders.ReinforcementBuilder(materialOptions); + LoaderMaterialBuilders.IBuilderDirector director = new LoaderMaterialBuilders.BuilderDirector(builder); return director.BuildMaterial(); } @@ -55,9 +55,32 @@ namespace StructureHelperLogics.Models.Materials public (double Compressive, double Tensile) GetStrength(LimitStates limitState, CalcTerms calcTerm) { - strengthLogic = new LCMBML.TrueStrengthReinforcementLogic(MaterialEntity.MainStrength); + strengthLogic = new LoaderMaterialLogics.TrueStrengthReinforcementLogic(MaterialEntity.MainStrength); var strength = strengthLogic.GetTrueStrength(); - return (strength.Comressive, strength.Tensile); + double compressionFactor = 1d; + double tensionFactor = 1d; + if (limitState == LimitStates.ULS) + { + compressionFactor /= 1.15d; + tensionFactor /= 1.15d; + } + var factors = GetStrengthFactors(limitState, calcTerm); + compressionFactor *= factors.Compressive; + tensionFactor *= factors.Tensile; + var compressiveStrength = strength.Comressive * compressionFactor; + if (limitState == LimitStates.ULS) + { + if (calcTerm == CalcTerms.ShortTerm) + { + compressiveStrength = Math.Min(4e8, compressiveStrength); + } + else + { + compressiveStrength = Math.Min(5e8, compressiveStrength); + } + } + var tensileStrength = strength.Tensile * tensionFactor; + return (compressiveStrength, tensileStrength); } } } diff --git a/StructureHelperLogics/NdmCalculations/Analyses/RC/AnchorageCalculator.cs b/StructureHelperLogics/NdmCalculations/Analyses/RC/AnchorageCalculator.cs index 82560e8..cbc4528 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/RC/AnchorageCalculator.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/RC/AnchorageCalculator.cs @@ -22,7 +22,8 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.RC public double GetBaseDevLength() { - return anchorage.GetBaseDevLength(); + var val = anchorage.GetBaseDevLength(); + return val; } public double GetDevLength() @@ -40,6 +41,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.RC var anchorageOptions = new AnchorageOptionsSP63(); anchorageOptions.ConcreteStrength = inputData.ConcreteStrength; anchorageOptions.ReinforcementStrength = inputData.ReinforcementStrength; + anchorageOptions.FactorEta1 = inputData.FactorEta1; anchorageOptions.ReinforcementStress = inputData.ReinforcementStress; anchorageOptions.CrossSectionArea = inputData.CrossSectionArea; anchorageOptions.CrossSectionPerimeter = inputData.CrossSectionPerimeter; diff --git a/StructureHelperLogics/NdmCalculations/Analyses/RC/AnchorageInputData.cs b/StructureHelperLogics/NdmCalculations/Analyses/RC/AnchorageInputData.cs index 3be14f1..7f8850e 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/RC/AnchorageInputData.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/RC/AnchorageInputData.cs @@ -14,5 +14,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.RC public double CrossSectionPerimeter { get; set; } public double ReinforcementStress { get; set; } public double LappedCountRate { get; set; } + public double FactorEta1 { get; set; } + public bool IsPrestressed { get; set; } } } diff --git a/StructureHelperLogics/NdmCalculations/Analyses/RC/IAnchorageInputData.cs b/StructureHelperLogics/NdmCalculations/Analyses/RC/IAnchorageInputData.cs index aeabf57..1ee2363 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/RC/IAnchorageInputData.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/RC/IAnchorageInputData.cs @@ -10,10 +10,12 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.RC { double ConcreteStrength { get; set; } double ReinforcementStrength { get; set; } + double FactorEta1 { get; set; } double CrossSectionArea { get; set; } double CrossSectionPerimeter { get; set; } double ReinforcementStress { get; set; } double LappedCountRate { get; set; } + bool IsPrestressed { get; set; } } } diff --git a/StructureHelperLogics/NdmCalculations/Analyses/RC/InputDataFactory.cs b/StructureHelperLogics/NdmCalculations/Analyses/RC/InputDataFactory.cs new file mode 100644 index 0000000..48158aa --- /dev/null +++ b/StructureHelperLogics/NdmCalculations/Analyses/RC/InputDataFactory.cs @@ -0,0 +1,74 @@ +using LoaderCalculator.Data.Matrix; +using LoaderCalculator.Logics; +using StructureHelperCommon.Infrastructures.Enums; +using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Infrastructures.Strings; +using StructureHelperLogics.Models.Materials; +using StructureHelperLogics.NdmCalculations.Primitives; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.NdmCalculations.Analyses.RC +{ + public static class InputDataFactory + { + private static IStressLogic stressLogic => new StressLogic(); + public static IAnchorageInputData GetInputData(ReinforcementPrimitive ndmPrimitive, IStrainMatrix strainMatrix, LimitStates limitState, CalcTerms calcTerm, double lappedCountRate) + { + var inputData = new AnchorageInputData(); + inputData.ConcreteStrength = GetConcreteStrength(limitState, calcTerm, ndmPrimitive); + inputData.ReinforcementStrength = GetReinforcementStrength(limitState, calcTerm, ndmPrimitive); + inputData.FactorEta1 = 2.5d; + inputData.CrossSectionArea = ndmPrimitive.Area; + var diameter = Math.Sqrt(ndmPrimitive.Area / Math.PI) * 2d; + inputData.CrossSectionPerimeter = Math.PI * diameter; + if (ndmPrimitive.HeadMaterial is null) + { + throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ": main material is incorrect or null"); + } + var material = ndmPrimitive.HeadMaterial.GetLoaderMaterial(limitState, calcTerm); + var ndm = ndmPrimitive.GetNdms(material).Single(); + if (strainMatrix is not null) + { + inputData.ReinforcementStress = stressLogic.GetStress(strainMatrix, ndm); + } + else + { + inputData.ReinforcementStress = inputData.ReinforcementStrength; + } + inputData.IsPrestressed = ndm.Prestrain > 0.0005d ? true : false; + inputData.LappedCountRate = lappedCountRate; + return inputData; + } + + private static double GetConcreteStrength(LimitStates limitState, CalcTerms calcTerm, ReinforcementPrimitive primitive) + { + if (primitive.HostPrimitive is not null) + { + var host = primitive.HostPrimitive; + var hostMaterial = host.HeadMaterial.HelperMaterial; + if (hostMaterial is IConcreteLibMaterial) + { + var concreteMaterial = hostMaterial as IConcreteLibMaterial; + var concreteStrength = concreteMaterial.GetStrength(limitState, calcTerm).Tensile; + return concreteStrength; + } + } + throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ": host material is incorrect or null"); + } + + private static double GetReinforcementStrength(LimitStates limitState, CalcTerms calcTerm, ReinforcementPrimitive primitive) + { + if (primitive.HeadMaterial.HelperMaterial is IReinforcementLibMaterial) + { + var material = primitive.HeadMaterial.HelperMaterial as IReinforcementLibMaterial; + var strength = material.GetStrength(limitState, calcTerm).Tensile; + return strength; + } + throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ": host's material is incorrect or null"); + } + } +} diff --git a/StructureHelperTests/FunctionalTests/Ndms/Calculators/AnchorageCalculatorTest/AnchorageCalculatorTest.cs b/StructureHelperTests/FunctionalTests/Ndms/Calculators/AnchorageCalculatorTest/AnchorageCalculatorTest.cs new file mode 100644 index 0000000..ca1f6d4 --- /dev/null +++ b/StructureHelperTests/FunctionalTests/Ndms/Calculators/AnchorageCalculatorTest/AnchorageCalculatorTest.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using NUnit.Framework; +using StructureHelperLogics.NdmCalculations.Analyses.RC; + +namespace StructureHelperTests.FunctionalTests.Ndms.Calculators.AnchorageCalculatorTest +{ + public class AnchorageCalculatorTest + { + [TestCase(0.012d, 0d, 0.416d)] + [TestCase(0.025d, 0d, 0.867d)] + [TestCase(0.032d, 0d, 1.110d)] + [TestCase(0.036d, 0d, 1.388d)] + public void Run_ShouldPass(double diameter, double stress, double expectedBaseDevLength) + { + //Arrange + var inputData = new AnchorageInputData(); + inputData.ConcreteStrength = 1e6; //Pa + inputData.ReinforcementStrength = 347e6; //Pa + inputData.FactorEta1 = 2.5d; + inputData.CrossSectionArea = Math.PI * diameter * diameter / 4d; + inputData.CrossSectionPerimeter = Math.PI * diameter; + inputData.ReinforcementStress = stress; + var calculator = new AnchorageCalculator(inputData); + //Act + var baseLength = calculator.GetBaseDevLength(); + //Assert + Assert.AreEqual(expectedBaseDevLength, baseLength, 0.001d); + } + } +} diff --git a/StructureHelperTests/FunctionalTests/Ndms/Calculators/ForceCalculatorTests/RCSectionsTest.cs b/StructureHelperTests/FunctionalTests/Ndms/Calculators/ForceCalculatorTests/RCSectionsTest.cs index 26c8f1d..009abcd 100644 --- a/StructureHelperTests/FunctionalTests/Ndms/Calculators/ForceCalculatorTests/RCSectionsTest.cs +++ b/StructureHelperTests/FunctionalTests/Ndms/Calculators/ForceCalculatorTests/RCSectionsTest.cs @@ -1,9 +1,11 @@ using LoaderCalculator.Tests.Infrastructures.Logics; using Moq; using NUnit.Framework; +using StructureHelperCommon.Services.Forces; using StructureHelperLogics.Models.Templates.CrossSections.RCs; using StructureHelperLogics.Models.Templates.RCs; using StructureHelperLogics.NdmCalculations.Analyses.ByForces; +using StructureHelperLogics.NdmCalculations.Primitives; namespace StructureHelperTests.FunctionalTests.Ndms.Calculators.ForceCalculatorTests { @@ -55,5 +57,37 @@ namespace StructureHelperTests.FunctionalTests.Ndms.Calculators.ForceCalculatorT Assert.True(calcResult == result.IsValid); Assert.True(firstForceResult == result.ForcesResultList[0].IsValid); } + + [TestCase(0.4d, 0.6d, 0.012d, 0.025d, 2, 2, 0d, 0d, 0d)] + public void Run_ShouldPassPrestrain(double width, double height, double topDiametr, double bottomDiametr, int widthCount, int heightCount, double expectedKx, double expectedKy, double expectedEpsZ) + { + //Arrange + var template = new RectangleBeamTemplate(width, height) { TopDiameter = topDiametr, BottomDiameter = bottomDiametr, WidthCount = widthCount, HeightCount = heightCount }; + var newSection = new SectionTemplate(new RectGeometryLogic(template)).GetCrossSection(); + var calculator = newSection.SectionRepository.CalculatorsList[0] as IForceCalculator; + calculator.CompressedMember.Buckling = false; + calculator.Run(); + var ndmPrimitives = newSection.SectionRepository.Primitives; + var result = calculator.Result as IForcesResults; + var strainMatrix = result.ForcesResultList[0].LoaderResults.StrainMatrix; + var source = StrainTupleService.ConvertToStrainTuple(strainMatrix); + //Act + foreach (var item in ndmPrimitives) + { + StrainTupleService.CopyProperties(source, item.AutoPrestrain); + } + calculator.Run(); + var result2 = calculator.Result as IForcesResults; + //Assert + Assert.IsNotNull(result2); + Assert.IsTrue(result2.IsValid); + var strainMatrix2 = result2.ForcesResultList[0].LoaderResults.StrainMatrix; + var kx = strainMatrix2.Kx; + var ky = strainMatrix2.Ky; + var epsz = strainMatrix2.EpsZ; + Assert.AreEqual(expectedKx, kx, 1e-10); + Assert.AreEqual(expectedKy, ky, 1e-10); + Assert.AreEqual(expectedEpsZ, epsz, 1e-10); + } } } diff --git a/StructureHelperTests/StructureHelperTests.csproj b/StructureHelperTests/StructureHelperTests.csproj index 25dd01e..2d73b0f 100644 --- a/StructureHelperTests/StructureHelperTests.csproj +++ b/StructureHelperTests/StructureHelperTests.csproj @@ -29,4 +29,8 @@ + + + + \ No newline at end of file diff --git a/StructureHelperTests/UnitTests/MaterialTests/MaterialStrengthTest.cs b/StructureHelperTests/UnitTests/MaterialTests/MaterialStrengthTest.cs new file mode 100644 index 0000000..7414124 --- /dev/null +++ b/StructureHelperTests/UnitTests/MaterialTests/MaterialStrengthTest.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using NUnit.Framework; +using StructureHelperCommon.Infrastructures.Enums; +using StructureHelperLogics.Models.Materials; + +namespace StructureHelperTests.UnitTests.MaterialTests +{ + public class MaterialStrengthTest + { + [TestCase(HeadmaterialType.Reinforecement400, CodeTypes.SP63_13330_2018, LimitStates.ULS, CalcTerms.ShortTerm, 347826086.95652175d, 347826086.95652175d)] + [TestCase(HeadmaterialType.Reinforecement400, CodeTypes.SP63_13330_2018, LimitStates.SLS, CalcTerms.ShortTerm, 400000000d, 400000000d)] + [TestCase(HeadmaterialType.Reinforecement500, CodeTypes.SP63_13330_2018, LimitStates.ULS, CalcTerms.ShortTerm, 400000000.0d, 434782608.69565225d)] + [TestCase(HeadmaterialType.Reinforecement500, CodeTypes.SP63_13330_2018, LimitStates.ULS, CalcTerms.LongTerm, 434782608.69565225d, 434782608.69565225d)] + [TestCase(HeadmaterialType.Reinforecement500, CodeTypes.SP63_13330_2018, LimitStates.SLS, CalcTerms.ShortTerm, 5e8d, 5e8d)] + [TestCase(HeadmaterialType.Reinforecement500, CodeTypes.SP63_13330_2018, LimitStates.SLS, CalcTerms.ShortTerm, 5e8d, 5e8d)] + [TestCase(HeadmaterialType.Concrete40, CodeTypes.SP63_13330_2018, LimitStates.ULS, CalcTerms.ShortTerm, 22461538.46153846d, 1395297.0017909051d)] + [TestCase(HeadmaterialType.Concrete40, CodeTypes.SP63_13330_2018, LimitStates.ULS, CalcTerms.LongTerm, 20215384.615384616d, 1255767.3016118146d)] + [TestCase(HeadmaterialType.Concrete40, CodeTypes.SP63_13330_2018, LimitStates.SLS, CalcTerms.ShortTerm, 29200000.0d, 2092945.5026863578d)] + [TestCase(HeadmaterialType.Concrete40, CodeTypes.SP63_13330_2018, LimitStates.SLS, CalcTerms.LongTerm, 29200000.0d, 2092945.5026863578d)] + public void Run_ShouldPass(HeadmaterialType headmaterialType, CodeTypes code, LimitStates limitState, CalcTerms calcTerm, double expectedCompressive, double expectedTensile) + { + //Arrange + var material = HeadMaterialFactory.GetHeadMaterial(headmaterialType, code); + var libMaterial = material.HelperMaterial as ILibMaterial; + //Act + var compressive = libMaterial.GetStrength(limitState, calcTerm).Compressive; + var tensile = libMaterial.GetStrength(limitState, calcTerm).Tensile; + //Assert + Assert.AreEqual(expectedCompressive, compressive, 1d); + Assert.AreEqual(expectedTensile, tensile, 1d); + } + } +}