Skip to content

Commit

Permalink
✨ periodic excitation load
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco-Pellegrino committed Sep 6, 2024
1 parent ccb07a8 commit e102197
Show file tree
Hide file tree
Showing 11 changed files with 143 additions and 26 deletions.
2 changes: 1 addition & 1 deletion FemDesign.Core/FemDesignConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
23 changes: 23 additions & 0 deletions FemDesign.Core/Loads/Loads/MassConversionTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,28 @@ public MassConversionTable(List<double> factors, List<LoadCase> loadCases)
}
}


public MassConversionTable(params (double gamma, LoadCase lc)[] values)
{
// get factors and load cases
List<double> factors = new List<double>();
List<LoadCase> loadCases = new List<LoadCase>();

foreach (var value in values)
{
factors.Add(value.gamma);
loadCases.Add(value.lc);
}

List<MassConversion> items = new List<MassConversion>();
for (int idx = 0; idx < factors.Count; idx++)
{
items.Add(new MassConversion(factors[idx], loadCases[idx].Guid));
}

this.EntityCreated();
this.MassConversions = items;
}

}
}
20 changes: 19 additions & 1 deletion FemDesign.Core/Loads/Loads/PeriodicExcitation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,32 @@ public double Frequency

public PeriodicLoad() { }

/// <summary>
///
/// </summary>
/// <param name="name"></param>
/// <param name="frequency">Hz</param>
/// <param name="cases"></param>
public PeriodicLoad(string name, double frequency, List<PeriodicCase> cases)
{
this.Name = name;
this.Frequency = frequency;
this.Case = cases;
}

/// <summary>
///
/// </summary>
/// <param name="name"></param>
/// <param name="frequency">Hz</param>
/// <param name="cases"></param>
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; }
Expand Down Expand Up @@ -122,7 +141,6 @@ public LoadCase LoadCase
}
}


public PeriodicCase() { }

public PeriodicCase(double factor, Shape phase, LoadCase LoadCase)
Expand Down
71 changes: 56 additions & 15 deletions FemDesign.Examples/C#/Example - Dynamic Loads/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Diagram> and List<ExcitationForceCombination>.
// public ExcitationForce(List<Diagram> diagrams, List<ExcitationForceCombination> combinations)

var diagram1 = new Diagram("diagram1", new List<double> { 0.0, 1, 2}, new List<double> { 1, 0.1, 0.3});
var diagram2 = new Diagram("diagram2", new List<double> { 0.0, 0.1, 0.2}, new List<double> { 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()
{
Expand All @@ -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<PeriodicCase> { new PeriodicCase(10, PeriodicCase.Shape.Cos, loadCase1) });
var record2 = new PeriodicLoad("record2", 10, new List<PeriodicCase> { 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<PeriodicCase>{
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<PeriodicCase> { periodicCase1, periodicCase2} );


var periodicExcitation = new FemDesign.Loads.PeriodicExcitation( new List<PeriodicLoad> { 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);
}

}
}
}
4 changes: 3 additions & 1 deletion FemDesign.Grasshopper/FemDesign.Grasshopper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
<Compile Include="Loads\Loads\Dynamics\ExcitationForceCombination.cs" />
<Compile Include="Loads\Loads\Dynamics\ExcitationLoad.cs" />
<Compile Include="Loads\Loads\Dynamics\PeriodicCase.cs" />
<Compile Include="Loads\Loads\Dynamics\PeriodicRecord.cs" />
<Compile Include="Loads\Loads\Dynamics\PeriodicLoad.cs" />
<Compile Include="Loads\Loads\LineLoadDefine.cs" />
<Compile Include="Loads\Loads\LineSupportMotionDefine.cs" />
<Compile Include="Loads\Loads\Mass.cs" />
Expand Down Expand Up @@ -941,8 +941,10 @@
<Content Include="Resources\icons\ImperfectionDefine3.png" />
<Content Include="Resources\icons\LabelledSection.png" />
<Content Include="Resources\icons\LineConnection.bmp" />
<None Include="Resources\icons\PeriodicCase.png" />
<Content Include="Resources\icons\PeriodicExcitationDefine2.png" />
<Content Include="Resources\icons\PeriodicExcitationDefine3.png" />
<None Include="Resources\icons\PeriodicExcitationLoad.png" />
<Content Include="Resources\icons\StabilityDefine2.png" />
<Content Include="Resources\icons\StabilityDefine3.png" />
<Content Include="Resources\icons\StageDefine2.png" />
Expand Down
13 changes: 9 additions & 4 deletions FemDesign.Grasshopper/Loads/Loads/Dynamics/PeriodicCase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ 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())
{

}
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);
}
Expand Down Expand Up @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;


}
}
20 changes: 20 additions & 0 deletions FemDesign.Grasshopper/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions FemDesign.Grasshopper/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -7383,4 +7383,10 @@
<data name="Config" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icons\Config.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="PeriodicCase" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icons\PeriodicCase.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="PeriodicExcitationLoad" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icons\PeriodicExcitationLoad.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e102197

Please sign in to comment.