<commit_before>module wdmerger_util_module

  use probdata_module

  implicit none

contains

  ! This routine calls all of the other subroutines at the beginning
  ! of a simulation to fill in the basic problem data.

  subroutine initialize_problem(init_in)

    use bl_error_module, only: bl_error
    use prob_params_module, only: dim

    implicit none

    integer :: init_in

    init = init_in

    ! Read in the namelist to set problem parameters.

    call read_namelist

    ! Establish binary parameters and create initial models.

    call binary_setup

    ! Set small_pres and small_ener.

    call set_small

  end subroutine initialize_problem



  ! This routine reads in the namelist

  subroutine read_namelist

    use bl_constants_module, only: ZERO
    use meth_params_module
    use prob_params_module, only: dim, coord_type
    use problem_io_module, only: probin

    implicit none

    integer :: untin

    ! Read namelist to override the module defaults.

    untin = 9 
    open(untin,file=probin,form='formatted',status='old')
    read(untin,fortin)
    close(unit=untin)

    ! Convert masses from solar masses to grams.

    mass_P = mass_P * M_solar
    mass_S = mass_S * M_solar

    max_he_wd_mass = max_he_wd_mass * M_solar
    max_hybrid_wd_mass = max_hybrid_wd_mass * M_solar
    max_co_wd_mass = max_co_wd_mass * M_solar

    hybrid_wd_he_shell_mass = hybrid_wd_he_shell_mass * M_solar
    co_wd_he_shell_mass = co_wd_he_shell_mass * M_solar

    if (mass_S < ZERO .and. central_density_S < ZERO) single_star = .true.

    ! Make sure that the primary mass is really the larger mass

    call ensure_primary_mass_larger

    ! We enforce that the orbital plane is (z, phi) for two-dimensional problems,
    ! with rotation about z = 0 along the radial axis.

    if (dim .eq. 2) then

       if (coord_type .ne. 1) then
          call bl_error("We only support cylindrical coordinates in two dimensions. Set coord_type == 1.")
       endif

       axis_1 = 2
       axis_2 = 3
       rot_axis = 1

    endif

    ! Make sure we have a sensible collision impact parameter.

    if (collision_impact_parameter > 1.0) then
       call bl_error("Impact parameter must be less than one in our specified units.")
    endif

    ! Safety check: we can't run most problems in one dimension.
    if (dim .eq. 1 .and. (.not. (problem .eq. 0 .or. problem .eq. 4))) then
       call bl_error("Can only run a collision or freefall in 1D. Exiting.")
    endif

    ! Don't do a merger in 2D.

    if (dim .eq. 2 .and. (problem .eq. 2 .or. problem .eq. 3)) then
       call bl_error("2D simulations do not work for non-axisymmetric problems like mergers.")
    endif

    ! Don't do a collision or a free-fall in a rotating reference frame.

    if (problem .eq. 0 .and. do_rotation .eq. 1) then
       call bl_error("The collision problem does not make sense in a rotating reference frame.")
    endif
<commit_msg>Remove restriction on doing merger problems in 2D<commit_after>module wdmerger_util_module

  use probdata_module

  implicit none

contains

  ! This routine calls all of the other subroutines at the beginning
  ! of a simulation to fill in the basic problem data.

  subroutine initialize_problem(init_in)

    use bl_error_module, only: bl_error
    use prob_params_module, only: dim

    implicit none

    integer :: init_in

    init = init_in

    ! Read in the namelist to set problem parameters.

    call read_namelist

    ! Establish binary parameters and create initial models.

    call binary_setup

    ! Set small_pres and small_ener.

    call set_small

  end subroutine initialize_problem



  ! This routine reads in the namelist

  subroutine read_namelist

    use bl_constants_module, only: ZERO
    use meth_params_module
    use prob_params_module, only: dim, coord_type
    use problem_io_module, only: probin

    implicit none

    integer :: untin

    ! Read namelist to override the module defaults.

    untin = 9 
    open(untin,file=probin,form='formatted',status='old')
    read(untin,fortin)
    close(unit=untin)

    ! Convert masses from solar masses to grams.

    mass_P = mass_P * M_solar
    mass_S = mass_S * M_solar

    max_he_wd_mass = max_he_wd_mass * M_solar
    max_hybrid_wd_mass = max_hybrid_wd_mass * M_solar
    max_co_wd_mass = max_co_wd_mass * M_solar

    hybrid_wd_he_shell_mass = hybrid_wd_he_shell_mass * M_solar
    co_wd_he_shell_mass = co_wd_he_shell_mass * M_solar

    if (mass_S < ZERO .and. central_density_S < ZERO) single_star = .true.

    ! Make sure that the primary mass is really the larger mass

    call ensure_primary_mass_larger

    ! We enforce that the orbital plane is (z, phi) for two-dimensional problems,
    ! with rotation about z = 0 along the radial axis.

    if (dim .eq. 2) then

       if (coord_type .ne. 1) then
          call bl_error("We only support cylindrical coordinates in two dimensions. Set coord_type == 1.")
       endif

       axis_1 = 2
       axis_2 = 3
       rot_axis = 1

    endif

    ! Make sure we have a sensible collision impact parameter.

    if (collision_impact_parameter > 1.0) then
       call bl_error("Impact parameter must be less than one in our specified units.")
    endif

    ! Safety check: we can't run most problems in one dimension.

    if (dim .eq. 1 .and. (.not. (problem .eq. 0 .or. problem .eq. 4))) then
       call bl_error("Can only run a collision or freefall in 1D. Exiting.")
    endif

    ! Don't do a collision or a free-fall in a rotating reference frame.

    if (problem .eq. 0 .and. do_rotation .eq. 1) then
       call bl_error("The collision problem does not make sense in a rotating reference frame.")
    endif

{'fraction_non_alphanumeric': 0.06075993696375416, 'fraction_numerical': 0.007354228681491858, 'mean_word_length': 2.8568534773801484, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1746751', 'n_tokens_mistral': 1915, 'n_tokens_neox': 1739, 'n_words': 654}