public static bool RunDesign(string mode, Model fdModel, string struxmlPath, Calculate.Analysis analysis, Calculate.Design design, [DefaultArgument("[]")] List <string> bscPath, string docxTemplatePath = "", bool endSession = false, bool closeOpenWindows = false, bool runNode = true) { if (!runNode) { throw new System.ArgumentException("runNode is set to false!"); } fdModel.SerializeModel(struxmlPath); analysis.SetLoadCombinationCalculationParameters(fdModel); return(fdModel.FdApp.RunDesign(mode, struxmlPath, analysis, design, bscPath, docxTemplatePath, endSession, closeOpenWindows)); }
static void Main() { // PRACTICAL EXAMPLE: PARAMETRIC STUDY - SENSITIVITY ANALYSIS // In this example, we will analyse how different stiffness values on a support // will affect a bridge (modelled simply as a beam). // This example was last updated 2022-05-03, using the ver. 21.1.0 FEM-Design API. // FILE PATH SETUP // Set the different paths and folders relevant to the example string struxmlPath = "Bridge Model.struxml"; string bscPath = Path.GetFullPath("eigenfreq.bsc"); List <string> bscPaths = new List <string>(); bscPaths.Add(bscPath); // READ MODEL AND GET SUPPORTS Model model = Model.DeserializeFromFilePath(struxmlPath); //Read point support number and its stiffness properties var support1 = model.Entities.Supports.PointSupport.FirstOrDefault(p => p.Name == "S.1"); var support2 = model.Entities.Supports.PointSupport.FirstOrDefault(p => p.Name == "S.2"); double alpha = 0.5; // ITERATION AND ANALYSIS PROCESS // Iterate over model using different stiffness value for the the rotational spring cy int N = 20; for (int i = 1; i <= N; i++) { // Change stiffness of support cy support1.Rotations.YPos = Math.Pow(10, alpha); support1.Rotations.YNeg = Math.Pow(10, alpha); support2.Rotations.YPos = Math.Pow(10, alpha); support2.Rotations.YNeg = Math.Pow(10, alpha); var supports = new List <Supports.PointSupport>() { support1, support2 }; model.AddElements(supports); // Save struxml string outPathIndividual = Path.GetFullPath("Bridge Model_out" + Convert.ToString(alpha, System.Globalization.CultureInfo.InvariantCulture) + ".struxml"); model.SerializeModel(outPathIndividual); // Run analysis var freq = new Calculate.Freq(5, 0, false, false, true, -0.01); Calculate.Analysis analysis = new Calculate.Analysis(null, null, freq, null, true, false, false, false, false, false, true, false, false, false, false, false, false); FemDesign.Calculate.FdScript fdScript = FemDesign.Calculate.FdScript.Analysis(outPathIndividual, analysis, bscPaths, "", true); Calculate.Application app = new Calculate.Application(); app.RunFdScript(fdScript, false, true, true); // Read results from csv file (general method) { Console.WriteLine(""); Console.WriteLine(string.Format("Alpha: {0}", alpha)); string text = System.IO.File.ReadAllText(fdScript.CmdListGen[0].OutFile); Console.WriteLine(text); } alpha = alpha + 0.5; } // ENDING THE PROGRAM Console.WriteLine("\nPress any key to close console."); Console.ReadKey(); }
public static Dictionary <string, object> RunAnalysis(Model fdModel, string struxmlPath, Calculate.Analysis analysis, [DefaultArgument("[]")] List <Results.ResultType> resultTypes, [DefaultArgument("[]")] Results.UnitResults units, string docxTemplatePath = "", bool endSession = true, bool closeOpenWindows = false, bool runNode = true) { if (!runNode) { throw new System.ArgumentException("runNode is set to false!"); } fdModel.SerializeModel(struxmlPath); analysis.SetLoadCombinationCalculationParameters(fdModel); units = Results.UnitResults.Default(); // It needs to check if model has been runned // Always Return the FeaNode Result resultTypes.Insert(0, Results.ResultType.FeaNode); resultTypes.Insert(1, Results.ResultType.FeaBar); resultTypes.Insert(1, Results.ResultType.FeaShell); // Create Bsc files from resultTypes var listProcs = resultTypes.Select(r => Results.ResultAttributeExtentions.ListProcs[r]); var bscPathsFromResultTypes = Calculate.Bsc.BscPathFromResultTypes(resultTypes, struxmlPath, units); var rtn = fdModel.FdApp.RunAnalysis(struxmlPath, analysis, bscPathsFromResultTypes, docxTemplatePath, endSession, closeOpenWindows); // Create FdScript var fdScript = FemDesign.Calculate.FdScript.ReadStr(struxmlPath, bscPathsFromResultTypes); IEnumerable <Results.IResult> results = Enumerable.Empty <Results.IResult>(); List <Results.FeaNode> feaNodeRes = new List <Results.FeaNode>(); List <Results.FeaBar> feaBarRes = new List <Results.FeaBar>(); List <Results.FeaShell> feaShellRes = new List <Results.FeaShell>(); if (resultTypes != null && resultTypes.Any()) { foreach (var cmd in fdScript.CmdListGen) { string path = cmd.OutFile; try { if (path.Contains("FeaNode")) { feaNodeRes = Results.ResultsReader.Parse(path).Cast <Results.FeaNode>().ToList(); } else if (path.Contains("FeaBar")) { feaBarRes = Results.ResultsReader.Parse(path).Cast <Results.FeaBar>().ToList(); } else if (path.Contains("FeaShell")) { feaShellRes = Results.ResultsReader.Parse(path).Cast <Results.FeaShell>().ToList(); } else { var _results = Results.ResultsReader.Parse(path); results = results.Concat(_results); } } catch (Exception e) { throw new Exception(e.InnerException.Message); } } } var fdFeaModel = new FemDesign.Results.FDfea(feaNodeRes, feaBarRes, feaShellRes); var resultGroups = results.GroupBy(t => t.GetType()).ToList(); // Convert Data in NestedList structure var resultsTree = new List <List <Results.IResult> >(); var i = 0; foreach (var resGroup in resultGroups) { resultsTree.Add(resGroup.ToList()); i++; } return(new Dictionary <string, object> { { "FdModel", fdModel }, { "FdFeaModel", fdFeaModel }, { "Results", resultsTree }, { "HasExited", rtn } }); }
static void Main() { // PRACTICAL EXAMPLE: PARAMETRIC STUDY - REACTIONS // In this example, we will analyse how different E-modules will result // in different reaction forces in the supports holding a concrete plate. // This example was last updated 2022-05-03, using the ver. 21.1.0 FEM-Design API. // FILE PATH SETUP // Set the different paths and folders relevant to the example string struxmlPath = "sample_slab.struxml"; string outFolder = "output/"; if (!Directory.Exists(outFolder)) { Directory.CreateDirectory(outFolder); } string bscPath = Path.GetFullPath("pointsupportreactions.bsc"); List <string> bscPaths = new List <string>(); bscPaths.Add(bscPath); // READ MODEL Model model = Model.DeserializeFromFilePath(struxmlPath); // READ SLAB TO ANALYSE // In this example, the slab is card-coded to no. 5; if you make any personal applications, // it is probably better to look for a slab with a certain name, eg. P.1, to avoid confusion. Shells.Slab slab = model.Entities.Slabs[4]; Materials.Material material = model.Entities.Slabs[4].Material; double Ecm = Convert.ToDouble(material.Concrete.Ecm); // ITERATION & ANALYSIS PROCESS // Iterate over model using different E-modulus for the slab for (int i = 1; i < 6; i++) { // Change E-modulus double new_Ecm = Math.Round(0.2 * i * Ecm); material.Concrete.Ecm = Convert.ToString(new_Ecm); // Save struxml string outPathIndividual = Path.GetFullPath(outFolder + "sample_slab_out" + Convert.ToString(new_Ecm) + ".struxml"); model.SerializeModel(outPathIndividual); // Run analysis Calculate.Analysis analysis = new Calculate.Analysis(null, null, null, null, calcCase: true, false, false, false, false, false, false, false, false, false, false, false, false); FemDesign.Calculate.FdScript fdScript = FemDesign.Calculate.FdScript.Analysis(outPathIndividual, analysis, bscPaths, "", true); Calculate.Application app = new Calculate.Application(); app.RunFdScript(fdScript, false, true, true); string pointSupportReactionsPath = Path.Combine(outFolder, "pointsupportreactions.csv"); // Reading results (This method is only available for some result types as of now, but more will be added) var results = Results.ResultsReader.Parse(pointSupportReactionsPath); var pointSupportReactions = results.Cast <Results.PointSupportReaction>().ToList(); // Print results Console.WriteLine(); Console.WriteLine($"Emean: {new_Ecm}"); Console.WriteLine("Id | Reaction "); foreach (var reaction in pointSupportReactions) { Console.WriteLine($"{reaction.Id,10} | {reaction.Fz,10}"); } } // ENDING THE PROGRAM Console.WriteLine("\nPress any key to close console."); Console.ReadKey(); }