% mm, mgon
delta_TM = 4;
n = 2;
up1 = 2;
up2 = 2.5;
l = (2+33e-6)*(1-2.5e-6*(20.1-5)) * 1000;
d = 31.954e3;
ro = 200000/pi;
sigma_delta0 = 0.4;
sigma_omega0 = 1;

%% kruznice
sigma_T0 = delta_TM *sqrt(n) /up2
sigma_Tdelta = l*ro/d^2 *sqrt(sigma_T0^2 - 1)
sigma_Tomega = ro/d *sqrt(sigma_T0^2 - 1)
n_delta = ceil( sigma_delta0^2 / sigma_Tdelta^2 )
n_omega = ceil( sigma_omega0^2 / sigma_Tomega^2 )
sigma_delta = sigma_delta0 / sqrt(n_delta)
sigma_omega = sigma_omega0 / sqrt(n_omega)
sigma_dm = d^2/l/ro *sigma_delta
sigma_qm = d/ro *sigma_omega
test = sigma_dm / sigma_qm

%% usecka
sigma_Td0 = delta_TM *sqrt(n) /up1
sigma_Tdelta = l*ro/d^2 *sqrt(sigma_Td0^2 - 1)
sigma_delta0^2 / sigma_Tdelta^2
n_delta = ceil( sigma_delta0^2 / sigma_Tdelta^2 )
sigma_delta = sigma_delta0 / sqrt(n_delta)
sigma_dm = d^2/l/ro *sigma_delta
sigma_d0 = sqrt(sigma_dm^2 + 1)
delta_Md = up1*sqrt(n)*sigma_dm

sigma_q0 = sqrt(sigma_qm^2 + 1)
delta_Mq = up1*sqrt(n)*sigma_qm

delta_Zd = 2* ( delta_TM - up1*sigma_d0/sqrt(2) )
delta_Zq = 2* ( delta_TM - up1*sigma_q0/sqrt(2) )
