Page 1 of 1

Apply ideal gas law for incompressible solver

Posted: Fri Dec 10, 2021 4:21 pm
by Ruonan
Dear developers,

Could you please help me with this question?

Following the heated square cavity tutorial, I used Boussinesq approximation, make density change with temperature. Now I want to make density change with both pressure and temperature, that is the ideal gas law, rho=P/(R*T). I think this may be more accurate than the Boussinesq.

But in the subroutine cs_user_physical_properties.f90, I don't know how to call variable "pressure". The code is shown below, with the part ***Pressure*** that cannot work now and need to be changed.

Code: Select all

  if (iscalt.gt.0) then
    ivart = isca(iscalt)
    call field_get_val_s(ivarfl(ivart), cvar_scalt)
  else
    write(nfecra,9010) iscalt
    call csexit (1)
  endif

  ! --- Pointers to density values

  call field_get_val_s(icrom, cpro_rom)
  call field_get_val_s(ibrom, bfpro_rom)

  call field_get_val_s(iprpfl(ibeta), cpro_beta)

  
  do iel = 1, ncel
    xvart = cvar_scalt(iel)
    cpro_rom(iel) = ***Pressure***/(287.0d0*xvart)
  enddo
Thanks a lot for your help!

Best regards,
Ruonan

Re: Apply ideal gas law for incompressible solver

Posted: Sat Dec 11, 2021 8:04 pm
by Yvan Fournier
Hello,

The following page from the documentation should help you find how to access the pressure variable: https://www.code-saturne.org/documentat ... _dico.html

Best regards,

Yvan

Re: Apply ideal gas law for incompressible solver

Posted: Mon Jan 10, 2022 4:27 pm
by Ruonan
Dear Yvan,

Thanks a lot for your help. I coded the ideal gas law into cs_user_physical_properties.f90 and got good results. The code is attached below.

Many thanks,
Ruonan

Code: Select all

call field_get_val_s(icrom, cpro_crom)
call field_get_val_s(iprtot, cpro_prtot)
call field_get_val_s(ivarfl(isca(iscalt)), cvar_scalt)

varam = 287.0d0

do iel = 1, ncel
  xvart = cvar_scalt(iel)
  prestot = cpro_prtot(iel)
  cpro_crom(iel) = (prestot)/(varam*xvart)
enddo