params_brag_pardiss_model_m.f90 Source File


Contents


Source Code

module params_brag_pardiss_model_m
    !! Parameters for the BRAGINSKII model related with pardiss_model
    use precision_grillix_m, only : GP, GP_LARGE, 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

    character(len=64), protected :: heatflux_model = 'BRAGINSKII_LIM'
    !! Model for computation of heat flux
    !! BRAGINSKII_LIM: Brgainskii model, possibly with heat flux limiters
    !! FREE_STREAMING: free streaming model
    !! LANDAU: Landau-fluid model
    real(GP), protected :: free_streaming_limiter_qfac = GP_LARGE
    !! Safety factor in the free-streaming heat conductivity limiters
    !! (take e.g. q95), as well as in neocl. viscosity limiter
    logical, protected :: landau_flutter_lhs_on = .false.
    !! Switch for turning on electromagnic flutter in the helmholtz_solver

    real(GP), protected :: chipar0_e = GP_NAN
    !! Normalized Braginskii parallel electron heat conductivity
    real(GP), protected :: heatflux_cutoff_e = GP_LARGE
    !! Cut-off value for electron heat flux (heat flux limiter)
    real(GP), protected :: free_streaming_fraction_e = GP_LARGE
    !! Free-streaming parallel electron heat conductivity limiter
    logical, protected :: heatflux_timplicit_e =.true.
    !! Switch for implicit treatment of electron heat conduction
    integer, protected :: landau_numlorentzians_e = 7
    !! Number of lorentzians for the calculation of the electron heat flux
        
    real(GP), protected :: chipar0_i = GP_NAN
    !! Normalized Braginskii parallel ion heat conductivity
    real(GP), protected :: heatflux_cutoff_i = GP_LARGE
    !! Cut-off value for ion heat flux (heat flux limiter)
    real(GP), protected :: free_streaming_fraction_i = GP_LARGE
    !! Free-streaming parallel ion heat conductivity limiter
    logical, protected :: heatflux_timplicit_i =.true.
    !! Switch for implicit treatment of ion heat conduction
    integer, protected :: landau_numlorentzians_i = 7
    !! Number of lorentzians for the calculation of the ion heat flux
    
    real(GP), protected :: aspect_ratio_inv = 0.0_GP
    !! Inverse aspect ratio eps = a / R0, used in neocl. viscosity limiter
    logical, protected :: viscosity_timplicit_upar =.true.
    !! Switch for implicit treatment of parallel momentum dissipation
    
    public :: read_params_brag_pardiss_model
    public :: write_params_brag_pardiss_model

    namelist / brag_pardiss_model /   &
        heatflux_model, &
        chipar0_e, &
        heatflux_cutoff_e, &
        free_streaming_fraction_e, &
        chipar0_i, &
        heatflux_cutoff_i, &
        free_streaming_fraction_i, &
        free_streaming_limiter_qfac, &
        aspect_ratio_inv, &
        landau_numlorentzians_e, &
        landau_numlorentzians_i, &       
        landau_flutter_lhs_on, &
        heatflux_timplicit_e, &
        heatflux_timplicit_i, &
        viscosity_timplicit_upar
    private brag_pardiss_model

contains

   subroutine read_params_brag_pardiss_model(filename)
        !! Reads parameters related with brag_pardiss_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=brag_pardiss_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_brag_pardiss_model(filename)
        !! Reads parameters related with brag_pardiss_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=brag_pardiss_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