There were two primary railway lines running through the Afan Valley.
The Swansea Bay line, operated by the Great Western Railway (GWR), transported coal from the Rhondda Valley and upper Afan Valley. It also carried passenger trains. The Gelli tunnel carried the Swansea Bay line from the Rhondda Valley, to the Afan Valley, and on to Swansea via Aberafan.
Engines were originally coal-powered steam engines. Diesel electric eventually replaced steam for passenger trains.
I took the train, both steam and diesel electric, from Cwmafan to Aberafan daily while attending grammar school. We walked from home to the railway station, and also walked to school at the other end.
The “PT line”, operated by the Port Talbot Railway and Docks Company (PTRD) primarily transported minerals. The line ran on the side of Mynydd Dinas in the lower Afan Valley, and crossed the valley on the big bridge (y bont fawr/y bont goch) near Pontrhydyfen. The line connected with other lines, including the GWR line.