GWtool
Gravitational-wave tool
 All Classes Files Functions Variables Pages
gw_mceta-m1m2.f90
Go to the documentation of this file.
1 !> \file gw_mceta-m1m2.f90 Convert the Chirp mass and symmetric mass ratio to M1 and M2
2 
3 
4 !
5 ! GWtool: Simple tools for working with gravitational waves
6 ! http://gwtool.sourceforge.net/
7 !
8 !
9 ! Copyright 2007-2013 AstroFloyd - astrofloyd.org
10 !
11 !
12 ! This file is part of GWtool.
13 !
14 ! GWtool is free software: you can redistribute it and/or modify
15 ! it under the terms of the GNU General Public License as published by
16 ! the Free Software Foundation, either version 3 of the License, or
17 ! (at your option) any later version.
18 !
19 ! GWtool is distributed in the hope that it will be useful,
20 ! but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ! GNU General Public License for more details.
23 !
24 ! You should have received a copy of the GNU General Public License
25 ! along with GWtool. If not, see <http://www.gnu.org/licenses/>.
26 
27 
28 
29 !***********************************************************************************************************************************
31  use sufr_kinds, only: double
32  use sufr_system, only: quit_program_error, syntax_quit
33 
34  implicit none
35  real(double) :: eta,eta1,mc,m1,m2,mtot
36  character :: tmpstr*(99)
37 
38  if(command_argument_count().eq.2) then
39  call get_command_argument(1,tmpstr)
40  read(tmpstr,*) mc
41  call get_command_argument(2,tmpstr)
42  read(tmpstr,*) eta
43  else
44  call syntax_quit('<Mc> <eta>', 0, 'This program converts masses expressed in Mchirp and eta to M1 and M2')
45  end if
46 
47  if(eta.lt.0.d0.or.eta.gt.0.5d0) call quit_program_error('eta should be 0.0 <= eta <= 0.5', 0)
48 
49  if(eta.le.0.25d0) then
50  write(6,'(/,A,2F15.8)')' Mc, eta: ',mc,eta
51  else
52  eta1 = 0.5d0 - eta
53  write(*,'(/,A,2F15.8,A,F8.5,A1)') ' Warning: eta > 0.25; Mapping it to 0.5-eta:'
54  write(*,'(A,2F15.8,A,F8.5,A1)') ' Mc, eta: ',mc,eta,' (->',eta1,')'
55  eta = eta1
56  end if
57 
58  mtot = mc/eta**(3.d0/5.d0)
59  m1 = mtot/2.d0 * (1.d0 + sqrt(1.d0 - 4*eta))
60  m2 = mtot/2.d0 * (1.d0 - sqrt(1.d0 - 4*eta))
61 
62  write(*,*)
63  write(*,'(2x,A,2F15.8)') 'M1, M2: ',m1,m2
64  write(*,'(2x,A,2F15.8)') 'M1/M2, M: ',m1/m2,m1+m2
65  write(*,*)
66 
67 end program gw_mceta_m1m2
68 !***********************************************************************************************************************************
69 
program gw_mceta_m1m2