From 6b1feb91eba36dbb09eeac62e4b1679f20e45747 Mon Sep 17 00:00:00 2001 From: Debraheem Date: Thu, 3 Sep 2026 14:59:27 -0400 Subject: [PATCH] Fix rotation and ST time smoothing state on restart --- star/private/alloc.f90 | 12 ++++++------ star/private/evolve.f90 | 3 ++- star/private/photo_in.f90 | 2 +- star/private/photo_out.f90 | 2 +- star/private/read_model.f90 | 5 ++++- star_data/public/star_data_def.inc | 2 +- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/star/private/alloc.f90 b/star/private/alloc.f90 index 53f5ac571c..c69697799c 100644 --- a/star/private/alloc.f90 +++ b/star/private/alloc.f90 @@ -524,6 +524,12 @@ subroutine star_info_arrays(s, c_in, action_in, ierr) if (failed('mlt_vc')) exit call do1(s% conv_vel, c% conv_vel) if (failed('conv_vel')) exit + + ! These are persistent inputs needed for ST time smoothing. + call do1(s% D_ST_start, c% D_ST_start) + if (failed('D_ST_start')) exit + call do1(s% nu_ST_start, c% nu_ST_start) + if (failed('nu_ST_start')) exit end if call do1(s% q, c% q) @@ -811,12 +817,6 @@ subroutine star_info_arrays(s, c_in, action_in, ierr) call do1(s% dynamo_B_phi, c% dynamo_B_phi) if (failed('dynamo_B_phi')) exit - !for ST time smoothing - call do1(s% D_ST_start, c% D_ST_start) - if (failed('D_ST_start')) exit - call do1(s% nu_ST_start, c% nu_ST_start) - if (failed('nu_ST_start')) exit - call do1(s% opacity, c% opacity) if (failed('opacity')) exit call do1(s% d_opacity_dlnd, c% d_opacity_dlnd) diff --git a/star/private/evolve.f90 b/star/private/evolve.f90 index dece07d13d..5e218a15fa 100644 --- a/star/private/evolve.f90 +++ b/star/private/evolve.f90 @@ -180,7 +180,7 @@ subroutine test_set_undefined call set_to_NaN(s% mesh_adjust_PE_conservation) call set_to_NaN(s% min_conv_time_scale) call set_to_NaN(s% mstar_dot_old) - call set_to_NaN(s% mstar_old) + if (.not. s% doing_first_model_after_restart) call set_to_NaN(s% mstar_old) call set_to_NaN(s% mx1_bot) call set_to_NaN(s% mx1_bot_r) call set_to_NaN(s% mx1_top) @@ -1894,6 +1894,7 @@ integer function prepare_for_new_step(s) call new_generation(s, ierr) if (failed('new_generation ierr')) return + s% doing_first_model_after_restart = .false. s% generations = 2 if ((s% time + s% dt_next) > s% max_age*secyer .and. s% max_age > 0) then diff --git a/star/private/photo_in.f90 b/star/private/photo_in.f90 index aa8879bf5c..b1e7d987a5 100644 --- a/star/private/photo_in.f90 +++ b/star/private/photo_in.f90 @@ -135,7 +135,7 @@ subroutine read_star_photo(s, fname, ierr) s% dq(1:nz), s% xa(:,1:nz), s% xh(:,1:nz), & s% omega(1:nz), s% j_rot(1:nz), s% mlt_vc(1:nz), s% conv_vel(1:nz), & s% D_ST_start(1:nz), s% nu_ST_start(1:nz), & ! needed for ST time smoothing - s% have_ST_start_info + s% have_ST_start_info, s% mstar_old call read_part_number(iounit) if (failed('rsp_num_periods')) return diff --git a/star/private/photo_out.f90 b/star/private/photo_out.f90 index 5967e184e2..ee8d8cb440 100644 --- a/star/private/photo_out.f90 +++ b/star/private/photo_out.f90 @@ -78,7 +78,7 @@ subroutine output_star_photo(s,iounit,ierr) s% dq(1:nz), s% xa(:,1:nz), s% xh(:,1:nz), & s% omega(1:nz), s% j_rot(1:nz), s% mlt_vc(1:nz), s% conv_vel(1:nz), & s% D_ST_start(1:nz), s% nu_ST_start(1:nz), & ! needed for ST time smoothing - s% have_ST_start_info + s% have_ST_start_info, s% mstar_old call write_part_number(iounit) write(iounit) & diff --git a/star/private/read_model.f90 b/star/private/read_model.f90 index 9f65c98a23..e68665604f 100644 --- a/star/private/read_model.f90 +++ b/star/private/read_model.f90 @@ -106,7 +106,10 @@ subroutine finish_load_model(s, restart, ierr) ! to account for the loading of old saved models. if (s% have_j_rot) then if (restart) then - ! only need to compute irot, w_div_w_crit_roche is stored in photos + ! Photo loading does not restore w_div_w_crit_roche. + ! Initialize it before either the fallback or set_vars can use it. + call use_xh_to_update_i_rot(s) + ! Preserve the photo's omega for rotation-dependent tidal deformation. call set_i_rot_from_omega_and_j_rot(s) else ! need to set w_div_w_crit_roche as well diff --git a/star_data/public/star_data_def.inc b/star_data/public/star_data_def.inc index 90c31b5bf4..4bbfdce821 100644 --- a/star_data/public/star_data_def.inc +++ b/star_data/public/star_data_def.inc @@ -1,7 +1,7 @@ character(len=24) :: version_number ! mesa version from file $MESA_DIR/data/version_number - integer, parameter :: star_def_version = 18 + integer, parameter :: star_def_version = 19 integer, parameter :: nz_alloc_extra = 200