├── .gitignore ├── LICENSE ├── README.md ├── c_version ├── .gitignore ├── KOI142.in ├── KOI142.in.astro ├── KOI142.in.cartesian ├── KOI_142_output.pro ├── Makefile ├── README ├── RV_KOI_142.eps ├── RV_data_KOI142 ├── RV_file ├── RV_file2 ├── RV_out ├── RV_out.expected ├── RV_out2 ├── TTVFast.c ├── TTVS_KOI_142.eps ├── Times ├── Times.expected ├── compare_output.c ├── kepcart2.c ├── machine-epsilon.c ├── myintegrator.h ├── run_TTVFast.c ├── setup_file ├── setup_file_astro_cartesian ├── setup_file_astro_elements ├── transit.h ├── ttv-map-jacobi.c └── ttv_errors.h ├── fortran_version ├── README ├── call_ttv_fast.for ├── make_ttv_fast ├── nbody_include.for ├── rvdata.txt ├── ttv_fast.for ├── ttv_fast.in └── ttv_fast_documentation.pdf ├── jl_version ├── .gitignore ├── TTVFast.jl ├── TTVFast_demo.jl ├── compile_libttvfast.cmd ├── demo_KOI142.jl └── demo_julia.jl └── julia_version ├── KOI142.in ├── KOI142.in.astro ├── KOI142.in.cartesian ├── KOI_142_output.pro ├── README ├── README.md ├── RV_KOI_142.eps ├── RV_data_KOI142 ├── RV_file ├── RV_file2 ├── RV_out ├── RV_out2 ├── TTVFast.c ├── TTVFast.jl ├── TTVS_KOI_142.eps ├── Times ├── kepcart2.jl ├── machine-epsilon.c ├── myintegrator.h ├── myintegrator.jl ├── run_TTVFast ├── run_TTVFast.c ├── setup_file ├── setup_file_astro_cartesian ├── setup_file_astro_elements ├── transit.h ├── transit.jl └── ttv-map-jacobi.c /.gitignore: -------------------------------------------------------------------------------- 1 | jl_version/libttvfast.so 2 | c_version/RV_out 3 | c_version/Times 4 | c_version/run_TTVFast 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | TTVFast 2 | ======= 3 | 4 | *This is a python compatability fork of TTVFast for use with 5 | [ttvfast-python](https://github.com/mindriot101/ttvfast-python)* 6 | 7 | TTVFast efficiently calculates transit times for n-planet systems and the corresponding radial velocities. 8 | 9 | 10 | Available Versions 11 | ======= 12 | 13 | The C version of the code is in the directory c_version, the Fortran version is in fortran_version. Both versions have specific README files. 14 | 15 | There is a Julia interface in the directory jl_version. First, you must create libttvfast.so (e.g., "cd jl_version; source compile_libttvfast.cmd" on Linux). Once you've done this, start julia and type 16 | 'include("demo_julia.jl")' to see an example of calling ttvfast and accessing the outputs from Julia. There's another example of using the same input file foramts as TTVFast. 17 | 18 | Citations 19 | ======= 20 | If you use this code, please cite Deck, Agol, Holman, & Nesvorny (2014), ApJ, 787, 132, arXiv:1403.1895. 21 | 22 | 23 | 24 | Please check back for updates to ensure that you are using the latest version. 25 | 26 | -Katherine Deck, Eric Agol, Matt Holman, & David Nesvorny 27 | -------------------------------------------------------------------------------- /c_version/.gitignore: -------------------------------------------------------------------------------- 1 | compare_output 2 | -------------------------------------------------------------------------------- /c_version/KOI142.in: -------------------------------------------------------------------------------- 1 | 0.000295994511 2 | 0.95573417954 3 | 0.00002878248 4 | 1.0917340278625494e+01 5.6159310042858110e-02 9.0921164935951211e+01 -1.1729336712101943e-18 1.8094838714599581e+02 -8.7093652691581923e+01 5 | 0.00061895914 6 | 2.2266898036209028e+01 5.6691301931178648e-02 8.7598285693573246e+01 4.6220554014026838e-01 1.6437004273382669e+00 -1.9584857031843157e+01 7 | 8 | -------------------------------------------------------------------------------- /c_version/KOI142.in.astro: -------------------------------------------------------------------------------- 1 | 0.000295994511 2 | 0.95573417954 3 | 0.00002878248 4 | 1.0917340278625497e+01 5.6159310042858110e-02 9.0921164935951211e+01 0.0000000000000000e+00 1.8094838714599561e+02 -8.7093652691581710e+01 5 | 0.00061895914 6 | 2.2265565872197687e+01 5.6666709482767016e-02 8.7598247127199073e+01 4.6214935847759059e-01 1.6715866399456485e+00 -1.9609909057518475e+01 7 | 8 | -------------------------------------------------------------------------------- /c_version/KOI142.in.cartesian: -------------------------------------------------------------------------------- 1 | 0.000295994511 2 | 0.95573417954 3 | 0.00002878248 4 | 4.2751105789149389e-03 -1.5242519870492784e-03 9.4799180429814917e-02 -5.4584946596113952e-02 9.7656270156749417e-06 -6.0736246062660626e-04 5 | 0.00061895914 6 | 1.3559014131822117e-01 -1.0049182503274595e-03 -5.0033242877868256e-02 1.4859847408958543e-02 1.9180380744132197e-03 4.2870425084428648e-02 7 | 8 | 9 | -------------------------------------------------------------------------------- /c_version/KOI_142_output.pro: -------------------------------------------------------------------------------- 1 | pro KOI_142_output 2 | set_plot,'ps' 3 | device,filen='RV_KOI_142.eps',/encapsulated,/inches,xsize=10.0,ysize = 8.0,$ 4 | /color,bits_per_pixel=8,/isolatin,/helvetica 5 | !p.font=0 6 | !p.thick=6 & !x.thick=5 & !y.thick=5 & !p.charthick=5 & syms=2.0 7 | !p.charsize=2.0 8 | 9 | readcol,"Times",planet,epoch,time,rsky,vsky,format ='l,l,d,d,d' 10 | readcol,"RV_out",t_rv_calc,rv_calc,format='d,d' 11 | readcol,"RV_out2",t_rv_calc_all,rv_calc_all,format='d,d' 12 | readcol,"RV_data_KOI142",t_rv_data,rv_data,uncertainty,format='d,d,d' 13 | ; RV data from Barros et al. 2013 14 | offset = -20.4547 15 | ; change units from AU/day to km/s: 16 | AU = 149597871.0 ;in km 17 | day = 3600.0*24.0; in seconds 18 | rv_calc = rv_calc*AU/day+offset 19 | rv_calc_all = rv_calc_all*AU/day+offset 20 | 21 | plotsym,0,/fill 22 | 23 | plot,t_rv_data,rv_data,psym=2,ytitle = 'RV (km/s)',xtitle = 'BJD_UTC-2456000',xrange=[460,620],xstyle=1,yrange=[-20.54,-20.35] 24 | oploterror,t_rv_data,rv_data,uncertainty,psym=2 25 | oplot,t_rv_calc_all,rv_calc_all,psym=-3,color=fsc_color("red") 26 | oplot,t_rv_calc,rv_calc,psym=8,color=fsc_color("red") 27 | device,/close 28 | 29 | k = where(epoch lt 114 AND planet eq 0) ;roughly the number observed in Nesvorny et al. 2013 paper), only look at KOI142b 30 | BFL = linfit(epoch[k],time[k]) 31 | TTV = time[k]-epoch[k]*BFL[1]-BFL[0] 32 | 33 | device,filen='TTVS_KOI_142.eps',/encapsulated,/inches,xsize=10.0,ysize = 8.0,$ 34 | /color,bits_per_pixel=8,/isolatin,/helvetica 35 | 36 | 37 | plot,epoch[k],TTV*24.0*60.0,psym=-8,xtitle = 'Transit Epoch',ytitle = 'TTV (min)',position = [0.2,0.2,0.9,0.9],charsize = 2 38 | device,/close 39 | 40 | 41 | set_plot,'x' 42 | !p.thick=1 & !x.thick=1 & !y.thick=1 & !p.charthick=1 43 | !p.charsize=2 44 | 45 | stop 46 | end 47 | -------------------------------------------------------------------------------- /c_version/Makefile: -------------------------------------------------------------------------------- 1 | RUN := run_TTVFast 2 | COMPARE := compare_output 3 | SOURCES := $(wildcard *.c) 4 | HEADERS := $(wildcard *.h) 5 | 6 | all: $(RUN) 7 | 8 | $(RUN): $(SOURCES) $(HEADERS) 9 | gcc -o $@ run_TTVFast.c TTVFast.c -lm -O3 -Wall -Wextra 10 | 11 | test: $(COMPARE) $(RUN) 12 | ./run_TTVFast setup_file Times RV_file RV_out 13 | ./$(COMPARE) 14 | 15 | $(COMPARE): compare_output.c 16 | gcc -o $@ $< -lm -Wall -Wextra 17 | 18 | 19 | clean: 20 | @-rm $(RUN) 21 | 22 | .PHONY: test 23 | -------------------------------------------------------------------------------- /c_version/README: -------------------------------------------------------------------------------- 1 | /*If you make use of this code, please cite Deck, Agol, Holman & Nesvorny, 2014, ApJ, 787, 132, arXiv:1403.1895 */ 2 | 3 | ***As of May 19, 2014, the sample program run_TTVFast.c has a small bug fixed. This only affected the code when cartesian input was used. In this case, the amount of memory allocated for the structure which holds the calculated transit times, durations, etc. was not correct. This was because the memory allocated depended on the orbital periods of the planets (roughly, the number of transits ~ Sum over the planets (total time/ orbital period). with cartesian input, the orbital period is not supplied). 4 | 5 | Now, n_events is hardwired to a large number to avoid this problem. see below. 6 | ----------------------------- 7 | 8 | TTVFast.c - this is the main piece of code. 9 | Auxiliary files are: ttv-map-jacobi.c, transit.h, myintegrator.h, kepcart2.c, machine-epsilon.c 10 | 11 | The arguments for TTVFast are: 12 | TTVFast(parameter array, time step, t0, tfinal, number of planets, structure to hold calculated transit information, structure to hold calculated RV information, number of RV observations, size of transit array, input style flag) 13 | 14 | Depending on what type of input you want to give (the options are Jacobi elements, Astrocentric elements, Astrocentric cartesian) the form of the input parameter array will be either 15 | For elements: 16 | G Mstar Mplanet Period E I LongNode Argument Mean Anomaly (at t=t0, the reference time).... 17 | repeated for each planet 18 | : 2+nplanets*7 in length 19 | or, for Cartesian: 20 | G Mstar Mplanet X Y Z VX VY VZ (at t=t0, the reference time).... 21 | repeated for each planet 22 | : 2+nplanets*7 in length 23 | 24 | G is in units of AU^3/day^2/M_sun, all masses are in units of M_sun, the Period is in units of days, and the angles are in DEGREES. Cartesian coordinates are in AU and AU/day. The coordinate system is as described in the paper text. One can use different units, as long as G is converted accordingly. 25 | 26 | 27 | (2) time step for the integration: SHOULD NOT BE LARGER THAN ~ 1/20 of the SHORTEST ORBITAL PERIOD. *Large eccentricities will likely require smaller steps* UNIT: days 28 | 29 | (3) t0, the reference time at which integration starts. UNIT: days 30 | 31 | (4) tfinal, the end point of integration (such that tfinal-t0 = observation time span). Again, in units of DAYS. 32 | 33 | (5) Number of planets, transiting or not. 34 | 35 | (6) structure to hold calculated transit information. This structure is a type called CalcTransit, defined in transit.h. This is allocated memory to hold information (transit time, rksy, vsky, etc.) for n_events = large number. By default this is set to 5000 - depending on how many planets you are studying and their orbital periods, this may need to be changed! If this number is not large enough to hold all transits determined by the code, you will get an error! 36 | 37 | 38 | Note that if there are fewer transits which actually occur during the integration, there will be unfilled spots in the CalcTransit structure. We recommend setting a DEFAULT value (as in the sample program, discussed below) so that it is obvious which spots were never filled by TTVFast. 39 | 40 | (7) The RV_model structure: also defined in transit.h. IF RV INFORMATION IS NOT DESIRED, the NULL POINTER should be passed. If RV information is desired, this should be a structure of RV_count spots with the times of RV observations. 41 | 42 | (8) RV_count: the number of RV observations. 43 | 44 | (9) Number of spots in the array of transit structure. If for some reason there are more events that trigger the transit condition than was allocated for, the code exits and prints an error message. 45 | 46 | (10) This is an integer flag that you set to either 0,1 or 2. No other values are accepted. A flag of 0 indicates that TTVFast should expect parameters that are Jacobi elements, flag of 1 indicates astrocentric elements, and a flag of 2 indicates astrocentric Cartesian. 47 | ----------------------------- 48 | SOME FIXED PARAMETERS: 49 | TOLERANCE = 1e-10 /* Tolerance for root finding convergence in transit time determination */ 50 | BAD_TRANSIT = -1 /* If the bisection method is passed a window that does not bracket the root uniquely, or if the bisection method does not converge within MAX_ITER iteractions, the code returns -1, as discussed in the paper */ 51 | MAX_ITER /* Max number of iterations of the bisection method. If reached, code returns BAD_TRANSIT value. This is also the maximum iterations for solving Kepler's incremental equation in the Kepler step. At large eccentricties, we found that sometimes the guess for Delta E based on the previous three steps was not good, and that Newton's method would not converge. In this case we try again with a more robust guess dE = dM - if Newton's method still fails, there is an error message. Smaller time steps alleviate this problem. Note that the timestep required for stability of the integrator for very eccentric orbits is generally small enough to avoid this issue, as dicussed in the paper.*/ 52 | ----------------------------- 53 | Also, we suggest setting a DEFAULT value in whatever program you use to call TTV_Fast.c Unfilled spots in the transit array can be set to this, so that it is clear which returned transit values should be used. See sample program. 54 | ----------------------------- 55 | 56 | SAMPLE PROGRAM: 57 | ----------------------------- 58 | TO COMPILE: 59 | gcc -o run_TTVFast run_TTVFast.c TTVFast.c -lm -O3 60 | ----------------------------- 61 | If you want TTVFast to return RV data: 62 | in SAMPLE PROGRAM, set CALCULATE_RV = 1, then: 63 | SAMPLE PROGRAM requires as arguments (1) setup_file (2) Output file for Times, (3) input file for RV (4) output file for RV 64 | In this case, the program run_TTVFast.c reads in the times of RV observations from (3), creates an array of structures to hold RV calculations, and passes that to TTVFast.c, which then fills it. 65 | If you *do not* want RV data, set CALCULATE_RV=0, then: 66 | SAMPLE PROGRAM requires as arguments (1) setup_file (2) Output file for Times 67 | IN this case, the program run_TTVFast.c does not attempt to read in a file of RV observation times, and passes a NULL pointer to TTV_Fast.c in place of the array of structures mentioned above. 68 | 69 | TO RUN SAMPLE PROGRAM: 70 | to produce (1) calculated TTVs & calculated RV at observed times and (2) predicted RV signal, run: 71 | (1) ./run_TTVFast setup_file Times RV_file RV_out 72 | (2) ./run_TTVFast setup_file Times RV_file2 RV_out2 73 | 74 | 75 | some details: 76 | Times holds the calculated transit information. The columns are: 77 | PLANET EPOCH TIME (DAYS) RSKY (AU) VSKY (AU/DAY) 78 | RV_out holds the calculated RV information. The columns are: 79 | TIME (DAYS) RADIAL VELOCITY (AU/DAY) 80 | The integration starts at BJD_UTC -2456000 = -1045 as specified in setup_file. 81 | RV_file: has times of RV measurements for KOI-142, as reported by: S. C. C. Barros et al. 2013, times are BJD_UTC-2456000 82 | RV_out holds the calculated radial velocities at the times in RV_file, as determined by TTVFast (in AU/day) 83 | RV_file2: a list of times to produce calculated RV, and RV_out2 holds the caculated RV. 84 | RV_out2 holds the predictions (just the RVs calculated more frequently). 85 | 86 | ****PLEASE NOTE**** The convention for radial velocities is such that when the star is moving towards us the radial velocity is negative. This is the opposite as in the code, where the star moving towards us corresponds to increasing z (since the observer is at +z). To account for this, the code returns -v_z for the radial velocity, rather than the true coordinate velocity v_z. 87 | 88 | 89 | The setup file is of the form: 90 | IC_file_NAME (set to KOI142.in. In KOI142.in are the parameters which will be read in and passed to TTVFast in the parameter array.) IC provided by David Nesvorny, they are Jacobi elements. 91 | 92 | t0 (reference time, set here to be -1045) 93 | time step (0.54 days, ~ 1/20 of the period of KOI142b) 94 | tfinal (tfinal-t0 = time of observation) 95 | number of planets = 2 96 | INPUT FLAG = 0 97 | 98 | If you want to try out astrocentric elements or astrocentric cartesian as input, the corresponding IC are in : KOI142.in.cartesian and KOI142.in.astro. The setup files are then setup_file_astro_cartesian or setup_file_astro_elements. They give the same integration parameters (time step, etc.) but a different IC file and input flag. 99 | 100 | 101 | In practice the user will likely not be reading in a file each time with this information, for example if calling TTVFast repeatedly by a minimization scheme. However all of these parameters MUST be set and passed to TTVFast. 102 | 103 | 104 | the IDL program KOI_142_output.pro: 105 | 1) produces a plot of the TTVs (TTVS_KOI_142.eps) 106 | 2) produces a plot of the RV data from S. C. C. Barros et al. 2013, with the mean removed, the calculated RV at those times, and the overall RV signal (from RV_out2).(RV_KOI_142.eps) 107 | ----------------------------- -------------------------------------------------------------------------------- /c_version/RV_KOI_142.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-3.0 EPSF-3.0 2 | %%BoundingBox: 0 0 720 576 3 | %%Title: Graphics produced by IDL 4 | %%For: kdeck@poincare, 5 | %% /data/kdeck/updated_files/ttvFastCode/ttv_fast_packageKD/package2/final_code/TTV_FAST_CODE 6 | %%Creator: IDL Version 8.1 (linux x86_64 m64) 7 | %%CreationDate: Thu Mar 6 12:48:03 2014 8 | %%DocumentData: Clean7bit 9 | %%Requirements: color 10 | %%LanguageLevel: 1 11 | %%PageOrder: Ascend 12 | %%Pages: (atend) 13 | %%DocumentNeededResources: (atend) 14 | %%EndComments 15 | %%BeginProlog 16 | %+ prolog.ps -- Prolog for IDL generated PostScript files 17 | %+ Copyright (c) 1988-2011 ITT Visual Information Solutions. All Rights Reserved. 18 | %v 5 19 | /$IDL_DICT 40 dict def $IDL_DICT begin /bdef { bind def } bind def /C 20 | {currentpoint newpath moveto} bdef /CP {currentpoint} bdef /D {currentpoint 21 | stroke moveto} bdef /F {closepath fill} bdef /K { setgray } bdef /M {moveto} 22 | bdef /N {rmoveto} bdef /P {lineto} bdef /R {rlineto} bdef /S {gsave show 23 | grestore} bdef /X {currentpoint pop} bdef /Z {gsave currentpoint lineto 20 24 | setlinewidth 1 setlinecap stroke grestore} bdef /L0 {[] 0 setdash} bdef /L1 25 | {[40 100] 0 setdash} bdef /L2 {[200 200] 0 setdash} bdef /L3 {[200 100 50 26 | 100] 0 setdash} bdef /L4 {[300 100 50 100 50 100 50 100] 0 setdash} bdef /L5 27 | {[400 200] 0 setdash} bdef /STDFONT { findfont exch scalefont setfont } bdef 28 | /ISOFONT { findfont dup length dict begin { 1 index /FID ne {def} {pop pop} 29 | ifelse } forall /Encoding ISOLatin1Encoding def currentdict end /idltmpfont 30 | exch definefont exch scalefont setfont } bdef /ISOBULLET { gsave /Helvetica 31 | findfont exch scalefont setfont (\267) show currentpoint grestore moveto} 32 | bdef /MITERLIMIT { 2.5 setmiterlimit } bdef end 33 | %%EndProlog 34 | %%Page: 0 1 35 | %%PageRequirements: color 36 | %%PageResources: (atend) 37 | %%PageOrientation: Portrait 38 | %%PageBoundingBox: 0 0 720 576 39 | %%BeginPageSetup 40 | $IDL_DICT begin 0.0283465 dup scale MITERLIMIT 41 | %%IncludeResource: font Helvetica 42 | 423.333 /Helvetica ISOFONT 43 | %%EndPageSetup 44 | 50 setlinewidth L0 0.000 0.000 0.000 setrgbcolor 4440 2816 M 19628 0 R D 45 | 9347 2816 M 0 322 R D gsave 9347 1760 translate 0 0 M 2 dup scale 46 | -353.06 0 N 47 | (500) show grestore 15481 2816 M 0 322 R D gsave 15481 1760 translate 0 0 M 48 | 2 dup scale -353.06 0 N 49 | (550) show grestore 21615 2816 M 0 322 R D gsave 21615 1760 translate 0 0 M 50 | 2 dup scale -353.06 0 N 51 | (600) show grestore 4440 2816 M 0 161 R D 5667 2816 M 0 161 R D 6894 2816 M 52 | 0 161 R D 8120 2816 M 0 161 R D 10574 2816 M 0 161 R D 11801 2816 M 0 161 R 53 | D 13027 2816 M 0 161 R D 14254 2816 M 0 161 R D 16708 2816 M 0 161 R D 54 | 17934 2816 M 0 161 R D 19161 2816 M 0 161 R D 20388 2816 M 0 161 R D 55 | 22841 2816 M 0 161 R D 24068 2816 M 0 161 R D 56 | gsave 14254 845 translate 0 0 M 2 dup scale -1899.92 0 N 57 | (BJD_UTC-2456000) show grestore 4440 18912 M 19628 0 R D 9347 18912 M 58 | 0 -322 R D 15481 18912 M 0 -322 R D 21615 18912 M 0 -322 R D 4440 18912 M 59 | 0 -161 R D 5667 18912 M 0 -161 R D 6894 18912 M 0 -161 R D 8120 18912 M 60 | 0 -161 R D 10574 18912 M 0 -161 R D 11801 18912 M 0 -161 R D 13027 18912 M 61 | 0 -161 R D 14254 18912 M 0 -161 R D 16708 18912 M 0 -161 R D 17934 18912 M 62 | 0 -161 R D 19161 18912 M 0 -161 R D 20388 18912 M 0 -161 R D 22841 18912 M 63 | 0 -161 R D 24068 18912 M 0 -161 R D 4440 2816 M 0 16096 R D 4440 2816 M 64 | 393 0 R D gsave 4218 2816 translate 0 0 M 2 dup scale -1306.41 0 N 65 | (-20.55) show grestore 4440 6840 M 393 0 R D gsave 4218 6559 translate 0 0 M 66 | 2 dup scale -1306.41 0 N 67 | (-20.50) show grestore 4440 10864 M 393 0 R D 68 | gsave 4218 10583 translate 0 0 M 2 dup scale -1306.41 0 N 69 | (-20.45) show grestore 4440 14888 M 393 0 R D 70 | gsave 4218 14607 translate 0 0 M 2 dup scale -1306.41 0 N 71 | (-20.40) show grestore 4440 18912 M 393 0 R D 72 | gsave 4218 18419 translate 0 0 M 2 dup scale -1306.41 0 N 73 | (-20.35) show grestore 4440 3621 M 196 0 R D 4440 4426 M 196 0 R D 74 | 4440 5231 M 196 0 R D 4440 6035 M 196 0 R D 4440 7645 M 196 0 R D 75 | 4440 8450 M 196 0 R D 4440 9255 M 196 0 R D 4440 10059 M 196 0 R D 76 | 4440 11669 M 196 0 R D 4440 12474 M 196 0 R D 4440 13279 M 196 0 R D 77 | 4440 14083 M 196 0 R D 4440 15693 M 196 0 R D 4440 16498 M 196 0 R D 78 | 4440 17303 M 196 0 R D 4440 18107 M 196 0 R D 79 | gsave 940 10864 translate 0 0 M 90 rotate 2 dup scale -940.647 0 N 80 | (RV \(km/s\)) show grestore 24068 2816 M 0 16096 R D 24068 2816 M -392 0 R D 81 | 24068 6840 M -392 0 R D 24068 10864 M -392 0 R D 24068 14888 M -392 0 R D 82 | 24068 18912 M -392 0 R D 24068 3621 M -196 0 R D 24068 4426 M -196 0 R D 83 | 24068 5231 M -196 0 R D 24068 6035 M -196 0 R D 24068 7645 M -196 0 R D 84 | 24068 8450 M -196 0 R D 24068 9255 M -196 0 R D 24068 10059 M -196 0 R D 85 | 24068 11669 M -196 0 R D 24068 12474 M -196 0 R D 24068 13279 M -196 0 R D 86 | 24068 14083 M -196 0 R D 24068 15693 M -196 0 R D 24068 16498 M -196 0 R D 87 | 24068 17303 M -196 0 R D 24068 18107 M -196 0 R D 60 setlinewidth 88 | 6219 13037 M 222 0 R -111 0 R 0 111 R 0 -222 R 0 111 R 111 111 R -222 -222 R 89 | 111 111 R -111 111 R 222 -222 R D 6968 5150 M 222 0 R -111 0 R 0 111 R 90 | 0 -222 R 0 111 R 111 111 R -222 -222 R 111 111 R -111 111 R 222 -222 R D 91 | 9919 7564 M 222 0 R -111 0 R 0 111 R 0 -222 R 0 111 R 111 111 R -222 -222 R 92 | 111 111 R -111 111 R 222 -222 R D 10292 9255 M 222 0 R -111 0 R 0 111 R 93 | 0 -222 R 0 111 R 111 111 R -222 -222 R 111 111 R -111 111 R 222 -222 R D 94 | 11023 14888 M 222 0 R -111 0 R 0 111 R 0 -222 R 0 111 R 111 111 R 95 | -222 -222 R 111 111 R -111 111 R 222 -222 R D 13329 14164 M 222 0 R -111 0 R 96 | 0 111 R 0 -222 R 0 111 R 111 111 R -222 -222 R 111 111 R -111 111 R 97 | 222 -222 R D 13831 14244 M 222 0 R -111 0 R 0 111 R 0 -222 R 0 111 R 98 | 111 111 R -222 -222 R 111 111 R -111 111 R 222 -222 R D 15547 9013 M 222 0 R 99 | -111 0 R 0 111 R 0 -222 R 0 111 R 111 111 R -222 -222 R 111 111 R -111 111 R 100 | 222 -222 R D 19340 13761 M 222 0 R -111 0 R 0 111 R 0 -222 R 0 111 R 101 | 111 111 R -222 -222 R 111 111 R -111 111 R 222 -222 R D 21172 9657 M 222 0 R 102 | -111 0 R 0 111 R 0 -222 R 0 111 R 111 111 R -222 -222 R 111 111 R -111 111 R 103 | 222 -222 R D 22883 6921 M 222 0 R -111 0 R 0 111 R 0 -222 R 0 111 R 104 | 111 111 R -222 -222 R 111 111 R -111 111 R 222 -222 R D 6219 13037 M 222 0 R 105 | -111 0 R 0 111 R 0 -222 R 0 111 R 111 111 R -222 -222 R 111 111 R -111 111 R 106 | 222 -222 R D 6968 5150 M 222 0 R -111 0 R 0 111 R 0 -222 R 0 111 R 111 111 R 107 | -222 -222 R 111 111 R -111 111 R 222 -222 R D 9919 7564 M 222 0 R -111 0 R 108 | 0 111 R 0 -222 R 0 111 R 111 111 R -222 -222 R 111 111 R -111 111 R 109 | 222 -222 R D 10292 9255 M 222 0 R -111 0 R 0 111 R 0 -222 R 0 111 R 110 | 111 111 R -222 -222 R 111 111 R -111 111 R 222 -222 R D 11023 14888 M 111 | 222 0 R -111 0 R 0 111 R 0 -222 R 0 111 R 111 111 R -222 -222 R 111 111 R 112 | -111 111 R 222 -222 R D 13329 14164 M 222 0 R -111 0 R 0 111 R 0 -222 R 113 | 0 111 R 111 111 R -222 -222 R 111 111 R -111 111 R 222 -222 R D 114 | 13831 14244 M 222 0 R -111 0 R 0 111 R 0 -222 R 0 111 R 111 111 R 115 | -222 -222 R 111 111 R -111 111 R 222 -222 R D 15547 9013 M 222 0 R -111 0 R 116 | 0 111 R 0 -222 R 0 111 R 111 111 R -222 -222 R 111 111 R -111 111 R 117 | 222 -222 R D 19340 13761 M 222 0 R -111 0 R 0 111 R 0 -222 R 0 111 R 118 | 111 111 R -222 -222 R 111 111 R -111 111 R 222 -222 R D 21172 9657 M 222 0 R 119 | -111 0 R 0 111 R 0 -222 R 0 111 R 111 111 R -222 -222 R 111 111 R -111 111 R 120 | 222 -222 R D 22883 6921 M 222 0 R -111 0 R 0 111 R 0 -222 R 0 111 R 121 | 111 111 R -222 -222 R 111 111 R -111 111 R 222 -222 R D 6330 12232 M 122 | 0 1610 R D 6203 12232 M 254 0 R D 6203 13842 M 254 0 R D 7079 3862 M 123 | 0 2576 R D 6952 3862 M 254 0 R D 6952 6438 M 254 0 R D 10030 6599 M 0 1931 R 124 | D 9903 6599 M 254 0 R D 9903 8530 M 254 0 R D 10403 8208 M 0 2093 R D 125 | 10276 8208 M 254 0 R D 10276 10301 M 254 0 R D 11134 13681 M 0 2414 R D 126 | 11007 13681 M 254 0 R D 11007 16095 M 254 0 R D 13440 13439 M 0 1449 R D 127 | 13313 13439 M 254 0 R D 13313 14888 M 254 0 R D 13942 13600 M 0 1288 R D 128 | 13815 13600 M 254 0 R D 13815 14888 M 254 0 R D 15658 8128 M 0 1770 R D 129 | 15531 8128 M 254 0 R D 15531 9898 M 254 0 R D 19451 12957 M 0 1609 R D 130 | 19324 12957 M 254 0 R D 19324 14566 M 254 0 R D 21283 9013 M 0 1288 R D 131 | 21156 9013 M 254 0 R D 21156 10301 M 254 0 R D 22994 5874 M 0 2093 R D 132 | 22867 5874 M 254 0 R D 22867 7967 M 254 0 R D 1.000 0.000 0.000 setrgbcolor 133 | 4440 7000 M Z 4563 7570 M -123 -570 R D 4685 8315 M -122 -745 R D 134 | 4808 9185 M -123 -870 R D 4931 10139 M -123 -954 R D 5054 11132 M 135 | -123 -993 R D 5176 12105 M -122 -973 R D 5299 12989 M -123 -884 R D 136 | 5422 13713 M -123 -724 R D 5544 14215 M -122 -502 R D 5667 14437 M 137 | -123 -222 R D 5790 14332 M -123 105 R D 5912 13873 M -122 459 R D 138 | 6035 13089 M -123 784 R D 6158 12063 M -123 1026 R D 6280 10907 M 139 | -122 1156 R D 6403 9734 M -123 1173 R D 6526 8647 M -123 1087 R D 140 | 6648 7733 M -122 914 R D 6771 7067 M -123 666 R D 6894 6706 M -123 361 R D 141 | 7016 6672 M -122 34 R D 7139 6938 M -123 -266 R D 7262 7444 M -123 -506 R D 142 | 7384 8128 M -122 -684 R D 7507 8947 M -123 -819 R D 7630 9863 M -123 -916 R 143 | D 7752 10836 M -122 -973 R D 7875 11815 M -123 -979 R D 7998 12735 M 144 | -123 -920 R D 8120 13526 M -122 -791 R D 8243 14121 M -123 -595 R D 145 | 8366 14448 M -123 -327 R D 8488 14442 M -122 6 R D 8611 14066 M -123 376 R D 146 | 8734 13340 M -123 726 R D 8856 12344 M -122 996 R D 8979 11190 M -123 1154 R 147 | D 9102 9997 M -123 1193 R D 9224 8873 M -122 1124 R D 9347 7913 M -123 960 R 148 | D 9470 7197 M -123 716 R D 9592 6781 M -122 416 R D 9715 6688 M -123 93 R D 149 | 9838 6890 M -123 -202 R D 9961 7332 M -123 -442 R D 10083 7956 M -122 -624 R 150 | D 10206 8721 M -123 -765 R D 10329 9596 M -123 -875 R D 10451 10545 M 151 | -122 -949 R D 10574 11523 M -123 -978 R D 10697 12472 M -123 -949 R D 152 | 10819 13324 M -122 -852 R D 10942 14003 M -123 -679 R D 11065 14430 M 153 | -123 -427 R D 11187 14524 M -122 -94 R D 11310 14235 M -123 289 R D 154 | 11433 13575 M -123 660 R D 11555 12617 M -122 958 R D 11678 11474 M 155 | -123 1143 R D 11801 10266 M -123 1208 R D 11923 9111 M -122 1155 R D 156 | 12046 8108 M -123 1003 R D 12169 7342 M -123 766 R D 12291 6872 M -122 470 R 157 | D 12414 6718 M -123 154 R D 12537 6856 M -123 -138 R D 12659 7234 M 158 | -122 -378 R D 12782 7797 M -123 -563 R D 12905 8508 M -123 -711 R D 159 | 13027 9339 M -122 -831 R D 13150 10260 M -123 -921 R D 13273 11232 M 160 | -123 -972 R D 13395 12203 M -122 -971 R D 13518 13106 M -123 -903 R D 161 | 13641 13864 M -123 -758 R D 13763 14385 M -122 -521 R D 13886 14578 M 162 | -123 -193 R D 14009 14381 M -123 197 R D 14131 13794 M -122 587 R D 163 | 14254 12882 M -123 912 R D 14377 11756 M -123 1126 R D 14499 10541 M 164 | -122 1215 R D 14622 9358 M -123 1183 R D 14745 8316 M -123 1042 R D 165 | 14868 7503 M -123 813 R D 14990 6977 M -122 526 R D 15113 6762 M -123 215 R 166 | D 15236 6836 M -123 -74 R D 15358 7150 M -122 -314 R D 15481 7653 M 167 | -123 -503 R D 15604 8309 M -123 -656 R D 15726 9093 M -122 -784 R D 168 | 15849 9982 M -123 -889 R D 15972 10943 M -123 -961 R D 16094 11929 M 169 | -122 -986 R D 16217 12877 M -123 -948 R D 16340 13704 M -123 -827 R D 170 | 16462 14313 M -122 -609 R D 16585 14603 M -123 -290 R D 16708 14501 M 171 | -123 102 R D 16830 13993 M -122 508 R D 16953 13136 M -123 857 R D 172 | 17076 12035 M -123 1101 R D 17198 10819 M -122 1216 R D 17321 9615 M 173 | -123 1204 R D 17444 8538 M -123 1077 R D 17566 7677 M -122 861 R D 174 | 17689 7097 M -123 580 R D 17812 6820 M -123 277 R D 17934 6830 M -122 -10 R 175 | D 18057 7081 M -123 -251 R D 18180 7523 M -123 -442 R D 18302 8123 M 176 | -122 -600 R D 18425 8859 M -123 -736 R D 18548 9713 M -123 -854 R D 177 | 18670 10659 M -122 -946 R D 18793 11653 M -123 -994 R D 18916 12636 M 178 | -123 -983 R D 19038 13525 M -122 -889 R D 19161 14216 M -123 -691 R D 179 | 19284 14601 M -123 -385 R D 19406 14596 M -122 5 R D 19529 14173 M 180 | -123 423 R D 19652 13377 M -123 796 R D 19775 12309 M -123 1068 R D 181 | 19897 11099 M -122 1210 R D 20020 9880 M -123 1219 R D 20143 8771 M 182 | -123 1109 R D 20265 7865 M -122 906 R D 20388 7230 M -123 635 R D 183 | 20511 6891 M -123 339 R D 20633 6837 M -122 54 R D 20756 7026 M -123 -189 R 184 | D 20879 7409 M -123 -383 R D 21001 7952 M -122 -543 R D 21124 8639 M 185 | -123 -687 R D 21247 9454 M -123 -815 R D 21369 10379 M -122 -925 R D 186 | 21492 11376 M -123 -997 R D 21615 12387 M -123 -1011 R D 21737 13328 M 187 | -122 -941 R D 21860 14094 M -123 -766 R D 21983 14572 M -123 -478 R D 188 | 22105 14665 M -122 -93 R D 22228 14332 M -123 333 R D 22351 13605 M 189 | -123 727 R D 22473 12577 M -122 1028 R D 22596 11381 M -123 1196 R D 190 | 22719 10152 M -123 1229 R D 22841 9014 M -122 1138 R D 22964 8066 M 191 | -123 948 R D 23087 7376 M -123 690 R D 23209 6976 M -122 400 R D 192 | 23332 6859 M -123 117 R D 23455 6986 M -123 -127 R D 23577 7309 M 193 | -122 -323 R D 23700 7796 M -123 -487 R D 23823 8431 M -123 -635 R D 194 | 23945 9206 M -122 -775 R D 24068 10106 M -123 -900 R D 24068 10106 M Z 195 | 1.000 0.000 0.000 setrgbcolor 6441 10422 M 0 15 R -3 14 R -5 14 R -6 13 R 196 | -8 12 R -10 11 R -11 9 R -12 8 R -13 7 R -14 5 R -14 2 R -15 1 R -14 -1 R 197 | -14 -2 R -14 -5 R -13 -7 R -12 -8 R -11 -9 R -10 -11 R -8 -12 R -6 -13 R 198 | -5 -14 R -3 -14 R -1 -15 R 1 -14 R 3 -14 R 5 -14 R 6 -13 R 8 -12 R 10 -11 R 199 | 11 -10 R 12 -8 R 13 -6 R 14 -5 R 14 -3 R 14 -1 R 15 1 R 14 3 R 14 5 R 13 6 R 200 | 12 8 R 11 10 R 10 11 R 8 12 R 6 13 R 5 14 R 3 14 R 0 14 R F 201 | 7190 6773 M -1 14 R -3 15 R -5 13 R -6 13 R -8 12 R -10 11 R -11 10 R 202 | -12 8 R -13 6 R -14 5 R -14 3 R -14 1 R -15 -1 R -14 -3 R -14 -5 R -13 -6 R 203 | -12 -8 R -11 -10 R -9 -11 R -9 -12 R -6 -13 R -5 -13 R -2 -15 R -1 -14 R 204 | 1 -15 R 2 -14 R 5 -14 R 6 -13 R 9 -12 R 9 -11 R 11 -9 R 12 -8 R 13 -7 R 205 | 14 -4 R 14 -3 R 15 -1 R 14 1 R 14 3 R 14 4 R 13 7 R 12 8 R 11 9 R 10 11 R 206 | 8 12 R 6 13 R 5 14 R 3 14 R 1 15 R F 207 | 10141 7666 M -1 14 R -3 14 R -4 14 R -7 13 R -8 12 R -9 11 R -11 10 R 208 | -12 8 R -14 6 R -13 5 R -14 3 R -15 1 R -14 -1 R -15 -3 R -13 -5 R -13 -6 R 209 | -13 -8 R -10 -10 R -10 -11 R -8 -12 R -7 -13 R -4 -14 R -3 -14 R -1 -14 R 210 | 1 -15 R 3 -14 R 4 -14 R 7 -13 R 8 -12 R 10 -11 R 10 -9 R 13 -8 R 13 -7 R 211 | 13 -4 R 15 -3 R 14 -1 R 15 1 R 14 3 R 13 4 R 14 7 R 12 8 R 11 9 R 9 11 R 212 | 8 12 R 7 13 R 4 14 R 3 14 R 1 15 R F 213 | 10514 10165 M -1 15 R -3 14 R -5 14 R -6 13 R -8 12 R -10 11 R -10 9 R 214 | -13 8 R -13 7 R -13 4 R -15 3 R -14 1 R -15 -1 R -14 -3 R -14 -4 R -13 -7 R 215 | -12 -8 R -11 -9 R -9 -11 R -8 -12 R -7 -13 R -4 -14 R -3 -14 R -1 -15 R 216 | 1 -14 R 3 -14 R 4 -14 R 7 -13 R 8 -12 R 9 -11 R 11 -10 R 12 -8 R 13 -6 R 217 | 14 -5 R 14 -3 R 15 -1 R 14 1 R 15 3 R 13 5 R 13 6 R 13 8 R 10 10 R 10 11 R 218 | 8 12 R 6 13 R 5 14 R 3 14 R 1 14 R F 219 | 11245 14528 M -1 15 R -3 14 R -5 14 R -6 13 R -8 12 R -10 11 R -11 9 R 220 | -12 8 R -13 7 R -13 4 R -15 3 R -14 1 R -15 -1 R -14 -3 R -14 -4 R -13 -7 R 221 | -12 -8 R -11 -9 R -9 -11 R -8 -12 R -7 -13 R -4 -14 R -3 -14 R -1 -15 R 222 | 1 -14 R 3 -15 R 4 -13 R 7 -13 R 8 -13 R 9 -10 R 11 -10 R 12 -8 R 13 -7 R 223 | 14 -4 R 14 -3 R 15 -1 R 14 1 R 15 3 R 13 4 R 13 7 R 12 8 R 11 10 R 10 10 R 224 | 8 13 R 6 13 R 5 13 R 3 15 R 1 14 R F 225 | 13551 12544 M -1 15 R -3 14 R -4 14 R -7 13 R -8 12 R -9 11 R -11 10 R 226 | -12 8 R -13 6 R -14 5 R -14 3 R -15 0 R -14 0 R -15 -3 R -13 -5 R -13 -6 R 227 | -12 -8 R -11 -10 R -10 -11 R -8 -12 R -6 -13 R -5 -14 R -3 -14 R -1 -15 R 228 | 1 -14 R 3 -14 R 5 -14 R 6 -13 R 8 -12 R 10 -11 R 11 -10 R 12 -8 R 13 -6 R 229 | 13 -5 R 15 -3 R 14 -1 R 15 1 R 14 3 R 14 5 R 13 6 R 12 8 R 11 10 R 9 11 R 230 | 8 12 R 7 13 R 4 14 R 3 14 R 1 14 R F 231 | 14053 14538 M -1 14 R -3 15 R -4 13 R -7 13 R -8 12 R -10 11 R -10 10 R 232 | -13 8 R -13 6 R -13 5 R -15 3 R -14 1 R -14 -1 R -15 -3 R -13 -5 R -14 -6 R 233 | -12 -8 R -10 -10 R -10 -11 R -8 -12 R -7 -13 R -4 -13 R -3 -15 R -1 -14 R 234 | 1 -15 R 3 -14 R 4 -14 R 7 -13 R 8 -12 R 10 -11 R 10 -9 R 12 -8 R 14 -7 R 235 | 13 -4 R 15 -3 R 14 -1 R 14 1 R 15 3 R 13 4 R 13 7 R 13 8 R 10 9 R 10 11 R 236 | 8 12 R 7 13 R 4 14 R 3 14 R 1 15 R F 237 | 15769 8642 M -1 15 R -3 14 R -4 14 R -7 13 R -8 12 R -9 11 R -11 9 R -12 8 R 238 | -14 7 R -13 5 R -14 2 R -15 1 R -14 -1 R -15 -2 R -13 -5 R -13 -7 R -13 -8 R 239 | -10 -9 R -10 -11 R -8 -12 R -7 -13 R -4 -14 R -3 -14 R -1 -15 R 1 -14 R 240 | 3 -14 R 4 -14 R 7 -13 R 8 -12 R 10 -11 R 10 -10 R 13 -8 R 13 -6 R 13 -5 R 241 | 15 -3 R 14 -1 R 15 1 R 14 3 R 13 5 R 14 6 R 12 8 R 11 10 R 9 11 R 8 12 R 242 | 7 13 R 4 14 R 3 14 R 1 14 R F 243 | 19562 14491 M -1 15 R -3 14 R -5 14 R -6 13 R -8 12 R -10 11 R -11 9 R 244 | -12 8 R -13 7 R -14 5 R -14 2 R -14 1 R -15 -1 R -14 -2 R -14 -5 R -13 -7 R 245 | -12 -8 R -11 -9 R -9 -11 R -9 -12 R -6 -13 R -5 -14 R -2 -14 R -1 -15 R 246 | 1 -14 R 2 -14 R 5 -14 R 6 -13 R 9 -12 R 9 -11 R 11 -10 R 12 -8 R 13 -6 R 247 | 14 -5 R 14 -3 R 15 -1 R 14 1 R 14 3 R 14 5 R 13 6 R 12 8 R 11 10 R 10 11 R 248 | 8 12 R 6 13 R 5 14 R 3 14 R 1 14 R F 249 | 21394 9722 M -1 14 R -2 15 R -5 13 R -6 13 R -9 12 R -9 11 R -11 10 R 250 | -12 8 R -13 6 R -14 5 R -14 3 R -15 1 R -14 -1 R -14 -3 R -14 -5 R -13 -6 R 251 | -12 -8 R -11 -10 R -10 -11 R -8 -12 R -6 -13 R -5 -13 R -3 -15 R -1 -14 R 252 | 1 -15 R 3 -14 R 5 -14 R 6 -13 R 8 -12 R 10 -11 R 11 -9 R 12 -8 R 13 -7 R 253 | 14 -4 R 14 -3 R 14 -1 R 15 1 R 14 3 R 14 4 R 13 7 R 12 8 R 11 9 R 9 11 R 254 | 9 12 R 6 13 R 5 14 R 2 14 R 1 15 R F 255 | 23105 7872 M -1 14 R -3 14 R -4 14 R -7 13 R -8 12 R -10 11 R -10 10 R 256 | -12 8 R -14 6 R -13 5 R -15 3 R -14 1 R -14 -1 R -15 -3 R -13 -5 R -13 -6 R 257 | -13 -8 R -10 -10 R -10 -11 R -8 -12 R -7 -13 R -4 -14 R -3 -14 R -1 -14 R 258 | 1 -15 R 3 -14 R 4 -14 R 7 -13 R 8 -12 R 10 -11 R 10 -9 R 13 -9 R 13 -6 R 259 | 13 -5 R 15 -2 R 14 -1 R 14 1 R 15 2 R 13 5 R 14 6 R 12 9 R 10 9 R 10 11 R 260 | 8 12 R 7 13 R 4 14 R 3 14 R 1 15 R F 261 | %%PageTrailer 262 | end 263 | %%PageResources: font Helvetica 264 | %%Trailer 265 | %%Pages: 1 266 | %%DocumentNeededResources: font Helvetica 267 | %%EOF 268 | -------------------------------------------------------------------------------- /c_version/RV_data_KOI142: -------------------------------------------------------------------------------- 1 | 475.40947 -20.423 0.010 2 | 481.50789 -20.521 0.016 3 | 505.56661 -20.491 0.012 4 | 508.60654 -20.470 0.013 5 | 514.56435 -20.400 0.015 6 | 533.36529 -20.409 0.009 7 | 537.45558 -20.408 0.008 8 | 551.44399 -20.473 0.011 9 | 582.35976 -20.414 0.010 10 | 597.30019 -20.465 0.008 11 | 611.24418 -20.499 0.013 -------------------------------------------------------------------------------- /c_version/RV_file: -------------------------------------------------------------------------------- 1 | 475.40947 2 | 481.50789 3 | 505.56661 4 | 508.60654 5 | 514.56435 6 | 533.36529 7 | 537.45558 8 | 551.44399 9 | 582.35976 10 | 597.30019 11 | 611.24418 -------------------------------------------------------------------------------- /c_version/RV_file2: -------------------------------------------------------------------------------- 1 | 450 2 | 451 3 | 452 4 | 453 5 | 454 6 | 455 7 | 456 8 | 457 9 | 458 10 | 459 11 | 460 12 | 461 13 | 462 14 | 463 15 | 464 16 | 465 17 | 466 18 | 467 19 | 468 20 | 469 21 | 470 22 | 471 23 | 472 24 | 473 25 | 474 26 | 475 27 | 476 28 | 477 29 | 478 30 | 479 31 | 480 32 | 481 33 | 482 34 | 483 35 | 484 36 | 485 37 | 486 38 | 487 39 | 488 40 | 489 41 | 490 42 | 491 43 | 492 44 | 493 45 | 494 46 | 495 47 | 496 48 | 497 49 | 498 50 | 499 51 | 500 52 | 501 53 | 502 54 | 503 55 | 504 56 | 505 57 | 506 58 | 507 59 | 508 60 | 509 61 | 510 62 | 511 63 | 512 64 | 513 65 | 514 66 | 515 67 | 516 68 | 517 69 | 518 70 | 519 71 | 520 72 | 521 73 | 522 74 | 523 75 | 524 76 | 525 77 | 526 78 | 527 79 | 528 80 | 529 81 | 530 82 | 531 83 | 532 84 | 533 85 | 534 86 | 535 87 | 536 88 | 537 89 | 538 90 | 539 91 | 540 92 | 541 93 | 542 94 | 543 95 | 544 96 | 545 97 | 546 98 | 547 99 | 548 100 | 549 101 | 550 102 | 551 103 | 552 104 | 553 105 | 554 106 | 555 107 | 556 108 | 557 109 | 558 110 | 559 111 | 560 112 | 561 113 | 562 114 | 563 115 | 564 116 | 565 117 | 566 118 | 567 119 | 568 120 | 569 121 | 570 122 | 571 123 | 572 124 | 573 125 | 574 126 | 575 127 | 576 128 | 577 129 | 578 130 | 579 131 | 580 132 | 581 133 | 582 134 | 583 135 | 584 136 | 585 137 | 586 138 | 587 139 | 588 140 | 589 141 | 590 142 | 591 143 | 592 144 | 593 145 | 594 146 | 595 147 | 596 148 | 597 149 | 598 150 | 599 151 | 600 152 | 601 153 | 602 154 | 603 155 | 604 156 | 605 157 | 606 158 | 607 159 | 608 160 | 609 161 | 610 162 | 611 163 | 612 164 | 613 165 | 614 166 | 615 167 | 616 168 | 617 169 | 618 170 | 619 171 | 620 172 | 621 173 | 622 174 | 623 175 | 624 176 | 625 177 | 626 178 | 627 179 | 628 180 | 629 181 | 630 182 | 631 183 | 632 184 | 633 185 | 634 186 | 635 187 | 636 188 | 637 189 | 638 190 | 639 191 | 640 192 | 641 193 | 642 194 | 643 195 | 644 196 | 645 197 | 646 198 | 647 199 | 648 200 | 649 201 | -------------------------------------------------------------------------------- /c_version/RV_out: -------------------------------------------------------------------------------- 1 | 4.754094700000000e+02 -4.557399570827615e-07 2 | 4.815078900000000e+02 -2.664545469316134e-05 3 | 5.055666100000000e+02 -2.023759760196753e-05 4 | 5.086065400000000e+02 -2.300427585052538e-06 5 | 5.145643500000000e+02 2.900816865436315e-05 6 | 5.333652900000000e+02 1.477347050308233e-05 7 | 5.374555800000001e+02 2.907887313600428e-05 8 | 5.514439900000000e+02 -1.322952680464436e-05 9 | 5.823597600000001e+02 2.874508640612880e-05 10 | 5.973001900000000e+02 -5.481921572024111e-06 11 | 6.112441800000000e+02 -1.876024000347331e-05 12 | -------------------------------------------------------------------------------- /c_version/RV_out.expected: -------------------------------------------------------------------------------- 1 | 4.754094700000000e+02 -4.557399570827615e-07 2 | 4.815078900000000e+02 -2.664545469316134e-05 3 | 5.055666100000000e+02 -2.023759760196753e-05 4 | 5.086065400000000e+02 -2.300427585052538e-06 5 | 5.145643500000000e+02 2.900816865436315e-05 6 | 5.333652900000000e+02 1.477347050308233e-05 7 | 5.374555800000001e+02 2.907887313600428e-05 8 | 5.514439900000000e+02 -1.322952680464436e-05 9 | 5.823597600000001e+02 2.874508640612880e-05 10 | 5.973001900000000e+02 -5.481921572024111e-06 11 | 6.112441800000000e+02 -1.876024000347331e-05 12 | -------------------------------------------------------------------------------- /c_version/RV_out2: -------------------------------------------------------------------------------- 1 | 4.500000000000000e+02 2.276723283691919e-05 2 | 4.510000000000000e+02 1.678151570998936e-05 3 | 4.520000000000000e+02 9.262205624964161e-06 4 | 4.530000000000000e+02 9.979137187025018e-07 5 | 4.540000000000000e+02 -7.228420545928260e-06 6 | 4.550000000000000e+02 -1.473275641283521e-05 7 | 4.560000000000000e+02 -2.093558312838057e-05 8 | 4.570000000000000e+02 -2.533761634119473e-05 9 | 4.580000000000000e+02 -2.754144583033064e-05 10 | 4.590000000000000e+02 -2.737435869976248e-05 11 | 4.600000000000000e+02 -2.501759684794587e-05 12 | 4.610000000000000e+02 -2.092756501611233e-05 13 | 4.620000000000000e+02 -1.558124687234957e-05 14 | 4.630000000000000e+02 -9.337086095853683e-06 15 | 4.640000000000000e+02 -2.487478835633220e-06 16 | 4.650000000000000e+02 4.638112838620663e-06 17 | 4.660000000000000e+02 1.162006513678570e-05 18 | 4.670000000000000e+02 1.796332012177503e-05 19 | 4.680000000000000e+02 2.316130992745019e-05 20 | 4.690000000000000e+02 2.675964518087322e-05 21 | 4.700000000000000e+02 2.835709532780984e-05 22 | 4.710000000000000e+02 2.759855172276977e-05 23 | 4.720000000000000e+02 2.430637001284504e-05 24 | 4.730000000000000e+02 1.868168873705636e-05 25 | 4.740000000000000e+02 1.131845471890991e-05 26 | 4.750000000000000e+02 3.019978929582441e-06 27 | 4.760000000000000e+02 -5.395428593615640e-06 28 | 4.770000000000000e+02 -1.319607082964222e-05 29 | 4.780000000000000e+02 -1.975343203810119e-05 30 | 4.790000000000000e+02 -2.453121548866321e-05 31 | 4.800000000000000e+02 -2.712229516790766e-05 32 | 4.810000000000000e+02 -2.736938176935597e-05 33 | 4.820000000000000e+02 -2.546158122063273e-05 34 | 4.830000000000000e+02 -2.183148905804108e-05 35 | 4.840000000000000e+02 -1.691750268383885e-05 36 | 4.850000000000000e+02 -1.104366398089651e-05 37 | 4.860000000000000e+02 -4.469307772220303e-06 38 | 4.870000000000000e+02 2.515785946424943e-06 39 | 4.880000000000000e+02 9.536809521066346e-06 40 | 4.890000000000000e+02 1.613751134314497e-05 41 | 4.900000000000000e+02 2.182002075655795e-05 42 | 4.910000000000000e+02 2.608450333834212e-05 43 | 4.920000000000000e+02 2.843031304546794e-05 44 | 4.930000000000000e+02 2.838724973751428e-05 45 | 4.940000000000000e+02 2.568922269915635e-05 46 | 4.950000000000000e+02 2.048223916093680e-05 47 | 4.960000000000000e+02 1.333425221159379e-05 48 | 4.970000000000000e+02 5.053793680331156e-06 49 | 4.980000000000000e+02 -3.508429511603460e-06 50 | 4.990000000000000e+02 -1.157264878873160e-05 51 | 5.000000000000000e+02 -1.846115631344439e-05 52 | 5.010000000000000e+02 -2.360335481382874e-05 53 | 5.020000000000000e+02 -2.658437515882760e-05 54 | 5.030000000000000e+02 -2.725607435197453e-05 55 | 5.040000000000000e+02 -2.580458414435725e-05 56 | 5.050000000000000e+02 -2.263608318970331e-05 57 | 5.060000000000000e+02 -1.815706899345884e-05 58 | 5.070000000000000e+02 -1.266434779670163e-05 59 | 5.080000000000000e+02 -6.387371784869863e-06 60 | 5.090000000000000e+02 4.244407336404824e-07 61 | 5.100000000000000e+02 7.443038193736560e-06 62 | 5.110000000000000e+02 1.425167646549306e-05 63 | 5.120000000000000e+02 2.036433962160149e-05 64 | 5.130000000000000e+02 2.524358894952369e-05 65 | 5.140000000000000e+02 2.830437368805902e-05 66 | 5.150000000000000e+02 2.897663035561929e-05 67 | 5.160000000000000e+02 2.690660533675487e-05 68 | 5.170000000000000e+02 2.217133873433175e-05 69 | 5.180000000000000e+02 1.529733068808118e-05 70 | 5.190000000000000e+02 7.088452668375406e-06 71 | 5.200000000000000e+02 -1.575910488072387e-06 72 | 5.210000000000000e+02 -9.868615413825560e-06 73 | 5.220000000000000e+02 -1.706401779654809e-05 74 | 5.230000000000000e+02 -2.256008898664583e-05 75 | 5.240000000000000e+02 -2.593407142669193e-05 76 | 5.250000000000000e+02 -2.703874360608231e-05 77 | 5.260000000000000e+02 -2.604746384632076e-05 78 | 5.270000000000000e+02 -2.333933987042256e-05 79 | 5.280000000000000e+02 -1.929600232190184e-05 80 | 5.290000000000000e+02 -1.419302759755857e-05 81 | 5.300000000000000e+02 -8.232002802212332e-06 82 | 5.310000000000000e+02 -1.622885110607881e-06 83 | 5.320000000000000e+02 5.353562561434123e-06 84 | 5.330000000000000e+02 1.232086183660592e-05 85 | 5.340000000000000e+02 1.880651736000498e-05 86 | 5.350000000000000e+02 2.424395659573284e-05 87 | 5.360000000000000e+02 2.798132116135976e-05 88 | 5.370000000000000e+02 2.936395155908907e-05 89 | 5.380000000000000e+02 2.795078473672442e-05 90 | 5.390000000000000e+02 2.373778892195217e-05 91 | 5.400000000000000e+02 1.719536220059898e-05 92 | 5.410000000000000e+02 9.112706617809450e-06 93 | 5.420000000000000e+02 3.931433477645830e-07 94 | 5.430000000000000e+02 -8.090847879962364e-06 95 | 5.440000000000000e+02 -1.556816876270840e-05 96 | 5.450000000000000e+02 -2.140813617861450e-05 97 | 5.460000000000000e+02 -2.517757665512662e-05 98 | 5.470000000000000e+02 -2.672108191243155e-05 99 | 5.480000000000000e+02 -2.619101400006055e-05 100 | 5.490000000000000e+02 -2.394001985415214e-05 101 | 5.500000000000000e+02 -2.033091276291287e-05 102 | 5.510000000000000e+02 -1.562413344436008e-05 103 | 5.520000000000000e+02 -9.995517312854793e-06 104 | 5.530000000000000e+02 -3.615347735119708e-06 105 | 5.540000000000000e+02 3.282044729988664e-06 106 | 5.550000000000000e+02 1.035895385676311e-05 107 | 5.560000000000000e+02 1.715860195365494e-05 108 | 5.570000000000000e+02 2.309505113603389e-05 109 | 5.580000000000000e+02 2.746639371880648e-05 110 | 5.590000000000000e+02 2.954885566522238e-05 111 | 5.600000000000000e+02 2.881573293452681e-05 112 | 5.610000000000000e+02 2.517128632229331e-05 113 | 5.620000000000000e+02 1.901625010750225e-05 114 | 5.630000000000000e+02 1.111506428431345e-05 115 | 5.640000000000000e+02 2.389265932974268e-06 116 | 5.650000000000000e+02 -6.246995286818541e-06 117 | 5.660000000000000e+02 -1.398073203169008e-05 118 | 5.670000000000000e+02 -2.015435152091580e-05 119 | 5.680000000000000e+02 -2.432027303902358e-05 120 | 5.690000000000000e+02 -2.630590513345423e-05 121 | 5.700000000000000e+02 -2.623583059323347e-05 122 | 5.710000000000000e+02 -2.443703196159337e-05 123 | 5.720000000000000e+02 -2.125982038627137e-05 124 | 5.730000000000000e+02 -1.695403687871968e-05 125 | 5.740000000000000e+02 -1.167164390138396e-05 126 | 5.750000000000000e+02 -5.543786231576184e-06 127 | 5.760000000000000e+02 1.239751080370859e-06 128 | 5.770000000000000e+02 8.379071731804079e-06 129 | 5.780000000000000e+02 1.543322679100780e-05 130 | 5.790000000000000e+02 2.180736907963714e-05 131 | 5.800000000000000e+02 2.676711042590767e-05 132 | 5.810000000000000e+02 2.953366580280036e-05 133 | 5.820000000000000e+02 2.949737954100782e-05 134 | 5.830000000000000e+02 2.646270017496790e-05 135 | 5.840000000000000e+02 2.074841588367283e-05 136 | 5.850000000000000e+02 1.308392426801976e-05 137 | 5.860000000000000e+02 4.402265499549341e-06 138 | 5.870000000000000e+02 -4.345733265891434e-06 139 | 5.880000000000000e+02 -1.230944204883278e-05 140 | 5.890000000000000e+02 -1.880527503617503e-05 141 | 5.900000000000000e+02 -2.336633572385539e-05 142 | 5.910000000000000e+02 -2.579463630081795e-05 143 | 5.920000000000000e+02 -2.618167900342672e-05 144 | 5.930000000000000e+02 -2.482971487374740e-05 145 | 5.940000000000000e+02 -2.208140859245097e-05 146 | 5.950000000000000e+02 -1.818034712775719e-05 147 | 5.960000000000000e+02 -1.325633177925810e-05 148 | 5.970000000000000e+02 -7.401770740789238e-06 149 | 5.980000000000000e+02 -7.638181789845893e-07 150 | 5.990000000000000e+02 6.391453821002121e-06 151 | 6.000000000000000e+02 1.364179527770917e-05 152 | 6.010000000000000e+02 2.039288595216171e-05 153 | 6.020000000000000e+02 2.589346037253662e-05 154 | 6.030000000000000e+02 2.932315096552258e-05 155 | 6.040000000000000e+02 2.999403813422920e-05 156 | 6.050000000000000e+02 2.760443574024212e-05 157 | 6.060000000000000e+02 2.238071604853015e-05 158 | 6.070000000000000e+02 1.500736055203793e-05 159 | 6.080000000000000e+02 6.421203735320754e-06 160 | 6.090000000000000e+02 -2.396646094466841e-06 161 | 6.100000000000000e+02 -1.056241369448529e-05 162 | 6.110000000000000e+02 -1.736667347094849e-05 163 | 6.120000000000000e+02 -2.231837801954060e-05 164 | 6.130000000000000e+02 -2.518728801705321e-05 165 | 6.140000000000000e+02 -2.602745263076964e-05 166 | 6.150000000000000e+02 -2.511695963237536e-05 167 | 6.160000000000000e+02 -2.279498253608990e-05 168 | 6.170000000000000e+02 -1.930221907293692e-05 169 | 6.180000000000000e+02 -1.474702763913191e-05 170 | 6.190000000000000e+02 -9.184833061780012e-06 171 | 6.200000000000000e+02 -2.722904494582745e-06 172 | 6.210000000000000e+02 4.404434894346178e-06 173 | 6.220000000000000e+02 1.179517503200858e-05 174 | 6.230000000000000e+02 1.886409645832031e-05 175 | 6.240000000000000e+02 2.485709942800738e-05 176 | 6.250000000000000e+02 2.892475793155644e-05 177 | 6.260000000000000e+02 3.030599931372156e-05 178 | 6.270000000000000e+02 2.859022446693387e-05 179 | 6.280000000000000e+02 2.390251460438834e-05 180 | 6.290000000000000e+02 1.687313149861364e-05 181 | 6.300000000000000e+02 8.434281538436364e-06 182 | 6.310000000000000e+02 -4.099750790989179e-07 183 | 6.320000000000000e+02 -8.747803208879800e-06 184 | 6.330000000000000e+02 -1.584357081179339e-05 185 | 6.340000000000000e+02 -2.117763059253149e-05 186 | 6.350000000000000e+02 -2.448217070173991e-05 187 | 6.360000000000000e+02 -2.577053738555476e-05 188 | 6.370000000000000e+02 -2.529683320022103e-05 189 | 6.380000000000000e+02 -2.339958223857406e-05 190 | 6.390000000000000e+02 -2.031946045436622e-05 191 | 6.400000000000000e+02 -1.614390437241818e-05 192 | 6.410000000000000e+02 -1.089195768056450e-05 193 | 6.420000000000000e+02 -4.634234558411915e-06 194 | 6.430000000000000e+02 2.423878939868885e-06 195 | 6.440000000000000e+02 9.902850264064457e-06 196 | 6.450000000000000e+02 1.723418889179904e-05 197 | 6.460000000000000e+02 2.367134944868602e-05 198 | 6.470000000000000e+02 2.834758910037839e-05 199 | 6.480000000000000e+02 3.043573622851173e-05 200 | 6.490000000000000e+02 2.941526957262477e-05 201 | -------------------------------------------------------------------------------- /c_version/compare_output.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | typedef struct { 6 | int planet, epoch; 7 | double time, rsky, vsky; 8 | } TimesRow; 9 | 10 | typedef struct { 11 | double time, rv; 12 | } RVRow; 13 | 14 | /* Copy of numpy.isclose */ 15 | int double_close(double x, double y) { 16 | const double rtol = 1E-5; 17 | const double atol = 1E-8; 18 | 19 | if (fabs(x - y) <= (atol + rtol * fabs(y))) { 20 | return 1; 21 | } else { 22 | return 0; 23 | } 24 | } 25 | 26 | void check_times_rows(const TimesRow *received, const TimesRow *expected, int line_no) { 27 | if (received->planet != expected->planet) { 28 | fprintf(stderr, "Planets do not match: %d != %d; line %d\n", 29 | received->planet, expected->planet, line_no); 30 | exit(1); 31 | } 32 | 33 | if (received->epoch != expected->epoch) { 34 | fprintf(stderr, "Epochs do not match: %d != %d; line %d\n", 35 | received->epoch, expected->epoch, line_no); 36 | exit(1); 37 | } 38 | 39 | if (!double_close(received->time, expected->time)) { 40 | fprintf(stderr, "Times do not match: %lf != %lf; line %d\n", 41 | received->time, expected->time, line_no); 42 | exit(1); 43 | } 44 | 45 | if (!double_close(received->rsky, expected->rsky)) { 46 | fprintf(stderr, "Rsky does not match: %lf != %lf; line %d\n", 47 | received->rsky, expected->rsky, line_no); 48 | exit(1); 49 | } 50 | 51 | if (!double_close(received->vsky, expected->vsky)) { 52 | fprintf(stderr, "Vsky does not match: %lf != %lf; line %d\n", 53 | received->vsky, expected->vsky, line_no); 54 | exit(1); 55 | } 56 | } 57 | 58 | void check_rv_rows(const RVRow *received, const RVRow *expected, int line_no) { 59 | if (!double_close(received->time, expected->time)) { 60 | fprintf(stderr, "Time does not match: %lf != %lf; line %d\n", 61 | received->time, expected->time, line_no); 62 | exit(1); 63 | } 64 | 65 | if (!double_close(received->rv, expected->rv)) { 66 | fprintf(stderr, "RV does not match: %lf != %lf; line %d\n", 67 | received->rv, expected->rv, line_no); 68 | exit(1); 69 | } 70 | } 71 | 72 | int main() { 73 | const char *times_file = "Times"; 74 | const char *times_expected_file = "Times.expected"; 75 | const char *rv_file = "RV_out"; 76 | const char *rv_expected_file = "RV_out.expected"; 77 | 78 | FILE *times, *times_expected; 79 | FILE *rv, *rv_expected; 80 | 81 | { 82 | printf("Checking %s\n", times_file); 83 | times = fopen(times_file, "r"); 84 | times_expected = fopen(times_expected_file, "r"); 85 | 86 | int line_no = 0; 87 | TimesRow received, expected; 88 | while (fscanf(times, "%d %d %lf %lf %lf\n", 89 | &(received.planet), &(received.epoch), 90 | &(received.time), &(received.rsky), &(received.vsky)) != EOF) { 91 | fscanf(times_expected, "%d %d %lf %lf %lf\n", 92 | &(expected.planet), &(expected.epoch), 93 | &(expected.time), &(expected.rsky), &(expected.vsky)); 94 | 95 | check_times_rows(&received, &expected, line_no); 96 | 97 | line_no++; 98 | 99 | } 100 | fclose(times); 101 | fclose(times_expected); 102 | } 103 | 104 | { 105 | printf("Checking %s\n", rv_file); 106 | rv = fopen(rv_file, "r"); 107 | rv_expected = fopen(rv_expected_file, "r"); 108 | 109 | int line_no = 0; 110 | RVRow received, expected; 111 | while (fscanf(rv, "%lf %lf\n", &(received.time), &(received.rv)) != EOF) { 112 | fscanf(rv_expected, "%lf %lf\n", &(expected.time), &(expected.rv)); 113 | 114 | check_rv_rows(&received, &expected, line_no); 115 | line_no++; 116 | } 117 | 118 | fclose(rv); 119 | fclose(rv_expected); 120 | } 121 | 122 | printf("OK\n"); 123 | 124 | 125 | return 0; 126 | } 127 | -------------------------------------------------------------------------------- /c_version/kepcart2.c: -------------------------------------------------------------------------------- 1 | /*If you make use of this code, please cite Deck, Agol, Holman & Nesvorny, 2014 */ 2 | // This file has two routines which convert a GM & Cartesian state to orbital elements and VICE VERSA. 3 | 4 | extern double machine_epsilon; 5 | void keplerian(double gm, PhaseState state, double *a, double *e, double *i, double *longnode, double *argperi, double *meananom) 6 | { 7 | double rxv_x, rxv_y, rxv_z, hs, h, parameter; 8 | double r, vs, rdotv, rdot, ecostrueanom, esintrueanom, cosnode, sinnode; 9 | double rcosu, rsinu, u, trueanom, eccanom; 10 | 11 | /* find direction of angular momentum vector */ 12 | rxv_x = state.y * state.zd - state.z * state.yd; 13 | rxv_y = state.z * state.xd - state.x * state.zd; 14 | rxv_z = state.x * state.yd - state.y * state.xd; 15 | hs = rxv_x * rxv_x + rxv_y * rxv_y + rxv_z * rxv_z; 16 | h = sqrt(hs); 17 | 18 | r = sqrt(state.x * state.x + state.y * state.y + state.z * state.z); 19 | vs = state.xd * state.xd + state.yd * state.yd + state.zd * state.zd; 20 | /* v = sqrt(vs); unnecessary */ 21 | rdotv = state.x * state.xd + state.y * state.yd + state.z * state.zd; 22 | rdot = rdotv / r; 23 | parameter = hs / gm; 24 | 25 | *i = acos(rxv_z / h); 26 | 27 | if(rxv_x!=0.0 || rxv_y!=0.0) { 28 | *longnode = atan2(rxv_x, -rxv_y); 29 | } else { 30 | *longnode = 0.0; 31 | } 32 | 33 | *a = 1.0 / (2.0 / r - vs / gm); 34 | 35 | ecostrueanom = parameter / r - 1.0; 36 | esintrueanom = rdot * h / gm; 37 | *e = sqrt(ecostrueanom * ecostrueanom + esintrueanom * esintrueanom); 38 | 39 | if(esintrueanom!=0.0 || ecostrueanom!=0.0) { 40 | trueanom = atan2(esintrueanom, ecostrueanom); 41 | } else { 42 | trueanom = 0.0; 43 | } 44 | 45 | cosnode = cos(*longnode); 46 | sinnode = sin(*longnode); 47 | 48 | /* u is the argument of latitude */ 49 | rcosu = state.x * cosnode + state.y * sinnode; 50 | rsinu = (state.y * cosnode - state.x * sinnode)/cos(*i); 51 | 52 | if(rsinu!=0.0 || rcosu!=0.0) { 53 | u = atan2(rsinu, rcosu); 54 | } else { 55 | u = 0.0; 56 | } 57 | 58 | *argperi = u - trueanom; 59 | 60 | eccanom = 2.0 * atan(sqrt((1.0 - *e)/(1.0 + *e)) * tan(trueanom/2.0)); 61 | *meananom = eccanom - *e * sin(eccanom); 62 | 63 | return; 64 | } 65 | 66 | 67 | void cartesian(double gm, double a, double e, double i, double longnode, double argperi, double meananom, PhaseState *state) 68 | { 69 | double meanmotion, cosE, sinE, foo; 70 | double x, y, z, xd, yd, zd; 71 | double xp, yp, zp, xdp, ydp, zdp; 72 | double cosw, sinw, cosi, sini, cosnode, sinnode; 73 | double E0, E1, E2, den; 74 | 75 | /* first compute eccentric anomaly */ 76 | E0 = meananom; 77 | do { 78 | E1 = meananom + e * sin(E0); 79 | E2 = meananom + e * sin(E1); 80 | 81 | den = E2 - 2.0*E1 + E0; 82 | if(fabs(den) > machine_epsilon) { 83 | E0 = E0 - (E1-E0)*(E1-E0)/den; 84 | } 85 | else { 86 | E0 = E2; 87 | E2 = E1; 88 | } 89 | } while(fabs(E0-E2) > machine_epsilon); 90 | 91 | cosE = cos(E0); 92 | sinE = sin(E0); 93 | 94 | /* compute unrotated positions and velocities */ 95 | foo = sqrt(1.0 - e*e); 96 | meanmotion = sqrt(gm/(a*a*a)); 97 | x = a * (cosE - e); 98 | y = foo * a * sinE; 99 | z = 0.0; 100 | xd = -a * meanmotion * sinE / (1.0 - e * cosE); 101 | yd = foo * a * meanmotion * cosE / (1.0 - e * cosE); 102 | zd = 0.0; 103 | 104 | /* rotate by argument of perihelion in orbit plane*/ 105 | cosw = cos(argperi); 106 | sinw = sin(argperi); 107 | xp = x * cosw - y * sinw; 108 | yp = x * sinw + y * cosw; 109 | zp = z; 110 | xdp = xd * cosw - yd * sinw; 111 | ydp = xd * sinw + yd * cosw; 112 | zdp = zd; 113 | 114 | /* rotate by inclination about x axis */ 115 | cosi = cos(i); 116 | sini = sin(i); 117 | x = xp; 118 | y = yp * cosi - zp * sini; 119 | z = yp * sini + zp * cosi; 120 | xd = xdp; 121 | yd = ydp * cosi - zdp * sini; 122 | zd = ydp * sini + zdp * cosi; 123 | 124 | /* rotate by longitude of node about z axis */ 125 | cosnode = cos(longnode); 126 | sinnode = sin(longnode); 127 | state->x = x * cosnode - y * sinnode; 128 | state->y = x * sinnode + y * cosnode; 129 | state->z = z; 130 | state->xd = xd * cosnode - yd * sinnode; 131 | state->yd = xd * sinnode + yd * cosnode; 132 | state->zd = zd; 133 | 134 | return; 135 | } 136 | 137 | -------------------------------------------------------------------------------- /c_version/machine-epsilon.c: -------------------------------------------------------------------------------- 1 | 2 | double determine_machine_epsilon() 3 | { 4 | double u, den; 5 | 6 | u = 1.0; 7 | do { 8 | u /= 2.0; 9 | den = 1.0 + u; 10 | } while(den>1.0); 11 | 12 | return(10.0 * u); 13 | } 14 | -------------------------------------------------------------------------------- /c_version/myintegrator.h: -------------------------------------------------------------------------------- 1 | //Here are some other parameters used. 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #define MAX(x,y) ((x) > (y)) ? (x) : (y) 9 | #define MIN(x,y) ((x) < (y)) ? (x) : (y) 10 | #define ABS(a) ((a) < 0 ? -(a) : (a)) 11 | 12 | typedef struct { 13 | double x, y, z; 14 | } Vector; 15 | 16 | 17 | typedef struct { 18 | double x, y, z, xd, yd, zd; 19 | } PhaseState; 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /c_version/run_TTVFast.c: -------------------------------------------------------------------------------- 1 | /*If you make use of this code, please cite Deck, Agol, Holman & Nesvorny, 2014, ApJ, 787, 132, arXiv:1403.1895 */ 2 | 3 | // This is the sample program showing how TTVFast is called. 4 | 5 | #include"transit.h" 6 | #include 7 | #include 8 | #include 9 | #include 10 | #define CALCULATE_RV 1 11 | 12 | void TTVFast(double *params,double dt, double Time, double total,int n_planets, CalcTransit *transit, CalcRV *RV_struct,int n,int m, int input); 13 | 14 | int main(int argc, char **argv) 15 | { 16 | double DEFAULT; 17 | FILE *setup_file; 18 | char ic_file_name[100]; 19 | FILE *dynam_param_file; 20 | FILE *RV_file; 21 | FILE *Transit_output; 22 | FILE *RV_output; 23 | double Time, dt,total; 24 | int nplanets; 25 | int planet,i; 26 | int n_events; 27 | int input_flag; 28 | setup_file = fopen(argv[1], "r"); 29 | fscanf(setup_file, "%s", ic_file_name); 30 | fscanf(setup_file, "%lf", &Time); /* T0*/ 31 | fscanf(setup_file, "%lf", &dt); /* timestep */ 32 | fscanf(setup_file, "%lf", &total); /* Final time*/ 33 | fscanf(setup_file, "%d", &nplanets); 34 | fscanf(setup_file, "%d", &input_flag); 35 | fclose(setup_file); 36 | Transit_output = fopen(argv[2], "w"); 37 | int RV_count = 0; 38 | double RV_time; 39 | CalcRV *RV_model; 40 | if(CALCULATE_RV){ 41 | if(argc!=5){ 42 | printf("Incorrect number of arguments: Setup File, Output File, RV Input file, RV output file - expecting RV data!\n"); 43 | exit(-1); 44 | } 45 | RV_file = fopen(argv[3],"r"); 46 | RV_output = fopen(argv[4],"w"); 47 | while(fscanf(RV_file,"%lf",&RV_time) != EOF){ 48 | RV_count ++; 49 | } 50 | fclose(RV_file); 51 | 52 | RV_model = (CalcRV*) calloc(RV_count,sizeof(CalcRV)); 53 | RV_file = fopen(argv[3],"r"); 54 | RV_count = 0; 55 | while(fscanf(RV_file,"%lf",&RV_time) != EOF){ 56 | (RV_model+RV_count)->time = RV_time; 57 | RV_count++; 58 | } 59 | fclose(RV_file); 60 | 61 | }else{ 62 | RV_model = NULL; 63 | } 64 | 65 | double p[2+nplanets*7]; 66 | dynam_param_file = fopen(ic_file_name,"r"); 67 | fscanf(dynam_param_file, "%lf %lf ",&p[0],&p[1]); 68 | planet=0; 69 | n_events=0; 70 | /*Read in planet params: */ 71 | /*Planet Mass/Stellar Mass, Period, Eccentricity, Inclination, Longnode, Arg Peri, Mean Anomaly */ 72 | while(planet < nplanets){ 73 | fscanf(dynam_param_file, "%lf %lf %lf %lf %lf %lf %lf",&p[planet*7+2],&p[planet*7+3],&p[planet*7+4],&p[planet*7+5],&p[planet*7+6],&p[planet*7+7],&p[planet*7+8]); 74 | planet++; 75 | } 76 | fclose(dynam_param_file); 77 | n_events = 5000; /*HARDWIRED, see README. you may need to change this depending on the number of planets and their orbital periods. */ 78 | /* create structure to hold transit calculations*/ 79 | CalcTransit *model; 80 | model = (CalcTransit*) calloc(n_events,sizeof(CalcTransit)); 81 | DEFAULT = -2; /* value for transit information that is not determined by TTVFast*/ 82 | for(i=0;itime = DEFAULT; 84 | } 85 | TTVFast(p,dt,Time,total,nplanets,model,RV_model,RV_count,n_events,input_flag); 86 | 87 | 88 | for(i=0;itime !=DEFAULT && (model+i)->time !=-1){ 91 | fprintf(Transit_output,"%d %d %.15le %.15le %.15le\n",(model+i)->planet, (model+i)->epoch, (model+i)->time,(model+i)->rsky,(model+i)->vsky); 92 | } 93 | } 94 | fflush(Transit_output); 95 | fclose(Transit_output); 96 | 97 | if(CALCULATE_RV){ 98 | for(i=0;itime, (RV_model+i)->RV); 100 | } 101 | 102 | fflush(RV_output); 103 | fclose(RV_output); 104 | } 105 | free(model); 106 | free(RV_model); 107 | 108 | } 109 | -------------------------------------------------------------------------------- /c_version/setup_file: -------------------------------------------------------------------------------- 1 | KOI142.in 2 | -1045 3 | 0.54 4 | 1700 5 | 2 6 | 0 -------------------------------------------------------------------------------- /c_version/setup_file_astro_cartesian: -------------------------------------------------------------------------------- 1 | KOI142.in.cartesian 2 | -1045 3 | 0.54 4 | 1700 5 | 2 6 | 2 -------------------------------------------------------------------------------- /c_version/setup_file_astro_elements: -------------------------------------------------------------------------------- 1 | KOI142.in.astro 2 | -1045 3 | 0.54 4 | 1700 5 | 2 6 | 1 -------------------------------------------------------------------------------- /c_version/transit.h: -------------------------------------------------------------------------------- 1 | //here are the definitions of the CalcTransit and CalcRV structure. 2 | typedef struct { 3 | int planet; 4 | int epoch; 5 | double time; 6 | double rsky; 7 | double vsky;} CalcTransit; 8 | 9 | typedef struct { 10 | double time; 11 | double RV;} CalcRV; 12 | -------------------------------------------------------------------------------- /c_version/ttv-map-jacobi.c: -------------------------------------------------------------------------------- 1 | /*If you make use of this code, please cite Deck, Agol, Holman & Nesvorny, 2014, ApJ, 787, 132, arXiv:1403.1895 */ 2 | 3 | //This file holds all the auxiliary files for the integration, including the Kepler step, the kick step, transit time solver employing Newton's method, transit time finder employing the bisection method, the symplectic corrector sub routines, etc. 4 | 5 | #include "ttv_errors.h" 6 | 7 | /* Forward declarations */ 8 | status_t Z(PhaseState p[], double a, double b); 9 | void copy_system(PhaseState p1[], PhaseState p2[]); 10 | void copy_state(PhaseState *s1, PhaseState *s2); 11 | 12 | status_t kepler_step(double gm, double dt, PhaseState *s0, PhaseState *s,int planet) 13 | { 14 | 15 | double r0, v0s, u, a, n, ecosE0, esinE0; 16 | double dM, x, sx, cx, f, fp, fpp, fppp, dx; 17 | double fdot, g, gdot; 18 | double sx2, cx2, x2; 19 | double ecosE; 20 | int count; 21 | r0 = sqrt(s0->x*s0->x + s0->y*s0->y + s0->z*s0->z); 22 | 23 | v0s = s0->xd*s0->xd + s0->yd*s0->yd + s0->zd*s0->zd; 24 | u = s0->x*s0->xd + s0->y*s0->yd + s0->z*s0->zd; 25 | a = 1.0/(2.0/r0 - v0s/gm); 26 | 27 | if(a<0.0) { 28 | return STATUS_HYPERBOLIC_ORBIT; 29 | } 30 | 31 | n = sqrt(gm/(a*a*a)); 32 | ecosE0 = 1.0 - r0/a; 33 | esinE0 = u/(n*a*a); 34 | 35 | dM = n*dt; 36 | 37 | x = 3.0*guess[planet][2]+guess[planet][0]-3.0*guess[planet][1]; 38 | 39 | count = 0; 40 | do { 41 | x2 = x/2.0; 42 | sx2 = sin(x2); cx2 = cos(x2); 43 | sx = 2.0*sx2*cx2; cx = cx2*cx2 - sx2*sx2; 44 | f = x + 2.0*sx2*(sx2*esinE0 - cx2*ecosE0) - dM; 45 | ecosE = cx*ecosE0 - sx*esinE0; 46 | fp = 1.0 - ecosE; 47 | fpp = (sx*ecosE0 + cx*esinE0)/2.0; 48 | fppp = ecosE/6.0; 49 | dx = -f/fp; 50 | dx = -f/(fp + dx*fpp); 51 | dx = -f/(fp + dx*(fpp + dx*fppp)); 52 | x += dx; 53 | count ++; 54 | 55 | } while(fabs(dx) > 1.0e-4 && count < MAX_ITER); 56 | 57 | 58 | 59 | if(fabs(f)> 1.0e-14){ 60 | x = dM; 61 | count = 0; 62 | do { 63 | x2 = x/2.0; 64 | sx2 = sin(x2); cx2 = cos(x2); 65 | sx = 2.0*sx2*cx2; cx = cx2*cx2 - sx2*sx2; 66 | f = x + 2.0*sx2*(sx2*esinE0 - cx2*ecosE0) - dM; 67 | ecosE = cx*ecosE0 - sx*esinE0; 68 | fp = 1.0 - ecosE; 69 | fpp = (sx*ecosE0 + cx*esinE0)/2.0; 70 | fppp = ecosE/6.0; 71 | dx = -f/fp; 72 | dx = -f/(fp + dx*fpp); 73 | dx = -f/(fp + dx*(fpp + dx*fppp)); 74 | x += dx; 75 | count++; 76 | } while(fabs(f) > 1.0e-14 && count < MAX_ITER); 77 | 78 | } 79 | 80 | if(count==MAX_ITER){ 81 | return STATUS_NON_CONVERGING; 82 | } 83 | 84 | guess[planet][0]=guess[planet][1]; 85 | guess[planet][1]=guess[planet][2]; 86 | guess[planet][2]=x; 87 | 88 | 89 | /* compute f and g */ 90 | x2 = x/2.0; 91 | sx2 = sin(x2); cx2 = cos(x2); 92 | f = 1.0 - (a/r0)*2.0*sx2*sx2; 93 | sx = 2.0*sx2*cx2; cx = cx2*cx2 - sx2*sx2; 94 | g = (2.0*sx2*(esinE0*sx2 + cx2*r0/a))/n; 95 | fp = 1.0 - cx*ecosE0 + sx*esinE0; 96 | fdot = -(a/(r0*fp))*n*sx; 97 | gdot = (1.0 + g*fdot)/f; 98 | 99 | /* compute new position and velocity */ 100 | s->x = f*s0->x + g*s0->xd; 101 | s->y = f*s0->y + g*s0->yd; 102 | s->z = f*s0->z + g*s0->zd; 103 | s->xd = fdot*s0->x + gdot*s0->xd; 104 | s->yd = fdot*s0->y + gdot*s0->yd; 105 | s->zd = fdot*s0->z + gdot*s0->zd; 106 | 107 | return STATUS_OK; 108 | } 109 | 110 | double kepler_transit_locator(double gm, double dt, PhaseState *s0, PhaseState *s) 111 | { 112 | double transitM; 113 | double a, n,r0, ecosE0, esinE0,u,v0s; 114 | double x, sx, cx, fp, fp2, dx; 115 | double fdot, g, gdot,f; 116 | double sx2, cx2, x2; 117 | double aOverR,dfdz,dgdz,dfdotdz,dgdotdz,dotproduct,dotproductderiv,rsquared,vsquared,xdotv; 118 | int count; 119 | 120 | r0 = sqrt(s0->x*s0->x + s0->y*s0->y + s0->z*s0->z); 121 | v0s = s0->xd*s0->xd + s0->yd*s0->yd + s0->zd*s0->zd; 122 | u = s0->x*s0->xd + s0->y*s0->yd + s0->z*s0->zd; 123 | a = 1.0/(2.0/r0 - v0s/gm); 124 | 125 | n = sqrt(gm/(a*a*a)); 126 | ecosE0 = 1.0 - r0/a; 127 | esinE0 = u/(n*a*a); 128 | 129 | aOverR= a/r0; 130 | rsquared = s0->x*s0->x + s0->y*s0->y; 131 | vsquared = s0->xd*s0->xd + s0->yd*s0->yd; 132 | xdotv =s0->x*s0->xd + s0->y*s0->yd; 133 | 134 | /*Initial Guess */ 135 | x = n*dt/2.0; 136 | count = 0; 137 | do{ 138 | x2 = x/2.0; 139 | sx2 = sin(x2); cx2 = cos(x2); 140 | f = 1.0 - aOverR*2.0*sx2*sx2; 141 | sx = 2.0*sx2*cx2; cx = cx2*cx2 - sx2*sx2; 142 | g = (2.0*sx2*(esinE0*sx2 + cx2/aOverR))/n; 143 | fp = 1.0 - cx*ecosE0 + sx*esinE0; 144 | fdot = -(aOverR/fp)*n*sx; 145 | fp2 = sx*ecosE0 + cx*esinE0; 146 | gdot = 1.0-2.0*sx2*sx2/fp; 147 | 148 | dgdotdz = -sx/fp+2.0*sx2*sx2/fp/fp*fp2; 149 | dfdz = -aOverR*sx; 150 | dgdz= 1.0/n*(sx*esinE0-(ecosE0-1.0)*cx); 151 | dfdotdz= -n*aOverR/fp*(cx+sx/fp*fp2); 152 | 153 | dotproduct = f*fdot*(rsquared)+g*gdot*(vsquared)+(f*gdot+g*fdot)*(xdotv); 154 | 155 | dotproductderiv = dfdz*(gdot*xdotv+fdot*rsquared)+dfdotdz*(f*rsquared+g*xdotv)+dgdz*(fdot*xdotv+gdot*vsquared)+dgdotdz*(g*vsquared+f*xdotv); 156 | 157 | dx = -dotproduct/dotproductderiv; 158 | 159 | x += dx; 160 | 161 | count++; 162 | 163 | }while((fabs(dx)> sqrt(TOLERANCE)) && (count < MAX_ITER)); 164 | /* Now update state */ 165 | x2 = x/2.0; 166 | sx2 = sin(x2); cx2 = cos(x2); 167 | sx = 2.0*sx2*cx2; 168 | 169 | cx = cx2*cx2 - sx2*sx2; 170 | f = 1.0 - (a/r0)*2.0*sx2*sx2; 171 | g = (2.0*sx2*(esinE0*sx2 + cx2/aOverR))/n; 172 | fp = 1.0 - cx*ecosE0 + sx*esinE0; 173 | fdot = -(aOverR/fp)*n*sx; 174 | gdot = (1.0 + g*fdot)/f; 175 | s->x = f*s0->x + g*s0->xd; 176 | s->y = f*s0->y + g*s0->yd; 177 | s->z = f*s0->z + g*s0->zd; 178 | s->xd = fdot*s0->x + gdot*s0->xd; 179 | s->yd = fdot*s0->y + gdot*s0->yd; 180 | s->zd = fdot*s0->z + gdot*s0->zd; 181 | /*Corresponding Delta Mean Anomaly */ 182 | transitM = x+esinE0*2.0*sx2*sx2-sx*ecosE0; 183 | 184 | return(transitM/n); 185 | } 186 | 187 | double bisection(double gm,PhaseState *s0, PhaseState *s1, PhaseState *s) 188 | { 189 | double g0,g1,g2; 190 | double a, n,r0, ecosE0, esinE0,u,v0s; 191 | double x, sx, cx, x2,sx2,cx2,fdot,gdot,f,g,fp,transitM,rsquared,vsquared,xdotv; 192 | double E0,esinE1,ecosE1,E1; 193 | double aOverR; 194 | double dot_product(double y, double aOverR, double esinE0, double ecosE0, double n,double rsquared, double vsquared, double xdotv); 195 | int iter; 196 | double dg2; 197 | 198 | r0 = sqrt(s1->x*s1->x + s1->y*s1->y + s1->z*s1->z); 199 | v0s = s1->xd*s1->xd + s1->yd*s1->yd + s1->zd*s1->zd; 200 | u = s1->x*s1->xd + s1->y*s1->yd + s1->z*s1->zd; 201 | a = 1.0/(2.0/r0 - v0s/gm); 202 | 203 | n = sqrt(gm/(a*a*a)); 204 | ecosE1 = 1.0 - r0/a; 205 | esinE1 = u/(n*a*a); 206 | 207 | E1 = atan2(esinE1,ecosE1); 208 | 209 | r0 = sqrt(s0->x*s0->x + s0->y*s0->y + s0->z*s0->z); 210 | v0s = s0->xd*s0->xd + s0->yd*s0->yd + s0->zd*s0->zd; 211 | u = s0->x*s0->xd + s0->y*s0->yd + s0->z*s0->zd; 212 | a = 1.0/(2.0/r0 - v0s/gm); 213 | rsquared = s0->x*s0->x+s0->y*s0->y; 214 | vsquared = s0->xd*s0->xd+s0->yd*s0->yd; 215 | xdotv = s0->x*s0->xd+s0->y*s0->yd; 216 | n = sqrt(gm/(a*a*a)); 217 | ecosE0 = 1.0 - r0/a; 218 | esinE0 = u/(n*a*a); 219 | E0 = atan2(esinE0,ecosE0); 220 | aOverR= a/r0; 221 | 222 | /* Interval endpoints */ 223 | g0 =0.0; 224 | g1 =(E1-E0); 225 | if(dot_product(g0,aOverR,esinE0,ecosE0,n,rsquared,vsquared,xdotv)*dot_product(g1,aOverR,esinE0,ecosE0,n,rsquared,vsquared,xdotv) < 0.0){ 226 | iter = 0; 227 | }else{ 228 | iter = MAX_ITER; 229 | } 230 | 231 | do{ 232 | g2 = (g1+g0)/2.0; 233 | dg2 = dot_product(g2,aOverR,esinE0,ecosE0,n,rsquared,vsquared,xdotv); 234 | if(dg2*dot_product(g0,aOverR,esinE0,ecosE0,n,rsquared,vsquared,xdotv) > 0.0){ 235 | g0 = g2; 236 | } 237 | else{ 238 | g1 = g2; 239 | } 240 | 241 | iter++; 242 | 243 | } while( (fabs(dg2)> TOLERANCE) && (iter < MAX_ITER)); 244 | 245 | if(iter ==MAX_ITER){ 246 | bad_transit_flag = 1; 247 | } 248 | 249 | /* Now update state */ 250 | x = g2; 251 | x2 = x/2.0; 252 | sx2 = sin(x2); cx2 = cos(x2); 253 | sx = 2.0*sx2*cx2; 254 | 255 | cx = cx2*cx2 - sx2*sx2; 256 | f = 1.0 - (a/r0)*2.0*sx2*sx2; 257 | g = (2.0*sx2*(esinE0*sx2 + cx2/aOverR))/n; 258 | fp = 1.0 - cx*ecosE0 + sx*esinE0; 259 | fdot = -(aOverR/fp)*n*sx; 260 | gdot = 1.0-2.0*sx2*sx2/fp; 261 | s->x = f*s0->x + g*s0->xd; 262 | s->y = f*s0->y + g*s0->yd; 263 | s->z = f*s0->z + g*s0->zd; 264 | s->xd = fdot*s0->x + gdot*s0->xd; 265 | s->yd = fdot*s0->y + gdot*s0->yd; 266 | s->zd = fdot*s0->z + gdot*s0->zd; 267 | /*Corresponding Delta Mean Anomaly */ 268 | transitM = (x+esinE0*2.0*sx2*sx2-sx*ecosE0); 269 | 270 | return(transitM/n); 271 | } 272 | 273 | 274 | double dot_product(double y, double aOverR, double esinE0, double ecosE0, double n,double rsquared, double vsquared, double xdotv) 275 | { 276 | double y2,sy2,cy2,f,sy,cy,fdot,gdot,dotprod,g,fp; 277 | y2 = y/2.0 ; 278 | 279 | sy2 = sin(y2) ; 280 | cy2 = cos(y2) ; 281 | f = 1.0 - aOverR*2.0*sy2*sy2 ; 282 | sy = 2.0*sy2*cy2 ; 283 | cy = cy2*cy2 - sy2*sy2 ; 284 | g = (2.0*sy2*(esinE0*sy2 + cy2/aOverR))/n ; 285 | fp = 1.0 - cy*ecosE0 + sy*esinE0 ; 286 | fdot = -(aOverR/fp)*n*sy ; 287 | gdot = 1.0-2.0*sy2*sy2/fp ; 288 | dotprod = f*fdot*(rsquared)+g*gdot*(vsquared)+(f*gdot+g*fdot)*(xdotv) ; 289 | 290 | return(dotprod); 291 | } 292 | 293 | 294 | 295 | void nbody_kicks(PhaseState p[], double dt) 296 | { 297 | Vector FF[MAX_N_PLANETS], GG[MAX_N_PLANETS]; 298 | Vector tmp[MAX_N_PLANETS], h[MAX_N_PLANETS], XX; 299 | double GMsun_over_r3[MAX_N_PLANETS], rp2, dx, dy, dz, r2, rij2; 300 | double q, q1, fq; 301 | double f0, fij, fijm; 302 | double sx, sy, sz, tx, ty, tz; 303 | int i, j; 304 | 305 | sx = 0.0; sy = 0.0; sz = 0.0; 306 | for(i=0; i=0; i--) { 344 | FF[i].x -= tx; FF[i].y -= ty; FF[i].z -= tz; 345 | f0 = GM[i]*GMsun_over_r3[i]; 346 | tx += h[i].x*f0; ty += h[i].y*f0; tz += h[i].z*f0; 347 | } 348 | 349 | /* factor1 = 1/eta[i-1] factor2 = eta[i]/eta[i-1] */ 350 | for(i=0; ix = s1->x; 447 | s2->y = s1->y; 448 | s2->z = s1->z; 449 | s2->xd = s1->xd; 450 | s2->yd = s1->yd; 451 | s2->zd = s1->zd; 452 | } 453 | 454 | void copy_system(PhaseState p1[], PhaseState p2[]) 455 | { 456 | int planet; 457 | 458 | for(planet=0; planet=1); 48 | local nrvs = length(rv_times) 49 | local transit_workspace = Libc.calloc(nevents,sizeof(ttvfast_transit_entry)) 50 | local rv_workspace = Libc.calloc(nrvs,sizeof(ttvfast_RV_entry)) 51 | @assert(transit_workspace != C_NULL); 52 | @assert(rv_workspace != C_NULL); 53 | for i in 1:nrvs 54 | pointer_to_array(convert(Ptr{ttvfast_RV_entry},rv_workspace),nrvs)[i] = ttvfast_RV_entry(rv_times[i],0.) 55 | end 56 | return ttvfast_outputs_type(transit_workspace,rv_workspace,convert(Cint,nevents),convert(Cint,nrvs) ); 57 | end 58 | 59 | function free_ttvfast_outputs(data::ttvfast_outputs_type) 60 | try 61 | Libc.free(data.rv_workspace); 62 | Libc.free(data.transit_workspace); 63 | catch 64 | println(STDERR, "# ERROR: Something funky happened while trying to deallocate the space reserved for TTVFast outputs.") 65 | end 66 | data.max_num_events = 0; 67 | data.num_rv_obs = 0; 68 | end 69 | 70 | function get_event(data::ttvfast_outputs_type, i::Integer) 71 | @assert( (i>=1) && (i<=data.max_num_events) ) 72 | pointer_to_array(data.transit_workspace,data.max_num_events)[i] 73 | end 74 | 75 | function get_rv(data::ttvfast_outputs_type, i::Integer, convert_to_mps::Bool=true) 76 | @assert( (i>=1) && (i<=data.num_rv_obs) ) 77 | rv = pointer_to_array(data.rv_workspace,data.num_rv_obs)[i].RV 78 | if(convert_to_mps) 79 | rv *= 1731456.84 # should check if you care about precision 80 | end 81 | return rv 82 | end 83 | 84 | function get_rv_time(data::ttvfast_outputs_type, i::Integer) 85 | @assert( (i>=1) && (i<=data.num_rv_obs) ) 86 | pointer_to_array(data.rv_workspace,data.num_rv_obs)[i].time 87 | end 88 | 89 | function ttvfast_inputs_type(p::Array{Cdouble,1} ; inflag::Integer = 0, t_start::Real=0., t_stop::Real=4*365.2425, dt::Real = 0.02) 90 | const local max_steps = 300000; 91 | local np = fld(length(p)-2,7); 92 | @assert(np>=2); 93 | @assert( length(p) == np*7+2 ); 94 | @assert( (inflag==0) || (inflag==1) || (inflag==2) ); 95 | @assert (t_stop>t_start); 96 | @assert( (t_stop-t_start) < dt*max_steps); 97 | return ttvfast_inputs_type(pointer(p),dt,t_start,t_stop,np,inflag); 98 | end 99 | 100 | function ttvfast!(in::ttvfast_inputs_type, out::ttvfast_outputs_type) 101 | # void TTVFast(double *params,double dt, double Time, double total,int n_planets, CalcTransit *transit, CalcRV *RV_struct,int n,int m, int input); 102 | ccall( (:TTVFast, LIBTTV ), Void, (Ptr{Void},Cdouble,Cdouble,Cdouble,Cint,Ptr{Void},Ptr{Void},Cint,Cint,Cint,), 103 | in.param,in.time_step,in.t_start,in.t_stop,in.num_planets, 104 | out.transit_workspace,out.rv_workspace,out.num_rv_obs,out.max_num_events,in.input_flag ) 105 | end 106 | 107 | end # Module TTVFast 108 | 109 | -------------------------------------------------------------------------------- /jl_version/TTVFast_demo.jl: -------------------------------------------------------------------------------- 1 | # Demo how to call TTV fast from Julia 2 | if !isdefined(:TTVFAST_INITIALIZED) 3 | include("TTVFast.jl") 4 | using TTVFast 5 | end 6 | 7 | # Integration parameters 8 | inflag = 0 9 | t_start=0.0 10 | t_stop=4*365.2425 11 | dt = 0.02 12 | 13 | # initializing array of input parameters to TTVFast 14 | # should make into nice function 15 | nplanets=2; # hardwired for now 16 | duration = t_stop-t_start 17 | p = Array(Cdouble,2+nplanets*7); 18 | p[1] = 4pi/365.2425^2; # G 19 | p[2] = 1.0; # Mstar 20 | num_events=0; 21 | for i in 1:nplanets 22 | p[2+7*(i-1)+1] = 0.0001*rand(); # Planet Mass 23 | p[2+7*(i-1)+2] = 3.0^i; # Period 24 | p[2+7*(i-1)+3] = rand(); # Eccentricity 25 | p[2+7*(i-1)+4] = pi/2; # Inclination 26 | p[2+7*(i-1)+5] = 2pi*rand(); # Longitude of Ascending Node 27 | p[2+7*(i-1)+6] = 2pi*rand(); # Argument of Pericenter 28 | p[2+7*(i-1)+7] = 2pi*rand(); # Mean Anomaly 29 | num_events += ceil(Integer, duration/p[2+7*(i-1)+2] +1); # /* large enough to fit all the transits calculated by the code*/ 30 | end 31 | 32 | ttvfast_input = ttvfast_inputs_type(p, t_start=t_start, t_stop=t_stop, dt=dt) 33 | 34 | incl_rvs = true # Make sure first rv_time is _after_ t_start+dt/2 or else won't get any RV outputs 35 | if incl_rvs 36 | num_rvs = 100 37 | rv_times = linspace(t_start+0.501*dt,t_stop, num_rvs) 38 | ttvfast_output = ttvfast_outputs_type(num_events ,rv_times) 39 | else 40 | ttvfast_output = ttvfast_outputs_type(num_events) 41 | end 42 | 43 | println(STDERR, "# About to call TTVFast") 44 | tic(); 45 | ttvfast!(ttvfast_input,ttvfast_output) 46 | toc(); 47 | 48 | println("# You can inspect transit times with calls like: ") 49 | println(" get_event(ttvfast_output,1)") 50 | println("transit[1] = ",get_event(ttvfast_output,1)) 51 | if incl_rvs 52 | println(" get_rv(ttvfast_output,1)") 53 | println("rv[1] = ", get_rv(ttvfast_output,1)) 54 | end 55 | 56 | println("# When you're done looking at outputs, remember to run...") 57 | println(" free_ttvfast_outputs(ttvfast_output) ") 58 | 59 | -------------------------------------------------------------------------------- /jl_version/compile_libttvfast.cmd: -------------------------------------------------------------------------------- 1 | gcc -shared -fPIC -o libttvfast.so ../c_version/TTVFast.c -lm -O3 2 | -------------------------------------------------------------------------------- /jl_version/demo_KOI142.jl: -------------------------------------------------------------------------------- 1 | # Demo how to call TTV fast from Julia 2 | if !isdefined(:TTVFAST_INITIALIZED) 3 | include("TTVFast.jl") 4 | using TTVFast 5 | end 6 | 7 | path = "../c_version/" 8 | setup_filename = "setup_file_astro_cartesian" 9 | RV_in_filename = "RV_file" 10 | 11 | # Read Integration parameters from file 12 | setup_param = split(readall(string(path,setup_filename))) 13 | inputfilename = string(path,setup_param[1]) 14 | t_start=parse(setup_param[2]) 15 | dt = parse(setup_param[3]) 16 | t_stop = parse(setup_param[4]) 17 | nplanets = parse(setup_param[5]) 18 | inflag = parse(setup_param[5]) 19 | 20 | # initializing array of input parameters to TTVFast using data from file 21 | p = Array(Cdouble,2+nplanets*7); 22 | param_str = split(readall(inputfilename)) 23 | @assert(length(p) == length(param_str)) 24 | {p[i] = parse(param_str[i]) for i in 1:length(p) } 25 | num_events=5000 # hardwired same as TTVFast 26 | 27 | ttvfast_input = ttvfast_inputs_type(p, t_start=t_start, t_stop=t_stop, dt=dt, inflag=inflag) 28 | 29 | incl_rvs = true # Make sure first rv_time is _after_ t_start+dt/2 or else won't get any RV outputs 30 | if incl_rvs 31 | rvfile_str = split(readall(string(path,RV_in_filename))) 32 | rv_times = zeros(Float64,length(rvfile_str)) 33 | {rv_times[i] = parse(rvfile_str[i]) for i in 1:length(rvfile_str) } 34 | ttvfast_output = ttvfast_outputs_type(num_events ,rv_times) 35 | else 36 | ttvfast_output = ttvfast_outputs_type(num_events) 37 | end 38 | 39 | println(STDERR, "# About to call TTVFast") 40 | tic(); 41 | ttvfast!(ttvfast_input,ttvfast_output) 42 | toc(); 43 | 44 | println("# You can inspect transit times with calls like: ") 45 | println(" get_event(ttvfast_output,1)") 46 | println("transit[1] = ",get_event(ttvfast_output,1)) 47 | if incl_rvs 48 | println(" get_rv(ttvfast_output,1)") 49 | println("rv[1] = ", get_rv(ttvfast_output,1)) 50 | end 51 | 52 | println("# When you're done looking at outputs, remember to run...") 53 | println(" free_ttvfast_outputs(ttvfast_output) ") 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /jl_version/demo_julia.jl: -------------------------------------------------------------------------------- 1 | # Demo how to call TTV fast from Julia 2 | if !isdefined(:TTVFAST_INITIALIZED) 3 | include("TTVFast.jl") 4 | using TTVFast 5 | end 6 | 7 | # Integration parameters 8 | inflag = 0 9 | t_start=0.0 10 | t_stop=4*365.2425 11 | dt = 0.02 12 | 13 | # initializing array of input parameters to TTVFast 14 | # should make into nice function 15 | nplanets=2; # hardwired for now 16 | duration = t_stop-t_start 17 | p = Array(Cdouble,2+nplanets*7); 18 | p[1] = 4pi/365.2425^2; # G 19 | p[2] = 1.0; # Mstar 20 | num_events=0; 21 | for i in 1:nplanets 22 | p[2+7*(i-1)+1] = 0.0001*rand(); # Planet Mass 23 | p[2+7*(i-1)+2] = 3.0^i; # Period 24 | p[2+7*(i-1)+3] = rand(); # Eccentricity 25 | p[2+7*(i-1)+4] = 90; # Inclination 26 | p[2+7*(i-1)+5] = 360*rand(); # Longitude of Ascending Node 27 | p[2+7*(i-1)+6] = 360*rand(); # Argument of Pericenter 28 | p[2+7*(i-1)+7] = 360*rand(); # Mean Anomaly 29 | num_events += ceil(Integer, duration/p[2+7*(i-1)+2] +1); # /* large enough to fit all the transits calculated by the code*/ 30 | end 31 | 32 | ttvfast_input = ttvfast_inputs_type(p, t_start=t_start, t_stop=t_stop, dt=dt) 33 | 34 | incl_rvs = true # Make sure first rv_time is _after_ t_start+dt/2 or else won't get any RV outputs 35 | if incl_rvs 36 | num_rvs = 100 37 | rv_times = collect(linspace(t_start+0.501*dt,t_stop, num_rvs)) 38 | ttvfast_output = ttvfast_outputs_type(num_events ,rv_times) 39 | else 40 | ttvfast_output = ttvfast_outputs_type(num_events) 41 | end 42 | 43 | println(STDERR, "# About to call TTVFast") 44 | tic(); 45 | ttvfast!(ttvfast_input,ttvfast_output) 46 | toc(); 47 | 48 | println("# You can inspect transit times with calls like: ") 49 | println(" get_event(ttvfast_output,1)") 50 | println("transit[1] = ",get_event(ttvfast_output,1)) 51 | if incl_rvs 52 | println(" get_rv(ttvfast_output,1)") 53 | println("rv[1] = ", get_rv(ttvfast_output,1)) 54 | end 55 | 56 | println("# When you're done looking at outputs, remember to run...") 57 | println(" free_ttvfast_outputs(ttvfast_output) ") 58 | 59 | -------------------------------------------------------------------------------- /julia_version/KOI142.in: -------------------------------------------------------------------------------- 1 | 0.000295994511 2 | 0.95573417954 3 | 0.00002878248 4 | 1.0917340278625494e+01 5.6159310042858110e-02 9.0921164935951211e+01 -1.1729336712101943e-18 1.8094838714599581e+02 -8.7093652691581923e+01 5 | 0.00061895914 6 | 2.2266898036209028e+01 5.6691301931178648e-02 8.7598285693573246e+01 4.6220554014026838e-01 1.6437004273382669e+00 -1.9584857031843157e+01 7 | 8 | -------------------------------------------------------------------------------- /julia_version/KOI142.in.astro: -------------------------------------------------------------------------------- 1 | 0.000295994511 2 | 0.95573417954 3 | 0.00002878248 4 | 1.0917340278625497e+01 5.6159310042858110e-02 9.0921164935951211e+01 0.0000000000000000e+00 1.8094838714599561e+02 -8.7093652691581710e+01 5 | 0.00061895914 6 | 2.2265565872197687e+01 5.6666709482767016e-02 8.7598247127199073e+01 4.6214935847759059e-01 1.6715866399456485e+00 -1.9609909057518475e+01 7 | 8 | -------------------------------------------------------------------------------- /julia_version/KOI142.in.cartesian: -------------------------------------------------------------------------------- 1 | 0.000295994511 2 | 0.95573417954 3 | 0.00002878248 4 | 4.2751105789149389e-03 -1.5242519870492784e-03 9.4799180429814917e-02 -5.4584946596113952e-02 9.7656270156749417e-06 -6.0736246062660626e-04 5 | 0.00061895914 6 | 1.3559014131822117e-01 -1.0049182503274595e-03 -5.0033242877868256e-02 1.4859847408958543e-02 1.9180380744132197e-03 4.2870425084428648e-02 7 | 8 | 9 | -------------------------------------------------------------------------------- /julia_version/KOI_142_output.pro: -------------------------------------------------------------------------------- 1 | pro KOI_142_output 2 | set_plot,'ps' 3 | device,filen='RV_KOI_142.eps',/encapsulated,/inches,xsize=10.0,ysize = 8.0,$ 4 | /color,bits_per_pixel=8,/isolatin,/helvetica 5 | !p.font=0 6 | !p.thick=6 & !x.thick=5 & !y.thick=5 & !p.charthick=5 & syms=2.0 7 | !p.charsize=2.0 8 | 9 | readcol,"Times",planet,epoch,time,rsky,vsky,format ='l,l,d,d,d' 10 | readcol,"RV_out",t_rv_calc,rv_calc,format='d,d' 11 | readcol,"RV_out2",t_rv_calc_all,rv_calc_all,format='d,d' 12 | readcol,"RV_data_KOI142",t_rv_data,rv_data,uncertainty,format='d,d,d' 13 | ; RV data from Barros et al. 2013 14 | offset = -20.4547 15 | ; change units from AU/day to km/s: 16 | AU = 149597871.0 ;in km 17 | day = 3600.0*24.0; in seconds 18 | rv_calc = rv_calc*AU/day+offset 19 | rv_calc_all = rv_calc_all*AU/day+offset 20 | 21 | plotsym,0,/fill 22 | 23 | plot,t_rv_data,rv_data,psym=2,ytitle = 'RV (km/s)',xtitle = 'BJD_UTC-2456000',xrange=[460,620],xstyle=1,yrange=[-20.54,-20.35] 24 | oploterror,t_rv_data,rv_data,uncertainty,psym=2 25 | oplot,t_rv_calc_all,rv_calc_all,psym=-3,color=fsc_color("red") 26 | oplot,t_rv_calc,rv_calc,psym=8,color=fsc_color("red") 27 | device,/close 28 | 29 | k = where(epoch lt 114 AND planet eq 0) ;roughly the number observed in Nesvorny et al. 2013 paper), only look at KOI142b 30 | BFL = linfit(epoch[k],time[k]) 31 | TTV = time[k]-epoch[k]*BFL[1]-BFL[0] 32 | 33 | device,filen='TTVS_KOI_142.eps',/encapsulated,/inches,xsize=10.0,ysize = 8.0,$ 34 | /color,bits_per_pixel=8,/isolatin,/helvetica 35 | 36 | 37 | plot,epoch[k],TTV*24.0*60.0,psym=-8,xtitle = 'Transit Epoch',ytitle = 'TTV (min)',position = [0.2,0.2,0.9,0.9],charsize = 2 38 | device,/close 39 | 40 | 41 | set_plot,'x' 42 | !p.thick=1 & !x.thick=1 & !y.thick=1 & !p.charthick=1 43 | !p.charsize=2 44 | 45 | stop 46 | end 47 | -------------------------------------------------------------------------------- /julia_version/README: -------------------------------------------------------------------------------- 1 | /*If you make use of this code, please cite Deck, Agol, Holman & Nesvorny, 2014, ApJ, 787, 132, arXiv:1403.1895 */ 2 | 3 | ***As of May 19, 2014, the sample program run_TTVFast.c has a small bug fixed. This only affected the code when cartesian input was used. In this case, the amount of memory allocated for the structure which holds the calculated transit times, durations, etc. was not correct. This was because the memory allocated depended on the orbital periods of the planets (roughly, the number of transits ~ Sum over the planets (total time/ orbital period). with cartesian input, the orbital period is not supplied). 4 | 5 | Now, n_events is hardwired to a large number to avoid this problem. see below. 6 | ----------------------------- 7 | 8 | TTVFast.c - this is the main piece of code. 9 | Auxiliary files are: ttv-map-jacobi.c, transit.h, myintegrator.h, kepcart2.c, machine-epsilon.c 10 | 11 | The arguments for TTVFast are: 12 | TTVFast(parameter array, time step, t0, tfinal, number of planets, structure to hold calculated transit information, structure to hold calculated RV information, number of RV observations, size of transit array, input style flag) 13 | 14 | Depending on what type of input you want to give (the options are Jacobi elements, Astrocentric elements, Astrocentric cartesian) the form of the input parameter array will be either 15 | For elements: 16 | G Mstar Mplanet Period E I LongNode Argument Mean Anomaly (at t=t0, the reference time).... 17 | repeated for each planet 18 | : 2+nplanets*7 in length 19 | or, for Cartesian: 20 | G Mstar Mplanet X Y Z VX VY VZ (at t=t0, the reference time).... 21 | repeated for each planet 22 | : 2+nplanets*7 in length 23 | 24 | G is in units of AU^3/day^2/M_sun, all masses are in units of M_sun, the Period is in units of days, and the angles are in DEGREES. Cartesian coordinates are in AU and AU/day. The coordinate system is as described in the paper text. One can use different units, as long as G is converted accordingly. 25 | 26 | 27 | (2) time step for the integration: SHOULD NOT BE LARGER THAN ~ 1/20 of the SHORTEST ORBITAL PERIOD. *Large eccentricities will likely require smaller steps* UNIT: days 28 | 29 | (3) t0, the reference time at which integration starts. UNIT: days 30 | 31 | (4) tfinal, the end point of integration (such that tfinal-t0 = observation time span). Again, in units of DAYS. 32 | 33 | (5) Number of planets, transiting or not. 34 | 35 | (6) structure to hold calculated transit information. This structure is a type called CalcTransit, defined in transit.h. This is allocated memory to hold information (transit time, rksy, vsky, etc.) for n_events = large number. By default this is set to 5000 - depending on how many planets you are studying and their orbital periods, this may need to be changed! If this number is not large enough to hold all transits determined by the code, you will get an error! 36 | 37 | 38 | Note that if there are fewer transits which actually occur during the integration, there will be unfilled spots in the CalcTransit structure. We recommend setting a DEFAULT value (as in the sample program, discussed below) so that it is obvious which spots were never filled by TTVFast. 39 | 40 | (7) The RV_model structure: also defined in transit.h. IF RV INFORMATION IS NOT DESIRED, the NULL POINTER should be passed. If RV information is desired, this should be a structure of RV_count spots with the times of RV observations. 41 | 42 | (8) RV_count: the number of RV observations. 43 | 44 | (9) Number of spots in the array of transit structure. If for some reason there are more events that trigger the transit condition than was allocated for, the code exits and prints an error message. 45 | 46 | (10) This is an integer flag that you set to either 0,1 or 2. No other values are accepted. A flag of 0 indicates that TTVFast should expect parameters that are Jacobi elements, flag of 1 indicates astrocentric elements, and a flag of 2 indicates astrocentric Cartesian. 47 | ----------------------------- 48 | SOME FIXED PARAMETERS: 49 | TOLERANCE = 1e-10 /* Tolerance for root finding convergence in transit time determination */ 50 | BAD_TRANSIT = -1 /* If the bisection method is passed a window that does not bracket the root uniquely, or if the bisection method does not converge within MAX_ITER iteractions, the code returns -1, as discussed in the paper */ 51 | MAX_ITER /* Max number of iterations of the bisection method. If reached, code returns BAD_TRANSIT value. This is also the maximum iterations for solving Kepler's incremental equation in the Kepler step. At large eccentricties, we found that sometimes the guess for Delta E based on the previous three steps was not good, and that Newton's method would not converge. In this case we try again with a more robust guess dE = dM - if Newton's method still fails, there is an error message. Smaller time steps alleviate this problem. Note that the timestep required for stability of the integrator for very eccentric orbits is generally small enough to avoid this issue, as dicussed in the paper.*/ 52 | ----------------------------- 53 | Also, we suggest setting a DEFAULT value in whatever program you use to call TTV_Fast.c Unfilled spots in the transit array can be set to this, so that it is clear which returned transit values should be used. See sample program. 54 | ----------------------------- 55 | 56 | SAMPLE PROGRAM: 57 | ----------------------------- 58 | TO COMPILE: 59 | gcc -o run_TTVFast run_TTVFast.c TTVFast.c -lm -O3 60 | ----------------------------- 61 | If you want TTVFast to return RV data: 62 | in SAMPLE PROGRAM, set CALCULATE_RV = 1, then: 63 | SAMPLE PROGRAM requires as arguments (1) setup_file (2) Output file for Times, (3) input file for RV (4) output file for RV 64 | In this case, the program run_TTVFast.c reads in the times of RV observations from (3), creates an array of structures to hold RV calculations, and passes that to TTVFast.c, which then fills it. 65 | If you *do not* want RV data, set CALCULATE_RV=0, then: 66 | SAMPLE PROGRAM requires as arguments (1) setup_file (2) Output file for Times 67 | IN this case, the program run_TTVFast.c does not attempt to read in a file of RV observation times, and passes a NULL pointer to TTV_Fast.c in place of the array of structures mentioned above. 68 | 69 | TO RUN SAMPLE PROGRAM: 70 | to produce (1) calculated TTVs & calculated RV at observed times and (2) predicted RV signal, run: 71 | (1) ./run_TTVFast setup_file Times RV_file RV_out 72 | (2) ./run_TTVFast setup_file Times RV_file2 RV_out2 73 | 74 | 75 | some details: 76 | Times holds the calculated transit information. The columns are: 77 | PLANET EPOCH TIME (DAYS) RSKY (AU) VSKY (AU/DAY) 78 | RV_out holds the calculated RV information. The columns are: 79 | TIME (DAYS) RADIAL VELOCITY (AU/DAY) 80 | The integration starts at BJD_UTC -2456000 = -1045 as specified in setup_file. 81 | RV_file: has times of RV measurements for KOI-142, as reported by: S. C. C. Barros et al. 2013, times are BJD_UTC-2456000 82 | RV_out holds the calculated radial velocities at the times in RV_file, as determined by TTVFast (in AU/day) 83 | RV_file2: a list of times to produce calculated RV, and RV_out2 holds the caculated RV. 84 | RV_out2 holds the predictions (just the RVs calculated more frequently). 85 | 86 | ****PLEASE NOTE**** The convention for radial velocities is such that when the star is moving towards us the radial velocity is negative. This is the opposite as in the code, where the star moving towards us corresponds to increasing z (since the observer is at +z). To account for this, the code returns -v_z for the radial velocity, rather than the true coordinate velocity v_z. 87 | 88 | 89 | The setup file is of the form: 90 | IC_file_NAME (set to KOI142.in. In KOI142.in are the parameters which will be read in and passed to TTVFast in the parameter array.) IC provided by David Nesvorny, they are Jacobi elements. 91 | 92 | t0 (reference time, set here to be -1045) 93 | time step (0.54 days, ~ 1/20 of the period of KOI142b) 94 | tfinal (tfinal-t0 = time of observation) 95 | number of planets = 2 96 | INPUT FLAG = 0 97 | 98 | If you want to try out astrocentric elements or astrocentric cartesian as input, the corresponding IC are in : KOI142.in.cartesian and KOI142.in.astro. The setup files are then setup_file_astro_cartesian or setup_file_astro_elements. They give the same integration parameters (time step, etc.) but a different IC file and input flag. 99 | 100 | 101 | In practice the user will likely not be reading in a file each time with this information, for example if calling TTVFast repeatedly by a minimization scheme. However all of these parameters MUST be set and passed to TTVFast. 102 | 103 | 104 | the IDL program KOI_142_output.pro: 105 | 1) produces a plot of the TTVs (TTVS_KOI_142.eps) 106 | 2) produces a plot of the RV data from S. C. C. Barros et al. 2013, with the mean removed, the calculated RV at those times, and the overall RV signal (from RV_out2).(RV_KOI_142.eps) 107 | ----------------------------- -------------------------------------------------------------------------------- /julia_version/README.md: -------------------------------------------------------------------------------- 1 | 11/22/2016 2 | 3 | I'm in the process of converting TTVFast to pure Julia (so that I can autodiff it 4 | & debug it more easily when it crashes). 5 | 6 | So far I've converted kepcart2.jl, but I need to figure out what to return for 7 | these functions & I need to test it. 8 | -------------------------------------------------------------------------------- /julia_version/RV_KOI_142.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-3.0 EPSF-3.0 2 | %%BoundingBox: 0 0 720 576 3 | %%Title: Graphics produced by IDL 4 | %%For: kdeck@poincare, 5 | %% /data/kdeck/updated_files/ttvFastCode/ttv_fast_packageKD/package2/final_code/TTV_FAST_CODE 6 | %%Creator: IDL Version 8.1 (linux x86_64 m64) 7 | %%CreationDate: Thu Mar 6 12:48:03 2014 8 | %%DocumentData: Clean7bit 9 | %%Requirements: color 10 | %%LanguageLevel: 1 11 | %%PageOrder: Ascend 12 | %%Pages: (atend) 13 | %%DocumentNeededResources: (atend) 14 | %%EndComments 15 | %%BeginProlog 16 | %+ prolog.ps -- Prolog for IDL generated PostScript files 17 | %+ Copyright (c) 1988-2011 ITT Visual Information Solutions. All Rights Reserved. 18 | %v 5 19 | /$IDL_DICT 40 dict def $IDL_DICT begin /bdef { bind def } bind def /C 20 | {currentpoint newpath moveto} bdef /CP {currentpoint} bdef /D {currentpoint 21 | stroke moveto} bdef /F {closepath fill} bdef /K { setgray } bdef /M {moveto} 22 | bdef /N {rmoveto} bdef /P {lineto} bdef /R {rlineto} bdef /S {gsave show 23 | grestore} bdef /X {currentpoint pop} bdef /Z {gsave currentpoint lineto 20 24 | setlinewidth 1 setlinecap stroke grestore} bdef /L0 {[] 0 setdash} bdef /L1 25 | {[40 100] 0 setdash} bdef /L2 {[200 200] 0 setdash} bdef /L3 {[200 100 50 26 | 100] 0 setdash} bdef /L4 {[300 100 50 100 50 100 50 100] 0 setdash} bdef /L5 27 | {[400 200] 0 setdash} bdef /STDFONT { findfont exch scalefont setfont } bdef 28 | /ISOFONT { findfont dup length dict begin { 1 index /FID ne {def} {pop pop} 29 | ifelse } forall /Encoding ISOLatin1Encoding def currentdict end /idltmpfont 30 | exch definefont exch scalefont setfont } bdef /ISOBULLET { gsave /Helvetica 31 | findfont exch scalefont setfont (\267) show currentpoint grestore moveto} 32 | bdef /MITERLIMIT { 2.5 setmiterlimit } bdef end 33 | %%EndProlog 34 | %%Page: 0 1 35 | %%PageRequirements: color 36 | %%PageResources: (atend) 37 | %%PageOrientation: Portrait 38 | %%PageBoundingBox: 0 0 720 576 39 | %%BeginPageSetup 40 | $IDL_DICT begin 0.0283465 dup scale MITERLIMIT 41 | %%IncludeResource: font Helvetica 42 | 423.333 /Helvetica ISOFONT 43 | %%EndPageSetup 44 | 50 setlinewidth L0 0.000 0.000 0.000 setrgbcolor 4440 2816 M 19628 0 R D 45 | 9347 2816 M 0 322 R D gsave 9347 1760 translate 0 0 M 2 dup scale 46 | -353.06 0 N 47 | (500) show grestore 15481 2816 M 0 322 R D gsave 15481 1760 translate 0 0 M 48 | 2 dup scale -353.06 0 N 49 | (550) show grestore 21615 2816 M 0 322 R D gsave 21615 1760 translate 0 0 M 50 | 2 dup scale -353.06 0 N 51 | (600) show grestore 4440 2816 M 0 161 R D 5667 2816 M 0 161 R D 6894 2816 M 52 | 0 161 R D 8120 2816 M 0 161 R D 10574 2816 M 0 161 R D 11801 2816 M 0 161 R 53 | D 13027 2816 M 0 161 R D 14254 2816 M 0 161 R D 16708 2816 M 0 161 R D 54 | 17934 2816 M 0 161 R D 19161 2816 M 0 161 R D 20388 2816 M 0 161 R D 55 | 22841 2816 M 0 161 R D 24068 2816 M 0 161 R D 56 | gsave 14254 845 translate 0 0 M 2 dup scale -1899.92 0 N 57 | (BJD_UTC-2456000) show grestore 4440 18912 M 19628 0 R D 9347 18912 M 58 | 0 -322 R D 15481 18912 M 0 -322 R D 21615 18912 M 0 -322 R D 4440 18912 M 59 | 0 -161 R D 5667 18912 M 0 -161 R D 6894 18912 M 0 -161 R D 8120 18912 M 60 | 0 -161 R D 10574 18912 M 0 -161 R D 11801 18912 M 0 -161 R D 13027 18912 M 61 | 0 -161 R D 14254 18912 M 0 -161 R D 16708 18912 M 0 -161 R D 17934 18912 M 62 | 0 -161 R D 19161 18912 M 0 -161 R D 20388 18912 M 0 -161 R D 22841 18912 M 63 | 0 -161 R D 24068 18912 M 0 -161 R D 4440 2816 M 0 16096 R D 4440 2816 M 64 | 393 0 R D gsave 4218 2816 translate 0 0 M 2 dup scale -1306.41 0 N 65 | (-20.55) show grestore 4440 6840 M 393 0 R D gsave 4218 6559 translate 0 0 M 66 | 2 dup scale -1306.41 0 N 67 | (-20.50) show grestore 4440 10864 M 393 0 R D 68 | gsave 4218 10583 translate 0 0 M 2 dup scale -1306.41 0 N 69 | (-20.45) show grestore 4440 14888 M 393 0 R D 70 | gsave 4218 14607 translate 0 0 M 2 dup scale -1306.41 0 N 71 | (-20.40) show grestore 4440 18912 M 393 0 R D 72 | gsave 4218 18419 translate 0 0 M 2 dup scale -1306.41 0 N 73 | (-20.35) show grestore 4440 3621 M 196 0 R D 4440 4426 M 196 0 R D 74 | 4440 5231 M 196 0 R D 4440 6035 M 196 0 R D 4440 7645 M 196 0 R D 75 | 4440 8450 M 196 0 R D 4440 9255 M 196 0 R D 4440 10059 M 196 0 R D 76 | 4440 11669 M 196 0 R D 4440 12474 M 196 0 R D 4440 13279 M 196 0 R D 77 | 4440 14083 M 196 0 R D 4440 15693 M 196 0 R D 4440 16498 M 196 0 R D 78 | 4440 17303 M 196 0 R D 4440 18107 M 196 0 R D 79 | gsave 940 10864 translate 0 0 M 90 rotate 2 dup scale -940.647 0 N 80 | (RV \(km/s\)) show grestore 24068 2816 M 0 16096 R D 24068 2816 M -392 0 R D 81 | 24068 6840 M -392 0 R D 24068 10864 M -392 0 R D 24068 14888 M -392 0 R D 82 | 24068 18912 M -392 0 R D 24068 3621 M -196 0 R D 24068 4426 M -196 0 R D 83 | 24068 5231 M -196 0 R D 24068 6035 M -196 0 R D 24068 7645 M -196 0 R D 84 | 24068 8450 M -196 0 R D 24068 9255 M -196 0 R D 24068 10059 M -196 0 R D 85 | 24068 11669 M -196 0 R D 24068 12474 M -196 0 R D 24068 13279 M -196 0 R D 86 | 24068 14083 M -196 0 R D 24068 15693 M -196 0 R D 24068 16498 M -196 0 R D 87 | 24068 17303 M -196 0 R D 24068 18107 M -196 0 R D 60 setlinewidth 88 | 6219 13037 M 222 0 R -111 0 R 0 111 R 0 -222 R 0 111 R 111 111 R -222 -222 R 89 | 111 111 R -111 111 R 222 -222 R D 6968 5150 M 222 0 R -111 0 R 0 111 R 90 | 0 -222 R 0 111 R 111 111 R -222 -222 R 111 111 R -111 111 R 222 -222 R D 91 | 9919 7564 M 222 0 R -111 0 R 0 111 R 0 -222 R 0 111 R 111 111 R -222 -222 R 92 | 111 111 R -111 111 R 222 -222 R D 10292 9255 M 222 0 R -111 0 R 0 111 R 93 | 0 -222 R 0 111 R 111 111 R -222 -222 R 111 111 R -111 111 R 222 -222 R D 94 | 11023 14888 M 222 0 R -111 0 R 0 111 R 0 -222 R 0 111 R 111 111 R 95 | -222 -222 R 111 111 R -111 111 R 222 -222 R D 13329 14164 M 222 0 R -111 0 R 96 | 0 111 R 0 -222 R 0 111 R 111 111 R -222 -222 R 111 111 R -111 111 R 97 | 222 -222 R D 13831 14244 M 222 0 R -111 0 R 0 111 R 0 -222 R 0 111 R 98 | 111 111 R -222 -222 R 111 111 R -111 111 R 222 -222 R D 15547 9013 M 222 0 R 99 | -111 0 R 0 111 R 0 -222 R 0 111 R 111 111 R -222 -222 R 111 111 R -111 111 R 100 | 222 -222 R D 19340 13761 M 222 0 R -111 0 R 0 111 R 0 -222 R 0 111 R 101 | 111 111 R -222 -222 R 111 111 R -111 111 R 222 -222 R D 21172 9657 M 222 0 R 102 | -111 0 R 0 111 R 0 -222 R 0 111 R 111 111 R -222 -222 R 111 111 R -111 111 R 103 | 222 -222 R D 22883 6921 M 222 0 R -111 0 R 0 111 R 0 -222 R 0 111 R 104 | 111 111 R -222 -222 R 111 111 R -111 111 R 222 -222 R D 6219 13037 M 222 0 R 105 | -111 0 R 0 111 R 0 -222 R 0 111 R 111 111 R -222 -222 R 111 111 R -111 111 R 106 | 222 -222 R D 6968 5150 M 222 0 R -111 0 R 0 111 R 0 -222 R 0 111 R 111 111 R 107 | -222 -222 R 111 111 R -111 111 R 222 -222 R D 9919 7564 M 222 0 R -111 0 R 108 | 0 111 R 0 -222 R 0 111 R 111 111 R -222 -222 R 111 111 R -111 111 R 109 | 222 -222 R D 10292 9255 M 222 0 R -111 0 R 0 111 R 0 -222 R 0 111 R 110 | 111 111 R -222 -222 R 111 111 R -111 111 R 222 -222 R D 11023 14888 M 111 | 222 0 R -111 0 R 0 111 R 0 -222 R 0 111 R 111 111 R -222 -222 R 111 111 R 112 | -111 111 R 222 -222 R D 13329 14164 M 222 0 R -111 0 R 0 111 R 0 -222 R 113 | 0 111 R 111 111 R -222 -222 R 111 111 R -111 111 R 222 -222 R D 114 | 13831 14244 M 222 0 R -111 0 R 0 111 R 0 -222 R 0 111 R 111 111 R 115 | -222 -222 R 111 111 R -111 111 R 222 -222 R D 15547 9013 M 222 0 R -111 0 R 116 | 0 111 R 0 -222 R 0 111 R 111 111 R -222 -222 R 111 111 R -111 111 R 117 | 222 -222 R D 19340 13761 M 222 0 R -111 0 R 0 111 R 0 -222 R 0 111 R 118 | 111 111 R -222 -222 R 111 111 R -111 111 R 222 -222 R D 21172 9657 M 222 0 R 119 | -111 0 R 0 111 R 0 -222 R 0 111 R 111 111 R -222 -222 R 111 111 R -111 111 R 120 | 222 -222 R D 22883 6921 M 222 0 R -111 0 R 0 111 R 0 -222 R 0 111 R 121 | 111 111 R -222 -222 R 111 111 R -111 111 R 222 -222 R D 6330 12232 M 122 | 0 1610 R D 6203 12232 M 254 0 R D 6203 13842 M 254 0 R D 7079 3862 M 123 | 0 2576 R D 6952 3862 M 254 0 R D 6952 6438 M 254 0 R D 10030 6599 M 0 1931 R 124 | D 9903 6599 M 254 0 R D 9903 8530 M 254 0 R D 10403 8208 M 0 2093 R D 125 | 10276 8208 M 254 0 R D 10276 10301 M 254 0 R D 11134 13681 M 0 2414 R D 126 | 11007 13681 M 254 0 R D 11007 16095 M 254 0 R D 13440 13439 M 0 1449 R D 127 | 13313 13439 M 254 0 R D 13313 14888 M 254 0 R D 13942 13600 M 0 1288 R D 128 | 13815 13600 M 254 0 R D 13815 14888 M 254 0 R D 15658 8128 M 0 1770 R D 129 | 15531 8128 M 254 0 R D 15531 9898 M 254 0 R D 19451 12957 M 0 1609 R D 130 | 19324 12957 M 254 0 R D 19324 14566 M 254 0 R D 21283 9013 M 0 1288 R D 131 | 21156 9013 M 254 0 R D 21156 10301 M 254 0 R D 22994 5874 M 0 2093 R D 132 | 22867 5874 M 254 0 R D 22867 7967 M 254 0 R D 1.000 0.000 0.000 setrgbcolor 133 | 4440 7000 M Z 4563 7570 M -123 -570 R D 4685 8315 M -122 -745 R D 134 | 4808 9185 M -123 -870 R D 4931 10139 M -123 -954 R D 5054 11132 M 135 | -123 -993 R D 5176 12105 M -122 -973 R D 5299 12989 M -123 -884 R D 136 | 5422 13713 M -123 -724 R D 5544 14215 M -122 -502 R D 5667 14437 M 137 | -123 -222 R D 5790 14332 M -123 105 R D 5912 13873 M -122 459 R D 138 | 6035 13089 M -123 784 R D 6158 12063 M -123 1026 R D 6280 10907 M 139 | -122 1156 R D 6403 9734 M -123 1173 R D 6526 8647 M -123 1087 R D 140 | 6648 7733 M -122 914 R D 6771 7067 M -123 666 R D 6894 6706 M -123 361 R D 141 | 7016 6672 M -122 34 R D 7139 6938 M -123 -266 R D 7262 7444 M -123 -506 R D 142 | 7384 8128 M -122 -684 R D 7507 8947 M -123 -819 R D 7630 9863 M -123 -916 R 143 | D 7752 10836 M -122 -973 R D 7875 11815 M -123 -979 R D 7998 12735 M 144 | -123 -920 R D 8120 13526 M -122 -791 R D 8243 14121 M -123 -595 R D 145 | 8366 14448 M -123 -327 R D 8488 14442 M -122 6 R D 8611 14066 M -123 376 R D 146 | 8734 13340 M -123 726 R D 8856 12344 M -122 996 R D 8979 11190 M -123 1154 R 147 | D 9102 9997 M -123 1193 R D 9224 8873 M -122 1124 R D 9347 7913 M -123 960 R 148 | D 9470 7197 M -123 716 R D 9592 6781 M -122 416 R D 9715 6688 M -123 93 R D 149 | 9838 6890 M -123 -202 R D 9961 7332 M -123 -442 R D 10083 7956 M -122 -624 R 150 | D 10206 8721 M -123 -765 R D 10329 9596 M -123 -875 R D 10451 10545 M 151 | -122 -949 R D 10574 11523 M -123 -978 R D 10697 12472 M -123 -949 R D 152 | 10819 13324 M -122 -852 R D 10942 14003 M -123 -679 R D 11065 14430 M 153 | -123 -427 R D 11187 14524 M -122 -94 R D 11310 14235 M -123 289 R D 154 | 11433 13575 M -123 660 R D 11555 12617 M -122 958 R D 11678 11474 M 155 | -123 1143 R D 11801 10266 M -123 1208 R D 11923 9111 M -122 1155 R D 156 | 12046 8108 M -123 1003 R D 12169 7342 M -123 766 R D 12291 6872 M -122 470 R 157 | D 12414 6718 M -123 154 R D 12537 6856 M -123 -138 R D 12659 7234 M 158 | -122 -378 R D 12782 7797 M -123 -563 R D 12905 8508 M -123 -711 R D 159 | 13027 9339 M -122 -831 R D 13150 10260 M -123 -921 R D 13273 11232 M 160 | -123 -972 R D 13395 12203 M -122 -971 R D 13518 13106 M -123 -903 R D 161 | 13641 13864 M -123 -758 R D 13763 14385 M -122 -521 R D 13886 14578 M 162 | -123 -193 R D 14009 14381 M -123 197 R D 14131 13794 M -122 587 R D 163 | 14254 12882 M -123 912 R D 14377 11756 M -123 1126 R D 14499 10541 M 164 | -122 1215 R D 14622 9358 M -123 1183 R D 14745 8316 M -123 1042 R D 165 | 14868 7503 M -123 813 R D 14990 6977 M -122 526 R D 15113 6762 M -123 215 R 166 | D 15236 6836 M -123 -74 R D 15358 7150 M -122 -314 R D 15481 7653 M 167 | -123 -503 R D 15604 8309 M -123 -656 R D 15726 9093 M -122 -784 R D 168 | 15849 9982 M -123 -889 R D 15972 10943 M -123 -961 R D 16094 11929 M 169 | -122 -986 R D 16217 12877 M -123 -948 R D 16340 13704 M -123 -827 R D 170 | 16462 14313 M -122 -609 R D 16585 14603 M -123 -290 R D 16708 14501 M 171 | -123 102 R D 16830 13993 M -122 508 R D 16953 13136 M -123 857 R D 172 | 17076 12035 M -123 1101 R D 17198 10819 M -122 1216 R D 17321 9615 M 173 | -123 1204 R D 17444 8538 M -123 1077 R D 17566 7677 M -122 861 R D 174 | 17689 7097 M -123 580 R D 17812 6820 M -123 277 R D 17934 6830 M -122 -10 R 175 | D 18057 7081 M -123 -251 R D 18180 7523 M -123 -442 R D 18302 8123 M 176 | -122 -600 R D 18425 8859 M -123 -736 R D 18548 9713 M -123 -854 R D 177 | 18670 10659 M -122 -946 R D 18793 11653 M -123 -994 R D 18916 12636 M 178 | -123 -983 R D 19038 13525 M -122 -889 R D 19161 14216 M -123 -691 R D 179 | 19284 14601 M -123 -385 R D 19406 14596 M -122 5 R D 19529 14173 M 180 | -123 423 R D 19652 13377 M -123 796 R D 19775 12309 M -123 1068 R D 181 | 19897 11099 M -122 1210 R D 20020 9880 M -123 1219 R D 20143 8771 M 182 | -123 1109 R D 20265 7865 M -122 906 R D 20388 7230 M -123 635 R D 183 | 20511 6891 M -123 339 R D 20633 6837 M -122 54 R D 20756 7026 M -123 -189 R 184 | D 20879 7409 M -123 -383 R D 21001 7952 M -122 -543 R D 21124 8639 M 185 | -123 -687 R D 21247 9454 M -123 -815 R D 21369 10379 M -122 -925 R D 186 | 21492 11376 M -123 -997 R D 21615 12387 M -123 -1011 R D 21737 13328 M 187 | -122 -941 R D 21860 14094 M -123 -766 R D 21983 14572 M -123 -478 R D 188 | 22105 14665 M -122 -93 R D 22228 14332 M -123 333 R D 22351 13605 M 189 | -123 727 R D 22473 12577 M -122 1028 R D 22596 11381 M -123 1196 R D 190 | 22719 10152 M -123 1229 R D 22841 9014 M -122 1138 R D 22964 8066 M 191 | -123 948 R D 23087 7376 M -123 690 R D 23209 6976 M -122 400 R D 192 | 23332 6859 M -123 117 R D 23455 6986 M -123 -127 R D 23577 7309 M 193 | -122 -323 R D 23700 7796 M -123 -487 R D 23823 8431 M -123 -635 R D 194 | 23945 9206 M -122 -775 R D 24068 10106 M -123 -900 R D 24068 10106 M Z 195 | 1.000 0.000 0.000 setrgbcolor 6441 10422 M 0 15 R -3 14 R -5 14 R -6 13 R 196 | -8 12 R -10 11 R -11 9 R -12 8 R -13 7 R -14 5 R -14 2 R -15 1 R -14 -1 R 197 | -14 -2 R -14 -5 R -13 -7 R -12 -8 R -11 -9 R -10 -11 R -8 -12 R -6 -13 R 198 | -5 -14 R -3 -14 R -1 -15 R 1 -14 R 3 -14 R 5 -14 R 6 -13 R 8 -12 R 10 -11 R 199 | 11 -10 R 12 -8 R 13 -6 R 14 -5 R 14 -3 R 14 -1 R 15 1 R 14 3 R 14 5 R 13 6 R 200 | 12 8 R 11 10 R 10 11 R 8 12 R 6 13 R 5 14 R 3 14 R 0 14 R F 201 | 7190 6773 M -1 14 R -3 15 R -5 13 R -6 13 R -8 12 R -10 11 R -11 10 R 202 | -12 8 R -13 6 R -14 5 R -14 3 R -14 1 R -15 -1 R -14 -3 R -14 -5 R -13 -6 R 203 | -12 -8 R -11 -10 R -9 -11 R -9 -12 R -6 -13 R -5 -13 R -2 -15 R -1 -14 R 204 | 1 -15 R 2 -14 R 5 -14 R 6 -13 R 9 -12 R 9 -11 R 11 -9 R 12 -8 R 13 -7 R 205 | 14 -4 R 14 -3 R 15 -1 R 14 1 R 14 3 R 14 4 R 13 7 R 12 8 R 11 9 R 10 11 R 206 | 8 12 R 6 13 R 5 14 R 3 14 R 1 15 R F 207 | 10141 7666 M -1 14 R -3 14 R -4 14 R -7 13 R -8 12 R -9 11 R -11 10 R 208 | -12 8 R -14 6 R -13 5 R -14 3 R -15 1 R -14 -1 R -15 -3 R -13 -5 R -13 -6 R 209 | -13 -8 R -10 -10 R -10 -11 R -8 -12 R -7 -13 R -4 -14 R -3 -14 R -1 -14 R 210 | 1 -15 R 3 -14 R 4 -14 R 7 -13 R 8 -12 R 10 -11 R 10 -9 R 13 -8 R 13 -7 R 211 | 13 -4 R 15 -3 R 14 -1 R 15 1 R 14 3 R 13 4 R 14 7 R 12 8 R 11 9 R 9 11 R 212 | 8 12 R 7 13 R 4 14 R 3 14 R 1 15 R F 213 | 10514 10165 M -1 15 R -3 14 R -5 14 R -6 13 R -8 12 R -10 11 R -10 9 R 214 | -13 8 R -13 7 R -13 4 R -15 3 R -14 1 R -15 -1 R -14 -3 R -14 -4 R -13 -7 R 215 | -12 -8 R -11 -9 R -9 -11 R -8 -12 R -7 -13 R -4 -14 R -3 -14 R -1 -15 R 216 | 1 -14 R 3 -14 R 4 -14 R 7 -13 R 8 -12 R 9 -11 R 11 -10 R 12 -8 R 13 -6 R 217 | 14 -5 R 14 -3 R 15 -1 R 14 1 R 15 3 R 13 5 R 13 6 R 13 8 R 10 10 R 10 11 R 218 | 8 12 R 6 13 R 5 14 R 3 14 R 1 14 R F 219 | 11245 14528 M -1 15 R -3 14 R -5 14 R -6 13 R -8 12 R -10 11 R -11 9 R 220 | -12 8 R -13 7 R -13 4 R -15 3 R -14 1 R -15 -1 R -14 -3 R -14 -4 R -13 -7 R 221 | -12 -8 R -11 -9 R -9 -11 R -8 -12 R -7 -13 R -4 -14 R -3 -14 R -1 -15 R 222 | 1 -14 R 3 -15 R 4 -13 R 7 -13 R 8 -13 R 9 -10 R 11 -10 R 12 -8 R 13 -7 R 223 | 14 -4 R 14 -3 R 15 -1 R 14 1 R 15 3 R 13 4 R 13 7 R 12 8 R 11 10 R 10 10 R 224 | 8 13 R 6 13 R 5 13 R 3 15 R 1 14 R F 225 | 13551 12544 M -1 15 R -3 14 R -4 14 R -7 13 R -8 12 R -9 11 R -11 10 R 226 | -12 8 R -13 6 R -14 5 R -14 3 R -15 0 R -14 0 R -15 -3 R -13 -5 R -13 -6 R 227 | -12 -8 R -11 -10 R -10 -11 R -8 -12 R -6 -13 R -5 -14 R -3 -14 R -1 -15 R 228 | 1 -14 R 3 -14 R 5 -14 R 6 -13 R 8 -12 R 10 -11 R 11 -10 R 12 -8 R 13 -6 R 229 | 13 -5 R 15 -3 R 14 -1 R 15 1 R 14 3 R 14 5 R 13 6 R 12 8 R 11 10 R 9 11 R 230 | 8 12 R 7 13 R 4 14 R 3 14 R 1 14 R F 231 | 14053 14538 M -1 14 R -3 15 R -4 13 R -7 13 R -8 12 R -10 11 R -10 10 R 232 | -13 8 R -13 6 R -13 5 R -15 3 R -14 1 R -14 -1 R -15 -3 R -13 -5 R -14 -6 R 233 | -12 -8 R -10 -10 R -10 -11 R -8 -12 R -7 -13 R -4 -13 R -3 -15 R -1 -14 R 234 | 1 -15 R 3 -14 R 4 -14 R 7 -13 R 8 -12 R 10 -11 R 10 -9 R 12 -8 R 14 -7 R 235 | 13 -4 R 15 -3 R 14 -1 R 14 1 R 15 3 R 13 4 R 13 7 R 13 8 R 10 9 R 10 11 R 236 | 8 12 R 7 13 R 4 14 R 3 14 R 1 15 R F 237 | 15769 8642 M -1 15 R -3 14 R -4 14 R -7 13 R -8 12 R -9 11 R -11 9 R -12 8 R 238 | -14 7 R -13 5 R -14 2 R -15 1 R -14 -1 R -15 -2 R -13 -5 R -13 -7 R -13 -8 R 239 | -10 -9 R -10 -11 R -8 -12 R -7 -13 R -4 -14 R -3 -14 R -1 -15 R 1 -14 R 240 | 3 -14 R 4 -14 R 7 -13 R 8 -12 R 10 -11 R 10 -10 R 13 -8 R 13 -6 R 13 -5 R 241 | 15 -3 R 14 -1 R 15 1 R 14 3 R 13 5 R 14 6 R 12 8 R 11 10 R 9 11 R 8 12 R 242 | 7 13 R 4 14 R 3 14 R 1 14 R F 243 | 19562 14491 M -1 15 R -3 14 R -5 14 R -6 13 R -8 12 R -10 11 R -11 9 R 244 | -12 8 R -13 7 R -14 5 R -14 2 R -14 1 R -15 -1 R -14 -2 R -14 -5 R -13 -7 R 245 | -12 -8 R -11 -9 R -9 -11 R -9 -12 R -6 -13 R -5 -14 R -2 -14 R -1 -15 R 246 | 1 -14 R 2 -14 R 5 -14 R 6 -13 R 9 -12 R 9 -11 R 11 -10 R 12 -8 R 13 -6 R 247 | 14 -5 R 14 -3 R 15 -1 R 14 1 R 14 3 R 14 5 R 13 6 R 12 8 R 11 10 R 10 11 R 248 | 8 12 R 6 13 R 5 14 R 3 14 R 1 14 R F 249 | 21394 9722 M -1 14 R -2 15 R -5 13 R -6 13 R -9 12 R -9 11 R -11 10 R 250 | -12 8 R -13 6 R -14 5 R -14 3 R -15 1 R -14 -1 R -14 -3 R -14 -5 R -13 -6 R 251 | -12 -8 R -11 -10 R -10 -11 R -8 -12 R -6 -13 R -5 -13 R -3 -15 R -1 -14 R 252 | 1 -15 R 3 -14 R 5 -14 R 6 -13 R 8 -12 R 10 -11 R 11 -9 R 12 -8 R 13 -7 R 253 | 14 -4 R 14 -3 R 14 -1 R 15 1 R 14 3 R 14 4 R 13 7 R 12 8 R 11 9 R 9 11 R 254 | 9 12 R 6 13 R 5 14 R 2 14 R 1 15 R F 255 | 23105 7872 M -1 14 R -3 14 R -4 14 R -7 13 R -8 12 R -10 11 R -10 10 R 256 | -12 8 R -14 6 R -13 5 R -15 3 R -14 1 R -14 -1 R -15 -3 R -13 -5 R -13 -6 R 257 | -13 -8 R -10 -10 R -10 -11 R -8 -12 R -7 -13 R -4 -14 R -3 -14 R -1 -14 R 258 | 1 -15 R 3 -14 R 4 -14 R 7 -13 R 8 -12 R 10 -11 R 10 -9 R 13 -9 R 13 -6 R 259 | 13 -5 R 15 -2 R 14 -1 R 14 1 R 15 2 R 13 5 R 14 6 R 12 9 R 10 9 R 10 11 R 260 | 8 12 R 7 13 R 4 14 R 3 14 R 1 15 R F 261 | %%PageTrailer 262 | end 263 | %%PageResources: font Helvetica 264 | %%Trailer 265 | %%Pages: 1 266 | %%DocumentNeededResources: font Helvetica 267 | %%EOF 268 | -------------------------------------------------------------------------------- /julia_version/RV_data_KOI142: -------------------------------------------------------------------------------- 1 | 475.40947 -20.423 0.010 2 | 481.50789 -20.521 0.016 3 | 505.56661 -20.491 0.012 4 | 508.60654 -20.470 0.013 5 | 514.56435 -20.400 0.015 6 | 533.36529 -20.409 0.009 7 | 537.45558 -20.408 0.008 8 | 551.44399 -20.473 0.011 9 | 582.35976 -20.414 0.010 10 | 597.30019 -20.465 0.008 11 | 611.24418 -20.499 0.013 -------------------------------------------------------------------------------- /julia_version/RV_file: -------------------------------------------------------------------------------- 1 | 475.40947 2 | 481.50789 3 | 505.56661 4 | 508.60654 5 | 514.56435 6 | 533.36529 7 | 537.45558 8 | 551.44399 9 | 582.35976 10 | 597.30019 11 | 611.24418 -------------------------------------------------------------------------------- /julia_version/RV_file2: -------------------------------------------------------------------------------- 1 | 450 2 | 451 3 | 452 4 | 453 5 | 454 6 | 455 7 | 456 8 | 457 9 | 458 10 | 459 11 | 460 12 | 461 13 | 462 14 | 463 15 | 464 16 | 465 17 | 466 18 | 467 19 | 468 20 | 469 21 | 470 22 | 471 23 | 472 24 | 473 25 | 474 26 | 475 27 | 476 28 | 477 29 | 478 30 | 479 31 | 480 32 | 481 33 | 482 34 | 483 35 | 484 36 | 485 37 | 486 38 | 487 39 | 488 40 | 489 41 | 490 42 | 491 43 | 492 44 | 493 45 | 494 46 | 495 47 | 496 48 | 497 49 | 498 50 | 499 51 | 500 52 | 501 53 | 502 54 | 503 55 | 504 56 | 505 57 | 506 58 | 507 59 | 508 60 | 509 61 | 510 62 | 511 63 | 512 64 | 513 65 | 514 66 | 515 67 | 516 68 | 517 69 | 518 70 | 519 71 | 520 72 | 521 73 | 522 74 | 523 75 | 524 76 | 525 77 | 526 78 | 527 79 | 528 80 | 529 81 | 530 82 | 531 83 | 532 84 | 533 85 | 534 86 | 535 87 | 536 88 | 537 89 | 538 90 | 539 91 | 540 92 | 541 93 | 542 94 | 543 95 | 544 96 | 545 97 | 546 98 | 547 99 | 548 100 | 549 101 | 550 102 | 551 103 | 552 104 | 553 105 | 554 106 | 555 107 | 556 108 | 557 109 | 558 110 | 559 111 | 560 112 | 561 113 | 562 114 | 563 115 | 564 116 | 565 117 | 566 118 | 567 119 | 568 120 | 569 121 | 570 122 | 571 123 | 572 124 | 573 125 | 574 126 | 575 127 | 576 128 | 577 129 | 578 130 | 579 131 | 580 132 | 581 133 | 582 134 | 583 135 | 584 136 | 585 137 | 586 138 | 587 139 | 588 140 | 589 141 | 590 142 | 591 143 | 592 144 | 593 145 | 594 146 | 595 147 | 596 148 | 597 149 | 598 150 | 599 151 | 600 152 | 601 153 | 602 154 | 603 155 | 604 156 | 605 157 | 606 158 | 607 159 | 608 160 | 609 161 | 610 162 | 611 163 | 612 164 | 613 165 | 614 166 | 615 167 | 616 168 | 617 169 | 618 170 | 619 171 | 620 172 | 621 173 | 622 174 | 623 175 | 624 176 | 625 177 | 626 178 | 627 179 | 628 180 | 629 181 | 630 182 | 631 183 | 632 184 | 633 185 | 634 186 | 635 187 | 636 188 | 637 189 | 638 190 | 639 191 | 640 192 | 641 193 | 642 194 | 643 195 | 644 196 | 645 197 | 646 198 | 647 199 | 648 200 | 649 201 | -------------------------------------------------------------------------------- /julia_version/RV_out: -------------------------------------------------------------------------------- 1 | 4.754094700000000e+02 -4.557399570827615e-07 2 | 4.815078900000000e+02 -2.664545469316134e-05 3 | 5.055666100000000e+02 -2.023759760196753e-05 4 | 5.086065400000000e+02 -2.300427585052538e-06 5 | 5.145643500000000e+02 2.900816865436315e-05 6 | 5.333652900000000e+02 1.477347050308233e-05 7 | 5.374555800000001e+02 2.907887313600428e-05 8 | 5.514439900000000e+02 -1.322952680464436e-05 9 | 5.823597600000001e+02 2.874508640612880e-05 10 | 5.973001900000000e+02 -5.481921572024111e-06 11 | 6.112441800000000e+02 -1.876024000347331e-05 12 | -------------------------------------------------------------------------------- /julia_version/RV_out2: -------------------------------------------------------------------------------- 1 | 4.500000000000000e+02 2.276723283691919e-05 2 | 4.510000000000000e+02 1.678151570998936e-05 3 | 4.520000000000000e+02 9.262205624964161e-06 4 | 4.530000000000000e+02 9.979137187025018e-07 5 | 4.540000000000000e+02 -7.228420545928260e-06 6 | 4.550000000000000e+02 -1.473275641283521e-05 7 | 4.560000000000000e+02 -2.093558312838057e-05 8 | 4.570000000000000e+02 -2.533761634119473e-05 9 | 4.580000000000000e+02 -2.754144583033064e-05 10 | 4.590000000000000e+02 -2.737435869976248e-05 11 | 4.600000000000000e+02 -2.501759684794587e-05 12 | 4.610000000000000e+02 -2.092756501611233e-05 13 | 4.620000000000000e+02 -1.558124687234957e-05 14 | 4.630000000000000e+02 -9.337086095853683e-06 15 | 4.640000000000000e+02 -2.487478835633220e-06 16 | 4.650000000000000e+02 4.638112838620663e-06 17 | 4.660000000000000e+02 1.162006513678570e-05 18 | 4.670000000000000e+02 1.796332012177503e-05 19 | 4.680000000000000e+02 2.316130992745019e-05 20 | 4.690000000000000e+02 2.675964518087322e-05 21 | 4.700000000000000e+02 2.835709532780984e-05 22 | 4.710000000000000e+02 2.759855172276977e-05 23 | 4.720000000000000e+02 2.430637001284504e-05 24 | 4.730000000000000e+02 1.868168873705636e-05 25 | 4.740000000000000e+02 1.131845471890991e-05 26 | 4.750000000000000e+02 3.019978929582441e-06 27 | 4.760000000000000e+02 -5.395428593615640e-06 28 | 4.770000000000000e+02 -1.319607082964222e-05 29 | 4.780000000000000e+02 -1.975343203810119e-05 30 | 4.790000000000000e+02 -2.453121548866321e-05 31 | 4.800000000000000e+02 -2.712229516790766e-05 32 | 4.810000000000000e+02 -2.736938176935597e-05 33 | 4.820000000000000e+02 -2.546158122063273e-05 34 | 4.830000000000000e+02 -2.183148905804108e-05 35 | 4.840000000000000e+02 -1.691750268383885e-05 36 | 4.850000000000000e+02 -1.104366398089651e-05 37 | 4.860000000000000e+02 -4.469307772220303e-06 38 | 4.870000000000000e+02 2.515785946424943e-06 39 | 4.880000000000000e+02 9.536809521066346e-06 40 | 4.890000000000000e+02 1.613751134314497e-05 41 | 4.900000000000000e+02 2.182002075655795e-05 42 | 4.910000000000000e+02 2.608450333834212e-05 43 | 4.920000000000000e+02 2.843031304546794e-05 44 | 4.930000000000000e+02 2.838724973751428e-05 45 | 4.940000000000000e+02 2.568922269915635e-05 46 | 4.950000000000000e+02 2.048223916093680e-05 47 | 4.960000000000000e+02 1.333425221159379e-05 48 | 4.970000000000000e+02 5.053793680331156e-06 49 | 4.980000000000000e+02 -3.508429511603460e-06 50 | 4.990000000000000e+02 -1.157264878873160e-05 51 | 5.000000000000000e+02 -1.846115631344439e-05 52 | 5.010000000000000e+02 -2.360335481382874e-05 53 | 5.020000000000000e+02 -2.658437515882760e-05 54 | 5.030000000000000e+02 -2.725607435197453e-05 55 | 5.040000000000000e+02 -2.580458414435725e-05 56 | 5.050000000000000e+02 -2.263608318970331e-05 57 | 5.060000000000000e+02 -1.815706899345884e-05 58 | 5.070000000000000e+02 -1.266434779670163e-05 59 | 5.080000000000000e+02 -6.387371784869863e-06 60 | 5.090000000000000e+02 4.244407336404824e-07 61 | 5.100000000000000e+02 7.443038193736560e-06 62 | 5.110000000000000e+02 1.425167646549306e-05 63 | 5.120000000000000e+02 2.036433962160149e-05 64 | 5.130000000000000e+02 2.524358894952369e-05 65 | 5.140000000000000e+02 2.830437368805902e-05 66 | 5.150000000000000e+02 2.897663035561929e-05 67 | 5.160000000000000e+02 2.690660533675487e-05 68 | 5.170000000000000e+02 2.217133873433175e-05 69 | 5.180000000000000e+02 1.529733068808118e-05 70 | 5.190000000000000e+02 7.088452668375406e-06 71 | 5.200000000000000e+02 -1.575910488072387e-06 72 | 5.210000000000000e+02 -9.868615413825560e-06 73 | 5.220000000000000e+02 -1.706401779654809e-05 74 | 5.230000000000000e+02 -2.256008898664583e-05 75 | 5.240000000000000e+02 -2.593407142669193e-05 76 | 5.250000000000000e+02 -2.703874360608231e-05 77 | 5.260000000000000e+02 -2.604746384632076e-05 78 | 5.270000000000000e+02 -2.333933987042256e-05 79 | 5.280000000000000e+02 -1.929600232190184e-05 80 | 5.290000000000000e+02 -1.419302759755857e-05 81 | 5.300000000000000e+02 -8.232002802212332e-06 82 | 5.310000000000000e+02 -1.622885110607881e-06 83 | 5.320000000000000e+02 5.353562561434123e-06 84 | 5.330000000000000e+02 1.232086183660592e-05 85 | 5.340000000000000e+02 1.880651736000498e-05 86 | 5.350000000000000e+02 2.424395659573284e-05 87 | 5.360000000000000e+02 2.798132116135976e-05 88 | 5.370000000000000e+02 2.936395155908907e-05 89 | 5.380000000000000e+02 2.795078473672442e-05 90 | 5.390000000000000e+02 2.373778892195217e-05 91 | 5.400000000000000e+02 1.719536220059898e-05 92 | 5.410000000000000e+02 9.112706617809450e-06 93 | 5.420000000000000e+02 3.931433477645830e-07 94 | 5.430000000000000e+02 -8.090847879962364e-06 95 | 5.440000000000000e+02 -1.556816876270840e-05 96 | 5.450000000000000e+02 -2.140813617861450e-05 97 | 5.460000000000000e+02 -2.517757665512662e-05 98 | 5.470000000000000e+02 -2.672108191243155e-05 99 | 5.480000000000000e+02 -2.619101400006055e-05 100 | 5.490000000000000e+02 -2.394001985415214e-05 101 | 5.500000000000000e+02 -2.033091276291287e-05 102 | 5.510000000000000e+02 -1.562413344436008e-05 103 | 5.520000000000000e+02 -9.995517312854793e-06 104 | 5.530000000000000e+02 -3.615347735119708e-06 105 | 5.540000000000000e+02 3.282044729988664e-06 106 | 5.550000000000000e+02 1.035895385676311e-05 107 | 5.560000000000000e+02 1.715860195365494e-05 108 | 5.570000000000000e+02 2.309505113603389e-05 109 | 5.580000000000000e+02 2.746639371880648e-05 110 | 5.590000000000000e+02 2.954885566522238e-05 111 | 5.600000000000000e+02 2.881573293452681e-05 112 | 5.610000000000000e+02 2.517128632229331e-05 113 | 5.620000000000000e+02 1.901625010750225e-05 114 | 5.630000000000000e+02 1.111506428431345e-05 115 | 5.640000000000000e+02 2.389265932974268e-06 116 | 5.650000000000000e+02 -6.246995286818541e-06 117 | 5.660000000000000e+02 -1.398073203169008e-05 118 | 5.670000000000000e+02 -2.015435152091580e-05 119 | 5.680000000000000e+02 -2.432027303902358e-05 120 | 5.690000000000000e+02 -2.630590513345423e-05 121 | 5.700000000000000e+02 -2.623583059323347e-05 122 | 5.710000000000000e+02 -2.443703196159337e-05 123 | 5.720000000000000e+02 -2.125982038627137e-05 124 | 5.730000000000000e+02 -1.695403687871968e-05 125 | 5.740000000000000e+02 -1.167164390138396e-05 126 | 5.750000000000000e+02 -5.543786231576184e-06 127 | 5.760000000000000e+02 1.239751080370859e-06 128 | 5.770000000000000e+02 8.379071731804079e-06 129 | 5.780000000000000e+02 1.543322679100780e-05 130 | 5.790000000000000e+02 2.180736907963714e-05 131 | 5.800000000000000e+02 2.676711042590767e-05 132 | 5.810000000000000e+02 2.953366580280036e-05 133 | 5.820000000000000e+02 2.949737954100782e-05 134 | 5.830000000000000e+02 2.646270017496790e-05 135 | 5.840000000000000e+02 2.074841588367283e-05 136 | 5.850000000000000e+02 1.308392426801976e-05 137 | 5.860000000000000e+02 4.402265499549341e-06 138 | 5.870000000000000e+02 -4.345733265891434e-06 139 | 5.880000000000000e+02 -1.230944204883278e-05 140 | 5.890000000000000e+02 -1.880527503617503e-05 141 | 5.900000000000000e+02 -2.336633572385539e-05 142 | 5.910000000000000e+02 -2.579463630081795e-05 143 | 5.920000000000000e+02 -2.618167900342672e-05 144 | 5.930000000000000e+02 -2.482971487374740e-05 145 | 5.940000000000000e+02 -2.208140859245097e-05 146 | 5.950000000000000e+02 -1.818034712775719e-05 147 | 5.960000000000000e+02 -1.325633177925810e-05 148 | 5.970000000000000e+02 -7.401770740789238e-06 149 | 5.980000000000000e+02 -7.638181789845893e-07 150 | 5.990000000000000e+02 6.391453821002121e-06 151 | 6.000000000000000e+02 1.364179527770917e-05 152 | 6.010000000000000e+02 2.039288595216171e-05 153 | 6.020000000000000e+02 2.589346037253662e-05 154 | 6.030000000000000e+02 2.932315096552258e-05 155 | 6.040000000000000e+02 2.999403813422920e-05 156 | 6.050000000000000e+02 2.760443574024212e-05 157 | 6.060000000000000e+02 2.238071604853015e-05 158 | 6.070000000000000e+02 1.500736055203793e-05 159 | 6.080000000000000e+02 6.421203735320754e-06 160 | 6.090000000000000e+02 -2.396646094466841e-06 161 | 6.100000000000000e+02 -1.056241369448529e-05 162 | 6.110000000000000e+02 -1.736667347094849e-05 163 | 6.120000000000000e+02 -2.231837801954060e-05 164 | 6.130000000000000e+02 -2.518728801705321e-05 165 | 6.140000000000000e+02 -2.602745263076964e-05 166 | 6.150000000000000e+02 -2.511695963237536e-05 167 | 6.160000000000000e+02 -2.279498253608990e-05 168 | 6.170000000000000e+02 -1.930221907293692e-05 169 | 6.180000000000000e+02 -1.474702763913191e-05 170 | 6.190000000000000e+02 -9.184833061780012e-06 171 | 6.200000000000000e+02 -2.722904494582745e-06 172 | 6.210000000000000e+02 4.404434894346178e-06 173 | 6.220000000000000e+02 1.179517503200858e-05 174 | 6.230000000000000e+02 1.886409645832031e-05 175 | 6.240000000000000e+02 2.485709942800738e-05 176 | 6.250000000000000e+02 2.892475793155644e-05 177 | 6.260000000000000e+02 3.030599931372156e-05 178 | 6.270000000000000e+02 2.859022446693387e-05 179 | 6.280000000000000e+02 2.390251460438834e-05 180 | 6.290000000000000e+02 1.687313149861364e-05 181 | 6.300000000000000e+02 8.434281538436364e-06 182 | 6.310000000000000e+02 -4.099750790989179e-07 183 | 6.320000000000000e+02 -8.747803208879800e-06 184 | 6.330000000000000e+02 -1.584357081179339e-05 185 | 6.340000000000000e+02 -2.117763059253149e-05 186 | 6.350000000000000e+02 -2.448217070173991e-05 187 | 6.360000000000000e+02 -2.577053738555476e-05 188 | 6.370000000000000e+02 -2.529683320022103e-05 189 | 6.380000000000000e+02 -2.339958223857406e-05 190 | 6.390000000000000e+02 -2.031946045436622e-05 191 | 6.400000000000000e+02 -1.614390437241818e-05 192 | 6.410000000000000e+02 -1.089195768056450e-05 193 | 6.420000000000000e+02 -4.634234558411915e-06 194 | 6.430000000000000e+02 2.423878939868885e-06 195 | 6.440000000000000e+02 9.902850264064457e-06 196 | 6.450000000000000e+02 1.723418889179904e-05 197 | 6.460000000000000e+02 2.367134944868602e-05 198 | 6.470000000000000e+02 2.834758910037839e-05 199 | 6.480000000000000e+02 3.043573622851173e-05 200 | 6.490000000000000e+02 2.941526957262477e-05 201 | -------------------------------------------------------------------------------- /julia_version/TTVFast.c: -------------------------------------------------------------------------------- 1 | /*If you make use of this code, please cite Deck, Agol, Holman & Nesvorny, 2 | 2014 ApJ, 787, 132, arXiv:1403.1895 */ 3 | 4 | // Main TTVFast file, which takes in the initial conditions, masses, G, timestep, t0, total amount of time, number of planets, number of RV measurements, size of Transit structure, and the RV and Transit structures. This is where the integration is formed & the transit times, rsky & vsky at transit, and RV at an observation time are calculated. Note that things called "helio" or "heliocentric" really should be "astrocentric". 5 | 6 | #define PI 3.14159265358979323846 7 | #define TWOPI 6.283185307179586476925287 8 | #define MAX_N_PLANETS 9 9 | #include"myintegrator.h" 10 | #include"transit.h" 11 | #define TOLERANCE 1e-10 12 | #define MAX_ITER 35 13 | #define BAD_TRANSIT -1 14 | int bad_transit_flag; 15 | PhaseState rp[MAX_N_PLANETS]; /* real coordinates */ 16 | PhaseState p[MAX_N_PLANETS]; /* map coordinates */ 17 | PhaseState temporary; 18 | PhaseState p_tmp[MAX_N_PLANETS]; 19 | PhaseState helioAhead[MAX_N_PLANETS]; 20 | PhaseState helioBehind[MAX_N_PLANETS]; 21 | 22 | PhaseState rp_tmp[MAX_N_PLANETS]; 23 | PhaseState p_RV[MAX_N_PLANETS]; 24 | PhaseState p_ahead[MAX_N_PLANETS]; 25 | PhaseState p_behind[MAX_N_PLANETS]; 26 | PhaseState rp_ahead[MAX_N_PLANETS]; 27 | PhaseState rp_behind[MAX_N_PLANETS]; 28 | 29 | double G; 30 | double GMsun; 31 | double GM[MAX_N_PLANETS]; 32 | double GJM[MAX_N_PLANETS]; 33 | double kc[MAX_N_PLANETS]; 34 | double kc_helio[MAX_N_PLANETS]; 35 | double m_eta[MAX_N_PLANETS]; 36 | double mm[MAX_N_PLANETS]; 37 | double Geta[MAX_N_PLANETS]; 38 | double guess[MAX_N_PLANETS][3]; 39 | double factor1[MAX_N_PLANETS], factor2[MAX_N_PLANETS]; 40 | double prev_dot[MAX_N_PLANETS],curr_dot[MAX_N_PLANETS],curr_z[MAX_N_PLANETS]; 41 | int count[MAX_N_PLANETS]; 42 | 43 | double tdot_result,dotA,dotB,TimeA,TimeB,RVTime; 44 | int tplanet; 45 | double dt; 46 | int n_planets; 47 | double Time; 48 | double machine_epsilon; 49 | #include "ttv-map-jacobi.c" 50 | #include "kepcart2.c" 51 | #include "machine-epsilon.c" 52 | 53 | void TTVFast(double *params,double dt, double Time, double total,int n_plan,CalcTransit *transit,CalcRV *RV_struct, int nRV, int n_events, int input_flag) 54 | { 55 | n_planets=n_plan; 56 | int planet; 57 | int i, j; 58 | j=0; 59 | void jacobi_heliocentric(PhaseState *jacobi, PhaseState *helio, double GMsun, double *GM); 60 | double dot0,dot1,dot2,rskyA,rskyB,vprojA,vprojB,rsky,vproj,velocity,new_dt; 61 | double compute_RV(PhaseState *ps); 62 | double compute_deriv(PhaseState ps,int planet); 63 | int RV_count = 0; 64 | int k=0; 65 | double deriv; 66 | double dt2 = dt/2.0; 67 | 68 | if(RV_struct !=NULL){ 69 | RV_count = nRV; 70 | } 71 | 72 | machine_epsilon = determine_machine_epsilon(); 73 | if(input_flag ==0){ 74 | read_jacobi_planet_elements(params); 75 | } 76 | if(input_flag ==1){ 77 | read_helio_planet_elements(params); 78 | } 79 | if(input_flag ==2){ 80 | read_helio_cartesian_params(params); 81 | } 82 | if(input_flag !=0 && input_flag !=1 && input_flag !=2){ 83 | printf("Input flag must be 0,1, or 2. \n"); 84 | exit(-1); 85 | } 86 | 87 | copy_system(p, rp); 88 | compute_corrector_coefficientsTO(dt); 89 | real_to_mapTO(rp, p); 90 | 91 | for(i = 0;i(RV_struct+j)->time && RVTime-dt<(RV_struct+j)->time){ 110 | if(RVTime-(RV_struct+j)->time > (RV_struct+j)->time-(RVTime-dt)){ 111 | copy_system(p_tmp,p_RV); 112 | new_dt= (RV_struct+j)->time-(RVTime-dt); 113 | A(p_RV,new_dt); 114 | velocity = compute_RV(p_RV); 115 | (RV_struct+j)->RV =velocity; 116 | 117 | }else{ 118 | copy_system(p,p_RV); 119 | new_dt= (RV_struct+j)->time-RVTime; 120 | A(p_RV,new_dt); 121 | velocity = compute_RV(p_RV); 122 | (RV_struct+j)->RV =velocity; 123 | } 124 | j++; 125 | } 126 | } 127 | 128 | /* now look for transits */ 129 | 130 | for(i = 0;i0 && curr_z[tplanet]>0){ 136 | bad_transit_flag = 0; 137 | copy_system(p,p_ahead); 138 | copy_system(p_tmp,p_behind); 139 | A(p_ahead,-dt2); 140 | A(p_behind,-dt2); 141 | jacobi_heliocentric(p_behind,helioBehind,GMsun,GM); 142 | jacobi_heliocentric(p_ahead,helioAhead,GMsun,GM); 143 | 144 | /* Calculate Rsky.Vsky */ 145 | dot2 = helioAhead[tplanet].x*helioAhead[tplanet].xd+helioAhead[tplanet].y*helioAhead[tplanet].yd; 146 | dot1 = helioBehind[tplanet].x*helioBehind[tplanet].xd+helioBehind[tplanet].y*helioBehind[tplanet].yd; 147 | 148 | if(dot1 < 0 && dot2 >0){ 149 | /* If Rsky.Vsky passed through zero*/ 150 | TimeA=Time; 151 | TimeB = Time-dt; 152 | dotA= TimeA+kepler_transit_locator(kc_helio[tplanet],-dt,&helioAhead[tplanet],&temporary); 153 | 154 | deriv = compute_deriv(temporary,tplanet); 155 | 156 | if(deriv < 0.0 || temporary.z <0.0 || dotA < TimeB-PI/mm[tplanet] || dotA > TimeA+PI/mm[tplanet]){ /* was the right root found?*/ 157 | dotA= TimeA+bisection(kc_helio[tplanet],&helioAhead[tplanet],&helioBehind[tplanet],&temporary); 158 | } 159 | 160 | rskyA = sqrt(temporary.x*temporary.x + temporary.y*temporary.y); 161 | vprojA = sqrt(temporary.xd*temporary.xd + temporary.yd*temporary.yd); 162 | 163 | dotB= TimeB+kepler_transit_locator(kc_helio[tplanet],dt,&helioBehind[tplanet],&temporary); 164 | 165 | deriv = compute_deriv(temporary,tplanet); 166 | 167 | if(deriv < 0.0 || temporary.z <0.0 || dotB < TimeB-PI/mm[tplanet] || dotB > TimeA+PI/mm[tplanet]){ /* was the right root found?*/ 168 | dotB= TimeB+bisection(kc_helio[tplanet],&helioBehind[tplanet],&helioAhead[tplanet],&temporary); 169 | } 170 | 171 | rskyB = sqrt(temporary.x*temporary.x + temporary.y*temporary.y); 172 | vprojB = sqrt(temporary.xd*temporary.xd + temporary.yd*temporary.yd); 173 | 174 | tdot_result = ((dotB-TimeB)*dotA+(TimeA-dotA)*dotB)/(TimeA-TimeB-dotA+dotB); 175 | 176 | rsky = ((dotB-TimeB)*rskyA+(TimeA-dotA)*rskyB)/(TimeA-TimeB-dotA+dotB); 177 | vproj = ((dotB-TimeB)*vprojA+(TimeA-dotA)*vprojB)/(TimeA-TimeB-dotA+dotB); 178 | }else{ 179 | 180 | copy_system(helioAhead,helioBehind); 181 | copy_system(p,p_ahead); 182 | B(p_ahead,dt); 183 | A(p_ahead,dt2); 184 | TimeA=Time+dt; 185 | TimeB = Time; 186 | jacobi_heliocentric(p_ahead,helioAhead,GMsun,GM); 187 | dotB= TimeB+kepler_transit_locator(kc_helio[tplanet],dt,&helioBehind[tplanet],&temporary); 188 | 189 | deriv = compute_deriv(temporary,tplanet); 190 | 191 | if(deriv < 0.0 || temporary.z <0.0 || dotB < TimeB-PI/mm[tplanet] || dotB > TimeA+PI/mm[tplanet]){ /* was the right root found?*/ 192 | dotB= TimeB+bisection(kc_helio[tplanet],&helioBehind[tplanet],&helioAhead[tplanet],&temporary); 193 | } 194 | 195 | rskyB = sqrt(temporary.x*temporary.x + temporary.y*temporary.y); 196 | vprojB = sqrt(temporary.xd*temporary.xd + temporary.yd*temporary.yd); 197 | 198 | dotA= TimeA+kepler_transit_locator(kc_helio[tplanet],-dt,&helioAhead[tplanet],&temporary); 199 | 200 | deriv = compute_deriv(temporary,tplanet); 201 | 202 | if(deriv < 0.0 || temporary.z <0.0 || dotA < TimeB-PI/mm[tplanet] || dotA > TimeA+PI/mm[tplanet]){ /* was the right root found?*/ 203 | dotA= TimeA+bisection(kc_helio[tplanet],&helioAhead[tplanet],&helioBehind[tplanet],&temporary); 204 | } 205 | 206 | rskyA = sqrt(temporary.x*temporary.x + temporary.y*temporary.y); 207 | vprojA = sqrt(temporary.xd*temporary.xd + temporary.yd*temporary.yd); 208 | 209 | tdot_result = ((dotB-TimeB)*dotA+(TimeA-dotA)*dotB)/(TimeA-TimeB-dotA+dotB); 210 | rsky = ((dotB-TimeB)*rskyA+(TimeA-dotA)*rskyB)/(TimeA-TimeB-dotA+dotB); 211 | vproj = ((dotB-TimeB)*vprojA+(TimeA-dotA)*vprojB)/(TimeA-TimeB-dotA+dotB); 212 | } 213 | if(k< n_events){ 214 | 215 | if(bad_transit_flag ==0){ 216 | (transit+k)->planet = tplanet; 217 | (transit+k)->epoch = count[tplanet]; 218 | (transit+k)->time = tdot_result; 219 | (transit+k)->rsky = rsky; 220 | (transit+k)->vsky = vproj; 221 | }else{ 222 | (transit+k)->planet = tplanet; 223 | (transit+k)->epoch = count[tplanet]; 224 | (transit+k)->time = BAD_TRANSIT; 225 | (transit+k)->rsky = BAD_TRANSIT; 226 | (transit+k)->vsky = BAD_TRANSIT; 227 | } 228 | count[tplanet]++; 229 | k++; 230 | }else{ 231 | printf("Not enough memory allocated for Transit structure: more events triggering as transits than expected. Possibily indicative of larger problem.\n"); 232 | exit(-1); 233 | } 234 | } 235 | 236 | prev_dot[i]=curr_dot[i]; 237 | } 238 | } 239 | } 240 | 241 | 242 | 243 | 244 | read_jacobi_planet_elements(params) 245 | double *params; 246 | { 247 | int planet; 248 | double solar_mass, GMplanet; 249 | double Getatmp, Getatmp0; 250 | double period,e,incl,longnode,argperi,MeanAnom; 251 | double a; 252 | G = params[0]; 253 | GMsun = params[1]*G; 254 | 255 | planet = 0; 256 | 257 | Getatmp = GMsun; 258 | 259 | while(planet < n_planets){ 260 | GM[planet] = params[planet*7+2]; 261 | GM[planet] *= G; 262 | 263 | Getatmp0 = Getatmp; 264 | Getatmp += GM[planet]; 265 | factor1[planet] = 1.0/Getatmp0; 266 | factor2[planet] = Getatmp/Getatmp0; 267 | GJM[planet] = GM[planet]/factor2[planet]; 268 | Geta[planet] = Getatmp; 269 | kc[planet] = GMsun*factor2[planet]; 270 | kc_helio[planet] = GMsun+GM[planet]; 271 | m_eta[planet] = GM[planet]/Geta[planet]; 272 | period = params[planet*7+3]; 273 | e = params[planet*7+4]; 274 | incl = params[planet*7+5]; 275 | longnode = params[planet*7+6]; 276 | argperi = params[planet*7+7]; 277 | MeanAnom = params[planet*7+8]; 278 | mm[planet] = 2*PI/period; 279 | a = pow(mm[planet]*mm[planet]/kc[planet],-1.0/3.0); 280 | incl *= PI/180.0; 281 | longnode *= PI/180.0; 282 | argperi *= PI/180.0; 283 | MeanAnom *=PI/180.0; 284 | guess[planet][0] = mm[planet]*dt; 285 | guess[planet][1] = mm[planet]*dt; 286 | guess[planet][2] = mm[planet]*dt; 287 | cartesian(kc[planet],a,e,incl,longnode,argperi,MeanAnom,&p[planet]); 288 | planet += 1; 289 | 290 | if(planet > MAX_N_PLANETS) { 291 | printf("too many planets: %d\n", planet); 292 | exit(-1); 293 | } 294 | } 295 | } 296 | 297 | 298 | 299 | read_helio_planet_elements(params) 300 | double *params; 301 | { 302 | int planet; 303 | double solar_mass, GMplanet; 304 | double Getatmp, Getatmp0; 305 | double period,e,incl,longnode,argperi,MeanAnom; 306 | double a; 307 | void heliocentric_jacobi(PhaseState *helio, PhaseState *jacobi, double GMsun, double *GM); 308 | PhaseState helio[MAX_N_PLANETS]; 309 | G = params[0]; 310 | GMsun = params[1]*G; 311 | 312 | planet = 0; 313 | 314 | Getatmp = GMsun; 315 | 316 | while(planet < n_planets){ 317 | GM[planet] = params[planet*7+2]; 318 | GM[planet] *= G; 319 | 320 | Getatmp0 = Getatmp; 321 | Getatmp += GM[planet]; 322 | factor1[planet] = 1.0/Getatmp0; 323 | factor2[planet] = Getatmp/Getatmp0; 324 | GJM[planet] = GM[planet]/factor2[planet]; 325 | Geta[planet] = Getatmp; 326 | kc[planet] = GMsun*factor2[planet]; 327 | kc_helio[planet] = GMsun+GM[planet]; 328 | m_eta[planet] = GM[planet]/Geta[planet]; 329 | period = params[planet*7+3]; 330 | e = params[planet*7+4]; 331 | incl = params[planet*7+5]; 332 | longnode = params[planet*7+6]; 333 | argperi = params[planet*7+7]; 334 | MeanAnom = params[planet*7+8]; 335 | mm[planet] = 2*PI/period; 336 | a = pow(mm[planet]*mm[planet]/kc[planet],-1.0/3.0); 337 | incl *= PI/180.0; 338 | longnode *= PI/180.0; 339 | argperi *= PI/180.0; 340 | MeanAnom *=PI/180.0; 341 | guess[planet][0] = mm[planet]*dt; 342 | guess[planet][1] = mm[planet]*dt; 343 | guess[planet][2] = mm[planet]*dt; 344 | cartesian(kc_helio[planet],a,e,incl,longnode,argperi,MeanAnom,&helio[planet]); 345 | planet += 1; 346 | 347 | if(planet > MAX_N_PLANETS) { 348 | printf("too many planets: %d\n", planet); 349 | exit(-1); 350 | } 351 | } 352 | heliocentric_jacobi(helio,p,GMsun,GM); 353 | 354 | } 355 | 356 | 357 | read_helio_cartesian_params(params) 358 | double *params; 359 | { 360 | int planet; 361 | double solar_mass, GMplanet; 362 | double Getatmp, Getatmp0; 363 | double a,r,vs,u; 364 | void heliocentric_jacobi(PhaseState *helio, PhaseState *jacobi, double GMsun, double *GM); 365 | PhaseState helio[MAX_N_PLANETS]; 366 | G = params[0]; 367 | GMsun = params[1]*G; 368 | 369 | planet = 0; 370 | 371 | Getatmp = GMsun; 372 | 373 | while(planet < n_planets){ 374 | GM[planet] = params[planet*7+2]; 375 | GM[planet]*=G; 376 | Getatmp0 = Getatmp; 377 | Getatmp += GM[planet]; 378 | factor1[planet] = 1.0/Getatmp0; 379 | factor2[planet] = Getatmp/Getatmp0; 380 | GJM[planet] = GM[planet]/factor2[planet]; 381 | Geta[planet] = Getatmp; 382 | kc[planet] = GMsun*factor2[planet]; 383 | kc_helio[planet] = GMsun+GM[planet]; 384 | m_eta[planet] = GM[planet]/Geta[planet]; 385 | helio[planet].x = params[planet*7+3]; 386 | helio[planet].xd = params[planet*7+3+3]; 387 | helio[planet].y = params[planet*7+4]; 388 | helio[planet].yd = params[planet*7+4+3]; 389 | helio[planet].z = params[planet*7+5]; 390 | helio[planet].zd = params[planet*7+5+3]; 391 | r = sqrt(helio[planet].x*helio[planet].x + helio[planet].y*helio[planet].y + helio[planet].z*helio[planet].z); 392 | vs = helio[planet].xd*helio[planet].xd + helio[planet].yd*helio[planet].yd + helio[planet].zd*helio[planet].zd; 393 | u = helio[planet].x*helio[planet].xd + helio[planet].y*helio[planet].yd + helio[planet].z*helio[planet].zd; 394 | a = 1.0/(2.0/r - vs/kc_helio[planet]); 395 | mm[planet] = sqrt(kc_helio[planet]/(a*a*a)); 396 | guess[planet][0] = mm[planet]*dt; 397 | guess[planet][1] = mm[planet]*dt; 398 | guess[planet][2] = mm[planet]*dt; 399 | planet += 1; 400 | 401 | if(planet > MAX_N_PLANETS) { 402 | printf("too many planets: %d\n", planet); 403 | exit(-1); 404 | } 405 | } 406 | heliocentric_jacobi(helio,p,GMsun,GM); 407 | } 408 | 409 | 410 | void jacobi_heliocentric(PhaseState *jacobi, PhaseState *helio, double GMsun, double *GM) 411 | { 412 | int i; 413 | double GetaC, GM_over_Geta; 414 | PhaseState s; 415 | s.x = 0.0; s.y = 0.0; s.z = 0.0; 416 | s.xd = 0.0; s.yd = 0.0; s.zd = 0.0; 417 | 418 | 419 | GetaC = GMsun; 420 | 421 | for(i=0; ix = (jacobi+i)->x + s.x; 424 | (helio+i)->y = (jacobi+i)->y + s.y; 425 | (helio+i)->z = (jacobi+i)->z + s.z; 426 | (helio+i)->xd = (jacobi+i)->xd + s.xd; 427 | (helio+i)->yd = (jacobi+i)->yd + s.yd; 428 | (helio+i)->zd = (jacobi+i)->zd + s.zd; 429 | 430 | GetaC += GM[i]; 431 | GM_over_Geta = GM[i]/GetaC; 432 | 433 | s.x += GM_over_Geta * (jacobi+i)->x; 434 | s.y += GM_over_Geta * (jacobi+i)->y; 435 | s.z += GM_over_Geta * (jacobi+i)->z; 436 | s.xd += GM_over_Geta * (jacobi+i)->xd; 437 | s.yd += GM_over_Geta * (jacobi+i)->yd; 438 | s.zd += GM_over_Geta * (jacobi+i)->zd; 439 | } 440 | 441 | 442 | 443 | 444 | } 445 | 446 | double compute_deriv(PhaseState s, int planet) 447 | { 448 | double deriv; /* Deriv of x*xd+y*yd = vsky^2+rsky.asky*/ 449 | deriv = s.xd*s.xd+s.yd*s.yd-kc_helio[planet]/pow(s.x*s.x+s.y*s.y+s.z*s.z,3.0/2.0)*(s.x*s.x+s.y*s.y); 450 | 451 | return(deriv); 452 | } 453 | 454 | double compute_RV(PhaseState *ps) 455 | { 456 | void jacobi_heliocentric(PhaseState *jacobiS, PhaseState *helioS, double GMsunS, double *GMS); 457 | PhaseState sun,helio[MAX_N_PLANETS]; 458 | jacobi_heliocentric(ps,helio,GMsun,GM); 459 | 460 | int i; 461 | double mtotal=GMsun; 462 | sun.x = 0.0; sun.y = 0.0; sun.z = 0.0; 463 | sun.xd = 0.0; sun.yd = 0.0; sun.zd = 0.0; 464 | for(i=0;ix; 466 | sun.xd+=-GM[i]*(helio+i)->xd; 467 | sun.y +=-GM[i]*(helio+i)->y; 468 | sun.yd+=-GM[i]*(helio+i)->yd; 469 | sun.z +=-GM[i]*(helio+i)->z; 470 | sun.zd+=-GM[i]*(helio+i)->zd; 471 | mtotal+=GM[i]; 472 | } 473 | sun.x /= mtotal; 474 | sun.y /= mtotal; 475 | sun.z /= mtotal; 476 | sun.xd /= mtotal; 477 | sun.yd /= mtotal; 478 | sun.zd /= mtotal; 479 | 480 | return(-sun.zd); /* in keeping with convention */ 481 | } 482 | 483 | 484 | void heliocentric_jacobi(PhaseState *helio, PhaseState *jacobi, double GMsun, double *GM) 485 | { 486 | int i; 487 | double mass, over_mass; 488 | PhaseState s; 489 | 490 | mass = 0.0; 491 | s.x = 0.0; s.y = 0.0; s.z = 0.0; 492 | s.xd = 0.0; s.yd = 0.0; s.zd = 0.0; 493 | 494 | mass = GMsun; 495 | over_mass = 1.0/GMsun; 496 | 497 | for(i=0; ix = (helio+i)->x - s.x * over_mass; 499 | (jacobi+i)->y = (helio+i)->y - s.y * over_mass; 500 | (jacobi+i)->z = (helio+i)->z - s.z * over_mass; 501 | (jacobi+i)->xd = (helio+i)->xd - s.xd * over_mass; 502 | (jacobi+i)->yd = (helio+i)->yd - s.yd * over_mass; 503 | (jacobi+i)->zd = (helio+i)->zd - s.zd * over_mass; 504 | 505 | s.x += GM[i] * (helio+i)->x; 506 | s.y += GM[i] * (helio+i)->y; 507 | s.z += GM[i] * (helio+i)->z; 508 | s.xd += GM[i] * (helio+i)->xd; 509 | s.yd += GM[i] * (helio+i)->yd; 510 | s.zd += GM[i] * (helio+i)->zd; 511 | 512 | mass += GM[i]; 513 | over_mass = 1.0/mass; 514 | } 515 | } 516 | 517 | 518 | 519 | -------------------------------------------------------------------------------- /julia_version/TTVFast.jl: -------------------------------------------------------------------------------- 1 | # *If you make use of this code, please cite Deck, Agol, Holman & Nesvorny, 2 | # 2014 ApJ, 787, 132, arXiv:1403.1895 */ 3 | 4 | #/ Main TTVFast file, which takes in the initial conditions, masses, G, timestep, t0, total amount of time, number of planets, number of RV measurements, size of Transit structure, and the RV and Transit structures. This is where the integration is formed & the transit times, rsky & vsky at transit, and RV at an observation time are calculated. Note that things called "helio" or "heliocentric" really should be "astrocentric". 5 | 6 | #define MAX_N_PLANETS 9 7 | #include"myintegrator.h" 8 | #include"transit.h" 9 | #define TOLERANCE 1e-10 10 | #define MAX_ITER 35 11 | #define BAD_TRANSIT -1 12 | int bad_transit_flag; 13 | PhaseState rp[MAX_N_PLANETS]; /* real coordinates */ 14 | PhaseState p[MAX_N_PLANETS]; /* map coordinates */ 15 | PhaseState temporary; 16 | PhaseState p_tmp[MAX_N_PLANETS]; 17 | PhaseState helioAhead[MAX_N_PLANETS]; 18 | PhaseState helioBehind[MAX_N_PLANETS]; 19 | 20 | PhaseState rp_tmp[MAX_N_PLANETS]; 21 | PhaseState p_RV[MAX_N_PLANETS]; 22 | PhaseState p_ahead[MAX_N_PLANETS]; 23 | PhaseState p_behind[MAX_N_PLANETS]; 24 | PhaseState rp_ahead[MAX_N_PLANETS]; 25 | PhaseState rp_behind[MAX_N_PLANETS]; 26 | 27 | double G; 28 | double GMsun; 29 | double GM[MAX_N_PLANETS]; 30 | double GJM[MAX_N_PLANETS]; 31 | double kc[MAX_N_PLANETS]; 32 | double kc_helio[MAX_N_PLANETS]; 33 | double m_eta[MAX_N_PLANETS]; 34 | double mm[MAX_N_PLANETS]; 35 | double Geta[MAX_N_PLANETS]; 36 | double guess[MAX_N_PLANETS][3]; 37 | double factor1[MAX_N_PLANETS], factor2[MAX_N_PLANETS]; 38 | double prev_dot[MAX_N_PLANETS],curr_dot[MAX_N_PLANETS],curr_z[MAX_N_PLANETS]; 39 | int count[MAX_N_PLANETS]; 40 | 41 | double tdot_result,dotA,dotB,TimeA,TimeB,RVTime; 42 | int tplanet; 43 | double dt; 44 | int n_planets; 45 | double Time; 46 | double machine_epsilon; 47 | #include "ttv-map-jacobi.c" 48 | #include "kepcart2.c" 49 | #include "machine-epsilon.c" 50 | 51 | #void TTVFast(double *params,double dt, double Time, double total,int n_plan,CalcTransit *transit,CalcRV *RV_struct, int nRV, int n_events, int input_flag) 52 | function TTVFast(Real::params,Real::dt,Real::Time,Real::total,Integer::n_plan,CalcTransit::transit,CalcRV::RV_struct,Integer:nRV,Integer::n_events,Integer::input_flag) 53 | 54 | n_planets=n_plan; 55 | # int planet; 56 | # int i, j; 57 | j=0; 58 | void jacobi_heliocentric(PhaseState *jacobi, PhaseState *helio, double GMsun, double *GM); 59 | double dot0,dot1,dot2,rskyA,rskyB,vprojA,vprojB,rsky,vproj,velocity,new_dt; 60 | double compute_RV(PhaseState *ps); 61 | double compute_deriv(PhaseState ps,int planet); 62 | int RV_count = 0; 63 | int k=0; 64 | double deriv; 65 | double dt2 = dt/2.0; 66 | 67 | if (RV_struct !=NULL) 68 | RV_count = nRV 69 | end 70 | 71 | # machine_epsilon = determine_machine_epsilon(); 72 | if (input_flag ==0) 73 | read_jacobi_planet_elements(params); 74 | end 75 | if (input_flag ==1) 76 | read_helio_planet_elements(params); 77 | end 78 | if (input_flag ==2) 79 | read_helio_cartesian_params(params); 80 | end 81 | if (input_flag !=0 && input_flag !=1 && input_flag !=2) 82 | printf("Input flag must be 0,1, or 2. \n"); 83 | exit(-1); 84 | end 85 | 86 | copy_system(p, rp); 87 | compute_corrector_coefficientsTO(dt); 88 | real_to_mapTO(rp, p); 89 | 90 | for(i = 0;i(RV_struct+j)->time && RVTime-dt<(RV_struct+j)->time){ 109 | if(RVTime-(RV_struct+j)->time > (RV_struct+j)->time-(RVTime-dt)){ 110 | copy_system(p_tmp,p_RV); 111 | new_dt= (RV_struct+j)->time-(RVTime-dt); 112 | A(p_RV,new_dt); 113 | velocity = compute_RV(p_RV); 114 | (RV_struct+j)->RV =velocity; 115 | 116 | }else{ 117 | copy_system(p,p_RV); 118 | new_dt= (RV_struct+j)->time-RVTime; 119 | A(p_RV,new_dt); 120 | velocity = compute_RV(p_RV); 121 | (RV_struct+j)->RV =velocity; 122 | } 123 | j++; 124 | } 125 | } 126 | 127 | /* now look for transits */ 128 | 129 | for(i = 0;i0 && curr_z[tplanet]>0){ 135 | bad_transit_flag = 0; 136 | copy_system(p,p_ahead); 137 | copy_system(p_tmp,p_behind); 138 | A(p_ahead,-dt2); 139 | A(p_behind,-dt2); 140 | jacobi_heliocentric(p_behind,helioBehind,GMsun,GM); 141 | jacobi_heliocentric(p_ahead,helioAhead,GMsun,GM); 142 | 143 | /* Calculate Rsky.Vsky */ 144 | dot2 = helioAhead[tplanet].x*helioAhead[tplanet].xd+helioAhead[tplanet].y*helioAhead[tplanet].yd; 145 | dot1 = helioBehind[tplanet].x*helioBehind[tplanet].xd+helioBehind[tplanet].y*helioBehind[tplanet].yd; 146 | 147 | if(dot1 < 0 && dot2 >0){ 148 | /* If Rsky.Vsky passed through zero*/ 149 | TimeA=Time; 150 | TimeB = Time-dt; 151 | dotA= TimeA+kepler_transit_locator(kc_helio[tplanet],-dt,&helioAhead[tplanet],&temporary); 152 | 153 | deriv = compute_deriv(temporary,tplanet); 154 | 155 | if(deriv < 0.0 || temporary.z <0.0 || dotA < TimeB-pi/mm[tplanet] || dotA > TimeA+pi/mm[tplanet]){ /* was the right root found?*/ 156 | dotA= TimeA+bisection(kc_helio[tplanet],&helioAhead[tplanet],&helioBehind[tplanet],&temporary); 157 | } 158 | 159 | rskyA = sqrt(temporary.x*temporary.x + temporary.y*temporary.y); 160 | vprojA = sqrt(temporary.xd*temporary.xd + temporary.yd*temporary.yd); 161 | 162 | dotB= TimeB+kepler_transit_locator(kc_helio[tplanet],dt,&helioBehind[tplanet],&temporary); 163 | 164 | deriv = compute_deriv(temporary,tplanet); 165 | 166 | if(deriv < 0.0 || temporary.z <0.0 || dotB < TimeB-pi/mm[tplanet] || dotB > TimeA+pi/mm[tplanet]){ /* was the right root found?*/ 167 | dotB= TimeB+bisection(kc_helio[tplanet],&helioBehind[tplanet],&helioAhead[tplanet],&temporary); 168 | } 169 | 170 | rskyB = sqrt(temporary.x*temporary.x + temporary.y*temporary.y); 171 | vprojB = sqrt(temporary.xd*temporary.xd + temporary.yd*temporary.yd); 172 | 173 | tdot_result = ((dotB-TimeB)*dotA+(TimeA-dotA)*dotB)/(TimeA-TimeB-dotA+dotB); 174 | 175 | rsky = ((dotB-TimeB)*rskyA+(TimeA-dotA)*rskyB)/(TimeA-TimeB-dotA+dotB); 176 | vproj = ((dotB-TimeB)*vprojA+(TimeA-dotA)*vprojB)/(TimeA-TimeB-dotA+dotB); 177 | }else{ 178 | 179 | copy_system(helioAhead,helioBehind); 180 | copy_system(p,p_ahead); 181 | B(p_ahead,dt); 182 | A(p_ahead,dt2); 183 | TimeA=Time+dt; 184 | TimeB = Time; 185 | jacobi_heliocentric(p_ahead,helioAhead,GMsun,GM); 186 | dotB= TimeB+kepler_transit_locator(kc_helio[tplanet],dt,&helioBehind[tplanet],&temporary); 187 | 188 | deriv = compute_deriv(temporary,tplanet); 189 | 190 | if(deriv < 0.0 || temporary.z <0.0 || dotB < TimeB-pi/mm[tplanet] || dotB > TimeA+pi/mm[tplanet]){ /* was the right root found?*/ 191 | dotB= TimeB+bisection(kc_helio[tplanet],&helioBehind[tplanet],&helioAhead[tplanet],&temporary); 192 | } 193 | 194 | rskyB = sqrt(temporary.x*temporary.x + temporary.y*temporary.y); 195 | vprojB = sqrt(temporary.xd*temporary.xd + temporary.yd*temporary.yd); 196 | 197 | dotA= TimeA+kepler_transit_locator(kc_helio[tplanet],-dt,&helioAhead[tplanet],&temporary); 198 | 199 | deriv = compute_deriv(temporary,tplanet); 200 | 201 | if(deriv < 0.0 || temporary.z <0.0 || dotA < TimeB-pi/mm[tplanet] || dotA > TimeA+pi/mm[tplanet]){ /* was the right root found?*/ 202 | dotA= TimeA+bisection(kc_helio[tplanet],&helioAhead[tplanet],&helioBehind[tplanet],&temporary); 203 | } 204 | 205 | rskyA = sqrt(temporary.x*temporary.x + temporary.y*temporary.y); 206 | vprojA = sqrt(temporary.xd*temporary.xd + temporary.yd*temporary.yd); 207 | 208 | tdot_result = ((dotB-TimeB)*dotA+(TimeA-dotA)*dotB)/(TimeA-TimeB-dotA+dotB); 209 | rsky = ((dotB-TimeB)*rskyA+(TimeA-dotA)*rskyB)/(TimeA-TimeB-dotA+dotB); 210 | vproj = ((dotB-TimeB)*vprojA+(TimeA-dotA)*vprojB)/(TimeA-TimeB-dotA+dotB); 211 | } 212 | if(k< n_events){ 213 | 214 | if(bad_transit_flag ==0){ 215 | (transit+k)->planet = tplanet; 216 | (transit+k)->epoch = count[tplanet]; 217 | (transit+k)->time = tdot_result; 218 | (transit+k)->rsky = rsky; 219 | (transit+k)->vsky = vproj; 220 | }else{ 221 | (transit+k)->planet = tplanet; 222 | (transit+k)->epoch = count[tplanet]; 223 | (transit+k)->time = BAD_TRANSIT; 224 | (transit+k)->rsky = BAD_TRANSIT; 225 | (transit+k)->vsky = BAD_TRANSIT; 226 | } 227 | count[tplanet]++; 228 | k++; 229 | }else{ 230 | printf("Not enough memory allocated for Transit structure: more events triggering as transits than expected. Possibily indicative of larger problem.\n"); 231 | exit(-1); 232 | } 233 | } 234 | 235 | prev_dot[i]=curr_dot[i]; 236 | } 237 | } 238 | } 239 | 240 | 241 | 242 | 243 | read_jacobi_planet_elements(params) 244 | double *params; 245 | { 246 | int planet; 247 | double solar_mass, GMplanet; 248 | double Getatmp, Getatmp0; 249 | double period,e,incl,longnode,argperi,MeanAnom; 250 | double a; 251 | G = params[0]; 252 | GMsun = params[1]*G; 253 | 254 | planet = 0; 255 | 256 | Getatmp = GMsun; 257 | 258 | while(planet < n_planets){ 259 | GM[planet] = params[planet*7+2]; 260 | GM[planet] *= G; 261 | 262 | Getatmp0 = Getatmp; 263 | Getatmp += GM[planet]; 264 | factor1[planet] = 1.0/Getatmp0; 265 | factor2[planet] = Getatmp/Getatmp0; 266 | GJM[planet] = GM[planet]/factor2[planet]; 267 | Geta[planet] = Getatmp; 268 | kc[planet] = GMsun*factor2[planet]; 269 | kc_helio[planet] = GMsun+GM[planet]; 270 | m_eta[planet] = GM[planet]/Geta[planet]; 271 | period = params[planet*7+3]; 272 | e = params[planet*7+4]; 273 | incl = params[planet*7+5]; 274 | longnode = params[planet*7+6]; 275 | argperi = params[planet*7+7]; 276 | MeanAnom = params[planet*7+8]; 277 | mm[planet] = 2*pi/period; 278 | a = pow(mm[planet]*mm[planet]/kc[planet],-1.0/3.0); 279 | incl *= pi/180.0; 280 | longnode *= pi/180.0; 281 | argperi *= pi/180.0; 282 | MeanAnom *=pi/180.0; 283 | guess[planet][0] = mm[planet]*dt; 284 | guess[planet][1] = mm[planet]*dt; 285 | guess[planet][2] = mm[planet]*dt; 286 | cartesian(kc[planet],a,e,incl,longnode,argperi,MeanAnom,&p[planet]); 287 | planet += 1; 288 | 289 | if(planet > MAX_N_PLANETS) { 290 | printf("too many planets: %d\n", planet); 291 | exit(-1); 292 | } 293 | } 294 | } 295 | 296 | 297 | 298 | function read_helio_planet_elements(Real::params) 299 | # double *params; 300 | 301 | # int planet; 302 | # double solar_mass, GMplanet; 303 | # double Getatmp, Getatmp0; 304 | # double period,e,incl,longnode,argperi,MeanAnom; 305 | # double a; 306 | # void heliocentric_jacobi(PhaseState *helio, PhaseState *jacobi, double GMsun, double *GM); 307 | Vector{PhaseState}::helio #[MAX_N_PLANETS]; 308 | G = params[0]; 309 | GMsun = params[1]*G; 310 | 311 | planet = 0; 312 | 313 | Getatmp = GMsun; 314 | 315 | while (planet < n_planets) 316 | GM[planet] = params[planet*7+2]; 317 | GM[planet] *= G; 318 | 319 | Getatmp0 = Getatmp; 320 | Getatmp += GM[planet]; 321 | factor1[planet] = 1.0/Getatmp0; 322 | factor2[planet] = Getatmp/Getatmp0; 323 | GJM[planet] = GM[planet]/factor2[planet]; 324 | Geta[planet] = Getatmp; 325 | kc[planet] = GMsun*factor2[planet]; 326 | kc_helio[planet] = GMsun+GM[planet]; 327 | m_eta[planet] = GM[planet]/Geta[planet]; 328 | period = params[planet*7+3]; 329 | ecc = params[planet*7+4]; 330 | incl = params[planet*7+5]; 331 | longnode = params[planet*7+6]; 332 | argperi = params[planet*7+7]; 333 | MeanAnom = params[planet*7+8]; 334 | mm[planet] = 2*pi/period; 335 | a = pow(mm[planet]*mm[planet]/kc[planet],-1.0/3.0); 336 | incl *= pi/180.0; 337 | longnode *= pi/180.0; 338 | argperi *= pi/180.0; 339 | MeanAnom *=pi/180.0; 340 | guess[planet][0] = mm[planet]*dt; 341 | guess[planet][1] = mm[planet]*dt; 342 | guess[planet][2] = mm[planet]*dt; 343 | cartesian(kc_helio[planet],a,ecc,incl,longnode,argperi,MeanAnom,&helio[planet]); 344 | planet += 1; 345 | 346 | if (planet > MAX_N_PLANETS) 347 | printf("too many planets: %d\n", planet); 348 | exit(-1); 349 | end 350 | end 351 | heliocentric_jacobi(helio,p,GMsun,GM); 352 | return 353 | end 354 | 355 | 356 | read_helio_cartesian_params(params) 357 | double *params; 358 | { 359 | int planet; 360 | double solar_mass, GMplanet; 361 | double Getatmp, Getatmp0; 362 | double a,r,vs,u; 363 | void heliocentric_jacobi(PhaseState *helio, PhaseState *jacobi, double GMsun, double *GM); 364 | PhaseState helio[MAX_N_PLANETS]; 365 | G = params[0]; 366 | GMsun = params[1]*G; 367 | 368 | planet = 0; 369 | 370 | Getatmp = GMsun; 371 | 372 | while(planet < n_planets){ 373 | GM[planet] = params[planet*7+2]; 374 | GM[planet]*=G; 375 | Getatmp0 = Getatmp; 376 | Getatmp += GM[planet]; 377 | factor1[planet] = 1.0/Getatmp0; 378 | factor2[planet] = Getatmp/Getatmp0; 379 | GJM[planet] = GM[planet]/factor2[planet]; 380 | Geta[planet] = Getatmp; 381 | kc[planet] = GMsun*factor2[planet]; 382 | kc_helio[planet] = GMsun+GM[planet]; 383 | m_eta[planet] = GM[planet]/Geta[planet]; 384 | helio[planet].x = params[planet*7+3]; 385 | helio[planet].xd = params[planet*7+3+3]; 386 | helio[planet].y = params[planet*7+4]; 387 | helio[planet].yd = params[planet*7+4+3]; 388 | helio[planet].z = params[planet*7+5]; 389 | helio[planet].zd = params[planet*7+5+3]; 390 | r = sqrt(helio[planet].x*helio[planet].x + helio[planet].y*helio[planet].y + helio[planet].z*helio[planet].z); 391 | vs = helio[planet].xd*helio[planet].xd + helio[planet].yd*helio[planet].yd + helio[planet].zd*helio[planet].zd; 392 | u = helio[planet].x*helio[planet].xd + helio[planet].y*helio[planet].yd + helio[planet].z*helio[planet].zd; 393 | a = 1.0/(2.0/r - vs/kc_helio[planet]); 394 | mm[planet] = sqrt(kc_helio[planet]/(a*a*a)); 395 | guess[planet][0] = mm[planet]*dt; 396 | guess[planet][1] = mm[planet]*dt; 397 | guess[planet][2] = mm[planet]*dt; 398 | planet += 1; 399 | 400 | if(planet > MAX_N_PLANETS) { 401 | printf("too many planets: %d\n", planet); 402 | exit(-1); 403 | } 404 | } 405 | heliocentric_jacobi(helio,p,GMsun,GM); 406 | } 407 | 408 | 409 | void jacobi_heliocentric(PhaseState *jacobi, PhaseState *helio, double GMsun, double *GM) 410 | { 411 | int i; 412 | double GetaC, GM_over_Geta; 413 | PhaseState s; 414 | s.x = 0.0; s.y = 0.0; s.z = 0.0; 415 | s.xd = 0.0; s.yd = 0.0; s.zd = 0.0; 416 | 417 | 418 | GetaC = GMsun; 419 | 420 | for(i=0; ix = (jacobi+i)->x + s.x; 423 | (helio+i)->y = (jacobi+i)->y + s.y; 424 | (helio+i)->z = (jacobi+i)->z + s.z; 425 | (helio+i)->xd = (jacobi+i)->xd + s.xd; 426 | (helio+i)->yd = (jacobi+i)->yd + s.yd; 427 | (helio+i)->zd = (jacobi+i)->zd + s.zd; 428 | 429 | GetaC += GM[i]; 430 | GM_over_Geta = GM[i]/GetaC; 431 | 432 | s.x += GM_over_Geta * (jacobi+i)->x; 433 | s.y += GM_over_Geta * (jacobi+i)->y; 434 | s.z += GM_over_Geta * (jacobi+i)->z; 435 | s.xd += GM_over_Geta * (jacobi+i)->xd; 436 | s.yd += GM_over_Geta * (jacobi+i)->yd; 437 | s.zd += GM_over_Geta * (jacobi+i)->zd; 438 | } 439 | 440 | 441 | 442 | 443 | } 444 | 445 | double compute_deriv(PhaseState s, int planet) 446 | { 447 | double deriv; /* Deriv of x*xd+y*yd = vsky^2+rsky.asky*/ 448 | deriv = s.xd*s.xd+s.yd*s.yd-kc_helio[planet]/pow(s.x*s.x+s.y*s.y+s.z*s.z,3.0/2.0)*(s.x*s.x+s.y*s.y); 449 | 450 | return(deriv); 451 | } 452 | 453 | function compute_RV(PhaseState::ps) 454 | 455 | void jacobi_heliocentric(PhaseState *jacobiS, PhaseState *helioS, double GMsunS, double *GMS); 456 | Vector{PhaseState}::sun,helio #[MAX_N_PLANETS]; 457 | jacobi_heliocentric(ps,helio,GMsun,GM); 458 | 459 | int i; 460 | Real::mtotal=GMsun; 461 | sun.x = 0.0; sun.y = 0.0; sun.z = 0.0; 462 | sun.xd = 0.0; sun.yd = 0.0; sun.zd = 0.0; 463 | for(i=0;ix; 465 | sun.xd+=-GM[i]*(helio+i)->xd; 466 | sun.y +=-GM[i]*(helio+i)->y; 467 | sun.yd+=-GM[i]*(helio+i)->yd; 468 | sun.z +=-GM[i]*(helio+i)->z; 469 | sun.zd+=-GM[i]*(helio+i)->zd; 470 | mtotal+=GM[i]; 471 | } 472 | sun.x /= mtotal; 473 | sun.y /= mtotal; 474 | sun.z /= mtotal; 475 | sun.xd /= mtotal; 476 | sun.yd /= mtotal; 477 | sun.zd /= mtotal; 478 | 479 | return(-sun.zd); /* in keeping with convention */ 480 | } 481 | 482 | 483 | void heliocentric_jacobi(PhaseState *helio, PhaseState *jacobi, double GMsun, double *GM) 484 | { 485 | int i; 486 | double mass, over_mass; 487 | PhaseState s; 488 | 489 | mass = 0.0; 490 | s.x = 0.0; s.y = 0.0; s.z = 0.0; 491 | s.xd = 0.0; s.yd = 0.0; s.zd = 0.0; 492 | 493 | mass = GMsun; 494 | over_mass = 1.0/GMsun; 495 | 496 | for(i=0; ix = (helio+i)->x - s.x * over_mass; 498 | (jacobi+i)->y = (helio+i)->y - s.y * over_mass; 499 | (jacobi+i)->z = (helio+i)->z - s.z * over_mass; 500 | (jacobi+i)->xd = (helio+i)->xd - s.xd * over_mass; 501 | (jacobi+i)->yd = (helio+i)->yd - s.yd * over_mass; 502 | (jacobi+i)->zd = (helio+i)->zd - s.zd * over_mass; 503 | 504 | s.x += GM[i] * (helio+i)->x; 505 | s.y += GM[i] * (helio+i)->y; 506 | s.z += GM[i] * (helio+i)->z; 507 | s.xd += GM[i] * (helio+i)->xd; 508 | s.yd += GM[i] * (helio+i)->yd; 509 | s.zd += GM[i] * (helio+i)->zd; 510 | 511 | mass += GM[i]; 512 | over_mass = 1.0/mass; 513 | } 514 | } 515 | 516 | 517 | 518 | -------------------------------------------------------------------------------- /julia_version/kepcart2.jl: -------------------------------------------------------------------------------- 1 | #*If you make use of this code, please cite Deck, Agol, Holman & Nesvorny, 2014 * 2 | # This file has two routines which convert a GM & Cartesian state to orbital elements and VICE VERSA. 3 | 4 | #void keplerian(double gm, PhaseState state, double *a, double *e, double *i, double *longnode, double *argperi, double *meananom) 5 | function keplerian(Real::gm,PhaseState::state,Real::a,Real::ecc,Real::i,Real::longnode,Real::argperi,Real::meananom) 6 | 7 | # double rxv_x, rxv_y, rxv_z, hs, h, parameter; 8 | # double r, vs, rdotv, rdot, ecostrueanom, esintrueanom, cosnode, sinnode; 9 | # double rcosu, rsinu, u, trueanom, eccanom; 10 | 11 | #* find direction of angular momentum vector * 12 | rxv_x = state.y * state.zd - state.z * state.yd; 13 | rxv_y = state.z * state.xd - state.x * state.zd; 14 | rxv_z = state.x * state.yd - state.y * state.xd; 15 | hs = rxv_x * rxv_x + rxv_y * rxv_y + rxv_z * rxv_z; 16 | h = sqrt(hs); 17 | 18 | r = sqrt(state.x * state.x + state.y * state.y + state.z * state.z); 19 | vs = state.xd * state.xd + state.yd * state.yd + state.zd * state.zd; 20 | #* v = sqrt(vs); unnecessary *# 21 | rdotv = state.x * state.xd + state.y * state.yd + state.z * state.zd; 22 | rdot = rdotv / r; 23 | parameter = hs / gm; 24 | 25 | i = acos(rxv_z / h); 26 | 27 | if (rxv_x!=0.0 || rxv_y!=0.0) 28 | longnode = atan2(rxv_x, -rxv_y); 29 | else 30 | longnode = 0.0; 31 | end 32 | 33 | a = 1.0 / (2.0 / r - vs / gm); 34 | 35 | ecostrueanom = parameter / r - 1.0; 36 | esintrueanom = rdot * h / gm; 37 | ecc = sqrt(ecostrueanom * ecostrueanom + esintrueanom * esintrueanom); 38 | 39 | if (esintrueanom!=0.0 || ecostrueanom!=0.0) 40 | trueanom = atan2(esintrueanom, ecostrueanom); 41 | else 42 | trueanom = 0.0; 43 | end 44 | 45 | cosnode = cos(longnode); 46 | sinnode = sin(longnode); 47 | 48 | #* u is the argument of latitude */ 49 | rcosu = state.x * cosnode + state.y * sinnode; 50 | rsinu = (state.y * cosnode - state.x * sinnode)/cos(i); 51 | 52 | if(rsinu!=0.0 || rcosu!=0.0) 53 | u = atan2(rsinu, rcosu); 54 | else 55 | u = 0.0; 56 | end 57 | 58 | argperi = u - trueanom; 59 | 60 | eccanom = 2.0 * atan(sqrt((1.0 - ecc)/(1.0 + ecc)) * tan(trueanom/2.0)); 61 | meananom = eccanom - ecc * sin(eccanom); 62 | 63 | return 64 | end 65 | 66 | 67 | #void cartesian(double gm, double a, double e, double i, double longnode, double argperi, double meananom, PhaseState *state) 68 | function cartesian(Real::gm,Real::a,Real::ecc,Real::i,Real::longnode,Real::argperi,Real::meananom,PhaseState:state) 69 | 70 | # double meanmotion, cosE, sinE, foo; 71 | # double x, y, z, xd, yd, zd; 72 | # double xp, yp, zp, xdp, ydp, zdp; 73 | # double cosw, sinw, cosi, sini, cosnode, sinnode; 74 | # double E0, E1, E2, den; 75 | 76 | #* first compute eccentric anomaly */ 77 | E0 = meananom; 78 | E2 = meananom + 1.0; 79 | while(fabs(E0-E2) > eps()); 80 | E1 = meananom + ecc * sin(E0); 81 | E2 = meananom + ecc * sin(E1); 82 | 83 | den = E2 - 2.0*E1 + E0; 84 | if(fabs(den) > eps()) 85 | E0 = E0 - (E1-E0)*(E1-E0)/den; 86 | else 87 | E0 = E2; 88 | E2 = E1; 89 | end 90 | end 91 | 92 | cosE = cos(E0); 93 | sinE = sin(E0); 94 | 95 | #* compute unrotated positions and velocities */ 96 | foo = sqrt(1.0 - ecc*ecc); 97 | meanmotion = sqrt(gm/(a*a*a)); 98 | x = a * (cosE - ecc); 99 | y = foo * a * sinE; 100 | z = 0.0; 101 | xd = -a * meanmotion * sinE / (1.0 - ecc * cosE); 102 | yd = foo * a * meanmotion * cosE / (1.0 - ecc * cosE); 103 | zd = 0.0; 104 | 105 | #* rotate by argument of perihelion in orbit plane*/ 106 | cosw = cos(argperi); 107 | sinw = sin(argperi); 108 | xp = x * cosw - y * sinw; 109 | yp = x * sinw + y * cosw; 110 | zp = z; 111 | xdp = xd * cosw - yd * sinw; 112 | ydp = xd * sinw + yd * cosw; 113 | zdp = zd; 114 | 115 | #* rotate by inclination about x axis */ 116 | cosi = cos(i); 117 | sini = sin(i); 118 | x = xp; 119 | y = yp * cosi - zp * sini; 120 | z = yp * sini + zp * cosi; 121 | xd = xdp; 122 | yd = ydp * cosi - zdp * sini; 123 | zd = ydp * sini + zdp * cosi; 124 | 125 | #* rotate by longitude of node about z axis */ 126 | cosnode = cos(longnode); 127 | sinnode = sin(longnode); 128 | state.x = x * cosnode - y * sinnode; 129 | state.y = x * sinnode + y * cosnode; 130 | state.z = z; 131 | state.xd = xd * cosnode - yd * sinnode; 132 | state.yd = xd * sinnode + yd * cosnode; 133 | state.zd = zd; 134 | 135 | return; 136 | end 137 | -------------------------------------------------------------------------------- /julia_version/machine-epsilon.c: -------------------------------------------------------------------------------- 1 | 2 | double determine_machine_epsilon() 3 | { 4 | double u, den; 5 | 6 | u = 1.0; 7 | do { 8 | u /= 2.0; 9 | den = 1.0 + u; 10 | } while(den>1.0); 11 | 12 | return(10.0 * u); 13 | } 14 | -------------------------------------------------------------------------------- /julia_version/myintegrator.h: -------------------------------------------------------------------------------- 1 | //Here are some other parameters used. 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #define MAX(x,y) ((x) > (y)) ? (x) : (y) 9 | #define MIN(x,y) ((x) < (y)) ? (x) : (y) 10 | #define ABS(a) ((a) < 0 ? -(a) : (a)) 11 | 12 | typedef struct { 13 | double x, y, z; 14 | } Vector; 15 | 16 | 17 | typedef struct { 18 | double x, y, z, xd, yd, zd; 19 | } PhaseState; 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /julia_version/myintegrator.jl: -------------------------------------------------------------------------------- 1 | //Here are some other parameters used. 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #define MAX(x,y) ((x) > (y)) ? (x) : (y) 9 | #define MIN(x,y) ((x) < (y)) ? (x) : (y) 10 | #define ABS(a) ((a) < 0 ? -(a) : (a)) 11 | 12 | type Vector 13 | x::Real 14 | y::Real 15 | z::Real 16 | end 17 | 18 | type PhaseState 19 | x::Real 20 | y::Real 21 | z::Real 22 | xd::Real 23 | yd::Real 24 | zd::Real 25 | end 26 | -------------------------------------------------------------------------------- /julia_version/run_TTVFast: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kdeck/TTVFast/47759d2acaaeda62e4a1ab23303ab1a1cfeadd76/julia_version/run_TTVFast -------------------------------------------------------------------------------- /julia_version/run_TTVFast.c: -------------------------------------------------------------------------------- 1 | /*If you make use of this code, please cite Deck, Agol, Holman & Nesvorny, 2014, ApJ, 787, 132, arXiv:1403.1895 */ 2 | 3 | // This is the sample program showing how TTVFast is called. 4 | 5 | #include"transit.h" 6 | #include 7 | #include 8 | #include 9 | #include 10 | #define CALCULATE_RV 1 11 | 12 | void TTVFast(double *params,double dt, double Time, double total,int n_planets, CalcTransit *transit, CalcRV *RV_struct,int n,int m, int input); 13 | 14 | int main(int argc, char **argv) 15 | { 16 | double DEFAULT; 17 | FILE *setup_file; 18 | char ic_file_name[100]; 19 | FILE *dynam_param_file; 20 | FILE *RV_file; 21 | FILE *Transit_output; 22 | FILE *RV_output; 23 | double Time, dt,total; 24 | int nplanets; 25 | int planet,i; 26 | int n_events; 27 | int input_flag; 28 | setup_file = fopen(argv[1], "r"); 29 | fscanf(setup_file, "%s", ic_file_name); 30 | fscanf(setup_file, "%lf", &Time); /* T0*/ 31 | fscanf(setup_file, "%lf", &dt); /* timestep */ 32 | fscanf(setup_file, "%lf", &total); /* Final time*/ 33 | fscanf(setup_file, "%d", &nplanets); 34 | fscanf(setup_file, "%d", &input_flag); 35 | fclose(setup_file); 36 | Transit_output = fopen(argv[2], "w"); 37 | int RV_count = 0; 38 | double RV_time; 39 | CalcRV *RV_model; 40 | if(CALCULATE_RV){ 41 | if(argc!=5){ 42 | printf("Incorrect number of arguments: Setup File, Output File, RV Input file, RV output file - expecting RV data!\n"); 43 | exit(-1); 44 | } 45 | RV_file = fopen(argv[3],"r"); 46 | RV_output = fopen(argv[4],"w"); 47 | while(fscanf(RV_file,"%lf",&RV_time) != EOF){ 48 | RV_count ++; 49 | } 50 | fclose(RV_file); 51 | 52 | RV_model = (CalcRV*) calloc(RV_count,sizeof(CalcRV)); 53 | RV_file = fopen(argv[3],"r"); 54 | RV_count = 0; 55 | while(fscanf(RV_file,"%lf",&RV_time) != EOF){ 56 | (RV_model+RV_count)->time = RV_time; 57 | RV_count++; 58 | } 59 | fclose(RV_file); 60 | 61 | }else{ 62 | RV_model = NULL; 63 | } 64 | 65 | double p[2+nplanets*7]; 66 | dynam_param_file = fopen(ic_file_name,"r"); 67 | fscanf(dynam_param_file, "%lf %lf ",&p[0],&p[1]); 68 | planet=0; 69 | n_events=0; 70 | /*Read in planet params: */ 71 | /*Planet Mass/Stellar Mass, Period, Eccentricity, Inclination, Longnode, Arg Peri, Mean Anomaly */ 72 | while(planet < nplanets){ 73 | fscanf(dynam_param_file, "%lf %lf %lf %lf %lf %lf %lf",&p[planet*7+2],&p[planet*7+3],&p[planet*7+4],&p[planet*7+5],&p[planet*7+6],&p[planet*7+7],&p[planet*7+8]); 74 | planet++; 75 | } 76 | fclose(dynam_param_file); 77 | n_events = 5000; /*HARDWIRED, see README. you may need to change this depending on the number of planets and their orbital periods. */ 78 | /* create structure to hold transit calculations*/ 79 | CalcTransit *model; 80 | model = (CalcTransit*) calloc(n_events,sizeof(CalcTransit)); 81 | DEFAULT = -2; /* value for transit information that is not determined by TTVFast*/ 82 | for(i=0;itime = DEFAULT; 84 | } 85 | TTVFast(p,dt,Time,total,nplanets,model,RV_model,RV_count,n_events,input_flag); 86 | 87 | 88 | for(i=0;itime !=DEFAULT && (model+i)->time !=-1){ 91 | fprintf(Transit_output,"%d %d %.15le %.15le %.15le\n",(model+i)->planet, (model+i)->epoch, (model+i)->time,(model+i)->rsky,(model+i)->vsky); 92 | } 93 | } 94 | fflush(Transit_output); 95 | fclose(Transit_output); 96 | 97 | if(CALCULATE_RV){ 98 | for(i=0;itime, (RV_model+i)->RV); 100 | } 101 | 102 | fflush(RV_output); 103 | fclose(RV_output); 104 | } 105 | free(model); 106 | free(RV_model); 107 | 108 | } 109 | -------------------------------------------------------------------------------- /julia_version/setup_file: -------------------------------------------------------------------------------- 1 | KOI142.in 2 | -1045 3 | 0.54 4 | 1700 5 | 2 6 | 0 -------------------------------------------------------------------------------- /julia_version/setup_file_astro_cartesian: -------------------------------------------------------------------------------- 1 | KOI142.in.cartesian 2 | -1045 3 | 0.54 4 | 1700 5 | 2 6 | 2 -------------------------------------------------------------------------------- /julia_version/setup_file_astro_elements: -------------------------------------------------------------------------------- 1 | KOI142.in.astro 2 | -1045 3 | 0.54 4 | 1700 5 | 2 6 | 1 -------------------------------------------------------------------------------- /julia_version/transit.h: -------------------------------------------------------------------------------- 1 | //here are the definitions of the CalcTransit and CalcRV structure. 2 | typedef struct { 3 | int planet; 4 | int epoch; 5 | double time; 6 | double rsky; 7 | double vsky;} CalcTransit; 8 | 9 | typedef struct { 10 | double time; 11 | double RV;} CalcRV; 12 | -------------------------------------------------------------------------------- /julia_version/transit.jl: -------------------------------------------------------------------------------- 1 | # here are the definitions of the CalcTransit and CalcRV structure. 2 | type CalcTransit 3 | planet::Integer 4 | epoch::Integer 5 | time::Real 6 | rsky::Real 7 | vsky::Real 8 | end 9 | 10 | type CalRV 11 | time::Real 12 | RV::Real 13 | end 14 | -------------------------------------------------------------------------------- /julia_version/ttv-map-jacobi.c: -------------------------------------------------------------------------------- 1 | /*If you make use of this code, please cite Deck, Agol, Holman & Nesvorny, 2014, ApJ, 787, 132, arXiv:1403.1895 */ 2 | 3 | //This file holds all the auxiliary files for the integration, including the Kepler step, the kick step, transit time solver employing Newton's method, transit time finder employing the bisection method, the symplectic corrector sub routines, etc. 4 | 5 | int kepler_step(double gm, double dt, PhaseState *s0, PhaseState *s,int planet) 6 | { 7 | 8 | double r0, v0s, u, a, n, ecosE0, esinE0; 9 | double dM, x, sx, cx, f, fp, fpp, fppp, dx; 10 | double fdot, g, gdot; 11 | double sx2, cx2, x2; 12 | double xx, yy, xx1, yy1, omx, h; 13 | double k0x, k0y, k1x, k1y, k2x, k2y, k3y; 14 | double ecosE, esinE; 15 | int count; 16 | r0 = sqrt(s0->x*s0->x + s0->y*s0->y + s0->z*s0->z); 17 | 18 | v0s = s0->xd*s0->xd + s0->yd*s0->yd + s0->zd*s0->zd; 19 | u = s0->x*s0->xd + s0->y*s0->yd + s0->z*s0->zd; 20 | a = 1.0/(2.0/r0 - v0s/gm); 21 | 22 | if(a<0.0) { 23 | printf("hyperbolic orbit %lf\n", a); 24 | exit(-1); 25 | } 26 | 27 | n = sqrt(gm/(a*a*a)); 28 | ecosE0 = 1.0 - r0/a; 29 | esinE0 = u/(n*a*a); 30 | 31 | dM = n*dt; 32 | 33 | x = 3.0*guess[planet][2]+guess[planet][0]-3.0*guess[planet][1]; 34 | 35 | count = 0; 36 | do { 37 | x2 = x/2.0; 38 | sx2 = sin(x2); cx2 = cos(x2); 39 | sx = 2.0*sx2*cx2; cx = cx2*cx2 - sx2*sx2; 40 | f = x + 2.0*sx2*(sx2*esinE0 - cx2*ecosE0) - dM; 41 | ecosE = cx*ecosE0 - sx*esinE0; 42 | fp = 1.0 - ecosE; 43 | fpp = (sx*ecosE0 + cx*esinE0)/2.0; 44 | fppp = ecosE/6.0; 45 | dx = -f/fp; 46 | dx = -f/(fp + dx*fpp); 47 | dx = -f/(fp + dx*(fpp + dx*fppp)); 48 | x += dx; 49 | count ++; 50 | 51 | } while(fabs(dx) > 1.0e-4 && count < MAX_ITER); 52 | 53 | 54 | 55 | if(fabs(f)> 1.0e-14){ 56 | x = dM; 57 | count = 0; 58 | do { 59 | x2 = x/2.0; 60 | sx2 = sin(x2); cx2 = cos(x2); 61 | sx = 2.0*sx2*cx2; cx = cx2*cx2 - sx2*sx2; 62 | f = x + 2.0*sx2*(sx2*esinE0 - cx2*ecosE0) - dM; 63 | ecosE = cx*ecosE0 - sx*esinE0; 64 | fp = 1.0 - ecosE; 65 | fpp = (sx*ecosE0 + cx*esinE0)/2.0; 66 | fppp = ecosE/6.0; 67 | dx = -f/fp; 68 | dx = -f/(fp + dx*fpp); 69 | dx = -f/(fp + dx*(fpp + dx*fppp)); 70 | x += dx; 71 | count++; 72 | } while(fabs(f) > 1.0e-14 && count < MAX_ITER); 73 | 74 | } 75 | 76 | if(count==MAX_ITER){ 77 | printf("Kepler step not converging in MAX_ITER. Likely need a smaller dt\n"); 78 | exit(-1); 79 | } 80 | 81 | guess[planet][0]=guess[planet][1]; 82 | guess[planet][1]=guess[planet][2]; 83 | guess[planet][2]=x; 84 | 85 | 86 | /* compute f and g */ 87 | x2 = x/2.0; 88 | sx2 = sin(x2); cx2 = cos(x2); 89 | f = 1.0 - (a/r0)*2.0*sx2*sx2; 90 | sx = 2.0*sx2*cx2; cx = cx2*cx2 - sx2*sx2; 91 | g = (2.0*sx2*(esinE0*sx2 + cx2*r0/a))/n; 92 | fp = 1.0 - cx*ecosE0 + sx*esinE0; 93 | fdot = -(a/(r0*fp))*n*sx; 94 | gdot = (1.0 + g*fdot)/f; 95 | 96 | /* compute new position and velocity */ 97 | s->x = f*s0->x + g*s0->xd; 98 | s->y = f*s0->y + g*s0->yd; 99 | s->z = f*s0->z + g*s0->zd; 100 | s->xd = fdot*s0->x + gdot*s0->xd; 101 | s->yd = fdot*s0->y + gdot*s0->yd; 102 | s->zd = fdot*s0->z + gdot*s0->zd; 103 | 104 | } 105 | 106 | double kepler_transit_locator(double gm, double dt, PhaseState *s0, PhaseState *s) 107 | { 108 | double y,y2,sy2,sy,test; 109 | double ecc,transitM,eprior; 110 | double a, n,r0, ecosE0, esinE0,u,v0s; 111 | double x, sx, cx, fp, fp2, dx; 112 | double fdot, g, gdot,f; 113 | double sx2, cx2, x2; 114 | double aOverR,dfdz,dgdz,dfdotdz,dgdotdz,dotproduct,dotproductderiv,rsquared,vsquared,xdotv; 115 | 116 | r0 = sqrt(s0->x*s0->x + s0->y*s0->y + s0->z*s0->z); 117 | v0s = s0->xd*s0->xd + s0->yd*s0->yd + s0->zd*s0->zd; 118 | u = s0->x*s0->xd + s0->y*s0->yd + s0->z*s0->zd; 119 | a = 1.0/(2.0/r0 - v0s/gm); 120 | 121 | n = sqrt(gm/(a*a*a)); 122 | ecosE0 = 1.0 - r0/a; 123 | esinE0 = u/(n*a*a); 124 | 125 | aOverR= a/r0; 126 | rsquared = s0->x*s0->x + s0->y*s0->y; 127 | vsquared = s0->xd*s0->xd + s0->yd*s0->yd; 128 | xdotv =s0->x*s0->xd + s0->y*s0->yd; 129 | 130 | /*Initial Guess */ 131 | x = n*dt/2.0; 132 | do{ 133 | x2 = x/2.0; 134 | sx2 = sin(x2); cx2 = cos(x2); 135 | f = 1.0 - aOverR*2.0*sx2*sx2; 136 | sx = 2.0*sx2*cx2; cx = cx2*cx2 - sx2*sx2; 137 | g = (2.0*sx2*(esinE0*sx2 + cx2/aOverR))/n; 138 | fp = 1.0 - cx*ecosE0 + sx*esinE0; 139 | fdot = -(aOverR/fp)*n*sx; 140 | fp2 = sx*ecosE0 + cx*esinE0; 141 | gdot = 1.0-2.0*sx2*sx2/fp; 142 | 143 | dgdotdz = -sx/fp+2.0*sx2*sx2/fp/fp*fp2; 144 | dfdz = -aOverR*sx; 145 | dgdz= 1.0/n*(sx*esinE0-(ecosE0-1.0)*cx); 146 | dfdotdz= -n*aOverR/fp*(cx+sx/fp*fp2); 147 | 148 | dotproduct = f*fdot*(rsquared)+g*gdot*(vsquared)+(f*gdot+g*fdot)*(xdotv); 149 | 150 | dotproductderiv = dfdz*(gdot*xdotv+fdot*rsquared)+dfdotdz*(f*rsquared+g*xdotv)+dgdz*(fdot*xdotv+gdot*vsquared)+dgdotdz*(g*vsquared+f*xdotv); 151 | 152 | dx = -dotproduct/dotproductderiv; 153 | 154 | x += dx; 155 | 156 | }while(fabs(dx)> sqrt(TOLERANCE)); 157 | /* Now update state */ 158 | x2 = x/2.0; 159 | sx2 = sin(x2); cx2 = cos(x2); 160 | sx = 2.0*sx2*cx2; 161 | 162 | cx = cx2*cx2 - sx2*sx2; 163 | f = 1.0 - (a/r0)*2.0*sx2*sx2; 164 | g = (2.0*sx2*(esinE0*sx2 + cx2/aOverR))/n; 165 | fp = 1.0 - cx*ecosE0 + sx*esinE0; 166 | fdot = -(aOverR/fp)*n*sx; 167 | gdot = (1.0 + g*fdot)/f; 168 | s->x = f*s0->x + g*s0->xd; 169 | s->y = f*s0->y + g*s0->yd; 170 | s->z = f*s0->z + g*s0->zd; 171 | s->xd = fdot*s0->x + gdot*s0->xd; 172 | s->yd = fdot*s0->y + gdot*s0->yd; 173 | s->zd = fdot*s0->z + gdot*s0->zd; 174 | /*Corresponding Delta Mean Anomaly */ 175 | transitM = x+esinE0*2.0*sx2*sx2-sx*ecosE0; 176 | 177 | return(transitM/n); 178 | } 179 | 180 | double bisection(double gm,PhaseState *s0, PhaseState *s1, PhaseState *s) 181 | { 182 | double g0,g1,g2; 183 | double a, n,r0, ecosE0, esinE0,u,v0s; 184 | double x, sx, cx, x2,sx2,cx2,fdot,gdot,f,g,fp,transitM,rsquared,vsquared,xdotv; 185 | double E0,esinE1,ecosE1,E1; 186 | double aOverR; 187 | double dot_product(double y, double aOverR, double esinE0, double ecosE0, double n,double rsquared, double vsquared, double xdotv); 188 | int iter; 189 | double dg2; 190 | 191 | r0 = sqrt(s1->x*s1->x + s1->y*s1->y + s1->z*s1->z); 192 | v0s = s1->xd*s1->xd + s1->yd*s1->yd + s1->zd*s1->zd; 193 | u = s1->x*s1->xd + s1->y*s1->yd + s1->z*s1->zd; 194 | a = 1.0/(2.0/r0 - v0s/gm); 195 | 196 | n = sqrt(gm/(a*a*a)); 197 | ecosE1 = 1.0 - r0/a; 198 | esinE1 = u/(n*a*a); 199 | 200 | E1 = atan2(esinE1,ecosE1); 201 | 202 | r0 = sqrt(s0->x*s0->x + s0->y*s0->y + s0->z*s0->z); 203 | v0s = s0->xd*s0->xd + s0->yd*s0->yd + s0->zd*s0->zd; 204 | u = s0->x*s0->xd + s0->y*s0->yd + s0->z*s0->zd; 205 | a = 1.0/(2.0/r0 - v0s/gm); 206 | rsquared = s0->x*s0->x+s0->y*s0->y; 207 | vsquared = s0->xd*s0->xd+s0->yd*s0->yd; 208 | xdotv = s0->x*s0->xd+s0->y*s0->yd; 209 | n = sqrt(gm/(a*a*a)); 210 | ecosE0 = 1.0 - r0/a; 211 | esinE0 = u/(n*a*a); 212 | E0 = atan2(esinE0,ecosE0); 213 | aOverR= a/r0; 214 | 215 | /* Interval endpoints */ 216 | g0 =0.0; 217 | g1 =(E1-E0); 218 | if(dot_product(g0,aOverR,esinE0,ecosE0,n,rsquared,vsquared,xdotv)*dot_product(g1,aOverR,esinE0,ecosE0,n,rsquared,vsquared,xdotv) < 0.0){ 219 | iter = 0; 220 | }else{ 221 | iter = MAX_ITER; 222 | } 223 | 224 | do{ 225 | g2 = (g1+g0)/2.0; 226 | dg2 = dot_product(g2,aOverR,esinE0,ecosE0,n,rsquared,vsquared,xdotv); 227 | if(dg2*dot_product(g0,aOverR,esinE0,ecosE0,n,rsquared,vsquared,xdotv) > 0.0){ 228 | g0 = g2; 229 | } 230 | else{ 231 | g1 = g2; 232 | } 233 | 234 | iter++; 235 | 236 | } while( (fabs(dg2)> TOLERANCE) && (iter < MAX_ITER)); 237 | 238 | if(iter ==MAX_ITER){ 239 | bad_transit_flag = 1; 240 | } 241 | 242 | /* Now update state */ 243 | x = g2; 244 | x2 = x/2.0; 245 | sx2 = sin(x2); cx2 = cos(x2); 246 | sx = 2.0*sx2*cx2; 247 | 248 | cx = cx2*cx2 - sx2*sx2; 249 | f = 1.0 - (a/r0)*2.0*sx2*sx2; 250 | g = (2.0*sx2*(esinE0*sx2 + cx2/aOverR))/n; 251 | fp = 1.0 - cx*ecosE0 + sx*esinE0; 252 | fdot = -(aOverR/fp)*n*sx; 253 | gdot = 1.0-2.0*sx2*sx2/fp; 254 | s->x = f*s0->x + g*s0->xd; 255 | s->y = f*s0->y + g*s0->yd; 256 | s->z = f*s0->z + g*s0->zd; 257 | s->xd = fdot*s0->x + gdot*s0->xd; 258 | s->yd = fdot*s0->y + gdot*s0->yd; 259 | s->zd = fdot*s0->z + gdot*s0->zd; 260 | /*Corresponding Delta Mean Anomaly */ 261 | transitM = (x+esinE0*2.0*sx2*sx2-sx*ecosE0); 262 | 263 | return(transitM/n); 264 | } 265 | 266 | 267 | double dot_product(double y, double aOverR, double esinE0, double ecosE0, double n,double rsquared, double vsquared, double xdotv) 268 | { 269 | double y2,sy2,cy2,f,sy,cy,fdot,gdot,dotprod,g,fp; 270 | y2 = y/2.0 ; 271 | 272 | sy2 = sin(y2) ; 273 | cy2 = cos(y2) ; 274 | f = 1.0 - aOverR*2.0*sy2*sy2 ; 275 | sy = 2.0*sy2*cy2 ; 276 | cy = cy2*cy2 - sy2*sy2 ; 277 | g = (2.0*sy2*(esinE0*sy2 + cy2/aOverR))/n ; 278 | fp = 1.0 - cy*ecosE0 + sy*esinE0 ; 279 | fdot = -(aOverR/fp)*n*sy ; 280 | gdot = 1.0-2.0*sy2*sy2/fp ; 281 | dotprod = f*fdot*(rsquared)+g*gdot*(vsquared)+(f*gdot+g*fdot)*(xdotv) ; 282 | 283 | return(dotprod); 284 | } 285 | 286 | 287 | 288 | void nbody_kicks(PhaseState p[], double dt) 289 | { 290 | Vector FF[MAX_N_PLANETS], GG[MAX_N_PLANETS], acc_tp; 291 | Vector tmp[MAX_N_PLANETS], h[MAX_N_PLANETS], XX; 292 | double GMsun_over_r3[MAX_N_PLANETS], rp2, dx, dy, dz, r2, rij2, rij5; 293 | double q, q1, fq; 294 | double f0, fi, fij, fijm, fr; 295 | double sx, sy, sz, tx, ty, tz; 296 | double indirectx, indirecty, indirectz, over_GMsun; 297 | double constant; 298 | int i, j; 299 | double qb0, qb1, qb2, qb3; 300 | double c, c1; 301 | 302 | double a0, a11, a22, a33, a12, a13, a23, a21, a32, a31, b01, b02, b03, b12, b13, b23; 303 | double x1, x2, x3; 304 | 305 | sx = 0.0; sy = 0.0; sz = 0.0; 306 | for(i=0; i=0; i--) { 344 | FF[i].x -= tx; FF[i].y -= ty; FF[i].z -= tz; 345 | f0 = GM[i]*GMsun_over_r3[i]; 346 | tx += h[i].x*f0; ty += h[i].y*f0; tz += h[i].z*f0; 347 | } 348 | 349 | /* factor1 = 1/eta[i-1] factor2 = eta[i]/eta[i-1] */ 350 | for(i=0; ix = s1->x; 441 | s2->y = s1->y; 442 | s2->z = s1->z; 443 | s2->xd = s1->xd; 444 | s2->yd = s1->yd; 445 | s2->zd = s1->zd; 446 | } 447 | 448 | void copy_system(PhaseState p1[], PhaseState p2[]) 449 | { 450 | int planet; 451 | 452 | for(planet=0; planet