Crack Calculator was added

This commit is contained in:
Evgeny Redikultsev
2023-07-16 17:21:28 +05:00
parent 3e0e51d0c9
commit d7a4b1f0a7
108 changed files with 1523 additions and 565 deletions

View File

@@ -0,0 +1,41 @@
using LoaderCalculator.Tests.Infrastructures.Logics;
using Moq;
using NUnit.Framework;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Services.Forces;
using StructureHelperLogics.Models.Calculations.CalculationProperties;
using StructureHelperLogics.Models.Templates.CrossSections.RCs;
using StructureHelperLogics.Models.Templates.RCs;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Cracking;
using StructureHelperLogics.NdmCalculations.Primitives;
using StructureHelperLogics.NdmCalculations.Triangulations;
namespace StructureHelperTests.FunctionalTests.Ndms.Calculators.CrackCalculatorTests
{
internal class CrackCalculatorTest
{
[TestCase(0.4d, 0.6d, 0.012d, 0.025d, 2, 2, 0.81d)]
public void Run_ShouldPass(double width, double height, double topDiametr, double bottomDiametr, int widthCount, int heightCount, double expectedFactor)
{
//Arrange
var template = new RectangleBeamTemplate(width, height) { TopDiameter = topDiametr, BottomDiameter = bottomDiametr, WidthCount = widthCount, HeightCount = heightCount };
var newSection = new SectionTemplate(new RectGeometryLogic(template)).GetCrossSection();
var ndmPrimitives = newSection.SectionRepository.Primitives;
ITriangulationOptions options = new TriangulationOptions { LimiteState = LimitStates.SLS, CalcTerm = CalcTerms.ShortTerm };
var ndms = Triangulation.GetNdms(ndmPrimitives, options);
var calculator = new CrackForceCalculator();
calculator.EndTuple = new ForceTuple() { Mx = -50e3d, My = -50e3d, Nz = 0d };
calculator.NdmCollection = ndms;
//Act
calculator.Run();
var result = (CrackForceResult)calculator.Result;
//Assert
Assert.NotNull(result);
Assert.IsTrue(result.IsValid);
Assert.AreEqual(expectedFactor, result.ActualFactor, 0.01d);
}
}
}

View File

@@ -65,7 +65,7 @@ namespace StructureHelperTests.FunctionalTests.Ndms.RCSections
{
var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Concrete40);
var primitive = new RectanglePrimitive(material) {CenterX = 0, CenterY = 0, Width = width, Height = height, NdmMaxSize = 1, NdmMinDivision = 20 };
var primitive = new RectanglePrimitive(material) {Width = width, Height = height, NdmMaxSize = 1, NdmMinDivision = 20 };
List<INdmPrimitive> primitives = new List<INdmPrimitive> {primitive};
return primitives;
}
@@ -81,16 +81,24 @@ namespace StructureHelperTests.FunctionalTests.Ndms.RCSections
List<INdmPrimitive> primitives = new List<INdmPrimitive>();
INdmPrimitive primitive;
//Right top bar
primitive = new PointPrimitive(material) { Area = topArea, CenterX = centerRT.X, CenterY = centerRT.Y };
primitive = new PointPrimitive(material) { Area = topArea};
primitive.Center.X = centerRT.X;
primitive.Center.Y = centerRT.Y;
primitives.Add(primitive);
//Left top bar
primitive = new PointPrimitive(material) { Area = topArea, CenterX = centerLT.X, CenterY = centerLT.Y };
primitive = new PointPrimitive(material) { Area = topArea};
primitive.Center.X = centerLT.X;
primitive.Center.Y = centerLT.Y;
primitives.Add(primitive);
//Right bottom bar
primitive = new PointPrimitive(material) { Area = bottomArea, CenterX = centerRB.X, CenterY = centerRB.Y };
primitive = new PointPrimitive(material) { Area = bottomArea};
primitive.Center.X = centerRB.X;
primitive.Center.Y = centerRB.Y;
primitives.Add(primitive);
//Left bottom bar
primitive = new PointPrimitive(material) { Area = bottomArea, CenterX = centerLB.X, CenterY = centerLB.Y };
primitive = new PointPrimitive(material) {Area = bottomArea };
primitive.Center.X = centerLB.X;
primitive.Center.Y = centerLB.Y;
primitives.Add(primitive);
return primitives;
}

View File

@@ -27,7 +27,7 @@ namespace StructureHelperTests.FunctionalTests.Ndms.SteelSections
ProgramSetting.NatSystem = NatSystems.EU;
var headMaterial = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Reinforcement400);
var options = new TriangulationOptions { LimiteState = LimitStates.ULS, CalcTerm = CalcTerms.ShortTerm };
var primitive = new RectanglePrimitive { CenterX = 0, CenterY = 0, Width = width, Height = height, HeadMaterial = headMaterial, NdmMaxSize = 1, NdmMinDivision = 100 };
var primitive = new RectanglePrimitive { Width = width, Height = height, HeadMaterial = headMaterial, NdmMaxSize = 1, NdmMinDivision = 100 };
var primitives = new List<INdmPrimitive>() { primitive};
var ndmCollection = Triangulation.GetNdms(primitives, options);
var loaderData = new LoaderOptions
@@ -62,7 +62,7 @@ namespace StructureHelperTests.FunctionalTests.Ndms.SteelSections
ProgramSetting.NatSystem = NatSystems.EU;
var headMaterial = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Reinforcement400);
var options = new TriangulationOptions { LimiteState = LimitStates.ULS, CalcTerm = CalcTerms.ShortTerm };
var primitive = new CirclePrimitive { CenterX = 0, CenterY = 0, Diameter = diameter, HeadMaterial = headMaterial, NdmMaxSize = 1, NdmMinDivision = 100 };
var primitive = new CirclePrimitive { Diameter = diameter, HeadMaterial = headMaterial, NdmMaxSize = 1, NdmMinDivision = 100 };
var primitives = new List<INdmPrimitive>() { primitive };
var ndmCollection = Triangulation.GetNdms(primitives, options);
var loaderData = new LoaderOptions

View File

@@ -0,0 +1,49 @@
using NUnit.Framework;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Calculators;
using StructureHelperLogics.Models.Materials;
namespace StructureHelperTests.UnitTests.Calcuators
{
internal class FindParameterTest
{
[TestCase(0d, 1d, 0.5d, 0.5d)]
[TestCase(0d, 10d, 5d, 5d)]
public void Run_ShouldPass_Valid(double startValue, double EndValue, double predicateValue, double expectedValue)
{
//Arrange
var calculator = new FindParameterCalculator()
{
StartValue = startValue,
EndValue = EndValue,
Predicate = x => x > predicateValue
};
//Act
calculator.Run();
var result = calculator.Result as FindParameterResult;
//Assert
Assert.NotNull(result);
Assert.IsTrue(result.IsValid);
Assert.AreEqual(predicateValue, expectedValue, 0.001d);
}
[TestCase(0d, 1d, 5d, 5d, false)]
[TestCase(0d, 10d, 15d, 15d, false)]
public void Run_ShouldPass_NotValid(double startValue, double EndValue, double predicateValue, double expectedValue, bool isValid)
{
//Arrange
var calculator = new FindParameterCalculator()
{
StartValue = startValue,
EndValue = EndValue,
Predicate = x => x > predicateValue
};
//Act
calculator.Run();
var result = calculator.Result as FindParameterResult;
//Assert
Assert.NotNull(result);
Assert.IsTrue(result.IsValid == isValid);
}
}
}

View File

@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
using NUnit.Framework;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperLogics.Models.Materials;

View File

@@ -49,10 +49,12 @@ namespace StructureHelperTests.UnitTests.Ndms.Triangulations
//Arrange
ProgramSetting.NatSystem = NatSystems.RU;
var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Concrete40);
var mainBlock = new RectanglePrimitive() { CenterX = centerX, CenterY = centerY, Width = width, Height = height, HeadMaterial = material };
var mainBlock = new RectanglePrimitive() { Width = width, Height = height, HeadMaterial = material };
mainBlock.Center.X = centerX;
mainBlock.Center.Y = centerY;
mainBlock.VisualProperty.ZIndex = 0;
var opening = new RectanglePrimitive()
{ CenterX = 0d, CenterY = 0d, Width = 0.3d, Height = 0.2d,
{ Width = 0.3d, Height = 0.2d,
HeadMaterial = material, Triangulate = triangOpening,
ClearUnderlying = true};
opening.VisualProperty.ZIndex = 1;
@@ -75,12 +77,12 @@ namespace StructureHelperTests.UnitTests.Ndms.Triangulations
//Arrange
ProgramSetting.NatSystem = NatSystems.RU;
var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Concrete40);
var mainBlock = new RectanglePrimitive() { CenterX = centerX, CenterY = centerY, Width = width, Height = height, HeadMaterial = material };
var mainBlock = new RectanglePrimitive() {Width = width, Height = height, HeadMaterial = material };
mainBlock.Center.X = centerX;
mainBlock.Center.Y = centerY;
mainBlock.VisualProperty.ZIndex = 0;
var opening = new CirclePrimitive()
{
CenterX = 0d,
CenterY = 0d,
Diameter = 0.3d,
HeadMaterial = material,
Triangulate = triangOpening,
@@ -106,12 +108,12 @@ namespace StructureHelperTests.UnitTests.Ndms.Triangulations
//Arrange
ProgramSetting.NatSystem = NatSystems.RU;
var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Concrete40);
var mainBlock = new CirclePrimitive() { CenterX = centerX, CenterY = centerY, Diameter = diameter, HeadMaterial = material };
var mainBlock = new CirclePrimitive() { Diameter = diameter, HeadMaterial = material };
mainBlock.Center.X = centerX;
mainBlock.Center.Y = centerY;
mainBlock.VisualProperty.ZIndex = 0;
var opening = new RectanglePrimitive()
{
CenterX = 0d,
CenterY = 0d,
Width = 0.3d,
Height = 0.2d,
HeadMaterial = material,

View File

@@ -66,7 +66,7 @@ namespace StructureHelperTests.ViewModelTests
//Arrange
ProgramSetting.NatSystem = NatSystems.RU;
var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Concrete40);
var primitive = new ReinforcementPrimitive() { HeadMaterial = material };
var primitive = new RebarPrimitive() { HeadMaterial = material };
var primitiveBase = new ReinforcementViewPrimitive(primitive);
//Act
var vm = new PrimitivePropertiesViewModel(primitiveBase, new CrossSectionRepository());