! for solar model info, see https://arxiv.org/abs/1601.07179

&simplex_search_controls 
   
   ! defaults are set in routine set_simplex_search_defaults
   ! in star/job/simplex_search_run_star_extras.inc.
   ! do not edit that file directly.
   ! can reset the default values simply by adding lines below
   ! or you can copy sections from the public file to here to customize for your case.

    just_do_first_values = .false.  ! if true, then no simplex search
    ! true for test suite.   set false for real optimization runs.

    ! set_uniform_initial_composition = .false. ! DID NOT WORK
    
    restart_simplex_from_file = .false.
    ! if true, then reads the output file (simplex_output_filename)
    ! and continues from where that stopped
    ! using the best n+1 results as the initial simplex
    ! (where n is the number of parameters)
    ! NOTE: this restores the best simplex, but you may still
    ! see it rerun recent cases if they were not good enough to be
    ! included in the simplex.  we don't restore the information
    ! about those failed attempts, so we need to rerun them.

    ! and here is an absolute limit
    ! chi2_search_limit1 = 1d10
    ! chi2_search_limit2 = 1d-10
    ! if best chi2 for the run is <= chi2_search_limit1,
    ! then stop the run if chi2 >= chi2_search_limit2.

    shell_script_for_each_sample = 'cp LOGS/history.data outputs/sample#_history.data ; cp prof_bestmodel.data outputs/sample#_prof.data ; cp -r png png-# ; rm -f png/* '
    shell_script_num_string_char = '#' ! replace by num string for sample
    ! Do whatever you like in the script.  e.g.,
    ! 'cp best.mod outputs/sample#_best.mod; cp LOGS/history.data outputs/sample#_history.data'
   
    write_profile_for_best_model = .true.
    best_model_profile_filename = 'prof_bestmodel.data'
    
    save_model_for_best_model = .true.
    best_model_save_model_filename = 'timeevol_bestmodel.data'    

    chi2_limit = 1d7
   
! specify parameters to be varied in search, with initial values and bounds
         
      ! user defined parameters
      ! see routine "will_set_my_param" in run_star_extras

         vary_my_param1 = .false.
         min_my_param1 = 0.245
         max_my_param1 = 0.289
         my_param1_name = 'Yproto' ! primordial helium abundance 
    
         vary_my_param2 = .false.
         min_my_param2 = 0.01
         max_my_param2 = 0.03
         my_param2_name = 'Zproto' ! primordial metallicity
         
         vary_my_param3 = .false.
         first_my_param3 = 1.0
         min_my_param3 = 0.5
         max_my_param3 = 1.0
         my_param3_name = 'M1' 

         vary_my_param4 = .false.
         first_my_param4 = 0.0
         min_my_param4 = -0.5
         max_my_param4 = 0.5
         my_param4_name = 'A1' ! opacity increase factor

         vary_my_param5 = .false.
         first_my_param5 = 0.00
         min_my_param5 = -0.5
         max_my_param5 = 0.5
         my_param5_name = 'A2' ! opacity increase factor 

         vary_my_param6 = .false.
         first_my_param6 = 0.0
         min_my_param6 = -0.5
         max_my_param6 = 0.5
         my_param6_name = 'A3' ! opacity increase factor
         
         
      ! built-in parameters
         first_FeH =  0.0000000000000000D+00
         first_Y =  2.8000000119209290D-01
         first_f_ov =  4.9195598822298649D-04
         first_alpha =  1.8084538895877329D+00
         first_my_param1 =  2.7422280995762394D-01
         first_my_param2 =  1.6057722065229405D-02
      
         vary_FeH = .false. ! FeH = [Fe/H] = log10((Z/X)/Z_div_X_solar)
         min_FeH = -0.09 ! Z/X = 0.01863820374
         max_FeH = 0.11 ! Z/X = 0.02953956222
         
         vary_Y = .false.
         min_Y = 0.245
         max_Y = 0.289

         ! alpha done using my_param1 (see below)
         vary_alpha = .false.  
         min_alpha = 1.80
         max_alpha =  2.40

         vary_f_ov = .false.
         min_f_ov = 0
         max_f_ov = 0.04
      
         vary_mass = .false.
         first_mass = 0.1d0
         min_mass = 1d0
         max_mass = 1d0         
   
      ! Y is independent parameter along with FeH
         Y_depends_on_Z = .false. 
            ! if false, then Y is a parameter like FeH.
               ! you should set vary_Y, first_Y, min_Y, and max_Y.
            ! if true, then Y depends on Z as follows: Y = Y0 + dYdZ*Z
               ! in this case, set vary_Y = .false. 
               ! first_Y, min_Y, and max_Y are unused.
         Y0 = 0.248d0
         dYdZ = 1.4d0
         
      ! overshoot_f0 is changed along with overshoot_f
         ! f0_ov = f0_ov_div_f_ov * f_ov
         f0_ov_div_f_ov = 1


! specify terms for chi^2 
   
   ! chi2 is an evenly weighted combination of terms
      ! only need to give values for target and sigma if include in chi^2

      ! do Teff as my_var1 as illustration (see below)
      !include_Teff_in_chi2 = .true.
      !Teff_target = 5777d0
      !Teff_sigma = 65d0

      include_logR_in_chi2 = .false. ! redundant wrt Teff and logL
      logR_target = -1
      logR_sigma = -1

      include_logg_in_chi2 = .false.
      logg_target = -1
      logg_sigma = -1
   
      include_logL_in_chi2 = .true.
      logL_target = 0.00d0
      logL_sigma = 0.01d0
      
      ! NOTE: for plotting with pgstar loggTe window -- logg vs. Teff
         ! you can set the following pgstar controls
         ! loggTe_target_logg
         ! loggTe_target_logg_sigma
         ! loggTe_target_Teff
         ! loggTe_target_Teff_sigma
      ! same if you are plotting HR window -- lg_L vs. lg_Teff
         ! you can set the following pgstar controls
         ! HR_target_logL
         ! HR_target_logL_sigma
         ! HR_target_Teff
         ! HR_target_Teff_sigma      
      
      include_FeH_in_chi2 = .false. ! [Fe/H]
      FeH_target = 0.00
      FeH_sigma = 0.05
      
         ! we calculate model [Fe/H] as = log10((Z/X)/Z_div_X_solar)
         ! using model surface average values for Z and X.
      Z_div_X_solar = 0.02293d0 ! what is this??????
      !Z_div_X_solar = 0.01815d0
         
      include_age_in_chi2 = .false.
      eval_chi2_at_target_age_only = .true. ! for solar model, only want chi2 at final age
      ! if either of these are set true, then you must set the following too.
         ! note: do not set max_age or num_adjusted_dt_steps_before_max_age.

      age_target = 4.567d9 ! 4.57d9 after zams + 4d7 for pre-main-sequence
      age_sigma = 1d7
         ! see Bahcall, Serenelli, and Basu, 2006; Bahcall and Pinsonneault, 1995
      num_smaller_steps_before_age_target = 200 ! only used if > 0
      dt_for_smaller_steps_before_age_target = 1d6 ! 1/10 age_sigma

      ! if include_age_in_chi2, then set the following:
      min_age_for_chi2 = 4.54d9 ! target - 7*sigma
      max_age_for_chi2 = 4.68d9 ! target + 7*sigma
      
      include_surface_Z_div_X_in_chi2 = .true. ! redundant wrt FeH
      !surface_Z_div_X_target = 2.292d-2 ! GS98 value
      surface_Z_div_X_target = 1.81d-2 ! Asplund 09 value
      surface_Z_div_X_sigma = 1d-3
         ! reminder: surface_Z_div_X = surface_Z/surface_X
         ! and FeH = log10(surface_Z_div_X/Z_div_X_solar)
         ! where Z_div_X_solar is a parameter specified in this inlist
   
      include_surface_He_in_chi2 = .true.
      surface_He_target = 0.2485d0 ! Basu & Antia 2004
      surface_He_sigma = 0.0035
   
      include_Rcz_in_chi2 = .true. ! radius of base of convective zone
      Rcz_target = 0.713d0 ! Basu & Antia 1997
      !Rcz_sigma = 1d-3
      Rcz_sigma = 1d-2
   
      include_solar_cs_rms_in_chi2 = .true. ! check sound profile
      solar_cs_rms_target = 0
      !solar_cs_rms_sigma = 2d-4
      solar_cs_rms_sigma = 1d-3
      report_solar_cs_rms = .false.

      ! to include user-defined variables in chi^2 spectro
      ! set the "my_var" variable in your extras_check_model routine set_my_vars
      !     use simplex_data, only: my_var1, my_var2, my_var3
      !     my_var1 = ......
   
      ! do Teff as my_var1 as illustration
      include_Teff_in_chi2 = .false.
      include_my_var1_in_chi2 = .true.
      my_var1_target = 5777d0
      my_var1_sigma = 10d0
      my_var1_name = 'my_Teff'
   
      include_my_var2_in_chi2 = .false.
      my_var2_target = 0
      my_var2_sigma = 0
      my_var2_name = 'my_var2'
   
      include_my_var3_in_chi2 = .false.
      my_var3_target = 0
      my_var3_sigma = 0
      my_var3_name = 'my_var3'

      ! adjust max timestep depending on chi2
      
         ! NOTE: if you set the timestep limits too large you run the risk of missing good chi^2 cases.
         ! but if they are very small, you will spend a lot of runtime calculating lots of frequencies
         ! for lots of models.  There is no standard set of best values for this.
         ! The choice will depend on the stage of evolution and how fast things are changing
         ! in the general region of the models with good chi2 values.  
         ! There is no alternative to trying things and tuning the controls for your problem.
         
         ! the following values are selected for the solar model case.  may not be right for you.
         
         chi2_limit_for_small_timesteps = 50
         max_yrs_dt_chi2_small_limit = 3d5 ! < max_yrs_dt_when_hot
         
         chi2_limit_for_smaller_timesteps = 20 ! < chi2_limit_for_small_timesteps
         max_yrs_dt_chi2_smaller_limit = 1d5 ! < max_yrs_dt_chi2_small_limit
         
         chi2_limit_for_smallest_timesteps = 10 ! < chi2_limit_for_smaller_timesteps
         max_yrs_dt_chi2_smallest_limit = 5d4 ! < max_yrs_dt_chi2_smaller_limit
   
sigmas_coeff_for_logL_limit = 0
sigmas_coeff_for_logg_limit = 0
sigmas_coeff_for_Teff_limit = 0 ! disable by setting to 0
sigmas_coeff_for_logR_limit = 0 ! disable by setting to 0
sigmas_coeff_for_surface_Z_div_X_limit = 0 ! disable by setting to 0
sigmas_coeff_for_surface_He_limit = 0 ! disable by setting to 0
sigmas_coeff_for_solar_Rcz_limit = 0 ! disable by setting to 0
sigmas_coeff_for_solar_cs_rms_limit = 0 ! disable by setting to 0
sigmas_coeff_for_my_var1_limit = 0 ! disable by setting to 0

/ ! end simplex_search_controls

