phys_init Subroutine

public subroutine phys_init()

Uses

  • proc~~phys_init~3~~UsesGraph proc~phys_init~3 phys_init mod_radiative_cooling mod_radiative_cooling proc~phys_init~3->mod_radiative_cooling module~mod_global_parameters mod_global_parameters proc~phys_init~3->module~mod_global_parameters module~mod_basic_types mod_basic_types module~mod_global_parameters->module~mod_basic_types module~mod_connectivity mod_connectivity module~mod_global_parameters->module~mod_connectivity module~mod_constants mod_constants module~mod_global_parameters->module~mod_constants module~mod_physicaldata mod_physicaldata module~mod_global_parameters->module~mod_physicaldata module~mod_variables mod_variables module~mod_global_parameters->module~mod_variables mpi mpi module~mod_global_parameters->mpi module~mod_variables->module~mod_basic_types

Initialize the module

Arguments

None

Calls

proc~~phys_init~3~~CallsGraph proc~phys_init~3 phys_init flux_type flux_type proc~phys_init~3->flux_type mom mom proc~phys_init~3->mom proc~mpistop mpistop proc~phys_init~3->proc~mpistop proc~phys_units~3 phys_units proc~phys_init~3->proc~phys_units~3 proc~read_params~3 read_params proc~phys_init~3->proc~read_params~3 proc~var_set_energy var_set_energy proc~phys_init~3->proc~var_set_energy proc~var_set_extravar var_set_extravar proc~phys_init~3->proc~var_set_extravar proc~var_set_momentum var_set_momentum proc~phys_init~3->proc~var_set_momentum proc~var_set_q var_set_q proc~phys_init~3->proc~var_set_q proc~var_set_rho var_set_rho proc~phys_init~3->proc~var_set_rho radiative_cooling_init radiative_cooling_init proc~phys_init~3->radiative_cooling_init radiative_cooling_init_params radiative_cooling_init_params proc~phys_init~3->radiative_cooling_init_params mpi_abort mpi_abort proc~mpistop->mpi_abort proc~errormsg errormsg proc~var_set_extravar->proc~errormsg proc~var_set_momentum->proc~errormsg

Called by

proc~~phys_init~3~~CalledByGraph proc~phys_init~3 phys_init proc~phys_activate~3 phys_activate proc~phys_activate~3->proc~phys_init~3

Source Code

  subroutine phys_init()

    use mod_global_parameters
    use mod_radiative_cooling, only: rc_fl, radiative_cooling_init_params, radiative_cooling_init

    call read_params(par_files)
    call phys_units()

    phys_energy  = ffhd_energy
    phys_total_energy  = ffhd_energy
    phys_internal_e = .false.
    phys_gamma = ffhd_gamma
    phys_partial_ionization=ffhd_partial_ionization
    gamma_1 = ffhd_gamma - 1.0d0
    inv_gamma_1 = 1.0d0/gamma_1
    

    ! Determine flux variables
    rho_ = var_set_rho()
    

    allocate(mom(1))
    mom(:) = var_set_momentum(1)
    

    ! Set index of energy variable
    if (ffhd_energy) then
       e_ = var_set_energy()
       p_ = e_
    else
       e_ = -1
       p_ = -1
    end if
    

    ! Set index for heat flux
    q_ = var_set_q()
    need_global_cmax = .true.
    hypertc_kappa = 8.d-7*unit_temperature**3.5_dp/unit_length/unit_density/unit_velocity**3.0_dp
    
    
    

    ! Set index of frozen magnetic field
    iw_b1 = var_set_extravar('b1', 'b1')
    iw_b2 = var_set_extravar('b2', 'b2')
    iw_b3 = var_set_extravar('b3', 'b3')
    

    ! set number of variables which need update ghostcells
    ! The frozen field (b1,b2,b3) is registered via var_set_extravar (it is
    ! not advected), but it is NOT exchanged through getbc: it is a pure
    ! function of position, so with the FILL_NWEXTRA_ANALYTIC flag (which
    ! config_schema.toml's `implies` sets for phys='ffhd') fill_nwextra_device
    ! re-derives it from usr_set_nwextra in every cell of every block -
    ! interior, inter-block ghosts, physical-boundary ghosts and polar-axis
    ! ghosts alike - after each tree change. Keeping it out of getbc is what
    ! lets the polar axis work: evaluating the user's analytic field at a ghost
    ! cell's own (mirrored) coordinates reproduces the pole sign flips for
    ! free, with no entry in typeboundary. So nwgc stops at nwflux, exactly as
    ! for hd and mhd.
    nwgc=nwflux
    

    ! Define custom flux types:
    if (.not. allocated(flux_type)) then
       allocate(flux_type(ndir, nw_flux))
       flux_type = flux_default
    else if (any(shape(flux_type) /= [ndir, nw_flux])) then
       call mpistop("phys_check error: flux_type has wrong shape")
    end if
    

    ! Only the frozen field (b1,b2,b3) is a genuine vector here: mom(1) is a
    ! scalar (the field-aligned momentum m_par), not 3 consecutive slots, so
    ! it must not be registered as one.
    nvector      = 1 ! No. vector vars
    allocate(iw_vector(nvector))
    iw_vector(1) = iw_b1 - 1
    

    call radiative_cooling_init_params(phys_gamma,He_abundance)
    call radiative_cooling_init(rc_fl)
    
    

  end subroutine phys_init