This paper introduces a new Modelica package called RailwaySystem Library that provides the capabilities of simulating the energy flow in electrical railway networks on which a fleet of railway vehicles is running.The focus of the library is set upon the interaction of the vehicle and its energy infrastructure, so that energy management aspects may be investigated from a holistic point of view taking the vehicle and the energy supply by the electric power grid into account. However this intention substantially relies on the provision of reliable data of the infrastructure, on the railway network and its power grid. To this purpose the library refers to an open XML-based data format dedicated to railway IT applications. Furthermore, the library is supposed to be used together with arbitrary component libraries to model the energy subsystems such as the vehicle or the power station.