Heated Square Cavity Tutorial Solution

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
CyprienR
Posts: 4
Joined: Wed Mar 16, 2022 10:02 am

Heated Square Cavity Tutorial Solution

Post by CyprienR »

Hi Yvan,

I have been trying to follow the Heated Square Cavity Tutorial and recreating the same results for few weeks now and I am still having issues getting the same velocity plot as in the PDF:
https://www.code-saturne.org/cms/web/si ... tyFlow.pdf

I am using Code Saturne 7.0.4
I think the problem is probably in my cs_user_physical_properties.c file

This is the routine I used:

Code: Select all

void
cs_user_physical_properties2(cs_domain_t   *domain, 
				cs_real_t t[])
{
  CS_NO_WARN_IF_UNUSED(domain);

  /* Check fields exists */
  if (CS_F_(lambda) == NULL)
    bft_error(__FILE__, __LINE__, 0,_("error lambda not variable\n"));
  if (CS_F_(rho) == NULL)
    bft_error(__FILE__, __LINE__, 0,_("error rho not variable\n"));
  if (CS_F_(cp) == NULL)
    bft_error(__FILE__, __LINE__, 0,_("error cp not variable\n"));

  cs_real_t *cpro_lambda = CS_F_(lambda)->val;
  cs_real_t *cpro_rho = CS_F_(rho)->val;
  cs_real_t *cpro_cp = CS_F_(cp)->val;
  cs_real_t *cpro_mu = CS_F_(mu)->val;
  cs_real_t *cpro_beta;
  
  cs_real_t vara=1000000; /* Rayleigh number */
  cs_real_t varb=1; /* Width between the plates */
  cs_real_t varc=10;  /* \Delta T= Th-Tc  */
  
  cs_real_t rho0= cpro_rho[0];/* 1.2039 */
  cs_real_t Cp0= cpro_cp[0]; /* 1004.84 */
  cs_real_t t0= 293.15; /* 293.15 */
  cs_real_t mu0= cpro_mu[0]; /* 1.83e-5 */
  cs_real_t gz= 9.81; 

  /* Impose thermal conductivity, density and specific heat for solid zones */
  {
    /* Volume zone "CM" must be defined in the GUI or in cs_user_zones.c */
    const cs_zone_t *z = cs_volume_zone_by_name("CM");

    for (cs_lnum_t i = 0; i < z->n_elts; i++) {
      cs_lnum_t cell_id = z->elt_ids[i];
            
      cpro_beta[cell_id] = cpro_lambda[cell_id]*mu0*vara/(pow(rho0,2)*Cp0*abs(gz)*varc*pow(varb,3));
      cpro_rho[cell_id] = rho0 - rho0*cpro_beta[cell_id]*(t[cell_id]-t0);

    }
  }
}
Could you let me know if you see some obvious mistake?

Thank you!

I also attach my whole case study with the Mesh, the XML and everything else.

Cyprien
Attachments
heated_cavity.zip
(1.08 MiB) Downloaded 60 times
CyprienR
Posts: 4
Joined: Wed Mar 16, 2022 10:02 am

Re: Heated Square Cavity Tutorial Solution

Post by CyprienR »

I realised that the answer of this tutorial is available on Github here

Here is the link for those who have some difficulties to find it:
https://github.com/code-saturne/saturne ... are_Cavity
Post Reply