Apply ideal gas law for incompressible solver

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
Ruonan
Posts: 136
Joined: Mon Dec 14, 2020 11:38 am

Apply ideal gas law for incompressible solver

Post 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
Yvan Fournier
Posts: 4220
Joined: Mon Feb 20, 2012 3:25 pm

Re: Apply ideal gas law for incompressible solver

Post 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
Ruonan
Posts: 136
Joined: Mon Dec 14, 2020 11:38 am

Re: Apply ideal gas law for incompressible solver

Post 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
Post Reply