public static Dictionary <string, object> BranchPunchingStrength(string HssTrussConnectionMemberType, string HssTrussConnectionClassification, CustomProfile MainBranchSection, double theta_main,
                                                                         string AxialForceTypeMain, CustomProfile SecondaryBranchSection, double theta_sec, string AxialForceTypeSecondary, double F_yb, CustomProfile ChordSection, double F_yc, bool IsTensionChord,
                                                                         double P_uChord, double M_uChord, double O_v, string Code = "AISC360-10")
        {
            //Default values
            double phiP_nMain       = -1;
            double phiP_nSec        = -1;
            bool   IsApplicableMain = false;
            bool   IsApplicableSecn = false;

            //Calculation logic:

            #region Evaluate and update input

            HssTrussConnectionMemberType     _MemberType;
            HssTrussConnectionClassification _Class;
            AxialForceType _MainBranchForceType;
            AxialForceType _SecondaryBranchForceType;


            ISectionHollow _MainBranchSection;
            ISectionHollow _SecondaryBranchSection;
            ISectionHollow _ChordSection;

            bool IsValidMemType = Enum.TryParse(HssTrussConnectionMemberType, true, out _MemberType);
            if (IsValidMemType == false)
            {
                throw new Exception("Failed to convert string. HssTrussConnectionMemberType must be either RHS (rectanguar HSS) or CHS (circular HSS) . Please check input.");
            }


            bool IsValidIClass = Enum.TryParse(HssTrussConnectionClassification, true, out _Class);
            if (IsValidIClass == false)
            {
                throw new Exception("Failed to convert string. HssTrussConnectionClassification needs to specify T,Y,X, GappedK or Overlapped K connection type. Please check input.");
            }


            bool IsValidMainForce = Enum.TryParse(AxialForceTypeMain, true, out _MainBranchForceType);
            if (IsValidMainForce == false)
            {
                throw new Exception("Failed to convert string. Specify force as Tension, Compression or Reversible. Please check input.");
            }


            bool IsValidSecForce = Enum.TryParse(AxialForceTypeSecondary, true, out _SecondaryBranchForceType);
            if (IsValidSecForce == false)
            {
                throw new Exception("Failed to convert string. Specify force as Tension, Compression or Reversible. Please check input.");
            }

            if (!(MainBranchSection.Section is ISectionHollow) || !(SecondaryBranchSection.Section is ISectionHollow) || !(ChordSection.Section is ISectionHollow))
            {
                throw new Exception("Failed to convert section. Section needs to be either a Pipe or a Tube. Please check input.");
            }

            _MainBranchSection      = MainBranchSection.Section as ISectionHollow;
            _SecondaryBranchSection = SecondaryBranchSection.Section as ISectionHollow;
            _ChordSection           = ChordSection.Section as ISectionHollow;
            #endregion


            HssTrussConnectionFactory factory = new HssTrussConnectionFactory();

            IHssTrussBranchConnection conMain = factory.GetConnection(_MemberType, _Class, _ChordSection, _MainBranchSection, _SecondaryBranchSection, F_yc,
                                                                      F_yb, theta_main, theta_sec, _MainBranchForceType, _SecondaryBranchForceType, IsTensionChord, P_uChord, M_uChord, O_v);

            IHssTrussBranchConnection conSec = factory.GetConnection(_MemberType, _Class, _ChordSection, _SecondaryBranchSection, _MainBranchSection, F_yc,
                                                                     F_yb, theta_sec, theta_main, _SecondaryBranchForceType, _MainBranchForceType, IsTensionChord, P_uChord, M_uChord, O_v);

            phiP_nMain = conMain.GetBranchPunchingStrength().Value;
            phiP_nSec  = conSec.GetBranchPunchingStrength().Value;

            IsApplicableMain = conMain.GetBranchPunchingStrength().IsApplicable;
            IsApplicableSecn = conSec.GetBranchPunchingStrength().IsApplicable;

            return(new Dictionary <string, object>
            {
                { "phiP_nMain", phiP_nMain }
                , { "phiP_nSec", phiP_nSec }
                , { "IsApplicableMain", IsApplicableMain }
                , { "IsApplicableSecn", IsApplicableSecn }
            });
        }
        public static Dictionary <string, object> ChordWallPlastificationStrength(string HssTrussConnectionMemberType, string HssTrussConnectionClassification, CustomProfile MainBranchSection, double theta_main,
                                                                                  string AxialForceTypeMain,
                                                                                  CustomProfile SecondaryBranchSection, double theta_sec, string AxialForceTypeSecondary, double F_yb, CustomProfile ChordSection, double F_yc, bool IsTensionChord,
                                                                                  double P_uChord, double M_uChord, double O_v, string Code = "AISC360-10")
        {
            //Default values
            double phiP_nMain       = 0;
            double phiP_nSec        = 0;
            bool   IsApplicableMain = false;
            bool   IsApplicableSecn = false;


            //Calculation logic:

            #region Evaluate and update input

            HssTrussConnectionMemberType     _MemberType;
            HssTrussConnectionClassification _Class;
            AxialForceType _MainBranchForceType;
            AxialForceType _SecondaryBranchForceType;


            ISectionHollow _MainBranchSection;
            ISectionHollow _SecondaryBranchSection;
            ISectionHollow _ChordSection;

            bool IsValidMemType = Enum.TryParse(HssTrussConnectionMemberType, true, out _MemberType);
            if (IsValidMemType == false)
            {
                throw new Exception("Failed to convert string. HssTrussConnectionMemberType must be either RHS (rectanguar HSS) or CHS (circular HSS) . Please check input.");
            }


            bool IsValidIClass = Enum.TryParse(HssTrussConnectionClassification, true, out _Class);
            if (IsValidIClass == false)
            {
                throw new Exception("Failed to convert string. HssTrussConnectionClassification needs to specify T,Y,X, GappedK or Overlapped K connection type. Please check input.");
            }


            bool IsValidMainForce = Enum.TryParse(AxialForceTypeMain, true, out _MainBranchForceType);
            if (IsValidMainForce == false)
            {
                throw new Exception("Failed to convert string. Specify force as Tension, Compression or Reversible. Please check input.");
            }


            bool IsValidSecForce = Enum.TryParse(AxialForceTypeSecondary, true, out _SecondaryBranchForceType);
            if (IsValidSecForce == false)
            {
                throw new Exception("Failed to convert string. Specify force as Tension, Compression or Reversible. Please check input.");
            }

            if (!(MainBranchSection.Section is ISectionHollow) || !(SecondaryBranchSection.Section is ISectionHollow) || !(ChordSection.Section is ISectionHollow))
            {
                throw new Exception("Failed to convert section. Section needs to be either a Pipe or a Tube. Please check input.");
            }

            _MainBranchSection      = MainBranchSection.Section as ISectionHollow;
            _SecondaryBranchSection = SecondaryBranchSection.Section as ISectionHollow;
            _ChordSection           = ChordSection.Section as ISectionHollow;
            #endregion


            HssTrussConnectionFactory factory = new HssTrussConnectionFactory();


            bool IsKConnection = _Class == Kodestruct.Steel.AISC.Entities.HssTrussConnectionClassification.GappedK || _Class == Kodestruct.Steel.AISC.Entities.HssTrussConnectionClassification.OverlappedK ? true : false;

            if (IsKConnection == true && _MemberType == Kodestruct.Steel.AISC.Entities.HssTrussConnectionMemberType.Chs && _MainBranchForceType == AxialForceType.Reversible && _SecondaryBranchForceType == AxialForceType.Reversible)
            {
                // account for load reversal in branches
                IHssTrussBranchConnection conMain1 = factory.GetConnection(_MemberType, _Class, _ChordSection, _MainBranchSection, _SecondaryBranchSection, F_yc,
                                                                           F_yb, theta_main, theta_sec, AxialForceType.Compression, AxialForceType.Tension, IsTensionChord, P_uChord, M_uChord, O_v);

                IHssTrussBranchConnection conMain2 = factory.GetConnection(_MemberType, _Class, _ChordSection, _MainBranchSection, _SecondaryBranchSection, F_yc,
                                                                           F_yb, theta_main, theta_sec, AxialForceType.Tension, AxialForceType.Compression, IsTensionChord, P_uChord, M_uChord, O_v);

                IHssTrussBranchConnection conSec1 = factory.GetConnection(_MemberType, _Class, _ChordSection, _SecondaryBranchSection, _MainBranchSection, F_yc,
                                                                          F_yb, theta_sec, theta_main, AxialForceType.Compression, AxialForceType.Tension, IsTensionChord, P_uChord, M_uChord, O_v);

                IHssTrussBranchConnection conSec2 = factory.GetConnection(_MemberType, _Class, _ChordSection, _SecondaryBranchSection, _MainBranchSection, F_yc,
                                                                          F_yb, theta_sec, theta_main, AxialForceType.Tension, AxialForceType.Compression, IsTensionChord, P_uChord, M_uChord, O_v);

                SteelLimitStateValue main1 = conMain1.GetChordWallPlastificationStrength(true);
                SteelLimitStateValue main2 = conMain2.GetChordWallPlastificationStrength(true);

                SteelLimitStateValue sec1 = conSec1.GetChordWallPlastificationStrength(true);
                SteelLimitStateValue sec2 = conSec2.GetChordWallPlastificationStrength(true);

                phiP_nMain = Math.Min(main1.Value, main2.Value);
                phiP_nMain = Math.Min(sec1.Value, sec2.Value);

                IsApplicableMain = main1.IsApplicable;
                IsApplicableSecn = sec1.IsApplicable;
            }
            else
            {
                IHssTrussBranchConnection conMain = factory.GetConnection(_MemberType, _Class, _ChordSection, _MainBranchSection, _SecondaryBranchSection, F_yc,
                                                                          F_yb, theta_main, theta_sec, _MainBranchForceType, _SecondaryBranchForceType, IsTensionChord, P_uChord, M_uChord, O_v);

                IHssTrussBranchConnection conSec = factory.GetConnection(_MemberType, _Class, _ChordSection, _SecondaryBranchSection, _MainBranchSection, F_yc,
                                                                         F_yb, theta_sec, theta_main, _SecondaryBranchForceType, _MainBranchForceType, IsTensionChord, P_uChord, M_uChord, O_v);

                SteelLimitStateValue main = conMain.GetChordWallPlastificationStrength(true);
                SteelLimitStateValue sec  = conSec.GetChordWallPlastificationStrength(true);
                phiP_nMain = main.Value;
                phiP_nSec  = sec.Value;

                IsApplicableMain = main.IsApplicable;
                IsApplicableSecn = sec.IsApplicable;
            }



            return(new Dictionary <string, object>
            {
                { "phiP_nMain", phiP_nMain }
                , { "phiP_nSec", phiP_nSec }
                , { "IsApplicableMain", IsApplicableMain }
                , { "IsApplicableSecn", IsApplicableSecn }
            });
        }