A method of controlling a power converter, connected to an electrical grid, to mimic a synchronous generator, wherein the method comprises: determining a frequency control error with respect to a setpoint frequency (f set) and an actual frequency (f act) of the power converter, determining an input power to an inertial model block including an inertia model which is a mathematical model of the inertia of a synchronous generator and mimics the inertia of a synchronous generator, wherein the inertia model has an inertia constant H that indicates the amount of the spinning mass that it is representing and has unit of seconds, the input power being determined by means of a speed governor block based on the frequency control error which is input to the speed governor block, the speed governor block being a closed-loop controller comprising a PI-regulator, regulating by means of the input power a rotational frequency (f) of the inertia model, determining a voltage control error with respect to a setpoint voltage (U set) and an actual voltage (U act) output by the power converter, determining an exciter parameter of a synchronous generator model based on the voltage control error, regulating by means of the exciter parameter an output voltage of the synchronous generator model, adjusting the rotational frequency (f) or a phase angle (θ) obtained from the rotational frequency (f), and the output voltage based on a virtual impedance of a stator of the synchronous generator model, and controlling the power converter based on the adjusted rotational frequency (f) or the adjusted phase angle (θ') and on the adjusted output voltage (U'), characterized in that the characteristics of the inertia model block and the speed governor block are changed adaptively in real time by adjusting parameters including the inertia constant H, gains K p and K i of the speed governor block and maximum and minimum limits of the speed governor block, to make the power converter mimic the characteristics of the conventional generators to enhance the ability to maintain synchronism during line faults. determining a frequency control error with respect to a setpoint frequency (f set) and an actual frequency (f act) of the power converter, determining an input power to an inertial model block including an inertia model which is a mathematical model of the inertia of a synchronous generator and mimics the inertia of a synchronous generator, wherein the inertia model has an inertia constant H that indicates the amount of the spinning mass that it is representing and has unit of seconds, the input power being determined by means of a speed governor block based on the frequency control error which is input to the speed governor block, the speed governor block being a closed-loop controller comprising a PI-regulator, regulating by means of the input power a rotational frequency (f) of the inertia model, determining a voltage control error with respect to a setpoint voltage (U set) and an actual voltage (U act) output by the power converter, determining an exciter parameter of a synchronous generator model based on the voltage control error, regulating by means of the exciter parameter an output voltage of the synchronous generator model, adjusting the rotational frequency (f) or a phase angle (θ) obtained from the rotational frequency (f), and the output voltage based on a virtual impedance of a stator of the synchronous generator model, and controlling the power converter based on the adjusted rotational frequency (f) or the adjusted phase angle (θ') and on the adjusted output voltage (U'), characterized in that the characteristics of the inertia model block and the speed governor block are changed adaptively in real time by adjusting parameters including the inertia constant H, gains K p and K i of the speed governor block and maximum and minimum limits of the speed governor block, to make the power converter mimic the characteristics of the conventional generators to enhance the ability to maintain synchronism during line faults.