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 IOrthotropic orthoTropicMaterial) { return($"E: {orthoTropicMaterial.YoungsModulus.VectorComponents()}, " + $"ρ: { orthoTropicMaterial.Density:G3}, " + $"ν: { orthoTropicMaterial.PoissonsRatio.VectorComponents()}," + $"α: { orthoTropicMaterial.ThermalExpansionCoeff.VectorComponents()}," + $"ζ: { orthoTropicMaterial.DampingRatio:G3}"); }
/***************************************************/ /**** 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); }