diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index f15224c7a..488f69f8b 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -88,6 +88,9 @@ and ``photosphere_r`` instead of the outermost-cell ``T(1)``, ``log10(grav(1))`` Fixed an issue where the `find0_quadratic` subroutine provided by the `num` module could accidentally divide by 0 when the points used for the quadratic interpolant did not bracket a root. +Incomplete split burns now trigger a stellar retry when they reach +``burn_steps_hard_limit``. + Fixed ``switch_to_radiative`` zeroing saved ``mlt_vc`` during TDC photo restarts and preparation for a new step. Mixing cleanup now preserves the velocity until it has been copied to ``mlt_vc_old``. diff --git a/net/private/net_burn_support.f90 b/net/private/net_burn_support.f90 index f9357c5dc..4374014ef 100644 --- a/net/private/net_burn_support.f90 +++ b/net/private/net_burn_support.f90 @@ -143,8 +143,7 @@ subroutine netint( & end if ! this is the normal exit point - if ( (nstp == max_steps) .or. & - (x-stopp)*(stopp-start)>= 0.0d0) then + if ((x-stopp)*(stopp-start)>= 0.0d0) then call burner_finish_substep(nstp, x, y, ierr) return end if @@ -178,6 +177,8 @@ subroutine netint( & ! back for another iteration or death end do + +! if we made it here, we took too many steps ierr = -1 return call mesa_error(__FILE__,__LINE__,'more than max_steps steps required in netint') @@ -638,4 +639,3 @@ end subroutine net_pzextr end module net_burn_support - diff --git a/star/private/struct_burn_mix.f90 b/star/private/struct_burn_mix.f90 index ac1d3ac94..2b0fea579 100644 --- a/star/private/struct_burn_mix.f90 +++ b/star/private/struct_burn_mix.f90 @@ -104,11 +104,8 @@ integer function do_struct_burn_mix(s, skip_global_corr_coeff_limit) end do if (s% trace_evolve) write(*,*) 'call do_burn' do_struct_burn_mix = do_burn(s, dt) - if (do_struct_burn_mix /= keep_going) then - write(*,2) 'failed in do_burn', s% model_number - call mesa_error(__FILE__,__LINE__,'do_struct_burn_mix') - return - end if + if (do_struct_burn_mix /= keep_going) return + do_struct_burn_mix = retry call set_vars_if_needed(s, s% dt, 'after do_burn', ierr) if (ierr /= 0) return do k=1,s% nz @@ -826,8 +823,8 @@ integer function do_burn(s, dt) real(dp), intent(in) :: dt integer :: & - k_bad, ierr, max_num_iters_k, nz, op_err, & - k, num_iters, species, max_num_iters_used, & + k_bad, ierr, nz, op_err, & + k, num_iters, species, & screening_mode, kmin integer(i8) :: time0 real(dp) :: total, avg_epsnuc, min_T_for_const_density_solver @@ -857,8 +854,6 @@ integer function do_burn(s, dt) if (dt <= 0d0) return - max_num_iters_used = 0 - max_num_iters_k = 0 k_bad = 0 screening_mode = get_screening_mode(s,ierr) @@ -894,7 +889,9 @@ integer function do_burn(s, dt) !$OMP PARALLEL DO PRIVATE(k,op_err,num_iters,avg_epsnuc) SCHEDULE(dynamic,2) do k = kmin, nz - if (k_bad /= 0) cycle +!$OMP ATOMIC READ + op_err = k_bad + if (op_err /= 0) cycle if (s% T_start(k) < s% op_split_burn_min_T) then ! We get here if we have an off center ignition, ! the arrays wont have been initialised earlier as they stop at the @@ -910,24 +907,20 @@ integer function do_burn(s, dt) screening_mode, & dt, num_iters, avg_epsnuc, burn_dbg, op_err) if (op_err /= 0) then - ierr = -1 +!$OMP ATOMIC WRITE k_bad = k cycle end if call do_eos_for_cell(s,k,op_err) if (op_err /= 0) then write(*,2) 'do_burn failed in do_eos_for_cell', k - ierr = -1 +!$OMP ATOMIC WRITE k_bad = k cycle end if !write(*,3) 'num_iters', k, num_iters s% burn_num_iters(k) = num_iters s% burn_avg_epsnuc(k) = avg_epsnuc - if (num_iters > max_num_iters_used) then - max_num_iters_used = num_iters - max_num_iters_k = k - end if end do !$OMP END PARALLEL DO @@ -936,34 +929,21 @@ integer function do_burn(s, dt) if (s% doing_timing) & call update_time(s, time0, total, s% time_solve_burn) - if (ierr /= 0) then + if (k_bad /= 0) then if (s% report_ierr) write(*,2) 'do_burn failed', k_bad - return - call mesa_error(__FILE__,__LINE__,'do_burn') - - do_burn = retry + s% result_reason = nonzero_ierr + s% retry_message = 'split burn failed' + s% retry_message_k = k_bad if (trace .or. s% report_ierr) then write(*,*) 'do_burn ierr' end if - call restore return end if if (dbg) write(*,2) 'done do_burn' - contains - - subroutine restore - integer :: j, k - do k = 1, nz - do j=1,species - s% xa(j,k) = s% xa_start(j,k) - end do - end do - end subroutine restore - end function do_burn