!Reference parameters
MODULE moduleRefParam
  !Parameters that define the problem (inputs)
  REAL(8):: n_ref, m_ref, T_ref, r_ref, debye_ref, sigmaVrel_ref
  !Reference parameters for non-dimensional problem
  REAL(8):: L_ref, v_ref, ti_ref, Vol_ref, EF_ref, Volt_ref, B_ref

  contains
    subroutine calculateDerivedRef()
      use moduleConstParam, only: pi, qe, eps_0, kb
      implicit none
      
      !Derived parameters
      L_ref     = DSQRT(kb*T_ref*eps_0/n_ref)/qe !reference length
      v_ref     = DSQRT(kb*T_ref/m_ref)          !reference velocity
      ti_ref    = L_ref/v_ref                    !reference time
      Vol_ref   = L_ref**3                       !reference volume
      EF_ref    = qe*n_ref*L_ref/eps_0           !reference electric field
      Volt_ref  = EF_ref*L_ref                   !reference voltage
      B_ref     = m_ref / (ti_ref * qe)          !reference magnetic field

      if (sigmaVrel_ref == 0.0d0) then
        ! No reference cross section provided, check radius
        if (r_ref == 0.0d0) then
          ! No reference radius provided, use reference length
          sigmaVrel_ref = L_ref**2 * v_ref

        else
            sigmaVrel_ref = pi*(r_ref+r_ref)**2*v_ref !reference cross section times velocity

        end if

      end if

    end subroutine calculateDerivedRef

END MODULE moduleRefParam

