Ejemplo n.º 1
0
        /// <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;
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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";
        }