Force calculator was repaired for buckling calculations

This commit is contained in:
Evgeny Redikultsev
2024-03-08 17:16:00 +05:00
parent 4359b2c49b
commit 0a453c5a95
18 changed files with 382 additions and 146 deletions

View File

@@ -1,5 +1,6 @@
using LoaderCalculator.Data.Ndms;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
@@ -17,6 +18,8 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
static readonly ForceCalculatorUpdateStrategy updateStrategy = new();
private readonly IForceTupleCalculator forceTupleCalculator;
private ForcesResults result;
public string Name { get; set; }
public List<LimitStates> LimitStatesList { get; private set; }
public List<CalcTerms> CalcTermsList { get; private set; }
@@ -50,7 +53,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
private void CalculateResult()
{
var ndmResult = new ForcesResults() { IsValid = true };
result = new ForcesResults()
{
IsValid = true
};
foreach (var combination in ForceCombinationLists)
{
foreach (var tuple in combination.DesignForces)
@@ -59,15 +65,34 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
var calcTerm = tuple.CalcTerm;
if (LimitStatesList.Contains(limitState) & CalcTermsList.Contains(calcTerm))
{
ProcessNdmResult(ndmResult, combination, tuple, limitState, calcTerm);
IForcesTupleResult tupleResult;
try
{
tupleResult = ProcessNdmResult(combination, tuple);
}
catch(Exception ex)
{
tupleResult = new ForcesTupleResult()
{
IsValid = false,
Description = string.Empty + ex,
DesignForceTuple = tuple
};
}
result.ForcesResultList.Add(tupleResult);
ActionToOutputResults?.Invoke(result);
}
}
}
Result = ndmResult;
Result = result;
}
private void ProcessNdmResult(ForcesResults ndmResult, IForceCombinationList combination, IDesignForceTuple tuple, LimitStates limitState, CalcTerms calcTerm)
private IForcesTupleResult ProcessNdmResult(IForceCombinationList combination, IDesignForceTuple tuple)
{
IForcesTupleResult tupleResult;
LimitStates limitState = tuple.LimitState;
CalcTerms calcTerm = tuple.CalcTerm;
var ndms = NdmPrimitivesService.GetNdms(Primitives, limitState, calcTerm);
IPoint2D point2D;
if (combination.SetInGravityCenter == true)
@@ -89,9 +114,22 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
TraceLogger?.AddMessage("Get eccentricity for full load");
newTuple = ProcessAccEccentricity(ndms, newTuple);
newTuple = GetForceTupleByBuckling(ndmResult, combination, limitState, calcTerm, ndms, newTuple);
var buckResult = GetForceTupleByBuckling(combination, limitState, calcTerm, ndms, newTuple);
if (buckResult.isValid == true)
{
newTuple = buckResult.tuple;
}
else
{
return new ForcesTupleResult()
{
IsValid = false,
DesignForceTuple = tuple,
Description = buckResult.description,
};
}
}
GetForceResult(ndmResult, limitState, calcTerm, ndms, newTuple);
tupleResult = GetForceResult(limitState, calcTerm, ndms, newTuple);
}
else
{
@@ -100,12 +138,14 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
string message = string.Format("Second order effect is not considered, despite force Nz={0}", newTuple.Nz);
TraceLogger?.AddMessage(message, TraceLogStatuses.Warning);
}
GetForceResult(ndmResult, limitState, calcTerm, ndms, newTuple);
tupleResult = GetForceResult(limitState, calcTerm, ndms, newTuple);
}
return tupleResult;
}
private IForceTuple GetForceTupleByBuckling(ForcesResults ndmResult, IForceCombinationList combination, LimitStates limitState, CalcTerms calcTerm, List<INdm> ndms, IForceTuple newTuple)
private (bool isValid, IForceTuple tuple, string description) GetForceTupleByBuckling(IForceCombinationList combination, LimitStates limitState, CalcTerms calcTerm, List<INdm> ndms, IForceTuple newTuple)
{
var tuple = newTuple.Clone() as IForceTuple;
var inputData = new BucklingInputData()
{
Combination = combination,
@@ -119,41 +159,31 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
if (bucklingResult.IsValid != true)
{
TraceLogger?.AddMessage(bucklingResult.Description, TraceLogStatuses.Error);
var result = new ForcesTupleResult
{
IsValid = false,
Description = $"Buckling result:\n{bucklingResult.Description}\n",
DesignForceTuple = new DesignForceTuple()
{
ForceTuple = newTuple,
LimitState = limitState,
CalcTerm = calcTerm
}
};
ndmResult.ForcesResultList.Add(result);
return (false, tuple, $"Buckling result:\n{bucklingResult.Description}");
}
else
{
newTuple = CalculateBuckling(newTuple, bucklingResult);
TraceLogger?.AddMessage($"Force combination with considering of second order effects");
TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(newTuple));
tuple = CalculateBuckling(tuple, bucklingResult);
TraceLogger?.AddMessage(string.Intern("Force combination with considering of second order effects"));
TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(tuple));
}
return newTuple;
return (true, tuple, string.Empty);
}
private void GetForceResult(ForcesResults ndmResult, LimitStates limitState, CalcTerms calcTerm, List<INdm> ndms, IForceTuple newTuple)
private IForcesTupleResult GetForceResult(LimitStates limitState, CalcTerms calcTerm, List<INdm> ndms, IForceTuple newTuple)
{
var result = GetPrimitiveStrainMatrix(ndms, newTuple, Accuracy);
result.DesignForceTuple.LimitState = limitState;
result.DesignForceTuple.CalcTerm = calcTerm;
result.DesignForceTuple.ForceTuple = newTuple;
ndmResult.ForcesResultList.Add(result);
ActionToOutputResults?.Invoke(ndmResult);
var tupleResult = GetPrimitiveStrainMatrix(ndms, newTuple, Accuracy);
tupleResult.DesignForceTuple.LimitState = limitState;
tupleResult.DesignForceTuple.CalcTerm = calcTerm;
tupleResult.DesignForceTuple.ForceTuple = newTuple;
return tupleResult;
}
private IForceTuple ProcessAccEccentricity(List<INdm> ndms, IForceTuple newTuple)
private IForceTuple ProcessAccEccentricity(List<INdm> ndms, IForceTuple tuple)
{
var newTuple = tuple.Clone() as IForceTuple;
var accLogic = new AccidentalEccentricityLogic()
{
Length = CompressedMember.GeometryLength,
@@ -161,7 +191,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
SizeY = ndms.Max(x => x.CenterY) - ndms.Min(x => x.CenterY),
InitialForceTuple = newTuple,
};
if (TraceLogger is not null) { accLogic.TraceLogger = TraceLogger.GetSimilarTraceLogger(50); }
if (TraceLogger is not null)
{
accLogic.TraceLogger = TraceLogger.GetSimilarTraceLogger(50);
}
newTuple = accLogic.GetForceTuple();
return newTuple;
}
@@ -196,7 +229,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
IForceTuple longTuple;
try
{
longTuple = designForces.Where(x => x.LimitState == limitState & x.CalcTerm == CalcTerms.LongTerm).First().ForceTuple;
longTuple = designForces
.Where(x => x.LimitState == limitState & x.CalcTerm == CalcTerms.LongTerm)
.Single()
.ForceTuple;
}
catch (Exception)
{

View File

@@ -9,6 +9,7 @@ using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.Services;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
@@ -33,18 +34,16 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
private IForcesTupleResult CalculateResult()
{
TraceLogger?.AddMessage($"Calculator type: {GetType()}", TraceLogStatuses.Service);
TraceLogger?.AddMessage($"Calculator logic based on calculating strain in plain section by elementary parts of finished size");
TraceLogger?.AddMessage(string.Intern($"Calculator type: {GetType()}"), TraceLogStatuses.Service);
TraceLogger?.AddMessage(string.Intern("Calculator logic based on calculating strain in plain section by elementary parts of finished size"));
var ndmCollection = InputData.NdmCollection;
TraceLogger?.AddMessage($"Collection of elementary parts contains {ndmCollection.Count()} parts");
TraceLogger?.AddMessage($"Summary area of elementary part collection = {ndmCollection.Sum(x => x.Area * x.StressScale)}", TraceLogStatuses.Service);
TraceLogger?.AddMessage($"Minimum x = {ndmCollection.Min(x => x.CenterX)}", TraceLogStatuses.Debug);
TraceLogger?.AddMessage($"Maximum x = {ndmCollection.Max(x => x.CenterX)}", TraceLogStatuses.Debug);
TraceLogger?.AddMessage($"Minimum y = {ndmCollection.Min(x => x.CenterY)}", TraceLogStatuses.Debug);
TraceLogger?.AddMessage($"Maximum y = {ndmCollection.Max(x => x.CenterY)}", TraceLogStatuses.Debug);
if (TraceLogger is not null)
{
TraceService.TraceNdmCollection(TraceLogger, ndmCollection);
}
var tuple = InputData.Tuple;
var accuracy = InputData.Accuracy;
TraceLogger?.AddMessage($"Input force combination");
TraceLogger?.AddMessage(string.Intern("Input force combination"));
TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(tuple));
var mx = tuple.Mx;
var my = tuple.My;
@@ -65,9 +64,9 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
NdmCollection = ndmCollection
};
var calculator = new Calculator();
TraceLogger?.AddMessage($"Calculation is started", TraceLogStatuses.Debug);
TraceLogger?.AddMessage(string.Intern("Calculation is started"), TraceLogStatuses.Debug);
calculator.Run(loaderData, new CancellationToken());
TraceLogger?.AddMessage($"Calculation result is obtained", TraceLogStatuses.Debug);
TraceLogger?.AddMessage(string.Intern("Calculation result is obtained"), TraceLogStatuses.Debug);
var calcResult = calculator.Result;
if (calcResult.AccuracyRate <= accuracy.IterationAccuracy)
{
@@ -77,18 +76,18 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
Description = LoggerStrings.CalculationHasDone,
LoaderResults = calcResult
};
forceTupleTraceResultLogic = new ForceTupleTraceResultLogic(ndmCollection) { TraceLogger = TraceLogger};
forceTupleTraceResultLogic = new ForceTupleTraceResultLogic(ndmCollection) { TraceLogger = TraceLogger };
forceTupleTraceResultLogic.TraceResult(result);
return result;
}
else
{
TraceLogger?.AddMessage($"Required accuracy rate has not achieved", TraceLogStatuses.Error);
TraceLogger?.AddMessage(string.Intern("Required accuracy rate has not achieved"), TraceLogStatuses.Error);
TraceLogger?.AddMessage($"Current accuracy {calcResult.AccuracyRate}, {calcResult.IterationCounter} iteration has done", TraceLogStatuses.Warning);
return new ForcesTupleResult()
{
IsValid = false,
Description = "Required accuracy rate has not achieved",
Description = string.Intern("Required accuracy rate has not achieved"),
LoaderResults = calcResult
};
}
@@ -103,8 +102,8 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
};
if (ex.Message == "Calculation result is not valid: stiffness matrix is equal to zero")
{
TraceLogger?.AddMessage($"Stiffness matrix is equal to zero\nProbably section was collapsed", TraceLogStatuses.Error);
result.Description = "Stiffness matrix is equal to zero\nProbably section was collapsed";
TraceLogger?.AddMessage(string.Intern("Stiffness matrix is equal to zero\nProbably section was collapsed"), TraceLogStatuses.Error);
result.Description = string.Intern("Stiffness matrix is equal to zero\nProbably section was collapsed");
}
else
{

View File

@@ -1,4 +1,5 @@
using LoaderCalculator.Data.Ndms;
using LoaderCalculator.Data.Materials;
using LoaderCalculator.Data.Ndms;
using LoaderCalculator.Logics;
using LoaderCalculator.Logics.Geometry;
using StructureHelperCommon.Models;
@@ -9,6 +10,7 @@ using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.Models.Materials;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Primitives;
using StructureHelperLogics.Services;
using StructureHelperLogics.Services.NdmPrimitives;
namespace StructureHelperLogics.NdmCalculations.Buckling
@@ -28,7 +30,7 @@ namespace StructureHelperLogics.NdmCalculations.Buckling
public IResult Result { get; private set; }
public IAccuracy Accuracy { get; set; }
public Action<IResult> ActionToOutputResults { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public Action<IResult> ActionToOutputResults { get; set; }
public IShiftTraceLogger? TraceLogger { get; set; }
private (double EtaAlongX, double EtaAlongY) GetBucklingCoefficients()
@@ -50,11 +52,9 @@ namespace StructureHelperLogics.NdmCalculations.Buckling
Accuracy = accuracy;
var allPrimitives = options.Primitives;
var concretePrimitives = GetConcretePrimitives();
var otherPrimitives = allPrimitives.Except(concretePrimitives);
ndmCollection = NdmPrimitivesService.GetNdms(allPrimitives, options.LimitState, options.CalcTerm);
concreteNdms = NdmPrimitivesService.GetNdms(concretePrimitives, options.LimitState, options.CalcTerm);
otherNdms = NdmPrimitivesService.GetNdms(otherPrimitives, options.LimitState, options.CalcTerm);
concreteNdms = ndmCollection.Where(x => x.Material is ICrackMaterial).ToList();
otherNdms = ndmCollection.Except(concreteNdms).ToList();
}
private (IConcreteDeltaELogic DeltaLogicX, IConcreteDeltaELogic DeltaLogicY) GetDeltaLogics()
@@ -78,35 +78,38 @@ namespace StructureHelperLogics.NdmCalculations.Buckling
return (DeltaElogicAboutX, DeltaElogicAboutY);
}
private IEnumerable<INdmPrimitive> GetConcretePrimitives()
{
var primitives = options.Primitives.Where(x => x.HeadMaterial.HelperMaterial is IConcreteLibMaterial);
return primitives;
}
private (double DX, double DY) GetStiffness()
{
const string sumStif = "Summary stiffness";
var gravityCenter = GeometryOperations.GetGravityCenter(ndmCollection);
string message = string.Format("Gravity center, x = {0}, y = {1}", gravityCenter.Cx, gravityCenter.Cy);
TraceLogger?.AddMessage(message);
if (TraceLogger is not null)
{
TraceLogger.AddMessage(string.Intern("Concrete elementary parts"));
TraceService.TraceNdmCollection(TraceLogger, concreteNdms);
TraceLogger.AddMessage(string.Intern("Nonconcrete elementary parts"));
TraceService.TraceNdmCollection(TraceLogger, otherNdms);
}
var (EIx, EIy) = GeometryOperations.GetReducedMomentsOfInertia(concreteNdms, gravityCenter);
TraceLogger.AddMessage(string.Format("Summary stiffness of concrete parts EIx,c = {0}", EIx));
TraceLogger.AddMessage(string.Format("Summary stiffness of concrete parts EIy,c = {0}", EIy));
TraceLogger?.AddMessage(string.Format("{0} of concrete parts EIx,c = {1}", sumStif, EIx));
TraceLogger?.AddMessage(string.Format("{0} of concrete parts EIy,c = {1}", sumStif, EIy));
var otherInertia = GeometryOperations.GetReducedMomentsOfInertia(otherNdms, gravityCenter);
TraceLogger.AddMessage(string.Format("Summary stiffness of nonconcrete parts EIx,s = {0}", otherInertia.EIy));
TraceLogger.AddMessage(string.Format("Summary stiffness of nonconcrete parts EIy,s = {0}", otherInertia.EIy));
TraceLogger?.AddMessage(string.Format("{0} of nonconcrete parts EIx,s = {1}", sumStif, otherInertia.EIx));
TraceLogger?.AddMessage(string.Format("{0} of nonconcrete parts EIy,s = {1}", sumStif, otherInertia.EIy));
var (Kc, Ks) = stiffnessLogicX.GetStiffnessCoeffitients();
var dX = Kc * EIx + Ks * otherInertia.EIx;
string mesDx = string.Format("Summary stiffness Dx = Kc * EIx,c + Ks * EIx,s = {0} * {1} + {2} * {3} = {4}",
Kc, EIx, Ks, otherInertia.EIx, dX);
TraceLogger.AddMessage(mesDx);
string mesDx = string.Format("{0} Dx = Kc * EIx,c + Ks * EIx,s = {1} * {2} + {3} * {4} = {5}",
sumStif, Kc, EIx, Ks, otherInertia.EIx, dX);
TraceLogger?.AddMessage(mesDx);
var stiffnessY = stiffnessLogicY.GetStiffnessCoeffitients();
var dY = stiffnessY.Kc * EIy + stiffnessY.Ks * otherInertia.EIy;
string mesDy = string.Format("Summary stiffness Dy = Kc * EIy,c + Ks * EIy,s = {0} * {1} + {2} * {3} = {4}",
stiffnessY.Kc, EIy, stiffnessY.Ks, otherInertia.EIy, dY);
TraceLogger.AddMessage(mesDy);
string mesDy = string.Format("{0} Dy = Kc * EIy,c + Ks * EIy,s = {1} * {2} + {3} * {4} = {5}",
sumStif, stiffnessY.Kc, EIy, stiffnessY.Ks, otherInertia.EIy, dY);
TraceLogger?.AddMessage(mesDy);
return (dX, dY);
}
@@ -132,8 +135,8 @@ namespace StructureHelperLogics.NdmCalculations.Buckling
point = new Point2D() { X = item.CenterX, Y = item.CenterY };
}
}
TraceLogger.AddMessage(string.Format("Most tensioned (minimum compressed) point: x = {0}, y = {1}", point.X, point.Y));
TraceLogger.AddMessage(string.Format("Strain: epsilon = {0}", maxStrain), TraceLogStatuses.Debug);
TraceLogger?.AddMessage(string.Format("Most tensioned (minimum compressed) point: x = {0}, y = {1}", point.X, point.Y));
TraceLogger?.AddMessage(string.Format("Strain: epsilon = {0}", maxStrain), TraceLogStatuses.Debug);
return point;
}

View File

@@ -0,0 +1,44 @@
using LoaderCalculator.Data.Ndms;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Loggers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Services
{
internal static class TraceService
{
public static void TraceNdmCollection(ITraceLogger traceLogger, IEnumerable<INdm> ndmCollection)
{
if (traceLogger is null)
{
throw new StructureHelperException(ErrorStrings.NullReference + ": trace logger");
}
if (ndmCollection is null)
{
traceLogger.AddMessage(string.Intern("Collection of elementary parts is null"), TraceLogStatuses.Error);
throw new StructureHelperException(ErrorStrings.NullReference + ": collection of elementary parts");
}
if (!ndmCollection.Any())
{
traceLogger.AddMessage("Collection of elementary parts is empty", TraceLogStatuses.Warning);
}
traceLogger.AddMessage(string.Format("Collection of elementary parts contains {0} parts", ndmCollection.Count()));
var mes = "area of elementary part collection ";
traceLogger.AddMessage(string.Format("{0} {1} A = {2}, {0} reduced {1} Ared = {3}",
LoggerStrings.Summary,
mes,
ndmCollection.Sum(x => x.Area),
ndmCollection.Sum(x => x.Area * x.StressScale)),
TraceLogStatuses.Service);
traceLogger.AddMessage($"Minimum x = {ndmCollection.Min(x => x.CenterX)}", TraceLogStatuses.Debug);
traceLogger.AddMessage($"Maximum x = {ndmCollection.Max(x => x.CenterX)}", TraceLogStatuses.Debug);
traceLogger.AddMessage($"Minimum y = {ndmCollection.Min(x => x.CenterY)}", TraceLogStatuses.Debug);
traceLogger.AddMessage($"Maximum y = {ndmCollection.Max(x => x.CenterY)}", TraceLogStatuses.Debug);
}
}
}