00001 subroutine peos2teos(nlines)
00002
00003 use phys_constant
00004 use def_peos_parameter
00005 implicit none
00006
00007 integer, intent(in) :: nlines
00008 real(8) :: rho_0, pre_0, facrho, facpre, fac2, gg, cc, ss, mb
00009 integer :: ii, iphase
00010 real(8) :: dlogrho, rhoteos, preteos, qteos, hh, pre, rho, ene
00011
00012 mb = 1.66d-24
00013
00014 open(850,file='peos_parameter.dat',status='old')
00015
00016 read(850,'(8x,1i5,es13.5)') nphase, rhoini_cgs
00017 read(850,'(2es13.5)') rho_0, pre_0
00018 do ii = nphase, 0, -1
00019 read(850,'(2es13.5)') rhocgs(ii), abi(ii)
00020 end do
00021
00022 close(850)
00023
00024
00025
00026
00027
00028
00029
00030 facrho = (g/c**2)**3*solmas**2
00031 facpre = g**3*solmas**2/c**8
00032
00033 do ii = 0, nphase
00034 rhoi(ii) = facrho*rhocgs(ii)
00035 end do
00036
00037 call peos_lookup(rho_0,rhocgs,iphase)
00038
00039 abc(iphase) = pre_0/rho_0**abi(iphase)
00040 abc(iphase) = facpre/facrho**abi(iphase)*abc(iphase)
00041 abccgs(iphase) = pre_0/(rho_0**abi(iphase))
00042
00043 if (iphase.gt.0) then
00044 do ii = iphase-1, 0, -1
00045 abc( ii) = rhoi( ii)**(abi(ii+1)-abi(ii))*abc( ii+1)
00046 abccgs(ii) = rhocgs(ii)**(abi(ii+1)-abi(ii))*abccgs(ii+1)
00047 end do
00048 end if
00049 if (iphase.lt.nphase) then
00050 do ii = iphase+1, nphase
00051 abc( ii) = rhoi( ii-1)**(abi(ii-1)-abi(ii))*abc( ii-1)
00052 abccgs(ii) = rhocgs(ii-1)**(abi(ii-1)-abi(ii))*abccgs(ii-1)
00053 end do
00054 end if
00055
00056 do ii = 0, nphase
00057 qi(ii) = abc(ii)*rhoi(ii)**(abi(ii)-1.0d0)
00058 end do
00059
00060 hi(0) = 1.0d0
00061 do ii = 1, nphase
00062 fac2 = abi(ii)/(abi(ii) - 1.0d0)
00063 hi(ii) = hi(ii-1) + fac2*(qi(ii) - qi(ii-1))
00064 end do
00065
00066 open(860,file='peos_parameter_output.dat',status='unknown')
00067 write(860,'(a1,8x,i5)')'#', nphase
00068 do ii = 0, nphase
00069 write(860,'(i5,10es13.5)') ii, abc(ii), abi(ii), rhoi(ii), &
00070 & qi(ii), hi(ii), abccgs(ii), rhocgs(ii), &
00071 & abccgs(ii)*rhocgs(ii)**abi(ii)
00072 end do
00073 close(860)
00074
00075 rhoini_gcm1 = facrho*rhoini_cgs
00076 call peos_lookup(rhoini_gcm1,rhoi,iphase)
00077 emdini_gcm1 = abc(iphase)*rhoini_gcm1**(abi(iphase)-1.0d0)
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093 write(6,*) "rhocgs(nphase)=", rhocgs(nphase), " nlines=", nlines
00094 dlogrho = dlog10(rhocgs(nphase))/dble(nlines)
00095
00096 open(850,file='teos_parameter.dat',status='unknown')
00097 do ii=0,nlines-1
00098 rhoteos = (10.0d0)**(dble(ii)*dlogrho)
00099 call peos_lookup(rhoteos,rhocgs,iphase)
00100 preteos = abccgs(iphase)*rhoteos**abi(iphase)
00101 qteos = preteos/rhoteos/(c**2)
00102 call peos_q2hprho(qteos, hh, pre, rho, ene)
00103 ene = ene/facrho
00104 rho = rho/facrho
00105 pre = pre/facpre
00106
00107 write(850,'(7e23.15)') ene, pre, hh, rho
00108
00109
00110
00111 end do
00112 close(850)
00113
00114 end subroutine peos2teos