## 4 Implementation
### Testing Description  
To compare performance and accuracy, the different algorithms described above are implemented in the Simulink environment. The comparison is between the different types of integration models that, starting from the voltage and rotation applied to the machine, outputs the fluxes. For this reason, the input side of the model compared is the same, with the generation of an identical voltage source and speed reference.  
All of the models have the same parameters, both for the machine simulated and for the solver and inputs. To highlight the possible final application, the machine chosen is an high performance induction machine for electric vehicles, up to 250 kW of power and 15,000 rpm maximum nominal speed, with its main data summarized in Table 1. An IM has been chosen, mainly, because the formulation implies the use of the full 4 \(\times\) 4 matrix implementation, without simplifications that could be used in SM to improve calculation performances, making it a more complex and severe test-bench.  
To assess how good the discrete approximations presented are to produce the correct machine fluxes, the first comparison is done feeding the model with a symmetric three-phase nominal voltage of 360 V, constant frequency of 6 \(\frac{\text{rad}}{\text{s}}\) and the rotor rotating at the same constant speed. The relative low speed and equal value between stator and rotor frequency was chosen to immediately qualitatively give a sense of how good is the implementation since, in a IM, if the speeds are equal, the rotor fluxes are constant. The other testing condition is carried out at an electric speed of 600\(\frac{\text{rad}}{\text{s}}\) to prove both the improvements using increasing sub-intervals integration steps and the algorithm capabilities at high frequency.  
Given that the machine equations are known and the continuous implementation is the best approximation possible for a model, its output is chosen as the true one against which the other method are compared. As a remainder, this method cannot be practically implemented in real time DSP, because of the DSP architecture and asynchronous calculation requirements of the method. Moreover, Simulink is optimized to run this type of models, thus producing better performance than any possible discrete-time implementation.  
The machine parameters and all the constants needed are calculated by a separate subsystem that takes the user inputs (resistance, inductance, number of iterations, pole pairs and magnet flux) and constructs the required matrices. In particular, it calculates matrix \([M]\) using (19). This division of operation wants to simulate the fact that in the real program some constants can be calculated in different parts of the algorithm to be used by more that one subsystem and that can also run much slower that the main control functions.  
Table 1 summarises both the simulation parameters and the machine ones. The entire model is run with a variable-step solver and the discrete algorithms are inserted into a triggered subsystem that produces the requested discrete sample timing.  
Figure 8: Discrete time model with fast rotation implementation: FAST-DSCR.  
All the tests are performed by supplying the motor with a standard sinusoidal three-phase voltage with known (variable) frequency. Clarke transformation is operated and the rotor speed is set as a constant.