private bool SetObject(IMaterialFragment material) { bool success = true; if (material is IIsotropic) { IIsotropic isotropic = material as IIsotropic; success &= m_model.PropMaterial.SetMPIsotropic(material.DescriptionOrName(), isotropic.YoungsModulus, isotropic.PoissonsRatio, isotropic.ThermalExpansionCoeff) == 0; } else if (material is IOrthotropic) { IOrthotropic orthoTropic = material as IOrthotropic; if (CheckPropertyWarning(orthoTropic, x => x.YoungsModulus) && CheckPropertyWarning(orthoTropic, x => x.PoissonsRatio) && CheckPropertyWarning(orthoTropic, x => x.ThermalExpansionCoeff) && CheckPropertyWarning(orthoTropic, x => x.ShearModulus)) { double[] e = orthoTropic.YoungsModulus.ToDoubleArray(); double[] v = orthoTropic.PoissonsRatio.ToDoubleArray(); double[] a = orthoTropic.ThermalExpansionCoeff.ToDoubleArray(); double[] g = orthoTropic.ShearModulus.ToDoubleArray(); success &= m_model.PropMaterial.SetMPOrthotropic(material.DescriptionOrName(), ref e, ref v, ref a, ref g) == 0; } else { success = false; } } success &= m_model.PropMaterial.SetWeightAndMass(material.DescriptionOrName(), 2, material.Density) == 0; SetAdapterId(material, material.Name); return(success); }
/***************************************************/ public static void SetMaterial(cSapModel model, IMaterialFragment material) { eMatType matType = eMatType.NoDesign; int colour = 0; string guid = ""; string notes = ""; string name = ""; if (model.PropMaterial.GetMaterial(material.Name, ref matType, ref colour, ref notes, ref guid) != 0) { model.PropMaterial.AddMaterial(ref name, GetMaterialType(material), "", "", ""); model.PropMaterial.ChangeName(name, material.Name); if (material is IIsotropic) { IIsotropic isotropic = material as IIsotropic; model.PropMaterial.SetMPIsotropic(material.Name, isotropic.YoungsModulus, isotropic.PoissonsRatio, isotropic.ThermalExpansionCoeff); } else if (material is IOrthotropic) { IOrthotropic orthoTropic = material as IOrthotropic; double[] e = orthoTropic.YoungsModulus.ToDoubleArray(); double[] v = orthoTropic.PoissonsRatio.ToDoubleArray(); double[] a = orthoTropic.ThermalExpansionCoeff.ToDoubleArray(); double[] g = orthoTropic.ShearModulus.ToDoubleArray(); model.PropMaterial.SetMPOrthotropic(material.Name, ref e, ref v, ref a, ref g); } model.PropMaterial.SetWeightAndMass(material.Name, 0, material.Density); } }
/***************************************************/ private static string MaterialAnalyticalValues(this IIsotropic isotropicMaterial) { return($"E: {isotropicMaterial.YoungsModulus:G3}, " + $"ρ: {isotropicMaterial.Density:G3}, " + $"ν: {isotropicMaterial.PoissonsRatio:G3}, " + $"α: {isotropicMaterial.ThermalExpansionCoeff:G3} , " + $"ζ: {isotropicMaterial.DampingRatio:G3}"); }
public static double ShearModulus(this IIsotropic materialFragment) { return(materialFragment.IsNull() ? 0 : materialFragment.YoungsModulus / (2 * (1 + materialFragment.PoissonsRatio))); }
/***************************************************/ /**** Public Methods ****/ /***************************************************/ public static rf.Material ToRFEM(this IMaterialFragment materialFragment, int materialId) { //Example: NameID|Steel S 235@TypeID|STEEL@StandardID|DIN EN 1993-1-1-10 rf.Material rfMaterial = new rf.Material(); rfMaterial.No = materialId; rfMaterial.Description = materialFragment.Name; rfMaterial.SpecificWeight = materialFragment.Density * 10; //translate from kg/m3 to kN/m3 if (materialFragment.GetType() == typeof(Aluminium)) { IIsotropic material = materialFragment as IIsotropic; rfMaterial.ThermalExpansion = material.ThermalExpansionCoeff; rfMaterial.PoissonRatio = material.PoissonsRatio; rfMaterial.ElasticityModulus = material.YoungsModulus; rfMaterial.TextID = "NameID | " + materialFragment.Name + "@TypeID | ALUMINIUM" + "@StandardID | No norm set!"; } else if (materialFragment.GetType() == typeof(Steel)) { IIsotropic material = materialFragment as IIsotropic; rfMaterial.ThermalExpansion = material.ThermalExpansionCoeff; rfMaterial.PoissonRatio = material.PoissonsRatio; rfMaterial.ElasticityModulus = material.YoungsModulus; rfMaterial.TextID = "NameID | " + materialFragment.Name + "@TypeID | STEEL" + "@StandardID | No norm set!"; } else if (materialFragment.GetType() == typeof(Concrete)) { IIsotropic material = materialFragment as IIsotropic; rfMaterial.ThermalExpansion = material.ThermalExpansionCoeff; rfMaterial.PoissonRatio = material.PoissonsRatio; rfMaterial.ElasticityModulus = material.YoungsModulus; rfMaterial.TextID = "NameID | " + materialFragment.Name + "@TypeID | CONCRETE" + "@StandardID | No norm set!"; } else if (materialFragment.GetType() == typeof(GenericIsotropicMaterial)) { IIsotropic material = materialFragment as IIsotropic; rfMaterial.ThermalExpansion = material.ThermalExpansionCoeff; rfMaterial.PoissonRatio = material.PoissonsRatio; rfMaterial.ElasticityModulus = material.YoungsModulus; rfMaterial.TextID = "NameID | " + materialFragment.Name + "@TypeID | STEEL" + "@StandardID | No norm set!"; } else if (materialFragment.GetType() == typeof(Timber)) { //TODO: this looks like orthotropic is turned into isotropic !!! IOrthotropic material = materialFragment as IOrthotropic; rfMaterial.ThermalExpansion = material.ThermalExpansionCoeff.X; rfMaterial.PoissonRatio = material.PoissonsRatio.Y; rfMaterial.ElasticityModulus = material.YoungsModulus.Z; rfMaterial.TextID = "NameID | " + materialFragment.Name + "@TypeID | TIMBER" + "@StandardID | No norm set!"; } else if (materialFragment.GetType() == typeof(GenericOrthotropicMaterial)) { IOrthotropic material = materialFragment as IOrthotropic; rfMaterial.ThermalExpansion = material.ThermalExpansionCoeff.X; rfMaterial.PoissonRatio = material.PoissonsRatio.Y; rfMaterial.ElasticityModulus = material.YoungsModulus.Z; rfMaterial.TextID = "NameID | " + materialFragment.Name + "@TypeID | TIMBER" + "@StandardID | No norm set!"; } else { IIsotropic material = materialFragment as IIsotropic; rfMaterial.ThermalExpansion = material.ThermalExpansionCoeff; rfMaterial.PoissonRatio = material.PoissonsRatio; rfMaterial.ElasticityModulus = material.YoungsModulus; Engine.Base.Compute.RecordWarning("Cannot make " + materialFragment.Name + ". Replaced with standard steel"); rfMaterial.TextID = "NameID | " + materialFragment.Name + "@TypeID | STEEL" + "@StandardID | No norm set!"; } return(rfMaterial); }
private bool SetObject(IMaterialFragment material) { bool success = true; string bhName = material.DescriptionOrName(); if (material is IIsotropic) { IIsotropic isotropic = material as IIsotropic; if (m_model.PropMaterial.SetMPIsotropic(bhName, isotropic.YoungsModulus, isotropic.PoissonsRatio, isotropic.ThermalExpansionCoeff) != 0) { CreatePropertyWarning("Isotropy", "Material", bhName); } } else if (material is IOrthotropic) { IOrthotropic orthoTropic = material as IOrthotropic; double[] e = orthoTropic.YoungsModulus.ToDoubleArray(); double[] v = orthoTropic.PoissonsRatio.ToDoubleArray(); double[] a = orthoTropic.ThermalExpansionCoeff.ToDoubleArray(); double[] g = orthoTropic.ShearModulus.ToDoubleArray(); if (m_model.PropMaterial.SetMPOrthotropic(bhName, ref e, ref v, ref a, ref g) != 0) { CreatePropertyWarning("Orthotropy", "Material", bhName); } } // Set Material Strengths eMatType matType = MaterialTypeToCSI(material.IMaterialType()); switch (matType) { case eMatType.Aluminum: Engine.Base.Compute.RecordWarning("BHoM material aluminum does not have SAP2000 material parameters yet."); break; case eMatType.Steel: // try/catch for casting to steel? Steel steel = material as Steel; if (m_model.PropMaterial.SetOSteel_1(bhName, steel.YieldStress, steel.UltimateStress, steel.YieldStress, steel.UltimateStress, 0, 0, 0, 0, 0, 0, 0) != 0) { CreatePropertyWarning("YieldStress", "Material", bhName); CreatePropertyWarning("UltimateStress", "Material", bhName); } break; case eMatType.Concrete: Concrete concrete = material as Concrete; // name as NW/LW? if (m_model.PropMaterial.SetOConcrete_2(bhName, concrete.CylinderStrength, concrete.CylinderStrength, false, 0, 0, 0, 0, 0, 0) != 0) { CreatePropertyWarning("ConcreteStrength", "Material", bhName); } break; case eMatType.Rebar: Steel reinf = material as Steel; if (m_model.PropMaterial.SetORebar_1(bhName, reinf.YieldStress, reinf.UltimateStress, reinf.YieldStress, reinf.UltimateStress, 0, 0, 0, 0, 0, false) != 0) { CreatePropertyWarning("YieldStress", "Material", bhName); CreatePropertyWarning("UltimateStress", "Material", bhName); } break; case eMatType.Tendon: Steel tendon = material as Steel; if (m_model.PropMaterial.SetOTendon_1(bhName, tendon.YieldStress, tendon.UltimateStress, 0, 0, 0) != 0) { CreatePropertyWarning("YieldStress", "Material", bhName); CreatePropertyWarning("UltimateStress", "Material", bhName); } break; default: Engine.Base.Compute.RecordWarning("BHoM material type not found, no additional design material parameters passed to SAP2000."); m_model.PropMaterial.SetONoDesign(bhName, 0, 0, 0); break; } if (m_model.PropMaterial.SetWeightAndMass(bhName, 2, material.Density) != 0) { CreatePropertyWarning("Density", "Material", bhName); } SetAdapterId(material, material.Name); return(success); }
/***************************************************/ /**** Private Methods ****/ /***************************************************/ private IFAttribute CreateMaterial(IMaterialFragment material) { IFAttribute lusasMaterial = null; if (material is IIsotropic) { IIsotropic isotropic = material as IIsotropic; if (d_LusasData.existsAttribute("Material", material.DescriptionOrName())) { lusasMaterial = d_LusasData.getAttribute("Material", material.DescriptionOrName()); } else { if (CheckPropertyWarning(isotropic, x => x.YoungsModulus) && CheckPropertyWarning(isotropic, x => x.PoissonsRatio) && CheckPropertyWarning(isotropic, x => x.ThermalExpansionCoeff) && CheckPropertyWarning(isotropic, x => x.Density)) { lusasMaterial = d_LusasData.createIsotropicMaterial(material.DescriptionOrName(), isotropic.YoungsModulus, isotropic.PoissonsRatio, isotropic.Density, isotropic.ThermalExpansionCoeff); } } } else if (material is IOrthotropic) { IOrthotropic orthotropic = material as IOrthotropic; if (d_LusasData.existsAttribute("Material", material.DescriptionOrName())) { lusasMaterial = d_LusasData.getAttribute("Material", material.DescriptionOrName()); } else { if (CheckPropertyWarning(orthotropic, x => x.YoungsModulus) && CheckPropertyWarning(orthotropic, x => x.PoissonsRatio) && CheckPropertyWarning(orthotropic, x => x.ThermalExpansionCoeff) && CheckPropertyWarning(orthotropic, x => x.ShearModulus) && CheckPropertyWarning(orthotropic, x => x.Density)) { lusasMaterial = d_LusasData.createOrthotropicAxisymmetricMaterial(material.DescriptionOrName(), orthotropic.YoungsModulus.X, orthotropic.YoungsModulus.Y, orthotropic.YoungsModulus.Z, orthotropic.ShearModulus.X, orthotropic.PoissonsRatio.X, orthotropic.PoissonsRatio.Y, orthotropic.PoissonsRatio.Z, 0.0, orthotropic.Density, 0.0); lusasMaterial.setValue("ax", orthotropic.ThermalExpansionCoeff.X); lusasMaterial.setValue("ay", orthotropic.ThermalExpansionCoeff.Y); lusasMaterial.setValue("az", orthotropic.ThermalExpansionCoeff.Z); lusasMaterial.setValue("axy", System.Math.Sqrt(System.Math.Pow(orthotropic.ThermalExpansionCoeff.X, 2) + System.Math.Pow(orthotropic.ThermalExpansionCoeff.Y, 2))); } } } if (lusasMaterial != null) { int adapterIdName = lusasMaterial.getID(); material.SetAdapterId(typeof(LusasId), adapterIdName); return(lusasMaterial); } return(null); }
/***************************************************/ /**** Private methods ****/ /***************************************************/ private bool CreateObject(ISectionProperty sectionProperty) { int secPropId = GetAdapterId <int>(sectionProperty); int err = 0; // creating new beam property. Do not showing an error for update err = St7.St7NewBeamProperty(1, secPropId, St7.btBeam, sectionProperty.Name); if (err != St7.ERR7_NoError) { err = St7.St7SetPropertyName(1, St7.ptBEAMPROP, secPropId, sectionProperty.Name); if (!St7ErrorCustom(err, "Could not create or update section property number " + secPropId)) { return(false); } } // check first that the material is isotropic if (!(sectionProperty.Material is IIsotropic)) { BHError("Material in section property number " + secPropId + " is not Isotropic."); return(false); } // set material to section property IIsotropic isotropic = sectionProperty.Material as IIsotropic; double[] materialVals = new double[9]; materialVals[St7.ipBeamModulus] = isotropic.YoungsModulus; materialVals[St7.ipBeamPoisson] = isotropic.PoissonsRatio; materialVals[St7.ipBeamDensity] = isotropic.Density; materialVals[St7.ipBeamAlpha] = isotropic.ThermalExpansionCoeff; err = St7.St7SetBeamMaterialData(1, secPropId, materialVals); if (!St7ErrorCustom(err, "Could not set material for a section property number " + secPropId)) { return(false); } err = St7.St7SetMaterialName(1, St7.ptBEAMPROP, secPropId, isotropic.Name); if (!St7ErrorCustom(err, "Could not set material name for a section property number " + secPropId)) { return(false); } err = St7.St7SetBeamUsePoisson(1, secPropId); if (!St7ErrorCustom(err, "Could not set Poisson ratio usage for a section property number " + secPropId)) { return(false); } // section property geometry set (double[], int, string)tuple = GetDimensionsFromSection(sectionProperty as dynamic); (double[] dimensions, int sectionType, string profileName) = tuple; err = St7.St7SetBeamSectionGeometry(1, secPropId, sectionType, dimensions); if (!St7ErrorCustom(err, "Could not set section geometry " + secPropId)) { return(false); } err = St7.St7SetBeamSectionName(1, secPropId, profileName); // set section properties int[] intBeamSec = new int[] { 0 }; double[] beamSecData = new double[11]; beamSecData[St7.ipAREA] = sectionProperty.Area; beamSecData[St7.ipI11] = sectionProperty.Iy; beamSecData[St7.ipI22] = sectionProperty.Iz; beamSecData[St7.ipJ] = sectionProperty.J; beamSecData[St7.ipSL1] = 0; //shear centre offset beamSecData[St7.ipSL2] = 0; //shear centre offset beamSecData[St7.ipSA1] = 0; // sectionProperty.Asy; beamSecData[St7.ipSA2] = 0; // sectionProperty.Asz; beamSecData[St7.ipXBAR] = sectionProperty.Vpy; //centroid X beamSecData[St7.ipYBAR] = sectionProperty.Vpz; //centroid Y beamSecData[St7.ipANGLE] = 0; // principal axes rotation err = St7.St7SetBeamSectionPropertyData(1, secPropId, intBeamSec, beamSecData); if (!St7ErrorCustom(err, "Could not set section properties " + secPropId)) { return(false); } return(true); }
/***************************************************/ /**** Private methods ****/ /***************************************************/ private bool CreateObject(ISurfaceProperty surfaceProperty) { int uID = 1; int platePropId = GetAdapterId <int>(surfaceProperty); int err = 0; if (surfaceProperty is ConstantThickness == false) { BHError("Only constant thickness plate properties are allowed in Strand7"); return(false); } // check first that the material is isotropic if (surfaceProperty.Material is IIsotropic == false) { BHError("Material in surface property number " + platePropId + " is not Isotropic."); return(false); } // creating new plate property. Do not showing an error for update err = St7.St7NewPlateProperty(uID, platePropId, St7.ptPlateShell, St7.mtIsotropic, surfaceProperty.Name); if (err != St7.ERR7_NoError) { err = St7.St7SetPropertyName(uID, St7.ptPLATEPROP, platePropId, surfaceProperty.Name); if (!St7ErrorCustom(err, "Could not create or update surface property number " + platePropId)) { return(false); } } // set material to section property IIsotropic isotropic = surfaceProperty.Material as IIsotropic; double[] materialVals = new double[8]; materialVals[St7.ipPlateIsoModulus] = isotropic.YoungsModulus; materialVals[St7.ipPlateIsoPoisson] = isotropic.PoissonsRatio; materialVals[St7.ipPlateIsoDensity] = isotropic.Density; materialVals[St7.ipPlateIsoAlpha] = isotropic.ThermalExpansionCoeff; materialVals[St7.ipPlateIsoDampingRatio] = isotropic.DampingRatio; err = St7.St7SetPlateIsotropicMaterial(uID, platePropId, materialVals); if (!St7ErrorCustom(err, "Could not set material for a plate property number " + platePropId)) { return(false); } err = St7.St7SetMaterialName(1, St7.ptPLATEPROP, platePropId, isotropic.Name); if (!St7ErrorCustom(err, "Could not set material name for a plate property number " + platePropId)) { return(false); } // set plate thickness double thickness = (surfaceProperty as ConstantThickness).Thickness; double[] plateThickness = new double[] { thickness, thickness }; err = St7.St7SetPlateThickness(uID, platePropId, plateThickness); if (!St7ErrorCustom(err, "Could not set plate thickness " + platePropId)) { return(false); } return(true); }