Esempio n. 1
0
        /// <summary>
        /// Adds the chemical new.
        /// </summary>
        /// <param name="exportData">The export data.</param>
        /// <param name="Models">The models.</param>
        private static void AddChemicalNew(IList <Models.ExportPropertyGeneral> properties, XElement Models, string baseElement)
        {
            if (properties.Where(p => p.Type == TMPropertyTypeEnum.ChemicalCompositions).Any())
            {
                XElement Model = new XElement("Model");
                Model.SetAttributeValue("IDref", "Composition");
                XElement SubModels       = new XElement("SubModels");
                XElement ModelInSubModel = new XElement("Model");
                ModelInSubModel.SetAttributeValue("Active", "true");
                //KtmDataContext db = new KtmDataContext();
                ModelInSubModel.SetAttributeValue("IDref", baseElement + "_Model");

                ExportPropertyGeneral property = properties.Where(p => p.Type == TMPropertyTypeEnum.ChemicalCompositions).FirstOrDefault();


                foreach (var item in property.Values)
                {
                    XElement DatasetSi = new XElement("Dataset");
                    DatasetSi.SetAttributeValue("IDref", item.X.Replace("Composition: ", "") + "_weight_content");
                    XElement FloatSi    = new XElement("Float");
                    XElement ConstantSi = new XElement("Constant");
                    XElement ValueSi    = new XElement("Value");
                    ValueSi.Value = item.Y.ToString();
                    ConstantSi.Add(ValueSi);
                    FloatSi.Add(ConstantSi);
                    DatasetSi.Add(FloatSi);
                    ModelInSubModel.Add(DatasetSi);
                }


                SubModels.Add(ModelInSubModel);
                Model.Add(SubModels);
                Models.Add(Model);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Formats the property value.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <returns></returns>
        private static string FormatPropertyValue(ExportPropertyGeneral property)
        {
            if (property != null)
            {
                double propDouble = double.Parse(property.Value);
                bool   isInt      = propDouble == (int)propDouble;
                switch (property.Type)
                {
                case PropertyTypeEnum.None:
                    break;

                case PropertyTypeEnum.PhysicalModulusOfElasticity:
                    return((double.Parse(property.Value) * 1000000000).ToString() + POINT);

                case PropertyTypeEnum.PhysicalPoissonCoefficient:
                    if (isInt)
                    {
                        return(property.Value + POINT);
                    }
                    else
                    {
                        return(property.Value);
                    }

                case PropertyTypeEnum.PhysicalDensity:
                    return((double.Parse(property.Value) * 1000).ToString() + POINT);

                case PropertyTypeEnum.PhysicalMeanCoeffThermalExpansion:
                    return((double.Parse(property.Value) / 1000000).ToString("F8", System.Globalization.CultureInfo.InvariantCulture));

                case PropertyTypeEnum.PhysicalThermalConductivity:
                    if (isInt)
                    {
                        return(property.Value + POINT);
                    }
                    else
                    {
                        return(property.Value);
                    }

                case PropertyTypeEnum.PhysicalSpecificThermalCapacity:

                    if (isInt)
                    {
                        return(property.Value + POINT);
                    }
                    else
                    {
                        return(property.Value);
                    }

                default:
                    return("0.");
                }
            }

            return("0.");
        }
        /// <summary>
        /// Formats the octet.
        /// </summary>
        /// <param name="export">The export.</param>
        /// <param name="exportType">Type of the export.</param>
        /// <returns></returns>
        private static string FormatOctet(ExportPropertyGeneral property, TypeOfOctet octetType)
        {
            double Num;
            string propertyValue = null;

            if (property != null)
            {
                propertyValue = property.Value;
            }
            return(propertyValue != null && double.TryParse(propertyValue, out Num) ? FillOctet(double.Parse(propertyValue), octetType) : EMPTYOCTET);
        }
Esempio n. 4
0
        /// <summary>
        /// Formats the octet.
        /// </summary>
        /// <param name="export">The export.</param>
        /// <param name="exportType">Type of the export.</param>
        /// <returns></returns>
        private static string FormatOctet(IList <ExportPropertyGeneral> properties, TMPropertyTypeEnum exportType, TypeOfOctet octetType)
        {
            double Num;
            string propertyValue           = null;
            ExportPropertyGeneral property = (from u in properties where u.Type == exportType select u).FirstOrDefault();

            if (property != null)
            {
                propertyValue = property.Value;
                return(propertyValue != null && double.TryParse(propertyValue, out Num) ? FillOctet(double.Parse(propertyValue), octetType, exportType) : EMPTYOCTET);
            }
            else
            {
                return(ZERO);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Fills the meta data.
        /// </summary>
        /// <param name="Metadata">The metadata.</param>
        private static void FillMetaData(XElement Metadata, IList <ExportPropertyGeneral> properties)
        {
            IList <ANSYSParameterDetail> ListOfParametersDetails = FillListOFParameterDetails();

            //firstly goes parameters
            foreach (var item in from u in ListOfParametersDetails where u.IdPrefix == "pa" select u)
            {
                //For young and poison and for plastic strain we show  more matadatas (first four)
                if ((item.IdString == "pa0" || item.IdString == "pa1" || item.IdString == "pa2" || item.IdString == "pa3" || item.IdString == "pa4") && (from u in properties where u.Type == TMPropertyTypeEnum.PhysicalModulusOfElasticity || u.Type == TMPropertyTypeEnum.PhysicalPoissonCoefficient || u.Type == TMPropertyTypeEnum.PhysicalDensity select u).Any())
                {
                    AddMetaDataXMLNode(Metadata, item);
                } // For plastic we show temperature too
                else if (item.IdString == "pa0" && ((from u in properties where u.Type == TMPropertyTypeEnum.PlasticStrainStress select u).Any()))
                {
                    AddMetaDataXMLNode(Metadata, item);
                }
                else
                {
                    //for other proeprties we show only one matadata
                    ExportPropertyGeneral prop = (from u in properties where u.Type == item.Type select u).FirstOrDefault();
                    if (prop != null)
                    {
                        AddMetaDataXMLNode(Metadata, item);
                    }
                }
            }
            //then goes properties
            foreach (var item in from u in ListOfParametersDetails where u.IdPrefix == "pr" select u)
            {
                if ((item.Type == TMPropertyTypeEnum.None && item.Id == 1 && ((from u in properties where u.Type == TMPropertyTypeEnum.PhysicalPoissonCoefficient select u).Count() > 0 || (from u in properties where u.Type == TMPropertyTypeEnum.PhysicalModulusOfElasticity select u).Count() > 0 || (from u in properties where u.Type == TMPropertyTypeEnum.PhysicalDensity select u).Count() > 0)) || (item.Type == TMPropertyTypeEnum.None && item.Id == 2 && (from u in properties where u.Type == TMPropertyTypeEnum.PlasticStrainStress select u).Count() > 0) || (item.Type == TMPropertyTypeEnum.None && item.Id == 3 && (from u in properties where u.Type == TMPropertyTypeEnum.FatigueStressPoints select u).Count() > 0) || (item.Type == TMPropertyTypeEnum.None && item.Id == 4 && (from u in properties where u.Type == TMPropertyTypeEnum.FatigueStrengthCoefficient select u).Count() > 0))
                {
                    AddMetaDataXMLNode(Metadata, item);
                }
                else
                {
                    ExportPropertyGeneral prop = (from u in properties where u.Type == item.Type select u).FirstOrDefault();
                    //only if I have property than should be in the list
                    if (prop != null)
                    {
                        AddMetaDataXMLNode(Metadata, item);
                    }
                }
            }
        }
        private IList <ExportPropertyGeneral> MapProperites(IList <ElsevierMaterials.Models.Domain.Export.Property> propertiesEls, int sourceId)
        {
            IList <ExportPropertyGeneral> properties = new List <ExportPropertyGeneral>();

            foreach (var property in propertiesEls)
            {
                ExportPropertyGeneral prop = new ExportPropertyGeneral();

                //TODO: Vise ti Basic Info ne treba jer sve imas u els info
                prop.Value       = property.Value;
                prop.Temperature = property.Temperature;
                prop.Name        = property.ElsBasicInfo.Name;
                prop.Unit        = property.ElsBasicInfo.Unit;

                int notMappedPropertyId       = property.ElsBasicInfo.SourceTypeId != 0 ? property.ElsBasicInfo.SourceTypeId : property.ElsBasicInfo.TypeId;
                TMPropertyTypeEnum propertyId = MapElsPropertyId(notMappedPropertyId, (SourceTypeEnum)sourceId);

                prop.Type = propertyId;

                properties.Add(prop);
            }
            return(properties);
        }
        private static string FormatOctetMATHF(PropertyTypeEnum exportPropertyType, TypeOfOctet octetType, ExportPropertyGeneral property)
        {
            double Num;
            string propertyValue = null;
            double value         = 0;



            if (property != null)
            {
                propertyValue = property.Value;
                value         = double.Parse(propertyValue);
                if (exportPropertyType == PropertyTypeEnum.PhysicalModulusOfElasticity)
                {
                    value = value * 1000;
                }
            }
            string emptyOctet = EMPTYOCTET;

            if (exportPropertyType != PropertyTypeEnum.PhysicalPoissonCoefficient)
            {
                emptyOctet = FillEmptySpace(0, octetType, 8);
            }


            return(propertyValue != null && double.TryParse(propertyValue, out Num) ? FillEmptySpace(value, octetType, 8) : emptyOctet);
        }
        public static string MATHFExport(IList <ExportPropertyGeneral> properties, string name, string standard)
        {
            MaterialTypePart = name + " " + standard;

            System.Text.StringBuilder str = new System.Text.StringBuilder();
            str.Append(HYPERFORM);
            str.Append(System.Environment.NewLine);
            str.Append(DOLAR);
            str.Append(System.Environment.NewLine);
            str.Append(DOLAR);
            str.Append(HFSOLVER);
            str.Append(System.Environment.NewLine);
            str.Append(DOLAR);
            str.Append(System.Environment.NewLine);
            str.Append(SCREENOUT);
            str.Append(System.Environment.NewLine);
            str.Append(SUBCASE);
            str.Append(System.Environment.NewLine);
            str.Append(SPC);
            str.Append(System.Environment.NewLine);
            str.Append(BIGINBULK);
            str.Append(System.Environment.NewLine);



            ExportPropertyGeneral property = properties.Where(u => u.Type == PropertyTypeEnum.StressStrain).FirstOrDefault();

            if (property != null)
            {
                if (property.Values != null)
                {
                    str.Append(PARAMCOEFFC);
                    str.Append(System.Environment.NewLine);
                    str.Append(COMMENT);
                    str.Append(System.Environment.NewLine);
                    str.Append(HFCURVES);
                    str.Append(System.Environment.NewLine);
                    str.Append(TABLES);
                    str.Append(System.Environment.NewLine);

                    foreach (var item in property.Values)
                    {
                        str.Append("+,      ");

                        str.Append(FillEmptySpace(double.Parse(item.X), TypeOfOctet.Right, 8));
                        str.Append(",");
                        str.Append(FillEmptySpace(item.Y, TypeOfOctet.Right, 7));
                        str.Append(System.Environment.NewLine);
                    }

                    str.Append(ENDCOMMA);
                    str.Append(System.Environment.NewLine);
                }
            }


            str.Append(COMMENT2);
            str.Append(System.Environment.NewLine);
            str.Append(HFNAMEMATS);
            str.Append(MaterialTypePart.PadLeft(75));
            str.Append(System.Environment.NewLine);

            str.Append(MATHF);
            str.Append(1.ToString().PadLeft(8));

            str.Append(FormatOctetMATHF(PropertyTypeEnum.PhysicalModulusOfElasticity, TypeOfOctet.Right, properties.Where(u => u.Type == PropertyTypeEnum.PhysicalModulusOfElasticity).FirstOrDefault()));
            str.Append(FormatOctetMATHF(PropertyTypeEnum.PhysicalPoissonCoefficient, TypeOfOctet.Right, properties.Where(u => u.Type == PropertyTypeEnum.PhysicalPoissonCoefficient).FirstOrDefault()));
            str.Append(FormatOctetMATHF(PropertyTypeEnum.MechanicalYield, TypeOfOctet.Right, properties.Where(u => u.Type == PropertyTypeEnum.MechanicalYield).FirstOrDefault()));
            str.Append(EMPTYOCTET);
            str.Append(EMPTYOCTET);
            str.Append(EMPTYOCTET);
            str.Append(System.Environment.NewLine);

            if (property == null)
            {
                str.Append(ENDNUMMBERSWITHOUTSS);
            }
            else
            {
                str.Append(ENDNUMMBERS);
            }

            str.Append(System.Environment.NewLine);
            str.Append(COMMENT3);
            str.Append(System.Environment.NewLine);
            str.Append(ENDDATA);
            return(str.ToString());
        }
Esempio n. 9
0
        private static string FillStressStrainParameters(string parameter, string variableType, ref XElement Data, ExportPropertyGeneral property)
        {
            foreach (var item in property.Values)
            {
                if (parameter == "pa6")
                {
                    if (Data.Value == "")
                    {
                        Data.Value = Data.Value + item.X;
                    }
                    else
                    {
                        Data.Value = Data.Value + "," + item.X;
                    }

                    if (variableType == "")
                    {
                        variableType = variableType + "Independent";
                    }
                    else
                    {
                        variableType = variableType + ",Independent";
                    }
                }
                if (parameter == "pa5")
                {
                    if (Data.Value == "")
                    {
                        Data.Value = Data.Value + item.Y * 1000000;
                    }
                    else
                    {
                        Data.Value = Data.Value + "," + item.Y * 1000000;
                    }

                    if (variableType == "")
                    {
                        variableType = variableType + "Dependent";
                    }
                    else
                    {
                        variableType = variableType + ",Dependent";
                    }
                }
                if (parameter == "pa0")
                {
                    if (Data.Value == "")
                    {
                        Data.Value = Data.Value + property.Temperature;
                    }
                    else
                    {
                        Data.Value = Data.Value + "," + property.Temperature;
                    }
                    if (variableType == "")
                    {
                        variableType = variableType + "Independent";
                    }
                    else
                    {
                        variableType = variableType + ",Independent";
                    }
                }
            }
            return(variableType);
        }
Esempio n. 10
0
        /// <summary>
        /// Fills the property data.
        /// </summary>
        /// <param name="BulkDetails">The bulk details.</param>
        private static void FillPropertyData(XElement BulkDetails, IList <ExportPropertyGeneral> properties, int vkKey)
        {
            //Physical Density
            if ((from u in properties where u.Type == TMPropertyTypeEnum.PhysicalDensity select u).Any())
            {
                ExportPropertyGeneral propertyDensity = (from u in properties where u.Type == TMPropertyTypeEnum.PhysicalDensity select u).FirstOrDefault();
                CreatePropertyData(vkKey, properties, BulkDetails, (Double.Parse(propertyDensity.Value) * 1000).ToString(), "float", "pr0", new ANSYSQualifier()
                {
                    Value = "Dependent", Name = "Variable Type"
                });
            }

            //Physical
            if ((from u in properties where u.Type == TMPropertyTypeEnum.PhysicalDensity || u.Type == TMPropertyTypeEnum.PhysicalModulusOfElasticity || u.Type == TMPropertyTypeEnum.PhysicalPoissonCoefficient select u).Any())
            {
                CreatePropertyData(vkKey, properties, BulkDetails, "-", "string", "pr1", new ANSYSQualifier()
                {
                    Value = "Isotropic", Name = "Behavior"
                }, new ANSYSQualifier()
                {
                    Value = "Young's Modulus and Poisson's Ratio", Name = "Derive from"
                });
            }



            //Physical Thermal Conductivity
            if ((from u in properties where u.Type == TMPropertyTypeEnum.PhysicalThermalConductivity select u).Any())
            {
                string tmpValue     = "";
                string tmpQualifier = "";

                foreach (var prop in properties.Where(p => p.Type == TMPropertyTypeEnum.PhysicalThermalConductivity))
                {
                    tmpQualifier += ",Dependent";
                    tmpValue     += "," + Double.Parse(prop.Value).ToString();
                }
                tmpValue     = tmpValue.Trim().TrimStart(',');
                tmpQualifier = tmpQualifier.Trim().TrimStart(',');

                CreatePropertyData(vkKey, properties, BulkDetails, "-", "string", "pr20", new ANSYSQualifier()
                {
                    Value = "Isotropic", Name = "Behavior"
                });
            }


            //Physical PropertiesOfficial Mean Coefficient
            if ((from u in properties where u.Type == TMPropertyTypeEnum.PhysicalMeanCoeffThermalExpansion select u).Any())
            {
                CreatePropertyData(vkKey, properties, BulkDetails, "-", "string", "pr21", new ANSYSQualifier()
                {
                    Value = "Secant", Name = "Definition"
                }, new ANSYSQualifier()
                {
                    Value = "Isotropic", Name = "Behavior"
                });
                CreatePropertyData(vkKey, properties, BulkDetails, "-", "string", "pr22", new ANSYSQualifier()
                {
                    Value = "Secant", Name = "Definition"
                }, new ANSYSQualifier()
                {
                    Value = "Isotropic", Name = "Behavior"
                });
            }


            //Physical Specific Thermal Capacity
            if ((from u in properties where u.Type == TMPropertyTypeEnum.PhysicalSpecificThermalCapacity select u).Any())
            {
                string tmpValue     = "";
                string tmpQualifier = "";

                foreach (var prop in properties.Where(p => p.Type == TMPropertyTypeEnum.PhysicalSpecificThermalCapacity))
                {
                    tmpQualifier += ",Dependent";
                    tmpValue     += "," + Double.Parse(prop.Value).ToString();
                }
                tmpValue     = tmpValue.Trim().TrimStart(',');
                tmpQualifier = tmpQualifier.Trim().TrimStart(',');


                CreatePropertyData(vkKey, properties, BulkDetails, tmpValue, "float", "pr26", new ANSYSQualifier()
                {
                    Value = tmpQualifier, Name = "Variable Type"
                });
            }
            //Stress Strain
            if ((from u in properties where u.Type == TMPropertyTypeEnum.PlasticStrainStress select u).Any())
            {
                CreatePropertyData(vkKey, properties, BulkDetails, "-", "string", "pr2", new ANSYSQualifier()
                {
                    Value = "Multilinear", Name = "Definition"
                });
            }
            //Fatigue stress
            if ((from u in properties where u.Type == TMPropertyTypeEnum.FatigueStressPoints select u).Any())
            {
                CreatePropertyData(vkKey, properties, BulkDetails, "-", "string", "pr3", new ANSYSQualifier()
                {
                    Value = "Mean Stress", Name = "Definition"
                }, new ANSYSQualifier()
                {
                    Value = "Linear", Name = "Interpolation"
                });
            }
            //Fatigue strain
            if ((from u in properties where u.Type == TMPropertyTypeEnum.FatigueStrengthCoefficient || u.Type == TMPropertyTypeEnum.FatigueStrengthExponent || u.Type == TMPropertyTypeEnum.FatigueDuctilityCoefficient || u.Type == TMPropertyTypeEnum.FatigueDuctilityExponent || u.Type == TMPropertyTypeEnum.FatigueCyclicStrengthCoefficient || u.Type == TMPropertyTypeEnum.FatigueCyclicStrengthExponent select u).Any())
            {
                CreatePropertyData(vkKey, properties, BulkDetails, "-", "string", "pr4", new ANSYSQualifier()
                {
                    Value = "Strain-Life", Name = "Display Curve Type"
                });
            }
            //Mechanical Yiels
            if ((from u in properties where u.Type == TMPropertyTypeEnum.MechanicalYield select u).Any())
            {
                ExportPropertyGeneral propertyMechanicalYield = (from u in properties where u.Type == TMPropertyTypeEnum.MechanicalYield select u).FirstOrDefault();
                CreatePropertyData(vkKey, properties, BulkDetails, (Double.Parse(propertyMechanicalYield.Value) * 1000000).ToString(), "float", "pr5", new ANSYSQualifier()
                {
                    Value = "Dependent", Name = "Variable Type"
                });
            }
            //Mechanical Tensile
            if ((from u in properties where u.Type == TMPropertyTypeEnum.MechanicalTensile select u).Any())
            {
                ExportPropertyGeneral propertyMechanicalTensile = (from u in properties where u.Type == TMPropertyTypeEnum.MechanicalTensile select u).FirstOrDefault();
                CreatePropertyData(vkKey, properties, BulkDetails, (Double.Parse(propertyMechanicalTensile.Value) * 1000000).ToString(), "float", "pr6", new ANSYSQualifier()
                {
                    Value = "Dependent", Name = "Variable Type"
                });
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Creates the parameter value.
        /// </summary>
        /// <param name="PropertyData">The property data.</param>
        /// <param name="parameter">The parameter.</param>
        /// <param name="format">The format.</param>
        /// <param name="exportType">Type of the export.</param>
        /// <param name="variableType">Type of the variable.</param>
        private static void CreateParameterValue(int vkKey, IList <ExportPropertyGeneral> properties, XElement PropertyData, string parameter, string format, TMPropertyTypeEnum exportType, string variableType)
        {
            XElement ParameterValue = new XElement("ParameterValue");

            ParameterValue.SetAttributeValue("parameter", parameter);
            ParameterValue.SetAttributeValue("format", format);
            XElement Data = new XElement("Data", "");

            ExportPropertyGeneral property = (from u in properties where u.Type == exportType select u).FirstOrDefault();

            if (property != null)
            {
                if (exportType == TMPropertyTypeEnum.PhysicalModulusOfElasticity)
                {
                    IList <ExportPropertyGeneral> list = (from u in properties where u.Type == exportType select u).ToList();
                    if (parameter == "pa0")
                    {
                        foreach (var prop in list)
                        {
                            if (list.IndexOf(prop) == 0)
                            {
                                if (vkKey < 1000000 && prop.Temperature == 999)
                                {
                                    Data.Value = "23";
                                }
                                else
                                {
                                    Data.Value = prop.Temperature.ToString();
                                }
                            }
                            else
                            {
                                Data.Value = Data.Value + "," + prop.Temperature.ToString();
                            }
                        }
                    }
                    else
                    {
                        foreach (var prop in list)
                        {
                            if (list.IndexOf(prop) == 0)
                            {
                                Data.Value = (Double.Parse(prop.Value) * 1000000000).ToString();
                            }
                            else
                            {
                                Data.Value = Data.Value + "," + (Double.Parse(prop.Value) * 1000000000).ToString();
                            }
                        }
                    }
                }
                else if (exportType == TMPropertyTypeEnum.PhysicalPoissonCoefficient)
                {
                    IList <ExportPropertyGeneral> list = (from u in properties where u.Type == TMPropertyTypeEnum.PhysicalModulusOfElasticity select u).ToList();

                    if (parameter == "pa2")
                    {
                        foreach (var prop in list)
                        {
                            if (list.IndexOf(prop) == 0)
                            {
                                Data.Value = property.Value;
                            }
                            else
                            {
                                Data.Value = Data.Value + "," + property.Value;
                            }
                        }
                    }
                }
                else if (exportType == TMPropertyTypeEnum.PhysicalSpecificThermalCapacity)
                {
                    IList <ExportPropertyGeneral> list = (from u in properties where u.Type == exportType select u).ToList();
                    if (parameter == "pa26")
                    {
                        foreach (var prop in list)
                        {
                            if (list.IndexOf(prop) == 0)
                            {
                                if (vkKey < 1000000 && prop.Temperature == 999)
                                {
                                    Data.Value = "23";
                                }
                                else
                                {
                                    Data.Value = prop.Temperature.ToString();
                                }
                            }
                            else
                            {
                                Data.Value = Data.Value + "," + prop.Temperature.ToString();
                            }
                        }
                    }
                    else
                    {
                        foreach (var prop in list)
                        {
                            if (list.IndexOf(prop) == 0)
                            {
                                Data.Value = prop.Value.ToString();
                            }
                            else
                            {
                                Data.Value = Data.Value + "," + prop.Value.ToString();
                            }
                        }
                    }
                }
                else if (exportType == TMPropertyTypeEnum.PhysicalThermalConductivity)
                {
                    IList <ExportPropertyGeneral> list = (from u in properties where u.Type == exportType select u).ToList();
                    if (parameter == "pa21")
                    {
                        foreach (var prop in list)
                        {
                            if (list.IndexOf(prop) == 0)
                            {
                                if (vkKey < 1000000 && prop.Temperature == 999)
                                {
                                    Data.Value = "23";
                                }
                                else
                                {
                                    Data.Value = prop.Temperature.ToString();
                                }
                            }
                            else
                            {
                                Data.Value = Data.Value + "," + prop.Temperature.ToString();
                            }
                        }
                    }
                    else
                    {
                        foreach (var prop in list)
                        {
                            if (list.IndexOf(prop) == 0)
                            {
                                Data.Value = prop.Value.ToString();
                            }
                            else
                            {
                                Data.Value = Data.Value + "," + prop.Value.ToString();
                            }
                        }
                    }
                }
                else if (exportType == TMPropertyTypeEnum.PhysicalMeanCoeffThermalExpansion)
                {
                    IList <ExportPropertyGeneral> list = (from u in properties where u.Type == exportType select u).ToList();
                    if (parameter == "pa25")
                    {
                        foreach (var prop in list)
                        {
                            if (list.IndexOf(prop) == 0)
                            {
                                if (vkKey < 1000000 && prop.Temperature == 999)
                                {
                                    Data.Value = "23";
                                }
                                else
                                {
                                    Data.Value = prop.Temperature.ToString();
                                }
                            }
                            else
                            {
                                Data.Value = Data.Value + "," + prop.Temperature.ToString();
                            }
                        }
                    }
                    else if (parameter == "pa23")
                    {
                        if (vkKey < 1000000)
                        {
                            if (property.Temperature == 999)
                            {
                                Data.Value = "23";
                            }
                            else
                            {
                                Data.Value = property.Temperature.ToString();
                            }
                        }
                        else
                        {
                            Data.Value = "20";
                        }
                    }
                    else if (parameter == "pa24")
                    {
                        Data.Value = "Coefficient of Thermal Expansion";
                    }
                    else
                    {
                        foreach (var prop in list)
                        {
                            if (list.IndexOf(prop) == 0)
                            {
                                Data.Value = string.Format(CultureInfo.InvariantCulture, "{0:0.###e+00}", Double.Parse(prop.Value) / 1000000);
                            }
                            else
                            {
                                Data.Value = Data.Value + "," + string.Format(CultureInfo.InvariantCulture, "{0:0.###e+00}", Double.Parse(prop.Value) / 1000000);
                            }
                        }
                    }
                }
                else if (exportType == TMPropertyTypeEnum.FatigueStrengthCoefficient || exportType == TMPropertyTypeEnum.FatigueCyclicStrengthCoefficient)
                {
                    Data.Value = (Double.Parse(property.Value) * 1000000).ToString();
                }

                else if (exportType == TMPropertyTypeEnum.FatigueCyclicStrengthExponent)
                {
                    Data.Value = string.Format("{0:f4}", double.Parse(property.Value));
                }
                else if (exportType == TMPropertyTypeEnum.PhysicalDensity)
                {
                    Data.Value = "-";
                }
                else if (exportType == TMPropertyTypeEnum.PlasticStrainStress)
                {
                    IList <ExportPropertyGeneral> list = (from u in properties where u.Type == exportType select u).ToList();
                    Data.Value = "";
                    foreach (var prop in list)
                    {
                        variableType = FillStressStrainParameters(parameter, variableType, ref Data, prop);
                    }
                }
                else if (exportType == TMPropertyTypeEnum.FatigueStressPoints)
                {
                    Data.Value = "";

                    foreach (var item in property.Values)
                    {
                        if (parameter == "pa8")
                        {
                            string valueX = "1";
                            for (int i = 1; i < double.Parse(item.X); i++)
                            {
                                valueX = valueX + "0";
                            }
                            if (Data.Value == "")
                            {
                                Data.Value = Data.Value + valueX;
                            }
                            else
                            {
                                Data.Value = Data.Value + "," + valueX;
                            }

                            if (variableType == "")
                            {
                                variableType = variableType + "Independent";
                            }
                            else
                            {
                                variableType = variableType + ",Independent";
                            }
                        }
                        if (parameter == "pa7")
                        {
                            if (Data.Value == "")
                            {
                                Data.Value = Data.Value + item.Y * 1000000;
                            }
                            else
                            {
                                Data.Value = Data.Value + "," + item.Y * 1000000;
                            }

                            if (variableType == "")
                            {
                                variableType = variableType + "Dependent";
                            }
                            else
                            {
                                variableType = variableType + ",Dependent";
                            }
                        }
                        if (parameter == "pa9")
                        {
                            if (Data.Value == "")
                            {
                                Data.Value = Data.Value + 0;
                            }
                            else
                            {
                                Data.Value = Data.Value + "," + 0;
                            }
                            if (variableType == "")
                            {
                                variableType = variableType + "Independent";
                            }
                            else
                            {
                                variableType = variableType + ",Independent";
                            }
                        }
                    }
                }
                else
                {
                    Data.Value = property.Value;
                }
            }


            XElement Qualifier = new XElement("Qualifier");

            Qualifier.SetAttributeValue("name", "Variable Type");
            Qualifier.Value = variableType;
            ParameterValue.Add(Data);
            ParameterValue.Add(Qualifier);
            PropertyData.Add(ParameterValue);
        }
Esempio n. 12
0
        /// <summary>
        /// Formats the value.
        /// </summary>
        /// <param name="ExportType">Type of the export.</param>
        /// <param name="subtype">The subtype.</param>
        /// <returns></returns>
        private static string FormatValue(IList <ExportPropertyGeneral> properties, PropertyTypeEnum ExportType, StressStrainType subtype = StressStrainType.None)
        {
            ExportPropertyGeneral property = (from u in properties where u.Type == ExportType select u).FirstOrDefault();


            string value       = "";
            string temperature = "";

            if (property != null)
            {
                value       = property.Value;
                temperature = property.Temperature.ToString();
            }

            switch (ExportType)
            {
            case PropertyTypeEnum.None:
                break;

            case PropertyTypeEnum.PhysicalModulusOfElasticity:
                if (value != null && value != "")
                {
                    value = (double.Parse(value) * 1000).ToString() + RIGHTZERO;
                }
                else
                {
                    value = FORMATEDZERO;
                }
                return(value);

            case PropertyTypeEnum.PhysicalPoissonCoefficient:
                if (value == null || value == "")
                {
                    value = FORMATEDZERO;
                }
                return(value);

            case PropertyTypeEnum.PhysicalDensity:
                if (value == null || value == "")
                {
                    value = FORMATEDZERO;
                }
                else
                {
                    value = value + "e-09,";
                }
                return(value);

            case PropertyTypeEnum.PlasticStrainStress:
                if (property != null)
                {
                    string table = "";
                    foreach (var item in property.Values)
                    {
                        table = table + item.Y + ", \t" + string.Format("{0:f4}", double.Parse(item.X)) + ", \t" + property.Temperature + System.Environment.NewLine;
                    }
                    return(table);
                }
                return("0, \t0.0000, \t0");

            default:
                break;
            }
            return(FORMATEDZERO);
        }
Esempio n. 13
0
        public static string FillESIPamCrash(int vkKey, string standard, string name, IList <ExportPropertyGeneral> properties)
        {
            ExportPropertyGeneral propertyDensity             = (from u in properties where u.Type == TMPropertyTypeEnum.PhysicalDensity select u).FirstOrDefault();
            ExportPropertyGeneral propertySpecificHeat        = (from u in properties where u.Type == TMPropertyTypeEnum.PhysicalSpecificThermalCapacity select u).FirstOrDefault();
            ExportPropertyGeneral propertyThermalConductivity = (from u in properties where u.Type == TMPropertyTypeEnum.PhysicalThermalConductivity select u).FirstOrDefault();
            ExportPropertyGeneral propertyModulusOfElasticity = (from u in properties where u.Type == TMPropertyTypeEnum.PhysicalModulusOfElasticity select u).FirstOrDefault();
            ExportPropertyGeneral propertyPoisson             = (from u in properties where u.Type == TMPropertyTypeEnum.PhysicalPoissonCoefficient select u).FirstOrDefault();
            ExportPropertyGeneral propertyStressStrain        = (from u in properties where u.Type == TMPropertyTypeEnum.StressStrain select u).FirstOrDefault();

            string exportString = "";

            if (propertyThermalConductivity != null || propertyDensity != null || propertySpecificHeat != null)
            {
                //StringBuilder sb  = new s
                exportString = exportString + THMAT + vkKey.ToString().PadLeft(8) + System.Environment.NewLine;
                exportString = exportString + NAME + name.Replace(" ", "_") + "_" + standard + System.Environment.NewLine;


                if (propertyDensity != null)
                {
                    exportString = exportString + MASS_DENSITY + System.Environment.NewLine + (String.Format(CultureInfo.InvariantCulture, "{0:0.###E+0}", Double.Parse(propertyDensity.Value) / 1000000)).PadLeft(10) + System.Environment.NewLine;
                }


                if (propertySpecificHeat != null)
                {
                    exportString = exportString + SPECIFIC_HEAT + System.Environment.NewLine + propertySpecificHeat.Value.PadLeft(10) + System.Environment.NewLine;
                }


                if (propertyThermalConductivity != null)
                {
                    exportString = exportString + CONDUCTIVITY + System.Environment.NewLine + propertyThermalConductivity.Value.PadLeft(10) + System.Environment.NewLine;
                }

                exportString = exportString + END_THMAT + System.Environment.NewLine;
                exportString = exportString + System.Environment.NewLine;
            }



            if (propertyModulusOfElasticity != null || propertyPoisson != null || propertyDensity != null || propertyStressStrain != null)
            {
                exportString = exportString + MATER + vkKey.ToString().PadLeft(8) + VALUE212 + (propertyDensity != null ? (String.Format(CultureInfo.InvariantCulture, "{0:0.###e+00}", Double.Parse(propertyDensity.Value) / 1000000)).PadLeft(16) : "0.0".PadLeft(16)) + System.Environment.NewLine;
                exportString = exportString + System.Environment.NewLine;

                exportString = exportString + NAME + name.Replace(" ", "_") + "_" + standard + System.Environment.NewLine;

                exportString = exportString + (propertyModulusOfElasticity != null ? Double.Parse(propertyModulusOfElasticity.Value) * 1000 + ".0" : "0.0".PadLeft(10)).PadLeft(10) + (propertyPoisson != null ? propertyPoisson.Value : "0.0").PadLeft(10) + (propertyStressStrain != null ? "CURVE".PadLeft(10) : "0.0").PadLeft(10) + "         0       0.0" + System.Environment.NewLine;
                exportString = exportString + System.Environment.NewLine;
                exportString = exportString + System.Environment.NewLine;
                exportString = exportString + System.Environment.NewLine;
                exportString = exportString + (propertyStressStrain != null ?  VALUE101: "       0") + System.Environment.NewLine;
                exportString = exportString + ZERO + System.Environment.NewLine;

                if (propertyStressStrain != null)
                {
                    exportString = exportString + FUNCT101 + System.Environment.NewLine;

                    exportString = exportString + BARS + System.Environment.NewLine;
                    string val = "";
                    foreach (var item in propertyStressStrain.Values)
                    {
                        string x;
                        if (item.X == "0")
                        {
                            x = "0.0".PadLeft(32);
                        }
                        else
                        {
                            x = item.X.PadLeft(32);
                        }
                        val = val + x + (item.Y.ToString() + ".0").PadLeft(16) + System.Environment.NewLine;
                    }
                    exportString = exportString + val + END;
                }
            }

            return(exportString);
        }
Esempio n. 14
0
        /// <summary>
        /// Fills the femap.
        /// </summary>
        /// <returns></returns>
        public static string FillFEMAP(string standard, string name, IList <ExportPropertyGeneral> properties)
        {
            string exportString = VERSION + System.Environment.NewLine;

            exportString = exportString + DOLAR + ENGINEERING + System.Environment.NewLine;
            exportString = exportString + DOLAR + UPDATEDENSITY + System.Environment.NewLine;
            exportString = exportString + DOLAR + CORRECTSPECIFIC + System.Environment.NewLine;
            exportString = exportString + DOLAR + FOLLOWINGUNITS + System.Environment.NewLine;
            exportString = exportString + DOLAR + E + System.Environment.NewLine;
            exportString = exportString + DOLAR + G + System.Environment.NewLine;
            exportString = exportString + DOLAR + DIMENSIONLESS + System.Environment.NewLine;
            exportString = exportString + DOLAR + EXPANSIONCOEFFICIENT + System.Environment.NewLine;
            exportString = exportString + DOLAR + CONDUCTUIVITI + System.Environment.NewLine;
            exportString = exportString + DOLAR + SPECIFICHEAT + System.Environment.NewLine;
            exportString = exportString + DOLAR + STRESSLIMITS + System.Environment.NewLine;
            exportString = exportString + DOLAR + MASSDENSISTY + System.Environment.NewLine;
            exportString = exportString + DOLAR + REFERENCETEMPERATURE + System.Environment.NewLine;
            exportString = exportString + COM + name + System.Environment.NewLine;
            exportString = exportString + CONSTMINUS1 + System.Environment.NewLine;
            exportString = exportString + CONST601 + System.Environment.NewLine;
            exportString = exportString + CONST601104 + System.Environment.NewLine;
            exportString = exportString + name + System.Environment.NewLine;
            exportString = exportString + CONST10 + System.Environment.NewLine;
            exportString = exportString + ZERRODECTED + System.Environment.NewLine;
            exportString = exportString + CONST25 + System.Environment.NewLine;
            exportString = exportString + ZERRODECTED + System.Environment.NewLine;
            exportString = exportString + ZERRODECTED + System.Environment.NewLine;
            exportString = exportString + ZERROQUINTET + System.Environment.NewLine;
            exportString = exportString + CONST200 + System.Environment.NewLine;
            ExportPropertyGeneral young         = (from u in properties where u.Type == PropertyTypeEnum.PhysicalModulusOfElasticity select u).FirstOrDefault();
            ExportPropertyGeneral poison        = (from u in properties where u.Type == PropertyTypeEnum.PhysicalPoissonCoefficient select u).FirstOrDefault();
            ExportPropertyGeneral expansion     = (from u in properties where u.Type == PropertyTypeEnum.PhysicalMeanCoeffThermalExpansion select u).FirstOrDefault();
            ExportPropertyGeneral conductivity  = (from u in properties where u.Type == PropertyTypeEnum.PhysicalThermalConductivity select u).FirstOrDefault();
            ExportPropertyGeneral spoecificHeat = (from u in properties where u.Type == PropertyTypeEnum.PhysicalSpecificThermalCapacity select u).FirstOrDefault();
            ExportPropertyGeneral density       = (from u in properties where u.Type == PropertyTypeEnum.PhysicalDensity select u).FirstOrDefault();

            exportString = exportString + FormatPropertyValue(young) + COMMA + FormatPropertyValue(young) + COMMA + FormatPropertyValue(young) + COMMA + ZERRO + COMMA + ZERRO + COMMA + ZERRO + COMMA + FormatPropertyValue(poison) + COMMA + FormatPropertyValue(poison) + COMMA + FormatPropertyValue(poison) + COMMA + BR1 + COMMA + System.Environment.NewLine;
            exportString = exportString + BR2 + COMMA + BR2 + COMMA + ZERRO + COMMA + ZERRO + COMMA + ZERRO + COMMA + BR1 + COMMA + BR2 + COMMA + ZERRO + COMMA + ZERRO + COMMA + ZERRO + COMMA + System.Environment.NewLine;
            exportString = exportString + BR1 + COMMA + ZERRO + COMMA + ZERRO + COMMA + ZERRO + COMMA + BR3 + COMMA + ZERRO + COMMA + ZERRO + COMMA + BR3 + COMMA + ZERRO + COMMA + BR3 + COMMA + System.Environment.NewLine;
            exportString = exportString + BR5 + COMMA + BR4 + COMMA + ZERRO + COMMA + BR5 + COMMA + ZERRO + COMMA + BR3 + COMMA + FormatPropertyValue(expansion) + COMMA + ZERRO + COMMA + ZERRO + COMMA + FormatPropertyValue(expansion) + COMMA + System.Environment.NewLine;
            exportString = exportString + ZERRO + COMMA + FormatPropertyValue(expansion) + COMMA + FormatPropertyValue(conductivity) + COMMA + ZERRO + COMMA + ZERRO + COMMA + FormatPropertyValue(conductivity) + COMMA + ZERRO + COMMA + FormatPropertyValue(conductivity) + COMMA + FormatPropertyValue(spoecificHeat) + COMMA + FormatPropertyValue(density) + COMMA + System.Environment.NewLine;
            string temperature = "";

            if (young != null && young.Temperature > 0)
            {
                temperature = (young.Temperature + 273.15).ToString();
            }
            else if (poison != null && poison.Temperature > 0)
            {
                temperature = (poison.Temperature + 273.15).ToString();
            }
            else if (expansion != null && expansion.Temperature > 0)
            {
                temperature = (expansion.Temperature + 273.15).ToString();
            }
            else if (conductivity != null && conductivity.Temperature > 0)
            {
                temperature = (conductivity.Temperature + 273.15).ToString();
            }
            else if (spoecificHeat != null && spoecificHeat.Temperature > 0)
            {
                temperature = (spoecificHeat.Temperature + 273.15).ToString();
            }
            else if (density != null && density.Temperature > 0)
            {
                temperature = (density.Temperature + 273.15).ToString();
            }
            exportString = exportString + ZERRO + COMMA + temperature + COMMA + ZERROOCTETORMATED + System.Environment.NewLine;
            exportString = exportString + ZERRODECTEDFORMATED + System.Environment.NewLine;
            exportString = exportString + ZERRODECTEDFORMATED + System.Environment.NewLine;
            exportString = exportString + ZERRODECTEDFORMATED + System.Environment.NewLine;
            exportString = exportString + ZERRODECTEDFORMATED + System.Environment.NewLine;
            exportString = exportString + ZERRODECTEDFORMATED + System.Environment.NewLine;
            exportString = exportString + ZERRODECTEDFORMATED + System.Environment.NewLine;
            exportString = exportString + ZERRODECTEDFORMATED + System.Environment.NewLine;
            exportString = exportString + ZERRODECTEDFORMATED + System.Environment.NewLine;
            exportString = exportString + ZERRODECTEDFORMATED + System.Environment.NewLine;
            exportString = exportString + ZERRODECTEDFORMATED + System.Environment.NewLine;
            exportString = exportString + ZERRODECTEDFORMATED + System.Environment.NewLine;
            exportString = exportString + ZERRODECTEDFORMATED + System.Environment.NewLine;
            exportString = exportString + ZERRODECTEDFORMATED + System.Environment.NewLine;
            exportString = exportString + ZERRODECTEDFORMATED + System.Environment.NewLine;
            exportString = exportString + CONST50 + System.Environment.NewLine;
            exportString = exportString + ZERRODECTED + System.Environment.NewLine;
            exportString = exportString + ZERRODECTED + System.Environment.NewLine;
            exportString = exportString + ZERRODECTED + System.Environment.NewLine;
            exportString = exportString + ZERRODECTED + System.Environment.NewLine;
            exportString = exportString + ZERRODECTED + System.Environment.NewLine;
            exportString = exportString + CONST70 + System.Environment.NewLine;
            exportString = exportString + ZERRODECTED + System.Environment.NewLine;
            exportString = exportString + ZERRODECTED + System.Environment.NewLine;
            exportString = exportString + ZERRODECTED + System.Environment.NewLine;
            exportString = exportString + ZERRODECTED + System.Environment.NewLine;
            exportString = exportString + ZERRODECTED + System.Environment.NewLine;
            exportString = exportString + ZERRODECTED + System.Environment.NewLine;
            exportString = exportString + ZERRODECTED + System.Environment.NewLine;
            exportString = exportString + CONSTMINUS1 + System.Environment.NewLine;
            return(exportString);
        }