public static Dictionary <string, object> MaximumCompressiveStrength(ConcreteFlexureAndAxiaSection ConcreteSection,
                                                                             string ConfinementReinforcementType = "Ties",
                                                                             bool IsPrestressed = false, string Code = "ACI318-14")
        {
            //Default values
            double phiP_o = 0;


            //Calculation logic:

            ConfinementReinforcementType ConfinementReinforcement;
            bool IsValidConfinementReinforcementType = Enum.TryParse(ConfinementReinforcementType, true, out ConfinementReinforcement);

            if (IsValidConfinementReinforcementType == false)
            {
                throw new Exception("Failed to convert string. ConfinementReinforcementType. Please check input");
            }
            double  P_o = 0.0;
            CalcLog log = new CalcLog();
            IConcreteSectionWithLongitudinalRebar Section = (IConcreteSectionWithLongitudinalRebar)ConcreteSection.FlexuralSection;
            ConcreteSectionCompression            column  = new ConcreteSectionCompression(Section, ConfinementReinforcement, log);

            P_o = column.GetMaximumForce() / 1000.0;     // convert to kip inch units;
            double phi = 0.65;

            phiP_o = phi * P_o;

            return(new Dictionary <string, object>
            {
                { "phiP_o", phiP_o }
            });
        }
        public void ShearWallCalculatesPMMDiagram()
        {
            double f_c_prime                         = 6;
            double f_c_prime_psi                     = f_c_prime * 1000;
            RebarMaterialFactory factory             = new RebarMaterialFactory();
            string         RebarSpecificationId      = "A615Grade60";
            IRebarMaterial LongitudinalRebarMaterial = factory.GetMaterial(RebarSpecificationId);
            double         h_total                   = 20 * 12;
            double         t_w                       = 12;
            double         N_curtains                = 2;
            double         s                         = 12;
            double         c_edge                    = 0;

            BoundaryZone BoundaryZoneTop    = new BoundaryZone(3, 3, "No8", 6, 3, 3);
            BoundaryZone BoundaryZoneBottom = new BoundaryZone(3, 3, "No8", 6, 3, 3);
            string       WallRebarSizeId    = "No4";


            FlexuralCompressionFiberPosition p    = FlexuralCompressionFiberPosition.Top;
            ConcreteMaterial             Concrete = new ConcreteMaterial(f_c_prime_psi, ConcreteTypeByWeight.Normalweight, null);
            ConfinementReinforcementType ConfinementReinforcementType = KodestructAci.ConfinementReinforcementType.Ties;

            CrossSectionRectangularShape shape = new CrossSectionRectangularShape(Concrete, null, t_w, h_total);

            List <KodestructAci.RebarPoint> LongitudinalBars = GetLongitudinalBars(shape.SliceableShape as ISectionRectangular, h_total, t_w, WallRebarSizeId, N_curtains, s, c_edge,
                                                                                   BoundaryZoneTop, BoundaryZoneBottom, LongitudinalRebarMaterial);

            KodestructAci.IConcreteFlexuralMember fs = new KodestructAci14.ConcreteSectionFlexure(shape, LongitudinalBars, null, ConfinementReinforcementType);

            IConcreteSectionWithLongitudinalRebar Section = fs as IConcreteSectionWithLongitudinalRebar;
            ConcreteSectionCompression            column  = new ConcreteSectionCompression(Section, ConfinementReinforcementType, null);
            //Convert axial force to pounds
            List <PMPair> Pairs         = column.GetPMPairs(p);
            var           PairsAdjusted = Pairs.Select(pair => new PMPair(pair.P / 1000.0, pair.M / 1000.0 / 12.0));

            string Filename = Path.Combine(Path.GetTempPath(), "PMInteractionShearWall.csv");

            using (CsvFileWriter writer = new CsvFileWriter(Filename))
            {
                foreach (var pair in PairsAdjusted)
                {
                    CsvRow row = new CsvRow();
                    row.Add(pair.M.ToString());
                    row.Add(pair.P.ToString());
                    writer.WriteRow(row);
                }
            }
        }
        /// <summary>
        ///     Moment strength with axial force (kip - in unit system for all inputs and outputs)
        /// </summary>
        /// <param name="P_u">   Factored axial force; to be taken as positive for  compression and negative for tension  </param>
        /// <param name="ConcreteSection">  Reinforced concrete section </param>
        /// <param name="ConfinementReinforcementType">  Type of compression member confinement reinforcement (tied, spiral etc) </param>
        /// <param name="FlexuralCompressionFiberLocation">Specifies if top or bottom fiber is in compression from the effects of bending moment</param>
        /// <param name="IsPrestressed">Indicates if member is prestressed</param>
        /// <param name="Code">Applicable version of code/standard</param>
        /// <returns name="phiM_n">  Design flexural strength at section   </returns>


        public static double MaximumMomentFromAxialForce(double P_u, ConcreteFlexureAndAxiaSection ConcreteSection,
                                                         string ConfinementReinforcementType = "Ties", string FlexuralCompressionFiberLocation = "Top",
                                                         bool IsPrestressed = false, string Code = "ACI318-14")
        {
            //Default values

            double phiM_n = 0.0;

            //Calculation logic:


            ConfinementReinforcementType ConfinementReinforcement;
            bool IsValidConfinementReinforcementType = Enum.TryParse(ConfinementReinforcementType, true, out ConfinementReinforcement);

            if (IsValidConfinementReinforcementType == false)
            {
                throw new Exception("Failed to convert string. ConfinementReinforcementType. Please check input");
            }

            FlexuralCompressionFiberPosition p;
            bool IsValidStringFiber = Enum.TryParse(FlexuralCompressionFiberLocation, true, out p);

            if (IsValidStringFiber == false)
            {
                throw new Exception("Flexural compression fiber location is not recognized. Check input.");
            }


            CalcLog log = new CalcLog();

            if (ConcreteSection.FlexuralSection is IConcreteSectionWithLongitudinalRebar)
            {
                IConcreteSectionWithLongitudinalRebar Section = (IConcreteSectionWithLongitudinalRebar)ConcreteSection.FlexuralSection;
                ConcreteSectionCompression            column  = new ConcreteSectionCompression(Section, ConfinementReinforcement, log);
                //Convert axial force to pounds
                double P_u_pounds = P_u * 1000.0;
                phiM_n = column.GetDesignMomentWithCompressionStrength(P_u_pounds, p).phiM_n / 1000.0; // convert to kip inch units
            }
            else
            {
                throw new Exception("Section of wrong type. Create a section type that has longitudinal bars as part of definition.");
            }

            return(phiM_n);
        }
        public void ShearWallCalculatesPMMDiagramMaxIteration()
        {
            double         f_c_prime                 = 6;
            double         f_c_prime_psi             = f_c_prime * 1000;
            IRebarMaterial LongitudinalRebarMaterial = new RebarMaterialGeneral(60000);
            double         l_w = 20 * 12;
            double         h   = 12;


            FlexuralCompressionFiberPosition p    = FlexuralCompressionFiberPosition.Top;
            ConcreteMaterial             Concrete = new ConcreteMaterial(f_c_prime_psi, ConcreteTypeByWeight.Normalweight, null);
            ConfinementReinforcementType ConfinementReinforcementType = KodestructAci.ConfinementReinforcementType.Ties;

            CrossSectionRectangularShape shape = new CrossSectionRectangularShape(Concrete, null, h, l_w);

            List <RebarPoint> LongitudinalBars = GetLongitudinalBarsFromCoordinates(LongitudinalRebarMaterial);

            KodestructAci.IConcreteFlexuralMember fs = new KodestructAci14.ConcreteSectionFlexure(shape, LongitudinalBars, null, ConfinementReinforcementType);

            IConcreteSectionWithLongitudinalRebar Section = fs as IConcreteSectionWithLongitudinalRebar;
            ConcreteSectionCompression            column  = new ConcreteSectionCompression(Section, ConfinementReinforcementType, null);
            //Convert axial force to pounds
            List <PMPair> Pairs         = column.GetPMPairs(p, 50, true);
            var           PairsAdjusted = Pairs.Select(pair => new PMPair(pair.P / 1000.0, pair.M / 1000.0 / 12.0));

            string Filename = Path.Combine(Path.GetTempPath(), "PMInteractionShearWallMaxIteration.csv");

            using (CsvFileWriter writer = new CsvFileWriter(Filename))
            {
                foreach (var pair in PairsAdjusted)
                {
                    CsvRow row = new CsvRow();
                    row.Add(pair.M.ToString());
                    row.Add(pair.P.ToString());
                    writer.WriteRow(row);
                }
            }
        }
        public ConcreteSectionCompression(IConcreteSectionWithLongitudinalRebar Section,
                                          ConfinementReinforcementType ConfinementReinforcementType,
                                          ICalcLog log, bool IsPrestressed = false)
            : base(Section.Section, Section.LongitudinalBars, log)
        {
            this.ConfinementReinforcementType = ConfinementReinforcementType;
            switch (ConfinementReinforcementType)
            {
            case ConfinementReinforcementType.Spiral:
                this.CompressionMemberType = IsPrestressed == false ? CompressionMemberType.NonPrestressedWithSpirals : CompressionMemberType.PrestressedWithSpirals;

                break;

            case ConfinementReinforcementType.Ties:
                this.CompressionMemberType = IsPrestressed == false ? CompressionMemberType.NonPrestressedWithTies : CompressionMemberType.PrestressedWithTies;
                break;

            case ConfinementReinforcementType.NoReinforcement:
                throw new Exception("Invalid type of ConfinementReinforcementType variable. Specify either ties or spirals. Alternatively use nodes for plain concrete design");
                break;
                this.CompressionMemberType = IsPrestressed == false ? CompressionMemberType.NonPrestressedWithTies : CompressionMemberType.PrestressedWithTies;
                break;
            }
        }