LCOV - code coverage report
Current view: top level - binary/test/src - test_binary.f90 (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 52 52
Test Date: 2025-06-06 17:08:43 Functions: 100.0 % 3 3

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

Generated by: LCOV version 2.0-1