fide.doc 74 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984
  1. F I D E
  2. ==========
  3. A REDUCE package for automation of
  4. FInite difference method for partial
  5. Differential Equation solving
  6. Version 1.1
  7. User's Manual
  8. -------------
  9. Richard Liska
  10. Faculty of Nuclear Science and Physical Engineering
  11. Technical University of Prague
  12. Brehova 7, 115 19 Prague 1, Czechoslovakia
  13. E-mail: tjerl@cspuni12.bitnet (EARN)
  14. Fax: (42 - 2) 84 73 54
  15. Tel: (42 - 2) 84 77 86
  16. May 1991
  17. 1
  18. Abstract
  19. --------
  20. The FIDE package performs automation of the process of numerical
  21. solving partial differential equations systems (PDES) by means of
  22. computer algebra. For PDES solving finite difference method is applied.
  23. The computer algebra system REDUCE and the numerical programming
  24. language FORTRAN are used in the presented methodology. The main aim of
  25. this methodology is to speed up the process of preparing numerical
  26. programs for solving PDES. This process is quite often, especially for
  27. complicated systems, a tedious and time consuming task.
  28. In the process one can find several stages in which computer
  29. algebra can be used for performing routine analytical calculations,
  30. namely: transforming differential equations into different coordinate
  31. systems, discretization of differential equations, analysis of
  32. difference schemes and generation of numerical programs. The FIDE
  33. package consists of the following modules:
  34. EXPRES for transforming PDES into any orthogonal coordinate system.
  35. IIMET for discretization of PDES by integro-interpolation method.
  36. APPROX for determining the order of approximation of difference
  37. scheme.
  38. CHARPOL for calculation of amplification matrix and characteristic
  39. polynomial of difference scheme, which are needed in Fourier
  40. stability analysis.
  41. HURWP for polynomial roots locating necessary in verifying the von
  42. Neumann stability condition.
  43. LINBAND for generating the block of FORTRAN code, which solves a
  44. system of linear algebraic equations with band matrix
  45. appearing quite often in difference schemes.
  46. Version 1.1 of the FIDE package is the result of porting FIDE
  47. package to REDUCE 3.4. In comparison with Version 1.0 some features has
  48. been changed in the LINBAND module (possibility to interface several
  49. numerical libraries).
  50. References
  51. ----------
  52. [1] R. Liska, L. Drska: FIDE: A REDUCE package for automation of FInite
  53. difference method for solving pDE. In ISSAC '90, Proceedings of
  54. the International Symposium on Symbolic and Algebraic Computation,
  55. Ed. S. Watanabe, M. Nagata. p. 169-176, ACM Press, Addison Wesley,
  56. New York 1990.
  57. 2
  58. Table of contents
  59. =================
  60. 1 E X P R E S 4
  61. 1.1 The specification of the coordinate system.......................4
  62. 1.2 The declaration of tensor quantities.............................5
  63. 1.3 New infix operators..............................................5
  64. 1.4 New prefix operators.............................................5
  65. 1.5 Tensor expressions...............................................6
  66. 1.6 Assigning statement..............................................7
  67. 2 I I M E T 8
  68. 2.1 Specification of the coordinates and the indices
  69. corresponding to them............................................8
  70. 2.2 Difference grids.................................................9
  71. 2.3 Declaring the dependence of functions on coordinates............10
  72. 2.4 Functions and difference grids..................................11
  73. 2.5 Equations and difference grids..................................12
  74. 2.6 Discretization of basic terms...................................13
  75. 2.7 Discretization of a system of equations.........................18
  76. 2.8 Error messages..................................................20
  77. 3 A P P R O X 21
  78. 3.1 Specification of the coordinates and the indices
  79. corresponding to them...........................................21
  80. 3.2 Specification of the Taylor expansion...........................21
  81. 3.3 Function declaration............................................22
  82. 3.4 Order of accuracy determination.................................23
  83. 4 C H A R P O L 24
  84. 4.1 Commands common with the IIMET module...........................24
  85. 4.2 Function declaration............................................24
  86. 4.3 Amplification matrix............................................25
  87. 4.4 Characteristic polynomial.......................................26
  88. 4.5 Automatic denotation............................................26
  89. 5 H U R W P 28
  90. 5.1 Conformal mapping...............................................28
  91. 5.2 Investigation of polynomial roots...............................28
  92. 6 L I N B A N D 30
  93. 6.1 Program generation..............................................30
  94. 6.2 Choosing the numerical library..................................32
  95. 6.3 Completion of the generated code................................32
  96. 3
  97. 1 E X P R E S
  98. ===========
  99. A Module for Transforming Differential
  100. Operators and Equations into an Arbitrary Orthogonal
  101. Coordinate System
  102. This module makes it possible to express various scalar, vector,
  103. and tensor differential equations in any orthogonal coordinate system.
  104. All transformations needed are executed automatically according to the
  105. coordinate system given by the user. The module was implemented
  106. according to the similar MACSYMA module from [1].
  107. 1.1 The specification of the coordinate system
  108. ------------------------------------------
  109. The coordinate system is specified using the following statement:
  110. SCALEFACTORS <d>,<tr 1>,...,<tr d>,<cor 1>,...,<cor d>;
  111. <d> ::= 2 | 3 coordinate system dimension
  112. <tr i> ::= "algebraic expression" the expression of the i-th
  113. Cartesian coordinate in new
  114. coordinates
  115. <cor i> ::= "identifier" the i-th new coordinate
  116. All evaluated quantities are transformed into the coordinate system set
  117. by the last SCALEFACTORS statement. By default, if this statement is not
  118. applied, the three-dimensional Cartesian coordinate system is employed.
  119. During the evaluation of SCALEFACTORS statement the metric coefficients,
  120. i.e. scale factors SF(i), of a defined coordinate system are computed
  121. and printed. If the WRCHRI switch is ON, then the nonzero Christoffel
  122. symbols of the coordinate system are printed too. By default the WRCHRI
  123. switch is OFF.
  124. 4
  125. 1.2 The declaration of tensor quantities
  126. ------------------------------------
  127. Tensor quantities are represented by identifiers. The VECTORS
  128. declaration declares the identifiers as vectors, the DYADS declaration
  129. declares the identifiers as dyads. i.e. two-dimensional tensors, and the
  130. TENSOR declaration declares the identifiers as tensor variables. The
  131. declarations have the following syntax:
  132. <declaration> <id 1>,<id 2>,...,<id n>;
  133. <declaration> ::= VECTORS | DYADS | TENSOR
  134. <id i> ::= "identifier"
  135. The value of the identifier V declared as vector in the two-dimensional
  136. coordinate system is (V(1), V(2)), where V(i) are the components of
  137. vector V. The value of the identifier T declared as a dyad is ((T(1,1),
  138. T(1,2)), (T(2,1), T(2,2))). The value of the tensor variable can be any
  139. tensor (see below). Tensor variables can be used only for a single
  140. coordinate system, after the coordinate system redefining by a new
  141. SCALEFACTORS statement, the tensor variables have to be re-defined using
  142. the assigning statement.
  143. 1.3 New infix operators
  144. -------------------
  145. For four different products between the tensor quantities, new
  146. infix operators have been introduced (in the explaining examples, a
  147. two-dimensional coordinate system, vectors U, V, and dyads T, W are
  148. considered):
  149. . - scalar product U.V = U(1)*V(1)+U(2)*V(2)
  150. ? - vector product U?V = U(1)*V(2)-U(2)*V(1)
  151. & - outer product U&V = ((U(1)*V(1),U(1)*V(2)),
  152. (U(2)*V(1),U(2)*V(2)))
  153. # - double scalar product T#W = T(1,1)*W(1,1)+T(1,2)*W(1,2)+
  154. T(2,1)*W(2,1)+T(2,2)*W(2,2)
  155. The other usual arithmetic infix operators +, -, *, ** can be used in
  156. all situations that have sense (e.g. vector addition, a multiplication
  157. of a tensor by a scalar, etc.).
  158. 1.4 New prefix operators
  159. --------------------
  160. New prefix operators have been introduced to express tensor
  161. quantities in its components and the differential operators over the
  162. tensor quantities:
  163. VECT - the explicit expression of a vector in its components
  164. DYAD - the explicit expression of a dyad in its components
  165. 5
  166. GRAD - differential operator of gradient
  167. DIV - differential operator of divergence
  168. LAPL - Laplace's differential operator
  169. CURL - differential operator of curl
  170. DIRDF - differential operator of the derivative in direction
  171. (1st argument is the directional vector)
  172. The results of the differential operators are written using the DIFF
  173. operator. DIFF(<scalar>,<cor i>) expresses the derivative of <scalar>
  174. with respect to the coordinate <cor i>. This operator is not further
  175. simplified. If the user wants to make it simpler as common derivatives,
  176. he performs the following declaration:
  177. FOR ALL X,Y LET DIFF(X,Y) = DF(X,Y); .
  178. Then, however, we must realize that if the scalars or tensor quantities
  179. do not directly explicitly depend on the coordinates, their dependencies
  180. have to be declared using the DEPEND statements, otherwise the
  181. derivative will be evaluated to zero. The dependence of all vector or
  182. dyadic components (as dependence of the name of vector or dyad) has to
  183. appear before VECTORS or DYADS declarations, otherwise after these
  184. declarations one has to declare the dependencies of all components. For
  185. formulating the explicit derivatives of tensor expressions, the
  186. differentiation operator DF can be used (e.g. the differentiation of a
  187. vector in its components).
  188. 1.5 Tensor expressions
  189. ------------------
  190. Tensor expressions are the input into the EXPRES module and can
  191. have a variety of forms. The output is then the formulation of the given
  192. tensor expression in the specified coordinate system. The most general
  193. form of a tensor expression <tensor> is described as follows (the
  194. conditions (d=i) represent the limitation on the dimension of the
  195. coordinate system equalling i):
  196. <tensor> ::= <scalar> | <vector> | <dyad>
  197. <scalar> ::= "algebraic expression, can contain <scalars>" |
  198. "tensor variable with scalar value" |
  199. <vector 1>.<vector 2> | <dyad 1>#<dyad 2> |
  200. (d=2)<vector 1>?<vector 2> | DIV <vector> |
  201. LAPL <scalar> | (d=2) ROT <vector> |
  202. DIRDF(<vector>,<scalar>)
  203. <vector> ::= "identifier declared by VECTORS statement" |
  204. "tensor variable with vector value" |
  205. VECT(<scalar 1>,...,<scalar d>) | -<vector> |
  206. <vector 1>+<vector 2> | <vector 1>-<vector 2> |
  207. <scalar>*<vector> | <vector>/<scalar> |
  208. <dyad>.<vector> | <vector>.<dyad> | (d=3)
  209. <vector 1>?<vector 2> | (d=2) <vector>?<dyad> |
  210. (d=2) <dyad>?<vector> | GRAD <scalar> |
  211. 6
  212. DIV <dyad> | LAPL <vector> | (d=3) ROT <vector> |
  213. DIRDF(<vector 1>,<vector 2>) | DF(<vector>,"usual
  214. further arguments")
  215. <dyad> ::= "identifier declared by DYADS statement" |
  216. "tensor variable with dyadic value" |
  217. DYAD((<scalar 11>,...,<scalar 1d>),...,(<scalar d1>,
  218. ...,<scalar dd>)) | -<dyad> | <dyad 1>+<dyad 2> |
  219. <dyad 1>-<dyad 2> | <scalar>*<dyad> | <dyad>/<scalar>
  220. | <dyad 1>.<dyad 2> | <vector 1>&<vector 2> |
  221. (d=3) <vector>?<dyad> | (d=3) <dyad>?<vector> |
  222. GRAD <vector> | DF(<dyad>,"usual further arguments")
  223. 1.6 Assigning statement
  224. -------------------
  225. The assigning statement for tensor variables has a usual syntax,
  226. namely:
  227. <tensor variable> := <tensor>
  228. <tensor variable> ::= "identifier declared TENSOR" .
  229. The assigning statement assigns the tensor variable the value of the
  230. given tensor expression, formulated in the given coordinate system.
  231. After a change of the coordinate system, the tensor variables have to be
  232. redefined.
  233. References
  234. ----------
  235. [1] M. C. Wirth, On the Automation of Computational Physics. PhDr
  236. Thesis. Report UCRL-52996, Lawrence Livermore National
  237. Laboratory, Livermore, 1980.
  238. 7
  239. 2 I I M E T
  240. =========
  241. A Module for Discretizing the Systems
  242. of Partial Differential Equations
  243. This program module makes it possible to discretize the specified
  244. system of partial differential equations using the integro-interpolation
  245. method, minimizing the number of the used interpolations in each
  246. independent variable. It can be used for non-linear systems and vector
  247. or tensor variables as well. The user specifies the way of discretizing
  248. individual terms of differential equations, controls the discretization
  249. and obtains various difference schemes according to his own wish.
  250. 2.1 Specification of the coordinates and the indices corresponding
  251. to them
  252. --------------------------------------------------------------
  253. The independent variables of differential equations will be called
  254. coordinates. The names of the coordinates and the indices that will
  255. correspond to the particular coordinates in the difference scheme are
  256. defined using the COORDINATES statement:
  257. COORDINATES <coordinate 1>{,<coordinate i>} [ INTO
  258. <index 1>{,<index i>}];
  259. <coordinate i> ::= "identifier" - the name of the coordinate
  260. <index i> ::= "identifier" - the name of the index
  261. This statement specifies that the <coordinate i> will correspond to the
  262. <index i>. A new COORDINATES statement cancels the definitions given by
  263. the preceding COORDINATES statement. If the part [ INTO ... ] is not
  264. included in the statement, the statement assigns the coordinates the
  265. indices I, J, K, L, M, N, respectively. If it is included, the number of
  266. coordinates and the number of indices should be the same.
  267. 8
  268. 2.2 Difference grids
  269. ----------------
  270. In the discretization, orthogonal difference grids are employed.
  271. In addition to the basic grid, called the integer one, there is another,
  272. the half-integer grid in each coordinate, whose cellular boundary points
  273. lie in the centers of the cells of the integer grid. The designation of
  274. the cellular separating points and centers is determined by the
  275. CENTERGRID switch: if it is ON and the index in the given coordinate is
  276. I, the centers of the grid cells are designated by indices I, I + 1,...,
  277. and the boundary points of the cells by indices I + 1/2,..., if, on the
  278. contrary, the switch is OFF, the cellular centers are designated by
  279. indices I + 1/2,..., and the boundary points by indices I, I + 1,...
  280. (see Fig. 2.1).
  281. ON CENTERGRID
  282. I-1/2 I I+1/2 I+1 I+3/2
  283. ---|--------|--------|--------------|--------------|----
  284. I I+1/2 I+1 I+3/2 I+2
  285. OFF CENTERGRID
  286. Figure 2.1 Types of grid
  287. In the case of ON CENTERGRID, the indices i,i+1,i-1... thus designate
  288. the centers of the cells of the integer grid and the boundary points of
  289. the cells of the half-integer grid, and, similarly, in the case of OFF
  290. CENTERGRID, the boundaries of the cells of the integer grid and the
  291. central points of the half-integer grid. The meaning of the integer and
  292. half-integer grids depends on the CENTERGRID switch in the described
  293. way. After the package is loaded, the CENTERGRID is ON. Obviously, this
  294. switch is significant only for non-uniform grids with a variable size of
  295. each cell.
  296. The grids can be uniform, i.e. with a constant cell size - the step
  297. of the grid. The following statement:
  298. GRID UNIFORM,<coordinate>{,<coordinate>};
  299. defines uniform grids in all coordinates occurring in it. Those
  300. coordinates that do not occur in the GRID UNIFORM statement are supposed
  301. to have non-uniform grids.
  302. In the outputs, the grid step is designated by the identifier that
  303. is made by putting the character H before the name of the coordinate.
  304. For a uniform grid, this identifier (e.g. for the coordinate X the grid
  305. step HX) has the meaning of a step of an integer or half-integer grids
  306. that are identical. For a non-uniform grid, this identifier is an
  307. operator and has the meaning of a step of an integer grid, i.e. the
  308. length of a cell whose center (in the case of ON CENTERGRID) or
  309. beginning (in the case of OFF CENTERGRID) is designated by a single
  310. argument of this operator. For each coordinate s designated by the
  311. 9
  312. identifier i, this step of the integer non-uniform grid is defined as
  313. follows:
  314. Hs(i+j) = s(i+j+1/2) - s(i+j-1/2) at ON CENTERGRID
  315. Hs(i+j) = s(i+j+1) - s(i+j) at OFF CENTERGRID
  316. for all integers j (s(k) designates the value of the coordinate s in the
  317. cellular boundary point subscripted with the index k). The steps of the
  318. half-integer non-uniform grid are not applied in outputs.
  319. 2.3 Declaring the dependence of functions on coordinates
  320. ----------------------------------------------------
  321. In the system of partial differential equations, two types of
  322. functions, in other words dependent variables can occur: namely, the
  323. given functions, whose values are known before the given system is
  324. solved, and the sought functions, whose values are not available until
  325. the system of equations is solved. The functions can be scalar, vector,
  326. or tensor, for vector or tensor functions the EXPRES module has to be
  327. applied at the same time. The names of the functions employed in the
  328. given system and their dependence on the coordinates are specified using
  329. the DEPENDENCE statement.
  330. DEPENDENCE <dependence>{,<dependence>};
  331. <dependence> ::= <function>([<order>],<coordinate>{,
  332. <coordinate>})
  333. <function> ::= "identifier" - the name of the function
  334. <order> ::= 1|2 tensor order of the function (the value of
  335. the function is 1 - vector, 2 - dyad (two-
  336. dimensional tensor))
  337. Every <dependence> in the statement determines on which <coordinates>
  338. the <function> depends. If the tensor <order> of the function occurs in
  339. the <dependence>, the <function> is declared as a vector or a dyad. If,
  340. however, the <function> has been declared by the VECTORS and DYADS
  341. statements of the EXPRES module, the user need not present the tensor
  342. <order>. By default, a function without any declaration is regarded as
  343. scalar. In the discretization, all scalar components of tensor functions
  344. are replaced by identifiers that arise by putting successively the
  345. function name and the individual indices of the given component (e.g.
  346. the tensor component T(1,2), written in the EXPRES module as T(1,2), is
  347. represented by the identifier T12). Before the DEPENDENCE statement is
  348. executed, the coordinates have to be defined using the COORDINATES
  349. statement. There may be several DEPENDENCE statements. The DEPENDENCE
  350. statement cancels all preceding determinations of which grids are to be
  351. used for differentiating the function or the equation for this function.
  352. These determinations can be either defined by the ISGRID or GRIDEQ
  353. statements, or computed in the evaluation of the IIM statement.
  354. The GIVEN statement:
  355. GIVEN <function>{,<function>};
  356. 10
  357. declares all functions included in it as given functions whose values
  358. are known to the user or can be computed. The CLEARGIVEN statement:
  359. CLEARGIVEN;
  360. cancels all preceding GIVEN declarations. If the TWOGRID switch is ON,
  361. the given functions can be differentiated both on the integer and the
  362. half-integer grids. If the TWOGRID switch is OFF, any given function can
  363. be differentiated only on one grid. After the package is loaded, the
  364. TWOGRID is ON.
  365. 2.4 Functions and difference grids
  366. ------------------------------
  367. Every scalar function or scalar component of a vector or a dyadic
  368. function occurring in the discretized system can be discretized in any
  369. of the coordinates either on the integer or half-integer grid. One of
  370. the tasks of the IIMET module is to find the optimum distribution of
  371. each of these dependent variables of the system on the integer and
  372. half-integer grids in all variables so that the number of the performed
  373. interpolations in the integro-interpolation method will be minimal.
  374. Using the statement
  375. SAME <function>{,<function>};
  376. all functions given in one of these declarations will be discretized on
  377. the same grids in all coordinates. In each SAME statement, at least one
  378. of these functions in one SAME statement must be the sought one. If the
  379. given function occurs in the SAME statement, it will be discretized only
  380. on one grid, regardless of the state of the TWOGRID switch. If a vector
  381. or a dyadic function occurs in the SAME statement, what has been said
  382. above relates to all its scalar components. There are several SAME
  383. statements that can be presented. All SAME statements can be canceled by
  384. the following statement:
  385. CLEARSAME;
  386. The SAME statement can be successfully used, for example, when the given
  387. function depends on the function sought in a complicated manner that
  388. cannot be included either in the differential equation or in the
  389. difference scheme explicitly, and when both the functions are desired to
  390. be discretized in the same points so that the user will not be forced to
  391. execute the interpolation during the evaluation of the given function.
  392. In some cases, it is convenient too to specify directly which
  393. variable on which grid is to be discretized, for which case the ISGRID
  394. statement is applied:
  395. ISGRID <s-function>{,<s-function>};
  396. <s-function> ::= <function>([<component>,]<s-grid>{,<s-grid>})
  397. <s-grid> ::= <coordinate> .. <grid>,
  398. 11
  399. <grid> ::= ONE | HALF designation of the integer
  400. (ONE) and half-integer (HALF)
  401. grids
  402. <component> ::= <i-dim> | for the vector <function>
  403. <i-dim>,<i-dim> for the dyadic <function>
  404. it is not presented for the
  405. scalar <function>
  406. <i-dim> ::= *| "natural number from 1 to the space dimension
  407. the space dimension is specified in the EXPRES
  408. module by the SCALEFACTORS statement, * means all
  409. components
  410. The statement defines that the given functions or their components will
  411. be discretized in the specified coordinates on the specified grids, so
  412. that, for example, the statement ISGRID U (X..ONE,Y..HALF), V(1,Z..ONE),
  413. T(*,1,X..HALF); defines that scalar U will be discretized on the integer
  414. grid in the coordinate X, and on the half-integer one in the coordinate
  415. Y, the first component of vector V will be on the integer grid in the
  416. coordinate Z, and the first column of tensor T will be on the
  417. half-integer grid in the coordinate X. The ISGRID statement can be
  418. applied more times. The functions used in this statement have to be
  419. declared before by the DEPENDENCE statement.
  420. 2.5 Equations and difference grids
  421. ------------------------------
  422. Every equation of the system of partial differential equations is
  423. an equation for some sought function (specified in the IIM statement).
  424. The correspondence between the sought functions and the equations is
  425. mutually unambiguous. The GRIDEQ statement makes it possible to
  426. determine on which grid an individual equation will be discretized in
  427. some or all coordinates
  428. GRIDEQ <g-function>{,<g-function>};
  429. <g-function> ::= <function>(<s-grid>{,<s-grid>})
  430. Every equation can be discretized in any coordinate either on the
  431. integer or half-integer grid. This statement determines the
  432. discretization of the equations given by the functions included in it in
  433. given coordinates, on given grids. The meaning of the fact that an
  434. equation is discretized on a certain grid is as follows: index I used in
  435. the DIFMATCH statements (discussed in the following section), specifying
  436. the discretization of the basic terms, will be located in the center of
  437. the cell of this grid, and indices I+1/2, I-1/2 from the DIFMATCH
  438. statement on the boundaries of the cell of this grid. The actual name of
  439. the index in the given coordinate is determined using the COORDINATES
  440. statement, and its location on the grid is set by the CENTERGRID switch.
  441. 12
  442. 2.6 Discretization of basic terms
  443. -----------------------------
  444. The discretization of a system of partial differential equations is
  445. executed successively in individual coordinates. In the discretization
  446. of an equation in one coordinate, the equation is linearized into its
  447. basic terms first that will be discretized independently then. If D is
  448. the designation for the discretization operator in the coordinate x,
  449. this linearization obeys the following rules:
  450. 1. D(a+b) = D(a)+D(b)
  451. 2. D(-a) = -D(a)
  452. 3. D(p.a) = p.D(a) (p does not depend on the coordinate x)
  453. 4. D(a/p) = D(a)/p
  454. The linearization lasts as long as some of these rules can be
  455. applied. The basic terms that must be discretized after the
  456. linearization have then the forms of the following quantities:
  457. 1. The actual coordinate in which the discretization is performed.
  458. 2. The sought function.
  459. 3. The given function.
  460. 4. The product of the quantities 1 - 7.
  461. 5. The quotient of the quantities 1 - 7.
  462. 6. The natural power of the quantities 1 - 7.
  463. 7. The derivative of the quantities 1 - 7 with respect to the
  464. actual coordinate.
  465. The way of discretizing these basic terms, while the functions are on
  466. integer and half-integer grids, is determined using the DIFMATCH
  467. statement:
  468. DIFMATCH <coordinate>,<pattern term>,{{<grid specification>,}
  469. <number of interpolations>, <discretized term>};
  470. <coordinate> ::= ALL | "identifier" - the coordinate name from
  471. the COORDINATES statement
  472. <pattern term> ::= <pattern coordinate>|
  473. <pattern sought function>|
  474. <pattern given function>|<pattern term> *
  475. <pattern term>|<pattern term> / <pattern term>|
  476. <pattern term> ** <exponent>|
  477. DIFF(<pattern term>,<pattern coordinate>[,<order
  478. of derivative>])|
  479. <declared operator>(<pattern term>{,<pattern term>})
  480. <pattern coordinate> ::= X
  481. <pattern sought function> ::= U | V | W
  482. <pattern given function> ::= F | G
  483. <exponent> ::= N | "integer greater than 1"
  484. <order of derivative> ::= "integer greater than 2"
  485. <grid specification> ::= <pattern function>=<grid>
  486. <pattern function> ::= <pattern sought function>|
  487. <pattern given function>
  488. 13
  489. <number of interpolations> ::= "non-negative integer"
  490. <discretized term> ::= <pattern operator>(<index expression>)|
  491. "natural number"|DI|DIM1|DIP1|DIM2|DIP2|
  492. <declared term> | - <discretized term> |
  493. <discretized term> + <discretized term> |
  494. <discretized term> * <discretized term> |
  495. <discretized term> / <discretized term> |
  496. (<discretized term>) |
  497. <discretized term> **<exponent>
  498. <pattern operator> ::= X | U | V | W | F | G
  499. <index expression> ::= <pattern index> |
  500. <pattern index> + <increment> |
  501. <pattern index> - <increment>
  502. <pattern index> ::= I
  503. <increment> = "rational number"
  504. DIFCONST <declared term>{,<declared term>};
  505. <declared term> ::= "identifier" - the constant parameter of
  506. the difference scheme.
  507. DIFFUNC <declared operator>{,<declared operator>};
  508. <declared operator> ::= "identifier" - prefix operator, that can
  509. appear in discretized equations (e.g. SIN).
  510. The first parameter of the DIFMATCH statement determines the coordinate
  511. for which the discretization defined in it is valid. If ALL is used, the
  512. discretization will be valid for all coordinates, and this
  513. discretization is accepted when it has been checked whether there has
  514. been no other discretization defined for the given coordinate and the
  515. given pattern term. Each pattern sought function, occurring in the
  516. pattern term, must be included in the specification of the grids. The
  517. pattern given functions from the pattern term can occur in the grid
  518. specification, but in some cases (see below) need not. In the grid
  519. specification the maximum number of 3 pattern functions may occur. The
  520. discretization of each pattern term has to be specified in all
  521. combinations of the pattern functions occurring in the grid
  522. specification, on the integer and half-integer grids, that is 2**n
  523. variants for the grid specification with n pattern functions
  524. (n=0,1,2,3). The discretized term is the discretization of the pattern
  525. term in the pattern coordinate X in the point X(I) on the pattern grid
  526. (see Fig. 2.2), and the pattern functions occurring in the grid
  527. specification are in the discretized term on the respective grids from
  528. this specification (to the discretized term corresponds the grid
  529. specification preceding it).
  530. integer grid
  531. X(I-1) X(I) X(I+1)
  532. | DIM1 | DIP1 |
  533. ---|------|------|-------------|-------------|-----|-----|---
  534. | DIM2 | DI | DIP2 |
  535. X(I-3/2) X(I-1/2) X(I+1/2) X(I+3/2)
  536. half-integer grid
  537. Figure 2.2 Pattern grid
  538. 14
  539. The pattern grid steps defined as
  540. DIM2 = X(I - 1/2) - X(I - 3/2)
  541. DIM1 = X(I) - X(I - 1)
  542. DI = X(I + 1/2) - X(I - 1/2)
  543. DIP1 = X(I + 1) - X(I)
  544. DIP2 = X(I + 3/2) - X(I + 1/2)
  545. can occur in the discretized term.
  546. In the integro-interpolation method, the discretized term is
  547. specified by the integral
  548. <discretized term>=1/(X(I+1/2)-X(I-1/2))*DINT(X(I-1/2),X(I+1/2),
  549. <pattern term>,X),
  550. where DINT is operator of definite integration DINT(from, to, function,
  551. variable). The number of interpolations determines how many
  552. interpolations were needed for calculating this integral in the given
  553. discrete form (the function on the integer or half-integer grid). If the
  554. integro-interpolation method is not used, the more convenient is the
  555. distribution of the functions on the half-integer and integer grids, the
  556. smaller number is chosen by the user. The parameters of the difference
  557. scheme defined by the DIFCONST statement can occur in the discretized
  558. expression too (for example, the implicit-explicit scheme on the
  559. implicit layer multiplied by the constant C and on the explicit one by
  560. (1-C)). As a matter of fact, all DIFMATCH statements create a base of
  561. pattern terms with the rules of how to discretize these terms in
  562. individual coordinates under the assumption that the functions occurring
  563. in the pattern terms are on the grids determined in the grid
  564. specification (all combinations must be included).
  565. The DIFMATCH statement does not check whether the discretized term
  566. is actually the discretization of the pattern term or whether in the
  567. discretized term occur the functions from the grid specification on the
  568. grids given by this specification. An example can be the following
  569. definition of the discretization of the first and second derivatives of
  570. the sought function in the coordinate R on a uniform grid:
  571. DIFMATCH R,DIFF(U,X),U=ONE,2,(U(I+1)-U(I-1))/(2*DI);
  572. U=HALF,0,(U(I+1/2)-U(I-1/2))/DI;
  573. DIFMATCH R,DIFF(U,X,2),U=ONE,0,(U(I+1)-2*U(I)+U(I-1))/DI**2,
  574. U=HALF,2,(U(I+3/2)-U(I+1/2)-U(I-1/2)+U(I-3/2))/(2*DI**2);
  575. All DIFMATCH statements can be cleared by the statement
  576. CLEARDIFMATCH;
  577. After this statement user has to supply its own DIFMATCH statements.
  578. But now back to the discretizing of the basic terms obtained by the
  579. linearization of the partial differential equation, as mentioned at the
  580. beginning of this section. Using the method of pattern matching, for
  581. each basic term a term representing its pattern is found in the base of
  582. 15
  583. pattern terms (specified by the DIFMATCH statements). The pattern
  584. matching obeys the following rules:
  585. 1. The pattern for the coordinate in which the discretization is
  586. executed is the pattern coordinate X.
  587. 2. The pattern for the sought function is some pattern sought
  588. function, and this correspondence is mutually unambiguous.
  589. 3. The pattern for the given function is some pattern given
  590. function, or, in case the EQFU switch is ON, some pattern sought
  591. function, and, again, the correspondence of the pattern with the
  592. given function is mutually unambiguous (after loading the EQFU
  593. switch is ON).
  594. 4. The pattern for the products of quantities is the product of the
  595. patterns of these quantities, irrespective of their sequence.
  596. 5. The pattern for the quotient of quantities is the quotient of the
  597. patterns of these quantities.
  598. 6. The pattern for the natural power of a quantity is the same power
  599. of the pattern of this quantity or the power of this quantity with
  600. the pattern exponent N.
  601. 7. The pattern for the derivative of a quantity with respect to the
  602. coordinate in which the discretization is executed is the derivative
  603. of the pattern of this quantity with respect to the pattern
  604. coordinate X of the same order of differentiation.
  605. 8. The pattern for the sum of the quantities that have the same
  606. pattern with the identical correspondence of functions and pattern
  607. functions is this common pattern (so that it will not be necessary
  608. to multiply the parentheses during discretizing the products in the
  609. second and further coordinates).
  610. When matching the pattern of one basic term, the program finds the
  611. pattern term and the functions corresponding to the pattern functions,
  612. maybe also the exponent corresponding to the pattern exponent N. After
  613. determining on which grids the individual functions and the individual
  614. equations will be discretized, which will be discussed in the next
  615. section, the program finds in the pattern term base the discretized term
  616. either with pattern functions on the same grids as are the functions
  617. from the basic term corresponding to them in case that the given
  618. equation is differentiated on the integer grid, or with pattern
  619. functions on inverse grids (an inverse integer grid is a half-integer
  620. grid, and vice versa) compared with those used for the functions from
  621. the basic term corresponding to them in case the given equation is
  622. differentiated on the half-integer grid (the discretized term in the
  623. DIFMATCH statement is expressed in the point X(I), i.e. on the integer
  624. grid, and holds for the discretizing of the equation on the integer
  625. grid; with regard to the substitutions for the pattern index I mentioned
  626. 16
  627. later, it is possible to proceed in this way and not necessary to define
  628. the discretization in the points X(I+1/2) too, i.e. on the half-integer
  629. grid). The program replaces in the thus obtained discretized term:
  630. 1. The pattern coordinate X with the particular coordinate s in
  631. which the discretization is actually performed.
  632. 2. The pattern index I and the grid steps DIM2, DIM1, DI, DIP1, DIP2
  633. with the expression given in table 2.1 according to the state of the
  634. CENTERGRID switch and to the fact whether the given equation is
  635. discretized on the integer or half-integer grid (i is the index
  636. corresponding to the coordinate s according to the COORDINATES
  637. statement, the grid steps were defined in section 2.2)
  638. 3. The pattern functions with the corresponding functions from the
  639. basic term and, possibly, the pattern exponent with the
  640. corresponding exponent from the basic term.
  641. --------------------------------------------------------------------
  642. | the equation discretized on |
  643. | the integer grid | the half-integer grid |
  644. | CENTERGRID |CENTERGRID|CENTERGRID| CENTERGRID |
  645. | OFF | ON | OFF | ON |
  646. |------------------------------------------------------------------|
  647. | I | i | i+1/2 |
  648. |----|-------------------------------------------------------------|
  649. |DIM2|(Hs(i-2)+Hs(i-1))/2| Hs(i-1) |(Hs(i-1)+Hs(i))/2 |
  650. |DIM1| Hs(i-1) | (Hs(i-1)+Hs(i))/2 | Hs(i) |
  651. |DI |(Hs(i-1)+Hs(i))/2 | Hs(i) |(Hs(i)+Hs(i+1))/2 |
  652. |DIP1| Hs(i) | (Hs(i)+Hs(i+1))/2 | Hs(i+1) |
  653. |DIP2|(Hs(i)+Hs(i+1))/2 | Hs(i+1) |(Hs(i+1)+Hs(i+2))/2|
  654. --------------------------------------------------------------------
  655. Table 2.1 Values of the pattern index and
  656. the pattern grid steps.
  657. More details will be given now to the discretization of the given
  658. functions and its specification. The given function may occur in the
  659. SAME statement, which makes it bound with some sought function, in other
  660. words it can be discretized only on one grid. This means that all basic
  661. terms, in which this function occurs, must have their pattern terms in
  662. whose discretization definitions by the DIFMATCH statement the pattern
  663. function corresponding to the mentioned given function has to occur in
  664. the grid specification. If the given function does not occur in the SAME
  665. statement and the TWOGRID switch is OFF, i.e. it can be discretized only
  666. on one grid again, the same holds true. If, however, the given function
  667. does not occur in the SAME statement and the TWOGRID switch is ON, i.e.
  668. it can be discretized simultaneously on the integer and the half-integer
  669. grids, then the basic terms of the equations including this function
  670. have their pattern terms in whose discretization definitions the pattern
  671. function corresponding to the mentioned given function need not occur in
  672. the grid specification. If, however, in spite of all, this pattern
  673. 17
  674. function in the discretization definition does occur in the grid
  675. specification, it is the alternative with a smaller number of
  676. interpolations occurring in the DIFMATCH statement that is selected for
  677. each particular basic term with a corresponding pattern (the given
  678. function can be on the integer or half-integer grid).
  679. Before the discretization is executed, it is necessary to define
  680. using the DIFMATCH statements the discretization of all pattern terms
  681. that are the patterns of all basic terms of all equations appearing in
  682. the discretized system in all coordinates. The fact that the pattern
  683. terms of the basic terms of partial equations occur repeatedly in
  684. individual systems has made it possible to create a library of the
  685. discretizations of the basic types of pattern terms using the
  686. integro-interpolation method. This library is a component part of the
  687. IIMET module (in its end) and makes work easier for those users who find
  688. the pattern matching mechanism described here too difficult. New
  689. DIFMATCH statements have to be created by those whose equations will
  690. contain a basic term having no pattern in this library, or those who
  691. need another method to perform the discretization. The described
  692. implemented algorithm of discretizing the basic terms is sufficiently
  693. general to enable the use of a nearly arbitrary discretization on
  694. orthogonal grids.
  695. 2.7 Discretization of a system of equations
  696. ---------------------------------------
  697. All statements influencing the run of the discretization that one
  698. want use in this run have to be executed before the discretization is
  699. initiated. The COORDINATES, DEPENDENCE, and DIFMATCH statements have to
  700. occur in all applications. Further, if necessary, the GRID UNIFORM,
  701. GIVEN, ISGRID, GRIDEQ, SAME, and DIFCONST statements can be used, or
  702. some of the CENTREGRID, TWOGRID, EQFU, and FULLEQ switches can be set.
  703. Only then the discretization of a system of partial differential
  704. equations can be started using the IIM statement:
  705. IIM <array>{,<sought function>,<equation>};
  706. <array> ::= "identifier" - the name of the array for storing
  707. the result
  708. <sought function> ::= "identifier" - the name of the function
  709. whose behavior is described by the
  710. equation
  711. <equation> ::= <left side> = <right side>
  712. <left side> ::= "algebraic expression" , the derivatives are
  713. designated by the DIFF operator
  714. <right side> ::= "algebraic expression"
  715. Hence, in the IIM statement the name of the array in which the resulting
  716. difference schemes will be stored, and the pair sought function -
  717. equation, which describes this function, are specified. The meaning of
  718. the relation between the sought function and its equation during the
  719. discretization lies in the fact that the sought function is preferred in
  720. its equation so that the interpolation is not, if possible, used in
  721. 18
  722. discretizing the terms of this equation that contain it. In the
  723. equations, the functions and the coordinates appear as identifiers. The
  724. identifiers that have not been declared as functions by the DEPENDENCE
  725. statement or as coordinates by the COORDINATES statement are considered
  726. constants independent of the coordinates. The partial derivatives are
  727. expressed by the DIFF operator that has the same syntax as the standard
  728. differentiation operator DF. The functions and the equations can also
  729. have the vector or tensor character. If these non-scalar quantities are
  730. applied, the EXPRES module has to be used together with the IIMET
  731. module, and also non-scalar differential operators such as GRAD, DIV,
  732. etc. can be employed.
  733. The sequence performed by the program in the discretization can be
  734. briefly summed up in the following items:
  735. 1. If there are non-scalar functions or equations in a system of
  736. equations, they are automatically converted into scalar quantities
  737. by means of the EXPRES module.
  738. 2. In each equation, the terms containing derivatives are
  739. transferred to the left side, and the other terms to the right side
  740. of the equation.
  741. 3. For each coordinate, with respect to the sequence in which they
  742. occur in the COORDINATES statement, the following is executed:
  743. a) It is determined on which grids all functions and all equations
  744. in the actual coordinate will be discretized, and simultaneously the
  745. limits are kept resulting from the ISGRID, GRIDEQ, and SAME
  746. statements if they were used. Such a distribution of functions and
  747. equations on the grids is selected among all possible variants that
  748. ensures the minimum sum of all numbers of the interpolations of the
  749. basic terms (specified by the DIFMATCH statement) of all equations
  750. if the FULLEQ switch is ON, or of all left sides of the equations if
  751. the FULLEQ switch is OFF (after the loading the FULLEQ switch is
  752. ON).
  753. b) The discretization itself is executed, as specified by the
  754. DIFMATCH statements.
  755. 4. If the array name is A, then if there is only one scalar equation
  756. in the IIM statement, the discretized left side of this equation is
  757. stored in A(0) and the discretized right side in A(1) (after the
  758. transfer mentioned in item 2), if there are more scalar equations
  759. than one in the IIM statement, the discretization of the left side
  760. of the i-th scalar equation is stored in A(i,0) and the
  761. discretization of the right side in A(i,1).
  762. The IIM statement can be used more times during one program run, and
  763. between its calls, the discretizing process can be altered using other
  764. statements of this module.
  765. 19
  766. 2.8 Error messages
  767. --------------
  768. The IIMET module provides error messages in the case of the user's
  769. errors. Similarly as in the REDUCE system, the error reporting is marked
  770. with five stars : "*****" on the line start. Some error messages are
  771. identical with those of the REDUCE system. Here are given some other
  772. error messages that require a more detailed explanation:
  773. ***** Matching of X term not found
  774. - the discretization of the pattern term that is the pattern of
  775. the basic term printed on the place X has not been
  776. defined (using the DIFMATCH statement)
  777. ***** Variable of type F not defined on grids in DIFMATCH
  778. - in the definition of the discretizing of the pattern term
  779. the given functions were not used in the grid
  780. specification and are needed now
  781. ***** X Free vars not yet implemented
  782. - in the grid specification in the DIFMATCH statement
  783. more than 3 pattern functions were used
  784. ***** All grids not given for term X
  785. - in the definition of the discretization of the pattern of
  786. the basic term printed on the place X not all
  787. necessary combinations of the grid specification
  788. of the pattern functions were presented
  789. 20
  790. 3 A P P R O X
  791. ===========
  792. A Module for Determining the Precision Order
  793. of the Difference Scheme
  794. This module makes it possible to determine the differential
  795. equation that is solved by the given difference scheme, and to determine
  796. the order of accuracy of the solution of this scheme in the grid steps
  797. in individual coordinates. The discrete function values are expanded
  798. into the Taylor series in the specified point.
  799. 3.1 Specification of the coordinates and the indices
  800. corresponding to them
  801. ------------------------------------------------
  802. The COORDINATES statement, described in the IIMET module manual,
  803. specifying the coordinates and the indices corresponding to them is the
  804. same for this program module as well. It has the same meaning and
  805. syntax. The present module version assumes a uniform grid in all
  806. coordinates. The grid step in the input difference schemes has to be
  807. designated by an identifier consisting of the character H and the name
  808. of the coordinate, e.g. the step of the coordinate X is HX.
  809. 3.2 Specification of the Taylor expansion
  810. -------------------------------------
  811. In the determining of the approximation order, all discrete values
  812. of the functions are expanded into the Taylor series in all coordinates.
  813. In order to determine the Taylor expansion, the program needs to know
  814. the point in which it performs this expansion, and the number of terms
  815. in the Taylor series in individual coordinates. The center of the Taylor
  816. expansion is specified by the CENTER statement and the number of terms
  817. in the Taylor series in individual coordinates by the MAXORDER
  818. statement:
  819. 21
  820. CENTER <center>{,<center>};
  821. <center> ::= <coordinate> = <increment>
  822. <increment> ::= "rational number"
  823. MAXORDER <order>{,<order>};
  824. <order> ::= <coordinate> = <number of terms>
  825. <number of terms> ::= "natural number"
  826. The increment in the CENTER statement determines that the center of the
  827. Taylor expansion in the given coordinate will be in the point specified
  828. by the index I + <increment>, where I is the index corresponding to this
  829. coordinate, defined using the COORDINATES statement, e.g. the following
  830. example
  831. COORDINATE T,X INTO N,J;
  832. CENTER T = 1/2, X = 1;
  833. MAXORDER T = 2, X = 3;
  834. specifies that the center of the Taylor expansion will be in the point
  835. (t(n+1/2),x(j+1)) and that until the second derivatives with respect to
  836. t (second powers of ht) and until the third derivatives with respect to
  837. x (third powers of hx) the expansion will be performed. The CENTER and
  838. MAXORDER statements can be placed only after the COORDINATES statement.
  839. If the center of the Taylor expansion is not defined in some coordinate,
  840. it is supposed to be in the point given by the index of this coordinate
  841. (i.e. zero increment). If the number of the terms of the Taylor
  842. expansion is not defined in some coordinate, the expansion is performed
  843. until the third derivatives with respect to this coordinate.
  844. 3.3 Function declaration
  845. --------------------
  846. All functions whose discrete values are to be expanded into the
  847. Taylor series must be declared using the FUNCTIONS statement:
  848. FUNCTIONS <name of function>{,<name of function>};
  849. <name of function> ::= "identifier"
  850. In the specification of the difference scheme, the functions are used as
  851. operators with one or more arguments, designating the discrete values of
  852. the functions. Each argument is the sum of the coordinate index (from
  853. the COORDINATES statement) and a rational number. If some index is
  854. omitted in the arguments of a function, this functional value is
  855. supposed to lie in the point in which the Taylor expansion is performed,
  856. as specified by the CENTER statement. In other words, if the COORDINATES
  857. and CENTER statements, shown in the example in the previous section, are
  858. valid, then it holds that U(N+1) = U(N+1,J+1) and U(J-1) = U(N+1/2,J-1).
  859. The FUNCTIONS statement can declare both the sought and the known
  860. functions for the expansion.
  861. 22
  862. 3.4 Order of accuracy determination
  863. -------------------------------
  864. The order of accuracy of the difference scheme is determined by the
  865. APPROX statement:
  866. APPROX (<diff. scheme>);
  867. <diff. scheme> ::= <l. side> = <r. side>
  868. <l. (r.) side> ::= "algebraic expression"
  869. In the difference scheme occur the functions in the form described in
  870. the preceding section, the coordinate indices and the grid steps
  871. described in section 3.1, and the other symbolic parameters of the
  872. difference scheme. The APPROX statement expands all discrete values of
  873. the functions declared in the FUNCTIONS statement into the Taylor series
  874. in all coordinates (the point in which the Taylor expansion is performed
  875. is specified by the CENTER statement, and the number of the expansion
  876. terms by the MAXORDER statement), substitutes the expansions into the
  877. difference scheme, which gives a modified differential equation. The
  878. modified differential equation, containing the grid steps too, is an
  879. equation that is really solved by the difference scheme (into the given
  880. orders in the grid steps).
  881. The partial differential equation, whose solution is approximated
  882. by the difference scheme, is determined by replacing the grid steps by
  883. zeros and is displayed after the following message:
  884. "Difference scheme approximates differential equation"
  885. Then the following message is displayed:
  886. "with orders of approximation:"
  887. and the lowest powers (except for zero) of the grid steps in all
  888. coordinates, occurring in the modified differential equation are
  889. written. If the PRAPPROX switch is ON, then the rest of the modified
  890. differential equation is printed. If this rest is added to the left hand
  891. side of the approximated differential equation, one obtain modified
  892. equation. By default the PRAPPROX switch is OFF. If the grid steps are
  893. found in some denominator in the modified equation, i.e. with a negative
  894. exponent, the following message is written, preceding the approximated
  895. differential equation:
  896. "Reformulate difference scheme, grid steps remain in denominator"
  897. and the approximated differential equation is not correctly determined
  898. (one of its sides is zero). Generally, this message means that there is
  899. a term in the difference scheme that is not a difference replacement of
  900. the derivative, i.e. the ratio of the differences of the discrete
  901. function values and the discrete values of the coordinates (the steps of
  902. the difference grid). The user, however, must realize that in some cases
  903. such a term occurs purposefully in the difference scheme (e.g. on the
  904. grid boundary to keep the scheme conservative).
  905. 23
  906. 4 C H A R P O L
  907. =============
  908. A Module for Calculating the Amplification Matrix
  909. and the Characteristic Polynomial of the
  910. Difference Scheme
  911. This program module is used for the first step of the stability
  912. analysis of the difference scheme using the Fourier method. It
  913. substitutes the Fourier components into the difference scheme,
  914. calculates the amplification matrix of the scheme for transition from
  915. one time layer to another, and computes the characteristic polynomial of
  916. this matrix.
  917. 4.1 Commands common with the IIMET module
  918. -------------------------------------
  919. The COORDINATES and GRID UNIFORM statements, described in the IIMET
  920. module manual, are applied in this module as well, having the same
  921. meaning and syntax. The time coordinate is assumed to be designated by
  922. the identifier T. The present module version requires all coordinates to
  923. have uniform grids, i.e. to be declared in the GRID UNIFORM statement.
  924. The grid step in the input difference schemes has to be designated by
  925. the identifier consisting of the character H and the name of the
  926. coordinate, e.g. the step of the time coordinate T is HT.
  927. 4.2 Function declaration
  928. --------------------
  929. The UNFUNC statement declares the names of the sought functions
  930. used in the difference scheme:
  931. UNFUNC <function>{,<function>}
  932. <function> ::= "identifier" - the name of the sought function
  933. The functions are used in the difference schemes as operators with one
  934. or more arguments for designating the discrete function values. Each
  935. 24
  936. argument is the sum of the index (from the COORDINATES statement) and a
  937. rational number. If some index is omitted in the function arguments,
  938. this function value is supposed to lie in the point specified only by
  939. this index, which means that, with the indices N and J and the function
  940. U, it holds that U(N+1) = U(N+1,J) and U(J-1) = U(N,J-1). As two-step
  941. (in time) difference schemes may be used only, the time index may occur
  942. either completely alone in the arguments, or in the sum with a one.
  943. 4.3 Amplification matrix
  944. --------------------
  945. The AMPMAT matrix operator computes the amplification matrix of a
  946. two-step difference scheme. Its argument is an one column matrix of the
  947. dimension (1,k), where k is the number of the equations of the
  948. difference scheme, that contains the difference equations of this scheme
  949. as algebraic expressions equal to the difference of the right and left
  950. sides of the difference equations. The value of the AMPMAT matrix
  951. operator is the square amplification matrix of the dimension (k,k).
  952. During the computation of the amplification matrix, two new identifiers
  953. are created for each spatial coordinate. The identifier made up of the
  954. character K and the name of the coordinate represents the wave number in
  955. this coordinate, and the identifier made up of the character A and the
  956. name of the coordinate represents the product of this wave number and
  957. the grid step in this coordinate divided by the least common multiple of
  958. all denominators occurring in the scheme in the function argument
  959. containing the index of this coordinate. On the output an equation is
  960. displayed defining the latter identifier. For example, if in the case of
  961. function U and index J in the coordinate X the expression U(J+1/2) has
  962. been used in the scheme (and, simultaneously, no denominator higher than
  963. 2 has occurred in the arguments with J), the following equation is
  964. displayed: AX: = (KX*HX)/2. The definition of these quantities As allows
  965. to express every sum occurring in the argument of the exponentials as
  966. the sum of these quantities multiplied by integers, so that after a
  967. transformation, the amplification matrix will contain only sin(As) and
  968. cos(As) (for all spatial coordinates s). The AMPMAT operator performs
  969. these transformations automatically. If the PRFOURMAT switch is ON
  970. (after the loading it is ON), the matrices H0 and H1 (the amplification
  971. matrix is equal to -H1**(-1)*H0) are displayed during the evaluation of
  972. the AMPMAT operator. These matrices can be used for finding a suitable
  973. substitution for the goniometric functions in the next run for a greater
  974. simplification.
  975. The TCON matrix operator transforms the square matrix into a
  976. Hermit-conjugate matrix, i.e. a transposed and complex conjugate one.
  977. Its argument is the square matrix and its value is Hermit-conjugate
  978. matrix of the argument. The Hermit-conjugate matrix is used for testing
  979. the normality and unitarity of the amplification matrix in the
  980. determining of the sufficient stability condition.
  981. 25
  982. 4.4 Characteristic polynomial
  983. -------------------------
  984. The CHARPOL operator calculates the characteristic polynomial of
  985. the given square matrix. The variable of the characteristic polynomial
  986. is designated by the LAM identifier. The operator has one argument, the
  987. square matrix, and its value is its characteristic polynomial in LAM.
  988. 4.5 Automatic denotation
  989. --------------------
  990. Several statements and procedures are designed for automatic
  991. denotation of some parts of algebraic expressions by identifiers. This
  992. denotation is namely useful when we obtain very large expressions, which
  993. cannot fit into the available memory. We can denote subparts of an
  994. expression from the previous step of calculation by identifiers, replace
  995. these subparts by these identifiers and continue the analytic
  996. calculation only with these identifiers. Every time we use this
  997. technique we have to explicitly survive in processed expressions those
  998. algebraic quantities which will be necessary in the following steps of
  999. calculation. The process of denotation and replacement is performed
  1000. automatically and the algebraic values which are denoted by these new
  1001. identifiers can be written out at any time. We describe how this
  1002. automatic denotation can be used.
  1003. The statement DENOTID defines the beginning letters of newly
  1004. created identifiers. Its syntax is
  1005. DENOTID <id>;
  1006. <id> ::= "identifier"
  1007. After this statement the new identifiers created by the operators
  1008. DENOTEPOL and DENOTEMAT will begin with the letters of the identifier
  1009. <id> used in this statement. Without using any DENOTID statement all new
  1010. identifiers will begin with one letter A. We suggest to use this
  1011. statement every time before using operators DENOTEPOL or DENOTEMAT with
  1012. some new identifier and to choose identifiers used in this statement in
  1013. such a way that the newly created identifiers are not equal to any
  1014. identifiers used in the expressions you are working with.
  1015. The operator DENOTEPOL has one argument, a polynomial in LAM, and
  1016. denotes the real and imaginary part of its coefficients by new
  1017. identifiers. The real part of the j-th LAM power coefficient is denoted
  1018. by the identifier <id>R0j and the imaginary part by <id>I0j, where <id>
  1019. is the identifier used in the last DENOTID statement. The denotation is
  1020. done only for non-numeric coefficients. The value of this operator is
  1021. the polynomial in LAM with coefficients constructed from the new
  1022. identifiers. The algebraic expressions which are denoted by these
  1023. identifiers are stored as LISP data structure standard quotient in the
  1024. LISP variable DENOTATION!* (assoc. list).
  1025. The operator DENOTEMAT has one argument, a matrix, and denotes the
  1026. real and imaginary parts of its elements. The real part of the (j,k)
  1027. matrix element is denoted by the identifier <id>Rjk and the imaginary
  1028. 26
  1029. part by <id>Ijk. The returned value of the operator is the original
  1030. matrix with non-numeric elements replaced by <id>Rjk + I*<id>Ijk. Other
  1031. matters are the same as for the DENOTEPOL operator.
  1032. The statement PRDENOT has the syntax
  1033. PRDENOT;
  1034. and writes from the variable DENOTATION!* the definitions of all new
  1035. identifiers introduced by the DENOTEPOL and DENOTEMAT operators since
  1036. the last call of CLEARDENOT statement (or program start) in the format
  1037. defined by the present setting of output control declarations and
  1038. switches. The definitions are written in the same order as they have
  1039. been entered, so that the definitions of the first DENOTEPOL or
  1040. DENOTEMAT operators are written first. This order guarantees that this
  1041. statement can be utilized directly to generate a semantically correct
  1042. numerical program (the identifiers from the first denotation can appear
  1043. in the second one, etc.).
  1044. The statement CLEARDENOT with the syntax
  1045. CLEARDENOT;
  1046. clears the variable DENOTATION!*, so that all denotations saved earlier
  1047. by the DENOTEPOL and DENOTEMAT operators in this variable are lost. The
  1048. PRDENOT statement succeeding this statement writes nothing.
  1049. 27
  1050. 5 H U R W P
  1051. =========
  1052. A Module for Polynomial Roots Locating
  1053. This module is used for verifying the stability of a polynomial,
  1054. i.e. for verifying if all roots of a polynomial lie in a unit circle
  1055. with its center in the origin. By investigating the characteristic
  1056. polynomial of the difference scheme, the user can determine the
  1057. conditions of the stability of this scheme.
  1058. 5.1 Conformal mapping
  1059. -----------------
  1060. The HURW operator transforms a polynomial using the conformal
  1061. mapping LAM=(z+1)/(z-1). Its argument is a polynomial in LAM and its
  1062. value is a transformed polynomial in LAM (LAM=z). If P is a polynomial
  1063. in LAM, then it holds: all roots LAM1i of the polynomial P are in their
  1064. absolute values smaller than one, i.e. |LAM1i|<1, iff the real parts of
  1065. all roots LAM2i of the HURW(P) polynomial are negative, i.e. Re
  1066. (LAM2i)<0.
  1067. The elimination of the unit polynomial roots (LAM=1), which has to
  1068. occur before the conformal transformation is performed, is made by the
  1069. TROOT1 operator. The argument of this operator is a polynomial in LAM
  1070. and its value is a polynomial in LAM not having its root equal to one
  1071. any more. Mostly, the investigated polynomial has some more parameters.
  1072. For some special values of those parameters, the polynomial may have a
  1073. unit root. During the evaluation of the TROOT1 operator, the condition
  1074. concerning the polynomial parameters is displayed, and if it is
  1075. fulfilled, the resulting polynomial has a unit root.
  1076. 5.2 Investigation of polynomial roots
  1077. ---------------------------------
  1078. The HURWITZP operator checks whether a polynomial is the Hurwitz
  1079. polynomial, i.e. whether all its roots have negative real parts. The
  1080. argument of the HURWITZP operator is a polynomial in LAM with real or
  1081. 28
  1082. complex coefficients, and its value is YES if the argument is the
  1083. Hurwitz polynomial. It is NO if the argument is not the Hurwitz
  1084. polynomial, and COND if it is the Hurwitz polynomial when the conditions
  1085. displayed by the HURWITZP operator during its analysis are fulfilled.
  1086. These conditions have the form of inequalities and contain algebraic
  1087. expressions made up of the polynomial coefficients. The conditions have
  1088. to be valid either simultaneously, or they are designated and a
  1089. proposition is created from them by the AND and OR logic operators that
  1090. has to be fulfilled (it is the condition concerning the parameters
  1091. occurring in the polynomial coefficient) by a polynomial to be the
  1092. Hurwitz one. This proposition is the sufficient condition, the necessary
  1093. condition is the fulfillment of all the inequalities displayed.
  1094. If the HURWITZP operator is called interactively, the user is
  1095. directly asked if the inequalities are or are not valid. The user
  1096. responds "Y" if the displayed inequality is valid, "N" if it is not, and
  1097. "?" if he does not know whether the inequality is true or not.
  1098. 29
  1099. 6 L I N B A N D
  1100. =============
  1101. A Module for Generating the Numeric Program for
  1102. Solving a System of Linear Algebraic Equations
  1103. with Band Matrix
  1104. The LINBAND module generates the numeric program in the FORTRAN
  1105. language, which solves a system of linear algebraic equations with band
  1106. matrix using the routine from the LINPACK, NAG ,IMSL or ESSL program
  1107. library. As input data only the system of equations is given to the
  1108. program. Automatically, the statements of the FORTRAN language are
  1109. generated that fill the band matrix of the system in the corresponding
  1110. memory mode of chosen library, call the solving routine, and assign the
  1111. chosen variables to the solution of the system. The module can be used
  1112. for solving linear difference schemes often having the band matrix.
  1113. 6.1 Program generation
  1114. ------------------
  1115. The program in the FORTRAN language is generated by the
  1116. GENLINBANDSOL statement (the braces in this syntax definition occur
  1117. directly in the program and do not have the usual meaning of the
  1118. possibility of repetition, they designate REDUCE lists):
  1119. GENLINBANDSOL (<n-lower>,<n-upper>,{<system>});
  1120. <n-lower> ::= "natural number"
  1121. <n-upper> ::= "natural number"
  1122. <system> ::= <part of system> | <part of system>,<system>
  1123. <part of system>::= {<variable>,<equation>} | <loop>
  1124. <variable> ::= "kernel"
  1125. <equation> ::= <left side> = <right side>
  1126. <left side> ::= "algebraic expression"
  1127. <right side> ::= "algebraic expression"
  1128. <loop> ::= {DO,{<parameter>,<from>,<to>,<step>},<c-system>}
  1129. <parameter> ::= "identifier"
  1130. <from> ::= <i-expression>
  1131. 30
  1132. <to> ::= <i-expression>
  1133. <step> ::= <i-expression>
  1134. <i-expression> ::= "algebraic expression" with natural value
  1135. (evaluated in FORTRAN)
  1136. <c-system> ::= <part of c-system> | <part of c-system>,<c-
  1137. system>
  1138. <part of c-system> ::= {<variable>,<equation>}
  1139. The first and second argument of the GENLINBANDSOL statement specifies
  1140. the number of the lower (below the main diagonal) and the upper
  1141. diagonals of the band matrix of the system. The system of linear
  1142. algebraic equations is specified by means of lists expressed by braces
  1143. { } in the REDUCE system. The variables of the equation system can be
  1144. identifiers, but most probably they are operators with an argument or
  1145. with arguments that are analogous to array in FORTRAN. The left side of
  1146. each equation has to be a linear combination of the system variables,
  1147. the right side, on the contrary, is not allowed to contain any variables
  1148. of the system. The sequence of the band matrix lines is given by the
  1149. sequence of the equations, and the sequence of the columns by the
  1150. sequence of the variables in the list describing the equation system.
  1151. The meaning of the loop in the system list is similar to that of
  1152. the DO loop of the FORTRAN language. The individual variables and
  1153. equations described by the loop are obtained as follows:
  1154. 1. <parameter> = <from>.
  1155. 2. The <parameter> value is substituted into the variables and
  1156. equations of the <c-system> loop, by which further variables and
  1157. equations of the system are obtained.
  1158. 3. <parameter> is increased by <step>.
  1159. 4. If <parameter> is less or equal <to>, then go to step 2, else all
  1160. variables and equations described by the loop have already been
  1161. obtained.
  1162. The variables and equations of the system included in the loop usually
  1163. contain the loop parameter, which mostly occur in the operator arguments
  1164. in the REDUCE language, or in the array indices in the FORTRAN language.
  1165. If NL = <n-lower>, NU = <n-upper>, and for some loop F = <from>, T
  1166. = <to>, S = <step> and N is the number of the equations in the loop
  1167. <c-system>, it has to be true that
  1168. UP(NL/N) + UP(NU/N) < DOWN((T-F)/S)
  1169. where UP represents the rounding-off to a higher natural number, and
  1170. DOWN the rounding-off to a lower natural number. With regard to the fact
  1171. that, for example, the last variable before the loop is not required to
  1172. equal the last variable from the loop system, into which the loop
  1173. parameter equal to F-S is substituted, when the band matrix is being
  1174. constructed, from the FORTRAN loop that corresponds to the loop from the
  1175. specification of the equation system, at least the first NL
  1176. variables-equations have to be moved to precede the FORTRAN loop, and at
  1177. 31
  1178. least the last NU variables-equations have to be moved to follow this
  1179. loop in order that the correspondence of the system variables in this
  1180. loop with the system variables before and after this loop will be
  1181. secured. And this move requires the above mentioned condition to be
  1182. fulfilled. As, in most cases, NL/N and NU/N are small with respect to
  1183. (T-F)/S, this condition does not represent any considerable constrain.
  1184. The loop parameters <from>, <to>, and <step> can be natural numbers
  1185. or expressions that must have natural values in the run of the FORTRAN
  1186. program.
  1187. 6.2 Choosing the numerical library
  1188. ------------------------------
  1189. The user can choose the routines of which numerical library will be
  1190. used in the generated FORTRAN code. The supported numerical libraries
  1191. are: LINPACK, NAG, IMSL and ESSL (IBM Engineering and Scientific
  1192. Subroutine Library) . The routines DGBFA, DGBSL (band solver) and DGTSL
  1193. (tridiagonal solver) are used from the LINPACK library, the routines
  1194. F01LBF, F04LDF (band solver) and F01LEF, F04LEF (tridiagonal solver) are
  1195. used from the NAG library, the routine LEQT1B is used from the IMSL
  1196. library and the routines DGBF, DGBS (band solver) and DGTF, DGTS
  1197. (tridiagonal solver) are used from the ESSL library. By default the
  1198. LINPACK library routines are used. The using of other libraries is
  1199. controlled by the switches NAG,IMSL and ESSL. All these switches are by
  1200. default OFF. If the switch IMSL is ON then the IMSL library routine is
  1201. used. If the switch IMSL is OFF and the switch NAG is ON then NAG
  1202. library routines are used. If the switches IMSL and NAG are OFF and the
  1203. switch ESSL is ON then the ESSL library is used. During generating the
  1204. code using LINPACK, NAG or ESSL libraries the special routines are use
  1205. for systems with tridiagonal matrices, because tridiagonal solvers are
  1206. faster than the band matrix solvers.
  1207. 6.3 Completion of the generated code
  1208. --------------------------------
  1209. The GENLINBANDSOL statement generates a block of FORTRAN code ( a
  1210. block of statements of the FORTRAN language) that performs the solution
  1211. of the given system of linear algebraic equations. In order to be used,
  1212. this block of code has to be completed with some declarations and
  1213. statements, thus getting a certain envelope that enables it to be
  1214. integrated into the main program.
  1215. In order to be able to work, the generated block of code has to be
  1216. preceded by:
  1217. 1. The declaration of arrays as described by the comments generated
  1218. into the FORTRAN code (near the calling of library routines)
  1219. 2. The assigning the values to the integer variables describing the
  1220. real dimensions of used arrays (again as described in generated
  1221. FORTRAN comments)
  1222. 32
  1223. 3. The filling of the variables that can occur in the loop parameters.
  1224. 4. The filling or declaration of all variables and arrays occurring in
  1225. the system equations, except for the variables of the system of linear
  1226. equations.
  1227. 5. The definition of subroutine ERROUT the call to which is generated
  1228. after some routines found that the matrix is algorithmically singular
  1229. The mentioned envelope for the generated block can be created
  1230. manually, or directly using the GENTRAN program package for generating
  1231. numeric programs. The LINBAND module itself uses the GENTRAN package,
  1232. and the GENLINBANDSOL statement can be applied directly in the input
  1233. files of the GENTRAN package (template processing). The GENTRAN package
  1234. has to be loaded prior to loading of the LINBAND module.
  1235. The generated block of FORTRAN code has to be linked with the
  1236. routines from chosen numerical library.
  1237. References
  1238. ----------
  1239. [1] R. Liska: Numerical Code Generation for Finite Difference Schemes
  1240. Solving. In IMACS World Congress on Computation and Applied
  1241. Mathematics. Dublin, July 22-26, 1991, Dublin,(In press).
  1242. 33