Pressure drop definition

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
JonasA
Posts: 18
Joined: Tue Feb 06, 2018 11:49 am

Pressure drop definition

Post by JonasA »

Hello,

I'm using code_Saturne 5.08 to simulate a pump.
I try using the functionality pressure drop definition in Calculation control > balance by zone.

It gives me a result, but I have not found in the user guide how to interpret it.

For example I have

Code: Select all

   ** PRESSURE DROP BY ZONE at iteration   1322
   ---------------------------------------------
------------------------------------------------------------
   ZONE SELECTION CRITERIA: "Rotor"
------------------------------------------------------------
  |                 |
  | p u . dS        | p u . dS
  |   -    -        |   -    -
  |                 |
  | inlet           | outlet
    7.2164e+04        4.1888e+04
------------------------------------------------------------
  |                 |
  | u^2/2 rho u . dS| u^2/2 rho u . dS
  | -         -    -| -         -    -
  |                 |
  | inlet           | outlet
   -6.0111e+04        7.8428e+04
------------------------------------------------------------
  |                 |
  |-rho(g . x)u . dS|-rho(g . x)u . dS
  |     -   - -    -|     -   - -    -
  |                 |
  | inlet           | outlet
    6.9678e+01        4.6571e+01
------------------------------------------------------------
  |                 |
  | u . dS          | u . dS
  | -    -          | -    -
  |                 |
  | inlet           | outlet
   -4.2756e+00        4.2756e+00
------------------------------------------------------------
  |                 |
  | rho u . dS      | rho u . dS
  |     -    -      |     -    -
  |                 |
  | inlet           | outlet
   -8.6275e+01        8.6275e+01
------------------------------------------------------------
So my questions are: what are the units, and what are the different field? I assume that inlet is when the flow goes in the volume and outlet when the flow is out.


Best regards
Jonas
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Pressure drop definition

Post by Yvan Fournier »

Hello,

Yes, inlet and outlet are as you guessed. The units are all international system units (meters, Pascals, ...).

The documentation could be improved I guess...

Regards,

Yvan
JonasA
Posts: 18
Joined: Tue Feb 06, 2018 11:49 am

Re: Pressure drop definition

Post by JonasA »

Thank you Ivan,

but I still do not get exactly what each of it means

For example, is p u dS the integral of the the pressure multiply by the velocity on the surface? Or only the integral of the pressure.

Is u .dS the volumetric flow rate? And rho u dS the mass flow rate?

I'd love to have a pressure drop in manometric head *(maybe in a future version)

best regards,
Jonas

*h=x + \frac{v^2}{2g} + \frac{p}{\rho g}
JonasA
Posts: 18
Joined: Tue Feb 06, 2018 11:49 am

Re: Pressure drop definition

Post by JonasA »

I have tried to add the manometric head to the variable that are written for the post processing.

I have 2 problems:

I have not manage to get access to the position of the center of the cell so the head will lack the height in the expression.

And the computation crash whenever the writer is called (checked by changing the times at which the post processing writing is done)
in cs_user_postprocess.c

Code: Select all

void
cs_user_postprocess_values(const char            *mesh_name,
                           int                    mesh_id,
                           int                    cat_id,
                           cs_probe_set_t        *probes,
                           cs_lnum_t              n_cells,
                           cs_lnum_t              n_i_faces,
                           cs_lnum_t              n_b_faces,
                           cs_lnum_t              n_vertices,
                           const cs_lnum_t        cell_list[],
                           const cs_lnum_t        i_face_list[],
                           const cs_lnum_t        b_face_list[],
                           const cs_lnum_t        vertex_list[],
                           const cs_time_step_t  *ts)
{

  /* Output of the manometric head
  h= x + v^2/2g + p/rho g
     ------------------------------------------------------ */

  /*< [postprocess_values_ex_1] */

    cs_real_t *s_cell;
    BFT_MALLOC(s_cell, n_cells, cs_real_t);

    const cs_real_t *rho = CS_F_(rho)->val;
    const cs_real_3_t *u = (cs_real_3_t *)CS_F_(u)->val;
    const cs_real_t *p = CS_F_(p)->val;
    //cs_real_t *xyzcen =  mesh_quantities->cell_cen;
    // The height is lacking!!!!
      for (cs_lnum_t i = 0; i < n_cells; i++) {
        cs_lnum_t cell_id = cell_list[i];
        s_cell[i] =   (      (u[cell_id][0]*u[cell_id][0]+u[cell_id][1]*u[cell_id][1]+u[cell_id][2]*u[cell_id][2])/(2*9.81)
                          + p[cell_id]/rho[cell_id]/9.81 );
      }
    

    cs_post_write_var(mesh_id,
                      CS_POST_WRITER_ALL_ASSOCIATED,  /* writer id filter */
                      "Head",                  /* var_name */
                      1,                              /* var_dim */
                      true,                           /* interlace, */
                      false,                          /* use_parent */
                      CS_POST_TYPE_cs_real_t,         /* var_type */
                      s_cell,                         /* cel_vals */
                      NULL,                           /* i_face_vals */
                      NULL,                           /* b_face_vals */
                      ts);

    BFT_FREE(s_cell);
  
  /*< [postprocess_values_ex_1] */
}
The code compile well, but sigsev when called.
Signal SIGSEGV (accès à une zone mémoire interdite) intercepté !

Pile d'appels :
1: 0x7f8c0b35412b <fvm_convert_array+0x66b> (libsaturne.so.5)
2: 0x7f8c0b17cc9a <fvm_writer_field_helper_output_e+0x5ca> (libsaturne.so.5)
3: 0x7f8c0b172621 <fvm_to_ensight_export_field+0x4f1> (libsaturne.so.5)
4: 0x7f8c0b17a3f7 <fvm_writer_export_field+0xd7> (libsaturne.so.5)
5: 0x7f8c0b239893 <cs_post_write_var+0x373> (libsaturne.so.5)
6: 0x557807d63286 <cs_user_postprocess_values+0x226> (cs_solver)
7: 0x7f8c0b23ea7c <cs_post_time_step_output+0xccc> (libsaturne.so.5)
8: 0x7f8c0b23f561 <cs_post_write_vars+0x11> (libsaturne.so.5)
9: 0x7f8c0b196e4e <caltri_+0x10b0> (libsaturne.so.5)
10: 0x7f8c0b16accd <cs_run+0x55d> (libsaturne.so.5)
11: 0x7f8c0b16a625 <main+0x125> (libsaturne.so.5)
12: 0x7f8c083572e1 <__libc_start_main+0xf1> (libc.so.6)
13: 0x557807d62f2a <_start+0x2a> (cs_solver)
Fin de la pile
Does anyone know how to write the writer call correctly and to access cell position in cs_user_postprocess_values()?

Best Regards,
Jonas
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Pressure drop definition

Post by Yvan Fournier »

Hello,

Any example accessing cell position in tje C Doxygen examples should do.

You probably have uninitialized variables in your code.

Use cs_glob_mesh_quantities->cell_cell
for cell centers.

Regards,

Yvan
JonasA
Posts: 18
Joined: Tue Feb 06, 2018 11:49 am

Re: Pressure drop definition

Post by JonasA »

Thanks,

I have done the changes and now it works.

Code: Select all

void
cs_user_postprocess_values(const char            *mesh_name,
                           int                    mesh_id,
                           int                    cat_id,
                           cs_probe_set_t        *probes,
                           cs_lnum_t              n_cells,
                           cs_lnum_t              n_i_faces,
                           cs_lnum_t              n_b_faces,
                           cs_lnum_t              n_vertices,
                           const cs_lnum_t        cell_list[],
                           const cs_lnum_t        i_face_list[],
                           const cs_lnum_t        b_face_list[],
                           const cs_lnum_t        vertex_list[],
                           const cs_time_step_t  *ts)
{

  /* Output of the manometric head
  h= x + v^2/2g + p/rho g
  and the piezometric head
  h = x + p/rho g
     ------------------------------------------------------ */

  if (cat_id == CS_POST_MESH_VOLUME) {
       // mesh quantities to get the height  
       const cs_mesh_quantities_t *mq = cs_glob_mesh_quantities;
       const cs_real_3_t *restrict cell_cen = (const cs_real_3_t *restrict)mq->cell_cen;
       cs_real_t *s_cell;
       cs_real_t *s2_cell;
       BFT_MALLOC(s_cell, n_cells, cs_real_t);
       BFT_MALLOC(s2_cell, n_cells, cs_real_t);

       const cs_real_t *rho = CS_F_(rho)->val;
       const cs_real_3_t *u = (cs_real_3_t *)CS_F_(u)->val;
       const cs_real_t *p = CS_F_(p)->val;
       // In my study, the height was on the y-axis and the gravity acceleration was 9.81m/s/s
       // You have to change manualy the folowing line
         for (cs_lnum_t i = 0; i < n_cells; i++) {
   	    cs_lnum_t cell_id = cell_list[i];
          	s_cell[i] =   (   cell_cen[cell_id][1] // height
   			       +  (u[cell_id][0]*u[cell_id][0]+u[cell_id][1]*u[cell_id][1]+u[cell_id][2]*u[cell_id][2])/(2*9.81) // kinetic energy
   			       + p[cell_id]/rho[cell_id]/9.81 ); // Pressure head
          	s2_cell[i] =   (   cell_cen[cell_id][1] // height
   			       + p[cell_id]/rho[cell_id]/9.81 ); // Pressure head
         }
       

       // Both value are in meter
       cs_post_write_var(mesh_id,
   		      CS_POST_WRITER_ALL_ASSOCIATED,  /* writer id filter */
   		      "Manometric_head",                  /* var_name */
   		      1,                              /* var_dim */
   		      true,                           /* interlace, */
   		      false,                          /* use_parent */
   		      CS_POST_TYPE_cs_real_t,         /* var_type */
   		      s_cell,                         /* cel_vals */
   		      NULL,                           /* i_face_vals */
   		      NULL,                           /* b_face_vals */
   		      ts);

       cs_post_write_var(mesh_id,
   		      CS_POST_WRITER_ALL_ASSOCIATED,  /* writer id filter */
   		      "Piezometric_head",                  /* var_name */
   		      1,                              /* var_dim */
   		      true,                           /* interlace, */
   		      false,                          /* use_parent */
   		      CS_POST_TYPE_cs_real_t,         /* var_type */
   		      s2_cell,                         /* cel_vals */
   		      NULL,                           /* i_face_vals */
   		      NULL,                           /* b_face_vals */
   		      ts);
       BFT_FREE(s_cell);
       BFT_FREE(s2_cell);
  }
}
It computes both the piezometric and the manometric head and write them in the output.

Regards,
Jonas
Luciano Garelli
Posts: 280
Joined: Fri Dec 04, 2015 1:42 pm

Re: Pressure drop definition

Post by Luciano Garelli »

Hello,

In the following pdf (pag. 21) you can find some additional information about the terms involved in the pressure drop definition.

https://www.code-saturne.org/cms/sites/ ... tion-2017

Regards,

Luciano
Post Reply