private static void Test_P_Delta_matrix() { var model = StructureGenerator.Generate3DFrameElementGrid(10, 10, 10); var zs = model.Nodes.Where(i => i.Constraints != Constraint.Fixed) .Select(i => i.Location.Z).Distinct().ToList(); foreach (var z in zs) { var relm = new RigidElement_MPC(); relm.Nodes.AddRange(model.Nodes.Where(i => i.Location.Z == z)); model.MpcElements.Add(relm); relm.UseForAllLoads = true; } StructureGenerator.AddRandomDisplacements(model, 0.1); model.Clone(); #region #endregion CalcUtil.GenerateP_Delta_Mpc(model, LoadCase.DefaultLoadCase, new DenseIrrefFinder()); }
private static void TestWithOpensees() { var model = StructureGenerator.Generate3DBarElementGrid(5, 5, 5); StructureGenerator.AddRandomiseLoading(model, true, false, LoadCase.DefaultLoadCase); StructureGenerator.AddRandomDisplacements(model, 0.3); model.Solve_MPC(); OpenseesValidator.OpenseesValidate(model, LoadCase.DefaultLoadCase, false); }
public static ValidationResult Validation_2() { var nx = 5; var ny = 5; var nz = 5; var grd = StructureGenerator.Generate3DBarElementGrid(nx, ny, nz); //StructureGenerator.SetRandomiseConstraints(grd); StructureGenerator.SetRandomiseSections(grd); StructureGenerator.AddRandomiseNodalLoads(grd, LoadCase.DefaultLoadCase); //random nodal loads StructureGenerator.AddRandomiseBeamUniformLoads(grd, LoadCase.DefaultLoadCase); //random elemental loads StructureGenerator.AddRandomDisplacements(grd, 0.1); var rnd = new Random(0); foreach (var elm in grd.Elements) { var bar = elm as BarElement; if (bar == null) { continue; } /* * if (rnd.Next() % 10 == 0) * { * var cnd = RandomStuff.GetRandomConstraint(); * * cnd.DY = cnd.DZ = cnd.RY = cnd.RZ = DofConstraint.Fixed; * * bar.StartReleaseCondition = cnd; * * } * * * if (rnd.Next() % 10 == 1) * { * var cnd = RandomStuff.GetRandomConstraint(); * * cnd.DY = cnd.DZ = cnd.RY = cnd.RZ = DofConstraint.Fixed; * * bar.EndReleaseCondition = cnd; * * } */ } grd.Solve_MPC(); var maxEpsilon = 0.0; foreach (var elm in grd.Elements) { var bar = elm as BarElement; if (bar == null) { continue; } var start = bar.StartReleaseCondition; var end = bar.EndReleaseCondition; var stFrc = bar.GetInternalForceAt(-1, LoadCase.DefaultLoadCase); var enFrc = bar.GetInternalForceAt(1, LoadCase.DefaultLoadCase); if (start != Constraints.Fixed) { if (start.DX == DofConstraint.Released) { maxEpsilon = Math.Max(Math.Abs(stFrc.Fx), maxEpsilon); } if (start.DY == DofConstraint.Released) { maxEpsilon = Math.Max(Math.Abs(stFrc.Fy), maxEpsilon); } if (start.DZ == DofConstraint.Released) { maxEpsilon = Math.Max(Math.Abs(stFrc.Fz), maxEpsilon); } if (start.RX == DofConstraint.Released) { maxEpsilon = Math.Max(Math.Abs(stFrc.Mx), maxEpsilon); } if (start.RY == DofConstraint.Released) { maxEpsilon = Math.Max(Math.Abs(stFrc.My), maxEpsilon); } if (start.RZ == DofConstraint.Released) { maxEpsilon = Math.Max(Math.Abs(stFrc.Mz), maxEpsilon); } } if (end != Constraints.Fixed) { if (end.DX == DofConstraint.Released) { maxEpsilon = Math.Max(Math.Abs(enFrc.Fx), maxEpsilon); } if (end.DY == DofConstraint.Released) { maxEpsilon = Math.Max(Math.Abs(enFrc.Fy), maxEpsilon); } if (end.DZ == DofConstraint.Released) { maxEpsilon = Math.Max(Math.Abs(enFrc.Fz), maxEpsilon); } if (end.RX == DofConstraint.Released) { maxEpsilon = Math.Max(Math.Abs(enFrc.Mx), maxEpsilon); } if (end.RY == DofConstraint.Released) { maxEpsilon = Math.Max(Math.Abs(enFrc.My), maxEpsilon); } if (end.RZ == DofConstraint.Released) { maxEpsilon = Math.Max(Math.Abs(enFrc.Mz), maxEpsilon); } } } var span = new HtmlTag("span"); span.Add("p").Text("Validate a 3D frame internal force and internal displacement"); span.Add("h3").Text("Validate objective"); span.Add("paragraph").Text("validate internal force and internal displacement of bar elements. ") .AddClosedTag("br"); span.Add("paragraph").Text("Internal displacement in each element at each end node should be equal to that node's displacement.").AddClosedTag("br"); span.Add("paragraph").Text("End forces and mid force should be in equiblirium with each other.").AddClosedTag("br"); span.Add("h3").Text("Model Definition"); span.Add("paragraph").Text($"A {nx}x{ny}x{nz} grid, with {grd.Nodes.Count} nodes and {grd.Elements.Count} bar elements.").AddClosedTag("br"); span.Add("paragraph").Text("Every node in the model have a random load on it, random displacement in original location.").AddClosedTag("br"); span.Add("h3").Text("Validation Result"); /* * {//internal displacements * * span.Add("h4").Text("Internal Displacements"); * span.Add("paragraph") * .Text(string.Format("Validation output for internal displacements:")); * * span.Add("p").AddClass("bg-info").AppendHtml(string.Format("-Max ABSOLUTE Error: {0:e3}", maxInternalDisplacementAbsErr)); * } * * * {//internal force * * span.Add("h4").Text("Internal Force"); * span.Add("paragraph") * .Text(string.Format("Validation output for internal force (force residuals):")); * * span.Add("p").AddClass("bg-info").AppendHtml(string.Format("-Max ABSOLUTE Error: {0:e3}", maxInternalForceResidual)); * } */ var buf = new ValidationResult(); buf.Span = span; buf.Title = "Internal force & displacement validation"; return(buf); }
public static ValidationResult Validation_1() { var nx = 2; var ny = 2; var nz = 2; #region model definition var grd = StructureGenerator.Generate3DBarElementGrid(nx, ny, nz); //StructureGenerator.SetRandomiseConstraints(grd); StructureGenerator.SetRandomiseSections(grd); StructureGenerator.AddRandomiseNodalLoads(grd, LoadCase.DefaultLoadCase);//random nodal loads //StructureGenerator.AddRandomiseBeamUniformLoads(grd, LoadCase.DefaultLoadCase);//random elemental loads StructureGenerator.AddRandomDisplacements(grd, 0.1); #endregion grd.Solve_MPC(); #region solve & compare var res = OpenseesValidator.OpenseesValidate(grd, LoadCase.DefaultLoadCase, false); var disp = res[0]; var reac = res[1]; var dispAbsErrIdx = disp.Columns.Cast <DataColumn>().ToList().FindIndex(i => i.ColumnName.ToLower().Contains("absolute")); var dispRelErrIdx = disp.Columns.Cast <DataColumn>().ToList().FindIndex(i => i.ColumnName.ToLower().Contains("relative")); var reacAbsErrIdx = reac.Columns.Cast <DataColumn>().ToList().FindIndex(i => i.ColumnName.ToLower().Contains("absolute")); var reacRelErrIdx = reac.Columns.Cast <DataColumn>().ToList().FindIndex(i => i.ColumnName.ToLower().Contains("relative")); var maxDispAbsError = disp.Rows.Cast <DataRow>().Max(ii => (double)ii.ItemArray[dispAbsErrIdx]); var maxDispRelError = disp.Rows.Cast <DataRow>().Max(ii => (double)ii.ItemArray[dispRelErrIdx]); var maxReacAbsError = reac.Rows.Cast <DataRow>().Max(ii => (double)ii.ItemArray[reacAbsErrIdx]); var maxReacRelError = reac.Rows.Cast <DataRow>().Max(ii => (double)ii.ItemArray[reacRelErrIdx]); var maxInternalDisplacementAbsErr = 0.0; var maxInternalForceResidual = 0.0; foreach (var elm in grd.Elements) { var bar = elm as BarElement; if (bar == null) { continue; } var tr = bar.GetTransformationManager(); var L = (bar.StartNode.Location - bar.EndNode.Location).Length; var d1 = bar.GetInternalDisplacementAt(-1, LoadCase.DefaultLoadCase); var d2 = bar.GetInternalDisplacementAt(+1, LoadCase.DefaultLoadCase); var dn1 = tr.TransformGlobalToLocal(bar.StartNode.GetNodalDisplacement(LoadCase.DefaultLoadCase)); var dn2 = tr.TransformGlobalToLocal(bar.EndNode.GetNodalDisplacement(LoadCase.DefaultLoadCase)); var diff1 = dn1 - d1; var diff2 = dn2 - d2; var dd = Math.Max(diff1.Displacements.Length, diff2.Displacements.Length); var dr = Math.Max(diff1.Rotations.Length, diff2.Rotations.Length); maxInternalDisplacementAbsErr = Math.Max(maxInternalDisplacementAbsErr, dd); maxInternalDisplacementAbsErr = Math.Max(maxInternalDisplacementAbsErr, dr); //yet internal force var n = 10; var stf = bar.GetLocalStifnessMatrix();//.GetGlobalStifnessMatrix(); var u1 = Displacement.ToVector(dn1); var u2 = Displacement.ToVector(dn2); var u = new Matrix(12, 1); u1.CopyTo(u.CoreArray, 0); u2.CopyTo(u.CoreArray, 6); var endFrc = stf * u; var stFc = Force.FromVector(endFrc.CoreArray, 0); var endFc = Force.FromVector(endFrc.CoreArray, 6); for (var i = 0; i < n; i++) { var xi = i / (n - 1.0) * 2.0 + -1; var x = bar.IsoCoordsToLocalCoords(xi)[0]; var fc = bar.GetInternalForceAt(xi); var toBegin = fc.Move(new Vector(-x, 0, 0)); var toEnd = fc.Move(new Vector(L - x, 0, 0)); var stResid = stFc + toBegin; var endResid = endFc - toEnd; var errs = new double[] { stResid.Forces.Length, stResid.Moments.Length, endResid.Forces.Length, endResid.Moments.Length }.Max(); maxInternalForceResidual = Math.Max(maxInternalForceResidual, errs); } } #endregion var span = new HtmlTag("span"); span.Add("p").Text("Validate 3D frame nodal displacement and reactions"); span.Add("h3").Text("Validate with"); span.Add("paragraph").Text("OpenSEES (the Open System for Earthquake Engineering Simulation) software (available via http://opensees.berkeley.edu/)"); span.Add("h3").Text("Validate objective"); span.Add("paragraph").Text("compare nodal displacement from BFE.net library and OpenSEES for a model consist of random 3d bars"); span.Add("h3").Text("Model Definition"); span.Add("paragraph").Text($"A {nx}x{ny}x{nz} grid, with {grd.Nodes.Count} nodes and {grd.Elements.Count} bar elements.").AddClosedTag("br"); span.Add("paragraph").Text("Every node in the model have a random load on it, random displacement in original location.").AddClosedTag("br"); span.Add("paragraph").Text("Every element in the model have a random uniform distributed load on it.").AddClosedTag("br"); span.Add("h3").Text("Validation Result"); #region nodal disp {//nodal displacements span.Add("h4").Text("Nodal Displacements"); span.Add("paragraph") .Text(string.Format("Validation output for nodal displacements:")); span.Add("p").AddClass("bg-info").AppendHtml(string.Format("-Max ABSOLUTE Error: {0:e3}<br/>-Max RELATIVE Error: {1:e3}", maxDispAbsError, maxDispRelError)); var id = "tbl_" + Guid.NewGuid().ToString("N").Substring(0, 5); span.Add("button").Attr("type", "button").Text("Toggle Details").AddClasses("btn btn-primary") .Attr("onclick", $"$('#{id}').collapse('toggle');"); var div = span.Add("div").AddClasses("panel-collapse", "collapse", "out").Id(id); var tbl = div.Add("table").AddClass("table table-striped table-inverse table-bordered table-hover"); tbl.Id(id); var trH = tbl.Add("Thead").Add("tr"); foreach (DataColumn column in disp.Columns) { trH.Add("th").Attr("scope", "col").Text(column.ColumnName); } var tbody = tbl.Add("tbody"); for (var i = 0; i < disp.Rows.Count; i++) { var tr = tbody.Add("tr"); for (var j = 0; j < disp.Columns.Count; j++) { tr.Add("td").Text(disp.Rows[i][j].ToString()); } } } #endregion #region nodal reaction {//nodal reactions span.Add("h4").Text("Nodal Support Reactions"); span.Add("paragraph") .Text(string.Format("Validation output for nodal support reactions:")); span.Add("p").AddClass("bg-info").AppendHtml(string.Format("-Max ABSOLUTE Error: {0:e3}<br/>-Max RELATIVE Error: {1:e3}", maxReacAbsError, maxReacRelError)); var id = "tbl_" + Guid.NewGuid().ToString("N").Substring(0, 5); span.Add("button").Attr("type", "button").Text("Toggle Details").AddClasses("btn btn-primary") .Attr("onclick", $"$('#{id}').collapse('toggle');"); var div = span.Add("div").AddClasses("panel-collapse", "collapse", "out").Id(id); var tbl = div.Add("table").AddClass("table table-striped table-inverse table-bordered table-hover"); tbl.Id(id); var trH = tbl.Add("Thead").Add("tr"); foreach (DataColumn column in reac.Columns) { trH.Add("th").Attr("scope", "col").Text(column.ColumnName); } var tbody = tbl.Add("tbody"); for (var i = 0; i < reac.Rows.Count; i++) { var tr = tbody.Add("tr"); for (var j = 0; j < reac.Columns.Count; j++) { tr.Add("td").Text(reac.Rows[i][j].ToString()); } } } #endregion #region internal displacement {//internal displacements span.Add("h4").Text("Internal Displacements"); span.Add("paragraph") .Text(string.Format("Validation output for internal displacements (Displacement at each end node of bar elements should be equal to bar element's internal displacement of bar element at that node)")); span.Add("p").AddClass("bg-info").AppendHtml(string.Format("-Max ABSOLUTE Error: {0:e3}", maxInternalDisplacementAbsErr)); } #endregion #region internal force {//internal force span.Add("h4").Text("Internal Force"); span.Add("paragraph") .Text(string.Format("Validation output for internal force (forces retrived by K.Δ formula should be in equiblirium with internal force of bar elements at any location within element):")); span.Add("p").AddClass("bg-info").AppendHtml(string.Format("-Max ABSOLUTE Error: {0:e3}", maxInternalForceResidual)); } #endregion var buf = new ValidationResult(); buf.Span = span; buf.Title = "3D Grid Validation"; return(buf); }
public static ValidationResult Validation_1() { var nx = 5; var ny = 5; var nz = 5; #region model definition var grd = StructureGenerator.Generate3DTriangleElementGrid(nx, ny, nz); StructureGenerator.SetRandomiseSections(grd); StructureGenerator.SetRandomiseMaterial(grd); StructureGenerator.AddRandomiseNodalLoads(grd, LoadCase.DefaultLoadCase);//random nodal loads //StructureGenerator.AddRandomiseBeamUniformLoads(grd, LoadCase.DefaultLoadCase);//random elemental loads StructureGenerator.AddRandomDisplacements(grd, 0.3); #endregion StructureGenerator.AddRandomiseNodalLoads(grd, LoadCase.DefaultLoadCase);//random nodal loads grd.Solve_MPC(); var res = OpenseesValidator.OpenseesValidate(grd, LoadCase.DefaultLoadCase, false); var disp = res[0]; var reac = res[1]; var dispAbsErrIdx = disp.Columns.Cast <DataColumn>().ToList().FindIndex(i => i.ColumnName.ToLower().Contains("absolute")); var dispRelErrIdx = disp.Columns.Cast <DataColumn>().ToList().FindIndex(i => i.ColumnName.ToLower().Contains("relative")); var reacAbsErrIdx = reac.Columns.Cast <DataColumn>().ToList().FindIndex(i => i.ColumnName.ToLower().Contains("absolute")); var reacRelErrIdx = reac.Columns.Cast <DataColumn>().ToList().FindIndex(i => i.ColumnName.ToLower().Contains("relative")); var maxDispAbsError = disp.Rows.Cast <DataRow>().Max(ii => (double)ii.ItemArray[dispAbsErrIdx]); var maxDispRelError = disp.Rows.Cast <DataRow>().Max(ii => (double)ii.ItemArray[dispRelErrIdx]); var maxReacAbsError = reac.Rows.Cast <DataRow>().Max(ii => (double)ii.ItemArray[reacAbsErrIdx]); var maxReacRelError = reac.Rows.Cast <DataRow>().Max(ii => (double)ii.ItemArray[reacRelErrIdx]); //var buf = new ValidationResult(); var span = new HtmlTag("span"); span.Add("p").Text("Validate a 3D rame"); span.Add("h3").Text("Validate with"); span.Add("paragraph").Text("OpenSEES (the Open System for Earthquake Engineering Simulation) software (available via http://opensees.berkeley.edu/)"); span.Add("h3").Text("Validate objective"); span.Add("paragraph").Text("compare nodal displacement from BFE.net library and OpenSEES for a model consist of 3d bar elements with random material and section for each one, that forms a grid" + " with a randomized nodal loading and narrow erratic on location of joint of grid elements."); span.Add("h3").Text("Model Definition"); span.Add("paragraph") .Text($"A {nx}x{ny}x{nz} grid, with {grd.Nodes.Count} nodes and {grd.Elements.Count} bar elements." + " Every node in the model have a random load on it."); span.Add("h3").Text("Validation Result"); span.Add("paragraph") .Text(string.Format("Validation output for nodal displacements:")); span.Add("p").AddClass("bg-info").AppendHtml(string.Format("-Max ABSOLUTE Error: {0:e3}<br/>-Max RELATIVE Error: {1:e3}", maxDispAbsError, maxDispRelError)); //span.Add("").Text(string.Format("Max ABSOLUTE Error: {0:e3}", maxAbsError)); var id = "tbl_" + Guid.NewGuid().ToString("N").Substring(0, 5); span.Add("button").Attr("type", "button").Text("Toggle Details").AddClasses("btn btn-primary") .Attr("onclick", $"$('#{id}').collapse('toggle');"); var div = span.Add("div").AddClasses("panel-collapse", "collapse", "out").Id(id); var tbl = div.Add("table").AddClass("table table-striped table-inverse table-bordered table-hover"); tbl.Id(id); var trH = tbl.Add("Thead").Add("tr"); foreach (DataColumn column in disp.Columns) { trH.Add("th").Attr("scope", "col").Text(column.ColumnName); } var tbody = tbl.Add("tbody"); for (var i = 0; i < disp.Rows.Count; i++) { var tr = tbody.Add("tr"); for (var j = 0; j < disp.Columns.Count; j++) { tr.Add("td").Text(disp.Rows[i][j].ToString()); } } var buf = new ValidationResult(); buf.Span = span; buf.Title = "3D Grid Validation"; return(buf); }
public static ValidationResult Validation_1() { var nx = 3; var ny = 3; var nz = 3; #region model definition var grd = StructureGenerator.Generate3DTet4Grid(nx, ny, nz); //StructureGenerator.SetRandomiseConstraints(grd); StructureGenerator.SetRandomiseSections(grd); StructureGenerator.AddRandomiseNodalLoads(grd, LoadCase.DefaultLoadCase);//random nodal loads //StructureGenerator.AddRandomiseBeamUniformLoads(grd, LoadCase.DefaultLoadCase);//random elemental loads StructureGenerator.AddRandomDisplacements(grd, 0.1); #endregion grd.Solve_MPC(); #region solve & compare var res = OpenseesValidator.OpenseesValidate(grd, LoadCase.DefaultLoadCase, false); var disp = res[0]; var reac = res[1]; var dispAbsErrIdx = disp.Columns.Cast <DataColumn>().ToList().FindIndex(i => i.ColumnName.ToLower().Contains("absolute")); var dispRelErrIdx = disp.Columns.Cast <DataColumn>().ToList().FindIndex(i => i.ColumnName.ToLower().Contains("relative")); var reacAbsErrIdx = reac.Columns.Cast <DataColumn>().ToList().FindIndex(i => i.ColumnName.ToLower().Contains("absolute")); var reacRelErrIdx = reac.Columns.Cast <DataColumn>().ToList().FindIndex(i => i.ColumnName.ToLower().Contains("relative")); var maxDispAbsError = disp.Rows.Cast <DataRow>().Max(ii => (double)ii.ItemArray[dispAbsErrIdx]); var maxDispRelError = disp.Rows.Cast <DataRow>().Max(ii => (double)ii.ItemArray[dispRelErrIdx]); var maxReacAbsError = reac.Rows.Cast <DataRow>().Max(ii => (double)ii.ItemArray[reacAbsErrIdx]); var maxReacRelError = reac.Rows.Cast <DataRow>().Max(ii => (double)ii.ItemArray[reacRelErrIdx]); var maxInternalDisplacementAbsErr = 0.0; var maxInternalForceResidual = 0.0; #endregion var span = new HtmlTag("span"); span.Add("p").Text("Validate 3D frame nodal displacement and reactions"); span.Add("h3").Text("Validate with"); span.Add("paragraph").Text("OpenSEES (the Open System for Earthquake Engineering Simulation) software (available via http://opensees.berkeley.edu/)"); span.Add("h3").Text("Validate objective"); span.Add("paragraph").Text("compare nodal displacement from BFE.net library and OpenSEES for a model consist of random 3d bars"); span.Add("h3").Text("Model Definition"); { } span.Add("paragraph").Text(string.Format("A {0}x{1}x{2} grid, with {3} nodes and {4} bar elements.", nx, ny, nz, grd.Nodes.Count, grd.Elements.Count)).AddClosedTag("br"); span.Add("paragraph").Text("Every node in the model have a random load on it, random displacement in original location.").AddClosedTag("br"); span.Add("paragraph").Text("Every element in the model have a random uniform distributed load on it.").AddClosedTag("br"); span.Add("h3").Text("Validation Result"); #region nodal disp {//nodal displacements span.Add("h4").Text("Nodal Displacements"); span.Add("paragraph") .Text(string.Format("Validation output for nodal displacements:")); span.Add("p").AddClass("bg-info").AppendHtml(string.Format("-Max ABSOLUTE Error: {0:e3}<br/>-Max RELATIVE Error: {1:e3}", maxDispAbsError, maxDispRelError)); var id = "tbl_" + Guid.NewGuid().ToString("N").Substring(0, 5); span.Add("button").Attr("type", "button").Text("Toggle Details").AddClasses("btn btn-primary") .Attr("onclick", string.Format("$('#{0}').collapse('toggle');", id)); var div = span.Add("div").AddClasses("panel-collapse", "collapse", "out").Id(id); var tbl = div.Add("table").AddClass("table table-striped table-inverse table-bordered table-hover"); tbl.Id(id); var trH = tbl.Add("Thead").Add("tr"); foreach (DataColumn column in disp.Columns) { trH.Add("th").Attr("scope", "col").Text(column.ColumnName); } var tbody = tbl.Add("tbody"); for (var i = 0; i < disp.Rows.Count; i++) { var tr = tbody.Add("tr"); for (var j = 0; j < disp.Columns.Count; j++) { tr.Add("td").Text(disp.Rows[i][j].ToString()); } } } #endregion #region nodal reaction {//nodal reactions span.Add("h4").Text("Nodal Support Reactions"); span.Add("paragraph") .Text(string.Format("Validation output for nodal support reactions:")); span.Add("p").AddClass("bg-info").AppendHtml(string.Format("-Max ABSOLUTE Error: {0:e3}<br/>-Max RELATIVE Error: {1:e3}", maxReacAbsError, maxReacRelError)); var id = "tbl_" + Guid.NewGuid().ToString("N").Substring(0, 5); span.Add("button").Attr("type", "button").Text("Toggle Details").AddClasses("btn btn-primary") .Attr("onclick", string.Format("$('#{0}').collapse('toggle');", id)); var div = span.Add("div").AddClasses("panel-collapse", "collapse", "out").Id(id); var tbl = div.Add("table").AddClass("table table-striped table-inverse table-bordered table-hover"); tbl.Id(id); var trH = tbl.Add("Thead").Add("tr"); foreach (DataColumn column in reac.Columns) { trH.Add("th").Attr("scope", "col").Text(column.ColumnName); } var tbody = tbl.Add("tbody"); for (var i = 0; i < reac.Rows.Count; i++) { var tr = tbody.Add("tr"); for (var j = 0; j < reac.Columns.Count; j++) { tr.Add("td").Text(reac.Rows[i][j].ToString()); } } } #endregion #region internal displacement {//internal displacements span.Add("h4").Text("Internal Displacements"); span.Add("paragraph") .Text(string.Format("Validation output for internal displacements (Displacement at each end node of bar elements should be equal to bar element's internal displacement of bar element at that node)")); span.Add("p").AddClass("bg-info").AppendHtml(string.Format("-Max ABSOLUTE Error: {0:e3}", maxInternalDisplacementAbsErr)); } #endregion #region internal force {//internal force span.Add("h4").Text("Internal Force"); span.Add("paragraph") .Text(string.Format("Validation output for internal force (forces retrived by K.Δ formula should be in equiblirium with internal force of bar elements at any location within element):")); span.Add("p").AddClass("bg-info").AppendHtml(string.Format("-Max ABSOLUTE Error: {0:e3}", maxInternalForceResidual)); } #endregion var buf = new ValidationResult(); buf.Span = span; buf.Title = "3D Grid Validation"; return(buf); }
public static ValidationResult Validation_2() { var nx = 5; var ny = 5; var nz = 5; var grd = StructureGenerator.Generate3DBarElementGrid(nx, ny, nz); //StructureGenerator.SetRandomiseConstraints(grd); StructureGenerator.SetRandomiseSections(grd); StructureGenerator.AddRandomiseNodalLoads(grd, LoadCase.DefaultLoadCase);//random nodal loads //StructureGenerator.AddRandomiseBeamUniformLoads(grd, LoadCase.DefaultLoadCase);//random elemental loads StructureGenerator.AddRandomDisplacements(grd, 0.1); grd.Solve_MPC(); var maxInternalDisplacementAbsErr = 0.0; var maxInternalForceResidual = 0.0; foreach (var elm in grd.Elements) { var bar = elm as BarElement; if (bar == null) { continue; } var tr = bar.GetTransformationManager(); var L = (bar.StartNode.Location - bar.EndNode.Location).Length; var d1 = bar.GetInternalDisplacementAt(-1, LoadCase.DefaultLoadCase); var d2 = bar.GetInternalDisplacementAt(+1, LoadCase.DefaultLoadCase); var dn1 = tr.TransformGlobalToLocal(bar.StartNode.GetNodalDisplacement(LoadCase.DefaultLoadCase)); var dn2 = tr.TransformGlobalToLocal(bar.EndNode.GetNodalDisplacement(LoadCase.DefaultLoadCase)); var diff1 = dn1 - d1; var diff2 = dn2 - d2; var dd = Math.Max(diff1.Displacements.Length, diff2.Displacements.Length); var dr = Math.Max(diff1.Rotations.Length, diff2.Rotations.Length); maxInternalDisplacementAbsErr = Math.Max(maxInternalDisplacementAbsErr, dd); maxInternalDisplacementAbsErr = Math.Max(maxInternalDisplacementAbsErr, dr); //yet internal force var n = 10; var stf = bar.GetLocalStifnessMatrix();//.GetGlobalStifnessMatrix(); var u1 = Displacement.ToVector(dn1); var u2 = Displacement.ToVector(dn2); var u = new Matrix(12, 1); u1.CopyTo(u.CoreArray, 0); u2.CopyTo(u.CoreArray, 6); var endFrc = stf * u; var stFc = Force.FromVector(endFrc.CoreArray, 0); var endFc = Force.FromVector(endFrc.CoreArray, 6); for (var i = 0; i < n; i++) { var xi = i / (n - 1.0) * 2.0 + -1; var x = bar.IsoCoordsToLocalCoords(xi)[0]; var fc = bar.GetInternalForceAt(xi); var toBegin = fc.Move(new Vector(-x, 0, 0)); var toEnd = fc.Move(new Vector(L - x, 0, 0)); var stResid = stFc + toBegin; var endResid = endFc - toEnd; var errs = new double[] { stResid.Forces.Length, stResid.Moments.Length, endResid.Forces.Length, endResid.Moments.Length }.Max(); maxInternalForceResidual = Math.Max(maxInternalForceResidual, errs); } } var span = new HtmlTag("span"); span.Add("p").Text("Validate a 3D frame internal force and internal displacement"); span.Add("h3").Text("Validate objective"); span.Add("paragraph").Text("validate internal force and internal displacement of bar elements. ") .AddClosedTag("br"); span.Add("paragraph").Text("Internal displacement in each element at each end node should be equal to that node's displacement.").AddClosedTag("br"); span.Add("paragraph").Text("End forces and mid force should be in equiblirium with each other.").AddClosedTag("br"); span.Add("h3").Text("Model Definition"); span.Add("paragraph").Text($"A {nx}x{ny}x{nz} grid, with {grd.Nodes.Count} nodes and {grd.Elements.Count} bar elements.").AddClosedTag("br"); span.Add("paragraph").Text("Every node in the model have a random load on it, random displacement in original location.").AddClosedTag("br"); span.Add("h3").Text("Validation Result"); {//internal displacements span.Add("h4").Text("Internal Displacements"); span.Add("paragraph") .Text(string.Format("Validation output for internal displacements:")); span.Add("p").AddClass("bg-info").AppendHtml(string.Format("-Max ABSOLUTE Error: {0:e3}", maxInternalDisplacementAbsErr)); } {//internal force span.Add("h4").Text("Internal Force"); span.Add("paragraph") .Text(string.Format("Validation output for internal force (force residuals):")); span.Add("p").AddClass("bg-info").AppendHtml(string.Format("-Max ABSOLUTE Error: {0:e3}", maxInternalForceResidual)); } var buf = new ValidationResult(); buf.Span = span; buf.Title = "Internal force & displacement validation"; return(buf); }