README.first 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. ******************************************************************************
  2. PRELIMINARY USER'S MANUAL FOR SWIFT
  3. ******************************************************************************
  4. Authors : Martin Duncan and Hal Levison
  5. Date: June 15/93
  6. Last Revisions: 11/29/00 HFL
  7. INTRODUCTION
  8. The SWIFT subroutine package provided here is designed to
  9. integrate a set of mutually gravitationally interacting bodies
  10. together with a group of test particles which feel the gravitational
  11. influence of the massive bodies but do not affect each other or the
  12. massive bodies. Four integration techniques are included:
  13. 1) Wisdom-Holmam Mapping (WHM). This is the n-body mapping
  14. method of Wisdom & Holman~(1991; AJ, 102, 1528).
  15. 2) Regularized Mixed Variable Symplectic (RMVS) method. This
  16. is an extension of the WHM that handles close approachs
  17. between test particles and planets. See Levison & Duncan
  18. (1994; Icarus, 108, 18).
  19. 3) A fourth order T+U Symplectic (TU4) method. This is the
  20. T+U method of Candy & Rozmus (1991; J. Comput. Phy., 92, 230).
  21. Also see Gladman, Duncan, & Candy(1991; CeMDA, 52, 221.)
  22. 4) A Bulirsch-Stoer method. This is a Bulirsch-Stoer from Press,
  23. Teukolsky, Vetterling, & Flannery (1992. `Numerical Recipes in
  24. FORTRAN').
  25. 5) SyMBA. This is a symplectic N-body that handles close
  26. encounters between massive bodies from Duncan et al
  27. (1998, aj, 116, 2067). SyMBA is run a little
  28. differently from the rest of Swift. See README.symba
  29. for more details.
  30. The package is designed so that the calls to each of these look
  31. identical so that it is trivial to replace one with another.
  32. In order to get to this file you have presumably obtained,
  33. uncompressed and untar-ed the swift.tar.Z file found on the Web at
  34. www.boulder.swri.edu or in the anonymous ftp directory on
  35. gort.boulder.swri.edu. You will now find various files and
  36. subdirectories. Most of the directories contain the subroutines that
  37. make up SWIFT. However, fully functional examples of working drivers
  38. are found in the subdirectory "main". They all have the same i/o
  39. except for minor differences noted below. The subroutines used are
  40. grouped by function in subdirectories with what we hope to be good
  41. internal documentation. There is a Tex file describing the WHM force
  42. calculations in the subdir. "mvs/getacch". The subdir. called
  43. "example" contains a working example for integrating the Sun plus the
  44. four giant planets as well as Pluto (the latter treated as a test
  45. particle) using the integrator "swift_whm". Descriptions of the
  46. drivers and the input and output files follow.
  47. COMPILING SWIFT
  48. There are two files that must be edited in order to complile
  49. SWIFT. In the top SWIFT directory, you will find a file called
  50. "@make". Edit this file. You will have to change the values of:
  51. SWIFT_DIR which is the top directory in which you put SWIFT.
  52. FORTRAN which is the command on your machine to run the Fortran
  53. compliler
  54. FFLAGS which are the flags you use for your Fortran. You MUST
  55. include a flag that will tell Fortran to make an object
  56. file, but does not try to link it. This is a "-c" on
  57. most machines. (In addition for SyMBA users, the
  58. flags must be set so that recursion will work on your
  59. machine.)
  60. PRECOMP is the full path of the C pre-compiler on your machine.
  61. This program is usually called cpp.
  62. CPPFLAGS are the flags for the cpp pre-compiler. See the next section
  63. for a discussion.
  64. Then type "@makeall". This will compile all the subroutines in the
  65. package. Swift will create a library called "libswift.a". This file
  66. must be copied into the "/usr/local/lib" directory on your machine.
  67. You must be root in order to do this. Once this is completed you can
  68. link a program to this package by adding the flag "-L/usr/local/lib -lswift"
  69. to your Fortran statements.
  70. Now you must complile the drivers. Change to the directory main
  71. (enter: " cd main"). You will have to edit "@make" and change the
  72. same variables as you did above. In this case, you do not want the -c
  73. option of the Fortran compiler. Now enter "@make". The executable
  74. files in the directory are now ready for use.
  75. You can now remove swift.tar, if you want.
  76. THE CPP FLAGS
  77. We have made a significant effort making sure that SWIFT is ANSI
  78. standard Fortran 77. Therefore, in principal, the Fortran source code
  79. should compile on any UNIX platform. Unfortunately, there are two
  80. places where this ideal breaks down: in the OPEN function and in
  81. recursive routines. In these cases, we make use of the C
  82. pre-compiler, cpp, which is universally available on UNIX machines (at
  83. least we hope). Cpp translates files ending with .F into Fortran .f
  84. files. In SWIFT, cpp needs two flags that will tell it what kind of
  85. fortran files to create. These are:
  86. 1) OPEN function: In several places, SWIFT needs to open files and
  87. append to the end of them. So, far we have found the there are two
  88. ways in which Fortran compilers do that. The first is with OPEN
  89. specifier "position='append'" and the second with "access='append'".
  90. If your machine is of the first type then use the CPPFLAG of
  91. "-D_OPEN_POSITION". If it is of the second use "-U_OPEN_POSITION".
  92. We have found that most machines are of the second type, however IBM
  93. RS6000's and HP's Fortran 90 are of the first type.
  94. 2) RECURSIVE ROUTINES: (Only SyMBA users need to worry about this!)
  95. Fortran 77 and Fortran 90 compilers handle recursion differently. As
  96. far as our experience goes, F77 allows any subroutine to be recursive,
  97. although you most likely will have to set compiler flags to accomplish
  98. this. F90 compilers require recursive subroutines to declared in the
  99. source code as `recursive subroutine X(....)'. If your compiler
  100. requires this than use the CPPFLAG of "-D_RECUR_SUB". If not use
  101. "-U_RECUR_SUB"
  102. 3) FXDR package: XDR is a platform independent binary format that
  103. Swift can use to write bin.dat files that can move between
  104. systems. If requires FXDR which can be found at:
  105. http://meteora.ucsd.edu/~pierce/fxdr_home_page.html
  106. However, Swift is written so that it can be run without it. If you
  107. have the fxdr library then set the -D_FXDR_AVAIL. If you do not
  108. want to use it then set -U_FXDR_AVAIL. If you try to write an XDR
  109. without the FXDR package Swift will complain and stop.
  110. If you don't know which is correct for you, we have supplied a test.
  111. Change to the directory cpp_test (enter: " cd cpp_test"). Follow the
  112. instructions in the README file.
  113. THE DRIVERS
  114. All of the drivers are designed to take essentially the same
  115. input files and to produce the same type of output. The basic step
  116. for all of them begins with heliocentric positions and velocities and
  117. advances them a timestep dt. Some methods (such as the Bulirsch-Stoer
  118. integrator) have internal substeps or iterations etc. but this is all
  119. hidden from the user. A description of the basic i/o files is given
  120. in the next section. The differences between drivers is given next.
  121. SWIFT_WHM : The basic WHM integrator when particles are to be
  122. removed at the time of close planetary encounters.
  123. Arbitrarily close solar encounters can occur.
  124. (This was called swift_mvs in previously releases of Swift.)
  125. SWIFT_RMVS3: The Regularized Mixed Variable Symplectic (RMVS) integrator.
  126. This handles close approachs between test particles and planets.
  127. SWIFT_BS : A Bulirsch-Stoer integrator with the same I/O as
  128. WHM except that in addition to the 3 input files
  129. the user is prompted for a tolerance EPS (1.e-8 is often
  130. used). The tolerance could be added to the end of
  131. the file mvs.in if redirection is used at input (see I/O below).
  132. The BS routine CAN get through close encounters, although
  133. it is usually about 10 times slower then SWIFT_RMVS.
  134. One can imagine writing a hybrid driver to switch from the
  135. WHM stuff to BS during occasional close encounters.
  136. SWIFT_LYAP: Computes Lyap. exponents for a set of test particles
  137. by integrating a set of shadow particles (one per test
  138. particle) with initial offsets in pos. and vel. read in
  139. from a file called 'shadow.in' with same format as
  140. 'tp.in' (see I/O description below). At time intervals
  141. spaced by dtout, the shadows are renormalized to their
  142. initial phase space distances from the real particles.
  143. An output file called 'lyap.out' has for each
  144. output time the log (base 10) of the Lyap. exponent
  145. gamma for each particle. NOTE: We don't recommend
  146. that you use this without talking to one of us first!
  147. SWIFT_LYAP2: Computes Lyap. exponents for a set of test particles
  148. by integrating the difference equations. Besides the usual
  149. par.in, pl.in, and tp.in, the program asked you how often
  150. to output the phase space distances. It also asks for a
  151. phase space vector representing the initial separation
  152. between a particle and a fictitious particle. Note that
  153. the orbit of the fictitious particle is not integrated,
  154. the difference equations are integrated. An output file called
  155. 'lyap2.out' has for each output time the phase space distance
  156. for each particle. NOTE: WE ARE STILL TESTING THIS, SO BE CAREFULL.
  157. SWIFT_TU4 : A fourth order symplectic integrator based not on the WHM
  158. decomposition of the Hamiltonian but rather on the traditional
  159. Kinetic (T) plus Potential (U) form. Used mostly as a check
  160. on the other routines.
  161. SWIFT_SYMBA5: SyMBA.
  162. INPUT/OUTPUT
  163. The simplest way to use e.g. 'swift_whm' is to use the file called
  164. 'mvs.in' in the 'examples' directory, which has just 3 lines
  165. corresponding to the names of 3 input files : param.in pl.in tp.in.
  166. Thus one types
  167. swift_whm < mvs.in
  168. The input parameters are as follows:
  169. PARAM.IN : This file has all the run-time parameters of the form :
  170. t0, tstop, dt
  171. dtout, dtdump
  172. L1 L2 L3 L4 L5 L6
  173. rmin, rmax, rmaxu, qmin, lclose
  174. binary_outputfile
  175. status_flag_for_open_statements
  176. where
  177. t0 is the initial time
  178. tstop is the time to stop the integration
  179. dt is the timestep
  180. dtout is the time interval between outputs (see below)
  181. dtdump is time interval between dumps of the 3 basic files (see below)
  182. L1-L6 are logicals and are set to T or F
  183. L1: .true.==> Include J2 and J4 for central body. These values
  184. must be included in the pl.in file.
  185. L2: .true.==> Does the various checks for coming too close to Sun
  186. or planet, or too far from Sun. If particles are
  187. removed a file called 'discard.out' will contain a
  188. set of entries for each removed particle that gives
  189. the time, the particle's posn and vel and istat flags
  190. and rstat flags (see a file called README.stat for a
  191. discription of the status flags), as well as all the
  192. planetary posns and vels. at the time of removal.
  193. So you will have a complete discription of the
  194. planetary system at removal time if you need it.
  195. NOTE: IF THIS BIT IS NOT SET YOU SHOULD OMIT THE LINE
  196. IN PARAM.IN THAT CONTAINS RMIN, RMAX ETC. AND HAVE ONLY
  197. THREE LINES IN ALL : THE LAST HAVING THE NAME OF
  198. THE BINARY OUTPUT FILE.
  199. L3: .true.==> Computes Jacobi integral for the tps (only useful
  200. if have only one planet on circ. orbit). Writes to
  201. a file called jacobi.out
  202. L4: .true.==> Computes energy and ang. momentum and writes out
  203. to a file called energy.out. (of course this only
  204. checks the accuracy of the planetary integrations).
  205. L5: .true.==> Write to a binary output file the heliocentric
  206. orbital elements of all bodies and test particles.
  207. The elements are written as REAL*4. The elements are
  208. a,e,i,OMEGA,omega and M, where OMEGA is the long. of
  209. ascending node, omega is arg. of peri. and M is mean
  210. anomaly. ROUTINES TO READ FROM THE BINARY FILE ARE
  211. GIVEN IN FOR EXAMPLE THE ROUTINE "FOLLOW" IN THE
  212. "TOOLS" DIRECTORY. TO USE FOLLOW SIMPLY RESPOND TO
  213. THE PROMPTS (e.g. the last query is for which
  214. particle # to follow - use a positive integer for a
  215. tp or a negative number if you want to follow a
  216. planet (e.g. -3 for the third massive body ie the
  217. second planet).
  218. L6: .true.==> Same as L5 except that Swift write an XDR file.
  219. NOTE: L5 and L6 cannot both be set to .true.
  220. rmin is the heliocentric distance at which a tp is stopped because
  221. it is deemed to be too close to the central body.
  222. SET TO -1. if you want to ignore this check
  223. rmax is the heliocentric distance at which a tp is stopped because
  224. it is deemed to be too far from the central body
  225. SET TO -1. if you want to ignore this check
  226. rmaxu is the heliocentric distance at which a tp is stopped because
  227. it is deemed to be too far from the central body AND it
  228. is also unbound with respect to the central body
  229. SET TO -1. if you want to ignore this check
  230. qmin is the perihelion distance at which a tp is stopped because
  231. it is deemed to be too close to the central body.
  232. SET TO -1. if you want to ignore this check
  233. Note: The orbital elements computed are the osculating
  234. (instantaneous) HELIOCENTRIC values. Because of the
  235. motion of the Sun induced by the planets, these values
  236. are unrepresentative of the barycentric values for
  237. particles which have semi-major axes beyond a few
  238. hundred AU. In particular, values for the pericentric
  239. distance and the inclination will vary considerably. As
  240. a result we STRONGLY RECOMMEND that a value of RMAX of
  241. a few hundred AU be used if a nonzero value of QMIN is
  242. used.
  243. lclose is a logical. If .true. then the code will check for close
  244. approaches between tp and planets. If tp gets within a distance
  245. rpl of the planet then it is stopped. rpl for each planet must
  246. be included in the pl.in if this flag is set. NOTE: we recommend
  247. that rpl be greater than a Hill sphere if you are using WHM.
  248. binary_outputfile is the name of a binary file to store the
  249. orbital elements at time intervals dtout (see below).
  250. status_flag_for_open_statements is the status flag for the open
  251. statements of all the output files but lyap.dat. Must be one
  252. of the following:
  253. new (program dies if the file exists)
  254. append (data is appended to the file)
  255. unknown (data is written over existing data).
  256. NOTES : 1) Every dtout time increments, the code outputs various quantities,
  257. depending on the value of the logical flags L1-L6 (read in from
  258. param.in).
  259. 2) At time increments set by dtdump, the code dumps all of
  260. the information needed to resume the integration at that time
  261. in case of power failures or in case one wishes to resume an
  262. integration from its endpoint. The info. is in 3 files called
  263. dump_pl.dat, dump_tp.dat, and dump_param.dat. The format is
  264. identical to pl.in, tp.in and param.in respectively. Note
  265. that t0 in dump_param.dat records the time of the dump and
  266. that the status_flag_for_open_statements is changed to
  267. `append', so that these files can be used to restart a stopped
  268. integration. Depending on the situation, one may wish to
  269. increase tstop in order to extend an integration. The files
  270. are overwritten with each dump so only the most recent one is
  271. preserved.
  272. NOTE: We strongly suggest that you set dtdump=dtout. This will
  273. make it easier to restart the program if your computer
  274. goes down.
  275. PL.IN : The code requires units in which the grav. constant G is unity.
  276. Any combo of lengths, masses and times that keeps that true is O.K.
  277. For example, the pl.in file given in the examples dir. uses lengths
  278. in AU and time in days (where one year is exactly 365.25 days). This
  279. forces the Solar mass to be about 2.96e-4. In the example, we
  280. give initial conditions from the classic paper of CHO for the
  281. integration of the outer planets. One could instead use units
  282. in which lengths are in AU, and the Solar Mass is unity but
  283. then the orbital period of a test particle at one AU would
  284. be 2*pi. The format is simple : first the # of bodies on the first
  285. line (INCLUDING the Sun) and then 3 lines for each body giving
  286. mass on the first line, heliocentric x,y,z on the next and
  287. heliocentric vx,vy,vz on the third. NOTE: The x,y,z and
  288. vx,vy,vz for the Sun MUST be 0!!
  289. In addition: if L1 = .true. then next to the Sun must be the
  290. values of J_2 * R^2 and J_4 R^4, where R is the radius of the
  291. central body.
  292. If L2=.true. and lclose=.true. than the lines that contain the masses
  293. of the planets must also include the stopping radius.
  294. TP.IN : In the same units as PL.IN, the first line is # of test particles.
  295. The test particles are assumed massless so for each particle there
  296. are 6 lines giving heliocentric x,y,z on first, helioc. vx,vy,vz on
  297. second and then 13 istat integers and 13 rstat integers (See
  298. README.stat for the definitions of the status flags). For most
  299. runs one would begin with ststud flags equal to zero
  300. unless it is a resumption of an earlier run. The code may
  301. alter the arrays as it runs.
  302. ********NOTE TO USERS WHO MAY MODIFY THE CODE : ***************************
  303. For reasons of efficiency and simplicity, in some of the subroutines
  304. which use the array istat, istat is dimensioned and used as if it were
  305. a vector rather than a 2D array. These subroutines need only know
  306. whether or not istat(i,1) is zero and we don't pass in or out the
  307. other elements of the matrix. This is standard practice in Fortran
  308. and we note clearly in the description in each subroutine if this
  309. is the case.
  310. **************************************************************************