Add BeamShearCalculator

This commit is contained in:
Evgeny Redikultsev
2025-02-16 17:24:16 +05:00
parent f60d031f91
commit e4a23f5139
39 changed files with 1023 additions and 24 deletions

View File

@@ -0,0 +1,58 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperLogics.NdmCalculations.Cracking;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.BeamShears
{
public class CheckBeamShearCalculatorInputDataLogic : ICheckInputDataLogic<IBeamShearCalculatorInputData>
{
private bool result;
private string checkResult;
public string CheckResult => checkResult;
public IBeamShearCalculatorInputData InputData { get; set; }
public IShiftTraceLogger? TraceLogger { get; set; }
public CheckBeamShearCalculatorInputDataLogic(IBeamShearCalculatorInputData inputData, IShiftTraceLogger? traceLogger)
{
InputData = inputData;
TraceLogger = traceLogger;
}
public bool Check()
{
result = true;
checkResult = string.Empty;
if (InputData is null)
{
result = false;
string errorString = ErrorStrings.ParameterIsNull + ": Input data";
throw new StructureHelperException(errorString);
}
if (InputData.BeamShearActions is null || ! InputData.BeamShearActions.Any())
{
result = false;
string errorString = "Collection of actions does not contain any action";
TraceMessage(errorString);
}
if (InputData.ShearSections is null || ! InputData.ShearSections.Any())
{
result = false;
string errorString = "Collection of sections does not contain any section";
TraceMessage(errorString);
}
return result;
}
private void TraceMessage(string errorString)
{
checkResult += errorString;
TraceLogger?.AddMessage(errorString);
}
}
}

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.BeamShears
{
public class GetInclinedSectionListInputData : IGetInclinedSectionListInputData
{
public int StepCount { get; set; } = 50;
public double MaxInclinedSectionLegthFactor { get; set; } = 3d;
public IGetInclinedSectionLogic? GetInclinedSectionLogic { get; set; }
public IBeamShearSection BeamShearSection { get; set; }
public GetInclinedSectionListInputData(IBeamShearSection beamShearSection)
{
BeamShearSection = beamShearSection;
}
}
}

View File

@@ -0,0 +1,87 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Shapes;
using StructureHelperCommon.Services;
namespace StructureHelperLogics.Models.BeamShears
{
public class GetInclinedSectionListLogic : IGetInclinedSectionListLogic
{
private readonly GetInclinedSectionListInputData inputData;
private IGetInclinedSectionLogic inclinedSectionLogic;
private double depth;
private double effectiveDepth;
private List<IInclinedSection> inclinedSections;
private List<double> coordinates;
public IShiftTraceLogger? TraceLogger { get; set; }
public GetInclinedSectionListLogic(
GetInclinedSectionListInputData inputData,
IShiftTraceLogger? traceLogger)
{
this.inputData = inputData;
TraceLogger = traceLogger;
}
public List<IInclinedSection> GetInclinedSections()
{
Check();
GetShapeParameters();
GetCoordinates();
foreach (var startCoord in coordinates)
{
var endCoordinates = coordinates.Where(x => x >= startCoord);
foreach (var endCoord in endCoordinates)
{
inclinedSectionLogic = InitializeInclinedSectionLogic(startCoord, endCoord);
IInclinedSection inclinedSection = inclinedSectionLogic.GetInclinedSection();
inclinedSections.Add(inclinedSection);
}
}
return inclinedSections;
}
private void GetCoordinates()
{
double maxSectionLength = inputData.MaxInclinedSectionLegthFactor * effectiveDepth;
double step = maxSectionLength / inputData.StepCount;
inclinedSections = new();
coordinates = new();
for (int i = 0; i < inputData.StepCount + 1; i++)
{
double endCoord = step * i;
coordinates.Add(endCoord);
}
}
private void Check()
{
CheckObject.IsNull(inputData);
CheckObject.IsNull(inputData.BeamShearSection);
}
private IGetInclinedSectionLogic InitializeInclinedSectionLogic(double startCoord, double endCoord)
{
if (inputData.GetInclinedSectionLogic is not null)
{
return inputData.GetInclinedSectionLogic;
}
return new GetInclinedSectionLogic(inputData.BeamShearSection, startCoord, endCoord, TraceLogger);
}
private void GetShapeParameters()
{
if (inputData.BeamShearSection.Shape is IRectangleShape rectangle)
{
depth = rectangle.Height;
}
else if (inputData.BeamShearSection.Shape is ICircleShape circle)
{
depth = circle.Diameter;
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(inputData.BeamShearSection.Shape));
}
effectiveDepth = depth - inputData.BeamShearSection.CenterCover;
}
}
}

View File

@@ -1,11 +1,6 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Shapes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.BeamShears
{
@@ -17,6 +12,8 @@ namespace StructureHelperLogics.Models.BeamShears
private double width;
private double depth;
private double effectiveDepth;
private InclinedSection? inclinedSection;
public IShiftTraceLogger? TraceLogger { get; set; }
public GetInclinedSectionLogic(
IBeamShearSection beamShearSection,
@@ -31,14 +28,26 @@ namespace StructureHelperLogics.Models.BeamShears
Check();
}
public GetInclinedSectionLogic(IShiftTraceLogger? traceLogger)
public IInclinedSection GetInclinedSection()
{
TraceLogger = traceLogger;
GetShapeParameters();
GetSection();
return inclinedSection;
}
public IShiftTraceLogger? TraceLogger { get; set; }
public IInclinedSection GetInclinedSection()
private void GetSection()
{
effectiveDepth = depth - beamShearSection.CenterCover;
inclinedSection = new()
{
FullDepth = depth,
EffectiveDepth = effectiveDepth,
StartCoord = startCoord,
EndCoord = endCoord,
WebWidth = width
};
}
private void GetShapeParameters()
{
if (beamShearSection.Shape is IRectangleShape rectangle)
{
@@ -54,17 +63,7 @@ namespace StructureHelperLogics.Models.BeamShears
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(beamShearSection.Shape));
}
effectiveDepth = depth - beamShearSection.CenterCover;
InclinedSection inclinedSection = new()
{
EffectiveDepth = effectiveDepth,
StartCoord = startCoord,
EndCoord = endCoord,
WebWidth = width
};
return inclinedSection;
}
private void Check()
{
if (beamShearSection is null)

View File

@@ -0,0 +1,106 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.BeamShears
{
public class GetSumForceByShearActionLogic : IGetSumForceByShearActionLogic
{
public IShiftTraceLogger? TraceLogger { get; set; }
public GetSumForceByShearActionLogic(IShiftTraceLogger? traceLogger)
{
TraceLogger = traceLogger;
}
public double GetSumShearForce(IBeamShearLoad beamShearAction, double startCoord, double endCoord)
{
if (beamShearAction is IUniformlyDistributedLoad distributedLoad)
{
return GetDistributedLoadSum(distributedLoad, startCoord, endCoord);
}
else if (beamShearAction is IConcenratedForce concenratedForce)
{
return GetConcentratedForceSum(concenratedForce, startCoord, endCoord);
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(beamShearAction));
}
}
private double GetConcentratedForceSum(IConcenratedForce concentratedForce, double startCoord, double endCoord)
{
TraceLogger?.AddMessage($"Concentrated force Name = {concentratedForce.Name}, Value = {concentratedForce.ForceValue}(N/m) ");
if (concentratedForce.ForceCoordinate > endCoord)
{
TraceLogger?.AddMessage($"Force coordinate {concentratedForce.ForceCoordinate}(m) is bigger than section end {endCoord}(m), so total load is zero");
return 0;
}
double totalLoad;
double limitCoordinate = startCoord;
if (concentratedForce.ForceCoordinate >= startCoord)
{
limitCoordinate = GetCoordinateByLevel(startCoord, endCoord, concentratedForce.RelativeLoadLevel);
}
if (concentratedForce.ForceCoordinate < limitCoordinate)
{
totalLoad = concentratedForce.ForceValue * concentratedForce.LoadRatio;
TraceLogger?.AddMessage($"Total load Q,tot = {concentratedForce.ForceValue}(N) * {concentratedForce.LoadRatio} = {totalLoad}(N)");
}
else
{
TraceLogger?.AddMessage($"Force coordinate {concentratedForce.ForceCoordinate}(m) is bigger than limit coordinate {limitCoordinate}(m), so total load is zero");
totalLoad = 0d;
}
return totalLoad;
}
private double GetDistributedLoadSum(IUniformlyDistributedLoad distributedLoad, double startCoord, double endCoord)
{
TraceLogger?.AddMessage($"Uniformly distributed load Name = {distributedLoad.Name}, Value = {distributedLoad.LoadValue}(N/m) ");
double loadStartCoord = Math.Max(distributedLoad.StartCoordinate, 0d);
if (loadStartCoord > endCoord)
{
TraceLogger?.AddMessage($"Load start coordinate {loadStartCoord}(m) is bigger than section end {endCoord}(m), so total load is zero");
return 0d;
}
double endCoordByLevel = GetCoordinateByLevel(startCoord, endCoord, distributedLoad.RelativeLoadLevel);
double loadEndCoord = Math.Min(distributedLoad.EndCoordinate, endCoordByLevel);
double loadLength = loadEndCoord - loadStartCoord;
TraceLogger?.AddMessage($"Total length L,tot = {loadEndCoord}(m) - {loadStartCoord}(m) = {loadLength}(m)");
double totalLoad = distributedLoad.LoadValue * distributedLoad.LoadRatio * loadLength;
TraceLogger?.AddMessage($"Total load Q,tot = {distributedLoad.LoadValue}(N/m) * {distributedLoad.LoadRatio} * {loadLength}(m) = {totalLoad}(N)");
return totalLoad;
}
private double GetCoordinateByLevel(double startCoord, double endCoord, double relativeLevel)
{
CheckRelativeLevel(relativeLevel);
double delta = endCoord - startCoord;
double coordinate = startCoord + delta * (relativeLevel + 0.5d);
return coordinate;
}
private void CheckRelativeLevel(double relativeLevel)
{
if (relativeLevel > 0.5d)
{
string errorString = ErrorStrings.IncorrectValue + ": relative level must not be greater than 0.5";
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
throw new StructureHelperException(errorString);
}
if (relativeLevel < -0.5d)
{
string errorString = ErrorStrings.IncorrectValue + ": relative level must not be less than -0.5";
TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error);
throw new StructureHelperException(errorString);
}
}
}
}

View File

@@ -7,8 +7,15 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.Models.BeamShears
{
/// <summary>
/// Implement logic for obtaining of inclined section
/// </summary>
public interface IGetInclinedSectionLogic : ILogic
{
/// <summary>
/// Returns inclined section
/// </summary>
/// <returns>Inclined section</returns>
IInclinedSection GetInclinedSection();
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.BeamShears
{
public interface IGetInclinedSectionListInputData
{
int StepCount { get; set; }
double MaxInclinedSectionLegthFactor { get; set; }
IGetInclinedSectionLogic? GetInclinedSectionLogic { get; set; }
IBeamShearSection BeamShearSection { get; set; }
}
}

View File

@@ -0,0 +1,12 @@
using StructureHelperCommon.Infrastructures.Interfaces;
namespace StructureHelperLogics.Models.BeamShears
{
/// <summary>
/// Returns collection of inclined section for beam shear calculating
/// </summary>
public interface IGetInclinedSectionListLogic : ILogic
{
List<IInclinedSection> GetInclinedSections();
}
}

View File

@@ -0,0 +1,25 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Forces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.BeamShears
{
/// <summary>
/// Implement logic for obtaining of summary force of action from start to end
/// </summary>
public interface IGetSumForceByShearActionLogic : ILogic
{
/// <summary>
/// Returns summary force of action from start to end
/// </summary>
/// <param name="beamShearAction">Source action</param>
/// <param name="startCoord">Coordinate of start point, m</param>
/// <param name="endCoord">Coordinate of end point, m</param>
/// <returns>Summary force, N</returns>
double GetSumShearForce(IBeamShearLoad beamShearAction, double startCoord, double endCoord);
}
}