Skip to content

Commit

Permalink
minor feature GetExactDisplacement
Browse files Browse the repository at this point in the history
  • Loading branch information
epsi1on committed Feb 14, 2024
1 parent 482c93d commit 9be1c14
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 4 deletions.
42 changes: 39 additions & 3 deletions Sources/BriefFiniteElementNet/Elements/BarElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1042,10 +1042,46 @@ public Displacement GetInternalDisplacementAt(double xi, LoadCase loadCase)
return buf;
}


public Displacement GetExactInternalDisplacementAt(double xi, LoadCase loadCase)
{
throw new NotImplementedException();
{
//check to see if xi is exactly on any discrete points, for example shear exactly under a a concentrated force point is not a single value so exception must thrown

var discretePoints = new List<IsoPoint>();

discretePoints.AddRange(this.GetInternalForceDiscretationPoints());


foreach (var load in Loads)
{
if (load.Case == loadCase)
discretePoints.AddRange(load.GetInternalForceDiscretationPoints());
}

foreach (var point in discretePoints)
{
if (xi == point.Xi)
throw new InvalidInternalForceLocationException(string.Format(CultureInfo.CurrentCulture, "Internal force diagram and value is descrete at xi = {0}, thus have no value in this location. try to find internal force a little bit after or before this point", xi));
}
}

var approx = GetInternalDisplacementAt(xi, loadCase);

var helpers = GetHelpers();

var buf = approx;


foreach (var load in this.Loads)
if (load.Case == loadCase)
foreach (var helper in helpers)
{
var d = helper.GetLoadDisplacementAt(this, load, new[] { xi });
buf += d;
}

return buf;
}


Expand All @@ -1057,7 +1093,7 @@ public Displacement GetInternalDisplacementAt(double xi)

public Displacement GetExactInternalDisplacementAt(double xi)
{
throw new NotImplementedException();
return GetExactInternalDisplacementAt(xi, LoadCase.DefaultLoadCase);
}
#endregion

Expand Down
61 changes: 60 additions & 1 deletion UnitTests/Tests/BarElementExactInternalDisplacement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,66 @@ public void TestEulerBernouly_Distributed_dirz()
//https://mechanicalc.com/reference/beam-deflection-tables
var expected = (w * x * x) / (24 * E * I) * (L - x) * (L - x);

Assert.IsTrue(Math.Abs(current-expected) < epsilon, "invalid value");
Assert.IsTrue(Math.Abs(current - expected) < epsilon, "invalid value");

if (x != 0 && x != L)
{
Assert.IsTrue(Math.Sign(current) == Math.Sign(w), "invalid sign");
}
}

}


[Test]
public void TestEulerBernouly_Distributed_diry()
{
//internal force of 2 node beam beam with uniform load and both ends fixed

var dir = BeamDirection.Y;
var w = 2.0;
var L = 4;//[m]
var I = 1;
var E = 1;

var nodes = new Node[2];

nodes[0] = (new Node(0, 0, 0));
nodes[1] = (new Node(L, 0, 0));

var elm = new BarElement(nodes[0], nodes[1]);
elm.Section = new UniformParametric1DSection(0, I, 0);
elm.Material = UniformIsotropicMaterial.CreateFromYoungPoisson(E, 0.25);

var u1 = new Loads.UniformLoad();

u1.Case = LoadCase.DefaultLoadCase;
u1.Direction = Vector.K;
u1.CoordinationSystem = CoordinationSystem.Local;
u1.Magnitude = w;

//u1.ForceIsoLocation = new IsoPoint(elm.LocalCoordsToIsoCoords(forceLocation)[0]);

var hlpr = new EulerBernoulliBeamHelper2Node(dir, elm);

var epsilon = 1e-6;


foreach (var x in CalcUtil.Divide(L, 10))
{
var xi = elm.LocalCoordsToIsoCoords(x);

var current = hlpr.GetLoadDisplacementAt(elm, u1, xi).DZ;

//https://mechanicalc.com/reference/beam-deflection-tables
var expected = (w * x * x) / (24 * E * I) * (L - x) * (L - x);

Assert.IsTrue(Math.Abs(current - expected) < epsilon, "invalid value");

if (x != 0 && x != L)
{
Assert.IsTrue(Math.Sign(current) == Math.Sign(w), "invalid sign");
}
}

}
Expand Down

0 comments on commit 9be1c14

Please sign in to comment.