Energy consumption on resistance in AC circuit?

The electrical part of a PM machine is described as a symmetric three-phase Y-connected circuit with floating neutral point, $e=Ldi/dt+Ri+v$, where $e$, $i$ and $v$ are vectors of emf, current and terminal voltage of three phases, and $L$ is inductor and $R$ is resistor. The mechanical part is described as $J\dot{\omega}=T_m-T_e$, where $J$ is inertia, $\omega$ is the speed, $T_m$ is mechanical torque and $T_e$ is electromagnetic torque. Two parts are coupled by $T_e=<e,i>/\omega$ and $e$ having magnitude $\sqrt{2}k_e\omega$ and frequency $p\omega$ where $k_e$ is emf constant (rms value) and $p$ is machine's pole-pair number.

Now I've been doing a simulation of the machine, where the terminal voltage was set to $v=0$, and a constant mechanical torque $T_m$ was applied for a short period of time $t_1$. The speed $\omega$ will first go up and then go down, and after a long time $t_2$ become 0. The same does the current. From energy's point of view, the energy into the machine is $E_{in}=\int_0^{t_{1}}T_m\omega(t)dt$; after $t_2$, because $\omega=0$ and $i=0$, there is no energy stored in $J$ and $L$, and thus the energy consumed by $R$ should be equal to $E_{in}$. I calculate the energy on $R$ using $E_{out}=3\int_0^{t_{2}}i^2(t)Rdt$, but I found $E_{in}\neq E_{out}$. I'm wondering whether I was using correct formula to calculate $E_{out}$. Thanks for any help.

Ps. The above integrations were calculated numerically.

• If you put up a circuit diagram I can probably answer this. – DanielSank Mar 18 '15 at 23:49
• Problem solved. It's an issue of the numeric integration. – user3703018 Mar 19 '15 at 11:09