From e102197545e97cad751c2cd7c424e8103bea9a40 Mon Sep 17 00:00:00 2001 From: MP Date: Fri, 6 Sep 2024 15:56:47 +0200 Subject: [PATCH] :sparkles: periodic excitation load --- FemDesign.Core/FemDesignConnection.cs | 2 +- .../Loads/Loads/MassConversionTable.cs | 23 ++++++ .../Loads/Loads/PeriodicExcitation.cs | 20 ++++- .../C#/Example - Dynamic Loads/Program.cs | 71 ++++++++++++++---- .../FemDesign.Grasshopper.csproj | 4 +- .../Loads/Loads/Dynamics/PeriodicCase.cs | 13 +++- .../{PeriodicRecord.cs => PeriodicLoad.cs} | 10 ++- .../Properties/Resources.Designer.cs | 20 +++++ .../Properties/Resources.resx | 6 ++ .../Resources/icons/PeriodicCase.png | Bin 0 -> 4848 bytes .../icons/PeriodicExcitationLoad.png | Bin 0 -> 686 bytes 11 files changed, 143 insertions(+), 26 deletions(-) rename FemDesign.Grasshopper/Loads/Loads/Dynamics/{PeriodicRecord.cs => PeriodicLoad.cs} (84%) create mode 100644 FemDesign.Grasshopper/Resources/icons/PeriodicCase.png create mode 100644 FemDesign.Grasshopper/Resources/icons/PeriodicExcitationLoad.png diff --git a/FemDesign.Core/FemDesignConnection.cs b/FemDesign.Core/FemDesignConnection.cs index 3d93cc503..9d23f298e 100644 --- a/FemDesign.Core/FemDesignConnection.cs +++ b/FemDesign.Core/FemDesignConnection.cs @@ -393,7 +393,7 @@ public void RunAnalysis(Analysis analysis) this.RunScript(script, "RunAnalysis"); } - if (analysis.Freq != null || analysis.Footfall != null) + if (analysis.Freq != null || analysis.Footfall != null || analysis.PeriodicEx != null || analysis.ExForce != null || analysis.GroundAcc != null) { script = new FdScript( logfile, diff --git a/FemDesign.Core/Loads/Loads/MassConversionTable.cs b/FemDesign.Core/Loads/Loads/MassConversionTable.cs index b0fe2e160..c1def2ee5 100644 --- a/FemDesign.Core/Loads/Loads/MassConversionTable.cs +++ b/FemDesign.Core/Loads/Loads/MassConversionTable.cs @@ -104,5 +104,28 @@ public MassConversionTable(List factors, List loadCases) } } + + public MassConversionTable(params (double gamma, LoadCase lc)[] values) + { + // get factors and load cases + List factors = new List(); + List loadCases = new List(); + + foreach (var value in values) + { + factors.Add(value.gamma); + loadCases.Add(value.lc); + } + + List items = new List(); + for (int idx = 0; idx < factors.Count; idx++) + { + items.Add(new MassConversion(factors[idx], loadCases[idx].Guid)); + } + + this.EntityCreated(); + this.MassConversions = items; + } + } } \ No newline at end of file diff --git a/FemDesign.Core/Loads/Loads/PeriodicExcitation.cs b/FemDesign.Core/Loads/Loads/PeriodicExcitation.cs index 78c64e722..4ebf680c1 100644 --- a/FemDesign.Core/Loads/Loads/PeriodicExcitation.cs +++ b/FemDesign.Core/Loads/Loads/PeriodicExcitation.cs @@ -60,6 +60,12 @@ public double Frequency public PeriodicLoad() { } + /// + /// + /// + /// + /// Hz + /// public PeriodicLoad(string name, double frequency, List cases) { this.Name = name; @@ -67,6 +73,19 @@ public PeriodicLoad(string name, double frequency, List cases) this.Case = cases; } + /// + /// + /// + /// + /// Hz + /// + public PeriodicLoad(string name, double frequency, params PeriodicCase[] cases) + { + this.Name = name; + this.Frequency = frequency; + this.Case = cases.ToList(); + } + [XmlIgnore] public Guid Guid { get; set; } @@ -122,7 +141,6 @@ public LoadCase LoadCase } } - public PeriodicCase() { } public PeriodicCase(double factor, Shape phase, LoadCase LoadCase) diff --git a/FemDesign.Examples/C#/Example - Dynamic Loads/Program.cs b/FemDesign.Examples/C#/Example - Dynamic Loads/Program.cs index e82c0ca7d..647ebfd9d 100644 --- a/FemDesign.Examples/C#/Example - Dynamic Loads/Program.cs +++ b/FemDesign.Examples/C#/Example - Dynamic Loads/Program.cs @@ -6,12 +6,14 @@ using System.Threading.Tasks; using FemDesign; +using FemDesign.Bars; using FemDesign.Calculate; using FemDesign.GenericClasses; using FemDesign.Geometry; using FemDesign.Loads; using FemDesign.Materials; using FemDesign.ModellingTools; +using FemDesign.Sections; using FemDesign.Shells; using FemDesign.Utils; using static FemDesign.Loads.PeriodicCase; @@ -22,22 +24,53 @@ internal class Program { static void Main() { + // The example demonstrates how to create a model with dynamic loads in FemDesign. var model = new Model(Country.COMMON); - var loadCase1 = new LoadCase("name", LoadCaseType.DeadLoad, LoadCaseDuration.Permanent); - var loadCase2 = new LoadCase("name2", LoadCaseType.Static, LoadCaseDuration.Permanent); + // create a steel beam long 6 meters with pinned supports at the end using FemDesign + var startPoint = new Point3d(0, 0, 0); + var endPoint = new Point3d(0, 6, 0); + var edge = new Edge(startPoint, endPoint); - model.AddLoadCases(loadCase1, loadCase2); + var steel = MaterialDatabase.GetDefault().Materials.Material.MaterialByName("S355"); + var section = SectionDatabase.GetDefault().Sections.Section.SectionByName("HEA300"); + + var beam = new Beam(edge, steel, section); + + var supportStart = Supports.PointSupport.Rigid(edge.Points[0]); + var supportEnd = Supports.PointSupport.Hinged(edge.Points[1]); + + model.AddElements(beam); + model.AddSupports(supportStart, supportEnd); + + // create load cases + var dl = new LoadCase("DL", LoadCaseType.DeadLoad, LoadCaseDuration.Permanent); + var ll = new LoadCase("LL", LoadCaseType.Static, LoadCaseDuration.Permanent); + + model.AddLoadCases(dl, ll); + + // create load combinations + var loadCombination = new LoadCombination("combo", LoadCombType.UltimateOrdinary, (dl, 1.35), (ll, 1.0)); + + model.AddLoadCombinations(loadCombination); + + // create a point load in the middle + var middlePoint = (edge.Points[0] + edge.Points[1]) / 2; + var pointLoad = PointLoad.Force(middlePoint, new Vector3d(0, 0, -10), ll); + + model.AddLoads(pointLoad); // create an excitation force + // The constructor requires a List and List. + // public ExcitationForce(List diagrams, List combinations) var diagram1 = new Diagram("diagram1", new List { 0.0, 1, 2}, new List { 1, 0.1, 0.3}); var diagram2 = new Diagram("diagram2", new List { 0.0, 0.1, 0.2}, new List { 1, 0.1, 0.3}); - var exLdCase1 = new ExcitationForceLoadCase(loadCase1, 1, diagram1); - var exLdCase2 = new ExcitationForceLoadCase(loadCase2, 2, diagram2); + var exLdCase1 = new ExcitationForceLoadCase(dl, 1, diagram1); + var exLdCase2 = new ExcitationForceLoadCase(ll, 2, diagram2); var combination1 = new ExcitationForceCombination() { @@ -61,27 +94,35 @@ static void Main() model.AddLoads(excitationForce); - // create periodic excitation load + // create a periodic load - var record1 = new PeriodicLoad("record1", 20, new List { new PeriodicCase(10, PeriodicCase.Shape.Cos, loadCase1) }); - var record2 = new PeriodicLoad("record2", 10, new List { new PeriodicCase(5, PeriodicCase.Shape.Sin, loadCase1) }); + var periodicCase1 = new PeriodicCase(1, Shape.Cos, dl); + var periodicCase2 = new PeriodicCase(5, Shape.Sin, dl); - var record3 = new PeriodicLoad("record3", 10, - new List{ - new PeriodicCase(5, PeriodicCase.Shape.Sin, loadCase1), - new PeriodicCase(2, PeriodicCase.Shape.Cos, loadCase2), - }); + var periodicLoad1 = new PeriodicLoad("record1", 20, periodicCase1); + var periodicLoad2 = new PeriodicLoad("record2", 10, periodicCase2); + var periodicLoad3 = new PeriodicLoad("record3", 10, new List { periodicCase1, periodicCase2} ); - var periodicExcitation = new FemDesign.Loads.PeriodicExcitation( new List { record1, record2, record3}); + model.AddLoads(periodicLoad1); + model.AddLoads(periodicLoad2); + model.AddLoads(periodicLoad3); - model.AddLoads(periodicExcitation); + // add mass definition + var massLoad = new Loads.MassConversionTable( (1, dl), (1, ll) ); + model.AddLoads(massLoad); + + var periodicExcitation = Analysis.PeriodicExcitation(); + var excitation = Analysis.ExcitationForce(); using (var femdesign = new FemDesignConnection(keepOpen: true)) { femdesign.Open(model); + femdesign.RunAnalysis(periodicExcitation); + femdesign.RunAnalysis(excitation); } + } } } \ No newline at end of file diff --git a/FemDesign.Grasshopper/FemDesign.Grasshopper.csproj b/FemDesign.Grasshopper/FemDesign.Grasshopper.csproj index c19719b26..59f7a837b 100644 --- a/FemDesign.Grasshopper/FemDesign.Grasshopper.csproj +++ b/FemDesign.Grasshopper/FemDesign.Grasshopper.csproj @@ -137,7 +137,7 @@ - + @@ -941,8 +941,10 @@ + + diff --git a/FemDesign.Grasshopper/Loads/Loads/Dynamics/PeriodicCase.cs b/FemDesign.Grasshopper/Loads/Loads/Dynamics/PeriodicCase.cs index 2447afc20..30850417c 100644 --- a/FemDesign.Grasshopper/Loads/Loads/Dynamics/PeriodicCase.cs +++ b/FemDesign.Grasshopper/Loads/Loads/Dynamics/PeriodicCase.cs @@ -14,7 +14,7 @@ namespace FemDesign.Grasshopper { public class PeriodicCase : FEM_Design_API_Component { - public PeriodicCase() : base("PeriodicCase", "PeriodicCase", "", CategoryName.Name(), SubCategoryName.Cat3()) + public PeriodicCase() : base("PeriodicCase.Define", "PeriodicCase.Define", "", CategoryName.Name(), SubCategoryName.Cat3()) { } @@ -22,7 +22,7 @@ protected override void RegisterInputParams(GH_InputParamManager pManager) { pManager.AddNumberParameter("Factor", "Factor", "", GH_ParamAccess.item, 1.0); pManager[pManager.ParamCount - 1].Optional = true; - pManager.AddTextParameter("Phase", "Phase", "", GH_ParamAccess.item, "Sin"); + pManager.AddTextParameter("Phase", "Phase", "\"Connect 'ValueList' to get the options.\\nPhase type:\\nSin\\\nCos", GH_ParamAccess.item, "Sin"); pManager[pManager.ParamCount - 1].Optional = true; pManager.AddGenericParameter("LoadCase", "LoadCase", "", GH_ParamAccess.item); } @@ -51,13 +51,18 @@ protected override System.Drawing.Bitmap Icon { get { - return null; + return FemDesign.Properties.Resources.PeriodicCase; } } public override Guid ComponentGuid { get { return new Guid("{4305829A-FDB0-4B7D-9F0D-12278C013661}"); } } - public override GH_Exposure Exposure => GH_Exposure.senary; + public override GH_Exposure Exposure => GH_Exposure.obscure; + + protected override void BeforeSolveInstance() + { + ValueListUtils.UpdateValueLists(this, 1, Enum.GetNames(typeof(FemDesign.Loads.PeriodicCase.Shape)).ToList(), null, GH_ValueListMode.DropDown); + } } } \ No newline at end of file diff --git a/FemDesign.Grasshopper/Loads/Loads/Dynamics/PeriodicRecord.cs b/FemDesign.Grasshopper/Loads/Loads/Dynamics/PeriodicLoad.cs similarity index 84% rename from FemDesign.Grasshopper/Loads/Loads/Dynamics/PeriodicRecord.cs rename to FemDesign.Grasshopper/Loads/Loads/Dynamics/PeriodicLoad.cs index d3dfd0b2d..ae99e0a99 100644 --- a/FemDesign.Grasshopper/Loads/Loads/Dynamics/PeriodicRecord.cs +++ b/FemDesign.Grasshopper/Loads/Loads/Dynamics/PeriodicLoad.cs @@ -14,14 +14,14 @@ namespace FemDesign.Grasshopper { public class PeriodicLoad : FEM_Design_API_Component { - public PeriodicLoad() : base("PeriodicLoad", "PeriodicLoad", "", CategoryName.Name(), SubCategoryName.Cat3()) + public PeriodicLoad() : base("PeriodicLoad.Define", "PeriodicLoad.Define", "", CategoryName.Name(), SubCategoryName.Cat3()) { } protected override void RegisterInputParams(GH_InputParamManager pManager) { pManager.AddTextParameter("Name", "Name", "", GH_ParamAccess.item); - pManager.AddNumberParameter("Frequency", "Frequency", "", GH_ParamAccess.item); + pManager.AddNumberParameter("Frequency", "Frequency", "Hz", GH_ParamAccess.item); pManager.AddGenericParameter("PeriodicCases", "PeriodicCases", "", GH_ParamAccess.list); } protected override void RegisterOutputParams(GH_OutputParamManager pManager) @@ -47,13 +47,15 @@ protected override System.Drawing.Bitmap Icon { get { - return null; + return FemDesign.Properties.Resources.PeriodicExcitationLoad; } } public override Guid ComponentGuid { get { return new Guid("{F6A3C3AC-8399-4894-9B77-BF0A65CF4F46}"); } } - public override GH_Exposure Exposure => GH_Exposure.senary; + public override GH_Exposure Exposure => GH_Exposure.obscure; + + } } \ No newline at end of file diff --git a/FemDesign.Grasshopper/Properties/Resources.Designer.cs b/FemDesign.Grasshopper/Properties/Resources.Designer.cs index f6141b34c..779e11529 100644 --- a/FemDesign.Grasshopper/Properties/Resources.Designer.cs +++ b/FemDesign.Grasshopper/Properties/Resources.Designer.cs @@ -1700,6 +1700,16 @@ internal static System.Drawing.Bitmap PeakSmoothingRegionDeconstruct { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap PeriodicCase { + get { + object obj = ResourceManager.GetObject("PeriodicCase", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -1720,6 +1730,16 @@ internal static System.Drawing.Bitmap PeriodicExcitationDefine3 { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap PeriodicExcitationLoad { + get { + object obj = ResourceManager.GetObject("PeriodicExcitationLoad", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/FemDesign.Grasshopper/Properties/Resources.resx b/FemDesign.Grasshopper/Properties/Resources.resx index 0aa0547dd..b3038895b 100644 --- a/FemDesign.Grasshopper/Properties/Resources.resx +++ b/FemDesign.Grasshopper/Properties/Resources.resx @@ -7383,4 +7383,10 @@ ..\Resources\icons\Config.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\icons\PeriodicCase.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\icons\PeriodicExcitationLoad.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/FemDesign.Grasshopper/Resources/icons/PeriodicCase.png b/FemDesign.Grasshopper/Resources/icons/PeriodicCase.png new file mode 100644 index 0000000000000000000000000000000000000000..3da8679c8e86fe2f2ccbaeba6fb99af9a1d2576c GIT binary patch literal 4848 zcmeHKdsGwY6_3hGKtNGMiyDFttW4ey5{QTdfyF?;s31k1%uJFI@*o*V07Zl%Ai9g< zbA6+rXoZCZMa2hYU07W$h!(7_pvWrqfoNA~MeUb>itV1$<2l{`NX}$t?&J5}`@8pk zCtt24ENG1FWLpx6G$tfi6bbIGrpv|({I(l}ec*N}MH)p!!UnQdr;+3F7@0`cVr0yS z%Sj~T-&B&@W9rEE{fZ4=l3JZ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