If you choose to take the train, it takes about 40 minutes to take the train from Yan 'an Railway Station to Zichang County, then get off at Zichang County Railway Station, and then take a local bus or taxi to Zhongshan Grottoes.
If you choose to take the bus, start from Yan 'an Bus Station and take the shuttle bus to Zichang County. After arriving in Zichang County, take the shuttle bus to Anding Town and get off at Zhongshan Grottoes, which takes about 2 hours.
Generally speaking, taking a train is faster and more convenient than taking a car, but the cost may be higher. If you are interested in grotto art, I suggest you go by train to better appreciate the beauty of Zhongshan Grottoes.