The ionic compressor has a prospective application potential for the conversion of mechanical energy into internal energy in high-pressure hydrogen as the ionic liquid can separate the metal piston and the hydrogen gas. The sloshing of the liquid inside is inevitable in such a liquid piston compressor, which has an impact on the specific energy consumption of the hydrogen compression. The thermofluid behaviour of this liquid sloshing can be effectively influenced by the baffle structure and piston trajectory. A novel concentric two-piston compressor is proposed in this paper, which has a unique structure that can act as a baffle inside and actively influences the fluid flow by adjusting the piston trajectory. The quantitative influence of key structural design factors on the compressor performance is investigated by mathematical modelling, based on which the optimal structural design was obtained by Taguchi and analysis of variance methods. Results indicate that the diameter ratio of Piston A to Piston B is the dominating factor for both the mass delivered and the specific energy consumption. With the optimal design in the structure, the specific energy consumption is found as 2328.49 kJ/kg, where the mass delivered and power consumption are observed as 21.42 kg/h and 13.86 kW, respectively.