diagnostics_braginskii_m.f90 Source File


Contents


Source Code

module diagnostics_braginskii_m
    !! Wrapper for BRAGINSKII model diagnostics
    !! Note: The whole diagnostics framework only works foar axisymmetric equilibria
    use comm_handler_m, only : comm_handler_t
    use error_handling_grillix_m, only: handle_error
    use status_codes_grillix_m, only : GRILLIX_ERR_OTHER
    use precision_grillix_m, only : GP
    use screen_io_m, only :  get_stdout
    use parallelisation_setup_m, only : is_rank_info_writer
    use variable_m, only : variable_t
    use gyroviscosity_m, only : gyroviscosity_t

    use equilibrium_m, only: equilibrium_t
    use equilibrium_storage_m, only : equilibrium_storage_t
    use mesh_cart_m, only: mesh_cart_t
    use parallel_map_m, only : parallel_map_t
    use polars_m, only : polars_t
    use penalisation_m, only : penalisation_t
    use inplane_operators_m, only : inplane_operators_t
    use sources_external_m, only : sources_external_t
    use parallel_target_flux_m, only : parallel_target_flux_t
    use perp_bnd_flux_m, only : perp_bnd_flux_t
    use multistep_m, only : multistep_storage_t
    use boundaries_braginskii_m, only : boundaries_braginskii_t
    use boundaries_neutrals_m, only : boundaries_neutrals_t
    use checkpoint_monitor_m, only : checkpoint_monitor_t
    use diagnostics_scalar_m, only : diagnostics_scalar_t
    use diagnostics_zonal_m, only : diagnostics_zonal_t
    use diagnostics_lineout_m, only : diagnostics_lineout_t
    use diagnostics_field_m, only : diagnostics_field_t
    use diagnostics_packet_m, only : diagnostics_packet_t
    use perf_m, only : perf_start, perf_stop

    ! Parameters
    use params_feature_selection_m, only : &
        scalar_diagnostics_on, zonal_diagnostics_on, &
        lineout_diagnostics_on, field_diagnostics_on, analyse_snapshots_on
    use params_tstep_m, only : &
        dtau, tau_snaps, tau_diags
        
    implicit none
    
    type, public :: diagnostics_braginskii_t
        !! Wrapper type containing diagnostic groups
        type(diagnostics_scalar_t), public :: scalar
        !! Scalar diagnostics group
        type(diagnostics_zonal_t), public :: zonal
        !! Zonal diagnostics group
        type(diagnostics_lineout_t), public :: lineout
        !! Lineout diagnostics group
        type(diagnostics_field_t), public :: field
        !! Field diagnostics type
        integer, private :: idiag
        !! Internal diagnostic step counter
        type(multistep_storage_t), private :: multistep_storage_cano
        !! Multistep storage for diagnostics (canonical)
        type(multistep_storage_t), private :: multistep_storage_stag
        !! Multistep storage for diagnostics (staggered)
        type(checkpoint_monitor_t), public :: clock
        !! Internal checkpoint monitor for computing and writing diagnostics

    contains
        procedure, public :: init => init_diagnostics
        procedure, public :: drive => drive_diagnostics
    end type
    
    interface

        module subroutine init_diagnostics(self, comm_handler, filepath_lineout, equi, &
                                    mesh_cano, mesh_stag, polars_cano, polars_stag, tau, &
                                    isnaps, ne, te, ti, pot, upar, jpar, apar, apar_fluct, &
                                    neutrals_dens, neutrals_parmom, neutrals_pressure)
            !! Initialize diagnostic
            class(diagnostics_braginskii_t), intent(inout) :: self
            !! Instance of class
            type(comm_handler_t), intent(in) :: comm_handler
            !! MPI communication handler
            character(len=*), intent(in) :: filepath_lineout
            !! Filepath to read lineout diagnostics parameters from
            class(equilibrium_t), intent(in) :: equi
            !! Magnetic equilibrium
            type(mesh_cart_t), intent(in) :: mesh_cano
            !! Mesh (canonical) within poloidal plane
            type(mesh_cart_t), intent(in) :: mesh_stag
            !! Mesh (staggered) within poloidal plane
            type(polars_t), intent(in) :: polars_cano
            !! Polars (canonical)
            type(polars_t), intent(in) :: polars_stag
            !! Polars (staggered)
            real(GP), intent(in) :: tau
            !! Time
            integer, intent(in) :: isnaps
            !! Braginskii snapshot counter
            type(variable_t), intent(in) :: ne
            !! Electron density
            type(variable_t), intent(in) :: te
            !! Electron temperature
            type(variable_t), intent(in) :: ti
            !! Ion temperature
            type(variable_t), intent(in) :: pot
            !! Electrostatic potential
            type(variable_t), intent(in) :: upar
            !! Paralle velocity
            type(variable_t), intent(in) :: jpar
            !! Parallel current
            type(variable_t), intent(in) :: apar
            !! Electromagnetic potential
            type(variable_t), intent(in) :: apar_fluct
            !! Electromagnetic potential fluctuation
            type(variable_t), intent(in) :: neutrals_dens
            !! Neutrals density
            type(variable_t), intent(in) :: neutrals_parmom
            !! Neutrals parallel momentum
            type(variable_t), intent(in) :: neutrals_pressure
            !! Neutrals pressure
        end subroutine

        module subroutine drive_diagnostics(self, comm_handler, equi, equi_on_cano, equi_on_stag, mesh_cano, &
                                    mesh_stag, map, penalisation_cano, penalisation_stag, polars_cano, polars_stag, &
                                    parflux_utils_cano, parflux_utils_stag, perp_bnd_flux_cano, perp_bnd_flux_stag, &
                                    opsinplane_cano, opsinplane_stag, boundaries, boundaries_neutrals, & 
                                    cf_buffer_cano, cf_buffer_stag, cf_diss_cano, cf_diss_stag, isnaps, tau, &
                                    ne, te, ti, pot, vort, upar, jpar, apar, apar_fluct, gstress, &
                                    neutrals_dens, neutrals_parmom, neutrals_pressure, &
                                    src_ne, src_te, src_ti, src_upar, src_vort, &
                                    sources_external)
            !! Main diagnostics routine
            class(diagnostics_braginskii_t), intent(inout) :: self
            !! Instance of class
            type(comm_handler_t), intent(in) :: comm_handler
            !! MPI communication handler
            class(equilibrium_t), intent(inout) :: equi
            !! Magnetic equilibrium
            class(equilibrium_storage_t), intent(in) :: equi_on_cano
            !! Equilibrium storage on canonical plane enabling faster performance at certain locations
            class(equilibrium_storage_t), intent(in) :: equi_on_stag
            !! Equilibrium storage on staggered plane enabling faster performance at certain locations
            type(mesh_cart_t), intent(in) :: mesh_cano
            !! Mesh (canonical) within poloidal plane
            type(mesh_cart_t), intent(in) :: mesh_stag
            !! Mesh (staggered) within poloidal plane
            type(parallel_map_t), intent(in) :: map
            !! Parallel map 
            type(penalisation_t), intent(in) :: penalisation_cano
            !! Penalisation (canonical)
            type(penalisation_t), intent(in) :: penalisation_stag
            !! Penalisation (staggered)
            type(polars_t), intent(in) :: polars_cano
            !! Polar grid and operators (canonical)
            type(polars_t), intent(in) :: polars_stag
            !! Polar grid and operators (staggered)
            type(parallel_target_flux_t), intent(in) :: parflux_utils_cano
            !! Parallel target flux utility (canonical)
            type(parallel_target_flux_t), intent(in) :: parflux_utils_stag
            !! Parallel target flux utility (staggered)
            type(perp_bnd_flux_t), intent(in) :: perp_bnd_flux_cano
            !! Perpendicular boundary flux utility (canonical)
            type(perp_bnd_flux_t), intent(in) :: perp_bnd_flux_stag
            !! Perpendicular boundary flux utility (staggered)
            type(inplane_operators_t), intent(inout) :: opsinplane_cano
            !! In-plane operators (canonical)
            type(inplane_operators_t), intent(inout) :: opsinplane_stag
            !! In-plane operators (staggered)
            type(boundaries_braginskii_t), intent(in) :: boundaries
            !! Boundary information for the Braginskii model
            type(boundaries_neutrals_t), intent(in) :: boundaries_neutrals
            !! Boundaries related with neutrals module
            real(GP), dimension(mesh_cano%get_n_points()), intent(in) :: cf_buffer_cano
            !! Buffer function (canonical)
            real(GP), dimension(mesh_stag%get_n_points()), intent(in) :: cf_buffer_stag
            !! Buffer function (staggered)
            real(GP), dimension(mesh_cano%get_n_points()), intent(in) :: cf_diss_cano
            !! Dissipation envelope function (canonical)
            real(GP), dimension(mesh_stag%get_n_points()), intent(in) :: cf_diss_stag
            !! Dissipation envelope function (staggered)
            integer, intent(in) :: isnaps
            !! Braginskii model snapshot number
            real(GP), intent(in) :: tau
            !! Time
            type(variable_t), intent(inout) :: ne 
            !! Electron density
            type(variable_t), intent(inout) :: te
            !! Electron temperature
            type(variable_t), intent(inout) :: ti
            !! Ion temperature
            type(variable_t), intent(inout) :: pot
            !! Electrostatic potential
            type(variable_t), intent(inout) :: vort
            !! Generalised vorticity
            type(variable_t), intent(inout) :: upar
            !! Parallel ion velocity
            type(variable_t), intent(inout) :: jpar
            !! Parallel current
            type(variable_t), intent(inout) :: apar
            !! Parallel electromagnetic potential
            type(variable_t), intent(inout) :: apar_fluct
            !! Parallel electromagnetic potential fluctation
            type(gyroviscosity_t), intent(inout) :: gstress
            !! Gyroviscosity
            type(variable_t), intent(inout) :: neutrals_dens
            !! Neutrals density
            type(variable_t), intent(inout) :: neutrals_parmom
            !! Neutrals parallel momentum
            type(variable_t), intent(inout) :: neutrals_pressure
            !! Neutrals pressure
            real(GP), dimension(mesh_cano%get_n_points_inner()), intent(in) :: src_ne
            !! Particle source values on inner mesh points
            real(GP), dimension(mesh_cano%get_n_points_inner()), intent(in) :: src_te
            !! Electron temperature source values on inner mesh points
            real(GP), dimension(mesh_cano%get_n_points_inner()), intent(in) :: src_ti
            !! Ion temperature source values on inner mesh points
            real(GP), dimension(mesh_cano%get_n_points_inner()), intent(in) :: src_upar
            !! Parallel momentum source values on inner mesh points
            real(GP), dimension(mesh_cano%get_n_points_inner()), intent(in) :: src_vort
            !! Vorticity source values on inner mesh points          
            type(sources_external_t), intent(inout) :: sources_external
            !! External sources
        end subroutine

    end interface

end module