Line data Source code
1 : ! ***********************************************************************
2 : !
3 : ! Copyright (C) 2010 Pablo Marchant & The MESA Team
4 : !
5 : ! This program is free software: you can redistribute it and/or modify
6 : ! it under the terms of the GNU Lesser General Public License
7 : ! as published by the Free Software Foundation,
8 : ! either version 3 of the License, or (at your option) any later version.
9 : !
10 : ! This program is distributed in the hope that it will be useful,
11 : ! but WITHOUT ANY WARRANTY; without even the implied warranty of
12 : ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 : ! See the GNU Lesser General Public License for more details.
14 : !
15 : ! You should have received a copy of the GNU Lesser General Public License
16 : ! along with this program. If not, see <https://www.gnu.org/licenses/>.
17 : !
18 : ! ***********************************************************************
19 :
20 : module binary_ctrls_io
21 :
22 : use const_def, only: dp
23 : use binary_def
24 :
25 : implicit none
26 :
27 : include "binary_controls.inc"
28 :
29 : logical, dimension(max_extra_inlists) :: read_extra_binary_controls_inlist
30 : character (len=strlen), dimension(max_extra_inlists) :: extra_binary_controls_inlist_name
31 :
32 : namelist /binary_controls/ &
33 : ! specifications for starting model
34 : m1, &
35 : m2, &
36 : initial_period_in_days, &
37 : initial_separation_in_Rsuns, &
38 : initial_eccentricity, &
39 :
40 : ! controls for output
41 : history_name, &
42 : history_interval, &
43 : append_to_star_history, &
44 : log_directory, &
45 : history_dbl_format, &
46 : history_int_format, &
47 : history_txt_format, &
48 : photo_interval, &
49 : photo_digits, &
50 : photo_directory, &
51 : terminal_interval, &
52 : write_header_frequency, &
53 : extra_binary_terminal_output_file, &
54 :
55 : ! timestep controls
56 : time_delta_coeff, &
57 : fm, &
58 : fm_hard, &
59 : fa, &
60 : fa_hard, &
61 : fr, &
62 : fr_hard, &
63 : fj, &
64 : fj_hard, &
65 : fe, &
66 : fe_hard, &
67 : fm_limit, &
68 : fr_limit, &
69 : fe_limit, &
70 : fr_dt_limit, &
71 : fdm, &
72 : fdm_hard, &
73 : dt_softening_factor, &
74 : varcontrol_case_a, &
75 : varcontrol_case_b, &
76 : varcontrol_ms, &
77 : varcontrol_post_ms, &
78 : dt_reduction_factor_for_j, &
79 :
80 : ! when to stop
81 : accretor_overflow_terminate, &
82 : terminate_if_initial_overflow, &
83 : terminate_if_L2_overflow, &
84 :
85 : ! mass transfer controls
86 : mass_transfer_alpha, &
87 : mass_transfer_beta, &
88 : mass_transfer_delta, &
89 : mass_transfer_gamma, &
90 : limit_retention_by_mdot_edd, &
91 : use_es_opacity_for_mdot_edd, &
92 : use_this_for_mdot_edd_eta, &
93 : use_radiation_corrected_transfer_rate, &
94 : initial_bh_spin, &
95 : use_this_for_mdot_edd, &
96 : mdot_scheme, &
97 : cur_mdot_frac, &
98 : max_explicit_abs_mdot, &
99 : max_tries_to_achieve, &
100 : solver_type, &
101 : implicit_scheme_tolerance, &
102 : implicit_scheme_tiny_factor, &
103 : initial_change_factor, &
104 : change_factor_fraction, &
105 : implicit_lambda, &
106 : max_change_factor, &
107 : min_change_factor, &
108 : num_tries_for_increase_change_factor, &
109 : change_factor_increase, &
110 : starting_mdot, &
111 : roche_min_mdot, &
112 : min_mdot_for_implicit, &
113 : max_implicit_abs_mdot, &
114 : report_rlo_solver_progress, &
115 : do_enhance_wind_1, &
116 : do_enhance_wind_2, &
117 : tout_B_wind_1, &
118 : tout_B_wind_2, &
119 : do_wind_mass_transfer_1, &
120 : do_wind_mass_transfer_2, &
121 : wind_BH_alpha_1, &
122 : wind_BH_alpha_2, &
123 : wind_BH_beta_1, &
124 : wind_BH_beta_2, &
125 : max_wind_transfer_fraction_1, &
126 : max_wind_transfer_fraction_2, &
127 :
128 : ! orbital jdot controls
129 : do_jdot_gr, &
130 : do_jdot_ml, &
131 : do_jdot_ls, &
132 : do_jdot_missing_wind, &
133 : do_jdot_mb, &
134 : include_accretor_mb, &
135 : magnetic_braking_gamma, &
136 : keep_mb_on, &
137 : jdot_mb_min_qconv_env, &
138 : jdot_mb_max_qconv_env, &
139 : jdot_mb_max_qconv_core, &
140 : jdot_mb_qlim_for_check_rad_core, &
141 : jdot_mb_qlim_for_check_conv_env, &
142 : jdot_mb_scale_for_low_qconv_env, &
143 : jdot_mb_mass_frac_for_scale, &
144 : jdot_multiplier, &
145 :
146 : ! rotation and sync controls
147 : do_j_accretion, &
148 : do_tidal_sync, &
149 : sync_type_1, &
150 : sync_type_2, &
151 : sync_mode_1, &
152 : sync_mode_2, &
153 : Ftid_1, &
154 : Ftid_2, &
155 : do_initial_orbit_sync_1, &
156 : do_initial_orbit_sync_2, &
157 : tidal_reduction, &
158 :
159 : ! eccentricity controls
160 : do_tidal_circ, &
161 : circ_type_1, &
162 : circ_type_2, &
163 : use_eccentricity_enhancement, &
164 : max_abs_edot_tidal, &
165 : max_abs_edot_enhance, &
166 : min_eccentricity, &
167 : max_eccentricity, &
168 : anomaly_steps, &
169 :
170 : ! irradiation controls
171 : accretion_powered_irradiation, &
172 : col_depth_for_eps_extra, &
173 : use_accretor_luminosity_for_irrad, &
174 : irrad_flux_at_std_distance, &
175 : std_distance_for_irradiation, &
176 : max_F_irr, &
177 :
178 : !common envelope controls
179 : CE_alpha, &
180 : CE_alpha_th, &
181 : CE_mass_loss_rate_high, &
182 : CE_mass_loss_rate_low, &
183 : CE_rel_rlo_for_detachment, &
184 : CE_years_detached_to_terminate, &
185 : CE_begin_at_max_implicit_abs_mdot, &
186 : CE_xa_diff_to_terminate, &
187 : CE_terminate_when_core_overflows, &
188 : CE_min_period_in_minutes, &
189 : CE_energy_factor_HII_toHI, &
190 : CE_energy_factor_HeII_toHeI, &
191 : CE_energy_factor_HeIII_toHeII, &
192 : CE_energy_factor_H2, &
193 : CE_fixed_lambda, &
194 :
195 : ! miscellaneous controls
196 : keep_donor_fixed, &
197 : mdot_limit_donor_switch, &
198 : use_tidal_deformation, &
199 : f_sync_switch_from_rot_defor, &
200 : f_sync_switch_width, &
201 : f_sync_switch_lim, &
202 : use_other_tidal_deformation_switch_function, &
203 : use_other_rlo_mdot, &
204 : use_other_check_implicit_rlo, &
205 : use_other_implicit_function_to_solve, &
206 : use_other_e2, &
207 : use_other_pgbinary_plots, &
208 : use_other_tsync, &
209 : use_other_sync_spin_to_orbit, &
210 : use_other_mdot_edd, &
211 : use_other_adjust_mdots, &
212 : use_other_accreted_material_j, &
213 : use_other_jdot_gr, &
214 : use_other_jdot_ml, &
215 : use_other_jdot_ls, &
216 : use_other_jdot_missing_wind, &
217 : use_other_jdot_mb, &
218 : use_other_extra_jdot, &
219 : use_other_binary_wind_transfer, &
220 : use_other_edot_tidal, &
221 : use_other_edot_enhance, &
222 : use_other_extra_edot, &
223 : use_other_CE_init, &
224 : use_other_CE_rlo_mdot, &
225 : use_other_CE_binary_evolve_step, &
226 : use_other_CE_binary_finish_step, &
227 : x_ctrl, &
228 : x_integer_ctrl, &
229 : x_logical_ctrl, &
230 : x_character_ctrl, &
231 :
232 : ! extra files
233 : read_extra_binary_controls_inlist, extra_binary_controls_inlist_name
234 :
235 : contains
236 :
237 :
238 0 : subroutine do_one_binary_setup(b, inlist, ierr)
239 : use utils_lib
240 : type (binary_info), pointer :: b
241 : character (len=*), intent(in) :: inlist
242 : integer, intent(out) :: ierr
243 :
244 : include 'formats'
245 :
246 0 : call set_default_binary_controls
247 0 : call read_binary_controls(b, inlist, ierr)
248 0 : if (ierr /= 0) return
249 :
250 0 : if (b% extra_binary_terminal_iounit /= 0) then
251 0 : close(b% extra_binary_terminal_iounit)
252 0 : b% extra_binary_terminal_iounit = 0
253 : end if
254 :
255 : ! open additional file for binary output
256 0 : if (len_trim(b% extra_binary_terminal_output_file) /= 0) then
257 : open(newunit=b% extra_binary_terminal_iounit, file=trim(b% extra_binary_terminal_output_file), &
258 0 : action='write', status='replace',iostat=ierr)
259 0 : if (ierr /= 0) then
260 0 : b% extra_binary_terminal_iounit = 0
261 0 : write(*,*) 'failed to open ' // trim(b% extra_binary_terminal_output_file)
262 0 : return
263 : end if
264 : end if
265 :
266 : end subroutine do_one_binary_setup
267 :
268 :
269 0 : subroutine read_binary_controls(b, filename, ierr)
270 : use utils_namelist, only: read_namelist, missing_namelist_error
271 : type (binary_info), pointer :: b
272 : character(*), intent(in) :: filename
273 : integer, intent(out) :: ierr
274 :
275 0 : call read_namelist(filename, read_binary_controls_file, "binary_controls", ierr, missing_namelist_error)
276 :
277 0 : if (ierr /= 0) return
278 :
279 0 : call store_binary_controls(b)
280 :
281 : end subroutine read_binary_controls
282 :
283 0 : subroutine read_binary_controls_file(unit, iostat, iomsg, extra_inlists, extra_inlists_mask)
284 : use const_def, only: strlen
285 : use utils_namelist, only: max_extra_inlists
286 :
287 : integer, intent(in) :: unit
288 : integer, intent(out) :: iostat
289 : character(len=strlen), intent(out) :: iomsg
290 : character(len=strlen), dimension(max_extra_inlists), intent(out) :: extra_inlists
291 : logical, dimension(max_extra_inlists), intent(out) :: extra_inlists_mask
292 :
293 : integer :: i
294 :
295 0 : read_extra_binary_controls_inlist(:) = .false.
296 :
297 0 : read(unit, nml=binary_controls, iostat=iostat, iomsg=iomsg)
298 :
299 0 : if (iostat /= 0) then
300 : return
301 : end if
302 :
303 0 : do i=1, max_extra_inlists
304 0 : extra_inlists(i) = extra_binary_controls_inlist_name(i)
305 0 : extra_inlists_mask(i) = read_extra_binary_controls_inlist(i)
306 : end do
307 :
308 : end subroutine read_binary_controls_file
309 :
310 0 : subroutine set_default_binary_controls
311 : include 'binary_controls.defaults'
312 0 : end subroutine set_default_binary_controls
313 :
314 :
315 0 : subroutine store_binary_controls(b)
316 : use utils_lib, only: mkdir
317 : type (binary_info), pointer :: b
318 :
319 : ! specifications for starting model
320 0 : b% m1 = m1
321 0 : b% m2 = m2
322 0 : b% initial_period_in_days = initial_period_in_days
323 0 : b% initial_separation_in_Rsuns = initial_separation_in_Rsuns
324 0 : b% initial_eccentricity = initial_eccentricity
325 :
326 : ! controls for output
327 0 : b% history_name = history_name
328 0 : b% history_interval = history_interval
329 0 : b% append_to_star_history = append_to_star_history
330 0 : b% log_directory = log_directory
331 0 : CALL mkdir(b% log_directory)
332 0 : b% history_dbl_format = history_dbl_format
333 0 : b% history_int_format = history_int_format
334 0 : b% history_txt_format = history_txt_format
335 0 : b% photo_interval = photo_interval
336 0 : b% photo_digits = photo_digits
337 0 : b% photo_directory = photo_directory
338 0 : CALL mkdir(b% photo_directory)
339 0 : b% terminal_interval = terminal_interval
340 0 : b% write_header_frequency = write_header_frequency
341 0 : b% extra_binary_terminal_output_file = extra_binary_terminal_output_file
342 :
343 : ! timestep controls
344 0 : b% time_delta_coeff = time_delta_coeff
345 0 : b% fm = fm
346 0 : b% fm_hard = fm_hard
347 0 : b% fa = fa
348 0 : b% fa_hard = fa_hard
349 0 : b% fr = fr
350 0 : b% fr_hard = fr_hard
351 0 : b% fj = fj
352 0 : b% fj_hard = fj_hard
353 0 : b% fe = fe
354 0 : b% fe_hard = fe_hard
355 0 : b% fm_limit = fm_limit
356 0 : b% fr_limit = fr_limit
357 0 : b% fe_limit = fe_limit
358 0 : b% fr_dt_limit = fr_dt_limit
359 0 : b% fdm = fdm
360 0 : b% fdm_hard = fdm_hard
361 0 : b% dt_softening_factor = dt_softening_factor
362 0 : b% varcontrol_case_a = varcontrol_case_a
363 0 : b% varcontrol_case_b = varcontrol_case_b
364 0 : b% varcontrol_ms = varcontrol_ms
365 0 : b% varcontrol_post_ms = varcontrol_post_ms
366 0 : b% dt_reduction_factor_for_j = dt_reduction_factor_for_j
367 :
368 : ! when to stop
369 0 : b% accretor_overflow_terminate = accretor_overflow_terminate
370 0 : b% terminate_if_initial_overflow = terminate_if_initial_overflow
371 0 : b% terminate_if_L2_overflow = terminate_if_L2_overflow
372 :
373 : ! mass transfer controls
374 0 : b% mass_transfer_alpha = mass_transfer_alpha
375 0 : b% mass_transfer_beta = mass_transfer_beta
376 0 : b% mass_transfer_delta = mass_transfer_delta
377 0 : b% mass_transfer_gamma = mass_transfer_gamma
378 0 : b% limit_retention_by_mdot_edd = limit_retention_by_mdot_edd
379 0 : b% use_es_opacity_for_mdot_edd = use_es_opacity_for_mdot_edd
380 0 : b% use_this_for_mdot_edd_eta = use_this_for_mdot_edd_eta
381 0 : b% use_radiation_corrected_transfer_rate = use_radiation_corrected_transfer_rate
382 0 : b% initial_bh_spin = initial_bh_spin
383 0 : b% use_this_for_mdot_edd = use_this_for_mdot_edd
384 0 : b% mdot_scheme = mdot_scheme
385 0 : b% cur_mdot_frac = cur_mdot_frac
386 0 : b% max_explicit_abs_mdot = max_explicit_abs_mdot
387 0 : b% max_tries_to_achieve = max_tries_to_achieve
388 0 : b% solver_type = solver_type
389 0 : b% implicit_scheme_tolerance = implicit_scheme_tolerance
390 0 : b% implicit_scheme_tiny_factor = implicit_scheme_tiny_factor
391 0 : b% initial_change_factor = initial_change_factor
392 0 : b% change_factor_fraction = change_factor_fraction
393 0 : b% implicit_lambda = implicit_lambda
394 0 : b% max_change_factor = max_change_factor
395 0 : b% min_change_factor = min_change_factor
396 0 : b% num_tries_for_increase_change_factor = num_tries_for_increase_change_factor
397 0 : b% change_factor_increase = change_factor_increase
398 0 : b% starting_mdot = starting_mdot
399 0 : b% roche_min_mdot = roche_min_mdot
400 0 : b% min_mdot_for_implicit = min_mdot_for_implicit
401 0 : b% max_implicit_abs_mdot = max_implicit_abs_mdot
402 0 : b% report_rlo_solver_progress = report_rlo_solver_progress
403 0 : b% do_enhance_wind_1 = do_enhance_wind_1
404 0 : b% do_enhance_wind_2 = do_enhance_wind_2
405 0 : b% tout_B_wind_1 = tout_B_wind_1
406 0 : b% tout_B_wind_2 = tout_B_wind_2
407 0 : b% do_wind_mass_transfer_1 = do_wind_mass_transfer_1
408 0 : b% do_wind_mass_transfer_2 = do_wind_mass_transfer_2
409 0 : b% wind_BH_alpha_1 = wind_BH_alpha_1
410 0 : b% wind_BH_alpha_2 = wind_BH_alpha_2
411 0 : b% wind_BH_beta_1 = wind_BH_beta_1
412 0 : b% wind_BH_beta_2 = wind_BH_beta_2
413 0 : b% max_wind_transfer_fraction_1 = max_wind_transfer_fraction_1
414 0 : b% max_wind_transfer_fraction_2 = max_wind_transfer_fraction_2
415 :
416 : ! orbital jdot controls
417 0 : b% do_jdot_gr = do_jdot_gr
418 0 : b% do_jdot_ml = do_jdot_ml
419 0 : b% do_jdot_ls = do_jdot_ls
420 0 : b% do_jdot_missing_wind = do_jdot_missing_wind
421 0 : b% do_jdot_mb = do_jdot_mb
422 0 : b% include_accretor_mb = include_accretor_mb
423 0 : b% magnetic_braking_gamma = magnetic_braking_gamma
424 0 : b% keep_mb_on = keep_mb_on
425 0 : b% jdot_mb_min_qconv_env = jdot_mb_min_qconv_env
426 0 : b% jdot_mb_max_qconv_env = jdot_mb_max_qconv_env
427 0 : b% jdot_mb_max_qconv_core = jdot_mb_max_qconv_core
428 0 : b% jdot_mb_qlim_for_check_rad_core = jdot_mb_qlim_for_check_rad_core
429 0 : b% jdot_mb_qlim_for_check_conv_env = jdot_mb_qlim_for_check_conv_env
430 0 : b% jdot_mb_scale_for_low_qconv_env = jdot_mb_scale_for_low_qconv_env
431 0 : b% jdot_mb_mass_frac_for_scale = jdot_mb_mass_frac_for_scale
432 0 : b% jdot_multiplier = jdot_multiplier
433 :
434 : ! rotation and sync controls
435 0 : b% do_j_accretion = do_j_accretion
436 0 : b% do_tidal_sync = do_tidal_sync
437 0 : b% sync_type_1 = sync_type_1
438 0 : b% sync_type_2 = sync_type_2
439 0 : b% sync_mode_1 = sync_mode_1
440 0 : b% sync_mode_2 = sync_mode_2
441 0 : b% Ftid_1 = Ftid_1
442 0 : b% Ftid_2 = Ftid_2
443 0 : b% do_initial_orbit_sync_1 = do_initial_orbit_sync_1
444 0 : b% do_initial_orbit_sync_2 = do_initial_orbit_sync_2
445 0 : b% tidal_reduction = tidal_reduction
446 :
447 : ! eccentricity controls
448 0 : b% do_tidal_circ = do_tidal_circ
449 0 : b% circ_type_1 = circ_type_1
450 0 : b% circ_type_2 = circ_type_2
451 0 : b% use_eccentricity_enhancement = use_eccentricity_enhancement
452 0 : b% max_abs_edot_tidal = max_abs_edot_tidal
453 0 : b% max_abs_edot_enhance = max_abs_edot_enhance
454 0 : b% min_eccentricity = min_eccentricity
455 0 : b% max_eccentricity = max_eccentricity
456 0 : b% anomaly_steps = anomaly_steps
457 :
458 : ! irradiation controls
459 0 : b% accretion_powered_irradiation = accretion_powered_irradiation
460 0 : b% use_accretor_luminosity_for_irrad = use_accretor_luminosity_for_irrad
461 0 : b% col_depth_for_eps_extra = col_depth_for_eps_extra
462 0 : b% irrad_flux_at_std_distance = irrad_flux_at_std_distance
463 0 : b% std_distance_for_irradiation = std_distance_for_irradiation
464 0 : b% max_F_irr = max_F_irr
465 :
466 : !common envelope controls
467 0 : b% CE_alpha = CE_alpha
468 0 : b% CE_alpha_th = CE_alpha_th
469 0 : b% CE_mass_loss_rate_high = CE_mass_loss_rate_high
470 0 : b% CE_mass_loss_rate_low = CE_mass_loss_rate_low
471 0 : b% CE_rel_rlo_for_detachment = CE_rel_rlo_for_detachment
472 0 : b% CE_years_detached_to_terminate = CE_years_detached_to_terminate
473 0 : b% CE_begin_at_max_implicit_abs_mdot = CE_begin_at_max_implicit_abs_mdot
474 0 : b% CE_xa_diff_to_terminate = CE_xa_diff_to_terminate
475 0 : b% CE_terminate_when_core_overflows = CE_terminate_when_core_overflows
476 0 : b% CE_min_period_in_minutes = CE_min_period_in_minutes
477 0 : b% CE_energy_factor_HII_toHI = CE_energy_factor_HII_toHI
478 0 : b% CE_energy_factor_HeII_toHeI = CE_energy_factor_HeII_toHeI
479 0 : b% CE_energy_factor_HeIII_toHeII = CE_energy_factor_HeIII_toHeII
480 0 : b% CE_energy_factor_H2 = CE_energy_factor_H2
481 0 : b% CE_fixed_lambda = CE_fixed_lambda
482 :
483 : ! miscellaneous controls
484 0 : b% keep_donor_fixed = keep_donor_fixed
485 0 : b% mdot_limit_donor_switch = mdot_limit_donor_switch
486 0 : b% use_tidal_deformation = use_tidal_deformation
487 0 : b% f_sync_switch_from_rot_defor = f_sync_switch_from_rot_defor
488 0 : b% f_sync_switch_width = f_sync_switch_width
489 0 : b% f_sync_switch_lim = f_sync_switch_lim
490 0 : b% use_other_tidal_deformation_switch_function = use_other_tidal_deformation_switch_function
491 0 : b% use_other_rlo_mdot = use_other_rlo_mdot
492 0 : b% use_other_check_implicit_rlo = use_other_check_implicit_rlo
493 0 : b% use_other_implicit_function_to_solve = use_other_implicit_function_to_solve
494 0 : b% use_other_e2 = use_other_e2
495 0 : b% use_other_pgbinary_plots = use_other_pgbinary_plots
496 0 : b% use_other_tsync = use_other_tsync
497 0 : b% use_other_sync_spin_to_orbit = use_other_sync_spin_to_orbit
498 0 : b% use_other_mdot_edd = use_other_mdot_edd
499 0 : b% use_other_adjust_mdots = use_other_adjust_mdots
500 0 : b% use_other_accreted_material_j = use_other_accreted_material_j
501 0 : b% use_other_jdot_gr = use_other_jdot_gr
502 0 : b% use_other_jdot_ml = use_other_jdot_ml
503 0 : b% use_other_jdot_ls = use_other_jdot_ls
504 0 : b% use_other_jdot_missing_wind = use_other_jdot_missing_wind
505 0 : b% use_other_jdot_mb = use_other_jdot_mb
506 0 : b% use_other_extra_jdot = use_other_extra_jdot
507 0 : b% use_other_binary_wind_transfer = use_other_binary_wind_transfer
508 0 : b% use_other_edot_tidal = use_other_edot_tidal
509 0 : b% use_other_edot_enhance = use_other_edot_enhance
510 0 : b% use_other_extra_edot = use_other_extra_edot
511 0 : b% use_other_CE_init = use_other_CE_init
512 0 : b% use_other_CE_rlo_mdot = use_other_CE_rlo_mdot
513 0 : b% use_other_CE_binary_evolve_step = use_other_CE_binary_evolve_step
514 0 : b% use_other_CE_binary_finish_step = use_other_CE_binary_finish_step
515 :
516 0 : b% x_ctrl = x_ctrl
517 0 : b% x_integer_ctrl = x_integer_ctrl
518 0 : b% x_logical_ctrl = x_logical_ctrl
519 0 : b% x_character_ctrl = x_character_ctrl
520 :
521 0 : end subroutine store_binary_controls
522 :
523 :
524 0 : subroutine set_binary_controls_for_writing(b, ierr)
525 : type (binary_info), pointer :: b
526 : integer, intent(out) :: ierr
527 :
528 0 : ierr = 0
529 :
530 : ! specifications for starting model
531 0 : m1 = b% m1
532 0 : m2 = b% m2
533 0 : initial_period_in_days = b% initial_period_in_days
534 0 : initial_separation_in_Rsuns = b% initial_separation_in_Rsuns
535 0 : initial_eccentricity = b% initial_eccentricity
536 :
537 : ! controls for output
538 0 : history_name = b% history_name
539 0 : history_interval = b% history_interval
540 0 : append_to_star_history = b% append_to_star_history
541 0 : log_directory = b% log_directory
542 0 : history_dbl_format = b% history_dbl_format
543 0 : history_int_format = b% history_int_format
544 0 : history_txt_format = b% history_txt_format
545 0 : photo_interval = b% photo_interval
546 0 : photo_digits = b% photo_digits
547 0 : photo_directory = b% photo_directory
548 0 : terminal_interval = b% terminal_interval
549 0 : write_header_frequency = b% write_header_frequency
550 0 : extra_binary_terminal_output_file = b% extra_binary_terminal_output_file
551 :
552 : ! timestep controls
553 0 : time_delta_coeff = b% time_delta_coeff
554 0 : fm = b% fm
555 0 : fm_hard = b% fm_hard
556 0 : fa = b% fa
557 0 : fa_hard = b% fa_hard
558 0 : fr = b% fr
559 0 : fr_hard = b% fr_hard
560 0 : fj = b% fj
561 0 : fj_hard = b% fj_hard
562 0 : fe = b% fe
563 0 : fe_hard = b% fe_hard
564 0 : fm_limit = b% fm_limit
565 0 : fr_limit = b% fr_limit
566 0 : fe_limit = b% fe_limit
567 0 : fr_dt_limit = b% fr_dt_limit
568 0 : fdm = b% fdm
569 0 : fdm_hard = b% fdm_hard
570 0 : dt_softening_factor = b% dt_softening_factor
571 0 : varcontrol_case_a = b% varcontrol_case_a
572 0 : varcontrol_case_b = b% varcontrol_case_b
573 0 : varcontrol_ms = b% varcontrol_ms
574 0 : varcontrol_post_ms = b% varcontrol_post_ms
575 0 : dt_reduction_factor_for_j = b% dt_reduction_factor_for_j
576 :
577 : ! when to stop
578 0 : accretor_overflow_terminate = b% accretor_overflow_terminate
579 0 : terminate_if_initial_overflow = b% terminate_if_initial_overflow
580 0 : terminate_if_L2_overflow = b% terminate_if_L2_overflow
581 :
582 : ! mass transfer controls
583 0 : mass_transfer_alpha = b% mass_transfer_alpha
584 0 : mass_transfer_beta = b% mass_transfer_beta
585 0 : mass_transfer_delta = b% mass_transfer_delta
586 0 : mass_transfer_gamma = b% mass_transfer_gamma
587 0 : limit_retention_by_mdot_edd = b% limit_retention_by_mdot_edd
588 0 : use_es_opacity_for_mdot_edd = b% use_es_opacity_for_mdot_edd
589 0 : use_this_for_mdot_edd_eta = b% use_this_for_mdot_edd_eta
590 0 : use_radiation_corrected_transfer_rate = b% use_radiation_corrected_transfer_rate
591 0 : initial_bh_spin = b% initial_bh_spin
592 0 : use_this_for_mdot_edd = b% use_this_for_mdot_edd
593 0 : mdot_scheme = b% mdot_scheme
594 0 : cur_mdot_frac = b% cur_mdot_frac
595 0 : max_explicit_abs_mdot = b% max_explicit_abs_mdot
596 0 : max_tries_to_achieve = b% max_tries_to_achieve
597 0 : solver_type = b% solver_type
598 0 : implicit_scheme_tolerance = b% implicit_scheme_tolerance
599 0 : implicit_scheme_tiny_factor = b% implicit_scheme_tiny_factor
600 0 : initial_change_factor = b% initial_change_factor
601 0 : change_factor_fraction = b% change_factor_fraction
602 0 : implicit_lambda = b% implicit_lambda
603 0 : max_change_factor = b% max_change_factor
604 0 : min_change_factor = b% min_change_factor
605 0 : num_tries_for_increase_change_factor = b% num_tries_for_increase_change_factor
606 0 : change_factor_increase = b% change_factor_increase
607 0 : starting_mdot = b% starting_mdot
608 0 : roche_min_mdot = b% roche_min_mdot
609 0 : min_mdot_for_implicit = b% min_mdot_for_implicit
610 0 : max_implicit_abs_mdot = b% max_implicit_abs_mdot
611 0 : report_rlo_solver_progress = b% report_rlo_solver_progress
612 0 : do_enhance_wind_1 = b% do_enhance_wind_1
613 0 : do_enhance_wind_2 = b% do_enhance_wind_2
614 0 : tout_B_wind_1 = b% tout_B_wind_1
615 0 : tout_B_wind_2 = b% tout_B_wind_2
616 0 : do_wind_mass_transfer_1 = b% do_wind_mass_transfer_1
617 0 : do_wind_mass_transfer_2 = b% do_wind_mass_transfer_2
618 0 : wind_BH_alpha_1 = b% wind_BH_alpha_1
619 0 : wind_BH_alpha_2 = b% wind_BH_alpha_2
620 0 : wind_BH_beta_1 = b% wind_BH_beta_1
621 0 : wind_BH_beta_2 = b% wind_BH_beta_2
622 0 : max_wind_transfer_fraction_1 = b% max_wind_transfer_fraction_1
623 0 : max_wind_transfer_fraction_2 = b% max_wind_transfer_fraction_2
624 :
625 : ! orbital jdot controls
626 0 : do_jdot_gr = b% do_jdot_gr
627 0 : do_jdot_ml = b% do_jdot_ml
628 0 : do_jdot_ls = b% do_jdot_ls
629 0 : do_jdot_missing_wind = b% do_jdot_missing_wind
630 0 : do_jdot_mb = b% do_jdot_mb
631 0 : include_accretor_mb = b% include_accretor_mb
632 0 : magnetic_braking_gamma = b% magnetic_braking_gamma
633 0 : keep_mb_on = b% keep_mb_on
634 0 : jdot_mb_min_qconv_env = b% jdot_mb_min_qconv_env
635 0 : jdot_mb_max_qconv_env = b% jdot_mb_max_qconv_env
636 0 : jdot_mb_max_qconv_core = b% jdot_mb_max_qconv_core
637 0 : jdot_mb_qlim_for_check_rad_core = b% jdot_mb_qlim_for_check_rad_core
638 0 : jdot_mb_qlim_for_check_conv_env = b% jdot_mb_qlim_for_check_conv_env
639 0 : jdot_mb_scale_for_low_qconv_env = b% jdot_mb_scale_for_low_qconv_env
640 0 : jdot_mb_mass_frac_for_scale = b% jdot_mb_mass_frac_for_scale
641 0 : jdot_multiplier = b% jdot_multiplier
642 :
643 : ! rotation and sync controls
644 0 : do_j_accretion = b% do_j_accretion
645 0 : do_tidal_sync = b% do_tidal_sync
646 0 : sync_type_1 = b% sync_type_1
647 0 : sync_type_2 = b% sync_type_2
648 0 : sync_mode_1 = b% sync_mode_1
649 0 : sync_mode_2 = b% sync_mode_2
650 0 : Ftid_1 = b% Ftid_1
651 0 : Ftid_2 = b% Ftid_2
652 0 : do_initial_orbit_sync_1 = b% do_initial_orbit_sync_1
653 0 : do_initial_orbit_sync_2 = b% do_initial_orbit_sync_2
654 0 : tidal_reduction = b% tidal_reduction
655 :
656 : ! eccentricity controls
657 0 : do_tidal_circ = b% do_tidal_circ
658 0 : circ_type_1 = b% circ_type_1
659 0 : circ_type_2 = b% circ_type_2
660 0 : use_eccentricity_enhancement = b% use_eccentricity_enhancement
661 0 : max_abs_edot_tidal = b% max_abs_edot_tidal
662 0 : max_abs_edot_enhance = b% max_abs_edot_enhance
663 0 : min_eccentricity = b% min_eccentricity
664 0 : max_eccentricity = b% max_eccentricity
665 0 : anomaly_steps = b% anomaly_steps
666 :
667 : ! irradiation controls
668 0 : accretion_powered_irradiation = b% accretion_powered_irradiation
669 0 : use_accretor_luminosity_for_irrad = b% use_accretor_luminosity_for_irrad
670 0 : col_depth_for_eps_extra = b% col_depth_for_eps_extra
671 0 : irrad_flux_at_std_distance = b% irrad_flux_at_std_distance
672 0 : std_distance_for_irradiation = b% std_distance_for_irradiation
673 0 : max_F_irr = b% max_F_irr
674 :
675 : !common envelope controls
676 0 : CE_alpha = b% CE_alpha
677 0 : CE_alpha_th = b% CE_alpha_th
678 0 : CE_mass_loss_rate_high = b% CE_mass_loss_rate_high
679 0 : CE_mass_loss_rate_low = b% CE_mass_loss_rate_low
680 0 : CE_rel_rlo_for_detachment = b% CE_rel_rlo_for_detachment
681 0 : CE_years_detached_to_terminate = b% CE_years_detached_to_terminate
682 0 : CE_begin_at_max_implicit_abs_mdot = b% CE_begin_at_max_implicit_abs_mdot
683 0 : CE_xa_diff_to_terminate = b% CE_xa_diff_to_terminate
684 0 : CE_terminate_when_core_overflows = b% CE_terminate_when_core_overflows
685 0 : CE_min_period_in_minutes = b% CE_min_period_in_minutes
686 0 : CE_energy_factor_HII_toHI = b% CE_energy_factor_HII_toHI
687 0 : CE_energy_factor_HeII_toHeI = b% CE_energy_factor_HeII_toHeI
688 0 : CE_energy_factor_HeIII_toHeII = b% CE_energy_factor_HeIII_toHeII
689 0 : CE_energy_factor_H2 = b% CE_energy_factor_H2
690 0 : CE_fixed_lambda = b% CE_fixed_lambda
691 :
692 : ! miscellaneous controls
693 0 : keep_donor_fixed = b% keep_donor_fixed
694 0 : mdot_limit_donor_switch = b% mdot_limit_donor_switch
695 0 : use_tidal_deformation = b% use_tidal_deformation
696 0 : f_sync_switch_from_rot_defor = b% f_sync_switch_from_rot_defor
697 0 : f_sync_switch_width = b% f_sync_switch_width
698 0 : f_sync_switch_lim = b% f_sync_switch_lim
699 0 : use_other_tidal_deformation_switch_function = b% use_other_tidal_deformation_switch_function
700 0 : use_other_rlo_mdot = b% use_other_rlo_mdot
701 0 : use_other_check_implicit_rlo = b% use_other_check_implicit_rlo
702 0 : use_other_implicit_function_to_solve = b% use_other_implicit_function_to_solve
703 0 : use_other_e2 = b% use_other_e2
704 0 : use_other_pgbinary_plots = b% use_other_pgbinary_plots
705 0 : use_other_tsync = b% use_other_tsync
706 0 : use_other_sync_spin_to_orbit = b% use_other_sync_spin_to_orbit
707 0 : use_other_mdot_edd = b% use_other_mdot_edd
708 0 : use_other_adjust_mdots = b% use_other_adjust_mdots
709 0 : use_other_accreted_material_j = b% use_other_accreted_material_j
710 0 : use_other_jdot_gr = b% use_other_jdot_gr
711 0 : use_other_jdot_ml = b% use_other_jdot_ml
712 0 : use_other_jdot_ls = b% use_other_jdot_ls
713 0 : use_other_jdot_missing_wind = b% use_other_jdot_missing_wind
714 0 : use_other_jdot_mb = b% use_other_jdot_mb
715 0 : use_other_extra_jdot = b% use_other_extra_jdot
716 0 : use_other_binary_wind_transfer = b% use_other_binary_wind_transfer
717 0 : use_other_edot_tidal = b% use_other_edot_tidal
718 0 : use_other_edot_enhance = b% use_other_edot_enhance
719 0 : use_other_extra_edot = b% use_other_extra_edot
720 0 : use_other_CE_init = b% use_other_CE_init
721 0 : use_other_CE_rlo_mdot = b% use_other_CE_rlo_mdot
722 0 : use_other_CE_binary_evolve_step = b% use_other_CE_binary_evolve_step
723 0 : use_other_CE_binary_finish_step = b% use_other_CE_binary_finish_step
724 :
725 0 : x_ctrl = b% x_ctrl
726 0 : x_integer_ctrl = b% x_integer_ctrl
727 0 : x_logical_ctrl = b% x_logical_ctrl
728 0 : x_character_ctrl = b% x_character_ctrl
729 :
730 0 : end subroutine set_binary_controls_for_writing
731 :
732 0 : subroutine write_binary_controls(io,ierr)
733 : integer, intent(in) :: io
734 : integer, intent(out) :: ierr
735 0 : write(io, nml=binary_controls, iostat=ierr)
736 0 : end subroutine write_binary_controls
737 :
738 :
739 0 : subroutine get_binary_control(b, name, val, ierr)
740 : use utils_lib, only: StrUpCase
741 : type (binary_info), pointer :: b
742 : character(len=*),intent(in) :: name
743 : character(len=*), intent(out) :: val
744 : integer, intent(out) :: ierr
745 :
746 0 : character(len(name)) :: upper_name
747 : character(len=512) :: str
748 : integer :: iounit,iostat,ind,i
749 :
750 :
751 : ! First save current controls
752 0 : call set_binary_controls_for_writing(b, ierr)
753 0 : if(ierr/=0) return
754 :
755 : ! Write namelist to temporary file
756 0 : open(newunit=iounit,status='scratch')
757 0 : write(iounit,nml=binary_controls)
758 0 : rewind(iounit)
759 :
760 : ! Namelists get written in capitals
761 0 : upper_name = StrUpCase(name)
762 0 : val = ''
763 : ! Search for name inside namelist
764 : do
765 0 : read(iounit,'(A)',iostat=iostat) str
766 0 : ind = index(str,trim(upper_name))
767 0 : if( ind /= 0 ) then
768 0 : val = str(ind+len_trim(upper_name)+1:len_trim(str)-1) ! Remove final comma and starting =
769 0 : do i=1,len(val)
770 0 : if(val(i:i)=='"') val(i:i) = ' '
771 : end do
772 : exit
773 : end if
774 0 : if(is_iostat_end(iostat)) exit
775 : end do
776 :
777 0 : if(len_trim(val) == 0 .and. ind==0 ) ierr = -1
778 :
779 0 : close(iounit)
780 :
781 0 : end subroutine get_binary_control
782 :
783 0 : subroutine set_binary_control(b, name, val, ierr)
784 : type (binary_info), pointer :: b
785 : character(len=*), intent(in) :: name, val
786 0 : character(len=len(name)+len(val)+19) :: tmp
787 : integer, intent(out) :: ierr
788 :
789 : ! First save current controls
790 0 : call set_binary_controls_for_writing(b, ierr)
791 0 : if(ierr/=0) return
792 :
793 0 : tmp=''
794 0 : tmp = '&binary_controls '//trim(name)//'='//trim(val)//' /'
795 :
796 : ! Load into namelist
797 0 : read(tmp, nml=binary_controls)
798 :
799 : ! Add to star
800 0 : call store_binary_controls(b)
801 0 : if(ierr/=0) return
802 :
803 : end subroutine set_binary_control
804 :
805 : end module binary_ctrls_io
806 :
|