! inlist to evolve a 15 solar mass star

! For the sake of future readers of this file (yourself included),
! ONLY include the controls you are actually using.  DO NOT include
! all of the other controls that simply have their default values.

&star_job
   ! pre_ms_relax_to_start_radiative_core = .false.
   create_pre_main_sequence_model = .true.
   pre_ms_T_c = 3d5
   change_mass_years_for_dt = 1d-2

    ! initial rotation defined separetely
    read_extra_star_job_inlist(1) = .true.
    extra_star_job_inlist_name(1) = 'inlist_extra'

  ! display on-screen plots
    pgstar_flag = .true.

    show_log_description_at_start = .false.

    new_rotation_flag = .true.
    change_rotation_flag = .true.
    relax_initial_omega_div_omega_crit = .true.
    !! this is just a random number, tidal sync takes care of it
    use_w_div_wc_flag_with_rotation = .true.

    set_uniform_initial_composition = .true.
    initial_h1 = 0.7155d0
    initial_h2 = 0d0
    initial_he3 = 0d0
    initial_he4 = 0.2703d0
    initial_zfracs = 6

    save_model_when_terminate = .true.
    save_model_filename = "model.dat"

/ ! end of star_job namelist


&eos
  use_Skye = .false. ! otherwise can run into issues due to mass_fraction_limit_for_Skye
  use_PC = .true.
  !mass_fraction_limit_for_Skye = 1d-15
/ ! end of eos namelist


&kap
  ! kap options
  ! see kap/defaults/kap.defaults
  use_Type2_opacities = .true.
  Zbase = 0.006 !0.0142
  kap_file_prefix = 'a09'
  kap_CO_prefix = 'a09_co'

/ ! end of kap namelist


&controls
    initial_z = 0.006

    photo_interval = 25
    Pextra_factor = 1.5d0

    ! initial mass defined separetely
    read_extra_controls_inlist(1) = .true.
    extra_controls_inlist_name(1) = 'inlist_extra'

    timestep_factor_for_retries = 0.8
    min_timestep_factor = 0.9
    max_timestep_factor = 1.05d0
    retry_hold = 5
    redo_limit = -1
    relax_hard_limits_after_retry = .false.
    min_timestep_limit = 1d-6

    report_solver_progress =   .false. 
    solver_iters_timestep_limit = 30
    gold_solver_iters_timestep_limit = 30
    gold2_solver_iters_timestep_limit = 30
    solver_max_tries_before_reject = 40
    gold2_iter_for_resid_tol2 = 5
    gold2_iter_for_resid_tol3 = 5
    gold2_tol_residual_norm3 = 1d-6
    gold2_tol_max_residual3 = 1d-3
    max_tries_for_retry = 40
    max_tries_after_5_retries = 40

    scale_max_correction = 0.01d0
    scale_max_correction_for_negative_surf_lum = .true.
    corr_coeff_limit = 1d-1
    ignore_min_corr_coeff_for_scale_max_correction = .true.
    ignore_species_in_max_correction = .true.
    max_resid_jump_limit = 1d99
    restore_mesh_on_retry = .true.
    num_steps_to_hold_mesh_after_retry = 5

    ! Fixing the position of the Lagrangian region of the mesh helps
    ! convergence near the Eddington limit
    max_logT_for_k_below_const_q = 100
    max_q_for_k_below_const_q = 0.995
    min_q_for_k_below_const_q = 0.995
    max_logT_for_k_const_mass = 100
    max_q_for_k_const_mass = 0.99
    min_q_for_k_const_mass = 0.99

    !extra spatial resolution
    mesh_delta_coeff = 1
    mesh_delta_coeff_for_highT = 1.0d0
    mesh_Pgas_div_P_exponent = 0.5d0
    max_dq = 0.005
    min_dq_for_xa = 1d-5
    max_allowed_nz = 50000

    !extra time resolution
    time_delta_coeff = 1

    ! Reduce superadiabaticity near the Eddington limit
    MLT_option = 'TDC'
    alpha_TDC_DAMPR = 1d0 ! for physical reasons
    use_superad_reduction = .true.
    superad_reduction_Gamma_limit = 0.5d0
    superad_reduction_Gamma_limit_scale = 5d0
    superad_reduction_Gamma_inv_scale = 5d0
    superad_reduction_diff_grads_limit = 1d-2 ! this is lowered to 1d-2 in the first 100 steps in run_star_extras
    superad_reduction_limit = -1d0

    max_model_number = 20000
    max_number_retries = 500

    ! extra controls for timestep
    ! these are for changes in mdot at the onset of mass transfer
    delta_lg_star_mass_limit = 5d-3
    delta_lg_star_mass_hard_limit = 1d-2
    ! these are to properly resolve core hydrogen depletion
    delta_lg_XH_cntr_limit = 0.05d0
    delta_lg_XH_cntr_max = 0.0d0
    delta_lg_XH_cntr_min = -5.0d0
    ! these are to properly resolve core helium depletion
    delta_lg_XHe_cntr_limit = 0.05d0
    delta_lg_XHe_cntr_max = 0.0d0
    delta_lg_XHe_cntr_min = -5.0d0
    ! these are to properly resolve core carbon depletion
    delta_lg_XC_cntr_limit = 0.05d0
    delta_lg_XC_cntr_max = 0.0d0
    delta_lg_XC_cntr_min = -5.0d0
    ! controls for absolute changes in composition
    delta_XH_cntr_limit = 0.002d0
    delta_XHe_cntr_limit = 0.002d0
    delta_XC_cntr_limit = 0.002d0
    delta_XH_cntr_hard_limit = 0.004d0
    !delta_XHe_cntr_hard_limit = 0.004d0
    !delta_XC_cntr_hard_limit = 0.004d0
    ! this is mainly to resolve properly when the star goes off the main sequence
    delta_HR_limit = 0.005d0
    ! relax default dHe/He and dH/H
    ! dHe_div_He_limit = 2d0
    ! dH_div_H_limit = 2d0

    ! we're not looking for much precision at the very late stages
    dX_nuc_drop_limit = 5d-2
    adjust_J_q_limit = -1d0
    adjust_J_q_hard_limit = -1d0

    delta_lgL_nuc_limit = 0.05d0

    log_directory = 'LOGS'

    profile_interval = 50
    history_interval = 1
    terminal_interval = 10
    write_header_frequency = 50
    max_num_profile_models = 10000

    use_ledoux_criterion = .true.

    ! Replace <<MIXING_LENGTH>> with the desired value of the mixing length, e.g. 1.5
    mixing_length_alpha = <<MIXING_LENGTH>> 
    alpha_semiconvection = 1d0
    thermohaline_coeff = 1d0
    remove_small_D_limit = 1d-50
    mixing_D_limit_for_log = 1d-50

    eps_mdot_leak_frac_factor = 0d0
    max_abs_rel_run_E_err = -1d0

  ! rotational mixing coeffs
    am_nu_ST_factor = 1.0
    D_visc_factor = 0.0
    am_nu_SH_factor = 0.0
    D_ST_factor = 0.0
    D_SH_factor = 0.0
    D_GSF_factor = 1.0
    D_ES_factor = 1.0
    D_SSI_factor = 1.0
    D_DSI_factor = 1.0
    am_D_mix_factor = 0.0333d0
    am_gradmu_factor = 0.1d0
    num_cells_for_smooth_gradL_composition_term = 5

  ! options for limiting of rotation corrections
    w_div_wcrit_max = 0.99d0
    w_div_wcrit_max2 = 0.98d0

  ! wind options
    ! for models with M>=10
    use_other_wind = .true.

    ! for 3 and 1 Msun models
    !cool_wind_full_on_T = 9.99d9
    !hot_wind_full_on_T = 1d10 
    !cool_wind_RGB_scheme = 'Reimers'
    !cool_wind_AGB_scheme = 'Blocker'
    !RGB_to_AGB_wind_switch = 1d-4
    !Reimers_scaling_factor = 0.1d0  
    !Blocker_scaling_factor = 0.2d0     

  ! controls for implicit wind
    surf_avg_tau_min = 0
    surf_avg_tau = 10
    max_mdot_redo_cnt = 200
    min_years_dt_for_redo_mdot = 0
    surf_omega_div_omega_crit_limit = 0.99d0
    surf_omega_div_omega_crit_tol = 0.06d0
    rotational_mdot_boost_fac = 1d10
    rotational_mdot_kh_fac = 1d10
    mdot_revise_factor = 1.2
    implicit_mdot_boost = 0.1
    
  ! we use step overshooting
    overshoot_scheme(1) = 'step'
    overshoot_zone_type(1) = 'burn_H'
    overshoot_zone_loc(1) = 'core'
    overshoot_bdy_loc(1) = 'top'
    overshoot_f(1) = 0.345 ! for M>10
    !overshoot_f(1) = 0.11 ! For M<10
    overshoot_f0(1) = 0.01
  ! a small amount of overshooting on top of any other convective core
  ! avoid spurious numerical behavior
    overshoot_scheme(2) = 'exponential'
    overshoot_zone_type(2) = 'any'
    overshoot_zone_loc(2) = 'core'
    overshoot_bdy_loc(2) = 'top'
    overshoot_f(2) = 0.01
    overshoot_f0(2) = 0.005

    calculate_Brunt_N2 = .true.

  ! this is to avoid odd behaviour when a star switches from accreting to mass losing
    max_mdot_jump_for_rotation = 1d99 

    log_L_lower_limit = -3d0

/ ! end of controls namelist
