A method for controlling vibration of a variable frequency drive controlled electric machine, in which method: - a resonance frequency/frequencies and a stiffness of the electric machine are determined in a ramp up/ ramp down test, which ramp up/ ramp down test is executed with help of said variable frequency drive; - an amount of damping is determined in an impulse test; - a mechanical transfer function is determined in a steady drive test; - a vibration control model is determined utilizing said resonance frequency/frequencies, said stiffness, said amount of damping and said mechanical transfer function; and - vibration of the electric machine is controlled utilizing said vibration control model; - wherein in the step of determining the resonance frequency/frequencies and the stiffness: - a ramp up/ ramp down of the electric machine is executed; - vibration is measured continually during said executed ramp up/ ramp down as measured vibration data; - the resonance frequency/resonance frequencies is/are determined utilizing said measured vibration data; and - the stiffness is calculated utilizing said determined resonance frequency/frequencies; - wherein in the step of determining the amount of damping: - an impulse is produced in an impulse test; - vibration is measured continually during said impulse test as measured vibration data; and - the amount of damping is calculated utilizing said measured vibration data. - a resonance frequency/frequencies and a stiffness of the electric machine are determined in a ramp up/ ramp down test, which ramp up/ ramp down test is executed with help of said variable frequency drive; - an amount of damping is determined in an impulse test; - a mechanical transfer function is determined in a steady drive test; - a vibration control model is determined utilizing said resonance frequency/frequencies, said stiffness, said amount of damping and said mechanical transfer function; and - vibration of the electric machine is controlled utilizing said vibration control model; - wherein in the step of determining the resonance frequency/frequencies and the stiffness: - a ramp up/ ramp down of the electric machine is executed; - vibration is measured continually during said executed ramp up/ ramp down as measured vibration data; - the resonance frequency/resonance frequencies is/are determined utilizing said measured vibration data; and - the stiffness is calculated utilizing said determined resonance frequency/frequencies; - wherein in the step of determining the amount of damping: - an impulse is produced in an impulse test; - vibration is measured continually during said impulse test as measured vibration data; and - the amount of damping is calculated utilizing said measured vibration data. - a ramp up/ ramp down of the electric machine is executed; - vibration is measured continually during said executed ramp up/ ramp down as measured vibration data; - the resonance frequency/resonance frequencies is/are determined utilizing said measured vibration data; and - the stiffness is calculated utilizing said determined resonance frequency/frequencies; - wherein in the step of determining the amount of damping: - an impulse is produced in an impulse test; - vibration is measured continually during said impulse test as measured vibration data; and - the amount of damping is calculated utilizing said measured vibration data. - an impulse is produced in an impulse test; - vibration is measured continually during said impulse test as measured vibration data; and - the amount of damping is calculated utilizing said measured vibration data.