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