using FeMM.Grasshopper.Helpers;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Parameters;
using Maffeis.Model.Materials;
using System;
using System.Collections.Generic;
namespace FeMM.Grasshopper.Components.MeCheck2
{
public class CreepAndShrinkageConcreteComponent : GH_Component
{
protected Dictionary<int, string> _cementType = new()
{
{ 0, "Class R" },
{ 1, "Class N" },
{ 2, "Class S" },
};
/// <summary>
/// Initializes a new instance of the MeshRemap class.
/// </summary>
public CreepAndShrinkageConcreteComponent()
: base("Creep And Shrinkage Concrete", "CS", "Calculate Creep And Shrinkage for Concrete according to standard EN1992", CategoryNameConstants.CATEGORY_CHECKS, CategoryNameConstants.SUBCATEGORY_MECHECK2)
{
}
/// <summary>
/// Registers all the input parameters for this component.
/// </summary>
protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddNumberParameter("Fck", "Fck", "", GH_ParamAccess.item);
pManager.AddNumberParameter("Elastic Modulus Steel", "Ea", "Elastic modulus of steel", GH_ParamAccess.item, 210000);
pManager.AddNumberParameter("Concrete Area", "Ac[mm]", "Cross sectional area", GH_ParamAccess.item);
pManager.AddNumberParameter("RH", "RH[%]", "Relative humidity of the ambient enviroment in %", GH_ParamAccess.item);
pManager.AddNumberParameter("u", "u[mm]", "The perimeter of the member in contact with the atmosphere", GH_ParamAccess.item);
pManager.AddNumberParameter("t0", "t0[days]", "The age of concrete at loading in days. Default value 28 days", GH_ParamAccess.item, 28);
pManager.AddNumberParameter("t", "t[days]", "The age of concrete in days at the moment considerated. If is 0, consider infinite time", GH_ParamAccess.item, 0);
int i = pManager.AddIntegerParameter("Cement Type", "CT", "The type of cement", GH_ParamAccess.item, 1);
Param_Integer mtParam = pManager[i] as Param_Integer;
foreach (KeyValuePair<int, string> v in _cementType)
mtParam.AddNamedValue(v.Value, v.Key);
}
/// <summary>
/// Registers all the output parameters for this component.
/// </summary>
protected override void RegisterOutputParams(GH_OutputParamManager pManager)
{
pManager.AddNumberParameter("n0", "n0", "Homogenization coefficient for instant time loads", GH_ParamAccess.item);
pManager.AddNumberParameter("n ∞", "n ∞", "Homogenization coefficient for infinite time loads", GH_ParamAccess.item);
pManager.AddNumberParameter("y(t,t0)", "y", "Creep coefficient", GH_ParamAccess.item);
pManager.AddNumberParameter("εcd", "εcd", "Drying Shrinkage strain", GH_ParamAccess.item);
pManager.AddNumberParameter("εca", "εca", "Autogenous Shrinkage strain", GH_ParamAccess.item);
pManager.AddNumberParameter("εcs", "εcs", "Total Shrinkage strain", GH_ParamAccess.item);
}
/// <summary>
/// This is the method that actually does the work.
/// </summary>
/// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
protected override void SolveInstance(IGH_DataAccess DA)
{
double fck = 0;
double Es = 0;
double rh = 0;
double concreteArea = 0;
double u = 0;
double t0 = 0;
double t = 0;
int cementType = 0;
int count = 0;
if (!DA.GetData(count++, ref fck))
return;
if (!DA.GetData(count++, ref Es))
return;
if (!DA.GetData(count++, ref concreteArea))
return;
if (!DA.GetData(count++, ref rh))
return;
if (!DA.GetData(count++, ref u))
return;
if (!DA.GetData(count++, ref t0))
return;
if (!DA.GetData(count++, ref t))
return;
if (!DA.GetData(count++, ref cementType))
return;
var concreteMaterialEN1992 = new ConcreteMaterialEN1992("", fck, ConcreteMaterial.CompressionStressStrainDiagrams.ParabolaRectangle,
0.2, 0.0025, 1e-6, (ConcreteMaterial.CementTypes)cementType);
double n0 = Es / concreteMaterialEN1992.ElasticModulusCompression;
double psiInf = t == 0 ? concreteMaterialEN1992.CalculatePhiinfiniteTime(rh, concreteArea, u, t0) : concreteMaterialEN1992.CalculatePhiT(rh, concreteArea, u, t, t0);
double n1 = Es / concreteMaterialEN1992.ElasticModulusCompression * (psiInf + 1);
double epsilonCAInf = 2.5 * (Math.Abs(fck) - 10) * Math.Pow(10, -6);
double epsilonCS = t == 0 ? concreteMaterialEN1992.GetEpsilonCSInfiniteTime(rh, concreteArea, u) : concreteMaterialEN1992.GetEpsilonCST(rh, concreteArea, u, t, t0);
DA.SetData(0, n0);
DA.SetData(1, n1);
DA.SetData(2, psiInf);
DA.SetData(3, -(epsilonCS - epsilonCAInf));
DA.SetData(4, -epsilonCAInf);
DA.SetData(5, -epsilonCS);
}
public override GH_Exposure Exposure => GH_Exposure.secondary;
/// <summary>
/// Provides an Icon for the component.
/// </summary>
protected override System.Drawing.Bitmap Icon => Properties.Resources.ConcreteCreepIcon;
/// <summary>
/// Gets the unique ID for this component. Do not change this ID after release.
/// </summary>
public override Guid ComponentGuid => new("83cbe8d4-b9b1-49c4-894c-4e54606a1356");
}
}