Exemple #1
0
        static void Main()
        {
            // PRACTICAL EXAMPLE: SETTING UP LOAD GROUPS
            // This example shows the core steps of creating load groups for a model.

            // This example was last updated 2022-04-06, using the ver. 21.1.0 FEM-Design API.


            // CREATING LOAD CASES
            LoadCase deadLoad1 = new LoadCase("Deadload1", LoadCaseType.DeadLoad, LoadCaseDuration.Permanent);
            LoadCase deadLoad2 = new LoadCase("Deadload2", LoadCaseType.DeadLoad, LoadCaseDuration.Permanent);
            LoadCase liveLoad1 = new LoadCase("Liveload1", LoadCaseType.Static, LoadCaseDuration.Permanent);
            LoadCase liveLoad2 = new LoadCase("Liveload2", LoadCaseType.Static, LoadCaseDuration.Permanent);

            List <LoadCase> loadCasesDeadLoads = new List <LoadCase>()
            {
                deadLoad1, deadLoad2
            };
            List <LoadCase> loadCaseLiveLoads = new List <LoadCase>()
            {
                liveLoad1, liveLoad2
            };


            // FETCHING LOAD CATEGORY DATABASE
            var          loadCategoryDatabase = LoadCategoryDatabase.GetDefault();
            LoadCategory loadCategory         = loadCategoryDatabase.LoadCategoryByName("A");


            // CREATING LOAD GROUPS
            var LG1 = new ModelGeneralLoadGroup(new LoadGroupPermanent(1, 1.35, 1, 1, loadCasesDeadLoads, ELoadGroupRelationship.Simultaneous, 0.89, "LG1"));
            var LG2 = new ModelGeneralLoadGroup(new LoadGroupTemporary(1.5, loadCategory.Psi0, loadCategory.Psi1, loadCategory.Psi2, true, loadCaseLiveLoads, ELoadGroupRelationship.Alternative, "LG2"));

            var loadGroups = new List <ModelGeneralLoadGroup>()
            {
                LG1, LG2
            };


            // CREATING AND OPENING NEW MODEL
            var model2 = new Model(Country.S, null, null, loadCasesDeadLoads.Concat(loadCaseLiveLoads).ToList(), null, loadGroups);

            string path = Path.GetFullPath("output/LoadGroups.struxml");

            if (!Directory.Exists("output"))
            {
                Directory.CreateDirectory("output");
            }

            model2.SerializeModel(path);
            var app = new Calculate.Application();

            app.OpenStruxml(path, true);
        }
Exemple #2
0
        static void Main()
        {
            // PRACTICAL EXAMPLE: COMBINING LOAD GROUPS
            // This example shows the steps for creating a complete set of load combination,
            // combining existing load groups. In addition to the main program, there are two
            // public functions at the bottom - CombineULS and CombineSLS.

            // This example was last updated 2022-04-06, using the ver. 21.1.0 FEM-Design API.


            // Create load cases
            LoadCase        deadLoad1          = new LoadCase("Deadload1", LoadCaseType.DeadLoad, LoadCaseDuration.Permanent);
            LoadCase        deadLoad2          = new LoadCase("Deadload2", LoadCaseType.DeadLoad, LoadCaseDuration.Permanent);
            LoadCase        liveLoad1          = new LoadCase("Liveload1", LoadCaseType.Static, LoadCaseDuration.Permanent);
            LoadCase        liveLoad2          = new LoadCase("Liveload2", LoadCaseType.Static, LoadCaseDuration.Permanent);
            LoadCase        windLoad1          = new LoadCase("Windload1", LoadCaseType.Static, LoadCaseDuration.Permanent);
            LoadCase        windLoad2          = new LoadCase("Windload2", LoadCaseType.Static, LoadCaseDuration.Permanent);
            List <LoadCase> loadCasesDeadLoads = new List <LoadCase>()
            {
                deadLoad1, deadLoad2
            };
            List <LoadCase> loadCaseCategoryA = new List <LoadCase>()
            {
                liveLoad1, liveLoad2
            };
            List <LoadCase> loadCaseCategoryWind = new List <LoadCase>()
            {
                windLoad1, windLoad2
            };
            List <LoadCase> loadCases = loadCasesDeadLoads.Concat(loadCaseCategoryA).Concat(loadCaseCategoryWind).ToList();


            // Get the load categories that hold the coefficients
            var          loadCategoryDatabase = LoadCategoryDatabase.GetDefault();
            LoadCategory loadCategoryA        = loadCategoryDatabase.LoadCategoryByName("A");
            LoadCategory loadCategoryWind     = loadCategoryDatabase.LoadCategoryByName("Wind");


            // Create load groups
            var LGPermanent = new LoadGroupPermanent(1, 1.35, 1, 1, loadCasesDeadLoads, ELoadGroupRelationship.Entire, 0.89, "LGPermanent");
            var LGA         = new LoadGroupTemporary(1.5, loadCategoryA.Psi0, loadCategoryA.Psi1, loadCategoryA.Psi2, true, loadCaseCategoryA, ELoadGroupRelationship.Alternative, "LGCategoryA");
            var LGWind      = new LoadGroupTemporary(1.5, loadCategoryWind.Psi0, loadCategoryWind.Psi1, loadCategoryWind.Psi2, true, loadCaseCategoryWind, ELoadGroupRelationship.Alternative, "LGCategoryWind");

            var loadGroups = new List <LoadGroupBase>()
            {
                LGPermanent, LGA, LGWind
            };


            // Wrap the load groups so that they can be added to the load group table
            var generalLoadGroups = new List <ModelGeneralLoadGroup>()
            {
                new ModelGeneralLoadGroup(LGPermanent), new ModelGeneralLoadGroup(LGA),
                new ModelGeneralLoadGroup(LGWind)
            };

            // Generate ULS and SLS Combinations
            List <LoadCombination> loadCombinations;
            LoadCombinationTable   loadCombinationTable = new LoadCombinationTable();

            CombineULS(loadGroups, loadCombinationTable);
            CombineSLS(loadGroups, loadCombinationTable);
            loadCombinations = loadCombinationTable.LoadCombinations;


            // Create model and open file in FEM design
            var model2 = new Model(Country.S, null, null, loadCases, loadCombinations, generalLoadGroups);

            string path = Path.GetFullPath("output/LoadGroupsAndCombinations.struxml");

            if (!Directory.Exists("output"))
            {
                Directory.CreateDirectory("output");
            }

            model2.SerializeModel(path);
            var app = new Calculate.Application();

            app.OpenStruxml(path, true);
        }
Exemple #3
0
        static void Main()
        {
            // EXAMPLE 4: EDITING AN EXISTING MODEL
            // In this example, we will edit an existing model by isolating a floor and replacing supporting
            // walls and pillars with appropriate supports. Using height as a point of comparison we can find
            // which elements to reuse from the old model, and create a new model with our selected elements.

            // This example was last updated 2022-04-13, using the ver. 21.1.0 FEM-Design API.


            // READ THE MODEL:
            // Deserialize the current model to access all the data in the .struxml file.
            FemDesign.Model model = FemDesign.Model.DeserializeFromFilePath("Example 4 - model.struxml");


            // ISOLATE A FLOOR:
            // Choose which floor will be singled out.
            int floor = 3;

            FemDesign.StructureGrid.Storey          storey       = model.Entities.Storeys.Storey[floor];
            List <GenericClasses.IStructureElement> storeyAsList = new List <GenericClasses.IStructureElement> {
                storey
            };
            double zCoord = storey.Origo.Z;


            // POINT SUPPORTS:
            // Find all pillars supporting the chosen floor, and place point supports in their place.
            // We can use the fact that point [1] of any pillar is always the highest one.
            var supports = new List <GenericClasses.ISupportElement>();

            for (int i = 0; i < model.Entities.Bars.Count; i++)
            {
                Bars.Bar tempBar = model.Entities.Bars[i];
                if (tempBar.BarPart.Type != Bars.BarType.Column)
                {
                    continue;
                }

                if (Math.Abs(tempBar.BarPart.Edge.Points[1].Z - zCoord) < Tolerance.LengthComparison)
                {
                    var tempSupport = new Supports.PointSupport(
                        point: new Geometry.FdPoint3d(tempBar.BarPart.Edge.Points[1].X, tempBar.BarPart.Edge.Points[1].Y, zCoord),
                        motions: Releases.Motions.RigidPoint(),
                        rotations: Releases.Rotations.Free()
                        );
                    supports.Add(tempSupport);
                }
            }


            // ELEMENTS:
            // The model only contains plates and walls, so we will not be looking for beams etc.
            // We are looking for the floor plate at the right height, and the walls below it to
            // replace them with line supports.
            var elements = new List <GenericClasses.IStructureElement>();

            // TESTING SLABS:
            // Slabs have a property which indicates if they are floors (plate) or walls (wall).
            // Based on this, we can sort out if we want to use them as an element or place a
            // line support in their stead.
            for (int i = 0; i < model.Entities.Slabs.Count; i++)
            {
                Shells.Slab tempSlab = model.Entities.Slabs[i];
                if (tempSlab.Type == Shells.SlabType.Plate && Math.Abs(tempSlab.SlabPart.LocalPos.Z - zCoord) < Tolerance.LengthComparison)
                {
                    elements.Add(tempSlab);
                }
                else if (tempSlab.Type == Shells.SlabType.Wall)
                {
                    if (Math.Abs(tempSlab.SlabPart.Region.Contours[0].Edges[2].Points[0].Z - zCoord) < Tolerance.LengthComparison)
                    {
                        // Creating supports with translational stiffnes in the Z direction only.
                        var tempSupport = new Supports.LineSupport(
                            edge: tempSlab.SlabPart.Region.Contours[0].Edges[2],
                            motions: new Releases.Motions(0, 0, 0, 0, 10E7, 10E7),
                            rotations: new Releases.Rotations(0, 0, 0, 0, 0, 0),
                            movingLocal: true
                            );
                        supports.Add(tempSupport);
                    }
                }
            }

            // TESTING PANELS:
            // Panels do not have the same property as slabs. Instead, we compare the height of all the
            // edge curves of the panel to discern if it is horizontal or not.
            for (int i = 0; i < model.Entities.Panels.Count; i++)
            {
                Shells.Panel tempPanel = model.Entities.Panels[i];
                bool         isSlab    = true;
                for (int j = 0; j < tempPanel.Region.Contours[0].Edges.Count; j++)
                {
                    if (tempPanel.Region.Contours[0].Edges[j].Points[0].Z != tempPanel.Region.Contours[0].Edges[j].Points[1].Z)
                    {
                        isSlab = false;
                        break;
                    }
                }
                if (isSlab && Math.Abs(tempPanel.Region.Contours[0].Edges[0].Points[0].Z - zCoord) < Tolerance.LengthComparison)
                {
                    elements.Add(tempPanel);
                }
                else if (!isSlab && Math.Abs(tempPanel.Region.Contours[0].Edges[2].Points[0].Z - zCoord) < Tolerance.LengthComparison)
                {
                    // Creating supports with translational stiffnes in the Z direction only.
                    var tempSupport = new Supports.LineSupport(
                        edge: tempPanel.Region.Contours[0].Edges[2],
                        motions: new Releases.Motions(0, 0, 0, 0, 10E7, 10E7),
                        rotations: new Releases.Rotations(0, 0, 0, 0, 0, 0),
                        movingLocal: true
                        );
                    supports.Add(tempSupport);
                }
            }


            // LOADS:
            // Similar to supports and elements, we will reuse loads from the model if they are on the correct height
            var loads = new List <GenericClasses.ILoadElement>();

            for (int i = 0; i < model.Entities.Loads.LineLoads.Count; i++)
            {
                if (Math.Abs(model.Entities.Loads.LineLoads[i].Edge.XAxis.Z - zCoord) < Tolerance.LengthComparison)
                {
                    loads.Add(model.Entities.Loads.LineLoads[i]);
                }
            }
            for (int i = 0; i < model.Entities.Loads.SurfaceLoads.Count; i++)
            {
                Loads.SurfaceLoad tempLoad = model.Entities.Loads.SurfaceLoads[i];
                if (Math.Abs(tempLoad.Region.Contours[0].Edges[0].Points[0].Z - zCoord) < Tolerance.LengthComparison)
                {
                    loads.Add(tempLoad);
                }
            }


            // CREATE NEW MODEL:
            // With a new model, we can add all our gathered elements to it. We can also take load cases,
            // load combinations, and the storey marker directly from the old model.
            FemDesign.Model newModel = new FemDesign.Model(Country.S);
            newModel.AddElements(elements);
            newModel.AddSupports(supports);
            newModel.AddLoads(loads);
            newModel.AddLoadCases(model.Entities.Loads.LoadCases);
            newModel.AddLoadCombinations(model.Entities.Loads.LoadCombinations);
            newModel.AddElements(storeyAsList);


            // SAVE AND RUN:
            // Create a file path for the new model, serialize it, and run the script!
            string path = Path.GetFullPath("output/edited_model.struxml");

            if (!Directory.Exists("output"))
            {
                Directory.CreateDirectory("output");
            }
            newModel.SerializeModel(path);
            Console.WriteLine($"Opening file at {path}");

            var app = new Calculate.Application();

            app.OpenStruxml(path, false);
        }
Exemple #4
0
        static void Main()
        {
            // EXAMPLE 2: ANALYSING A MODEL
            // This example will show you how to run an analyse
            // with a given model from within a C# script.

            // This example was last updated 2022-05-03, using the ver. 21.1.0 FEM-Design API.


            // LOADING UP THE MODEL
            string struxmlPath = "exbeam.struxml";
            Model  model       = Model.DeserializeFromFilePath(struxmlPath);


            // SETUP BY LOAD CALCULATION SETTINGS
            // These settings are found in the FEM-Design calculation window.
            bool NLE  = true;
            bool PL   = true;
            bool NLS  = false;
            bool Cr   = false;
            bool _2nd = false;


            // SETTING UP LOAD COMBINATIONS
            // In this example, we use the same settings (CombItem)
            // for all load combinations, applied with a simple loop.
            var combItem = new FemDesign.Calculate.CombItem(0, 0, NLE, PL, NLS, Cr, _2nd);

            int numLoadCombs = model.Entities.Loads.LoadCombinations.Count;
            var combItems    = new List <Calculate.CombItem>();

            for (int i = 0; i < numLoadCombs; i++)
            {
                combItems.Add(combItem);
            }

            Calculate.Comb comb = new Calculate.Comb();
            comb.CombItem = combItems.ToList();


            // CHOOSING THE ANALYSIS SETTINGS
            // These dictate which calculations to run.
            FemDesign.Calculate.Analysis analysis = new FemDesign.Calculate.Analysis(
                stage: null,
                comb: comb,
                freq: null,
                footfall: null,
                calcCase: true,
                calcCStage: false,
                calcImpf: false,
                calcComb: true,
                calcGMax: false,
                calcStab: false,
                calcFreq: false,
                calcSeis: false,
                calcDesign: false,
                calcFootfall: false,
                elemFine: false,
                diaphragm: false,
                peakSmoothing: false
                );


            // RUN THE ANALYSIS VIA AN FDSCRIPT
            var bscPath = new List <string> {
                @"C:\GitHub\femdesign-api\FemDesign.Examples\C#\Example 2 - Analysing a model\bin\Debug\pointsupportreactions.bsc"
            };

            FemDesign.Calculate.FdScript fdScript = FemDesign.Calculate.FdScript.Analysis(Path.GetFullPath(struxmlPath), analysis, bscPath, "", true);
            Calculate.Application        app      = new Calculate.Application();
            app.RunFdScript(fdScript, false, true, true);
        }
Exemple #5
0
        static void Main()
        {
            // PRACTICAL EXAMPLE: CREATE POST-TENSIONED CABLES
            // This example will show you how to add post-tensioned cables to your concrete beam.

            // This example was last updated 2022-05-03, using the ver. 21.1.0 FEM-Design API.


            // DEFINE GEOMETRY
            var p1   = new Geometry.FdPoint3d(0.0, 2.0, 0);
            var p2   = new Geometry.FdPoint3d(10, 2.0, 0);
            var edge = new Geometry.Edge(p1, p2, Geometry.FdVector3d.UnitY());

            // CREATE BEAM
            Materials.MaterialDatabase materialsDB = Materials.MaterialDatabase.DeserializeStruxml("materials.struxml");
            Sections.SectionDatabase   sectionsDB  = Sections.SectionDatabase.DeserializeStruxml("sections.struxml");

            var material = materialsDB.MaterialByName("C35/45");
            var section  = sectionsDB.SectionByName("Concrete sections, Rectangle, 300x900");

            var bar = new Bars.Bar(
                edge,
                Bars.BarType.Beam,
                material,
                sections: new Sections.Section[] { section },
                connectivities: new Bars.Connectivity[] { Bars.Connectivity.GetRigid() },
                eccentricities: new Bars.Eccentricity[] { Bars.Eccentricity.GetDefault() },
                identifier: "B");


            // CREATE POST-TENSIONED CABLE
            var shape = new Reinforcement.PtcShapeType(
                start: new Reinforcement.PtcShapeStart(0.0, 0.0),
                intermediates: new List <Reinforcement.PtcShapeInner>()
            {
                new Reinforcement.PtcShapeInner(0.4, -0.20, 0.0, 0.1),
                new Reinforcement.PtcShapeInner(0.6, -0.20, 0.0),
            },
                end: new Reinforcement.PtcShapeEnd(0.0, 0.0, 0.9)
                );

            var losses = new Reinforcement.PtcLosses(
                curvatureCoefficient: 0.05,
                wobbleCoefficient: 0.007,
                anchorageSetSlip: 0.0,
                elasticShortening: 0.0,
                creepStress: 0.0,
                shrinkageStress: 0.0,
                relaxationStress: 0.0);

            var manufacturing = new Reinforcement.PtcManufacturingType(
                positions: new List <double>()
            {
                0.3, 0.7
            },
                shiftX: 0.0,
                shiftZ: 0.1);

            var strandData = new Reinforcement.PtcStrandLibType(
                name: "Custom ptc material",
                f_pk: 1860.0,
                a_p: 150.0,
                e_p: 195000.0,
                rho: 7.810,
                relaxationClass: 2,
                rho_1000: 0.1);

            var ptc = new Reinforcement.Ptc(
                bar,
                shape,
                losses,
                manufacturing,
                strandData,
                jackingSide: Reinforcement.JackingSide.Start,
                jackingStress: 1000.0,
                numberOfStrands: 3,
                identifier: "PTC");

            var elements = new List <GenericClasses.IStructureElement>()
            {
                bar,
                ptc
            };


            // CREATE AND OPEN MODEL
            Model  model = new Model(Country.S, elements);
            string path  = "output/post_tensioned_cable.struxml";

            if (!Directory.Exists("output"))
            {
                Directory.CreateDirectory("output");
            }
            model.SerializeModel(path);

            var app = new Calculate.Application();

            app.OpenStruxml(Path.GetFullPath(path), false);
        }
Exemple #6
0
        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();
        }
Exemple #7
0
        static void Main()
        {
            // EXAMPLE 1: CREATING A SIMPLE BEAM
            // This example will show you how to model a simple supported beam,
            // and how to save it for export to FEM-Design.Before running,
            // make sure you have a window with FEM-Design open.

            // This example was last updated 2022-04-27, using the ver. 21.1.0 FEM-Design API.


            // Define geometry
            var p1  = new Geometry.FdPoint3d(2.0, 2.0, 0);
            var p2  = new Geometry.FdPoint3d(10, 2.0, 0);
            var mid = p1 + (p2 - p1) * 0.5;

            // Create elements
            var edge = new Geometry.Edge(p1, p2, Geometry.FdVector3d.UnitZ());

            Materials.MaterialDatabase materialsDB = Materials.MaterialDatabase.DeserializeStruxml("materials.struxml");
            Sections.SectionDatabase   sectionsDB  = Sections.SectionDatabase.DeserializeStruxml("sections.struxml");

            var material = materialsDB.MaterialByName("C35/45");
            var section  = sectionsDB.SectionByName("Concrete sections, Rectangle, 300x900");

            var bar = new Bars.Bar(
                edge,
                Bars.BarType.Beam,
                material,
                sections: new Sections.Section[] { section },
                connectivities: new Bars.Connectivity[] { Bars.Connectivity.GetRigid() },
                eccentricities: new Bars.Eccentricity[] { Bars.Eccentricity.GetDefault() },
                identifier: "B");

            bar.BarPart.LocalY = Geometry.FdVector3d.UnitY();
            var elements = new List <GenericClasses.IStructureElement>()
            {
                bar
            };


            // Create supports
            var s1 = new Supports.PointSupport(
                point: p1,
                motions: Releases.Motions.RigidPoint(),
                rotations: Releases.Rotations.Free()
                );

            var s2 = new Supports.PointSupport(
                point: p2,
                motions: new Releases.Motions(yNeg: 1e10, yPos: 1e10, zNeg: 1e10, zPos: 1e10),
                rotations: Releases.Rotations.Free()
                );
            var supports = new List <GenericClasses.ISupportElement>()
            {
                s1, s2
            };


            // Create load cases
            var deadload  = new Loads.LoadCase("Deadload", Loads.LoadCaseType.DeadLoad, Loads.LoadCaseDuration.Permanent);
            var liveload  = new Loads.LoadCase("Liveload", Loads.LoadCaseType.Static, Loads.LoadCaseDuration.Permanent);
            var loadcases = new List <Loads.LoadCase>()
            {
                deadload, liveload
            };


            // Create load combinations
            var slsFactors = new List <double>()
            {
                1.0, 1.0
            };
            var SLS        = new Loads.LoadCombination("SLS", Loads.LoadCombType.ServiceabilityCharacteristic, loadcases, slsFactors);
            var ulsFactors = new List <double>()
            {
                1.35, 1.5
            };
            var ULS = new Loads.LoadCombination("ULS", Loads.LoadCombType.UltimateOrdinary, loadcases, ulsFactors);
            var loadCombinations = new List <Loads.LoadCombination>()
            {
                SLS, ULS
            };


            // Create loads
            var pointForce  = new Loads.PointLoad(mid, new Geometry.FdVector3d(0.0, 0.0, -5.0), liveload, null, Loads.ForceLoadType.Force);
            var pointMoment = new Loads.PointLoad(p2, new Geometry.FdVector3d(0.0, 5.0, 0.0), liveload, null, Loads.ForceLoadType.Moment);

            var lineLoadStart = new Geometry.FdVector3d(0.0, 0.0, -2.0);
            var lineLoadEnd   = new Geometry.FdVector3d(0.0, 0.0, -4.0);
            var lineLoad      = new Loads.LineLoad(edge, lineLoadStart, lineLoadEnd, liveload, Loads.ForceLoadType.Force, "", constLoadDir: true, loadProjection: true);

            var loads = new List <GenericClasses.ILoadElement>()
            {
                pointForce,
                pointMoment,
                lineLoad
            };


            // Add to model
            Model model = new Model(Country.S);

            model.AddElements(elements);
            model.AddSupports(supports);
            model.AddLoadCases(loadcases);
            model.AddLoadCombinations(loadCombinations);
            model.AddLoads(loads);


            // Save model then open in FEM-Design
            string path = System.IO.Path.GetFullPath("simple_model.struxml");

            model.SerializeModel(path);

            var app = new Calculate.Application();

            app.OpenStruxml(path, true);
        }
Exemple #8
0
        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();
        }