(* This notebook calculates the Conductance of the Strontium oven Nozzle, formulae taken from Chapter 2 "Flow of Gases Through Tubes and Orifices", Livesey *)

(* Definitions *)
Clear[T,P,cm,L,um,pm]
um = 10^-6 m;
m = 10^2 cm;
cm = .1 L^(1/3);
in = 2.54 cm;
g = .001 kg;
J = kg m^2/s^2;
GasConstant = 8.3144621 J/(mol Kelvin);
torr = 101300/760 kg /(m s^2);
k = 1.381 10^-23 J/Kelvin;

(* Relevant variables *)
T = (620+273) Kelvin;
P = .1 torr;
capillaryID = 200um;
capillaryOD = 414 um;
Ntubes = 198;
Lcapillary = 1 cm;
MolarMass = 87.62g/mol; (* Strontium *)
Ntriangle = 2 Ntubes;
Leg = .2679492 capillaryOD; (* Equilateral triangle leg length *)

(* Calculate! *)

(* Capillary Tube Conductance *)
Ccapillary = Simplify[ID^3(Pi GasConstant T/(2 MolarMass))^(1/2)/(3 Lcapillary),{L>0,s>0}];

(* Equilateral Triangle Conductance *)
Ctriangle = Simplify[3 Log[3] Leg^3/(8 Lcaplillary)(GasConstant T/(2 Pi Mm))^(1/2),{L>0,s>0}];

(* Total Conductance of the capillary array *)
Cnozzle = Ntubes Ccapillary+Ntriangle Ctriangle

(* Total Particle Rate *)
dNdt = P Cnozzle/(k T);

(* Particle Rate within a 2 degree beam *)
Rate = dNdt Integrate[Cos[x],{x,-Pi/180,Pi/180}]/2

(* Now find if losses due to an imperfect nozzle are significant. Possible issues are the annulus between the OD of the nozzle and the ID of the containing pipe section, and the small rectangular slit between the clamp plate and the nozzle body *)

pipeID = .625 in;
nozzleOD = .623 in; (* should be w/in a few 0.001in *)
Lannulus = 2 in;  (* modifiy this parameter to achieve desired C *)
e = nozzleOD/pipeID;
X = 1/(1-e^2)(4/3-e+e^3-2/3(1+e^2)EllipticE[e^2] +2/3(1-e^2)EllipticK[e^2]);
Aannulus = Pi/4 pipeID^2(1-e^2);
αannulus = pipeID X/Lannulus;

Cannulus = Simplify[Aannulus(GasConstant T/(2 Pi Mm))^(1/2)αannulus,{L>0,s>0}]
Cnozzle/Cannulus

(* The slit in the capillary clamp interface can be approximated by formula 2.29 since L>>a, b>>a, b>>L *)

a = 0.001 in;  (* tolerance of gap *)
b = 0.25 in;   (* diameter of inner bore *)
Lslit = 0.185 in;  (* thickness of clamp plate *)

Aslit =a b;
αslit = a/Lslit(Log[2Lslit/a]-.5);
Cslit = Simplify[Aslit (GasConstant T/(2 Pi Mm))^(1/2)αslit,{L>0,s>0}]

(* Want Cnozzle to be much greater than Closs *)
Closs = Cannulus+Cslit;

Cnozzle/Cannulus
Cnozzle/Cslit
Cnozzle/Closs