0
$\begingroup$

I make this program, i have a 2xN matrix in which the columns are the ID of planets and their period, the rows are the number of planets, for istance something like that:

1 0.44
1 0.8
1 0.9
2 0.9
2 1.2
3 2.0
3 3.0

The trick to change from one system of planet to the other is to rename all the planets of a system with the same number and the planets of other system with another number so, i can be able to change the resonance condition from one system to another one.

The program is simple:

1) read the file and save the columns and rows numbers, 2) create and save a matrix of col*row objects, 3) save as a vector the name and period of planets, 4) start the cycle:

for r=1,row <--- THIS MUST READ all the file if (difference in name = 0.) then start the resonance find criterion for l = 0,4 (number of planet in each system: THIS MUST BE MODIFIED !!)

for i = 1,5 
for j =1,5

if (i*period(l)-j*period(l+1) eq 0) then write on file <- RESONANCE CONDITION !!!

end if
   end for
   end for
   else write a separation between the first set and second set of planets !
   end if

This is the IDL code i wrote: pro resfind

file = "data.dat"
rows =File_Lines(file) ; per le righe
openr,lun,file,/Get_lun ; per le colonne
line=""
readf,lun,line
cols = n_elements(StrSplit(line, /RegEx, /extract))

openr,1,"data.dat" 
 data = dblarr(cols,rows)
 readf,1,data
close,1


name = data(0,*)
period = data(1,*)

openw,2,"find.dat"
 for r = 0, rows-2 DO BEGIN ;
        if (name(r)-name(r+1) EQ 0) then begin 
                for l = 0,rows-2 do begin 
                         for j = 1,4 do begin
                                 for i = 1,4 do begin

                                           if (abs(i*period(l)-j*period(l+1)) EQ 0.) then begin 
                                           printf,2, 'i resonance:', i , ' j resonance:',j,' planet ID:',l,' planet ID:',l+1
                                           endif
                                 endfor 
                         endfor
                endfor
        endif else begin
        printf,2, '                                                    ' 
endfor


close,2

end

PROBLEMS:

1) i can't understand how to eliminate the multiply of resonance (2:4, 3:6 and so on);

2) in the second for loop (the one with the planet) the number of planets must be change every time but i don't understand how to change this.

And this is the f90 version of the code:

program resfind
    implicit none
    integer::i,j,k,s,n
    real*8,allocatable::ID(:),period(:)

    open(10,file='data.dat')
    n=0
        DO
          READ(10,*,END=100)
          n=n+1
        END DO

 100     continue
        rewind(10)

    allocate(ID(n),period(n))
s=0
    do s=1, n
        read(10,*) ID(s),period(s)
    end do
    open(20,file='find90.dat')

! do r = 0, rows-2 DO BEGIN ;
!        if (name(r)-name(r+1) EQ 0) then begin 


i=0
j=0
k=0
 do i = 1,n-1 
  do j = 1,5 
   do k = 1,5  
     if (abs(j*period(i)-k*period(i+1)).EQ.0.0) then   
     print*, i,j,k
    write(20,*) 'j resonance:', j , ' k resonance:',k,' planet ID:',i,' planet ID:',i+1
    end if
   end do
  end do
 end do

 close(20)

end program resfind

Thanks a lot.

$\endgroup$

closed as off-topic by Brandon Enright, Kyle Kanos, David Z Mar 29 '14 at 19:02

  • This question does not appear to be about physics within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ This doesn't really seem like it has to do with physics, it seems more like you're looking for help debugging your Fortran code. $\endgroup$ – DumpsterDoofus Mar 29 '14 at 15:03
  • $\begingroup$ this is my guess to find resonances, i put the codes here to understand if someone have different idea on the if condition to check for resonances . $\endgroup$ – Panichi Pattumeros PapaCastoro Mar 29 '14 at 15:28
  • $\begingroup$ This question would probably fit on the up and coming mathematical modeling SE when it opens up. $\endgroup$ – Chris Mueller Mar 29 '14 at 15:34
  • 2
    $\begingroup$ This question appears to be off-topic because it is about programming and a specific program rather than physics or a specific physics concept. $\endgroup$ – Brandon Enright Mar 29 '14 at 16:38
0
$\begingroup$

I'm having trouble understanding what you're trying to say, but assuming you're just looking for period resonances of the form $a:b$ where $1\leq a,b\leq 5$, the following 4 lines of Mathematica code using your example list of extrasolar periods should suffice:

A = {0.44, 0.8, 0.9, 0.9, 1.2, 2.0, 3.0};
n = Length[A];
d = 0.05;
ResonanceMatrix = MatrixForm[Table[DeleteCases[Tally[Flatten[Table[If[Abs[k A[[i]] - l A[[j]]] < Sqrt[k l] d, l/k, "NR"], {k,5}, {l, 5}]]][[All, 1]], "NR"], {i, n}, {j, n}]]

Output:

$$\text{ResonanceMatrix}=\left( \begin{array}{ccccccc} \{1\} & \{\} & \left\{\frac{1}{2}\right\} & \left\{\frac{1}{2}\right\} & \{\} & \{\} & \{\} \\ \{\} & \{1\} & \{\} & \{\} & \left\{\frac{2}{3}\right\} & \left\{\frac{2}{5}\right\} & \{\} \\ \{2\} & \{\} & \{1\} & \{1\} & \left\{\frac{3}{4}\right\} & \{\} & \{\} \\ \{2\} & \{\} & \{1\} & \{1\} & \left\{\frac{3}{4}\right\} & \{\} & \{\} \\ \{\} & \left\{\frac{3}{2}\right\} & \left\{\frac{4}{3}\right\} & \left\{\frac{4}{3}\right\} & \{1\} & \left\{\frac{3}{5}\right\} & \left\{\frac{2}{5}\right\} \\ \{\} & \left\{\frac{5}{2}\right\} & \{\} & \{\} & \left\{\frac{5}{3}\right\} & \{1\} & \left\{\frac{2}{3}\right\} \\ \{\} & \{\} & \{\} & \{\} & \left\{\frac{5}{2}\right\} & \left\{\frac{3}{2}\right\} & \{1\} \\ \end{array} \right)$$

For example, the $(2,5)$ entry is $\frac{2}{3}$, indicating that there is a $2:3$-resonance between planet 2 and planet 5. The diagonal entries are all 1, since every planet has a $1:1$-resonance with itself. The parameter $d$ controls the tolerance when deciding if resonance occurs. Duplicates of the form $\frac{na}{nb}$ for $n\in\mathbb{Z}$ are automatically deleted.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.