Villars Mathematica examples

Fifth International Accelerator School for Linear Colliders, Villars-sur-Ollon, 25.Oct - 6.Nov 2010

Eigensystem:

Eigensystem homogeneous plane wave

lossless={μ>0,ϵ>0};
A={{0,-I ω μ},{-I ω ϵ,0}};A//TraditionalForm

Λ=DiagonalMatrix[Eigensystem[A][[1]]];Simplify[Λ, Assumptions->lossless]//TraditionalForm

V=Eigensystem[A][[2]]\[Transpose];Simplify[V, Assumptions->lossless]//TraditionalForm

Simplify[Inverse[V], Assumptions->lossless]//TraditionalForm

Standing waves on a transmission line:

Forward and backward voltage (wave):

With[{γ=.01+I 1},Manipulate[r=rabs (E^(I φ));Plot[{Abs[(E^(-γ x))],
Abs[r (E^(γ x))],Re[(E^(-γ x+I t))],Re[r (E^(γ x+I t))]},{x,-30,0},PlotRange->{-2.5,2.5}],{t,0,2 π},{rabs,0,1},{φ,-π,π}]]

Total voltage - standing wave pattern:

With[{γ=.01+I 1},Manipulate[r=rabs (E^(I φ));Plot[{Abs[(E^(-γ x))+r (E^(γ x))],Abs[(E^(-γ x))]+Abs[r (E^(γ x))],Abs[(E^(-γ x))]-Abs[r (E^(γ x))],Re[(E^(-γ x+I t))+r (E^(γ x+I t))]},{x,-30,0},PlotRange->{-2.5,2.5}],{t,0,2 π},{rabs,0,1},{φ,-π,π}]]

Smith Chart:

Smith Chart construction:

z=x+I y;map=((z-1)/(z+1));

ZPlane=Show[ParametricPlot[Through[{Re,Im}[x+I y]], {x,0, 1}, {y,-5,-1},PlotStyle->Yellow,  PlotRange->{{0,10},{-5,5}}],ParametricPlot[Through[{Re,Im}[z]], {x,1, 10}, {y,-5,-1},PlotStyle->Blue],ParametricPlot[Through[{Re,Im}[z]], {x,0, 1}, {y,-1,1},PlotStyle->Green],ParametricPlot[Through[{Re,Im}[z]], {x,1, 10}, {y,-1,1},PlotStyle->Red],ParametricPlot[Through[{Re,Im}[z]], {x,0, 1}, {y,1,5},PlotStyle->Pink],ParametricPlot[Through[{Re,Im}[z]], {x,1, 10}, {y,1,5},PlotStyle->None]];
Smithchart=Show[ParametricPlot[Through[{Re,Im}[map]],{x,0, 1}, {y,-5,-1},PlotStyle->Yellow, PlotRange->{{-1,1},{-1,1}}],Graphics[Circle[]],ParametricPlot[Through[{Re,Im}[map]],{x,1, 10}, {y,-5,-1},PlotStyle->Blue],
ParametricPlot[Through[{Re,Im}[map]],{x,0, 1}, {y,-1,1},PlotStyle->Green],ParametricPlot[Through[{Re,Im}[map]],{x,1, 10}, {y,-1,1},PlotStyle->Red],
ParametricPlot[Through[{Re,Im}[map]],{x,0, 1}, {y,1,5},PlotStyle->Pink],ParametricPlot[Through[{Re,Im}[map]],{x,1, 10}, {y,1,5},PlotStyle->None]];
GraphicsRow[{ZPlane, Smithchart}]

Smith Chart application - mismatch towards generator:

Manipulate[Block[{r=-1,z=z0},
GraphicsRow[{Show[Smithchart,Graphics[{PointSize[Large],Point[Through[{Re,Im}[r (E^(-I  2 z))]]]}]],Show[Plot[Im[((1+r (E^(-I  2 zz)))/(1-r (E^(-I  2 zz))))],{zz,0,2 π}],Graphics[{PointSize[Large],Point[{z,Im[((1+r (E^(-I  2 z)))/(1-r (E^(-I  2 z))))]}]}]]},ImageSize->Large]],{z0,0,2π}]

Plane waves to waveguide:

Plane wave:

Manipulate[Plot3D[Sin[t-Cos[φ]z-Sin[φ] x],{z,0,20},{x,-10,10},MeshFunctions->{#3&},Mesh->1,PlotPoints->50,AspectRatio->.6,ViewPoint->{15,-30,50},Axes->False],{t,0,2 π},{{φ,0},((-π)/2),(π/2)}]

Rectangular waveguide:

With[{φ=20°},Animate[Show[Plot3D[Sin[t-Cos[φ]z-Sin[φ] x]+Sin[t-Cos[-φ]z-Sin[-φ] x],{z,0,20},{x,-10,10},MeshFunctions->{#3&},Mesh->1,PlotPoints->40,AspectRatio->.6,ViewPoint->{15,-30,50},Axes->False,PlotStyle->Directive[Orange,Specularity[White,20],Opacity[0.8]]],Graphics3D[{Blue,Polygon[{{0,((-π/2)/(Sin[φ])),-2},{0,((-π/2)/(Sin[φ])),2},{20,((-π/2)/(Sin[φ])),2},{20,((-π/2)/(Sin[φ])),-2}}],Blue,Polygon[{{0,((π/2)/(Sin[φ])),-2},{0,((π/2)/(Sin[φ])),2},{20,((π/2)/(Sin[φ])),2},{20,((π/2)/(Sin[φ])),-2}}]}]],{t,0,2 π}]]

Bessel function:

Manipulate[Plot3D[BesselJ[0,kρ(Sqrt[(x^2)+(y^2)])]Cos[t],{x,-5,5},{y,0,10},MeshFunctions->{#3&},Mesh->{{0.}},ViewPoint->{15,-30,50},Axes->False,PlotPoints->30,PlotStyle->Directive[Orange,Specularity[White,20],Opacity[0.8]],PlotRange->{-1,1}],{t,0,2 π},{kρ,1,3}]

Transit time factor vs. gap length:

Plot[Abs[((Sin[π x])/(π x))],{x,0,3},PlotRange->All,AxesLabel->{"h/λ","TT"}]

Resonance curve:

Off[General::ivar];Manipulate[LogLogPlot[Q=(10^lq);Abs[(Q/(1+I Q(ω-(ω^(-1)))))],{ω,.2,5},PlotPoints->50,PlotRange->{.2,100},ImageSize->Large,GridLines->All,Frame->True,FrameLabel->{"ω/(Subscript[ω, 0])","((Z[ω])/(R/Q))"}],{{lq,0,"Log[Q]"},0,4}]

Simple cavities:

Closed pillbox fundamental mode (tuned to 500 MHz):

c0=299792458.;MHz=1*^6;χ=x/.FindRoot[BesselJ[0,x]==0,{x,2.4}]; geometry={h->0.2633,a->0.2295};ω=((χ c0)/a);
Q=((Sqrt[2 σ a χ c0 μ])/(2  (1+(a/h))));ronq=4 μ c0 (a/h)(((Sin[((χ h)/(2 a))])^2)/( π (χ^3)((BesselJ[1,χ])^2)));{(ω/(2 π MHz)),Q,ronq, ronq Q} /.σ->58*^6

%/.geometry

Spherical cavity:

c0=299792458.;MHz=1*^6;χ=x/.FindRoot[Evaluate[D[(Sqrt[π (x/2)])BesselJ[(3/2),x],x]==0],{x,2.7}];
ω=((χ c0)/a);f=(ω/(2 π));
ψ[ρ_,θ_]:=(Sqrt[π ((k ρ)/2)])BesselJ[(3/2),k ρ]Cos[θ]

Hφ[ρ_,θ_]:=((-1)/ρ)(∂_θ) ψ[ρ,θ];Simplify[Hφ[ρ,θ]];

P=(Sqrt[((ω μ)/(2 σ))])(((((Sin[ka])/ka)-Cos[ka]))^2)/.ka->χ;W=μ (a/ka)(∫_0^ka)(((((Sin[kρ])/(kρ))-Cos[kρ]))^2)\[DifferentialD]kρ/.ka->χ;
Q=((ω W)/P);
{(f/MHz),Q}/.{μ->4*^-7 π,σ->58*^6,a->0.5}

Periodic structure - Brillouin diagram

Equivalent circuit: π-type. Parallel ((Subscript[y, p])/2)both at input and at output, series (Subscript[y, s]) between those. Below, the series (Subscript[y, s]) consists of only an inductivity, whereas (Subscript[y, p]) is a parallel resonance (determining the lower cut-off).

Off[Solve::ifun];eqns={ys==((((ωπ)^2)-((ω0)^2))/(I 4 ω rq0 ω0)),yp==I (1/rq0)((ω/(ω0))-((ω0)/ω)),v1==v+v1 (E^g),(yp/2) v1+ys v==((-yp)/2) v1+ys v (E^(-g))};solution=Solve[eqns,{g,v1,ys,yp}];

Block[{ωπ=1.5,rq0=1,ω0=1.},Plot[Im[g/.solution[[1]]],{ω,0,2},PlotRange->All]]

Simple klystron

Module[{nel=60,ω=2 π,dt},dt=(1/nel);Manipulate[ω0= ω;γ0=1+vDC;
p0=ConstantArray[(Sqrt[((γ0)^2)-1]),nel];t0=Table[(i-1)dt,{i,nel}];p1=p0-((Sqrt[1+(p0^2)])/p0)v0 (Sin[ω t0]);t1=t0+((Sqrt[1+(p1^2)])/p1)l;i1=((Total[(E^(-I ω t1))])/nel);v1=  (rc/(1-I qc(ωc-((ωc)^(-1)))))  i1;p2=p1-((Sqrt[1+(p1^2)])/p1)Re[v1 (E^(I ω t1))];
ListPlot[{Transpose[{t0,p0}],Transpose[{t1,p1}],Transpose[{t1,p2}]},PlotRange->{{0,10},{0.0,3}}],{{vDC,.2,"DC voltage"},0.05,1},{{l,2,"Drift Length"},0.0,4},{{rc,0,"Cavity impedance"},0,2},{{ωc,1,"Cavity resonance f"},.8,1.2},{{qc,20,"Cavity Q"},10,100},{{v0,0.02,"RF drive voltage"},0,.1}]]