Generate tabulated flux linkage data for ideal PMSM

```
[F,T,dFdA,dFdB,dFdC,dFdX]
= elec_generateIdealPMSMfluxData(PM,Ld,Lq,L0,A,B,C,X)
```

```
[F]
= elec_generateIdealPMSMfluxData(PM,Ld,Lq,L0,A,B,C,X)
```

```
[F,T,dFdA,dFdB,dFdC,dFdX]
= elec_generateIdealPMSMfluxData(PM,Ld,Lq,L0,D,Q,X)
```

```
[F]
= elec_generateIdealPMSMfluxData(PM,Ld,Lq,L0,D,Q,X)
```

`[`

generates 4-D flux linkage data, including the torque and the
partial derivatives, for an ideal permanent magnet synchronous motor
(PMSM).`F`

,`T`

,`dFdA`

,`dFdB`

,`dFdC`

,`dFdX`

]
= elec_generateIdealPMSMfluxData(`PM`

,`Ld`

,`Lq`

,`L0`

,`A`

,`B`

,`C`

,`X`

)

Use this function to create test data for the FEM-Parameterized PMSM block, either for validation purposes or to set up a model before the actual flux linkage data is available.

The flux linking each winding has contributions from the permanent magnet plus the three windings. Therefore, the total flux is given by [1]:

$$\left[\begin{array}{c}{\psi}_{a}\\ \begin{array}{l}{\psi}_{b}\\ {\psi}_{c}\end{array}\end{array}\right]=\left[\begin{array}{ccc}{L}_{aa}& {L}_{ab}& {L}_{ac}\\ {L}_{ba}& {L}_{bb}& {L}_{bc}\\ {L}_{ca}& {L}_{cb}& {L}_{cc}\end{array}\right]\left[\begin{array}{c}{i}_{a}\\ \begin{array}{l}{i}_{b}\\ {i}_{c}\end{array}\end{array}\right]+\left[\begin{array}{c}{\psi}_{am}\\ \begin{array}{l}{\psi}_{bm}\\ {\psi}_{cm}\end{array}\end{array}\right]$$

$$\begin{array}{l}{L}_{aa}={L}_{s}+{L}_{m}\mathrm{cos}\left(2{\theta}_{r}\right)\\ {L}_{bb}={L}_{s}+{L}_{m}\mathrm{cos}\left(2\left({\theta}_{r}-2\pi /3\right)\right)\\ {L}_{cc}={L}_{s}+{L}_{m}\mathrm{cos}\left(2\left({\theta}_{r}+2\pi /3\right)\right)\\ {L}_{ab}={L}_{ba}=-{M}_{s}-{L}_{m}\mathrm{cos}\left({\theta}_{r}+\pi /6\right)\\ {L}_{bc}={L}_{cb}=-{M}_{s}-{L}_{m}\mathrm{cos}\left({\theta}_{r}+\pi /6-2\pi /3\right)\\ {L}_{ca}={L}_{ac}=-{M}_{s}-{L}_{m}\mathrm{cos}\left({\theta}_{r}+\pi /6+2\pi /3\right)\\ {\psi}_{am}={\psi}_{m}\mathrm{cos}{\theta}_{e}\\ {\psi}_{bm}={\psi}_{m}\mathrm{cos}\left({\theta}_{e}-2\pi /3\right)\\ {\psi}_{bm}={\psi}_{m}\mathrm{cos}\left({\theta}_{e}+2\pi /3\right)\end{array}$$

Here, *Θ*_{e} is the electrical angle,
which is related to rotor angle *Θ*_{r}
by *Θ*_{e} =
*N**·Θ*_{r}. The function assumes that the permanent magnet flux
linking the A-phase winding is at the maximum for *Θ*_{e} =
0.

The function output `F`

corresponds to
*ψ*_{a} tabulated as a function
of A-phase current, B-phase current, C-phase current, and rotor
angle.

*Ls*, *Lm*, and *Ms* are
related to input arguments `Ld`

, `Lq`

, and
`L0`

by:

$$\begin{array}{l}{L}_{s}=\frac{{L}_{0}}{3}+\frac{{L}_{d}}{3}+\frac{{L}_{q}}{3}\\ {M}_{s}=\frac{{L}_{d}}{6}-\frac{{L}_{0}}{3}+\frac{{L}_{q}}{6}\\ {L}_{m}=\frac{{L}_{d}}{3}-\frac{{L}_{q}}{3}\end{array}$$

[1] Anderson, P.M. *Analysis of Faulted Power
Systems*. 1st Edition. Wiley-IEEE Press, July 1995,
p.187.