orthovec.tex 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. \chapter[ORTHOVEC: scalars and vectors]%
  2. {ORTHOVEC: Three-dimensional vector analysis}
  3. \label{ORTHOVEC}
  4. \typeout{{ORTHOVEC: Three-dimensional vector analysis}}
  5. {\footnotesize
  6. \begin{center}
  7. James W.~Eastwood \\
  8. AEA Technology, Culham Laboratory \\
  9. Abingdon \\
  10. Oxon OX14 3DB, England \\[0.05in]
  11. e--mail: jim\_eastwood@aeat.co.uk
  12. \end{center}
  13. }
  14. \ttindex{ORTHOVEC}
  15. The ORTHOVEC package is a collection of \REDUCE\ procedures and
  16. operations which provide a simple to use environment for the
  17. manipulation of scalars and vectors. Operations include addition,
  18. subtraction, dot and cross products, division, modulus, div, grad,
  19. curl, laplacian, differentiation, integration, ${\bf a \cdot \nabla}$
  20. and Taylor expansion.
  21. \section{Initialisation}\label{vstart}
  22. \ttindex{VSTART}
  23. The procedure \f{START} initialises ORTHOVEC. VSTART provides a
  24. menu of standard coordinate systems:-
  25. \begin{enumerate}
  26. \index{cartesian coordinates}
  27. \item cartesian $(x, y, z) = $ {\tt (x, y, z)}
  28. \index{cylindrical coordinates}
  29. \item cylindrical $(r, \theta, z) = $ {\tt (r, th, z)}
  30. \index{spherical coordinates}
  31. \item spherical $(r, \theta, \phi) = $ {\tt (r, th, ph) }
  32. \item general $( u_1, u_2, u_3 ) = $ {\tt (u1, u2, u3) }
  33. \item others
  34. \end{enumerate}
  35. which the user selects by number. Selecting options (1)-(4)
  36. automatically sets up the coordinates and scale factors. Selection
  37. option (5) shows the user how to select another coordinate system. If
  38. VSTART is not called, then the default cartesian coordinates are used.
  39. ORTHOVEC may be re-initialised to a new coordinate system at any time
  40. during a given \REDUCE\ session by typing
  41. \begin{verbatim}
  42. VSTART $.
  43. \end{verbatim}
  44. \section{Input-Output}
  45. ORTHOVEC assumes all quantities are either scalars or 3 component
  46. vectors. To define a vector $a$ with components $(c_1, c_2, c_3)$ use
  47. the procedure SVEC:\ttindex{SVEC}
  48. \begin{verbatim}
  49. a := svec(c1, c2, c3);
  50. \end{verbatim}
  51. The procedure\ttindex{VOUT} \f{VOUT} (which returns the value of its
  52. argument) can be used to give labelled output of components
  53. in algebraic form:
  54. \begin{verbatim}
  55. b := svec (sin(x)**2, y**2, z)$
  56. vout(b)$
  57. \end{verbatim}
  58. The operator {\tt \_} can be used to select a particular
  59. component (1, 2 or 3) for output {\em e.g.}
  60. \begin{verbatim}
  61. b_1 ;
  62. \end{verbatim}
  63. \section{Algebraic Operations}
  64. Six infix operators, sum, difference, quotient, times, exponentiation
  65. and cross product, and four prefix
  66. operators, plus, minus, reciprocal
  67. and modulus are defined in ORTHOVEC. These operators can take suitable
  68. combinations of scalar and vector arguments,
  69. and in the case of scalar arguments reduce to the usual definitions of
  70. $ +, -, *, /, $ etc.
  71. The operators are represented by symbols
  72. \index{+ ! 3-D vector}\index{- ! 3-D vector}\index{/ ! 3-D vector}
  73. \index{* ! 3-D vector}\index{* ! 3-D vector}\index{"\^{} ! 3-D vector}
  74. \index{$><$ ! 3-D vector}
  75. \begin{verbatim}
  76. +, -, /, *, ^, ><
  77. \end{verbatim}
  78. \index{$><$ ! diphthong} The composite {\tt ><} is an
  79. attempt to represent the cross product symbol
  80. $\times$ in ASCII characters.
  81. If we let ${\bf v}$ be a vector and $s$ be a scalar, then
  82. valid combinations of arguments of the
  83. procedures and operators and the type of the result
  84. are as summarised below. The notation used is\\
  85. {\em result :=procedure(left argument, right argument) } or\\
  86. {\em result :=(left operand) operator (right operand) } . \\
  87. \underline{Vector Addition} \\
  88. \ttindex{VECTORPLUS}\ttindex{VECTORADD}\index{vector ! addition}
  89. \begin{tabular}{rclcrcl}
  90. {\bf v} &:=& VECTORPLUS({\bf v}) &{\rm or}& {\bf v} &:=& + {\bf v} \\
  91. s &:=& VECTORPLUS(s) &{\rm or} & s &:=& + s \\
  92. {\bf v} &:=& VECTORADD({\bf v},{\bf v}) &{\rm or }& {\bf v} &:=&
  93. {\bf v} + {\bf v} \\
  94. s &:=& VECTORADD(s,s) &{\rm or }& s &:=& s + s \\
  95. \end{tabular} \\
  96. \underline{Vector Subtraction} \\
  97. \ttindex{VECTORMINUS}\ttindex{VECTORDIFFERENCE}\index{vector ! subtraction}
  98. \begin{tabular}{rclcrcl}
  99. {\bf v} &:=& VECTORMINUS({\bf v}) &{\rm or}&
  100. {\bf v} &:=& - {\bf v} \\
  101. s &:=& VECTORMINUS(s) &{\rm or} & s &:=& - s \\
  102. {\bf v} &:=& VECTORDIFFERENCE({\bf v},{\bf v}) &{\rm or }& {\bf v} &:=&
  103. {\bf v} - {\bf v} \\
  104. s &:=& VECTORDIFFERENCE(s,s) &{\rm or }& s &:=& s - s \\
  105. \end{tabular} \\
  106. \underline{Vector Division}\\
  107. \ttindex{VECTORRECIP}\ttindex{VECTORQUOTIENT}\index{vector ! division}
  108. \begin{tabular}{rclcrcl}
  109. {\bf v} &:=& VECTORRECIP({\bf v}) &{\rm or}& {\bf v} &:=& /
  110. {\bf v} \\
  111. s &:=& VECTORRECIP(s) &{\rm or} & s &:=& / s \\
  112. {\bf v} &:=& VECTORQUOTIENT({\bf v},{\bf v}) &{\rm or }& {\bf v} &:=&
  113. {\bf v} / {\bf v} \\
  114. {\bf v} &:=& VECTORQUOTIENT({\bf v}, s ) &{\rm or }& {\bf v} &:=&
  115. {\bf v} / s \\
  116. {\bf v} &:=& VECTORQUOTIENT( s ,{\bf v}) &{\rm or }& {\bf v} &:=&
  117. s / {\bf v} \\
  118. s &:=& VECTORQUOTIENT(s,s) &{\rm or }& s &:=& s / s
  119. \\
  120. \end{tabular} \\
  121. \underline{Vector Multiplication}\\
  122. \ttindex{VECTORTIMES}\index{vector ! multiplication}
  123. \begin{tabular}{rclcrcl}
  124. {\bf v} &:=& VECTORTIMES( s ,{\bf v}) &{\rm or }& {\bf v} &:=&
  125. s * {\bf v} \\
  126. {\bf v} &:=& VECTORTIMES({\bf v}, s ) &{\rm or }& {\bf v} &:=& {\bf
  127. v} * s \\
  128. s &:=& VECTORTIMES({\bf v},{\bf v}) &{\rm or }& s &:=& {\bf
  129. v} * {\bf v} \\
  130. s &:=& VECTORTIMES( s , s ) &{\rm or }& s &:=&
  131. s * s \\
  132. \end{tabular} \\
  133. \underline{Vector Cross Product} \\
  134. \ttindex{VECTORCROSS}\index{cross product}\index{vector ! cross product}
  135. \begin{tabular}{rclcrcl}
  136. {\bf v} &:=& VECTORCROSS({\bf v},{\bf v}) &{\rm or }& {\bf v} &:=& {\bf
  137. v} $\times$ {\bf v} \\
  138. \end{tabular} \\
  139. \underline{Vector Exponentiation}\\
  140. \ttindex{VECTOREXPT}\index{vector ! exponentiation}
  141. \begin{tabular}{rclcrcl}
  142. s &:=& VECTOREXPT ({\bf v}, s ) &{\rm or }& s &:=& {\bf
  143. v} \^{} s \\
  144. s &:=& VECTOREXPT ( s , s ) &{\rm or }& s &:=& s
  145. \^{} s \\
  146. \end{tabular} \\
  147. \underline{Vector Modulus}\\
  148. \ttindex{VMOD}\index{vector ! modulus}
  149. \begin{tabular}{rcl}
  150. s &:=& VMOD (s)\\
  151. s &:=& VMOD ({\bf v}) \\
  152. \end{tabular} \\
  153. All other combinations of operands for these operators lead to error
  154. messages being issued. The first two instances of vector
  155. multiplication are scalar multiplication of vectors, the third is the
  156. \index{vector ! dot product}\index{vector ! inner product}
  157. \index{inner product}\index{dot product}
  158. product of two scalars and the last is the inner (dot) product. The
  159. prefix operators {\tt +, -, /} can take either scalar or vector
  160. arguments and return results of the same type as their arguments.
  161. VMOD returns a scalar.
  162. In compound expressions, parentheses may be used to specify the order of
  163. combination. If parentheses are omitted the ordering of the
  164. operators, in increasing order of precedence is
  165. \begin{verbatim}
  166. + | - | dotgrad | * | >< | ^ | _
  167. \end{verbatim}
  168. and these are placed in the precedence list defined in \REDUCE{}
  169. after $<$.
  170. Vector divisions are defined as follows: If ${\bf a}$ and ${\bf b}$ are
  171. vectors and $c$ is a scalar, then
  172. \begin{eqnarray*}
  173. {\bf a} / {\bf b} & = & \frac{{\bf a} \cdot {\bf b}}{ \mid {\bf b}
  174. \mid^2}\\
  175. c / {\bf a} & = & \frac{c {\bf a} }{ \mid {\bf a} \mid^2}
  176. \end{eqnarray*}
  177. Both scalar multiplication and dot products are given by the same symbol,
  178. braces are advisable to ensure the correct
  179. precedences in expressions such as $({\bf a} \cdot {\bf b})
  180. ({\bf c} \cdot {\bf d})$.
  181. Vector exponentiation is defined as the power of the modulus:\\
  182. ${\bf a}^n \equiv {\rm VMOD}(a)^n = \mid {\bf a} \mid^n$
  183. \section{Differential Operations}
  184. Differential operators provided are div, grad, curl, delsq, and dotgrad.
  185. \index{div operator}\index{grad operator}\index{curl operator}
  186. \index{delsq operator}\index{dotgrad operator}
  187. All but the last of these are prefix operators having a single
  188. vector or scalar argument as appropriate. Valid combinations of
  189. operator and argument, and the type of the result are shown in
  190. table~\ref{vvecttable}.
  191. \begin{table}
  192. \begin{center}
  193. \begin{tabular}{rcl}
  194. s & := & div ({\bf v}) \\
  195. {\bf v} & := & grad(s) \\
  196. {\bf v} & := & curl({\bf v}) \\
  197. {\bf v} & := & delsq({\bf v}) \\
  198. s & := & delsq(s) \\
  199. {\bf v} & := & {\bf v} dotgrad {\bf v} \\
  200. s & := & {\bf v} dotgrad s
  201. \end{tabular}
  202. \end{center}
  203. \caption{ORTHOVEC valid combinations of operator and argument}\label{vvecttable}
  204. \end{table}
  205. All other combinations of operator and argument type cause error
  206. messages to be issued. The differential operators have their usual
  207. meanings. The coordinate system used by these operators is
  208. set by invoking VSTART (cf. Sec.~\ref{vstart}). The names {\tt h1},
  209. {\tt h2} and {\tt h3 } are
  210. reserved for the scale factors, and {\tt u1}, {\tt u2} and {\tt u3} are
  211. used for the coordinates.
  212. A vector extension, VDF, of the \REDUCE\ procedure DF allows the
  213. differentiation of a vector (scalar) with respect to a scalar to be
  214. performed. Allowed forms are\ttindex{VDF}
  215. VDF({\bf v}, s) $\rightarrow$ {\bf v} and
  216. VDF(s, s) $\rightarrow$ s ,
  217. where, for example\\
  218. \begin{eqnarray*}
  219. {\tt vdf( B,x)} \equiv \frac{\partial {\bf B}}{\partial x}
  220. \end{eqnarray*}
  221. The standard \REDUCE\ procedures DEPEND and NODEPEND have been redefined
  222. to allow dependences of vectors to be compactly
  223. defined. For example\index{DEPEND statement}\index{NODEPEND statement}
  224. \begin{verbatim}
  225. a := svec(a1,a2,a3)$;
  226. depend a,x,y;
  227. \end{verbatim}
  228. causes all three components {\tt a1},{\tt a2} and {\tt a3} of {\tt a}
  229. to be treated as functions of {\tt x} and {\tt y}.
  230. Individual component dependences can still be defined if desired.
  231. \begin{verbatim}
  232. depend a3,z;
  233. \end{verbatim}
  234. The procedure VTAYLOR gives truncated Taylor series expansions of scalar
  235. or vector functions:-\ttindex{VTAYLOR}
  236. \begin{verbatim}
  237. vtaylor(vex,vx,vpt,vorder);
  238. \end{verbatim}
  239. returns the series expansion of the expression
  240. VEX with respect to variable VX\ttindex{VORDER}
  241. about point VPT to order VORDER. Valid
  242. combinations of argument types are shown in table~\ref{ORTHOVEC:validexp}. \\
  243. \begin{table}
  244. \begin{center}
  245. \begin{tabular}{cccc}
  246. VEX & VX & VPT & VORDER \\[2ex]
  247. {\bf v} & {\bf v} & {\bf v} & {\bf v}\\
  248. {\bf v} & {\bf v} & {\bf v} & s\\
  249. {\bf v} & s & s & s \\
  250. s & {\bf v} & {\bf v} & {\bf v} \\
  251. s & {\bf v} & {\bf v} & s\\
  252. s & s & s & s\\
  253. \end{tabular}
  254. \end{center}
  255. \caption{ORTHOVEC valid combination of argument types.}\label{ORTHOVEC:validexp}
  256. \end{table}
  257. Any other combinations cause error messages to be issued. Elements of
  258. VORDER must be non-negative integers, otherwise error messages are
  259. issued. If scalar VORDER is given for a vector expansion, expansions
  260. in each component are truncated at the same order, VORDER.
  261. The new version of Taylor expansion applies\index{l'H\^opital's rule}
  262. l'H\^opital's rule in evaluating coefficients, so handle cases such as
  263. $\sin(x) / (x) $ , etc. which the original version of ORTHOVEC could
  264. not. The procedure used for this is LIMIT,\ttindex{LIMIT} which can
  265. be used directly to find the limit of a scalar function {\tt ex} of
  266. variable {\tt x} at point {\tt pt}:-
  267. \begin{verbatim}
  268. ans := limit(ex,x,pt);
  269. \end{verbatim}
  270. \section{Integral Operations}
  271. Definite and indefinite vector, volume and scalar line integration
  272. procedures are included in ORTHOVEC. They are defined as follows:
  273. \ttindex{VINT}\ttindex{DVINT}
  274. \ttindex{VOLINT}\ttindex{DVOLINT}\ttindex{LINEINT}\ttindex{DLINEINT}
  275. \begin{eqnarray*}
  276. {\rm VINT} ({\bf v},x) & = & \int {\bf v}(x)dx\\
  277. %
  278. {\rm DVINT} ({\bf v},x, a, b) & = & \int^b_a {\bf v} (x) dx\\
  279. %
  280. {\rm VOLINT} ({\bf v}) & = & \int {\bf v} h_1 h_2 h_3 du_1 du_2 du_3\\
  281. %
  282. {\rm DVOLINT}({\bf v},{\bf l},{\bf u},n) & = & \int^{\bf u}_{\bf l}
  283. {\bf v} h_1 h_2 h_3 du_1 du_2 du_3\\
  284. %
  285. {\rm LINEINT} ({\bf v, \omega}, t) & = & \int {\bf v} \cdot {\bf dr}
  286. \equiv \int v_i h_i \frac{\partial \omega_i}{\partial t} dt\\
  287. %
  288. {\rm DLINEINT} ({\bf v, \omega} t, a, b) & = & \int^b_a v_i h_i
  289. \frac{\partial \omega_i}{\partial t} dt\\
  290. \end{eqnarray*}
  291. In the vector and volume integrals, ${\bf v}$ are vector or scalar,
  292. $a, b,x$ and $n$ are scalar. Vectors ${\bf l}$ and ${\bf u}$ contain
  293. expressions for lower and upper bounds to the integrals. The integer
  294. index $n$ defines the order in which the integrals over $u_1, u_2$ and
  295. $u_3$ are performed in order to allow for functional dependencies in
  296. the integral bounds:
  297. \begin{center}
  298. \begin{tabular}{ll}
  299. n & order\\ 1 & $u_1~u_2~u_3$\\
  300. %
  301. 2 & $u_3~u_1~u_2$\\
  302. %
  303. 3 & $u_2~u_3~u_1$\\
  304. %
  305. 4 & $u_1~u_3~u_2$\\
  306. %
  307. 5 & $u_2~u_1~u_3$\\ otherwise & $u_3~u_2~u_1$\\
  308. \end{tabular}
  309. \end{center}
  310. The vector ${\bf \omega}$ in the line integral's arguments contain
  311. explicit parameterisation of the coordinates $u_1, u_2, u_3$ of the
  312. line ${\bf u}(t)$ along which the integral is taken.