<commit_before>! a simple gamma-law equation of state
! p = rho e (gamma - 1)
module eos_module

  use datatypes_module
  use params_module, only: gamma
  implicit none

  integer, parameter :: eos_input_p = 1
  integer, parameter :: eos_input_e = 2

contains

  subroutine eos(input, p, e, rho)
    
    integer,          intent(in   ) :: input
    real (kind=dp_t), intent(inout) :: p
    real (kind=dp_t), intent(inout) :: e
    real (kind=dp_t), intent(in   ) :: rho

    if (input == eos_input_p) then

       if (p < 0.0_dp_t) then
          print *, 'ERROR: input pressure < 0 in EOS'
          stop
       endif

       e = p / (rho * (gamma - 1.0_dp_t))

    else if (input == eos_input_e) then

       if (e < 0.0_dp_t) then
          print *, 'ERROR: input internal energy < 0 in EOS'
          stop
       endif

       p = rho*e*(gamma - 1.0_dp_t)

    endif

  end subroutine eos

end module eos_module<commit_msg>add a mode to do e,p as inputs<commit_after>! a simple gamma-law equation of state
! p = rho e (gamma - 1)
module eos_module

  use datatypes_module
  use params_module, only: gamma
  implicit none

  integer, parameter :: eos_input_p = 1
  integer, parameter :: eos_input_e = 2
  integer, parameter :: eos_input_pe = 3

contains

  subroutine eos(input, p, e, rho)
    
    integer,          intent(in   ) :: input
    real (kind=dp_t), intent(inout) :: p
    real (kind=dp_t), intent(inout) :: e
    real (kind=dp_t), intent(inout) :: rho

    if (input == eos_input_p) then

       if (p < 0.0_dp_t) then
          print *, 'ERROR: input pressure < 0 in EOS'
          stop
       endif

       e = p / (rho * (gamma - 1.0_dp_t))

    else if (input == eos_input_e) then

       if (e < 0.0_dp_t) then
          print *, 'ERROR: input internal energy < 0 in EOS'
          stop
       endif

       p = rho*e*(gamma - 1.0_dp_t)

    else if (input == eos_input_pe) then

       ! pressure and energy are inputs -- return density
       if (e < 0.0_dp_t .or. p < 0.0_dp_t) then
          print *, 'ERROR: input internal energy or pressure < 0 in EOS'
          stop
       endif

       rho = p/e/(gamma - 1.0_dp_t)

    else
       print *, 'ERROR: invalid input in EOS'
       stop
    endif

  end subroutine eos

end module eos_module
{'fraction_non_alphanumeric': 0.10317460317460317, 'fraction_numerical': 0.014991181657848324, 'mean_word_length': 2.099726775956284, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2661112', 'n_tokens_mistral': 860, 'n_tokens_neox': 797, 'n_words': 256}