/// <summary> /// /// The main program executes the tests. Output may be routed to /// various locations, depending on the arguments passed. /// </summary> /// <remarks>Run with --help for a full list of arguments supported</remarks> /// <param name="args"></param> public static int Main(string[] args) { // set the system of physical units to SI INIReader.ClearSingleton(); UnitsConversionFactories.ClearSingleton(); var ini = INIReader.Instance(); ini.Values["UnitsSystem"] = "SI"; ini.Values["gravity"] = "10.0"; // run the tests var res = new AutoRun().Execute(args); Console.WriteLine("Press any key to close"); Console.ReadKey(); return res; }
public void ImperialUnits() { var k3d = new Toolkit(); var logger = new MessageLogger(); // make temporary changes to the the ini-file and units-conversion INIReader.ClearSingleton(); UnitsConversionFactories.ClearSingleton(); var ini = INIReader.Instance(); ini.Values["UnitsSystem"] = "imperial"; var resourcePath = Path.Combine(Utils.PluginPathExe(), @"..\..\Resources\"); // get a cross section from the cross section table in the folder 'Resources' var crosecPath = Path.Combine(resourcePath, "CrossSectionValues.csv"); CroSecTable inCroSecs = k3d.CroSec.ReadCrossSectionTable(crosecPath, out var info); var crosec_family = inCroSecs.crosecs.FindAll(x => x.family == "W"); var crosec_initial = crosec_family.Find(x => x.name == "W12X26"); // clear temporary changes to the the ini-file and units-conversion INIReader.ClearSingleton(); UnitsConversionFactories.ClearSingleton(); var cs = crosec_initial as CroSec_I; var m2feet = 3.28084; var height_feet = 0.31 * m2feet; var width_feet = 0.165 * m2feet; Assert.AreEqual(cs._height, height_feet, 1e-5); Assert.AreEqual(cs.lf_width, width_feet, 1e-5); var feet42inch4 = Math.Pow(12.0, 4); var cm42inch4 = Math.Pow(1.0 / 2.54, 4); var Iyy_inch1 = 8491.12 * cm42inch4; var Iyy_inch2 = cs.Iyy * feet42inch4; Assert.AreEqual(Iyy_inch1, Iyy_inch2, 1e-1); }
public void ModelMassImperialUnits() { // make temporary changes to the the ini-file and units-conversion INIReader.ClearSingleton(); UnitsConversionFactories.ClearSingleton(); var ini = INIReader.Instance(); ini.Values["UnitsSystem"] = "imperial"; ini.Values["gravity"] = "9.80665"; var k3d = new Toolkit(); var gamma = 1.0; // (kip/ft3) var unit_material = new FemMaterial_Isotrop("unit", "unit", 1, 0.5, 0.5, gamma, 1.0, 1.0, null); var b = 12; // (inch) var t = 6; // (inch) var unit_crosec = k3d.CroSec.Box(b, b, b, t, t, t, 0, 0, unit_material); var elems = new List <BuilderBeam>() { k3d.Part.IndexToBeam(0, 1, "A", unit_crosec), }; var L = 1.0; // in feet var points = new List <Point3> { new Point3(), new Point3(L, 0, 0) }; var model = k3d.Model.AssembleModel(elems, null, null, out var info, out var mass, out var cog, out var msg, out var runtimeWarning, new List <Joint>(), points); // clear temporary changes to the the ini-file and units-conversion INIReader.ClearSingleton(); UnitsConversionFactories.ClearSingleton(); ini = INIReader.Instance(); // switch back to SI units ini.Values["UnitsSystem"] = "SI"; Assert.AreEqual(mass, 1000, 1e-10); }
public void MeshLoadProfiling() { var k3d = new Toolkit(); int nBeams = 20; int nFaces = 1500; double lengthBeams = 10.0; double xIncBeam = lengthBeams / nBeams; double xIncMesh = lengthBeams / nFaces; double limit_dist = xIncBeam / 100.0; // create beams var lines = new List <Line3>(); var nodeI = new Point3(0, 0, 0); for (int beamInd = 0; beamInd < nBeams; ++beamInd) { var nodeK = new Point3(nodeI.X + xIncBeam, 0, 0); lines.Add(new Line3(nodeI, nodeK)); nodeI = nodeK; } LineToBeam.solve(new List <Point3>(), lines, true, true, limit_dist, new List <Vector3>(), new List <string>(), new List <Color>(), new List <CroSec>(), true, out List <Point3> outPoints, out List <BuilderBeam> builderElements, out string info); // create a MeshLoad var meshUnitLoadsBuffer = new Dictionary <MeshUnitLoad, MeshUnitLoad>(); var mesh = new Mesh(); mesh.Vertices.Add(new Point3d(0, -0.5, 0)); mesh.Vertices.Add(new Point3d(0, 0.5, 0)); for (var faceInd = 0; faceInd < nFaces; ++faceInd) { mesh.Vertices.Add(new Point3d((faceInd + 1) * xIncMesh, -0.5, 0)); mesh.Vertices.Add(new Point3d((faceInd + 1) * xIncMesh, 0.5, 0)); var nV = mesh.Vertices.Count; mesh.Faces.AddFace(new MeshFace(nV - 4, nV - 3, nV - 1, nV - 2)); } UnitsConversionFactory ucf = UnitsConversionFactories.Conv(); UnitConversion m = ucf.m(); var baseMesh = m.toBaseMesh(new RhinoMesh(mesh)); var load = new MeshLoad(new List <Vector3>() { new Vector3(0, 0, -1) }); load.InitUnitLoads(meshUnitLoadsBuffer, baseMesh, LoadOrientation.global, new List <bool>() { true, true }, new List <Point3>(), new List <string>()); // create a Support var support = k3d.Support.Support(new Point3(0, 0, 0), k3d.Support.SupportFixedConditions); // assemble the model var model = k3d.Model.AssembleModel(builderElements, new List <Support>() { support }, new List <Load>() { load }, out info, out var mass, out var cog, out var msg, out var runtimeWarning); ThIAnalyze.solve(model, out var outMaxDisp, out var outG, out var outComp, out var warning, out model); Assert.AreEqual(outMaxDisp[0], 2.8232103119331837, 1E-5); // Assert.AreEqual(1, 1, 1E-8); }
public void CantileverEigenfrequency() { // make temporary changes to the the ini-file and units-conversion INIReader.ClearSingleton(); UnitsConversionFactories.ClearSingleton(); var ini = INIReader.Instance(); ini.Values["UnitsSystem"] = "imperial"; ini.Values["gravity"] = "9.80665"; var k3d = new Toolkit(); var E = 70000; // (kip/ft2) == 486111.1 (psi) var gamma = 1.0; // (kip/ft3) var unit_material = new FemMaterial_Isotrop("unit", "unit", E, 0.5 * E, 0.5 * E, gamma, 1.0, 1.0, null); var b = 6; // (inch) var t = 3; // (inch) // Iy = 108 inch^4 // g = 20.833 lb/inch var unit_crosec = k3d.CroSec.Box(b, b, b, t, t, t, 0, 0, unit_material); var elems = new List <BuilderBeam>() { k3d.Part.IndexToBeam(0, 1, "A", unit_crosec), }; var L = 10.0; // in feet var points = new List <Point3> { new Point3(), new Point3(L, 0, 0) }; var supports = new List <Support> { k3d.Support.Support(0, k3d.Support.SupportFixedConditions) }; var model = k3d.Model.AssembleModel(elems, supports, null, out var info, out var mass, out var cog, out var msg, out var runtimeWarning, new List <Joint>(), points); // calculate the natural vibrations int from_shape_ind = 1; int shapes_num = 1; int max_iter = 100; double eps = 1e-8; var disp_dummy = new List <double>(); var scaling = EigenShapesScalingType.matrix; model = k3d.Algorithms.NaturalVibes(model, from_shape_ind, shapes_num, max_iter, eps, disp_dummy, scaling, out var nat_frequencies, out var modal_masses, out var participation_facs, out var participation_facs_disp, out model); // calculate the expected value of the first eigen-frequency // see Young, W. C., Budynas, R. G.(2002). Roark's Formulas for Stress and Strain . // 7nd Edition, McGraw-Hill, Chapter 16 , pp 767 - 768 var E_ = E * 1000.0 * Math.Pow(UnitsConversionFactory.in2ft, 2); var I_ = unit_crosec.Iyy / Math.Pow(UnitsConversionFactory.in2ft, 4); var w_ = unit_crosec.A * gamma * 1000.0 * UnitsConversionFactory.in2ft; var g_ = UnitsConversionFactory.g_IU / UnitsConversionFactory.in2ft; var L_ = L / UnitsConversionFactory.in2ft; var Kn = 3.52; var f1_expected = Kn / 2.0 / Math.PI * Math.Sqrt(E_ * I_ * g_ / w_ / Math.Pow(L_, 4)); Assert.AreEqual(nat_frequencies[0], f1_expected, 1e-2); // clear temporary changes to the the ini-file and units-conversion INIReader.ClearSingleton(); UnitsConversionFactories.ClearSingleton(); ini = INIReader.Instance(); // switch back to SI units ini.Values["UnitsSystem"] = "SI"; }
public void MeshLoadProfiling() { var k3d = new Toolkit(); var logger = new MessageLogger(); int nBeams = 20; int nFaces = 1500; double lengthBeams = 10.0; double xIncBeam = lengthBeams / nBeams; double xIncMesh = lengthBeams / nFaces; double limit_dist = xIncBeam / 100.0; // create beams var lines = new List <Line3>(); var nodeI = new Point3(0, 0, 0); for (int beamInd = 0; beamInd < nBeams; ++beamInd) { var nodeK = new Point3(nodeI.X + xIncBeam, 0, 0); lines.Add(new Line3(nodeI, nodeK)); nodeI = nodeK; } var builderElements = k3d.Part.LineToBeam(lines, new List <string>(), new List <CroSec>(), logger, out List <Point3> outPoints); // create a MeshLoad var mesh = new Mesh3((nFaces + 1) * 2, nFaces); mesh.AddVertex(new Point3(0, -0.5, 0)); mesh.AddVertex(new Point3(0, 0.5, 0)); for (var faceInd = 0; faceInd < nFaces; ++faceInd) { mesh.AddVertex(new Point3((faceInd + 1) * xIncMesh, -0.5, 0)); mesh.AddVertex(new Point3((faceInd + 1) * xIncMesh, 0.5, 0)); var nV = mesh.Vertices.Count; mesh.AddFace(nV - 4, nV - 3, nV - 1, nV - 2); } UnitsConversionFactory ucf = UnitsConversionFactories.Conv(); UnitConversion m = ucf.m(); var baseMesh = m.toBaseMesh(mesh); // create a mesh load var load = k3d.Load.MeshLoad(new List <Vector3>() { new Vector3(0, 0, -1) }, baseMesh); // create a support var support = k3d.Support.Support(new Point3(0, 0, 0), k3d.Support.SupportFixedConditions); // assemble the model var model = k3d.Model.AssembleModel(builderElements, new List <Support>() { support }, new List <Load>() { load }, out var info, out var mass, out var cog, out var message, out var runtimeWarning); // calculate the model model = k3d.Algorithms.AnalyzeThI(model, out var outMaxDisp, out var outG, out var outComp, out var warning); Assert.AreEqual(outMaxDisp[0], 2.8232103119228276, 1E-5); }