System Controlling: September 2012

Saturday, September 22, 2012

ACIM model in rotor fixed reference frame

In case of a direct torque control we can use the rotor fixed frame, which means that the $\omega_\gamma=0$. In this case we can describe the motor with the following equations(you can find the deduction under the following link)
$$
\begin{bmatrix} u_{sd} \\ u_{sq} \end{bmatrix}=R_r \begin{bmatrix} i_{sd} \\ i_{sq} \end{bmatrix} +\frac{d}{dt}\begin{bmatrix} \psi_{sd} \\ \psi_{sq} \end{bmatrix}\tag{1}
$$
$$\begin{bmatrix} u_{rd} \\ u_{rq} \end{bmatrix}=R_r \begin{bmatrix} i_{rd} \\ i_{rq} \end{bmatrix} +\frac{d}{dt}\begin{bmatrix} \psi_{rd} \\ \psi_{rq} \end{bmatrix}+\omega_r\begin{bmatrix} \psi_{rd} \\ -\psi_{rq} \end{bmatrix}\tag{2}$$
The motor torque can be expressed the rotor flux magnitude $\psi_r$ and stator current component $i_s$
$$
T_e =  \frac{3p L_m}{2 L_r}\left(\psi_{rd}i_{sq}-\psi_{rq}i_{sd}\right)\tag{3}
$$
and the flux equations are the following
$$\begin{bmatrix}\psi_{sd} \\ \psi_{sq}\end{bmatrix}=L_s\begin{bmatrix}i_{sd} \\ i_{sq} \end{bmatrix}+L_m\begin{bmatrix}i_{rd} \\ i_{rq} \end{bmatrix}\tag{4}$$
$$\begin{bmatrix}\psi_{rd} \\ \psi_{rq}\end{bmatrix}=L_m\begin{bmatrix}i_{sd} \\ i_{sq} \end{bmatrix}+L_r\begin{bmatrix}i_{rd} \\ i_{rq} \end{bmatrix}\tag{5}$$
I would like to estimate the rotor fluxes and the electrical motor speed $\omega_r$. In this case there are five state variables $\begin{bmatrix}i_{sd} & i_{sq} & \psi_{rd} & \psi_{rq} & \omega_r \end{bmatrix}$, to get the state variables we have to make a few arithmetic operations.
We would like to get the flux equations, after sorting the $2^{nd}$ equation we will end up with the following
$$\frac{d}{dt}\begin{bmatrix} \psi_{rd} \\ \psi_{rq} \end{bmatrix} = - R_r \begin{bmatrix} i_{rd} \\ i_{rq} \end{bmatrix} - \omega_r\begin{bmatrix} \psi_{rd} \\ -\psi_{rq} \end{bmatrix}+\begin{bmatrix} u_{rd} \\ u_{rq} \end{bmatrix}\tag{6}$$
We can't measure the rotor currents, but we can express the rotor currents using the $5^{th}$ equations.
$$\begin{bmatrix}i_{rd} \\ i_{rq} \end{bmatrix}=\frac{1}{L_r}\begin{bmatrix}\psi_{rd} \\ \psi_{rq}\end{bmatrix}-\frac{L_m}{L_r}\begin{bmatrix}i_{sd} \\ i_{sq} \end{bmatrix}\tag{7}$$
Replacing the rotor currents in the $6^{th}$ expression we will get the rotor flux equations
$$\frac{d}{dt} \begin{bmatrix} \psi_{rd} \\ \psi_{rq} \end{bmatrix} = -R_r \left(\frac{1}{L_r} \begin{bmatrix}\psi_{rd} \\ \psi_{rq} \end{bmatrix}-\frac{L_m}{L_r} \begin{bmatrix}i_{sd} \\ i_{sq} \end{bmatrix}\right) - \omega_r \begin{bmatrix} \psi_{rd} \\ -\psi_{rq} \end{bmatrix} $$ $$ \frac{d}{dt} \begin{bmatrix} \psi_{rd} \\ \psi_{rq} \end{bmatrix} = \frac{L_m}{\tau_r} \begin{bmatrix}i_{sd} \\ i_{sq} \end{bmatrix} + \begin{bmatrix} -\frac{1}{\tau_r} & -\omega_r \\ \omega_r & -\frac{1}{\tau_r} \end{bmatrix} \begin{bmatrix} \psi_{rd} \\ -\psi_{rq} \end{bmatrix}\tag{8} $$
After those arithmetic operation we got the rotor's flux equations, to get the stator's current equations we replace the $1^{st}$ equation's stator fluxes using the $4^{th}$ expressions, also we have to replace in the $4^{th}$ expression the rotor currents, by using the $7^{th}$ equations.
After some arithmetical operation we will get the stator currents
$$ \frac{d}{dt} \begin{bmatrix} i_{sd} \\ i_{sq} \end{bmatrix} = \begin{bmatrix} -\frac{R_s+\frac{L_m^2R_r}{L_r^2}}{L_s\sigma}& 0 \\ 0 & -\frac{R_s+\frac{L_m^2R_r}{L_r^2}}{L_s\sigma}  \end{bmatrix}\begin{bmatrix}i_{sd} \\ i_{sq} \end{bmatrix}\\+\begin{bmatrix} \frac{L_m}{L_s\sigma L_r\tau_r} & \frac{\omega_rL_m}{L_s\sigma L_r} \\ -\frac{\omega_rL_m}{L_s\sigma L_r} & \frac{L_m}{L_s\sigma L_r\tau_r}  \end{bmatrix}\begin{bmatrix}\psi_{rd} \\ \psi_{rq} \end{bmatrix}+\begin{bmatrix} \frac{1}{L_s\sigma} & 0 \\ 0 & \frac{1}{L_s\sigma} \end{bmatrix}\begin{bmatrix} u_{sd} \\ u_{sq} \end{bmatrix}\tag{9} $$
Where
$$
\tau_r=\frac{L_r}{R_r}
$$
and
$$
\sigma=1-\frac{L_m^2}{L_sL_r}
$$
The equations above combined with the Extended Kalman filte can be used to estimate the fluxes and rotor speed. The dynamic model for an induction motor by choosing the stator currents $i_sd$, $i_sq$ and rotor fluxes $\psi_rd$, $\psi_rq$ as state variables, is as follows
$$
\frac{dx}{dt}=Ax(t)+Bu(t)\tag{10}
$$
$$
y(t)=Cx(t)+Du(t)\tag{11}
$$
where
$$
A= \begin{bmatrix} -\frac{R_s+\frac{L_m^2R_r}{L_r^2}}{L_s\sigma} & 0 &  \frac{L_m}{L_s\sigma L_r\tau_r} & \frac{\omega_rL_m}{L_s\sigma L_r} \\ 0 & -\frac{R_s+\frac{L_m^2R_r}{L_r^2}}{L_s\sigma}  & -\frac{\omega_rL_m}{L_s\sigma L_r} & \frac{L_m}{L_s\sigma L_r\tau_r} \\ \frac{L_m}{\tau_r} & 0 & -\frac{1}{\tau_r} & -\omega_r \\ 0 & \frac{L_m}{\tau_r} &   \omega_r & -\frac{1}{\tau_r}  \end{bmatrix}\tag{12}
$$
$$B=\begin{bmatrix} \frac{1}{L_s\sigma} & 0 \\ 0 & \frac{1}{L_s\sigma} \\ 0 & 0 \\ 0 & 0\end{bmatrix}\tag{13}$$
$$C=\begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \end{bmatrix}\tag{14}$$
$$D=\begin{bmatrix} 0 \end{bmatrix} \tag{15}$$

Wednesday, September 19, 2012

Three-phase induction motor in different reference frames

In order to understand, analyze and control the ac induction motor, a dynamic model is necessary. The significant step forward in the analysis of the three-phase induction motor was the reference frame theory. Using this theory, it is possible to transform the machine dynamic model to a different reference frame.
Figure 1.
The equations of the ACIM's (alternate current induction motor) is easy to deduce from the machine structure and circuits.
The stator equations are the following
$$ u_{sa}=R_si_{sa}+\frac{d\psi_{sa}}{dt}\\
u_{sb}=R_si_{sb}+\frac{d\psi_{sb}}{dt}\\
u_{sc}=R_si_{sc}+\frac{d\psi_{sc}}{dt}\tag{1}
$$
and the rotor equations are the following
$$ u_{ra}=R_ri_{ra}+\frac{d\psi_{ra}}{dt}\\
u_{rb}=R_ri_{rb}+\frac{d\psi_{rb}}{dt}\\
u_{rc}=R_ri_{rc}+\frac{d\psi_{rc}}{dt}\tag{2}
$$
Both the current and the voltage are time dependent. In the three-phase reference frame the motor windings are located at 120 degree. Applying the Clarke transformation on the three phase motor, more info in the previous blog, we can write the three-phase machine equations in two phase
$$ u_{s\alpha}=R_si_{s\alpha}+\frac{d\psi_{s\alpha}}{dt}\\
u_{s\beta}=R_si_{s\beta}+\frac{d\psi_{s\beta}}{dt}\tag{3}
$$
$$ u_{r\alpha}=R_ri_{r\alpha}+\frac{d\psi_{r\alpha}}{dt}\\
u_{r\beta}=R_ri_{r\beta}+\frac{d\psi_{r\beta}}{dt}\tag{4}
$$
The $3^{rd}$ and $4^{th}$ equations are based on two different reference frames, one is the stationary, fixed to the stator, the other is rotating with the rotor at electrical motor speed $\omega_r$. With respect of the $\alpha/\beta$ system, the ACIM can be equally describe by two other perpendicular windings. This transformation is applied to transfer the stator and rotor equation's to a common reference frame named $d/q$ (rotating reference frame). In the common reference frame it is easier to describe the dynamic model and behaviour of the ACIM.There are four reference frames widely used in ACIM analysis, namely he stationary, rotor, synchronous and arbitrary reference frame.

Stationary or stator fixed reference frame


In this case the reference frame speed is 0 and all the variables are referred to the stator fixed reference frame. With the following equation we can describe the current in the d/q reference frame.
$$
i_{rd} = i_{r\alpha}cos\theta-i_{r\beta}sin\theta\\
i_{rq} = i_{r\alpha}sin\theta+i_{r\beta}cos\theta\tag{5}
$$
The matrices of the transformation $T_{-\theta}$ and inverse transformation $T^{-1}_{-\theta}$ are the following
$$
T_{-\theta}=\begin{bmatrix}  cos\theta & -sin\theta \\ sin\theta & cos\theta \end{bmatrix}\tag{6}
$$
$$
T^{-1}_{-\theta}=\begin{bmatrix}  cos\theta & sin\theta \\ -sin\theta & cos\theta \end{bmatrix}\tag{7}
$$
The $6^{th}$ and $7^{th}$ equations also can apply on the voltage and flux, because of this we can transform the $3^{rd}$ and $4^{th}$ equations 
$$ T_{-\theta} \begin{bmatrix} u_{r\alpha} \\ u_{r\beta} \end{bmatrix}=T_{-\theta} R_r \begin{bmatrix} i_{r\alpha} \\ i_{r\beta} \end{bmatrix} +T_{-\theta} \frac{d}{dt} \begin{bmatrix} \psi_{r\alpha} \\ \psi_{r\beta} \end{bmatrix}\tag{9} $$
Because $$T^{-1}_{-\theta}T_{-\theta}=1\tag{10}$$we can multiplying the rotor flux vector, it remain unchanged.
$$\begin{bmatrix} u_{rd} \\ u_{rq} \end{bmatrix}=R_r \begin{bmatrix} i_{rd} \\ i_{rq} \end{bmatrix} +T_{-\theta} \frac{d}{dt}\left(T_{-\theta}^{-1}T_{-\theta} \begin{bmatrix} \psi_{r\alpha} \\ \psi_{r\beta} \end{bmatrix}\right)\\ \begin{bmatrix} u_{rd} \\ u_{rq} \end{bmatrix}=R_r \begin{bmatrix} i_{rd} \\ i_{rq} \end{bmatrix} +T_{-\theta} \frac{d}{dt}\left(T_{-\theta}^{-1} \begin{bmatrix} \psi_{rd} \\ \psi_{rq} \end{bmatrix}\right)\\ \begin{bmatrix} u_{rd} \\ u_{rq} \end{bmatrix}=R_r \begin{bmatrix} i_{rd} \\ i_{rq} \end{bmatrix} +T_{-\theta}T_{-\theta}^{-1} \frac{d}{dt} \begin{bmatrix} \psi_{rd} \\ \psi_{rq} \end{bmatrix}+T_{-\theta} \frac{d}{dt}\left(T_{-\theta}^{-1}\right)\begin{bmatrix} \psi_{rd} \\ \psi_{rq} \end{bmatrix}\tag{11}$$
Where
$$T_{-\theta} \frac{d}{dt}\left(T_{-\theta}^{-1}\right)=T_{-\theta} \left(\frac{d}{d\theta}T_{-\theta}^{-1}\right)\frac{d\theta}{dt}\\=\begin{bmatrix}  0 & cos\theta^2+sin\theta^2 \\ -cos\theta^2-sin\theta^2 & 0 \end{bmatrix}\frac{d\theta}{dt}=\begin{bmatrix}  0 & 1 \\ -1 & 0 \end{bmatrix}\omega_r\tag{12}$$
If we insert the $12^{th}$ equation into the $11^{th}$ equation finally we get the stator and rotor equations in the same, stator fixed reference frame.
$$
\begin{bmatrix} u_{sd} \\ u_{sq} \end{bmatrix}=R_r \begin{bmatrix} i_{sd} \\ i_{sq} \end{bmatrix} +\frac{d}{dt}\begin{bmatrix} \psi_{sd} \\ \psi_{sq} \end{bmatrix}\tag{13}
$$
$$\begin{bmatrix} u_{rd} \\ u_{rq} \end{bmatrix}=R_r \begin{bmatrix} i_{rd} \\ i_{rq} \end{bmatrix} +\frac{d}{dt}\begin{bmatrix} \psi_{rd} \\ \psi_{rq} \end{bmatrix}+\omega_r\begin{bmatrix} \psi_{rd} \\ -\psi_{rq} \end{bmatrix}\tag{14}$$

Rotor fixed reference frame


In this case the common reference is attached to the rotor and it is rotating with the electrical speed $\omega_r$. In this case the transformation matrices are the following,
$$
T_{-\gamma}=\begin{bmatrix}  cos\gamma & sin\gamma \\ -sin\gamma & cos\gamma \end{bmatrix}\tag{15}
$$
$$
T^{-1}_{-\gamma}=\begin{bmatrix}  cos\gamma & -sin\gamma \\ sin\gamma & cos\gamma \end{bmatrix}\tag{16}
$$
Applying the same calculation as in the stator fixed reference frame we will get the following equation,
$$
\begin{bmatrix} u_{sd} \\ u_{sq} \end{bmatrix}=R_r \begin{bmatrix} i_{sd} \\ i_{sq} \end{bmatrix} +\frac{d}{dt}\begin{bmatrix} \psi_{sd} \\ \psi_{sq} \end{bmatrix}+\omega_r\begin{bmatrix} -\psi_{sd} \\ \psi_{sq} \end{bmatrix}\tag{17}
$$
$$\begin{bmatrix} u_{rd} \\ u_{rq} \end{bmatrix}=R_r \begin{bmatrix} i_{rd} \\ i_{rq} \end{bmatrix} +\frac{d}{dt}\begin{bmatrix} \psi_{rd} \\ \psi_{rq} \end{bmatrix}\tag{18}$$

Arbitrary rotating reference frame


By replacing the $-\theta$ with $\gamma-\theta$ we can obtain the rotor variables and rotor equation in arbitrary reference frame. In this case the transformation matrices are the following
$$T_{\gamma-\theta}=\begin{bmatrix} cos\left(\gamma-\theta\right) & sin\left(\gamma-\theta\right) \\ -sin\left(\gamma-\theta\right) & cos\left(\gamma-\theta\right) \end{bmatrix}\tag{19} $$
$$ T^{-1}_{\gamma-\theta}=\begin{bmatrix} cos\left(\gamma-\theta\right) & -sin\left(\gamma-\theta\right) \\ sin\left(\gamma-\theta\right) & cos\left(\gamma-\theta\right) \end{bmatrix}\tag{20}$$
Applying the transformation matrices on the $3^{rd}$ and $4^{th}$ equations we will end up with the following equation in the arbitrary reference frame
$$
\begin{bmatrix} u_{sd} \\ u_{sq} \end{bmatrix}=R_r \begin{bmatrix} i_{sd} \\ i_{sq} \end{bmatrix} +\frac{d}{dt}\begin{bmatrix} \psi_{sd} \\ \psi_{sq} \end{bmatrix}+\omega_\gamma\begin{bmatrix} -\psi_{sd} \\ \psi_{sq} \end{bmatrix}\tag{21}
$$
$$\begin{bmatrix} u_{rd} \\ u_{rq} \end{bmatrix}=R_r \begin{bmatrix} i_{rd} \\ i_{rq} \end{bmatrix} +\frac{d}{dt}\begin{bmatrix} \psi_{rd} \\ \psi_{rq} \end{bmatrix}+\left(\omega_\gamma-\omega_r\right)\begin{bmatrix} -\psi_{rd} \\ \psi_{rq} \end{bmatrix}\tag{22}$$
The stator and rotor fixed reference frame is just a particular case of the arbitrary rotating reference frame.  In the stator fixed reference frame the $\omega_\gamma$ is set to zero yield. If the reference frame is rotating with $\omega_r$ the equations of the rotor reference frame are obtained.

Sunday, September 9, 2012

Clarke coordinate transformation

The Clarke transformation does a magnitude invariant translation from a three-phase system to a two orthogonal system.
In order to understand the Clarke transformation I will introduce the 3-phase induction motor.
Figure 1. 3 phase induction motor windings

Three windings are organized with 120° angle difference in the physical space between each other. On the right side of the figure they are illustrated in a simplified way, where a winding is represented with an inductor.
At a certain time point, for e.g. the currents in the three windings have the directions and values as shown in Figure 2, they could be summarized by using the vector addition. The result is as shown in the figure.
Figure 2.






Referring to Figure 2 we can calculate the sum of the current vectors as:
$$i_s = i_u+i_ve^{{2\pi\over3}j}+i_we^{{4\pi\over3}j}\tag{1}$$
Using the Euler formula:
$$e^{j\omega} = \cos(\omega)+j \sin(\omega)\tag{2}$$
We will get the following equation:
$$i_s = \left(i_ucos(0)+i_vcos\left({2\pi\over3}\right)+i_wcos\left({4\pi\over3}\right)\right)\\+j\left(i_usin(0)+i_vsin\left({2\pi\over3}\right)+i_wsin\left({4\pi\over3}\right) \right)\tag{3}$$
$$i_s = \left(i_u-{1\over2}i_v-{1\over2}i_w\right)+j\left(0+{\sqrt3\over2}i_v-{\sqrt3\over2}i_w\right)\tag{4}$$
 In order to keep constant magnitude of the vectors during the transformation we put a $k_1$ coefficient.
$$i_s={k_1}i_s\tag{5}$$
The real and imaginary parts can be separated and rewritten as:
$$i_\alpha =Re\left(i_s\right)=k_1\left(i_u-{1\over2}i_v-{1\over2}i_w\right)\\
i_\beta =Im\left(i_s\right)=k_1\left(0+{\sqrt3\over2}i_v-{\sqrt3\over2}i_w\right)\tag{6}$$
Adding a zero-axis value
$$i_0={k_1}{k_2}(i_u+i_v+i_w)\tag{7}$$
Using the $6$ and $7$ equation we can write the following transformation:
$$ \left[ \begin{array}{c} i_\alpha \\ i_\beta \\ i_0 \end{array} \right] =k_1 \begin{bmatrix}  1 & -{1\over2} & -{1\over2} \\ 0 & {\sqrt3\over2} & -{\sqrt3\over2} \\ {k_2} & {k_2} & {k_2} \end{bmatrix}\left[ \begin{array}{c} i_u \\ i_v \\ i_w \end{array} \right]\tag{8}$$
Where the $T$ transformation matrix is as follows
$$T=k_1 \begin{bmatrix}  1 & -{1\over2} & -{1\over2} \\ 0 & {\sqrt3\over2} & -{\sqrt3\over2} \\ {k_2} & {k_2} & {k_2} \end{bmatrix}\tag{9}$$
and the inverse $T^{-1}$ transformation matrix is
$$T^{-1}=k_1 \begin{bmatrix}  1 & 0 & {k_2} \\ -{1\over2} & {\sqrt3\over2} & {k_2} \\ -{1\over2}  & -{\sqrt3\over2} & {k_2}  \end{bmatrix}\tag{10}$$
To determine the $k_1$ and $k_2$ we have to solve the following equation
$$
 T^{-1}T=\begin{bmatrix}  1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}\tag{11}
$$
Using the $11^th$ equation we can write the following
$$
k_1^2 \begin{bmatrix}  1 & 0 & {k_2} \\ -{1\over2} & {\sqrt3\over2} & {k_2} \\ -{1\over2}  & -{\sqrt3\over2} & {k_2}  \end{bmatrix}\begin{bmatrix}  1 & -{1\over2} & -{1\over2} \\ 0 & {\sqrt3\over2} & -{\sqrt3\over2} \\ {k_2} & {k_2} & {k_2} \end{bmatrix}=\begin{bmatrix}  1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}\tag{12}
$$
Solving the $12^th$ equation the $k_1$ and $k_2$ value will be:
$$k_1=\sqrt{2\over3}\tag{13}$$

$$k_2={1\over{\sqrt2}}\tag{14}$$
Replacing $k_1$ and $k_2$ in the $T$ matrix, finally we will get the following transformation matrix
$$T=\sqrt{2\over3} \begin{bmatrix}  1 & -{1\over2} & -{1\over2} \\ 0 & {\sqrt3\over2} & -{\sqrt3\over2} \\ {1\over{\sqrt2}} & {1\over{\sqrt2}} & {1\over{\sqrt2}} \end{bmatrix}\tag{15}$$
No we can test the above transformation matrices, for this purpose I implemented the transformation matrices in python using numpy
def clarke_p_i_i0(self,a,b,c):
        T = sqrt(2./3.)* array([
                              [1., -1./2., -1./2.],
                              [0., sqrt(3.)/2., -sqrt(3.)/2.],
                              [1./sqrt(2.), 1./sqrt(2.), 1./sqrt(2.)]
                              ])
        return  dot(T, array([[a],[b],[c]]));
        
    
def inv_clarke_p_i_i0(self,alpha, beta, Io=0):
        T = sqrt(2./3.)* array([
                              [1., 0., 1/sqrt(2.)], 
                              [-1./2.,  sqrt(3.)/2., 1./sqrt(2.)], 
                              [-1./2.,  -sqrt(3.)/2., 1./sqrt(2.)]
                              ])
        
        return  dot(T, array([[alpha],[beta],[Io]])); 

The output of the transformation and inverse transformation is the following
Figure 3.

Using the following relation
$$
i_u+i_v+i_w=0\tag{16}
$$
so
$$
 i_w = -i_u-i_v\tag{17}
$$
Applying the $17^th$ relation on the $6^th$ equation the value of the $i_\alpha$ will be the following
$$
i_\alpha = i_u-{1\over2}i_v- {1\over2}\left(-i_u-i_v\right)\\
i_\alpha = {3\over2}i_u\tag{18}
$$
applying this to the $i_\beta$ we get the following equation
$$
i_\beta =  {{\sqrt3}\over2}i_u+{\sqrt{3}}i_v\tag{19}
$$
The $18^th$ and $19^th$, applied on voltage and current, is not power invariant, because of this we have to solve the following equation
$$
u_ui_u+u_vi_v+u_wi_w=u_\alpha i_\alpha+u_\beta i_\beta\tag{20}
$$
$$
u_\alpha i_\alpha+u_\beta i_\beta =  {3\over2}u_u {3\over2}i_u+
\left(\sqrt{3\over2}u_u+\sqrt{3}u_b\right) \left(\sqrt{3\over2}i_u+\sqrt{3}i_b\right) \\
={3\over2}\left(u_ui_u+u_vi_v+u_wi_w\right)\tag{21}
$$
So the $2\over3$ scaling factor guarantee the power invariance. Because of the symmetrical distribution of the scaling factor $2\over3$, following equations are used to transform the three-phase reference frame to two-phase reference frame.
$$
i _\alpha={\sqrt{2\over3}}{3\over2}i_v={\sqrt{3\over2}}i_v\tag{22}
$$
and
$$
i_\beta =  {\sqrt{2\over3}}\left({{\sqrt3}\over2}i_u+{\sqrt{3}}i_v\right)\\
={1\over\sqrt2}i_u+{\sqrt2}i_v\tag{23}
$$
Writing the matrix form the equation above
$$
T= \begin{bmatrix} \sqrt{3\over2} & 0 \\ {1\over\sqrt2} &  {\sqrt2} \end{bmatrix}\tag{24}
$$
and the inverse transformation
$$
T^{-1}= \begin{bmatrix} \sqrt{2\over3} & 0 \\ -{1\over\sqrt6} & {1\over\sqrt2} \\
-{1\over\sqrt6} & -{1\over\sqrt2}  \end{bmatrix}\tag{25}
$$
The equation above can apply also for voltage transformation.
Python implementation:
def clarke_p_i(self,a,b):

        """"""

        T = array([
                    [sqrt(3./2.), 0],
                    [1./sqrt(2.), sqrt(2.)]
                ])

        return  dot(T, array([[a],[b]]));

        

def inv_clarke_p_i(self,alpha, beta):

        T = array([
                    [sqrt(2./3.), 0],
                    [-1./sqrt(6.), 1./sqrt(2.)],
                    [-1./sqrt(6.), -1./sqrt(2.)],
                 ])
        
        return dot(T, array([[alpha],[beta]]))
Figure 4.
The transformation matrices mentioned above are power invariant, but also it's possible to write the magnitude invariant transformation. If we replace the $k_1$ and $k_2$ in the $9^{th}$ equation with ${2\over3}$ and ${1\over3}$, the transformation and inverse transformation matrices are the following

$$T={2\over3} \begin{bmatrix}  1 & -{1\over2} & -{1\over2} \\ 0 & {\sqrt3\over2} & -{\sqrt3\over2} \\ 1\over2 & 1\over2 & 1\over2 \end{bmatrix}\tag{26}$$
$$T^{-1}={3\over2} \begin{bmatrix}  {2\over3} & 0 & {1\over2} \\ -{1\over3} & {1\over\sqrt3} & {1\over2} \\ -{1\over3}  & -{1\over\sqrt3} & {1\over2}  \end{bmatrix}\tag{27}
$$
Python implementation: 
def clarke_m_i(self,a,b,c): 
        T = 2./3.* array([
                              [1., -1./2., -1./2.],
                              [0., sqrt(3.)/2., -sqrt(3.)/2.],
                              [1./2., 1./2., 1./2.]
                              ])
        return  dot(T, array([[a],[b],[c]]));
        
 def inv_clarke_m_i(self,alpha, beta, Io):
        T = 3./2.* array([
                              [2./3., 0., 1./2.], 
                              [-1./3.,  1/sqrt(3.), 1./2.], 
                              [-1./3.,  -1/sqrt(3.), 1./2.]
                              ])        
        return  dot(T, array([[alpha],[beta],[Io]]));

Figure 5.

As you see on the $Figure 3.$, $Figure 4.$ the amplitude of the transformation is not invariant, comparing with the $Figure 5.$ where the amplitude is invariant.

You can find an example in the github under the T_CoorTrans.py
Sources:
[1] Fujitsu Coordinate transform
[2] BME - Villamos Hajtások, Villamos Energetika Tanszék
[3] Mircea Popescu - Induction motor modelling for vector control purpose
[4] Prof. Dr.-Ing. Ralph Kennel - Master course Power Electronics