Introduction
This page provides examples of code blocks that may be used to define physical variable laws.
- Warning
It is forbidden to modify turbulent viscosity visct
here (a specific subroutine is dedicated to that: usvist)
- icp = 1 must have been specified in usipsu if we wish to define a variable specific heat cpro_cp (otherwise: memory overwrite).
- the kivisl field integer key (diffusivity_id) must have been specified in usipsu if we wish to define a variable viscosity
viscls
.
- Warning
- : if the scalar is the temperature, cpro_vscalt corresponds to its conductivity (Lambda) in W/(m K)
The types of boundary faces at the previous time step are available (except at the first time step, where arrays itypfb
and itrifb
have not been initialized yet)
It is recommended to keep only the minimum necessary in this file (i.e. remove all unused example code)
Molecular viscosity varying with temperature
The values of the molecular viscosity are provided as a function of the temperature. All variables are evaluated at the cell centers.
Here is the corresponding code:
ivart = isca(itempk)
call field_get_val_s(ivarfl(ivart), cvar_scalt)
call field_get_val_s(iviscl, cpro_viscl)
varam = -3.4016d-9
varbm = 6.2332d-7
varcm = -4.5577d-5
vardm = 1.6935d-3
do iel = 1, ncel
xvart = cvar_scalt(iel)
cpro_viscl(iel) = xvart*(xvart*(varam*xvart+varbm)+varcm)+vardm
enddo
Molecular volumetric viscosity varying with temperature
The values of the molecular volumetric viscosity are provided as a function of the temperature. All variables are evaluated at the cell centers.
Here is the corresponding code:
ivart = isca(itempk)
call field_get_val_s(ivarfl(ivart), cvar_scalt)
if (iviscv.ge.0) then
call field_get_val_s(iviscv, cpro_viscv)
else
cpro_viscv => null()
endif
if (iviscv.lt.0) then
write(nfecra,2000) iviscv
call csexit (1)
endif
varam = -3.4016d-9
varbm = 6.2332d-7
varcm = -4.5577d-5
vardm = 1.6935d-3
do iel = 1, ncel
xvart = cvar_scalt(iel)
cpro_viscv(iel) = xvart*(xvart*(varam*xvart+varbm)+varcm)+vardm
enddo
Isobaric specific heat varying with temperature
The values of the isobaric specific heat values are provided as a function of the temperature. All variables are evaluated at the cell centers.
- Warning
- : do not discard the call to the subroutine 'usthht' at the end of this example: its purpose is to calculate the isochoric specific heat. Indeed, this variable needs to be computed from the isobaric specific heat using the thermodynamics laws.
Here is the corresponding code:
ivart = isca(itempk)
call field_get_val_s(ivarfl(ivart), cvar_scalt)
if (icp.ge.0) call field_get_val_s(icp, cpro_cp)
if (icp.lt.0) then
write(nfecra,1000) icp
call csexit (1)
endif
if (icv.lt.0) then
write(nfecra,1001) icv
call csexit (1)
endif
varac = 0.00001d0
varbc = 1000.0d0
do iel = 1, ncel
xvart = cvar_scalt(iel)
cpro_cp(iel) = varac*xvart + varbc
enddo
call field_get_val_s(icv, cpro_cv)
call field_get_val_s(igmxml, mix_mol_mas)
Molecular thermal conductivity varying with temperature
The values of the molecular thermal conductivity are provided as a function of the temperature. All variables are evaluated at the cell centers.
Here is the corresponding code:
ivart = isca(itempk)
call field_get_val_s(ivarfl(ivart), cvar_scalt)
call field_get_key_int(ivarfl(isca(itempk)), kivisl, ifcvsl)
if (ifcvsl.ge.0) then
call field_get_val_s(ifcvsl, cpro_vtmpk)
else
cpro_vtmpk => null()
endif
if (ifcvsl.lt.0) then
write(nfecra,1010) itempk
call csexit (1)
endif
varal = -3.3283d-7
varbl = 3.6021d-5
varcl = 1.2527d-4
vardl = 0.58923d0
do iel = 1, ncel
xvart = cvar_scalt(iel)
cpro_vtmpk(iel) = (xvart*(xvart*(varal*xvart+varbl)+varcl)+vardl)
enddo
Molecular diffusivity of user-defined scalars varying with temperature
The molecular diffusivity can be set for all the user-defined scalars except:
- temperature and enthalpy (already dealt with above: for these variables, the 'diffusivity' is the thermal conductivity)
- variances of the fluctuations of another scalar variable (the diffusivity is assumed to be equal to that of the associated scalar) The values of the molecular diffusivity are provided as a function of the temperature. All variables are evaluated at the cell centers.
Here is the corresponding code:
do iscal = 1, nscaus
ith = 0
if (iscal.eq.itempk) ith = 1
if (ith.eq.0.and.iscavr(iscal).le.0) then
ivart = isca(itempk)
call field_get_val_s(ivarfl(ivart), cvar_scalt)
call field_get_key_int(ivarfl(isca(iscal)), kivisl, ifcvsl)
if (ifcvsl.ge.0) then
call field_get_val_s(ifcvsl, cpro_vscal)
else
cpro_vscal => null()
endif
if (ifcvsl.lt.0) then
write(nfecra,1010) iscal
call csexit (1)
endif
varal = -3.3283d-7
varbl = 3.6021d-5
varcl = 1.2527d-4
vardl = 0.58923d0
do iel = 1, ncel
xvart = cvar_scalt(iel)
cpro_vscal(iel) = (xvart*(xvart*(varal*xvart+varbl)+varcl)+vardl)
enddo
endif
enddo