params_neut_model_m.f90 Source File


Contents


Source Code

module params_neut_model_m
    !! Parameters for the neutrals model related with model, i.e.
    !! physics parameters
    use precision_grillix_m, only : GP, GP_NAN
    use error_handling_grillix_m, only: handle_error
    use status_codes_grillix_m, only : GRILLIX_ERR_NAMELIST
    use screen_io_m, only :  get_stdout
    implicit none

    real(GP), protected :: ne_ref = GP_NAN
    !! Reference density  [cm^-3]
    real(GP), protected :: te_ref = GP_NAN
    !! Reference temperature [eV]
    real(GP), protected :: k_ref = GP_NAN
    !! Reference rate coefficient [cm^3/s]
    real(GP), protected :: w_ref = GP_NAN
    !! Reference cooling rate coefficient [eV cm^3/s]
    real(GP), protected :: s_cx = GP_NAN
    !! Normalized charge exchange cross section
    real(GP), protected :: mach_limit = 1.0_GP
    !! Mach limit, for limiting diffusion coefficient value upwards
    real(GP), protected :: diff_tn_min = 0.0_GP
    !! Minimum neutrals temperature in neutrals density diffusion coefficient
    real(GP), protected :: pot_iz = 13.6_GP
    !! Ionization potential [eV]
    real(GP), protected :: pardiss_coeff_dens = 0.0_GP
    !! Parallel (numerical) diffusion coefficent acting on neutrals density
    real(GP), protected :: pardiss_coeff_parmom = 0.0_GP
    !! Parallel (numerical) diffusion coefficent acting on neutrals parallel momentum
    real(GP), protected :: pardiss_coeff_pressure = 0.0_GP
    !! Parallel (numerical) diffusion coefficent acting on neutrals pressure
    real(GP), protected :: rcy_coeff = 1.0_GP
    !! Recycling coefficient
    logical, protected :: evolve_pressure = .true.
    !! Boolean whether to evolve neutrals pressure (3-moment model)
    !! If disabled, neutrals will be set to ion temperature at the start of every neutrals timestep 
    logical, protected :: apply_neumann_mirror = .false.
    !! Whether or not to apply neumann mirroring to neutrals quantities to prevent
    !! diffusive outflows out of target, only relevant when using recycling boundary conditions
    logical, protected :: gas_puff_on = .false.
    !! Switch to enable external gas puff source
    character(LEN=128), protected :: gas_puff_path = 'gas_puff.in'
    !! Path to file where gas puffing source parameters are specified
    real(GP), protected :: src_rcy_temp = 0.0_GP
    !! Temperature of newly recycled neutrals
    real(GP), protected :: cx_cooling_thresh = 0.0_GP
    !! Ion temperature threshold below which TN is treated as 0 eV for Ti CX cooling
    real(GP), protected :: cx_cooling_thresh_min = 0.0_GP
    !! Ion temperature threshold below which which TN is treated normally again for Ti CX cooling
    real(GP), protected :: diff_co_smoothing = 0.0_GP
    !! Smoothing coefficient for diffusion coefficient

    public :: read_params_neut_model
    public :: write_params_neut_model

    namelist / neut_model / &
        ne_ref, &
        te_ref, &
        k_ref, &
        w_ref, &
        s_cx, &
        mach_limit, &
        diff_tn_min, &
        pot_iz, &
        pardiss_coeff_dens, &
        pardiss_coeff_parmom, &
        pardiss_coeff_pressure, &
        rcy_coeff, &
        evolve_pressure, &
        apply_neumann_mirror, &
        gas_puff_on, &
        gas_puff_path, &
        src_rcy_temp, &
        cx_cooling_thresh, &
        cx_cooling_thresh_min, &
        diff_co_smoothing
    private neut_model

contains

   subroutine read_params_neut_model(filename)
        !! Reads parameters related with neutrals model
        character(len=*), intent(in) :: filename
        !! Filename, to read from

        integer :: io_unit, io_error
        character(len=256) :: io_errmsg

        open(newunit=io_unit, file=filename, status='old', action='read', &
            iostat=io_error, iomsg=io_errmsg)
        if (io_error /= 0) then
            call handle_error(io_errmsg, GRILLIX_ERR_NAMELIST, &
                              __LINE__, __FILE__)
        endif

        read(io_unit, nml=neut_model, iostat=io_error, iomsg=io_errmsg)
        if (io_error /= 0) then
            call handle_error(io_errmsg, GRILLIX_ERR_NAMELIST, &
                              __LINE__, __FILE__)
        endif

        close(io_unit)

    end subroutine

    subroutine write_params_neut_model(filename)
        !! Reads parameters related with neutrals model
        character(len=*), intent(in), optional :: filename
        !! If present, filename where params are written to,
        !! if not present, writes to screen

        integer :: io_unit, io_error
        character(len=256) :: io_errmsg

        if (present(filename)) then
            open(newunit=io_unit, file=filename, status='unknown', &
                access='append', action='write', &
                iostat=io_error, iomsg=io_errmsg )
            if (io_error /= 0) then
                call handle_error(io_errmsg, GRILLIX_ERR_NAMELIST, &
                                  __LINE__, __FILE__)
            endif
        else
            io_unit = get_stdout()
        endif

        write(io_unit, nml=neut_model, iostat=io_error, iomsg=io_errmsg)
        if (io_error /= 0) then
            call handle_error(io_errmsg, GRILLIX_ERR_NAMELIST, &
                              __LINE__, __FILE__)
        endif

        if (present(filename)) then
            close(io_unit)
        endif

    end subroutine

end module