mesa
mesa copied to clipboard
Angular momentum conservation check
Looking through solve_omega_mix I noticed that we only check if angular momentum was conserved if there are no other torques:
if (.not. (s% use_other_torque .or. s% use_other_torque_implicit .or. &
associated(s% binary_other_torque))) then
! check conservation for cases with no extra torque
J_tot1 = total_angular_momentum(s) ! what we have
if (abs(J_tot0 - J_tot1) > s% angular_momentum_error_retry*abs(J_tot0)) then
s% retry_message = 'retry: failed to conserve angular momentum in mixing'
write(*,*) "angular momentum error larger than angular_momentum_error_retry", abs(J_tot0 - J_tot1)/abs(J_tot0)
do_solve_omega_mix = retry
else if (abs(J_tot0 - J_tot1) > s% angular_momentum_error_warn*abs(J_tot0)) then
write(*,*) "angular momentum error larger than angular_momentum_error_warn", abs(J_tot0 - J_tot1)/abs(J_tot0)
end if
if (dbg) then
write(*,2) 'final J_tot1', s% model_number, J_tot1
write(*,2) '(J_tot1 - J_tot0)/J_tot0', &
steps_used, (J_tot1 - J_tot0)/J_tot0, J_tot0, J_tot1
end if
end if
Shouldn't we be checking this even if there are other torques (and just comparing the change against the net torque)?