+ _dc VPM generatorBack-to-backconverterfigure 1 – System overview5where Me is the electromechanical torque developed by the electrical machine (when theelectrical machine is operated as a generator Me will be negative) and Jtotal isthe moment ofinertia of the entire mechanical system. In p.u. values equation (2.2) becomes:1( ) e tmdnm mdt T= + (2.3)For more accurate results, the mechanical dynamics could be modelled as a two-mass-systemwith a spring and damper between them, but this was not done due to constraintsin time andin available information.1.2 Permanent magnet generatorThe generator model is implemented entirely in dq-coordinates. That is to say, there are noAC-states in the model. The generator is modelled with dc voltages and currentsin a rotorfixedrotating coordinate system with the d-axis being in the direction of the flux from thepermanent magnets. This model is a scaled per-unit model, and essentially the same as thatshown in [Nilsen, 2005].The equations for the d- and q-axis voltages are as follows:1 s s dd sd qndu ri ndtyyw= × + × - × (2.4)s s 1 qq sq dndu ri ndtyyw= × + × + × (2.5)Here, id, iq, vd and vq are the p.u. d- and q-axis currents and voltages respectively, rs is the p.u.stator resistance. ? n is the basic electrical frequency of the generator, n isthe p.u. frequencyog the generator and ? d and ? q are the d- and q-axis fluxes respectively.