%calcuate moment of interia of test masses, torques required to make
%observed motion see Evan's script attached to alog 16344
clear all

rTm=0.345/2; %radius
hTm=0.204; %thickness of test mass

volTm=pi*rTm^2*hTm;
mTm=2.2e3*volTm;
iTm=mTm/12*(3*rTm^2+hTm^2);

kp=(2*pi*0.52).^2*iTm;

%theta=0.1e-6; %radians amplitude of motion durring oscilation
theta_osc=[(24.55-24.25),(35.85-35.45), (23.97-23.75), -1*(19.625-19.725) ].*1e-6;
theta_power=[0.5e-6, 1e-6, 0.4e-6, 0.18e-6]; %change durring power up %ETMX ETMY ITMX ITMY

torque_required_osc=kp*theta_osc
torque_required_power=kp*theta_power

%% find circultaing power
%calibration of TR QPDs (alog 15431 D hoak)
TR_QE=0.8;
TR_cnts_per_W=2*1000*(32768/20)*TR_QE;
analog_gain=10^(18/20);
optical_eff=2.5e-2; %2.5% of the light leaving the ETM reaches each QPD

cnts_sum=65000; %fluctuating part durring oscillation

cnts_power=54000-11000; %change powering up to 10Watts from 2
cnts_osc=65850-64200; %amplitude of oscillation
Watts_leaving_ETM=cnts_sum/(TR_cnts_per_W*optical_eff*analog_gain);
T_ETM=3.6e-6;
circ_pow_up=cnts_power/(TR_cnts_per_W*optical_eff*analog_gain*T_ETM);
circ_osc=cnts_osc/(TR_cnts_per_W*optical_eff*analog_gain*T_ETM);
%% find required miscentering
c_light=3e8;
miscentering_power_up=torque_required_power*c_light/(2*circ_pow_up)
miscentering_osc=torque_required_osc*c_light/(2*circ_osc)

%find circutlaing powers for different values of TRX
TRX_vec=[64304,99070, 44400];
circ_pows_vec=TRX_vec./(TR_cnts_per_W*optical_eff*analog_gain*T_ETM)