So far I have a basic motor model running in a Qt program that graphs the results. The model just uses the Park/Clarke transforms to go from the inverter PWM voltages to Vq and Vd, uses these along with a calculated BEMF and Ld and Lq to calculate motor currents, uses the currents to calculate torque, the torque to calculate acceleration, the acceleration to calculate the change in rotor position and then the inverse Park/Clarke to get back to 3phase motor currents. No idea whether this is a valid model (and anything more sophisticated involving magnetic field modelling is well beyond me) but so far it seems to generate vaguely sensible results.
The next step is to add the OpenInverter FOC software and see if the model continues to give sensible results and whether the field weakening issues can be reproduced.
So the question - what's the bare minimum subset of the OpenInverter FOC software that I need to integrate into the simulation? It needs to be enough to be realistic but not so much that I spend forever writing test stubs for code I don't really understand.
EDIT (Jan 23)
This thread has become quite a lengthy tome. If you are interested in reading through the full process of my getting to grips with how motors work and lots of plots please feel free to read on. However if you are more interested in a high level understanding and using the simulator without having to read through the whole thread here are links to the posts that are hopefully of the most interest

Wiki link - https://openinverter.org/wiki/IPM_Motor_Simulator
IPM Equations - viewtopic.php?p=44359#p44359
How OpenInverter does Space Vector Modulation - viewtopic.php?p=44564#p44564
MTPA curves - viewtopic.php?p=45061#p45061
Explanation of SyncAdv change - viewtopic.php?p=45088#p45088
Explanation of PM Motors - viewtopic.php?p=45449#p45449
Explanation of control loops/tuning - viewtopic.php?p=45510#p45510
Start of discussion about motor inductance - viewtopic.php?p=46915#p46915
Motor equations voltage terms - https://openinverter.org/forum/vie ... 2#p47212
Start of results using FULL motor model - viewtopic.php?p=47226#p47226 (results prior to this point can be misleading!)
Current circles and voltage ellipses - viewtopic.php?p=47287#p47287
First coasting test for critical current - viewtopic.php?p=47564#p47564
Power/Torque plots - viewtopic.php?p=47770#p47770
Comparison of simulator vs real world - viewtopic.php?p=48144#p48144
Johannes says 'topic solved'

Calculating flux linkage from plots - viewtopic.php?p=48609#p48609
Over modulation - viewtopic.php?p=48638#p48638
Thoughts for future development - viewtopic.php?p=48756#p48756
Johannes video on how to use simulator - viewtopic.php?p=48960#p48960
Vq limiting (not resolved) - viewtopic.php?p=49172#p49172
How to install - viewtopic.php?p=49176#p49176 viewtopic.php?p=50233#p50233 viewtopic.php?p=50232#p50232
Full install guide - viewtopic.php?p=50884#p50884
Operating Instructions - viewtopic.php?p=50885#p50885