Line data Source code
1 : module test_binary_mod
2 :
3 : use binary_lib
4 : use binary_timestep, only: binary_pick_next_timestep
5 : use binary_def
6 : use binary_private_def
7 : use star_def
8 : use star_lib
9 : use const_def
10 : use math_lib
11 : implicit none
12 :
13 : contains
14 :
15 4 : subroutine do_test
16 : integer :: binary_id, id, ierr, res
17 1 : real(dp) :: fL2
18 : type(binary_info), pointer :: b
19 : type(star_info), pointer :: s
20 :
21 : include 'formats'
22 :
23 1 : call math_init ! we need this for exp10
24 :
25 1 : write (*, *) 'check time_delta_coeff behavior'
26 1 : binary_id = alloc_binary(ierr)
27 1 : call binary_ptr(binary_id, b, ierr)
28 1 : call alloc_star(id, ierr)
29 1 : call star_ptr(id, s, ierr)
30 1 : b%s_donor => s ! set donor star
31 1 : b%d_i = 1
32 1 : b%a_i = 2
33 1 : b%point_mass_i = 1 ! no second star
34 1 : b%rl_relative_gap_old(2) = 0d0
35 1 : b%rl_relative_gap(2) = 0d0
36 :
37 1 : b%max_timestep = 10d0 ! current max timestep
38 1 : s%time_step = 10d0 ! current time step
39 :
40 : ! these are dummy vals so function doesn't give nans
41 1 : s%star_mass = 1d0
42 1 : s%he_core_mass = 1d0
43 1 : b%mtransfer_rate = 0d0
44 1 : b%env_old(b%d_i) = 0d0
45 1 : b%angular_momentum_j_old = 0d0
46 1 : b%separation_old = 0d0
47 1 : b%eccentricity_old = 0d0
48 1 : b%fa = -1d0
49 1 : b%fe = -1d0
50 1 : b%fj = -1d0
51 1 : b%fm = -1d0
52 1 : b%fdm = -1d0
53 1 : b%mtransfer_rate = 0d0
54 1 : b%s_donor%center_h1 = 0d0
55 1 : b%varcontrol_ms = 0d0
56 1 : b%varcontrol_post_ms = 0d0
57 :
58 : ! test for rl
59 1 : b%rl_relative_gap_old(b%d_i) = -0.102d0
60 1 : b%rl_relative_gap(b%d_i) = -0.100d0 ! so change = -2d-3
61 1 : b%fr = 1d-2
62 1 : b%fr_limit = 1d-2
63 1 : b%fr_dt_limit = 0d0
64 1 : b%fr_hard = -1d0
65 1 : b%ignore_hard_limits_this_step = .true.
66 :
67 1 : b%dt_softening_factor = 0d0 ! no softening
68 1 : b%time_delta_coeff = 1d0
69 : ! rel change is 2d-2 so timestep should be cut in half
70 : ! max(rel_change, fr_limit) / fr = 2d0 = cut factor
71 1 : res = binary_pick_next_timestep(b)
72 :
73 1 : write (*, 1) 'b% max_timestep / secyer', b%max_timestep/secyer ! should be 5
74 :
75 1 : b%max_timestep = 10d0
76 1 : b%time_delta_coeff = 0.5d0
77 : ! now fr is effectively 0.5d-2, so timestep cut in 4 this time
78 1 : res = binary_pick_next_timestep(b)
79 :
80 1 : write (*, 1) 'b% max_timestep / secyer', b%max_timestep/secyer ! should be 2.5
81 :
82 : ! Test accretion disk functions
83 1 : write (*, *) 'check L2_mass_loss_fraction behavior'
84 :
85 1 : fL2 = binary_L2_mass_loss_fraction(20.0_dp, 10.0_dp, 0.001_dp, 2.0_dp, 0.1_dp, 1.3_dp/2.4_dp, ierr)
86 :
87 1 : write (*, 1) 'fL2', fL2 ! should be ~0.9
88 :
89 1 : fL2 = binary_L2_mass_loss_fraction(20.0_dp, 10.0_dp, 0.0001_dp, 2.0_dp, 0.1_dp, 1.3_dp/2.4_dp, ierr)
90 :
91 1 : write (*, 1) 'fL2', fL2 ! should be ~0.2
92 :
93 1 : fL2 = binary_L2_mass_loss_fraction(20.0_dp, 18.0_dp, 0.0_dp, 304.0_dp, 0.1_dp, 0.64_dp, ierr)
94 :
95 1 : write (*, 1) 'fL2', fL2 ! should be 0.0
96 :
97 1 : write (*, '(a)') 'done'
98 :
99 1 : end subroutine do_test
100 :
101 : end module test_binary_mod
102 :
103 1 : program test_binary
104 1 : use test_binary_mod
105 : implicit none
106 1 : call do_test
107 1 : end program test_binary
|