Exemple #1
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);
        }
        public void BinarySerialization()
        {
            var crosecs = new List <CroSec>();

            crosecs.Add(new CroSec_Circle("family", "name", "country", null, null, 10.0, 2.0));

            BinaryFormatter formatter = new BinaryFormatter();

            using (FileStream fs = File.Create(@"crosecs.dat"))
            {
                formatter.Serialize(fs, crosecs);
            }

            var table = new CroSecTable();

            table.read(@"crosecs.dat");

            var h0 = crosecs[0].getHeight();
            var h1 = table.crosecs[0].getHeight();

            Assert.AreEqual(h0, h1, 1E-5);
        }
        public void Beam()
        {
            var    k3d    = new Toolkit();
            var    logger = new MessageLogger();
            double length = 4.0;
            var    p0     = new Point3(0, 0, 0);
            var    p1     = new Point3(length, 0, 0);
            var    axis   = new Line3(p0, p1);

            var resourcePath = Path.Combine(Utils.PluginPathExe(), @"..\..\Resources\");

            // get a material from the material table in the folder 'Resources'
            var materialPath = Path.Combine(resourcePath, "MaterialProperties.csv");
            var inMaterials  = k3d.Material.ReadMaterialTable(materialPath);
            var material     = inMaterials.Find(x => x.name == "Steel");

            // 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 == "FRQ");
            var         crosec_initial = crosec_family.Find(x => x.name == "FRQ45/5");

            // attach the material to the cross section
            crosec_initial.setMaterial(material);

            // create the column
            var beams = k3d.Part.LineToBeam(new List <Line3> {
                axis
            }, new List <string>()
            {
                "B1"
            }, new List <CroSec>()
            {
                crosec_initial
            }, logger,
                                            out var out_points);

            // create supports
            var supports = new List <Support>
            {
                k3d.Support.Support(p0, new List <bool>()
                {
                    true, true, true, true, false, false
                }),
                k3d.Support.Support(p1, new List <bool>()
                {
                    false, true, true, false, false, false
                })
            };

            // create a Point-load
            var loads = new List <Load>
            {
                k3d.Load.PointLoad(p1, new Vector3(0, 0, -100))
            };

            // create the model
            var model = k3d.Model.AssembleModel(beams, supports, loads,
                                                out info, out var mass, out var cog, out var message, out var warning);

            // 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 List <double> nat_frequencies, out List <double> modal_masses, out List <Vector3> participation_facs,
                                                out List <double> participation_facs_disp, out model);

            Assert.AreEqual(nat_frequencies[0], 8.9828263788644716, 1e-8);
        }
Exemple #4
0
        public void Column()
        {
            var    k3d    = new Toolkit();
            var    logger = new MessageLogger();
            double length = 4.0;
            var    p0     = new Point3(0, 0, 0);
            var    p1     = new Point3(0, 0, length);
            var    axis   = new Line3(p0, p1);

            var resourcePath = @"";

            // get a material from the material table in the folder 'Resources'
            var materialPath = Path.Combine(resourcePath, "Materials/MaterialProperties.csv");
            var inMaterials  = k3d.Material.ReadMaterialTable(materialPath);
            var material     = inMaterials.Find(x => x.name == "Steel");

            // get a cross section from the cross section table in the folder 'Resources'
            var         crosecPath     = Path.Combine(resourcePath, "CrossSections/CrossSectionValues.bin");
            CroSecTable inCroSecs      = k3d.CroSec.ReadCrossSectionTable(crosecPath, out var info);
            var         crosec_family  = inCroSecs.crosecs.FindAll(x => x.family == "FRQ");
            var         crosec_initial = crosec_family.Find(x => x.name == "FRQ45/5");

            // attach the material to the cross section
            crosec_initial.setMaterial(material);

            // create the column
            var beams = k3d.Part.LineToBeam(new List <Line3> {
                axis
            }, new List <string>()
            {
                "B1"
            }, new List <CroSec>()
            {
                crosec_initial
            }, logger,
                                            out var out_points);

            // create supports
            var supports = new List <Support>();

            supports.Add(k3d.Support.Support(p0, new List <bool>()
            {
                true, true, true, false, false, true
            }));
            supports.Add(k3d.Support.Support(p1, new List <bool>()
            {
                true, true, false, false, false, false
            }));

            // create a Point-load
            var loads = new List <Load>
            {
                k3d.Load.PointLoad(p1, new Vector3(0, 0, -100))
            };

            // create the model
            var model = k3d.Model.AssembleModel(beams, supports, loads,
                                                out info, out var mass, out var cog, out var message, out var warning);

            // calculate Th.I response
            model = k3d.Algorithms.AnalyzeThI(model, out var out_max_disp, out var out_g, out var out_comp, out message);

            // optimize the cross section
            model = k3d.Algorithms.OptiCroSec(model, crosec_family,
                                              out var maxDisplacements, out var compliances, out message);

            // disassemble the model
            k3d.Model.Disassemble(model, logger, out var points, out var lines, out var meshes, out beams, out var shells,
                                  out supports, out loads, out var materials, out var crosecs, out var joints);

            // check the buckling length,; a negative value means that the length was autogenerated
            Assert.AreEqual(beams[0].BucklingLength(BuilderElementStraightLine.BucklingDir.bklY), -length, 1E-10);
            // check the resulting cross section
            Assert.AreEqual(beams[0].BucklingLength(BuilderElementStraightLine.BucklingDir.bklY), -length, 1E-10);
            Assert.AreEqual(beams[0].crosec.name, "FRQ70/6");
        }
        public void TwoPointLoads()
        {
            var    k3d    = new Toolkit();
            var    logger = new MessageLogger();
            double length = 4.0;
            var    p0     = new Point3(0, 0, 0);
            var    p1     = new Point3(length, 0, 0);
            var    axis   = new Line3(p0, p1);

            var resourcePath = @"";

            // get a material from the material table in the folder 'Resources'
            var materialPath = Path.Combine(resourcePath, "Materials/MaterialProperties.csv");
            var inMaterials  = k3d.Material.ReadMaterialTable(materialPath);
            var material     = inMaterials.Find(x => x.name == "Steel");

            // get a cross section from the cross section table in the folder 'Resources'
            var         crosecPath     = Path.Combine(resourcePath, "CrossSections/CrossSectionValues.bin");
            CroSecTable inCroSecs      = k3d.CroSec.ReadCrossSectionTable(crosecPath, out var info);
            var         crosec_family  = inCroSecs.crosecs.FindAll(x => x.family == "FRQ");
            var         crosec_initial = crosec_family.Find(x => x.name == "FRQ45/5");

            // attach the material to the cross section
            crosec_initial.setMaterial(material);

            // create the column
            var beams = k3d.Part.LineToBeam(new List <Line3> {
                axis
            }, new List <string>()
            {
                "B1"
            }, new List <CroSec>()
            {
                crosec_initial
            }, logger,
                                            out var out_points);

            // create supports
            var supports = new List <Support>
            {
                k3d.Support.Support(p0, new List <bool>()
                {
                    true, true, true, true, true, true
                }),
            };

            // create a Point-load
            var loads = new List <Load>
            {
                k3d.Load.PointLoad(p1, new Vector3(0, 100, 0), new Vector3(), "LC0"),
                k3d.Load.PointLoad(p1, new Vector3(0, 0, 50), new Vector3(), "LC1")
            };

            // create the model
            var model = k3d.Model.AssembleModel(beams, supports, loads,
                                                out info, out var mass, out var cog, out var message, out var is_warning);

            // calculate the displacements
            ThIAnalyze.solve(model, out var outMaxDisp, out var outG, out var outComp, out var warning, out model);
            Assert.AreEqual(54.338219302231252, outMaxDisp[0], 1e-5);
            Assert.AreEqual(27.169109651115626, outMaxDisp[1], 1e-5);
        }