Add steel Material

This commit is contained in:
Evgeny Redikultsev
2025-12-14 17:40:53 +05:00
parent 01cc3947bc
commit 68b15682bb
44 changed files with 1047 additions and 152 deletions

View File

@@ -7,12 +7,14 @@ namespace StructureHelperLogics.Models.Materials
{
public enum HeadmaterialType
{
Concrete40,
Reinforcement400,
Reinforcement500,
Elastic200,
Carbon1400,
Glass1200
Concrete40 = 0,
Reinforcement400 = 1,
Reinforcement500 = 2,
Elastic200 = 3,
Carbon1400 = 4,
Glass1200 = 5,
SteelS245 = 6,
SteelS345 = 7,
}
public static class HeadMaterialFactory
@@ -20,23 +22,46 @@ namespace StructureHelperLogics.Models.Materials
private static CodeTypes codeType;
private static IEnumerable<ILibMaterialEntity> LibConcreteMaterials => LibMaterialPepository.GetConcreteRepository();
private static IEnumerable<ILibMaterialEntity> LibReinforcementMaterials => LibMaterialPepository.GetReinforcementRepository();
private static IEnumerable<ILibMaterialEntity> LibSteelMaterials => LibMaterialPepository.GetSteelRepository();
public static IHeadMaterial GetHeadMaterial(HeadmaterialType type)
{
if (type == HeadmaterialType.Concrete40) { return GetConcrete40(); }
if (type == HeadmaterialType.Reinforcement400) { return GetReinforcement400(); }
if (type == HeadmaterialType.Reinforcement500) { return GetReinforcement500(); }
if (type == HeadmaterialType.Elastic200) { return GetElastic200(); }
if (type == HeadmaterialType.Carbon1400) { return GetCarbon1400(); }
if (type == HeadmaterialType.Glass1200) { return GetGlass1200(); }
else if (type == HeadmaterialType.Reinforcement400) { return GetReinforcement400(); }
else if (type == HeadmaterialType.Reinforcement500) { return GetReinforcement500(); }
else if (type == HeadmaterialType.Elastic200) { return GetElastic200(); }
else if (type == HeadmaterialType.Carbon1400) { return GetCarbon1400(); }
else if (type == HeadmaterialType.Glass1200) { return GetGlass1200(); }
else if (type == HeadmaterialType.SteelS245) { return GetSteelS245(); }
else if (type == HeadmaterialType.SteelS345) { return GetSteelS345(); }
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + nameof(type));
}
private static IHeadMaterial GetSteelS245()
{
var material = new HeadMaterial() { Name = "New steel" };
var libMaterial = LibSteelMaterials.Where(x => x.Name.Contains("245")).First();
var libMat = new SteelLibMaterial(Guid.NewGuid());
libMat.MaterialEntity = libMaterial;
material.HelperMaterial = libMat;
return material;
}
private static IHeadMaterial GetSteelS345()
{
var material = new HeadMaterial() { Name = "New steel" };
var libMaterial = LibSteelMaterials.Where(x => x.Name.Contains("345")).First();
var libMat = new SteelLibMaterial(Guid.NewGuid());
libMat.MaterialEntity = libMaterial;
material.HelperMaterial = libMat;
return material;
}
private static IHeadMaterial GetReinforcement500()
{
var material = new HeadMaterial() { Name = "New reinforcement" };
var libMaterial = LibReinforcementMaterials.Where(x => x.Name.Contains("500")).First();
var libMat = new ReinforcementLibMaterial();
var libMat = new ReinforcementLibMaterial(Guid.NewGuid());
libMat.MaterialEntity = libMaterial;
material.HelperMaterial = libMat;
return material;
@@ -77,7 +102,7 @@ namespace StructureHelperLogics.Models.Materials
{
var material = new HeadMaterial() { Name = "New reinforcement" };
var libMaterial = LibReinforcementMaterials.Where(x => x.Name.Contains("400")).First();
var libMat = new ReinforcementLibMaterial();
var libMat = new ReinforcementLibMaterial(Guid.NewGuid());
libMat.MaterialEntity = libMaterial;
material.HelperMaterial = libMat;
return material;

View File

@@ -0,0 +1,12 @@
using StructureHelperCommon.Models.Materials;
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.Models.Materials
{
public interface ISteelLibMaterial : ILibMaterial
{
double MaxPlasticStrainRatio { get; set; }
}
}

View File

@@ -7,11 +7,12 @@ namespace StructureHelperLogics.Models.Materials
public class ConcreteLibUpdateStrategy : IUpdateStrategy<IConcreteLibMaterial>
{
private IUpdateStrategy<ILibMaterial> libUpdateStrategy;
private IUpdateStrategy<ILibMaterial> LibUpdateStrategy => libUpdateStrategy ??= new LibMaterialUpdateStrategy();
public ConcreteLibUpdateStrategy(IUpdateStrategy<ILibMaterial> libUpdateStrategy)
{
this.libUpdateStrategy = libUpdateStrategy;
}
public ConcreteLibUpdateStrategy() : this(new LibMaterialUpdateStrategy())
public ConcreteLibUpdateStrategy()
{
}
@@ -20,7 +21,7 @@ namespace StructureHelperLogics.Models.Materials
CheckObject.ThrowIfNull(sourceObject);
CheckObject.ThrowIfNull(targetObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; }
libUpdateStrategy.Update(targetObject, sourceObject);
LibUpdateStrategy.Update(targetObject, sourceObject);
targetObject.TensionForULS = sourceObject.TensionForULS;
targetObject.TensionForSLS = sourceObject.TensionForSLS;
targetObject.RelativeHumidity = sourceObject.RelativeHumidity;

View File

@@ -0,0 +1,63 @@
using LoaderCalculator.Data.Materials;
using LoaderCalculator.Data.Materials.DiagramTemplates;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Materials.Libraries;
using System;
using System.Collections.Generic;
using System.Security.Policy;
using System.Text;
using System.Windows.Media.TextFormatting;
namespace StructureHelperLogics.Models.Materials.Logics
{
public class GetSteelLoaderMaterialLogic
{
IObjectConvertStrategy<ISteelDiagramAbsoluteProperty, ISteelDiagramRelativeProperty> convertStrategy;
public double InitialModulus { get; set; }
public double CompressionStrength { get; set; }
public double TensionStrength { get; internal set; }
public double MaxPlasticStrainRatio { get; set; }
public ISteelDiagramRelativeProperty DiagramProperty { get; set; }
public IMaterial GetMaterial()
{
double elasticCompressionStrain = CompressionStrength / InitialModulus;
double fullCompressionStrain = elasticCompressionStrain * (1 + MaxPlasticStrainRatio);
Material material = new()
{
Diagram = GetDiagram(),
LimitPositiveStrain = fullCompressionStrain,
LimitNegativeStrain = - fullCompressionStrain,
};
return material;
}
private Func<double, double> GetDiagram()
{
MultiLinearStressStrainDiagram compressionDiagram = GetMultiLinearDiagram(CompressionStrength);
MultiLinearStressStrainDiagram tensionDiagram = GetMultiLinearDiagram(TensionStrength);
var posNegDiagram = new PosNegDigramDecorator(tensionDiagram, compressionDiagram);
return posNegDiagram.GetStressByStrain;
}
private MultiLinearStressStrainDiagram GetMultiLinearDiagram(double strength)
{
convertStrategy ??= new SteelRelativeToAbsoluteDiagramConvertLogic(InitialModulus, strength);
var absoluteProperty = convertStrategy.Convert(DiagramProperty);
List<IStressStrainPair> stressStrainPairs = new()
{
new StressStrainPair() { Stress = 0, Strain = 0},
new StressStrainPair() { Stress = absoluteProperty.StressOfProportionality, Strain = absoluteProperty.StrainOfProportionality},
new StressStrainPair() { Stress = absoluteProperty.BaseStrength, Strain = absoluteProperty.StrainOfStartOfYielding},
new StressStrainPair() { Stress = absoluteProperty.BaseStrength, Strain = absoluteProperty.StrainOfEndOfYielding},
new StressStrainPair() { Stress = absoluteProperty.StressOfUltimateStrength, Strain = absoluteProperty.StrainOfUltimateStrength},
new StressStrainPair() { Stress = absoluteProperty.StressOfFracture, Strain = absoluteProperty.StrainOfFracture},
};
var multiDiagram = new MultiLinearStressStrainDiagram(stressStrainPairs);
return multiDiagram;
}
}
}

View File

@@ -14,10 +14,16 @@ namespace StructureHelperLogics.Models.Materials
{
public class HelperMaterialUpdateStrategy : IUpdateStrategy<IHelperMaterial>
{
private IUpdateStrategy<IElasticMaterial> elasticStrategy;
private IUpdateStrategy<IFRMaterial> frStrategy;
private IUpdateStrategy<IConcreteLibMaterial> concreteStrategy;
private IUpdateStrategy<IReinforcementLibMaterial> reinforcementStrategy;
private IUpdateStrategy<IElasticMaterial> elasticUpdateStrategy;
private IUpdateStrategy<IFRMaterial> frUpdateStrategy;
private IUpdateStrategy<IConcreteLibMaterial> concreteUpdateStrategy;
private IUpdateStrategy<IReinforcementLibMaterial> reinforcementUpdateStrategy;
private IUpdateStrategy<ISteelLibMaterial> steelUpdateStrategy;
private IUpdateStrategy<IElasticMaterial> ElasticUpdateStrategy => elasticUpdateStrategy ??= new ElasticUpdateStrategy();
private IUpdateStrategy<IFRMaterial> FrUpdateStrategy => frUpdateStrategy ??= new FRUpdateStrategy();
private IUpdateStrategy<IConcreteLibMaterial> ConcreteUpdateStrategy => concreteUpdateStrategy ??= new ConcreteLibUpdateStrategy();
private IUpdateStrategy<IReinforcementLibMaterial> ReinforcementUpdateStrategy => reinforcementUpdateStrategy ??= new ReinforcementLibUpdateStrategy();
private IUpdateStrategy<ISteelLibMaterial> SteelUpdateStrategy => steelUpdateStrategy ??= new SteelLibMaterialUpdateStrategy();
private IUpdateStrategy<IHelperMaterial> safetyFactorUpdateStrategy = new HelpermaterialSafetyFactorsUpdateStrategy();
public HelperMaterialUpdateStrategy(IUpdateStrategy<IElasticMaterial> elasticStrategy,
IUpdateStrategy<IFRMaterial> frStrategy,
@@ -25,17 +31,12 @@ namespace StructureHelperLogics.Models.Materials
IUpdateStrategy<IReinforcementLibMaterial> reinforcementStrategy
)
{
this.elasticStrategy = elasticStrategy;
this.frStrategy = frStrategy;
this.concreteStrategy = concreteStrategy;
this.reinforcementStrategy = reinforcementStrategy;
this.elasticUpdateStrategy = elasticStrategy;
this.frUpdateStrategy = frStrategy;
this.concreteUpdateStrategy = concreteStrategy;
this.reinforcementUpdateStrategy = reinforcementStrategy;
}
public HelperMaterialUpdateStrategy() : this(
new ElasticUpdateStrategy(),
new FRUpdateStrategy(),
new ConcreteLibUpdateStrategy(),
new ReinforcementLibUpdateStrategy()
)
public HelperMaterialUpdateStrategy()
{ }
public void Update(IHelperMaterial targetObject, IHelperMaterial sourceObject)
@@ -50,11 +51,11 @@ namespace StructureHelperLogics.Models.Materials
}
else if (sourceObject is IElasticMaterial)
{
elasticStrategy.Update(targetObject as IElasticMaterial, sourceObject as IElasticMaterial);
ElasticUpdateStrategy.Update(targetObject as IElasticMaterial, sourceObject as IElasticMaterial);
}
else if (sourceObject is IFRMaterial)
{
frStrategy.Update(targetObject as IFRMaterial, sourceObject as IFRMaterial);
FrUpdateStrategy.Update(targetObject as IFRMaterial, sourceObject as IFRMaterial);
}
else
{
@@ -66,11 +67,15 @@ namespace StructureHelperLogics.Models.Materials
{
if (sourceObject is IConcreteLibMaterial concreteLibMaterial)
{
concreteStrategy.Update(targetObject as IConcreteLibMaterial, concreteLibMaterial);
concreteUpdateStrategy.Update(targetObject as IConcreteLibMaterial, concreteLibMaterial);
}
else if (sourceObject is IReinforcementLibMaterial reinforcementLibMaterial)
{
reinforcementStrategy.Update(targetObject as IReinforcementLibMaterial, reinforcementLibMaterial);
ReinforcementUpdateStrategy.Update(targetObject as IReinforcementLibMaterial, reinforcementLibMaterial);
}
else if (sourceObject is ISteelLibMaterial steelLibMaterial)
{
SteelUpdateStrategy.Update(targetObject as ISteelLibMaterial, steelLibMaterial);
}
else
{

View File

@@ -0,0 +1,34 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Materials;
using StructureHelperCommon.Services;
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.Models.Materials
{
public class SteelLibMaterialUpdateStrategy : IUpdateStrategy<ISteelLibMaterial>
{
private IUpdateStrategy<ILibMaterial> libUpdateStrategy;
private IUpdateStrategy<ILibMaterial> LibUpdateStrategy => libUpdateStrategy ??= new LibMaterialUpdateStrategy();
public SteelLibMaterialUpdateStrategy(IUpdateStrategy<ILibMaterial> libUpdateStrategy)
{
this.libUpdateStrategy = libUpdateStrategy;
}
public SteelLibMaterialUpdateStrategy()
{
}
public void Update(ISteelLibMaterial targetObject, ISteelLibMaterial sourceObject)
{
CheckObject.ThrowIfNull(sourceObject);
CheckObject.ThrowIfNull(targetObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; }
LibUpdateStrategy.Update(targetObject, sourceObject);
targetObject.MaxPlasticStrainRatio = sourceObject.MaxPlasticStrainRatio;
}
}
}

View File

@@ -1,16 +1,9 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Models.Materials.Libraries;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Loadermaterials = LoaderCalculator.Data.Materials;
using LMBuilders = LoaderCalculator.Data.Materials.MaterialBuilders;
using LoaderMaterialLogics = LoaderCalculator.Data.Materials.MaterialBuilders.MaterialLogics;
using LoaderCalculator.Data.Materials;
using StructureHelperCommon.Models.Materials;
using LoaderCalculator.Data.Materials;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Materials;
using StructureHelperCommon.Models.Materials.Libraries;
using LoaderMaterialLogics = LoaderCalculator.Data.Materials.MaterialBuilders.MaterialLogics;
namespace StructureHelperLogics.Models.Materials
{
@@ -24,7 +17,7 @@ namespace StructureHelperLogics.Models.Materials
public Guid Id { get; }
public ILibMaterialEntity MaterialEntity { get; set; }
public List<IMaterialSafetyFactor> SafetyFactors { get; set; } = new();
public List<IMaterialSafetyFactor> SafetyFactors { get; set; } = [];
public IMaterialLogic MaterialLogic { get; set; }
public List<IMaterialLogic> MaterialLogics => materialLogics;
@@ -36,14 +29,9 @@ namespace StructureHelperLogics.Models.Materials
MaterialLogic = materialLogics.First();
}
public ReinforcementLibMaterial() : this (Guid.NewGuid())
{
}
public object Clone()
{
var newItem = new ReinforcementLibMaterial();
var newItem = new ReinforcementLibMaterial(Guid.NewGuid());
var updateStrategy = new ReinforcementLibUpdateStrategy();
updateStrategy.Update(newItem, this);
return newItem;

View File

@@ -0,0 +1,89 @@
using LoaderCalculator.Data.Materials;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Materials;
using StructureHelperCommon.Models.Materials.Libraries;
using StructureHelperLogics.Models.Materials.Logics;
namespace StructureHelperLogics.Models.Materials
{
public class SteelLibMaterial : ISteelLibMaterial
{
const MaterialTypes materialType = MaterialTypes.Steel;
private const double safetyFactorForULS = 1.05;
private const double safetyFactorforSLS = 1.0;
private IMaterialFactorLogic factorLogic => new MaterialFactorLogic(SafetyFactors);
private readonly List<IMaterialLogic> materialLogics = ProgramSetting.MaterialLogics.Where(x => x.MaterialType == materialType).ToList();
public Guid Id { get; }
public ILibMaterialEntity MaterialEntity { get; set; }
public IMaterialLogic MaterialLogic { get; set; }
public List<IMaterialLogic> MaterialLogics => materialLogics;
public List<IMaterialSafetyFactor> SafetyFactors { get; set; } = [];
public double MaxPlasticStrainRatio { get; set; } = 3.0;
public SteelLibMaterial(Guid id)
{
Id = id;
MaterialLogic = materialLogics.First();
}
public object Clone()
{
SteelLibMaterial newItem = new(Guid.NewGuid());
var logic = new SteelLibMaterialUpdateStrategy();
logic.Update(newItem, this);
return newItem;
}
public IMaterial GetCrackedLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
{
return GetLoaderMaterial(limitState, calcTerm);
}
public IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
{
SteelMaterialLogicOption options = new()
{
MaterialEntity = MaterialEntity,
SafetyFactors = SafetyFactors,
MaxPlasticStrainRatio = MaxPlasticStrainRatio,
LimitState = limitState,
CalcTerm = calcTerm,
};
MaterialLogic.Options = options;
var material = MaterialLogic.GetLoaderMaterial();
return material;
}
public (double Compressive, double Tensile) GetStrength(LimitStates limitState, CalcTerms calcTerm)
{
double baseStength = MaterialEntity.MainStrength;
var factors = factorLogic.GetTotalFactor(limitState, calcTerm);
double compressionFactor = 1d;
double tensionFactor = 1d;
compressionFactor *= factors.Compressive;
tensionFactor *= factors.Tensile;
double factor;
if (limitState == LimitStates.ULS)
{
factor = safetyFactorForULS;
}
else if (limitState == LimitStates.SLS)
{
factor = safetyFactorforSLS;
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(limitState));
}
double strength = baseStength / factor;
return (strength * compressionFactor, strength * tensionFactor);
}
}
}