Ukrainians can travel free of charge by long-distance trains in Poland.

From February 27, Ukrainian citizens forced to flee as a result of the Russian military invasion will be able to travel free of charge on long-distance trains in Poland.
They can go in transit to the border with Germany. Currently, there are 6 such Intercity high-speed trains in Poland. In Frankfurt-on-Oder, people can cross the border and thus seek refuge in Germany.
Warning! To move on to Germany, you need to give up shelter in Poland. If the controllers ask for a ticket on the trains, it will be enough to show a Ukrainian passport, and a domestic passport is enough.

Source in German: https://www.rnd.de/reise/kostenlose-bahnfahrten-fuer-ukrainer-in-deutschland-2N6RL2YOJ5ACTGUTFGERBFPBT4.html?outputType=amp