Skip to content

Commit 72f0d21

Browse files
authored
Fixing fpe's in binary (#486)
Work on fpe's in binary as well as a few other places in star.
1 parent 18ddce3 commit 72f0d21

File tree

5 files changed

+60
-40
lines changed

5 files changed

+60
-40
lines changed

binary/private/binary_evolve.f90

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ subroutine binarydata_init(b, doing_restart)
188188
b% CE_lambda2 = 0d0
189189
b% CE_Ebind1 = 0d0
190190
b% CE_Ebind2 = 0d0
191+
b% mtransfer_rate = 0
191192

192193
b% num_tries = 0
193194

@@ -337,6 +338,11 @@ integer function binary_evolve_step(b)
337338
b% eccentricity = b% eccentricity + get_edot(b) *b% time_step*secyer
338339
if (b% eccentricity < b% min_eccentricity) b% eccentricity = b% min_eccentricity
339340
if (b% eccentricity > b% max_eccentricity) b% eccentricity = b% max_eccentricity
341+
else
342+
b% edot_tidal = 0d0
343+
b% edot_enhance = 0d0
344+
b% extra_edot = 0d0
345+
b% edot = 0d0
340346
end if
341347

342348
!use new eccentricity to calculate new time coordinate
@@ -504,17 +510,19 @@ integer function binary_finish_step(b)
504510

505511
binary_finish_step = keep_going
506512
! update change factor in case mtransfer_rate has changed
507-
if(b% mtransfer_rate_old /= b% mtransfer_rate .and. &
508-
b% mtransfer_rate /= 0 .and. b% mtransfer_rate_old /= 0) then
509-
if(b% mtransfer_rate < b% mtransfer_rate_old) then
510-
b% change_factor = b% change_factor*(1d0-b% implicit_lambda) + b% implicit_lambda* &
511-
(1+b% change_factor_fraction*(b% mtransfer_rate/b% mtransfer_rate_old-1))
512-
else
513-
b% change_factor = b% change_factor*(1d0-b% implicit_lambda) + b% implicit_lambda* &
514-
(1+b% change_factor_fraction*(b% mtransfer_rate_old/b% mtransfer_rate-1))
513+
if(.not. b% doing_first_model_of_run) then
514+
if(b% mtransfer_rate_old /= b% mtransfer_rate .and. &
515+
b% mtransfer_rate /= 0 .and. b% mtransfer_rate_old /= 0) then
516+
if(b% mtransfer_rate < b% mtransfer_rate_old) then
517+
b% change_factor = b% change_factor*(1d0-b% implicit_lambda) + b% implicit_lambda* &
518+
(1+b% change_factor_fraction*(b% mtransfer_rate/b% mtransfer_rate_old-1))
519+
else
520+
b% change_factor = b% change_factor*(1d0-b% implicit_lambda) + b% implicit_lambda* &
521+
(1+b% change_factor_fraction*(b% mtransfer_rate_old/b% mtransfer_rate-1))
522+
end if
523+
if(b% change_factor > b% max_change_factor) b% change_factor = b% max_change_factor
524+
if(b% change_factor < b% min_change_factor) b% change_factor = b% min_change_factor
515525
end if
516-
if(b% change_factor > b% max_change_factor) b% change_factor = b% max_change_factor
517-
if(b% change_factor < b% min_change_factor) b% change_factor = b% min_change_factor
518526
end if
519527

520528
! store all variables into "old"

binary/private/binary_timestep.f90

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -126,39 +126,46 @@ integer function binary_pick_next_timestep(b)
126126

127127
if (b% max_timestep < 0) b% max_timestep = b% s_donor% dt
128128

129-
130129
b% env(b% d_i) = s% star_mass - s% he_core_mass
131130
if (b% point_mass_i == 0) then
132131
b% env(b% a_i) = b% s_accretor% star_mass - b% s_accretor% he_core_mass
133132
end if
134133

135-
if (b% env_old(b% d_i) /= 0) then
136-
env_change = b% env(b% d_i) - b% env_old(b% d_i)
134+
if(.not. b% doing_first_model_of_run) then
135+
if (b% env_old(b% d_i) /= 0) then
136+
env_change = b% env(b% d_i) - b% env_old(b% d_i)
137+
else
138+
env_change = 0
139+
end if
140+
141+
if (b% rl_relative_gap_old(b% d_i) /= 0) then
142+
rel_gap_change = b% rl_relative_gap_old(b% d_i) - b% rl_relative_gap(b% d_i)
143+
else
144+
rel_gap_change = 0
145+
end if
146+
147+
if (b% angular_momentum_j_old /= 0) then
148+
j_change = b% angular_momentum_j - b% angular_momentum_j_old
149+
else
150+
j_change = 0
151+
end if
152+
153+
if (b% separation_old /= 0) then
154+
sep_change = b% separation - b% separation_old
155+
else
156+
sep_change = 0
157+
end if
158+
if (b% eccentricity_old /= 0) then
159+
e_change = b% eccentricity - b% eccentricity_old
160+
else
161+
e_change = 0
162+
end if
137163
else
138164
env_change = 0
139-
end if
140-
141-
if (b% rl_relative_gap_old(b% d_i) /= 0) then
142-
rel_gap_change = b% rl_relative_gap_old(b% d_i) - b% rl_relative_gap(b% d_i)
143-
else
144165
rel_gap_change = 0
145-
end if
146-
147-
if (b% angular_momentum_j_old /= 0) then
148-
j_change = b% angular_momentum_j - b% angular_momentum_j_old
149-
else
150166
j_change = 0
151-
end if
152-
153-
if (b% separation_old /= 0) then
154-
sep_change = b% separation - b% separation_old
155-
else
156167
sep_change = 0
157-
end if
158-
if (b% eccentricity_old /= 0) then
159-
e_change = b% eccentricity - b% eccentricity_old
160-
else
161-
e_change = 0
168+
e_change = 0
162169
end if
163170

164171
! get limits for dt based on relative changes

star/private/history.f90

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1950,10 +1950,12 @@ subroutine history_getval(&
19501950
end do
19511951

19521952
case(h_i_rot_total)
1953-
val = 0d0
1954-
do k = 1, s% nz
1955-
val = val + s% dm_bar(k) * s%i_rot(k)% val
1956-
end do
1953+
if(s% rotation_flag) then
1954+
val = 0d0
1955+
do k = 1, s% nz
1956+
val = val + s% dm_bar(k) * s%i_rot(k)% val
1957+
end do
1958+
end if
19571959
case(h_surf_avg_j_rot)
19581960
val = if_rot(s% j_rot_avg_surf)
19591961
case(h_surf_avg_omega)
@@ -2728,9 +2730,9 @@ subroutine history_getval(&
27282730
int_val = s% k_below_const_q
27292731
is_int_val = .true.
27302732
case (h_q_below_const_q)
2731-
val = s% q(s% k_below_const_q)
2733+
if(s% k_below_const_q>0) val = s% q(s% k_below_const_q)
27322734
case (h_logxq_below_const_q)
2733-
val = safe_log10(sum(s% dq(1:s% k_below_const_q - 1)))
2735+
if(s% k_below_const_q>0) val = safe_log10(sum(s% dq(1:s% k_below_const_q - 1)))
27342736

27352737
case (h_k_const_mass)
27362738
int_val = s% k_const_mass

star/test_suite/make_env/src/run_star_extras.f90

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ subroutine create_env(id, s, ierr)
358358

359359
s% model_number = 0
360360
s% star_age = 0
361+
s% crystal_core_boundary_mass = -1d0
361362

362363
write(*,2) 'start.mod', nz
363364
call star_write_model(id, 'start.mod', ierr)
@@ -479,6 +480,7 @@ subroutine do1_cell(ierr) ! uses r(k), T_m1, P_m1, logRho_m1
479480
s% lnT(k) = logT*ln10
480481
s% rho(k) = exp10(logRho)
481482
s% T(k) = T_00
483+
s% rho_start(k) = s% rho(k)
482484
call star_do_eos_for_cell(s% id, k, ierr)
483485
if (ierr /= 0) then
484486
write(*, *) 'Call star_do_eos_for_cell failed', k
@@ -498,6 +500,7 @@ subroutine do1_cell(ierr) ! uses r(k), T_m1, P_m1, logRho_m1
498500
s% csound_start(k) = s% csound(k)
499501
s% mlt_gradT_fraction = -1d0
500502
s% adjust_mlt_gradT_fraction(k) = -1d0
503+
s% gradL_composition_term(k) = 0d0
501504

502505
! skipping use_other_alpha_mlt and other_gradr_factor
503506
s% alpha_mlt(k) = s% mixing_length_alpha

star/test_suite/starspots/src/run_star_extras.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ subroutine YREC_spots_other_mlt_results(id, k, MLT_option, & ! NOTE: k=0 is a v
165165

166166
!------------------------------
167167
!if (s% star_age >= 10d0) then
168-
if (.not. s% doing_relax) then
168+
if (.not. s% doing_relax .and. .not. s% doing_first_model_of_run) then
169169
xspot_of_r = (P - PB_i)/P
170170
gradr_spot = gradr/( fspot*pow4(xspot_of_r) + 1d0 - fspot)
171171
else

0 commit comments

Comments
 (0)