Trace logging for sorce of cracking was added

This commit is contained in:
Evgeny Redikultsev
2024-02-01 23:01:50 +05:00
parent 79ef8c5304
commit 783d5e0591
16 changed files with 212 additions and 59 deletions

View File

@@ -14,7 +14,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
public IResult Result { get; private set; }
public Action<IResult> ActionToOutputResults { get; set; }
public IShiftTraceLogger? TraceLogger { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public IShiftTraceLogger? TraceLogger { get; set; }
public ForceTupleCalculator(IForceTupleInputData inputData)
{
@@ -31,14 +31,24 @@ 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");
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);
var tuple = InputData.Tuple;
var accuracy = InputData.Accuracy;
TraceLogger?.AddMessage($"Input force combination");
TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(tuple));
var mx = tuple.Mx;
var my = tuple.My;
var nz = tuple.Nz;
TraceLogger?.AddMessage($"Required accuracy rate {accuracy.IterationAccuracy}");
TraceLogger?.AddMessage($"Maximum iteration count {accuracy.MaxIterationCount}");
try
{
var loaderData = new LoaderOptions
@@ -53,23 +63,45 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
NdmCollection = ndmCollection
};
var calculator = new Calculator();
TraceLogger?.AddMessage($"Calculation is started", TraceLogStatuses.Debug);
calculator.Run(loaderData, new CancellationToken());
TraceLogger?.AddMessage($"Calculation result is obtained", TraceLogStatuses.Debug);
var calcResult = calculator.Result;
if (calcResult.AccuracyRate <= accuracy.IterationAccuracy)
{
return new ForcesTupleResult() { IsValid = true, Description = "Analysis is done succsefully", LoaderResults = calcResult };
TraceLogger?.AddMessage($"Analisis is done succsesfully");
TraceLogger?.AddMessage($"Current accuracy {calcResult.AccuracyRate}, {calcResult.IterationCounter} iteration has done", TraceLogStatuses.Debug);
return new ForcesTupleResult()
{
IsValid = true,
Description = "Analysis is done succsefully",
LoaderResults = calcResult
};
}
else
{
TraceLogger?.AddMessage($"Required accuracy rate has not achived", 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 achived", LoaderResults = calcResult };
}
}
catch (Exception ex)
{
var result = new ForcesTupleResult() { IsValid = false };
if (ex.Message == "Calculation result is not valid: stiffness matrix is equal to zero") { result.Description = "Stiffness matrix is equal to zero \nProbably section was collapsed"; }
else { result.Description = $"Error is appeared due to analysis. Error: {ex}"; }
TraceLogger?.AddMessage($"Critical error ocured during calculation\n{ex}", TraceLogStatuses.Error);
var result = new ForcesTupleResult()
{
IsValid = false
};
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";
}
else
{
result.Description = $"Error is appeared due to analysis. Error: {ex}";
}
return result;
}
}

View File

@@ -1,6 +1,9 @@
using LoaderCalculator.Data.Ndms;
using LoaderCalculator.Logics;
using LoaderCalculator.Logics.Geometry;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Services.Forces;
using System;
@@ -11,19 +14,30 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics
{
internal class SofteningFactorLogic
internal class SofteningFactorLogic : ILogic
{
public static IStressLogic stressLogic = new StressLogic();
public IEnumerable<INdm> NdmCollection { get; set; }
public StrainTuple StrainTuple { get; set; }
public IShiftTraceLogger? TraceLogger { get; set; }
public StrainTuple GetSofteningFactors()
{
var strainTuple = new StrainTuple();
TraceLogger?.AddMessage($"Calculator type: {GetType()}", TraceLogStatuses.Service);
TraceLogger?.AddMessage($"Logic of analisys based on calculating sum of secant stifness of elementary parts EA,i = A,i * Esec,i");
TraceLogger?.AddMessage($"Calculating geometry properies for strains");
TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(StrainTuple));
var loaderStainMatrix = TupleConverter.ConvertToLoaderStrainMatrix(StrainTuple);
var (MxFactor, MyFactor, NzFactor) = GeometryOperations.GetSofteningsFactors(NdmCollection, loaderStainMatrix);
strainTuple.Mx = MxFactor;
strainTuple.My = MyFactor;
strainTuple.Nz = NzFactor;
TraceLogger?.AddMessage($"Reducing of stiffness in {ProgramSetting.GeometryNames.SndAxisName}-plane: EIx_cracked / EIx_uncracked = {MxFactor}");
TraceLogger?.AddMessage($"Reducing of stiffness in {ProgramSetting.GeometryNames.FstAxisName}-plane: EIy_cracked / EIy_uncracked = {MyFactor}");
TraceLogger?.AddMessage($"Reducing of along {ProgramSetting.GeometryNames.TrdAxisName}-axis: EA_cracked / EA_uncracked = {NzFactor}");
var strainTuple = new StrainTuple
{
Mx = MxFactor,
My = MyFactor,
Nz = NzFactor
};
return strainTuple;
}
}