diff --git a/FemDesign.Core/FemDesignConnection.cs b/FemDesign.Core/FemDesignConnection.cs index 3d93cc50..9d23f298 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 b0fe2e16..c1def2ee 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 78c64e72..4ebf680c 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 e82c0ca7..647ebfd9 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 c19719b2..59f7a837 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 2447afc2..30850417 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 d3dfd0b2..ae99e0a9 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 f6141b34..779e1152 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 0aa0547d..b3038895 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 00000000..3da8679c Binary files /dev/null and b/FemDesign.Grasshopper/Resources/icons/PeriodicCase.png differ diff --git a/FemDesign.Grasshopper/Resources/icons/PeriodicExcitationLoad.png b/FemDesign.Grasshopper/Resources/icons/PeriodicExcitationLoad.png new file mode 100644 index 00000000..a56c7787 Binary files /dev/null and b/FemDesign.Grasshopper/Resources/icons/PeriodicExcitationLoad.png differ