Phil Lucht Math & Physics Archive
Home / Math and Physics Files / Physics / E&M / Electrostatics / bowl / bowl in toroidals

maple text

DOCX · 17.6 KB
Open DOCX file

Maple code, apparently Phil's, for the electrostatic potential of a charged bowl (a spherical cap) in toroidal coordinates (xi, u). It defines the potential V from arccot terms with floor-based branch selection, plus helper routines arctan2Pi and getu that convert (rho,z) to the bowl-label angle u. It then makes 3D plots of V and u over an azimuthal slice, with u0 set to 2Pi/8.

AI-written summary; may contain errors.

Extracted text (machine-read; may contain errors)
> restart; Construct the charged bowl potential in toroidal coordinates A := sqrt(cosh(xi)-cos(u)): B := sqrt(1 + cos(u)): C := sqrt(cosh(xi)-cos(2*u0-u)): E := sqrt(1+cos(2*u0-u)): eta1 := floor((3*Pi-u)/(2*Pi)): eta2 := floor((2*u0-u+Pi)/(2*Pi)): T1 := (1/A)*arccot(((-1)^eta1)*(B/A)): T2 := (1/C)*arccot(((-1)^eta2)*(E/C)): V := (V0/Pi)*A*(T1+T2); V0 := 1: a := 1: u0 := evalf(2*Pi/8); Routine arctan2Pi Given (x,y) somewhere on a circle, return the angle in (0,2Pi) measured CCW from the xxis. Warning: returned result may include unevaluated mulitples of Pi > arctan2Pi := proc(x,y) local q; if type(x,numeric) and type(y,numeric) then if x = 0 and y = 0 then print("arctan2Pi(0,0) error." ); RETURN(0) fi; if x = 0 and y > 0 then RETURN(Pi/2) fi; if x = 0 and y < 0 then RETURN(3*Pi/2) fi; if x > 0 and y = 0 then RETURN(0) fi; if x < 0 and y = 0 then RETURN(Pi) fi; if x > 0 and y > 0 then q := 0 fi; if x < 0 and y > 0 then q := Pi fi; if x < 0 and y < 0 then q := Pi fi; if x > 0 and y < 0 then q := 2*Pi fi; RETURN(arctan(y/x)+q); else 'arctan2Pi(x,y)'; fi; end: Routine getu Given a,u0, rho,z, compute toroidal bowl-label parameter u in range (u0,u0+2Pi) > getu := proc(rho,z) global a,u0; local xi,cosu,sinu,t1; if type(rho,numeric) and type(z,numeric) then xi := arctanh(2*a*rho/(a^2+rho^2+z^2)); if rho = 0 then cosu := (z^2- a^2)/ (z^2+a^2); sinu := 2*a*z/(z^2+a^2); else cosu := cosh(xi)-(a/rho)*sinh(xi); sinu := (z/rho)*sinh(xi); fi; t1 := evalf(arctan2Pi(cosu,sinu)); if t1 < u0 then t1 := t1 + evalf(2*Pi) fi; # get into proper range RETURN(t1); else 'getu(rho,z)'; fi; end: Plot the potential of the charged bowl (an azimuthal slice) > xi := arctanh(2*a*abs(rho)/(a^2+rho^2+z^2)): > u := getu(rho,z): > plot3d(V, rho = -2..2, z = -2..3,numpoints=2000,axes=BOXED, view=0..1); > u := getu(rho,z): > plot3d(u, rho = -3..3, z = -4..4,axes=BOXED,numpoints=2000);