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_alpha_core, &
182 : CE_mass_loss_rate_high, &
183 : CE_mass_loss_rate_low, &
184 : CE_rel_rlo_for_detachment, &
185 : CE_years_detached_to_terminate, &
186 : CE_begin_at_max_implicit_abs_mdot, &
187 : CE_xa_diff_to_terminate, &
188 : CE_terminate_when_core_overflows, &
189 : CE_min_period_in_minutes, &
190 : CE_energy_factor_HII_toHI, &
191 : CE_energy_factor_HeII_toHeI, &
192 : CE_energy_factor_HeIII_toHeII, &
193 : CE_energy_factor_H2, &
194 : CE_fixed_lambda, &
195 :
196 : ! miscellaneous controls
197 : keep_donor_fixed, &
198 : mdot_limit_donor_switch, &
199 : use_other_rlo_mdot, &
200 : use_other_check_implicit_rlo, &
201 : use_other_implicit_function_to_solve, &
202 : use_other_tsync, &
203 : use_other_sync_spin_to_orbit, &
204 : use_other_mdot_edd, &
205 : use_other_adjust_mdots, &
206 : use_other_accreted_material_j, &
207 : use_other_jdot_gr, &
208 : use_other_jdot_ml, &
209 : use_other_jdot_ls, &
210 : use_other_jdot_missing_wind, &
211 : use_other_jdot_mb, &
212 : use_other_extra_jdot, &
213 : use_other_binary_wind_transfer, &
214 : use_other_edot_tidal, &
215 : use_other_edot_enhance, &
216 : use_other_extra_edot, &
217 : use_other_CE_init, &
218 : use_other_CE_rlo_mdot, &
219 : use_other_CE_binary_evolve_step, &
220 : use_other_CE_binary_finish_step, &
221 : x_ctrl, &
222 : x_integer_ctrl, &
223 : x_logical_ctrl, &
224 : x_character_ctrl, &
225 :
226 : ! extra files
227 : read_extra_binary_controls_inlist, extra_binary_controls_inlist_name
228 :
229 : contains
230 :
231 :
232 0 : subroutine do_one_binary_setup(b, inlist, ierr)
233 : use utils_lib
234 : type (binary_info), pointer :: b
235 : character (len=*), intent(in) :: inlist
236 : integer, intent(out) :: ierr
237 :
238 : include 'formats'
239 :
240 0 : call set_default_binary_controls
241 0 : call read_binary_controls(b, inlist, ierr)
242 :
243 : ! open additional file for binary output
244 0 : if (len_trim(b% extra_binary_terminal_output_file) /= 0) then
245 : open(newunit=b% extra_binary_terminal_iounit, file=trim(b% extra_binary_terminal_output_file), &
246 0 : action='write', status='replace',iostat=ierr)
247 0 : if (ierr /= 0) then
248 0 : write(*,*) 'failed to open ' // trim(b% extra_binary_terminal_output_file)
249 0 : return
250 : end if
251 : end if
252 :
253 : end subroutine do_one_binary_setup
254 :
255 :
256 0 : subroutine read_binary_controls(b, filename, ierr)
257 : use utils_lib
258 : type (binary_info), pointer :: b
259 : character(*), intent(in) :: filename
260 : integer, intent(out) :: ierr
261 :
262 0 : call read_binary_controls_file(b, filename, 1, ierr)
263 :
264 0 : end subroutine read_binary_controls
265 :
266 :
267 0 : recursive subroutine read_binary_controls_file(b, filename, level, ierr)
268 : use utils_lib
269 : character(*), intent(in) :: filename
270 : type (binary_info), pointer :: b
271 : integer, intent(in) :: level
272 : integer, intent(out) :: ierr
273 : logical, dimension(max_extra_inlists) :: read_extra
274 : character (len=strlen), dimension(max_extra_inlists) :: extra
275 : integer :: unit, i
276 :
277 0 : ierr = 0
278 :
279 0 : if (level >= 10) then
280 0 : write(*,*) 'ERROR: too many levels of nested extra binary controls inlist files'
281 0 : ierr = -1
282 0 : return
283 : end if
284 :
285 0 : if (len_trim(filename) > 0) then
286 0 : open(newunit=unit, file=trim(filename), action='read', delim='quote', status='old', iostat=ierr)
287 0 : if (ierr /= 0) then
288 0 : write(*, *) 'Failed to open binary control namelist file ', trim(filename)
289 0 : return
290 : end if
291 0 : read(unit, nml=binary_controls, iostat=ierr)
292 0 : close(unit)
293 0 : if (ierr /= 0) then
294 0 : write(*, *)
295 0 : write(*, *)
296 0 : write(*, *)
297 0 : write(*, *)
298 : write(*, '(a)') &
299 0 : 'Failed while trying to read binary control namelist file: ' // trim(filename)
300 : write(*, '(a)') &
301 0 : 'Perhaps the following runtime error message will help you find the problem.'
302 0 : write(*, *)
303 0 : open(newunit=unit, file=trim(filename), action='read', delim='quote', status='old', iostat=ierr)
304 0 : read(unit, nml=binary_controls)
305 0 : close(unit)
306 0 : return
307 : end if
308 : end if
309 :
310 0 : call store_binary_controls(b, ierr)
311 :
312 : ! recursive calls to read other inlists
313 0 : do i=1, max_extra_inlists
314 0 : read_extra(i) = read_extra_binary_controls_inlist(i)
315 0 : read_extra_binary_controls_inlist(i) = .false.
316 0 : extra(i) = extra_binary_controls_inlist_name(i)
317 0 : extra_binary_controls_inlist_name(i) = 'undefined'
318 :
319 0 : if (read_extra(i)) then
320 0 : call read_binary_controls_file(b, extra(i), level+1, ierr)
321 0 : if (ierr /= 0) return
322 : end if
323 : end do
324 :
325 : end subroutine read_binary_controls_file
326 :
327 :
328 0 : subroutine set_default_binary_controls
329 : include 'binary_controls.defaults'
330 0 : end subroutine set_default_binary_controls
331 :
332 :
333 0 : subroutine store_binary_controls(b, ierr)
334 : use utils_lib, only: mkdir
335 : type (binary_info), pointer :: b
336 : integer, intent(out) :: ierr
337 :
338 0 : ierr = 0
339 :
340 : ! specifications for starting model
341 0 : b% m1 = m1
342 0 : b% m2 = m2
343 0 : b% initial_period_in_days = initial_period_in_days
344 0 : b% initial_separation_in_Rsuns = initial_separation_in_Rsuns
345 0 : b% initial_eccentricity = initial_eccentricity
346 :
347 : ! controls for output
348 0 : b% history_name = history_name
349 0 : b% history_interval = history_interval
350 0 : b% append_to_star_history = append_to_star_history
351 0 : b% log_directory = log_directory
352 0 : CALL mkdir(b% log_directory)
353 0 : b% history_dbl_format = history_dbl_format
354 0 : b% history_int_format = history_int_format
355 0 : b% history_txt_format = history_txt_format
356 0 : b% photo_interval = photo_interval
357 0 : b% photo_digits = photo_digits
358 0 : b% photo_directory = photo_directory
359 0 : CALL mkdir(b% photo_directory)
360 0 : b% terminal_interval = terminal_interval
361 0 : b% write_header_frequency = write_header_frequency
362 0 : b% extra_binary_terminal_output_file = extra_binary_terminal_output_file
363 :
364 : ! timestep controls
365 0 : b% time_delta_coeff = time_delta_coeff
366 0 : b% fm = fm
367 0 : b% fm_hard = fm_hard
368 0 : b% fa = fa
369 0 : b% fa_hard = fa_hard
370 0 : b% fr = fr
371 0 : b% fr_hard = fr_hard
372 0 : b% fj = fj
373 0 : b% fj_hard = fj_hard
374 0 : b% fe = fe
375 0 : b% fe_hard = fe_hard
376 0 : b% fm_limit = fm_limit
377 0 : b% fr_limit = fr_limit
378 0 : b% fe_limit = fe_limit
379 0 : b% fr_dt_limit = fr_dt_limit
380 0 : b% fdm = fdm
381 0 : b% fdm_hard = fdm_hard
382 0 : b% dt_softening_factor = dt_softening_factor
383 0 : b% varcontrol_case_a = varcontrol_case_a
384 0 : b% varcontrol_case_b = varcontrol_case_b
385 0 : b% varcontrol_ms = varcontrol_ms
386 0 : b% varcontrol_post_ms = varcontrol_post_ms
387 0 : b% dt_reduction_factor_for_j = dt_reduction_factor_for_j
388 :
389 : ! when to stop
390 0 : b% accretor_overflow_terminate = accretor_overflow_terminate
391 0 : b% terminate_if_initial_overflow = terminate_if_initial_overflow
392 0 : b% terminate_if_L2_overflow = terminate_if_L2_overflow
393 :
394 : ! mass transfer controls
395 0 : b% mass_transfer_alpha = mass_transfer_alpha
396 0 : b% mass_transfer_beta = mass_transfer_beta
397 0 : b% mass_transfer_delta = mass_transfer_delta
398 0 : b% mass_transfer_gamma = mass_transfer_gamma
399 0 : b% limit_retention_by_mdot_edd = limit_retention_by_mdot_edd
400 0 : b% use_es_opacity_for_mdot_edd = use_es_opacity_for_mdot_edd
401 0 : b% use_this_for_mdot_edd_eta = use_this_for_mdot_edd_eta
402 0 : b% use_radiation_corrected_transfer_rate = use_radiation_corrected_transfer_rate
403 0 : b% initial_bh_spin = initial_bh_spin
404 0 : b% use_this_for_mdot_edd = use_this_for_mdot_edd
405 0 : b% mdot_scheme = mdot_scheme
406 0 : b% cur_mdot_frac = cur_mdot_frac
407 0 : b% max_explicit_abs_mdot = max_explicit_abs_mdot
408 0 : b% max_tries_to_achieve = max_tries_to_achieve
409 0 : b% solver_type = solver_type
410 0 : b% implicit_scheme_tolerance = implicit_scheme_tolerance
411 0 : b% implicit_scheme_tiny_factor = implicit_scheme_tiny_factor
412 0 : b% initial_change_factor = initial_change_factor
413 0 : b% change_factor_fraction = change_factor_fraction
414 0 : b% implicit_lambda = implicit_lambda
415 0 : b% max_change_factor = max_change_factor
416 0 : b% min_change_factor = min_change_factor
417 0 : b% num_tries_for_increase_change_factor = num_tries_for_increase_change_factor
418 0 : b% change_factor_increase = change_factor_increase
419 0 : b% starting_mdot = starting_mdot
420 0 : b% roche_min_mdot = roche_min_mdot
421 0 : b% min_mdot_for_implicit = min_mdot_for_implicit
422 0 : b% max_implicit_abs_mdot = max_implicit_abs_mdot
423 0 : b% report_rlo_solver_progress = report_rlo_solver_progress
424 0 : b% do_enhance_wind_1 = do_enhance_wind_1
425 0 : b% do_enhance_wind_2 = do_enhance_wind_2
426 0 : b% tout_B_wind_1 = tout_B_wind_1
427 0 : b% tout_B_wind_2 = tout_B_wind_2
428 0 : b% do_wind_mass_transfer_1 = do_wind_mass_transfer_1
429 0 : b% do_wind_mass_transfer_2 = do_wind_mass_transfer_2
430 0 : b% wind_BH_alpha_1 = wind_BH_alpha_1
431 0 : b% wind_BH_alpha_2 = wind_BH_alpha_2
432 0 : b% wind_BH_beta_1 = wind_BH_beta_1
433 0 : b% wind_BH_beta_2 = wind_BH_beta_2
434 0 : b% max_wind_transfer_fraction_1 = max_wind_transfer_fraction_1
435 0 : b% max_wind_transfer_fraction_2 = max_wind_transfer_fraction_2
436 :
437 : ! orbital jdot controls
438 0 : b% do_jdot_gr = do_jdot_gr
439 0 : b% do_jdot_ml = do_jdot_ml
440 0 : b% do_jdot_ls = do_jdot_ls
441 0 : b% do_jdot_missing_wind = do_jdot_missing_wind
442 0 : b% do_jdot_mb = do_jdot_mb
443 0 : b% include_accretor_mb = include_accretor_mb
444 0 : b% magnetic_braking_gamma = magnetic_braking_gamma
445 0 : b% keep_mb_on = keep_mb_on
446 0 : b% jdot_mb_min_qconv_env = jdot_mb_min_qconv_env
447 0 : b% jdot_mb_max_qconv_env = jdot_mb_max_qconv_env
448 0 : b% jdot_mb_max_qconv_core = jdot_mb_max_qconv_core
449 0 : b% jdot_mb_qlim_for_check_rad_core = jdot_mb_qlim_for_check_rad_core
450 0 : b% jdot_mb_qlim_for_check_conv_env = jdot_mb_qlim_for_check_conv_env
451 0 : b% jdot_mb_scale_for_low_qconv_env = jdot_mb_scale_for_low_qconv_env
452 0 : b% jdot_mb_mass_frac_for_scale = jdot_mb_mass_frac_for_scale
453 0 : b% jdot_multiplier = jdot_multiplier
454 :
455 : ! rotation and sync controls
456 0 : b% do_j_accretion = do_j_accretion
457 0 : b% do_tidal_sync = do_tidal_sync
458 0 : b% sync_type_1 = sync_type_1
459 0 : b% sync_type_2 = sync_type_2
460 0 : b% sync_mode_1 = sync_mode_1
461 0 : b% sync_mode_2 = sync_mode_2
462 0 : b% Ftid_1 = Ftid_1
463 0 : b% Ftid_2 = Ftid_2
464 0 : b% do_initial_orbit_sync_1 = do_initial_orbit_sync_1
465 0 : b% do_initial_orbit_sync_2 = do_initial_orbit_sync_2
466 0 : b% tidal_reduction = tidal_reduction
467 :
468 : ! eccentricity controls
469 0 : b% do_tidal_circ = do_tidal_circ
470 0 : b% circ_type_1 = circ_type_1
471 0 : b% circ_type_2 = circ_type_2
472 0 : b% use_eccentricity_enhancement = use_eccentricity_enhancement
473 0 : b% max_abs_edot_tidal = max_abs_edot_tidal
474 0 : b% max_abs_edot_enhance = max_abs_edot_enhance
475 0 : b% min_eccentricity = min_eccentricity
476 0 : b% max_eccentricity = max_eccentricity
477 0 : b% anomaly_steps = anomaly_steps
478 :
479 : ! irradiation controls
480 0 : b% accretion_powered_irradiation = accretion_powered_irradiation
481 0 : b% use_accretor_luminosity_for_irrad = use_accretor_luminosity_for_irrad
482 0 : b% col_depth_for_eps_extra = col_depth_for_eps_extra
483 0 : b% irrad_flux_at_std_distance = irrad_flux_at_std_distance
484 0 : b% std_distance_for_irradiation = std_distance_for_irradiation
485 0 : b% max_F_irr = max_F_irr
486 :
487 : !common envelope controls
488 0 : b% CE_alpha = CE_alpha
489 0 : b% CE_alpha_th = CE_alpha_th
490 0 : b% CE_alpha_core = CE_alpha_core
491 0 : b% CE_mass_loss_rate_high = CE_mass_loss_rate_high
492 0 : b% CE_mass_loss_rate_low = CE_mass_loss_rate_low
493 0 : b% CE_rel_rlo_for_detachment = CE_rel_rlo_for_detachment
494 0 : b% CE_years_detached_to_terminate = CE_years_detached_to_terminate
495 0 : b% CE_begin_at_max_implicit_abs_mdot = CE_begin_at_max_implicit_abs_mdot
496 0 : b% CE_xa_diff_to_terminate = CE_xa_diff_to_terminate
497 0 : b% CE_terminate_when_core_overflows = CE_terminate_when_core_overflows
498 0 : b% CE_min_period_in_minutes = CE_min_period_in_minutes
499 0 : b% CE_energy_factor_HII_toHI = CE_energy_factor_HII_toHI
500 0 : b% CE_energy_factor_HeII_toHeI = CE_energy_factor_HeII_toHeI
501 0 : b% CE_energy_factor_HeIII_toHeII = CE_energy_factor_HeIII_toHeII
502 0 : b% CE_energy_factor_H2 = CE_energy_factor_H2
503 0 : b% CE_fixed_lambda = CE_fixed_lambda
504 :
505 : ! miscellaneous controls
506 0 : b% keep_donor_fixed = keep_donor_fixed
507 0 : b% mdot_limit_donor_switch = mdot_limit_donor_switch
508 0 : b% use_other_rlo_mdot = use_other_rlo_mdot
509 0 : b% use_other_check_implicit_rlo = use_other_check_implicit_rlo
510 0 : b% use_other_implicit_function_to_solve = use_other_implicit_function_to_solve
511 0 : b% use_other_tsync = use_other_tsync
512 0 : b% use_other_sync_spin_to_orbit = use_other_sync_spin_to_orbit
513 0 : b% use_other_mdot_edd = use_other_mdot_edd
514 0 : b% use_other_adjust_mdots = use_other_adjust_mdots
515 0 : b% use_other_accreted_material_j = use_other_accreted_material_j
516 0 : b% use_other_jdot_gr = use_other_jdot_gr
517 0 : b% use_other_jdot_ml = use_other_jdot_ml
518 0 : b% use_other_jdot_ls = use_other_jdot_ls
519 0 : b% use_other_jdot_missing_wind = use_other_jdot_missing_wind
520 0 : b% use_other_jdot_mb = use_other_jdot_mb
521 0 : b% use_other_extra_jdot = use_other_extra_jdot
522 0 : b% use_other_binary_wind_transfer = use_other_binary_wind_transfer
523 0 : b% use_other_edot_tidal = use_other_edot_tidal
524 0 : b% use_other_edot_enhance = use_other_edot_enhance
525 0 : b% use_other_extra_edot = use_other_extra_edot
526 0 : b% use_other_CE_init = use_other_CE_init
527 0 : b% use_other_CE_rlo_mdot = use_other_CE_rlo_mdot
528 0 : b% use_other_CE_binary_evolve_step = use_other_CE_binary_evolve_step
529 0 : b% use_other_CE_binary_finish_step = use_other_CE_binary_finish_step
530 :
531 0 : b% x_ctrl = x_ctrl
532 0 : b% x_integer_ctrl = x_integer_ctrl
533 0 : b% x_logical_ctrl = x_logical_ctrl
534 0 : b% x_character_ctrl = x_character_ctrl
535 :
536 0 : end subroutine store_binary_controls
537 :
538 :
539 0 : subroutine set_binary_controls_for_writing(b, ierr)
540 : type (binary_info), pointer :: b
541 : integer, intent(out) :: ierr
542 :
543 0 : ierr = 0
544 :
545 : ! specifications for starting model
546 0 : m1 = b% m1
547 0 : m2 = b% m2
548 0 : initial_period_in_days = b% initial_period_in_days
549 0 : initial_separation_in_Rsuns = b% initial_separation_in_Rsuns
550 0 : initial_eccentricity = b% initial_eccentricity
551 :
552 : ! controls for output
553 0 : history_name = b% history_name
554 0 : history_interval = b% history_interval
555 0 : append_to_star_history = b% append_to_star_history
556 0 : log_directory = b% log_directory
557 0 : history_dbl_format = b% history_dbl_format
558 0 : history_int_format = b% history_int_format
559 0 : history_txt_format = b% history_txt_format
560 0 : photo_interval = b% photo_interval
561 0 : photo_digits = b% photo_digits
562 0 : photo_directory = b% photo_directory
563 0 : terminal_interval = b% terminal_interval
564 0 : write_header_frequency = b% write_header_frequency
565 0 : extra_binary_terminal_output_file = b% extra_binary_terminal_output_file
566 :
567 : ! timestep controls
568 0 : time_delta_coeff = b% time_delta_coeff
569 0 : fm = b% fm
570 0 : fa = b% fa
571 0 : fr = b% fr
572 0 : fj = b% fj
573 0 : fe = b% fe
574 0 : fm_limit = b% fm_limit
575 0 : fr_limit = b% fr_limit
576 0 : fe_limit = b% fe_limit
577 0 : fr_dt_limit = b% fr_dt_limit
578 0 : fdm = b% fdm
579 0 : fdm_hard = b% fdm_hard
580 0 : dt_softening_factor = b% dt_softening_factor
581 0 : varcontrol_case_a = b% varcontrol_case_a
582 0 : varcontrol_case_b = b% varcontrol_case_b
583 0 : varcontrol_ms = b% varcontrol_ms
584 0 : varcontrol_post_ms = b% varcontrol_post_ms
585 0 : dt_reduction_factor_for_j = b% dt_reduction_factor_for_j
586 :
587 : ! when to stop
588 0 : accretor_overflow_terminate = b% accretor_overflow_terminate
589 0 : terminate_if_initial_overflow = b% terminate_if_initial_overflow
590 0 : terminate_if_L2_overflow = b% terminate_if_L2_overflow
591 :
592 : ! mass transfer controls
593 0 : mass_transfer_alpha = b% mass_transfer_alpha
594 0 : mass_transfer_beta = b% mass_transfer_beta
595 0 : mass_transfer_delta = b% mass_transfer_delta
596 0 : mass_transfer_gamma = b% mass_transfer_gamma
597 0 : limit_retention_by_mdot_edd = b% limit_retention_by_mdot_edd
598 0 : use_es_opacity_for_mdot_edd = b% use_es_opacity_for_mdot_edd
599 0 : use_this_for_mdot_edd_eta = b% use_this_for_mdot_edd_eta
600 0 : use_radiation_corrected_transfer_rate = b% use_radiation_corrected_transfer_rate
601 0 : initial_bh_spin = b% initial_bh_spin
602 0 : use_this_for_mdot_edd = b% use_this_for_mdot_edd
603 0 : mdot_scheme = b% mdot_scheme
604 0 : cur_mdot_frac = b% cur_mdot_frac
605 0 : max_explicit_abs_mdot = b% max_explicit_abs_mdot
606 0 : max_tries_to_achieve = b% max_tries_to_achieve
607 0 : solver_type = b% solver_type
608 0 : implicit_scheme_tolerance = b% implicit_scheme_tolerance
609 0 : implicit_scheme_tiny_factor = b% implicit_scheme_tiny_factor
610 0 : initial_change_factor = b% initial_change_factor
611 0 : change_factor_fraction = b% change_factor_fraction
612 0 : implicit_lambda = b% implicit_lambda
613 0 : max_change_factor = b% max_change_factor
614 0 : min_change_factor = b% min_change_factor
615 0 : num_tries_for_increase_change_factor = b% num_tries_for_increase_change_factor
616 0 : change_factor_increase = b% change_factor_increase
617 0 : starting_mdot = b% starting_mdot
618 0 : roche_min_mdot = b% roche_min_mdot
619 0 : min_mdot_for_implicit = b% min_mdot_for_implicit
620 0 : max_implicit_abs_mdot = b% max_implicit_abs_mdot
621 0 : report_rlo_solver_progress = b% report_rlo_solver_progress
622 0 : do_enhance_wind_1 = b% do_enhance_wind_1
623 0 : do_enhance_wind_2 = b% do_enhance_wind_2
624 0 : tout_B_wind_1 = b% tout_B_wind_1
625 0 : tout_B_wind_2 = b% tout_B_wind_2
626 0 : do_wind_mass_transfer_1 = b% do_wind_mass_transfer_1
627 0 : do_wind_mass_transfer_2 = b% do_wind_mass_transfer_2
628 0 : wind_BH_alpha_1 = b% wind_BH_alpha_1
629 0 : wind_BH_alpha_2 = b% wind_BH_alpha_2
630 0 : wind_BH_beta_1 = b% wind_BH_beta_1
631 0 : wind_BH_beta_2 = b% wind_BH_beta_2
632 0 : max_wind_transfer_fraction_1 = b% max_wind_transfer_fraction_1
633 0 : max_wind_transfer_fraction_2 = b% max_wind_transfer_fraction_2
634 :
635 : ! orbital jdot controls
636 0 : do_jdot_gr = b% do_jdot_gr
637 0 : do_jdot_ml = b% do_jdot_ml
638 0 : do_jdot_ls = b% do_jdot_ls
639 0 : do_jdot_missing_wind = b% do_jdot_missing_wind
640 0 : do_jdot_mb = b% do_jdot_mb
641 0 : include_accretor_mb = b% include_accretor_mb
642 0 : magnetic_braking_gamma = b% magnetic_braking_gamma
643 0 : keep_mb_on = b% keep_mb_on
644 0 : jdot_mb_min_qconv_env = b% jdot_mb_min_qconv_env
645 0 : jdot_mb_max_qconv_env = b% jdot_mb_max_qconv_env
646 0 : jdot_mb_max_qconv_core = b% jdot_mb_max_qconv_core
647 0 : jdot_mb_qlim_for_check_rad_core = b% jdot_mb_qlim_for_check_rad_core
648 0 : jdot_mb_qlim_for_check_conv_env = b% jdot_mb_qlim_for_check_conv_env
649 0 : jdot_mb_scale_for_low_qconv_env = b% jdot_mb_scale_for_low_qconv_env
650 0 : jdot_mb_mass_frac_for_scale = b% jdot_mb_mass_frac_for_scale
651 0 : jdot_multiplier = b% jdot_multiplier
652 :
653 : ! rotation and sync controls
654 0 : do_j_accretion = b% do_j_accretion
655 0 : do_tidal_sync = b% do_tidal_sync
656 0 : sync_type_1 = b% sync_type_1
657 0 : sync_type_2 = b% sync_type_2
658 0 : sync_mode_1 = b% sync_mode_1
659 0 : sync_mode_2 = b% sync_mode_2
660 0 : Ftid_1 = b% Ftid_1
661 0 : Ftid_2 = b% Ftid_2
662 0 : do_initial_orbit_sync_1 = b% do_initial_orbit_sync_1
663 0 : do_initial_orbit_sync_2 = b% do_initial_orbit_sync_2
664 0 : tidal_reduction = b% tidal_reduction
665 :
666 : ! eccentricity controls
667 0 : do_tidal_circ = b% do_tidal_circ
668 0 : circ_type_1 = b% circ_type_1
669 0 : circ_type_2 = b% circ_type_2
670 0 : use_eccentricity_enhancement = b% use_eccentricity_enhancement
671 0 : max_abs_edot_tidal = b% max_abs_edot_tidal
672 0 : max_abs_edot_enhance = b% max_abs_edot_enhance
673 0 : min_eccentricity = b% min_eccentricity
674 0 : max_eccentricity = b% max_eccentricity
675 0 : anomaly_steps = b% anomaly_steps
676 :
677 : ! irradiation controls
678 0 : accretion_powered_irradiation = b% accretion_powered_irradiation
679 0 : use_accretor_luminosity_for_irrad = b% use_accretor_luminosity_for_irrad
680 0 : col_depth_for_eps_extra = b% col_depth_for_eps_extra
681 0 : irrad_flux_at_std_distance = b% irrad_flux_at_std_distance
682 0 : std_distance_for_irradiation = b% std_distance_for_irradiation
683 0 : max_F_irr = b% max_F_irr
684 :
685 : !common envelope controls
686 0 : CE_alpha = b% CE_alpha
687 0 : CE_alpha_th = b% CE_alpha_th
688 0 : CE_alpha_core = b% CE_alpha_core
689 0 : CE_mass_loss_rate_high = b% CE_mass_loss_rate_high
690 0 : CE_mass_loss_rate_low = b% CE_mass_loss_rate_low
691 0 : CE_rel_rlo_for_detachment = b% CE_rel_rlo_for_detachment
692 0 : CE_years_detached_to_terminate = b% CE_years_detached_to_terminate
693 0 : CE_begin_at_max_implicit_abs_mdot = b% CE_begin_at_max_implicit_abs_mdot
694 0 : CE_xa_diff_to_terminate = b% CE_xa_diff_to_terminate
695 0 : CE_terminate_when_core_overflows = b% CE_terminate_when_core_overflows
696 0 : CE_min_period_in_minutes = b% CE_min_period_in_minutes
697 0 : CE_fixed_lambda = b% CE_fixed_lambda
698 :
699 : ! miscellaneous controls
700 0 : keep_donor_fixed = b% keep_donor_fixed
701 0 : mdot_limit_donor_switch = b% mdot_limit_donor_switch
702 0 : use_other_rlo_mdot = b% use_other_rlo_mdot
703 0 : use_other_check_implicit_rlo = b% use_other_check_implicit_rlo
704 0 : use_other_implicit_function_to_solve = b% use_other_implicit_function_to_solve
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, ierr)
801 0 : if(ierr/=0) return
802 :
803 : end subroutine set_binary_control
804 :
805 : end module binary_ctrls_io
806 :
|