! SMNA 2022 - Lecture 3 - pgStar

&star_job

      mesa_dir =''

! create pre-main sequence or interpolate a pre-made zams model
      create_pre_main_sequence_model = .true. 
      pre_ms_relax_num_steps = 100

! 49 isotope network
      change_net              = .true.   
      new_net_name            = 'mesa_49.net' !'basic.net'
      show_net_reactions_info = .false.
      list_net_reactions      = .false.
      show_net_species_info   = .false.

! turn on hydro
      change_initial_v_flag = .true.
      change_v_flag = .false.
      new_v_flag = .true.

! set initial ages and model numbers
      set_initial_age          = .true.
      initial_age              = 0 ! in years
      set_initial_model_number = .true.
      initial_model_number     = 0


! turn on rotation near zams     
      change_rotation_flag = .false.      
      new_rotation_flag    = .true.

      near_zams_relax_omega_div_omega_crit = .true.  ! true to turn on rotation at zams
      num_steps_to_relax_rotation = 50               ! use this many steps to change value    
      relax_omega_max_yrs_dt = 1.0d0                 ! keep timesteps small to prevent significant evolution
      new_omega_div_omega_crit = 1.9d-4   
      
! save models at run termination 
      save_model_when_terminate = .true.
      save_model_filename = 'zams.mod'
      write_profile_when_terminate = .true.
      filename_for_profile_when_terminate = 'zams.data'
      save_photo_when_terminate = .true.

! use my history / profile columns
      history_columns_file = './history_columns.list'
      profile_columns_file = './profile_columns.list'

! pgstar
      pgstar_flag = .true.
      disable_pgstar_during_relax_flag = .true.
      save_pgstar_files_when_terminate = .true.

/ ! end of star_job namelist



&eos
  ! equation-of-state options
  ! see eos/defaults/eos.defaults

/ ! end of eos namelist


&kap
      ! opacity options
      ! see kap/defaults/kap.defaults

      use_Type2_opacities = .true.
      Zbase = 0.02

      kap_file_prefix = 'a09'    ! 'gs98' 'a09'  'OP_a09' 'OP_gs98'
      kap_CO_prefix   = 'a09_co' ! 'gs98_co' 'a09_co'

/ ! end of kap namelist


&controls

! mass and metallicity
       initial_mass = 2.10d0   
       initial_z = 0.020d0     ! Solar Metallicity 


! stopping condition
! first stop at the envelope limit, then the luminosity limit for cooling
!       stop_near_zams = .true.
       envelope_mass_limit = 0.1d0   
       max_model_number = 400000


! output frequencies
       photo_interval         = 100
       photo_digits           = 6
       profile_interval       = 100
       max_num_profile_models = 4000
       history_interval       = 1
       terminal_interval      = 10
       write_header_frequency = 10
!       extra_terminal_output_file = 'log.txt'


! atmosphere
    atm_option = 'T_tau'
    atm_T_tau_relation = 'Eddington'
    atm_T_tau_opacity = 'fixed'


! winds
      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.1   
      Blocker_scaling_factor = 0.5   


! options for energy conservation (see MESA V, Section 3)
      energy_eqn_option = 'dedt'
      use_gold_tolerances = .false.


! convergence
      varcontrol_target           = 5.0d-4
      min_timestep_factor         = 0.8d0
      max_timestep_factor         = 1.05d0


! mass resolution
       max_dq = 0.05
       mesh_delta_coeff = 1.5   
       max_allowed_nz = 400000


! resolve the outer layers
     log_tau_function_weight = 10


! time step resolution on fuel depletion
      delta_XH_cntr_limit  = 0.01d0
      delta_XHe_cntr_limit = 0.01d0
      delta_XC_cntr_limit  = 0.01d0
      delta_XO_cntr_limit  = 0.01d0

      delta_lg_XH_cntr_limit = 0.01d0
      delta_lg_XH_cntr_max   = 0.0d0
      delta_lg_XH_cntr_min   = -6.0d0
      delta_lg_XH_cntr_hard_limit = 0.02d0

      delta_lg_XHe_cntr_limit = 0.01d0
      delta_lg_XHe_cntr_max   = 0.0d0
      delta_lg_XHe_cntr_min   = -6.0d0
      delta_lg_XHe_cntr_hard_limit = 0.02d0

      delta_lg_XC_cntr_limit = 0.01d0
      delta_lg_XC_cntr_max   = 0.0d0
      delta_lg_XC_cntr_min   = -3.0d0
      delta_lg_XC_cntr_hard_limit = 0.02d0

      delta_lg_XNe_cntr_limit = 0.01d0
      delta_lg_XNe_cntr_max   = 0.0d0
      delta_lg_XNe_cntr_min   = -3.0d0
      delta_lg_XNe_cntr_hard_limit = 0.02d0

      delta_lg_XO_cntr_limit = 0.01d0
      delta_lg_XO_cntr_max   = 0.0d0
      delta_lg_XO_cntr_min   = -3.0d0
      delta_lg_XO_cntr_hard_limit = 0.02d0


! mainly to resolve in the HR diagram when the star goes off the main sequence
!      delta_HR_limit = 0.0025d0
      delta_lgL_He_limit = 0.1


! mixing

! convection 
   mixing_length_alpha = 1.5d0
   MLT_option = 'Henyey'

! mlt++
    okay_to_reduce_gradT_excess = .true.

! schwartzchild or ledoux
    use_ledoux_criterion = .true.

    num_cells_for_smooth_gradL_composition_term = 10
    threshold_for_smooth_gradL_composition_term = 0.02

    num_cells_for_smooth_brunt_B = 10
    threshold_for_smooth_brunt_B = 0.1


! semiconvection
      alpha_semiconvection = 1.0d-2      ! 1.0d-2  1.0d-4 1.0
      semiconvection_option = 'Langer_85 mixing; gradT = gradr'


! thermohaline
      thermohaline_coeff = 1.0d0          ! 1.0d0  0.1 100
      thermohaline_option = 'Kippenhahn'  !  'Kippenhahn'  'Traxler_Garaud_Stellmach_11'    'Brown_Garaud_Stellmach_13'


! rotation induced 
      am_nu_visc_factor = 1.0  !   1  
      am_D_mix_factor = 0.03      ! 0.0333333333333
      D_DSI_factor = 1.0d0
      D_SH_factor  = 1.0d0
      D_SSI_factor = 1.0d0
      D_ES_factor  = 1.0d0
      D_GSF_factor = 1.0d0
      D_ST_factor  = 0.0d0


! element diffusion
! causes a lot of retries and hydro fails, especially during core & shell he burns
! as the gradients are sharp. if diffusion is turned on, uncomment the timestep
! limiters below. more timesteps of course, but overall more efficient and 
! presumaby trustworthy

! time resolution
! limit the abundance changes in a timestep
     dX_nuc_drop_limit = 5.0d-4        !  1.0d-4  default = 5.0d-2
     dX_nuc_drop_limit_at_high_T = -1  ! default = -1 = same as dX_nuc_drop_limit
     dX_nuc_drop_min_X_limit = 1.0d-3  ! 1.0d-3  default = 1.0d-4
     dX_nuc_drop_max_A_limit = 52   

      do_element_diffusion = .false.
      diffusion_use_full_net = .false.
      diffusion_num_classes = 11
      diffusion_class_representative(1) = 'h1'
      diffusion_class_representative(2) = 'he3'
      diffusion_class_representative(3) = 'he4'
      diffusion_class_representative(4) = 'c12'
      diffusion_class_representative(5) = 'n14'
      diffusion_class_representative(6) = 'o16'
      diffusion_class_representative(7) = 'ne20'
      diffusion_class_representative(8) = 'ne22'
      diffusion_class_representative(9) = 'mg24'
      diffusion_class_representative(10) = 'si28'
      diffusion_class_representative(11) = 'fe56'
      diffusion_class_A_max(1)  = 2
      diffusion_class_A_max(2)  = 3
      diffusion_class_A_max(3)  = 4
      diffusion_class_A_max(4)  = 12
      diffusion_class_A_max(5)  = 14
      diffusion_class_A_max(6)  = 16
      diffusion_class_A_max(7)  = 20
      diffusion_class_A_max(8)  = 22
      diffusion_class_A_max(9)  = 24
      diffusion_class_A_max(10) = 28
      diffusion_class_A_max(11) = 10000



/ ! end of controls namelist

