1 |
|
---|
2 | Module LE_module
|
---|
3 |
|
---|
4 | USE DataDeclarations
|
---|
5 | USE GlobalDeclarations
|
---|
6 | USE PhysicalDeclarations
|
---|
7 |
|
---|
8 | Implicit None
|
---|
9 |
|
---|
10 | Private
|
---|
11 |
|
---|
12 | real xi, dtheta, poly_index, theta, xlast, dxdtlast,k1,k2,k3,k4,h,f,xi_last,dtheta_last,theta_last,dtheta1
|
---|
13 |
|
---|
14 | PUBLIC CalcParams,LE_params,
|
---|
15 |
|
---|
16 | CONTAINS
|
---|
17 |
|
---|
18 | Subroutine CalcParams(R_star,M_star,poly_index,h,rho_cent,xi_last,dtheta1,K,a_scale,p_cent,rho_profile)
|
---|
19 |
|
---|
20 | !requires a user input star/clump radius, a polytropic index, and a central density and integration length h
|
---|
21 | !and calculated xi_last (root), and corresponding dtheta/dxi
|
---|
22 | !outputs scaling constant a, mass of star/clump,gas constant K, and central Pressue
|
---|
23 |
|
---|
24 | Real(Kind=qPrec) :: R_star,M_star,rho_new,h,poly_index,rho_cent,xi_last,dtheta1,K,a_scale,rho_profile
|
---|
25 | Real:: xi_last
|
---|
26 |
|
---|
27 | a_scale=xi_last/R_star
|
---|
28 |
|
---|
29 | M_star=4*pi*rho_cent*(R_star**3)*(-1/xi_last)*(dtheta1)
|
---|
30 |
|
---|
31 | K=4*pi*G/((poly_index+1)(a_scale**2))*rho_cent**((poly_index-1)/poly_index)
|
---|
32 |
|
---|
33 | p_cent=K*rho_cent**(1+1/poly_index)
|
---|
34 |
|
---|
35 | rho_profile=rho_cent*theta**poly_index
|
---|
36 |
|
---|
37 | end subroutine calcparams
|
---|
38 |
|
---|
39 | !initial conditions
|
---|
40 | numsteps=0
|
---|
41 | theta=1-(xi**2.0)/6.0+(poly_index/120.0)*(xi**4.0)-(8.0*poly_index**2.0-5.0*poly_index)/(15120.0)*(xi**5.0)
|
---|
42 | dtheta=-xi/3.0+(poly_index/30.0)*(xi**3.0)-(8.0*poly_index**2.0-5.0*poly_index)/(2520.0)*(xi**5.0)
|
---|
43 |
|
---|
44 | Function LE_params(xi,dtheta,poly_index,theta,xi_last,dtheta1,dtheta_last,theta_last)
|
---|
45 | Real:: LE_rho,xi,xi, dtheta, poly_index, theta,k1,k2,k3,k4,h,f,xi_last,dtheta_last,theta_last,dtheta1
|
---|
46 | do while(theta.ge.0)
|
---|
47 | xi=xi+h
|
---|
48 | theta=theta+h*dtheta
|
---|
49 | !calculating the runge kutta
|
---|
50 |
|
---|
51 | k1=h*f(poly_index,xi,theta,dtheta)
|
---|
52 | k2=h*f(poly_index,xi+h/2.0,theta+k1/2.0,dtheta)
|
---|
53 | k3=h*f(poly_index,xi+h/2.0,theta+k2/2.0,dtheta)
|
---|
54 | k4=h*f(poly_index,xi+h,theta+k3,dtheta)
|
---|
55 |
|
---|
56 | dtheta=dtheta+(k1+2.0*k2+2.0*k3+k4)/6.0
|
---|
57 |
|
---|
58 | theta_last=theta
|
---|
59 | dtheta_last=dtheta
|
---|
60 | enddo
|
---|
61 |
|
---|
62 | print*,'final value for xi',xi
|
---|
63 | print*,'final value for theta',theta
|
---|
64 | print*,'final value for dtheta/dphi',dtheta
|
---|
65 |
|
---|
66 | !final conditions (for root)
|
---|
67 | xi = xi + (theta/(theta_last-theta))*h
|
---|
68 | dtheta1 = dtheta - (xi-xi_last)*(dtheta-dtheta_last)/h
|
---|
69 |
|
---|
70 | write(unit=6,FMT=*) 'first root of phi at xi=',xi_last
|
---|
71 | write(unit=6,FMT=*) 'at this point dtheta/dt = ',dtheta1
|
---|
72 | end
|
---|
73 |
|
---|
74 |
|
---|
75 | !function f calculate the second order dtheta
|
---|
76 |
|
---|
77 | real function f(poly_index,xi,theta,dtheta)
|
---|
78 | implicit none
|
---|
79 | real poly_index,xi,theta,dtheta
|
---|
80 | f=-theta**poly_index-2.0*dtheta/xi
|
---|
81 | return
|
---|
82 | end |
---|