示例#1
0
        public static Analysis Execute(List <js.JSNode> nodes, List <js.JSBar> bars, List <js.JSPointLoad> pointLoads)
        {
            var analysis = new Analysis();

            var jointAnalysis = new js.JSModel();

            jointAnalysis.AddItems(bars, nodes, pointLoads);
            jointAnalysis.Solve();

            analysis.model = jointAnalysis;
            return(analysis);
        }
示例#2
0
        public void SolveDeflections(JSModel model)
        {
            var LoverAE = new double[model.Bars.Count];

            foreach (var bar in model.Bars)
            {
                LoverAE[bar.Number] = bar.Length / (double.IsNaN(bar.EA) ? model.EA_default : bar.EA);
            }

            foreach (var node in model.Nodes)
            {
                var defl = new Vector2d();
                if (!node.XRestrained)
                {
                    defl.X = CalculateDeflection(node, GetVirtualVectorB_FromVirtualForceFx(node), LoverAE);
                }
                if (!node.YRestrained)
                {
                    defl.Y = CalculateDeflection(node, GetVirtualVectorB_FromVirtualForceFy(node), LoverAE);
                }
                node.Deflection = defl;
            }
        }
示例#3
0
        /// <summary>
        /// Performs the analysis: populates bars with bar forces and nodes with node reactions.
        /// </summary>
        /// <param name="jointAnalysis">The joint analysis to be updated.</param>
        public void SolveForces(JSModel jointAnalysis)
        {
            var Nodes = jointAnalysis.Nodes;
            var Bars  = jointAnalysis.Bars;
            var Loads = jointAnalysis.Loads;

            for (int i = 0; i < Nodes.Count; i++)
            {
                Nodes[i].Reset(i);
            }

            for (int i = 0; i < Bars.Count; i++)
            {
                Bars[i].Reset(i);
            }

            foreach (var pl in Loads)
            {
                pl.Node.AppliedForces += pl.Force;
            }

            int nodeCount         = Nodes.Count;
            int xConstrainedCount = 0;
            int yConstrainedCount = 0;
            int variableNumber    = Bars.Count;

            //Variables number
            //0 to Nbars-1 (for each bar force)
            //Nbars to Nbars+Nconstraints-1 (for each constrained direction on each node)

            foreach (var node in Nodes)
            {
                if (node.XRestrained)
                {
                    xConstrainedCount++;
                    node.VariableNumber_Rx = variableNumber++;
                }
                if (node.YRestrained)
                {
                    yConstrainedCount++;
                    node.VariableNumber_Ry = variableNumber++;
                }
            }

            NumberOfEquations = nodeCount * 2 + 3;
            NumberOfUnknowns  = variableNumber;

            if (NumberOfEquations < variableNumber)
            {
                throw new Exception("Number of unknowns exceeds the number of equations");
            }

            //Unknowns list
            //Bars 0 => n
            //Reactions 0 => n
            SetupMatrices();

            int equationNo = 0;

            foreach (var node in Nodes)
            {
                AddNodeXEquilibrium(node, equationNo++);
                AddNodeYEquilibrium(node, equationNo++);
            }
            AddGlobalXEquilibrium(Nodes, equationNo++);
            AddGlobalYEquilibrium(Nodes, equationNo++);
            AddGlobalMomentEquilibrium(Nodes, equationNo++);

            var xResult = SolveForMatrixX();

            foreach (var node in Nodes)
            {
                node.ReactionResult = new Vector2d();
                if (node.XRestrained)
                {
                    var value = xResult[node.VariableNumber_Rx];
                    if (Math.Abs(value) > MinForceValue)
                    {
                        node.ReactionResult.X = value;
                    }
                }
                if (node.YRestrained)
                {
                    var value = xResult[node.VariableNumber_Ry];
                    if (Math.Abs(value) > MinForceValue)
                    {
                        node.ReactionResult.Y = value;
                    }
                }
            }

            foreach (var bar in Bars)
            {
                var value = xResult[bar.Number];
                bar.ForceResult = Math.Abs(value) > MinForceValue ? value : 0;
            }

            X_Array = xResult;
        }