In this paper, a dual-stage modeling and optimization framework has been developed to obtain an optimal combination and size of wayside energy storage systems (WESSs) for application in DC rail transportation. Energy storage technologies may consist of a standalone battery, a standalone supercapacitor, a standalone flywheel, or a combination of these. Results from the dual-stage modeling and optimization process have been utilized for deducing an application-specific composition of type and size of the WESSs. These applications consist of different percentages of energy saving due to regenerative braking, voltage regulation, peak demand reduction, estimated payback period, and system resiliency. In the first stage, sizes of the ESSs have been estimated using developed detailed mathematical models, and optimized using the Genetic Algorithm (GA). In the second stage, the respective sizes of ESSs are simulated by developing an all-inclusive model of the transit system, ESS and ESS management system (EMS) in MATLAB/Simulink. The mathematical modeling provides initial recommendations for the sizes from a large search space. However, the dynamic simulation contributes to the optimization by highlighting the transit system constraints and practical limitations of ESSs, which impose bounds on the maximum energy that can be captured from decelerating trains.