I just got the field oriented control "interior permanent magnet" correction working with the leaf motor. Basically, with a high "saliency" motor, you use Id = 0, Iq = current magnitude. But for buried magnets, , there's also some of the torque from reluctance torque. I guess that's the stator pulling toward the steel laminations between the magnets (I think that's how it works). At any rate, to get the best torque per amp, you start with a current magnitude, and break it up into Id and Iq, where Id is negative. The formula, found here
at around the 22 minute mark:
https://www.youtube.com/watch?v=bZwLFpXhFbI
But instead of all that crap I think you can just run through all Id from 0 down to -sqrt(currentMagnitude). The goal was to find the best torque for the fixed magnitude. To quantify best torque (because who the heck has a torque measuring thing), I started the motor at 0 rpm, and checked what caused the motor to accelerate until the motor ran out of voltage in the shortest time (so, during that whole time, currentMagnitude was constant).
Then, I tried again with a fixed magnitude of 23amp, and found that the ideal Id was about half of the ideal Id for 12amp. Here's a video:
https://www.youtube.com/watch?v=VTn4fKNVbGc