Add steel material saving

This commit is contained in:
Evgeny Redikultsev
2025-12-20 21:32:02 +05:00
parent 68b15682bb
commit 7e82e5ee9d
47 changed files with 1160 additions and 381 deletions

View File

@@ -4,6 +4,7 @@ using LoaderCalculator.Data.Materials.MaterialBuilders;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Materials.Libraries.Logics;
using System;
using System.Collections.Generic;
@@ -11,9 +12,9 @@ namespace StructureHelperCommon.Models.Materials.Libraries
{
public class SteelMaterialBuilderLogic : IMaterialLogic
{
private const double safetyFactorForULS = 1.05;
private const double safetyFactorforSLS = 1.0;
private ISteelMaterialLogicOption option;
private ICheckEntityLogic<ISteelMaterialLogicOption> checkEntityLogic;
private ICheckEntityLogic<ISteelMaterialLogicOption> CheckEntityLogic => checkEntityLogic ??= new SteelMaterialLogicOptionCheckStrategy() { Entity = option};
IObjectConvertStrategy<ISteelDiagramAbsoluteProperty, ISteelDiagramRelativeProperty> convertStrategy;
private IMaterialFactorLogic factorLogic;
private double compressionStrength;
@@ -33,23 +34,29 @@ namespace StructureHelperCommon.Models.Materials.Libraries
public IMaterial GetLoaderMaterial()
{
option = Options as ISteelMaterialLogicOption;
if (DiagramType == DiagramType.TripleLinear)
CheckOptions();
factorLogic = new MaterialFactorLogic(Options.SafetyFactors);
GetStrength();
Material material = new()
{
factorLogic = new MaterialFactorLogic(Options.SafetyFactors);
GetStrength();
Material material = new()
{
InitModulus = option.MaterialEntity.InitialModulus,
Diagram = GetDiagram(),
LimitPositiveStrain = GetMaxStrain(tensionStrength),
LimitNegativeStrain = -GetMaxStrain(compressionStrength),
};
return material;
InitModulus = option.MaterialEntity.InitialModulus,
Diagram = GetDiagram(),
LimitPositiveStrain = GetMaxStrain(tensionStrength),
LimitNegativeStrain = -GetMaxStrain(compressionStrength),
};
return material;
}
private void CheckOptions()
{
if (Options is not ISteelMaterialLogicOption steelOption)
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(Options));
}
else
option = steelOption;
if (CheckEntityLogic.Check() == false)
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(DiagramType));
throw new StructureHelperException("Option is not correct: \n" + CheckEntityLogic.CheckResult);
}
}
@@ -62,18 +69,61 @@ namespace StructureHelperCommon.Models.Materials.Libraries
private Func<double, double> GetDiagram()
{
MultiLinearStressStrainDiagram compressionDiagram = GetMultiLinearDiagram(compressionStrength);
MultiLinearStressStrainDiagram tensionDiagram = GetMultiLinearDiagram(tensionStrength);
IDiagram compressionDiagram = GetDiagram(compressionStrength);
IDiagram tensionDiagram = GetDiagram(tensionStrength);
var posNegDiagram = new PosNegDigramDecorator(tensionDiagram, compressionDiagram);
return posNegDiagram.GetStressByStrain;
}
private IDiagram GetDiagram(double strength)
{
if (strength == 0.0)
{
ConstantValueDiagram diagram = new() { ConstantValue = 0.0 };
return diagram;
}
MultiLinearStressStrainDiagram multiDiagram = GetMultiLinearDiagram(strength);
return multiDiagram;
}
private MultiLinearStressStrainDiagram GetMultiLinearDiagram(double strength)
{
convertStrategy = new SteelRelativeToAbsoluteDiagramConvertLogic(Options.MaterialEntity.InitialModulus, strength);
var diagramProperty = SteelDiagramPropertyFactory.GetProperty(((ISteelMaterialEntity)Options.MaterialEntity).PropertyType);
var absoluteProperty = convertStrategy.Convert(diagramProperty);
List<IStressStrainPair> stressStrainPairs = new()
List<IStressStrainPair> stressStrainPairs;
if (DiagramType == DiagramType.Bilinear)
{
stressStrainPairs = GetBiLinearStressStrainPairs(absoluteProperty);
}
else if (DiagramType == DiagramType.TripleLinear)
{
stressStrainPairs = GetTripleLinearStressStrainPairs(absoluteProperty);
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(DiagramType));
}
var multiDiagram = new MultiLinearStressStrainDiagram(stressStrainPairs);
return multiDiagram;
}
private static List<IStressStrainPair> GetBiLinearStressStrainPairs(ISteelDiagramAbsoluteProperty absoluteProperty)
{
return new()
{
new StressStrainPair() { Stress = 0, Strain = 0},
new StressStrainPair() { Stress = absoluteProperty.BaseStrength, Strain = absoluteProperty.BaseStrain},
new StressStrainPair() { Stress = absoluteProperty.BaseStrength, Strain = absoluteProperty.StrainOfEndOfYielding},
new StressStrainPair() { Stress = absoluteProperty.StressOfUltimateStrength, Strain = absoluteProperty.StrainOfUltimateStrength},
new StressStrainPair() { Stress = absoluteProperty.StressOfFracture, Strain = absoluteProperty.StrainOfFracture},
};
}
private static List<IStressStrainPair> GetTripleLinearStressStrainPairs(ISteelDiagramAbsoluteProperty absoluteProperty)
{
return new()
{
new StressStrainPair() { Stress = 0, Strain = 0},
new StressStrainPair() { Stress = absoluteProperty.StressOfProportionality, Strain = absoluteProperty.StrainOfProportionality},
@@ -83,8 +133,6 @@ namespace StructureHelperCommon.Models.Materials.Libraries
new StressStrainPair() { Stress = absoluteProperty.StressOfFracture, Strain = absoluteProperty.StrainOfFracture},
};
var multiDiagram = new MultiLinearStressStrainDiagram(stressStrainPairs);
return multiDiagram;
}
public void GetStrength()
@@ -98,17 +146,17 @@ namespace StructureHelperCommon.Models.Materials.Libraries
double factor;
if (Options.LimitState == Infrastructures.Enums.LimitStates.ULS)
{
factor = safetyFactorForULS;
factor = option.UlsFactor;
}
else if (Options.LimitState == Infrastructures.Enums.LimitStates.SLS)
{
factor = safetyFactorforSLS;
factor = option.SlsFactor;
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(Options.LimitState));
}
double strength = baseStength / factor;
double strength = baseStength * option.ThicknessFactor * option.WorkConditionFactor / factor;
compressionStrength = strength * compressionFactor;
tensionStrength = strength * tensionFactor;
}